I found this thread looking for the same thing... just wanted to check nothing changed in the 1.5 years since that thread? Such functionality still doesn't exist in Ogre itself?
btw in this line I found the cast is not needed:
CODE: SELECT ALL
MovableObject* pObject = static_cast<MovableObject*>(itObject.getNext());
So I simplified slightly to
CODE: SELECT ALL
while ( itObject.hasMoreElements() )
node->getCreator()->destroyMovableObject(itObject.getNext());
And I now have these two handy functions you are all free to copy (since I copied them myself...)
CODE: SELECT ALL
void OgreUtil::destroyAllAttachedMovableObjects( SceneNode* node )
{
if(!node) return;
SceneNode::ObjectIterator itObject = node->getAttachedObjectIterator();
while ( itObject.hasMoreElements() )
node->getCreator()->destroyMovableObject(itObject.getNext());
SceneNode::ChildNodeIterator itChild = node->getChildIterator();
while ( itChild.hasMoreElements() )
{
SceneNode* pChildNode = static_cast<SceneNode*>(itChild.getNext());
destroyAllAttachedMovableObjects( pChildNode );
}
}
void OgreUtil::destroySceneNode( Ogre::SceneNode* node )
{
if(!node) return;
destroyAllAttachedMovableObjects(node);
node->removeAndDestroyAllChildren();
node->getCreator()->destroySceneNode(node);
}
OgreUtil is just a class I have with static methods.