-----------------------------------------------------------------------
| 174 | } |
| 175 | //----------------------------------------------------------------------- |
| 176 | void SceneNode::detachObject( MovableObject *obj ) |
| 177 | { |
| 178 | if( obj->getParentNode() != this ) |
| 179 | { |
| 180 | OGRE_EXCEPT( Exception::ERR_ITEM_NOT_FOUND, |
| 181 | "MovableObject ID: " + StringConverter::toString( obj->getId() ) + ", named '" + |
| 182 | obj->getName() + "' is not attached to this SceneNode!", |
| 183 | "SceneNode::detachObject" ); |
| 184 | } |
| 185 | else if( obj->mParentIndex >= mAttachments.size() || |
| 186 | obj != *( mAttachments.begin() + static_cast<ptrdiff_t>( obj->mParentIndex ) ) ) |
| 187 | { |
| 188 | OGRE_EXCEPT( Exception::ERR_INTERNAL_ERROR, |
| 189 | "MovableObject ID: " + StringConverter::toString( obj->getId() ) + ", named '" + |
| 190 | obj->getName() + |
| 191 | "' had it's mParentIndex out of date!!! (or the MovableObject wasn't " |
| 192 | "attached to this SceneNode)", |
| 193 | "SceneNode::detachObject" ); |
| 194 | } |
| 195 | |
| 196 | ObjectVec::iterator itor = mAttachments.begin() + static_cast<ptrdiff_t>( obj->mParentIndex ); |
| 197 | |
| 198 | ( *itor )->_notifyAttached( (SceneNode *)0 ); |
| 199 | itor = efficientVectorRemove( mAttachments, itor ); |
| 200 | |
| 201 | if( itor != mAttachments.end() ) |
| 202 | { |
| 203 | // The object that was at the end got swapped and has now a different index |
| 204 | ( *itor )->mParentIndex = static_cast<size_t>( itor - mAttachments.begin() ); |
| 205 | } |
| 206 | } |
| 207 | //----------------------------------------------------------------------- |
| 208 | void SceneNode::detachAllObjects() |
| 209 | { |
no test coverage detected