diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2011-06-23 23:09:09 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2011-06-23 23:09:09 +0400 |
commit | 2d2aa95227e3b00f9dc42293d4231af3dc5a99b9 (patch) | |
tree | cfc159562c6e0f48957d702104dd18f7d2cc05af /source/gameengine/Converter/BL_ShapeDeformer.cpp | |
parent | 413bc87e4f18bb46eeb2f2f52b5278d182b51de8 (diff) |
BGE Animations: Making shape actions work again:
* BL_DeformableGameObject is no longer responsible for handling keys, BL_ShapeDeformer is
* BL_ShapeDeformer also creates a copy of the key on construction and puts it back on the mesh when destructed. This avoids us permanently modifying Blender data.
* I'm not too fond of clearing out the key every frame, but this works and I can't think of another alternative at the moment (something may be possible with some key juggling)
Diffstat (limited to 'source/gameengine/Converter/BL_ShapeDeformer.cpp')
-rw-r--r-- | source/gameengine/Converter/BL_ShapeDeformer.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 8d8f149bb6c..c651d457cd9 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -68,9 +68,40 @@ extern "C"{ #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS +BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, + Object *bmeshobj, + RAS_MeshObject *mesh) + : + BL_SkinDeformer(gameobj,bmeshobj, mesh), + m_lastShapeUpdate(-1) +{ + m_key = m_bmesh->key; + m_bmesh->key = copy_key(m_key); +}; + +/* this second constructor is needed for making a mesh deformable on the fly. */ +BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, + Object *bmeshobj_old, + Object *bmeshobj_new, + RAS_MeshObject *mesh, + bool release_object, + bool recalc_normal, + BL_ArmatureObject* arma) + : + BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, recalc_normal, arma), + m_lastShapeUpdate(-1) +{ + m_key = m_bmesh->key; + m_bmesh->key = copy_key(m_key); +}; BL_ShapeDeformer::~BL_ShapeDeformer() { + if (m_key && m_bmesh->key) + { + free_key(m_bmesh->key); + m_bmesh->key = m_key; + } }; RAS_Deformer *BL_ShapeDeformer::GetReplica() @@ -190,3 +221,13 @@ bool BL_ShapeDeformer::Update(void) } return bSkinUpdate; } + +Key *BL_ShapeDeformer::GetKey() +{ + return m_bmesh->key; +} + +void BL_ShapeDeformer::SetKey(Key *key) +{ + m_bmesh->key = key; +} |