void World::RemoveGameObject( GameObjectPtr inGameObject ) { int index = inGameObject->GetIndexInWorld(); int lastIndex = mGameObjects.size() - 1; if( index != lastIndex ) { mGameObjects[ index ] = mGameObjects[ lastIndex ]; mGameObjects[ index ]->SetIndexInWorld( index ); } inGameObject->SetIndexInWorld( -1 ); mGameObjects.pop_back(); }