BGE Animations: Beginning work on layer blending. Blending armature actions works...
authorMitchell Stokes <mogurijin@gmail.com>
Wed, 29 Jun 2011 02:42:46 +0000 (02:42 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Wed, 29 Jun 2011 02:42:46 +0000 (02:42 +0000)
source/gameengine/Converter/BL_ArmatureObject.cpp
source/gameengine/Converter/BL_ArmatureObject.h
source/gameengine/Ketsji/BL_Action.cpp
source/gameengine/Ketsji/BL_ActionManager.cpp

index c6c20a96482deae28c8084a7fd6956ebfb3e6496..f33eafce620782b1b97d0b2aa9731b6ec5b7a47c 100644 (file)
@@ -137,10 +137,8 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
 
 
 /* Only allowed for Poses with identical channels */
-void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/)
-{
-       short mode= ACTSTRIPMODE_BLEND;
-       
+void game_blend_poses(bPose *dst, bPose *src, float srcweight, short mode)
+{      
        bPoseChannel *dchan;
        const bPoseChannel *schan;
        bConstraint *dcon, *scon;
@@ -152,8 +150,6 @@ void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/)
                dstweight = 1.0F - srcweight;
                break;
        case ACTSTRIPMODE_ADD:
-               dstweight = 1.0F;
-               break;
        default :
                dstweight = 1.0F;
        }
index 2c3ca7404b372e285c4b7f576d339dab77939cbd..92a9a3685c980073104115f4acec2d89615c45d9 100644 (file)
@@ -145,7 +145,7 @@ protected:
 };
 
 /* Pose function specific to the game engine */
-void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight/*, short mode*/); /* was blend_poses */
+void game_blend_poses(struct bPose *dst, struct bPose *src, float srcweight, short mode); /* was blend_poses */
 //void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
 void game_copy_pose(struct bPose **dst, struct bPose *src, int copy_con);
 void game_free_pose(struct bPose *pose);
index 149189b6a7921238324b753d63fd0c616eebed36..33e4e179071385ba557f711f5d07692acc74d929 100644 (file)
@@ -46,6 +46,7 @@ extern "C" {
 #include "BKE_action.h"
 #include "RNA_access.h"
 #include "RNA_define.h"
+#include "DNA_nla_types.h"
 }
 
 BL_Action::BL_Action(class KX_GameObject* gameobj)
@@ -172,6 +173,7 @@ bool BL_Action::Play(const char* name,
        m_endframe = end;
        m_blendin = blendin;
        m_playmode = play_mode;
+       m_blendmode = blend_mode;
        m_endtime = 0.f;
        m_blendframe = 0.f;
        m_blendstart = 0.f;
@@ -328,12 +330,17 @@ void BL_Action::Update(float curtime)
                        float weight = 1.f - (m_blendframe/m_blendin);
 
                        // Blend the poses
-                       game_blend_poses(m_pose, m_blendpose, weight);
+                       game_blend_poses(m_pose, m_blendpose, weight, ACTSTRIPMODE_BLEND);
                }
 
 
                // Handle layer blending
-               
+               if (m_blendmode != ACT_BLEND_NONE)
+               {
+                       obj->GetMRDPose(&m_blendpose);
+                       game_blend_poses(m_pose, m_blendpose, 1.f, ACTSTRIPMODE_ADD);
+               }
+
                obj->SetPose(m_pose);
 
                obj->SetActiveAction(NULL, 0, curtime);
index dfa06bd19d5a2068d9e098e755668b377f496803..096235eeb9941f4d44ac4ceb3c944198dedeeeeb 100644 (file)
@@ -67,6 +67,9 @@ bool BL_ActionManager::PlayAction(const char* name,
                                                                short ipo_flags,
                                                                float playback_speed)
 {
+       // Disable layer blending on the first layer
+       if (layer == 0) blend_mode = BL_Action::ACT_BLEND_NONE;
+
        return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
 }