diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2013-04-14 22:54:06 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2013-04-14 22:54:06 +0400 |
commit | 8051ab07fc79baa02569086bfb76f6fa91b9cd68 (patch) | |
tree | ef5ecb3b32241af1cf2a6c74ed88b967838b9dd8 /source | |
parent | 86f306f1d90a48a9efe72a8ef4faf6b5fa41f8e0 (diff) |
BGE: Cleaning up BL_ShapeDeformer's use of Blender's Key. This also fixes a bug with replicas (added objects) crashing when using shape keys.
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Converter/BL_ShapeDeformer.cpp | 30 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ShapeDeformer.h | 1 |
2 files changed, 12 insertions, 19 deletions
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index f262532e7e2..59cf10d326a 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -52,6 +52,7 @@ #include "BKE_main.h" #include "BKE_key.h" #include "BKE_ipo.h" +#include "BKE_library.h" #include "MT_Point3.h" extern "C"{ @@ -73,8 +74,7 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, m_useShapeDrivers(false), m_lastShapeUpdate(-1) { - m_key = m_bmesh->key; - m_bmesh->key = BKE_key_copy(m_key); + m_key = BKE_key_copy(m_bmesh->key); }; /* this second constructor is needed for making a mesh deformable on the fly. */ @@ -90,18 +90,14 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, m_useShapeDrivers(false), m_lastShapeUpdate(-1) { - m_key = m_bmesh->key; - m_bmesh->key = BKE_key_copy(m_key); + m_key = BKE_key_copy(m_bmesh->key); }; BL_ShapeDeformer::~BL_ShapeDeformer() { - if (m_key && m_bmesh->key && m_key != m_bmesh->key) + if (m_key) { - BKE_key_free(m_bmesh->key); - BLI_remlink_safe(&G.main->key, m_bmesh->key); - MEM_freeN(m_bmesh->key); - m_bmesh->key = m_key; + BKE_libblock_free(&G.main->key, m_key); m_key = NULL; } }; @@ -119,6 +115,8 @@ void BL_ShapeDeformer::ProcessReplica() { BL_SkinDeformer::ProcessReplica(); m_lastShapeUpdate = -1; + + m_key = BKE_key_copy(m_key); } bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma) @@ -165,12 +163,12 @@ bool BL_ShapeDeformer::Update(void) m_pMeshObject->CheckWeightCache(blendobj); /* we will blend the key directly in m_transverts array: it is used by armature as the start position */ - /* m_bmesh->key can be NULL in case of Modifier deformer */ - if (m_bmesh->key) { + /* m_key can be NULL in case of Modifier deformer */ + if (m_key) { /* store verts locally */ VerifyStorage(); - BKE_key_evaluate_relative(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts, m_bmesh->key, NULL, 0); /* last arg is ignored */ + BKE_key_evaluate_relative(0, m_bmesh->totvert, m_bmesh->totvert, (char *)(float *)m_transverts, m_key, NULL, 0); /* last arg is ignored */ m_bDynamic = true; } @@ -199,15 +197,11 @@ bool BL_ShapeDeformer::Update(void) #endif bSkinUpdate = true; } + return bSkinUpdate; } Key *BL_ShapeDeformer::GetKey() { - return m_bmesh->key; -} - -void BL_ShapeDeformer::SetKey(Key *key) -{ - m_bmesh->key = key; + return m_key; } diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 60f27c85e4f..a506fb9c7f6 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -65,7 +65,6 @@ public: bool ExecuteShapeDrivers(void); struct Key *GetKey(); - void SetKey(struct Key *key); void ForceUpdate() { |