Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / gameengine / Converter / BL_SkinDeformer.h
index e130dc15dbf40752d500d8e8bc0ee271db3f0c16..d3fc5ae2a81ad72cbe1fb472d5915dc5b10e0c90 100644 (file)
@@ -52,30 +52,25 @@ public:
 //     void SetArmatureController (BL_ArmatureController *cont);
        virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
        {
-               void **h_obj = (*map)[m_armobj];
-               if (h_obj){
-                       SetArmature( (BL_ArmatureObject*)(*h_obj) );
+               if (m_armobj){
+                       void **h_obj = (*map)[m_armobj];
+                       if (h_obj){
+                               SetArmature( (BL_ArmatureObject*)(*h_obj) );
+                       }
+                       else
+                               m_armobj=NULL;
                }
-               else
-                       m_armobj=NULL;
        }
        void SetArmature (class BL_ArmatureObject *armobj);
 
-       BL_SkinDeformer(struct Object *bmeshobj, 
+       BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+                                       struct Object *bmeshobj, 
                                        class BL_SkinMeshObject *mesh,
-                                       BL_ArmatureObject* arma = NULL)
-                                       :       //
-                                               BL_MeshDeformer(bmeshobj, mesh),
-                                               m_armobj(arma),
-                                               m_lastUpdate(-1),
-                                               m_defbase(&bmeshobj->defbase),
-                                               m_releaseobject(false),
-                                               m_restoremat(false)
-       {
-       };
+                                       BL_ArmatureObject* arma = NULL);
 
        /* this second constructor is needed for making a mesh deformable on the fly. */
-       BL_SkinDeformer(struct Object *bmeshobj_old,
+       BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+                                       struct Object *bmeshobj_old,
                                        struct Object *bmeshobj_new,
                                        class BL_SkinMeshObject *mesh,
                                        bool release_object,
@@ -84,17 +79,33 @@ public:
        virtual void ProcessReplica();
        virtual RAS_Deformer *GetReplica();
        virtual ~BL_SkinDeformer();
-       void Update (void);
+       bool Update (void);
        bool Apply (class RAS_IPolyMaterial *polymat);
+       bool PoseApplied()
+               { return m_poseApplied; }
+       void PoseApplied(bool applied)
+               { m_poseApplied = applied; }
+       bool PoseUpdated(void)
+               { 
+                       if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) {
+                               return true;
+                       }
+                       return false;
+               }
+
+       void ForceUpdate()
+       {
+               m_lastArmaUpdate = -1.0;
+       };
 
 protected:
        BL_ArmatureObject*              m_armobj;       //      Our parent object
        float                                   m_time;
-       double                                  m_lastUpdate;
+       double                                  m_lastArmaUpdate;
        ListBase*                               m_defbase;
-       float                                   m_obmat[4][4];  // the original object matrice in case of dynamic mesh replacement
-       bool                                    m_restoremat;           
+       float                                   m_obmat[4][4];  // the reference matrix for skeleton deform
        bool                                    m_releaseobject;
+       bool                                    m_poseApplied;
 
 };