diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2010-05-25 12:42:11 +0400 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2010-05-25 12:42:11 +0400 |
commit | 5416f51b7a0c4e1ca23592385fbd025355cedc0e (patch) | |
tree | 36bb3048c539582e935faa0ccf041bd1adc8a126 /source/gameengine | |
parent | e26cc71bd0a4976c8adf8f6586a71de7ce1003d4 (diff) |
BGE Fix for: [#22142] Armature deformation does not work in Game Engine. + parent type to modifiers doversion(). Patch by Xavier Thomas (xat)
This fix the problem of not being able to play animations created with Blender 2.5 in BGE. Patch reviewed by Benoit
Added also other parent to modifier conversions as requested by Joshua (aligorith). I didn't bump subversion here, but the patch should work still. If not I'm increasing subversion sooner anyways (tomorrow or by the middle of the week I hope).
I was waiting to commit this one together with the Logic Editor datablock patch (converting material_name DNA properties to struct Material *). However my patch is getting too big and it's better if it's alone (easier to analyze later, eventual fixes, ...)
Mitchell, this commit adds a function that can help hardware skinning - HasArmatureDeformer()
Diffstat (limited to 'source/gameengine')
4 files changed, 22 insertions, 5 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 4a2aa3695fa..2f0f70ed9fe 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1729,7 +1729,7 @@ static KX_GameObject *gameobject_from_blenderobject( // only support relative shape key bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE; bool bHasDvert = mesh->dvert != NULL && ob->defbase.first; - bool bHasArmature = (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && bHasDvert); + bool bHasArmature = (BL_ModifierDeformer::HasArmatureDeformer(ob) && ob->parent && ob->parent->type == OB_ARMATURE && bHasDvert); bool bHasModifier = BL_ModifierDeformer::HasCompatibleDeformer(ob); bool bHasSoftBody = (!ob->parent && (ob->gameflag & OB_SOFT_BODY)); @@ -2357,8 +2357,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (me->dvert){ BL_DeformableGameObject *obj = (BL_DeformableGameObject*)converter->FindGameObject(blenderobj); - - if (obj && blenderobj->parent && blenderobj->parent->type==OB_ARMATURE && blenderobj->partype==PARSKEL){ + + if (obj && BL_ModifierDeformer::HasArmatureDeformer(blenderobj) && blenderobj->parent && blenderobj->parent->type==OB_ARMATURE){ KX_GameObject *par = converter->FindGameObject(blenderobj->parent); if (par && obj->GetDeformer()) ((BL_SkinDeformer*)obj->GetDeformer())->SetArmature((BL_ArmatureObject*) par); diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index e28ea47b162..5ccf8de29b1 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -114,11 +114,27 @@ bool BL_ModifierDeformer::HasCompatibleDeformer(Object *ob) continue; if (!(md->mode & eModifierMode_Realtime)) continue; + /* armature modifier are handled by SkinDeformer, not ModifierDeformer */ + if (md->type == eModifierType_Armature ) + continue; return true; } return false; } +bool BL_ModifierDeformer::HasArmatureDeformer(Object *ob) +{ + if (!ob->modifiers.first) + return false; + + ModifierData* md; + for (md = (ModifierData*)ob->modifiers.first; md; md = (ModifierData*)md->next) { + if (md->type == eModifierType_Armature ) + return true; + } + return false; +} + bool BL_ModifierDeformer::Update(void) { bool bShapeUpdate = BL_ShapeDeformer::Update(); diff --git a/source/gameengine/Converter/BL_ModifierDeformer.h b/source/gameengine/Converter/BL_ModifierDeformer.h index 1122d5e8b32..adf537110f1 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.h +++ b/source/gameengine/Converter/BL_ModifierDeformer.h @@ -45,6 +45,7 @@ class BL_ModifierDeformer : public BL_ShapeDeformer { public: static bool HasCompatibleDeformer(Object *ob); + static bool HasArmatureDeformer(Object *ob); BL_ModifierDeformer(BL_DeformableGameObject *gameobj, diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index ebd0fa5c525..d72fef166e6 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1067,12 +1067,12 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u bool bHasShapeKey = blendmesh->key != NULL && blendmesh->key->type==KEY_RELATIVE; bool bHasDvert = blendmesh->dvert != NULL; bool bHasArmature = + BL_ModifierDeformer::HasArmatureDeformer(blendobj) && parentobj && // current parent is armature parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE && oldblendobj && // needed for mesh deform blendobj->parent && // original object had armature (not sure this test is needed) - blendobj->parent->type == OB_ARMATURE && - blendobj->partype==PARSKEL && + blendobj->parent->type == OB_ARMATURE && blendmesh->dvert!=NULL; // mesh has vertex group bool bHasSoftBody = (!parentobj && (blendobj->gameflag & OB_SOFT_BODY)); |