Hi all,
The goal is to have 0 recursion and keep the array linear to load/save hierarchy.
One way I have is to have a ReorderActor function in SceneManager :
void CSceneManager::ReorderActor( IActor* Parent, IActor* Child )
{
// Find the child actor in this scene manager.
for( UInt32 i = 0; i < m_ActorArray.GetSize(); ++i )
{
// Check if the child actor is found.
if( m_ActorArray[ i ] == Child )
{
m_ActorArray.Remove( i );
break;
}
}
// Find the parent actor in this scene manager.
for( UInt32 i = 0; i < m_ActorArray.GetSize(); ++i )
{
// Check if the parent actor is found.
if( m_ActorArray[ i ] == Parent )
{
m_ActorArray.InsertBefore( Child, i + 1 );
break;
}
}
}
IActor stores a pointer of the scene manager he is affected and in AddChild/RemoveChild he calls this function.
Now the question is : Is this way a good way or should be avoided ?
Thanks for the help