Fix #35329: action actuator crash with replacemesh, pointers got outdated.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 13 May 2013 10:54:57 +0000 (10:54 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 13 May 2013 10:54:57 +0000 (10:54 +0000)
No need to cache this, creating it is quick.

source/gameengine/Ketsji/BL_Action.cpp
source/gameengine/Ketsji/BL_Action.h

index fa00cafa148da2f7c1f9ad1bb7a8249d483430d2..07295d238ef63ec56c71370afeaa0b1d070a07df 100644 (file)
@@ -55,7 +55,6 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
        m_pose(NULL),
        m_blendpose(NULL),
        m_blendinpose(NULL),
-       m_ptrrna(NULL),
        m_obj(gameobj),
        m_startframe(0.f),
        m_endframe(0.f),
@@ -71,24 +70,6 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
        m_done(true),
        m_calc_localtime(true)
 {
-       if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
-       {
-               BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj;
-
-               m_ptrrna = new PointerRNA();
-               RNA_id_pointer_create(&obj->GetArmatureObject()->id, m_ptrrna);
-       }
-       else
-       {
-               BL_DeformableGameObject *obj = (BL_DeformableGameObject*)m_obj;
-               BL_ShapeDeformer *shape_deformer = dynamic_cast<BL_ShapeDeformer*>(obj->GetDeformer());
-
-               if (shape_deformer)
-               {
-                       m_ptrrna = new PointerRNA();
-                       RNA_id_pointer_create(&shape_deformer->GetKey()->id, m_ptrrna);
-               }
-       }
 }
 
 BL_Action::~BL_Action()
@@ -99,8 +80,6 @@ BL_Action::~BL_Action()
                game_free_pose(m_blendpose);
        if (m_blendinpose)
                game_free_pose(m_blendinpose);
-       if (m_ptrrna)
-               delete m_ptrrna;
        ClearControllerList();
 }
 
@@ -426,7 +405,11 @@ void BL_Action::Update(float curtime)
                        bPose *temp = arm->pose;
 
                        arm->pose = m_pose;
-                       animsys_evaluate_action(m_ptrrna, m_action, NULL, m_localtime);
+
+                       PointerRNA ptrrna;
+                       RNA_id_pointer_create(&arm->id, &ptrrna);
+
+                       animsys_evaluate_action(&ptrrna, m_action, NULL, m_localtime);
 
                        arm->pose = temp;
                }
@@ -465,8 +448,10 @@ void BL_Action::Update(float curtime)
                {
                        Key *key = shape_deformer->GetKey();
 
+                       PointerRNA ptrrna;
+                       RNA_id_pointer_create(&key->id, &ptrrna);
 
-                       animsys_evaluate_action(m_ptrrna, m_action, NULL, m_localtime);
+                       animsys_evaluate_action(&ptrrna, m_action, NULL, m_localtime);
 
                        // Handle blending between shape actions
                        if (m_blendin && m_blendframe < m_blendin)
index 370bbf51d723d2f3d33fe0da0b760c99b79f1e11..e4088633e61f58f2520600b07ddbed8f2ee383df 100644 (file)
@@ -42,7 +42,6 @@ private:
        struct bPose* m_pose;
        struct bPose* m_blendpose;
        struct bPose* m_blendinpose;
-       struct PointerRNA *m_ptrrna;
        std::vector<class SG_Controller*> m_sg_contr_list;
        class KX_GameObject* m_obj;
        std::vector<float>      m_blendshape;