diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2011-07-03 05:59:17 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2011-07-03 05:59:17 +0400 |
commit | 5f4f75c51a511f4f190c16eedfc4c04c3b9aa387 (patch) | |
tree | 9c226d26639fdeb1c4b546183f4178979e7b93cb /source/gameengine/Ketsji | |
parent | 8c3f2923fdc0626d4c2e7f6307c1ec4fd0e8c7f3 (diff) |
BGE Animations: Adding in layer weights to allow for layer blending.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/BL_Action.cpp | 11 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_Action.h | 12 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_ActionManager.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Ketsji/BL_ActionManager.h | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 24 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.h | 2 |
6 files changed, 25 insertions, 32 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index dec34289bbb..f764a4b1028 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -46,7 +46,6 @@ 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) @@ -111,7 +110,7 @@ bool BL_Action::Play(const char* name, short priority, float blendin, short play_mode, - short blend_mode, + float layer_weight, short ipo_flags, float playback_speed) { @@ -173,11 +172,11 @@ 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; m_speed = playback_speed; + m_layer_weight = layer_weight; m_done = false; @@ -335,15 +334,15 @@ 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, ACTSTRIPMODE_BLEND); + game_blend_poses(m_pose, m_blendpose, weight); } // Handle layer blending - if (m_blendmode != ACT_BLEND_NONE) + if (m_layer_weight >= 0) { obj->GetMRDPose(&m_blendpose); - game_blend_poses(m_pose, m_blendpose, 1.f, ACTSTRIPMODE_ADD); + game_blend_poses(m_pose, m_blendpose, m_layer_weight); } obj->SetPose(m_pose); diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h index d9a2187540e..f03a22a81cd 100644 --- a/source/gameengine/Ketsji/BL_Action.h +++ b/source/gameengine/Ketsji/BL_Action.h @@ -58,12 +58,13 @@ private: float m_blendframe; float m_blendstart; + float m_layer_weight; + float m_speed; short m_priority; short m_playmode; - short m_blendmode; short m_ipo_flags; @@ -84,7 +85,7 @@ public: short priority, float blendin, short play_mode, - short blend_mode, + float layer_weight, short ipo_flags, float playback_speed); void Stop(); @@ -107,13 +108,6 @@ public: enum { - ACT_BLEND_NONE = 0, - ACT_BLEND_MIX, - ACT_BLEND_MAX, - }; - - enum - { ACT_IPOFLAG_FORCE = 1, ACT_IPOFLAG_LOCAL = 2, ACT_IPOFLAG_ADD = 4, diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp index 096235eeb99..8d862c38961 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.cpp +++ b/source/gameengine/Ketsji/BL_ActionManager.cpp @@ -63,14 +63,14 @@ bool BL_ActionManager::PlayAction(const char* name, short priority, float blendin, short play_mode, - short blend_mode, + float layer_weight, short ipo_flags, float playback_speed) { // Disable layer blending on the first layer - if (layer == 0) blend_mode = BL_Action::ACT_BLEND_NONE; + if (layer == 0) layer_weight = -1.f; - return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed); + return m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed); } void BL_ActionManager::StopAction(short layer) diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h index 99053ba27a6..3836c6b59d2 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.h +++ b/source/gameengine/Ketsji/BL_ActionManager.h @@ -49,7 +49,7 @@ public: short priority=0, float blendin=0.f, short play_mode=0, - short blend_mode=0, + float layer_weight=0.f, short ipo_flags=0, float playback_speed=1.f); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 35fe956b0e8..334868d283a 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -367,11 +367,11 @@ bool KX_GameObject::PlayAction(const char* name, short priority, float blendin, short play_mode, - short blend_mode, + float layer_weight, short ipo_flags, float playback_speed) { - return GetActionManager()->PlayAction(name, start, end, layer, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed); + return GetActionManager()->PlayAction(name, start, end, layer, priority, blendin, play_mode, layer_weight, ipo_flags, playback_speed); } void KX_GameObject::StopAction(short layer) @@ -3037,19 +3037,19 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage, } KX_PYMETHODDEF_DOC(KX_GameObject, playAction, - "playAction(name, start_frame, end_frame, layer=0, priority=0 blendin=0, play_mode=ACT_MODE_PLAY, blend_mode=ACT_BLEND_NONE, ipo_flags=0, speed=1.0)\n" + "playAction(name, start_frame, end_frame, layer=0, priority=0 blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0)\n" "plays an action\n") { const char* name; - float start, end, blendin=0.f, speed=1.f; + float start, end, blendin=0.f, speed=1.f, layer_weight=0.f; short layer=0, priority=0; short ipo_flags=0; - short play_mode=0, blend_mode=0; + short play_mode=0; - static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "priority", "blendin", "play_mode", "blend_mode", "ipo_flags", "speed", NULL}; + static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "priority", "blendin", "play_mode", "layer_weight", "ipo_flags", "speed", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhhhf:playAction", const_cast<char**>(kwlist), - &name, &start, &end, &layer, &priority, &blendin, &play_mode, &blend_mode, &ipo_flags, &speed)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhfhf:playAction", const_cast<char**>(kwlist), + &name, &start, &end, &layer, &priority, &blendin, &play_mode, &layer_weight, &ipo_flags, &speed)) return NULL; if (layer < 0 || layer > MAX_ACTION_LAYERS) @@ -3064,13 +3064,13 @@ KX_PYMETHODDEF_DOC(KX_GameObject, playAction, play_mode = BL_Action::ACT_MODE_MAX; } - if (blend_mode < 0 || blend_mode > BL_Action::ACT_BLEND_MAX) + if (layer_weight < 0.f || layer_weight > 1.f) { - printf("KX_GameObject.playAction(): given blend_mode (%d) is out of range (0 - %d), setting to ACT_BLEND_NONE", blend_mode, BL_Action::ACT_BLEND_MAX-1); - blend_mode = BL_Action::ACT_BLEND_NONE; + printf("KX_GameObject.playAction(): given layer_weight (%f) is out of range (0.0 - 1.0), setting to 0.0", layer_weight); + layer_weight = 0.f; } - PlayAction(name, start, end, layer, priority, blendin, play_mode, blend_mode, ipo_flags, speed); + PlayAction(name, start, end, layer, priority, blendin, play_mode, layer_weight, ipo_flags, speed); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index b43b5e02d45..96bd42ba702 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -218,7 +218,7 @@ public: short priority=0, float blendin=0.f, short play_mode=0, - short blend_mode=0, + float layer_weight=0.f, short ipo_flags=0, float playback_speed=1.f); |