OctreeNode.GetNode C# (CSharp) Method

GetNode() public method

public GetNode ( float x, float y, float z, double shortestDistance ) : object
x float
y float
z float
shortestDistance double
return object
    public object GetNode(float x, float y, float z, double shortestDistance)
    {
        object closest = null;
        if (Branch == null)
        {
           // var childDistance = this.Bounds.BorderDistance(x, y, z);
            //if (childDistance > shortestDistance)
           //     return null;
            foreach (OctreeLeaf leaf in Items)
            {
                var distance = Math.Sqrt(
                    Math.Pow(x - leaf.X, 2.0) +
                    Math.Pow(y - leaf.Y, 2.0) +
                    Math.Pow(z - leaf.Z, 2.0));

                if (!(distance < shortestDistance)) continue;
                shortestDistance = distance;
                closest = leaf.LeafObject;
            }
            return closest;
        }
        // Check the distance of the bounds of the branch,
        // versus the bestDistance. If there is a boundary that
        // is closer, then it is possible that another node has an
        // object that is closer.
        foreach (OctreeNode t in Branch)
        {
            var childDistance = t.Bounds.BorderDistance(x, y, z);
            if (!(childDistance < shortestDistance)) continue;
            object test = t.GetNode(x, y, z, shortestDistance);
            if (test != null)
                closest = test;
        }
        return closest;
    }

Same methods

OctreeNode::GetNode ( OctreeBox, rect, ArrayList nodes ) : ArrayList
OctreeNode::GetNode ( float xMax, float xMin, float yMax, float yMin, float zMax, float zMin ) : ArrayList
OctreeNode::GetNode ( float xMax, float xMin, float yMax, float yMin, float zMax, float zMin, ArrayList nodes ) : ArrayList
OctreeNode::GetNode ( Vector3 vector ) : object
OctreeNode::GetNode ( Vector3 vector, double shortestDistance ) : object
OctreeNode::GetNode ( float x, float y, float z ) : object

Usage Example

Beispiel #1
0
 public object GetNode(float x, float y, float z)
 {
     return(Top.GetNode(x, y, z));
 }