Game Development Reference
In-Depth Information
~BVHNode();
}
template<class BoundingVolumeClass>
BVHNode<BoundingVolumeClass>::~BVHNode<BoundingVolumeClass>()
{
// If we don't have a parent, then we ignore the sibling processing.
if (parent)
{
// Find our sibling.
BVHNode<BoundingVolumeClass> *sibling;
if (parent->children[0] == this) sibling = parent->children[1];
else sibling = parent->children[0];
// Write its data to our parent.
parent->volume = sibling->volume;
parent->body = sibling->body;
parent->children[0] = sibling->children[0];
parent->children[1] = sibling->children[1];
// Delete the sibling (we blank its parent and
// children to avoid processing/deleting them).
sibling->parent = NULL;
sibling->body = NULL;
sibling->children[0] = NULL;
sibling->children[1] = NULL;
delete sibling;
// Recalculate the parent's bounding volume.
parent->recalculateBoundingVolume();
}
// Delete our children (again we remove their parent data so
// we don't try to process their siblings as they are deleted).
if (children[0]) {
children[0]->parent = NULL;
delete children[0];
}
if (children[1]) {
children[1]->parent = NULL;
delete children[0];
}
}
Search Nedrilad ::




Custom Search