//---------------------------------------------------------------------------- Spatial* BspNode::GetContainingNode (const APoint& point) { SpatialPtr posChild = GetPositiveChild(); SpatialPtr negChild = GetNegativeChild(); if (posChild || negChild) { BspNode* bspChild; if (mWorldPlane.WhichSide(point) < 0) { bspChild = DynamicCast<BspNode>(negChild); if (bspChild) { return bspChild->GetContainingNode(point); } else { return negChild; } } else { bspChild = DynamicCast<BspNode>(posChild); if (bspChild) { return bspChild->GetContainingNode(point); } else { return posChild; } } } return this; }
Spatial* BspNode::GetContainingNode(Vector4<float> const& point) { std::shared_ptr<Spatial> posChild = GetPositiveChild(); std::shared_ptr<Spatial> negChild = GetNegativeChild(); if (posChild || negChild) { BspNode* bspChild; if (WhichSide(point) < 0) { bspChild = dynamic_cast<BspNode*>(negChild.get()); if (bspChild) { return bspChild->GetContainingNode(point); } else { return negChild.get(); } } else { bspChild = dynamic_cast<BspNode*>(posChild.get()); if (bspChild) { return bspChild->GetContainingNode(point); } else { return posChild.get(); } } } return this; }