[Bf-blender-cvs] [371e5f2] master: BGE: Cleanup : merge 3 loop in 1 in function DupliGroupRecurse.

Porteries Tristan noreply at git.blender.org
Fri May 15 16:20:30 CEST 2015


Commit: 371e5f25a054759014efa27c6fe4d497854ed64e
Author: Porteries Tristan
Date:   Fri May 15 16:17:18 2015 +0200
Branches: master
https://developer.blender.org/rB371e5f25a054759014efa27c6fe4d497854ed64e

BGE: Cleanup : merge 3 loop in 1 in function DupliGroupRecurse.

===================================================================

M	source/gameengine/Ketsji/KX_Scene.cpp

===================================================================

diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index a460d9b..674f1e3 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<KX_GameObject*>::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)




More information about the Bf-blender-cvs mailing list