forked from bartvdbraak/blender
ActionActuator in the game engine working again to display deformed meshes with the new animation system.
Note that the animation conversion from existing 2.4x blend files doesnt yet set the Action pointer in the actuator so the only way to test is to use the python api to set the new converted action active on the actuator because there is no user interface.
This commit is contained in:
parent
ecb39291e9
commit
54ed699743
@ -57,6 +57,13 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_action.h"
|
||||
#include "RNA_access.h"
|
||||
#include "RNA_define.h"
|
||||
}
|
||||
|
||||
BL_ActionActuator::~BL_ActionActuator()
|
||||
{
|
||||
if (m_pose)
|
||||
@ -360,10 +367,31 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
|
||||
|
||||
/* Get the underlying pose from the armature */
|
||||
obj->GetPose(&m_pose);
|
||||
|
||||
|
||||
// 2.4x function,
|
||||
/* Override the necessary channels with ones from the action */
|
||||
// XXX extract_pose_from_action(m_pose, m_action, m_localtime);
|
||||
|
||||
|
||||
// 2.5x - replacement for extract_pose_from_action(...) above.
|
||||
{
|
||||
struct PointerRNA id_ptr;
|
||||
Object *arm= obj->GetArmatureObject();
|
||||
bPose *pose_back= arm->pose;
|
||||
|
||||
arm->pose= m_pose;
|
||||
RNA_id_pointer_create((ID *)arm, &id_ptr);
|
||||
animsys_evaluate_action(&id_ptr, m_action, NULL, m_localtime);
|
||||
|
||||
arm->pose= pose_back;
|
||||
|
||||
// 2.5x - could also do this but looks too high level, constraints use this, it works ok.
|
||||
// Object workob; /* evaluate using workob */
|
||||
// what_does_obaction((Scene *)obj->GetScene(), obj->GetArmatureObject(), &workob, m_pose, m_action, NULL, m_localtime);
|
||||
}
|
||||
|
||||
// done getting the pose from the action
|
||||
|
||||
/* Perform the user override (if any) */
|
||||
if (m_userpose){
|
||||
extract_pose_from_pose(m_pose, m_userpose);
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_armature_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "MT_Matrix4x4.h"
|
||||
|
||||
@ -48,10 +49,12 @@
|
||||
BL_ArmatureObject::BL_ArmatureObject(
|
||||
void* sgReplicationInfo,
|
||||
SG_Callbacks callbacks,
|
||||
Object *armature )
|
||||
Object *armature,
|
||||
Scene *scene)
|
||||
|
||||
: KX_GameObject(sgReplicationInfo,callbacks),
|
||||
m_objArma(armature),
|
||||
m_scene(scene), // maybe remove later. needed for where_is_pose
|
||||
m_framePose(NULL),
|
||||
m_lastframe(0.0),
|
||||
m_activeAct(NULL),
|
||||
@ -93,9 +96,9 @@ void BL_ArmatureObject::ApplyPose()
|
||||
{
|
||||
m_armpose = m_objArma->pose;
|
||||
m_objArma->pose = m_pose;
|
||||
|
||||
//m_scene->r.cfra++;
|
||||
if(m_lastapplyframe != m_lastframe) {
|
||||
where_is_pose(NULL, m_objArma); // XXX
|
||||
where_is_pose(m_scene, m_objArma); // XXX
|
||||
m_lastapplyframe = m_lastframe;
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ public:
|
||||
BL_ArmatureObject(
|
||||
void* sgReplicationInfo,
|
||||
SG_Callbacks callbacks,
|
||||
Object *armature
|
||||
Object *armature,
|
||||
Scene *scene
|
||||
);
|
||||
virtual ~BL_ArmatureObject();
|
||||
|
||||
@ -67,6 +68,7 @@ public:
|
||||
|
||||
struct bArmature * GetArmature() { return m_armature; }
|
||||
const struct bArmature * GetArmature() const { return m_armature; }
|
||||
const struct Scene * GetScene() const { return m_scene; }
|
||||
|
||||
Object* GetArmatureObject() {return m_objArma;}
|
||||
|
||||
@ -84,6 +86,7 @@ protected:
|
||||
struct bPose *m_pose;
|
||||
struct bPose *m_armpose;
|
||||
struct bPose *m_framePose;
|
||||
struct Scene *m_scene; // need for where_is_pose
|
||||
double m_lastframe;
|
||||
class BL_ActionActuator *m_activeAct;
|
||||
short m_activePriority;
|
||||
|
@ -1795,7 +1795,8 @@ static KX_GameObject *gameobject_from_blenderobject(
|
||||
gameobj = new BL_ArmatureObject(
|
||||
kxscene,
|
||||
KX_Scene::m_callbacks,
|
||||
ob // handle
|
||||
ob,
|
||||
blenderscene // handle
|
||||
);
|
||||
/* Get the current pose from the armature object and apply it as the rest pose */
|
||||
break;
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include "KX_BlenderScalarInterpolator.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
|
Loading…
Reference in New Issue
Block a user