[Bf-blender-cvs] [1941364] master: BGE: Fixing a crash when animating objects with modifiers and armatures.

Mitchell Stokes noreply at git.blender.org
Thu Apr 10 01:23:23 CEST 2014


Commit: 19413644dac0f56623c520c5da2039ed0294c220
Author: Mitchell Stokes
Date:   Wed Apr 9 16:19:13 2014 -0700
https://developer.blender.org/rB19413644dac0f56623c520c5da2039ed0294c220

BGE: Fixing a crash when animating objects with modifiers and armatures.

Our deformer system really needs some work. First, there was a crash
with shape keys because BL_ModifierDeformer derives from
BL_ShapeDeformer, which means we try to execute shape keys even if we do
not have them. Also, for some reason BL_ModifierDeformer::Update() does
not work if called from the threaded loop, so it is skipped for now. In
other words, skinned updates on meshes with modifiers are currently not
run in parallel.

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

M	source/gameengine/Converter/BL_ShapeDeformer.cpp
M	source/gameengine/Ketsji/KX_Scene.cpp

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

diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
index 43f719d..8bb9f85 100644
--- a/source/gameengine/Converter/BL_ShapeDeformer.cpp
+++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp
@@ -122,6 +122,12 @@ void BL_ShapeDeformer::ProcessReplica()
 
 bool BL_ShapeDeformer::LoadShapeDrivers(KX_GameObject* parent)
 {
+	// Only load shape drivers if we have a key
+	if (GetKey() == NULL) {
+		m_useShapeDrivers = false;
+		return false;
+	}
+
 	// Fix drivers since BL_ArmatureObject makes copies
 	if (parent->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) {
 		BL_ArmatureObject *arma = (BL_ArmatureObject*)parent;
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index fbd9eeb..e125dec 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -1601,6 +1601,7 @@ void KX_Scene::AddAnimatedObject(CValue* gameobj)
 static void update_anim_thread_func(TaskPool *pool, void *taskdata, int UNUSED(threadid))
 {
 	KX_GameObject *gameobj, *child;
+	RAS_Deformer *deformer;
 	CListValue *children;
 	bool needs_update;
 	double curtime = *(double*)BLI_task_pool_userdata(pool);
@@ -1648,8 +1649,14 @@ static void update_anim_thread_func(TaskPool *pool, void *taskdata, int UNUSED(t
 		for (int j=0; j<children->GetCount(); ++j) {
 			child = (KX_GameObject*)children->GetValue(j);
 
-			if (child->GetDeformer())
+			deformer = child->GetDeformer();
+
+			// This check is ugly, but the modifier deformer currently doesn't
+			// work if called from here. This is a quick work-around to prevent
+			// crashing, but it really should be fixed.
+			if (deformer && !dynamic_cast<BL_ModifierDeformer*>(deformer)) {
 				child->GetDeformer()->Update();
+			}
 		}
 
 		children->Release();




More information about the Bf-blender-cvs mailing list