Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / gameengine / Converter / BL_DeformableGameObject.cpp
index 68a2e41ca4714f6a4e281f508b3678c1b92f712c..d23274324eeb79db9cd9e8cd2f37da15c65cb61d 100644 (file)
@@ -28,6 +28,8 @@
  */
 
 #include "BL_DeformableGameObject.h"
+#include "BL_ShapeDeformer.h"
+#include "BL_ShapeActionActuator.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -60,3 +62,48 @@ CValue*              BL_DeformableGameObject::GetReplica()
        ProcessReplica(replica);
        return replica;
 }
+
+bool BL_DeformableGameObject::SetActiveAction(BL_ShapeActionActuator *act, short priority, double curtime)
+{
+       if (curtime != m_lastframe){
+               m_activePriority = 9999;
+               m_lastframe= curtime;
+               m_activeAct = NULL;
+       }
+
+       if (priority<=m_activePriority)
+       {
+               if (m_activeAct && (m_activeAct!=act))
+                       m_activeAct->SetBlendTime(0.0f);        /* Reset the blend timer */
+               m_activeAct = act;
+               m_activePriority = priority;
+               m_lastframe = curtime;
+       
+               return true;
+       }
+       else{
+               act->SetBlendTime(0.0f);
+               return false;
+       }
+}
+
+bool BL_DeformableGameObject::GetShape(vector<float> &shape)
+{
+       shape.clear();
+       if (m_pDeformer)
+       {
+               Mesh* mesh = ((BL_MeshDeformer*)m_pDeformer)->GetMesh();
+               // this check is normally superfluous: a shape deformer can only be created if the mesh
+               // has relative keys
+               if (mesh && mesh->key && mesh->key->type==KEY_RELATIVE) 
+               {
+                       KeyBlock *kb;
+                       for (kb = (KeyBlock*)mesh->key->block.first; kb; kb = (KeyBlock*)kb->next)
+                       {
+                               shape.push_back(kb->curval);
+                       }
+               }
+       }
+       return !shape.empty();
+}
+