From 8d179ca920d29dad1abfd91e27b8f6632fc86dca Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Thu, 23 Jun 2011 19:20:28 +0000 Subject: BGE Animations: BL_Action now creates a PointerRNA only when constructed instead of on each Update() call. --- source/gameengine/Ketsji/BL_Action.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source/gameengine/Ketsji/BL_Action.cpp') diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 836bc24ffcd..078c69ab9e2 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -62,9 +62,16 @@ BL_Action::BL_Action(class KX_GameObject* gameobj) m_pose(NULL), m_blendpose(NULL), m_sg_contr(NULL), + m_ptrrna(NULL), m_done(true) { + if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) + { + BL_ArmatureObject *obj = (BL_ArmatureObject*)m_obj; + m_ptrrna = new PointerRNA(); + RNA_id_pointer_create((ID*)obj->GetArmatureObject(), m_ptrrna); + } } BL_Action::~BL_Action() @@ -78,6 +85,8 @@ BL_Action::~BL_Action() m_obj->GetSGNode()->RemoveSGController(m_sg_contr); delete m_sg_contr; } + if (m_ptrrna) + delete m_ptrrna; } void BL_Action::Play(const char* name, @@ -100,7 +109,6 @@ void BL_Action::Play(const char* name, return; } - //if (m_obj->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE) if (prev_action != m_action) { // Create an SG_Controller @@ -224,13 +232,11 @@ void BL_Action::Update(float curtime) // Extract the pose from the action { - struct PointerRNA id_ptr; Object *arm = obj->GetArmatureObject(); bPose *temp = arm->pose; arm->pose = m_pose; - RNA_id_pointer_create((ID*)arm, &id_ptr); - animsys_evaluate_action(&id_ptr, m_action, NULL, m_localtime); + animsys_evaluate_action(m_ptrrna, m_action, NULL, m_localtime); arm->pose = temp; } -- cgit v1.2.3