diff options
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1959b3d8b0a..fd709a87def 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -819,38 +819,47 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) // the logic must be replicated first because we need // the new logic bricks before relinking vector<KX_GameObject*>::iterator git; - for (git = m_logicHierarchicalGameObjects.begin(); git != m_logicHierarchicalGameObjects.end(); ++git) { - KX_GameObject *gameobj = *git; - - if (gameobj->GetBlenderGroupObject() == blgroupobj) { - // set references for dupli-group - // groupobj holds a list of all objects, that belongs to this group - groupobj->AddInstanceObjects(gameobj); - // every object gets the reference to its dupli-group object - gameobj->SetDupliGroupObject(groupobj); - } - - gameobj->ReParentLogic(); - - // relink any pointers as necessary, sort of a temporary solution + 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) + { // this will also relink the actuator to objects within the hierarchy - gameobj->Relink(&m_map_gameobject_to_replica); + (*git)->Relink(&m_map_gameobject_to_replica); // add the object in the layer of the parent - gameobj->SetLayer(groupobj->GetLayer()); + (*git)->SetLayer(groupobj->GetLayer()); + } - // replicate crosslinks etc. between logic bricks - ReplicateLogic(gameobj); + // replicate crosslinks etc. between logic bricks + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + ReplicateLogic((*git)); + } - // now look if object in the hierarchy have dupli group and recurse + // now look if object in the hierarchy have dupli group and recurse + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { /* Replicate all constraints. */ - if (gameobj->GetPhysicsController()) { - gameobj->GetPhysicsController()->ReplicateConstraints(gameobj, m_logicHierarchicalGameObjects); - gameobj->ClearConstraints(); + if ((*git)->GetPhysicsController()) { + (*git)->GetPhysicsController()->ReplicateConstraints((*git), m_logicHierarchicalGameObjects); + (*git)->ClearConstraints(); } - if (gameobj != groupobj && gameobj->IsDupliGroup()) + if ((*git) != groupobj && (*git)->IsDupliGroup()) // can't instantiate group immediately as it destroys m_logicHierarchicalGameObjects - duplilist.push_back(gameobj); + duplilist.push_back((*git)); + + if ((*git)->GetBlenderGroupObject() == blgroupobj) { + // set references for dupli-group + // groupobj holds a list of all objects, that belongs to this group + groupobj->AddInstanceObjects((*git)); + + // every object gets the reference to its dupli-group object + (*git)->SetDupliGroupObject(groupobj); + } } for (git = duplilist.begin(); !(git == duplilist.end()); ++git) |