Fix #35329: action actuator crash with replacemesh, pointers got outdated.

No need to cache this, creating it is quick.
This commit is contained in:
Brecht Van Lommel 2013-05-13 10:54:57 +00:00
parent fa4ef0828e
commit 21955ac8aa
2 changed files with 8 additions and 24 deletions

@ -55,7 +55,6 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
m_pose(NULL), m_pose(NULL),
m_blendpose(NULL), m_blendpose(NULL),
m_blendinpose(NULL), m_blendinpose(NULL),
m_ptrrna(NULL),
m_obj(gameobj), m_obj(gameobj),
m_startframe(0.f), m_startframe(0.f),
m_endframe(0.f), m_endframe(0.f),
@ -71,24 +70,6 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
m_done(true), m_done(true),
m_calc_localtime(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() BL_Action::~BL_Action()
@ -99,8 +80,6 @@ BL_Action::~BL_Action()
game_free_pose(m_blendpose); game_free_pose(m_blendpose);
if (m_blendinpose) if (m_blendinpose)
game_free_pose(m_blendinpose); game_free_pose(m_blendinpose);
if (m_ptrrna)
delete m_ptrrna;
ClearControllerList(); ClearControllerList();
} }
@ -426,7 +405,11 @@ void BL_Action::Update(float curtime)
bPose *temp = arm->pose; bPose *temp = arm->pose;
arm->pose = m_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; arm->pose = temp;
} }
@ -465,8 +448,10 @@ void BL_Action::Update(float curtime)
{ {
Key *key = shape_deformer->GetKey(); 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 // Handle blending between shape actions
if (m_blendin && m_blendframe < m_blendin) if (m_blendin && m_blendframe < m_blendin)

@ -42,7 +42,6 @@ private:
struct bPose* m_pose; struct bPose* m_pose;
struct bPose* m_blendpose; struct bPose* m_blendpose;
struct bPose* m_blendinpose; struct bPose* m_blendinpose;
struct PointerRNA *m_ptrrna;
std::vector<class SG_Controller*> m_sg_contr_list; std::vector<class SG_Controller*> m_sg_contr_list;
class KX_GameObject* m_obj; class KX_GameObject* m_obj;
std::vector<float> m_blendshape; std::vector<float> m_blendshape;