From 371e5f25a054759014efa27c6fe4d497854ed64e Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Fri, 15 May 2015 16:17:18 +0200 Subject: BGE: Cleanup : merge 3 loop in 1 in function DupliGroupRecurse. --- source/gameengine/Ketsji/KX_Scene.cpp | 39 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'source/gameengine/Ketsji/KX_Scene.cpp') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a460d9bd392..674f1e3c1b3 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -823,38 +823,29 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) // the logic must be replicated first because we need // the new logic bricks before relinking vector::iterator git; - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { - (*git)->ReParentLogic(); - } - - // relink any pointers as necessary, sort of a temporary solution - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { + for (git = m_logicHierarchicalGameObjects.begin(); git != m_logicHierarchicalGameObjects.end()); ++git) { + KX_GameObject *gameobj = *git; + gameobj->ReParentLogic(); + + // relink any pointers as necessary, sort of a temporary solution // this will also relink the actuator to objects within the hierarchy - (*git)->Relink(&m_map_gameobject_to_replica); + gameobj->Relink(&m_map_gameobject_to_replica); // add the object in the layer of the parent - (*git)->SetLayer(groupobj->GetLayer()); - } + gameobj->SetLayer(groupobj->GetLayer()); - // replicate crosslinks etc. between logic bricks - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { - ReplicateLogic((*git)); - } + // replicate crosslinks etc. between logic bricks + ReplicateLogic(gameobj); - // now look if object in the hierarchy have dupli group and recurse - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { + // now look if object in the hierarchy have dupli group and recurse /* Replicate all constraints. */ - if ((*git)->GetPhysicsController()) { - (*git)->GetPhysicsController()->ReplicateConstraints((*git), m_logicHierarchicalGameObjects); - (*git)->ClearConstraints(); + if (gameobj->GetPhysicsController()) { + gameobj->GetPhysicsController()->ReplicateConstraints(gameobj, m_logicHierarchicalGameObjects); + gameobj->ClearConstraints(); } - if ((*git) != groupobj && (*git)->IsDupliGroup()) + if (gameobj != groupobj && gameobj->IsDupliGroup()) // can't instantiate group immediately as it destroys m_logicHierarchicalGameObjects - duplilist.push_back((*git)); + duplilist.push_back(gameobj); } for (git = duplilist.begin(); !(git == duplilist.end()); ++git) -- cgit v1.2.3