-----------------------------------------------------------------------
| 893 | } |
| 894 | //----------------------------------------------------------------------- |
| 895 | void SceneManager::destroySceneNode( SceneNode *sn ) |
| 896 | { |
| 897 | if( sn->mGlobalIndex >= mSceneNodes.size() || |
| 898 | sn != *( mSceneNodes.begin() + static_cast<ptrdiff_t>( sn->mGlobalIndex ) ) ) |
| 899 | { |
| 900 | OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, |
| 901 | "SceneNode ID: " + StringConverter::toString( sn->getId() ) + ", named '" + |
| 902 | sn->getName() + |
| 903 | "' had it's mGlobalIndex out of date!!! (or the SceneNode wasn't " |
| 904 | "created with this SceneManager)", |
| 905 | "SceneManager::destroySceneNode" ); |
| 906 | } |
| 907 | |
| 908 | { |
| 909 | // For any scene nodes which are tracking this node |
| 910 | // (or if this node is a tracker), remove its entry. |
| 911 | AutoTrackingSceneNodeVec::iterator itor = mAutoTrackingSceneNodes.begin(); |
| 912 | AutoTrackingSceneNodeVec::iterator endt = mAutoTrackingSceneNodes.end(); |
| 913 | |
| 914 | while( itor != endt ) |
| 915 | { |
| 916 | if( itor->source == sn || itor->target == sn ) |
| 917 | { |
| 918 | itor = efficientVectorRemove( mAutoTrackingSceneNodes, itor ); |
| 919 | endt = mAutoTrackingSceneNodes.end(); |
| 920 | } |
| 921 | else |
| 922 | { |
| 923 | ++itor; |
| 924 | } |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | SceneNodeList::iterator itor = mSceneNodes.begin() + static_cast<ptrdiff_t>( sn->mGlobalIndex ); |
| 929 | |
| 930 | // detach from parent (don't do this in destructor since bulk destruction |
| 931 | // behaves differently) |
| 932 | Node *parentNode = sn->getParent(); |
| 933 | if( parentNode ) |
| 934 | { |
| 935 | parentNode->removeChild( sn ); |
| 936 | } |
| 937 | itor = efficientVectorRemove( mSceneNodes, itor ); |
| 938 | OGRE_DELETE sn; |
| 939 | sn = 0; |
| 940 | |
| 941 | // The node that was at the end got swapped and has now a different index |
| 942 | if( itor != mSceneNodes.end() ) |
| 943 | ( *itor )->mGlobalIndex = static_cast<size_t>( itor - mSceneNodes.begin() ); |
| 944 | } |
| 945 | //----------------------------------------------------------------------- |
| 946 | SceneNode *SceneManager::getRootSceneNode( SceneMemoryMgrTypes sceneType ) |
| 947 | { |
no test coverage detected