예제 #1
0
    private bool DivideCheck(List <Vector3> _positions, Perlin _perlin, float _avg_density)
    {
        int count = 0;

        foreach (Vector3 pos in _positions)
        {
            // is this position within bounds of node
            if (pos.x >= transform.position.x && pos.x < (transform.position.x + size_x) &&
                pos.z >= transform.position.z && pos.z < (transform.position.z + size_z))
            {
                // What values are inthis area, so we can produce the correct density type
                average_density += _perlin.GetDensityType((int)pos.x, (int)pos.z);
                count++;
            }
        }

        average_density = average_density / count;

        if (average_density == 0)
        {
            average_density = _avg_density;
        }

        if (count >= divide_count)
        {
            return(true);
        }

        return(false);
    }