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.
This commit is contained in:
parent
c3fefebe47
commit
19413644da
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue