protected void TagNodesWithObject( BspNode node, MovableObject obj, Vector3 pos )
{
if ( node.IsLeaf )
{
// Add to movable->node map
// Insert all the time, will get current if already there
objectToNodeMap.Add( obj, node );
node.AddObject( obj );
}
else
{
// Find distance to dividing plane
float dist = node.GetDistance( pos );
//CHECK: treat obj as bounding box?
if ( Utility.Abs( dist ) < obj.BoundingRadius )
{
// Bounding sphere crosses the plane, do both.
TagNodesWithObject( node.BackNode, obj, pos );
TagNodesWithObject( node.FrontNode, obj, pos );
}
else if ( dist < 0 )
{
// Do back.
TagNodesWithObject( node.BackNode, obj, pos );
}
else
{
// Do front.
TagNodesWithObject( node.FrontNode, obj, pos );
}
}
}