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 | |
parent | 8c3f2923fdc0626d4c2e7f6307c1ec4fd0e8c7f3 (diff) |
BGE Animations: Adding in layer weights to allow for layer blending.
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/BL_ActionActuator.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ActionActuator.h | 3 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ArmatureObject.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ArmatureObject.h | 2 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_ConvertActuators.cpp | 1 | ||||
-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 |
11 files changed, 34 insertions, 36 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 7c86f19a883..05e612050e4 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -184,7 +184,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (!m_is_going && bPositiveEvent) { m_is_going = true; - if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, 0, m_ipo_flags) && m_end_reset) + if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, m_layer_weight, m_ipo_flags) && m_end_reset) obj->SetActionFrame(m_layer, m_localtime); } else if (m_is_going && bNegativeEvent) @@ -203,7 +203,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) else if (m_playtype == ACT_ACTION_LOOP_END) { // Convert into a play and let it finish - obj->PlayAction(m_action->id.name+2, start, end, m_layer, 0, 0, BL_Action::ACT_MODE_PLAY, 0, m_ipo_flags); + obj->PlayAction(m_action->id.name+2, start, end, m_layer, 0, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags); obj->SetActionFrame(m_layer, m_localtime); return true; diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 96b9b5e2551..3004aa2e6ca 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -53,6 +53,7 @@ public: short blendin, short priority, short layer, + float layer_weight, short ipo_flags, short end_reset, float stride) @@ -72,6 +73,7 @@ public: m_playtype(playtype), m_priority(priority), m_layer(layer), + m_layer_weight(layer_weight), m_ipo_flags(ipo_flags), m_end_reset(end_reset), m_is_going(false), @@ -165,6 +167,7 @@ protected: float m_blendin; float m_blendstart; float m_stridelength; + float m_layer_weight; short m_playtype; short m_priority; short m_layer; diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index f33eafce620..7fd40875397 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -137,13 +137,14 @@ 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) +void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/) { bPoseChannel *dchan; const bPoseChannel *schan; bConstraint *dcon, *scon; float dstweight; int i; + short mode = ACTSTRIPMODE_BLEND; switch (mode){ case ACTSTRIPMODE_BLEND: diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 92a9a3685c9..2c3ca7404b3 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -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); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index e952fb2687f..a06e16b2f1d 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -220,6 +220,7 @@ void BL_ConvertActuators(char* maggiename, actact->blendin, actact->priority, actact->layer, + actact->layer_weight, ipo_flags, actact->end_reset, actact->stridelength 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); |