[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58127] branches/ge_dev/source/gameengine/ Ketsji/KX_Scene.cpp: BGE: Adding animation culling.

Mitchell Stokes mogurijin at gmail.com
Tue Jul 9 22:50:15 CEST 2013


Revision: 58127
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58127
Author:   moguri
Date:     2013-07-09 20:50:15 +0000 (Tue, 09 Jul 2013)
Log Message:
-----------
BGE: Adding animation culling. Armature objects will only have their poses updated if their children meshes have not already been culled. Regular object animations will always be updated since they are cheap.

Modified Paths:
--------------
    branches/ge_dev/source/gameengine/Ketsji/KX_Scene.cpp

Modified: branches/ge_dev/source/gameengine/Ketsji/KX_Scene.cpp
===================================================================
--- branches/ge_dev/source/gameengine/Ketsji/KX_Scene.cpp	2013-07-09 20:06:36 UTC (rev 58126)
+++ branches/ge_dev/source/gameengine/Ketsji/KX_Scene.cpp	2013-07-09 20:50:15 UTC (rev 58127)
@@ -1578,9 +1578,37 @@
 
 void KX_Scene::UpdateAnimations(double curtime)
 {
-	// Update any animations
-	for (int i=0; i<m_animatedlist->GetCount(); ++i)
-		((KX_GameObject*)m_animatedlist->GetValue(i))->UpdateActionManager(curtime);
+	KX_GameObject *gameobj;
+	bool needs_update;
+
+	for (int i=0; i<m_animatedlist->GetCount(); ++i) {
+		gameobj = (KX_GameObject*)m_animatedlist->GetValue(i);
+
+		// Non-armature updates are fast enough, so just update them
+		needs_update = gameobj->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE;
+
+		if (!needs_update) {
+			// If we got here, we're looking to update an armature, so check its children meshes
+			// to see if we need to bother with a more expensive pose update
+			CListValue *children = gameobj->GetChildren();
+			KX_GameObject *child;
+
+			// Check for meshes that haven't been culled
+			for (int j=0; j<children->GetCount(); ++j) {
+				child = (KX_GameObject*)children->GetValue(j);
+
+				if (child->GetMeshCount() > 0 && !child->GetCulled()) {
+					needs_update = true;
+					break;
+				}
+			}
+
+			children->Release();
+		}
+
+		if (needs_update)
+			gameobj->UpdateActionManager(curtime);
+	}
 }
 
 void KX_Scene::LogicUpdateFrame(double curtime, bool frame)




More information about the Bf-blender-cvs mailing list