From 19413644dac0f56623c520c5da2039ed0294c220 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 9 Apr 2014 16:19:13 -0700 Subject: 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. --- source/gameengine/Converter/BL_ShapeDeformer.cpp | 6 ++++++ source/gameengine/Ketsji/KX_Scene.cpp | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 43f719d80c4..8bb9f850bcf 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 fbd9eeba8ed..e125dec860e 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; jGetCount(); ++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(deformer)) { child->GetDeformer()->Update(); + } } children->Release(); -- cgit v1.2.3