Revision: 14335
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14335
Author: ben2610
Date: 2008-04-05 15:33:08 +0200 (Sat, 05 Apr 2008)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/gameengine/Converter/BL_SkinDeformer.cpp
trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h
Modified: trunk/blender/source/gameengine/Converter/BL_SkinDeformer.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_SkinDeformer.cpp
2008-04-05 10:55:18 UTC (rev 14334)
+++ trunk/blender/source/gameengine/Converter/BL_SkinDeformer.cpp
2008-04-05 13:33:08 UTC (rev 14335)
@@ -60,11 +60,35 @@
#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 */
Modified: trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h 2008-04-05
10:55:18 UTC (rev 14334)
+++ trunk/blender/source/gameengine/Converter/BL_SkinDeformer.h 2008-04-05
13:33:08 UTC (rev 14335)
@@ -72,7 +72,8 @@
m_armobj(arma),
m_lastUpdate(-1),
m_defbase(&bmeshobj->defbase),
- m_releaseobject(false)
+ m_releaseobject(false),
+ m_restoremat(false)
{
};
@@ -81,15 +82,7 @@
struct Object *bmeshobj_new,
class BL_SkinMeshObject *mesh,
bool release_object,
- BL_ArmatureObject* arma = NULL)
- : //
- BL_MeshDeformer(bmeshobj_old,
mesh),
- m_armobj(arma),
- m_lastUpdate(-1),
-
m_defbase(&bmeshobj_old->defbase),
- m_releaseobject(release_object)
- {
- };
+ BL_ArmatureObject* arma = NULL);
virtual void ProcessReplica();
virtual RAS_Deformer *GetReplica();
@@ -102,6 +95,8 @@
float m_time;
double m_lastUpdate;
ListBase* m_defbase;
+ float m_obmat[4][4]; // the original
object matrice in case of dynamic mesh replacement
+ bool m_restoremat;
bool m_releaseobject;
};
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs