diff options
Diffstat (limited to 'source/gameengine/SceneGraph')
-rw-r--r-- | source/gameengine/SceneGraph/SG_Node.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Node.h | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index 2436f6ecb55..706568fc3fe 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -150,6 +150,12 @@ GetRootSGParent( return (m_SGparent ? (const SG_Node*) m_SGparent->GetRootSGParent() : (const SG_Node*) this); } +bool SG_Node::IsAncessor(const SG_Node* child) const +{ + return (!child->m_SGparent) ? false : + (child->m_SGparent == this) ? true : IsAncessor(child->m_SGparent); +} + void SG_Node:: DisconnectFromParent( diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 78fa61c019e..5d2bac2b955 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -77,6 +77,13 @@ public: SG_Node* child ); + /** + * Return true if the node is the ancessor of child + */ + bool + IsAncessor( + const SG_Node* child + ) const; /** * Get the current list of children. Do not use this interface for * adding or removing children please use the methods of this class for |