/// Remove a slice from this world. /// /// @param[in] pSlice SceneDefinition to remove. /// /// @return True if the slice was removed successfully, false if not. /// /// @see AddSlice() bool World::RemoveSlice( Slice* pSlice ) { HELIUM_ASSERT( pSlice ); // Make sure the slice is part of this world. if( pSlice->GetWorld() != this ) { HELIUM_TRACE( TraceLevels::Error, TXT( "World::RemoveSlice(): SceneDefinition \"%s\" is not part of world \"%s\".\n" ), *pSlice->GetSceneDefinition()->GetPath().ToString(), *GetSceneDefinition()->GetPath().ToString() ); return false; } //// Detach all entities in the slice. //size_t entityCount = pSlice->GetEntityCount(); //for( size_t entityIndex = 0; entityIndex < entityCount; ++entityIndex ) //{ // Entity* pEntity = pSlice->GetEntity( entityIndex ); // HELIUM_ASSERT( pEntity ); //} // Remove the slice from the slice list and clear out all references back to this world. size_t index = pSlice->GetWorldIndex(); HELIUM_ASSERT( index < m_Slices.GetSize() ); pSlice->ClearWorldInfo(); m_Slices.RemoveSwap( index ); // Update the index of the slice which has been moved to fill the slice list entry we just removed. size_t sliceCount = m_Slices.GetSize(); if( index < sliceCount ) { Slice* pMovedSlice = m_Slices[ index ]; HELIUM_ASSERT( pMovedSlice ); HELIUM_ASSERT( pMovedSlice->GetWorldIndex() == sliceCount ); pMovedSlice->SetWorldIndex( index ); } return true; }