diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-04-05 17:33:08 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-04-05 17:33:08 +0400 |
commit | cc33fcfe7b76aa8370cace83859d085b42304d48 (patch) | |
tree | bd01c8aeb131267892ddaf5df8b14755c3dde831 /source/gameengine/Converter/BL_SkinDeformer.cpp | |
parent | 0eb018919a193a4d868f90e21601eba383a82e60 (diff) |
Commit patch #2439: Mesh replacement in BGE will react properly to armature deform
Changing the mesh of an object that has a deform controller (armature) is now properly handled. The new mesh must have vertex groups matching the armature bones. In simple terms, the new mesh must deform correctly when you assign it to the object in Blender and you test the action. It will deform the same when you replace the object mesh during the game.
Diffstat (limited to 'source/gameengine/Converter/BL_SkinDeformer.cpp')
-rw-r--r-- | source/gameengine/Converter/BL_SkinDeformer.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index e9ec6f9116b..6bc623b645c 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -60,11 +60,35 @@ extern "C"{ #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS + +BL_SkinDeformer::BL_SkinDeformer( + struct Object *bmeshobj_old, // Blender object that owns the new mesh + struct Object *bmeshobj_new, // Blender object that owns the original mesh + class BL_SkinMeshObject *mesh, + bool release_object, + BL_ArmatureObject* arma) : + BL_MeshDeformer(bmeshobj_old, mesh), + m_armobj(arma), + m_lastUpdate(-1), + m_defbase(&bmeshobj_old->defbase), + m_releaseobject(release_object) + { + Mat4CpyMat4(m_obmat, bmeshobj_old->obmat); + m_restoremat = true; + // this is needed to ensure correct deformation of mesh: + // the deformation is done with Blender's armature_deform_verts() function + // that takes an object as parameter and not a mesh. The object matrice is used + // in the calculation, so we must force the same matrice to simulate a pure replacement of mesh + Mat4CpyMat4(bmeshobj_old->obmat, bmeshobj_new->obmat); + } + BL_SkinDeformer::~BL_SkinDeformer() { if(m_releaseobject && m_armobj) m_armobj->Release(); -}; + if (m_restoremat) + Mat4CpyMat4(m_objMesh->obmat, m_obmat); +} /* XXX note, this __NLA_OLDDEFORM define seems to be obsolete */ |