Revision: 20941
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20941
Author:   campbellbarton
Date:     2009-06-16 22:38:18 +0200 (Tue, 16 Jun 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    
branches/blender2.5/blender/source/gameengine/Converter/BL_ActionActuator.cpp
    
branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.cpp
    branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.h
    
branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
    
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/BL_ActionActuator.cpp
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/BL_ActionActuator.cpp   
    2009-06-16 20:33:13 UTC (rev 20940)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/BL_ActionActuator.cpp   
    2009-06-16 20:38:18 UTC (rev 20941)
@@ -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 @@
                        
                        /* 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);

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.cpp
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.cpp   
    2009-06-16 20:33:13 UTC (rev 20940)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.cpp   
    2009-06-16 20:38:18 UTC (rev 20941)
@@ -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 @@
 {
        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;
        }
 }

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.h
===================================================================
--- branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.h 
2009-06-16 20:33:13 UTC (rev 20940)
+++ branches/blender2.5/blender/source/gameengine/Converter/BL_ArmatureObject.h 
2009-06-16 20:38:18 UTC (rev 20941)
@@ -51,7 +51,8 @@
        BL_ArmatureObject(
                void* sgReplicationInfo,
                SG_Callbacks callbacks,
-               Object *armature
+               Object *armature,
+               Scene *scene
        );
        virtual ~BL_ArmatureObject();
 
@@ -67,6 +68,7 @@
        
        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 @@
        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;

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
        2009-06-16 20:33:13 UTC (rev 20940)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/BL_BlenderDataConversion.cpp
        2009-06-16 20:38:18 UTC (rev 20941)
@@ -1795,7 +1795,8 @@
                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;

Modified: 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
===================================================================
--- 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
    2009-06-16 20:33:13 UTC (rev 20940)
+++ 
branches/blender2.5/blender/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
    2009-06-16 20:38:18 UTC (rev 20941)
@@ -27,7 +27,7 @@
  */
 
 #include "KX_BlenderScalarInterpolator.h"
-#include "stdio.h"
+
 #include <cstring>
 
 extern "C" {


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to