From d122f24c1af429dd59a0051db01650fd2b1abbba Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 29 Jun 2011 01:53:17 +0000 Subject: [PATCH] BGE Animations: Fixing a bug with priority and non continuous animations. --- source/gameengine/Converter/BL_ActionActuator.cpp | 3 +-- source/gameengine/Ketsji/BL_Action.cpp | 11 ++++++++--- source/gameengine/Ketsji/BL_Action.h | 2 +- source/gameengine/Ketsji/BL_ActionManager.cpp | 4 ++-- source/gameengine/Ketsji/BL_ActionManager.h | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 4 ++-- source/gameengine/Ketsji/KX_GameObject.h | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 3368e43c9e8..5a91c10c189 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -184,8 +184,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (!m_is_going && bPositiveEvent) { m_is_going = true; - obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, 0, m_ipo_flags); - if (m_end_reset) + 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) obj->SetActionFrame(m_layer, m_localtime); } else if (m_is_going && bNegativeEvent) diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 1741e74a771..149189b6a79 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -104,7 +104,7 @@ BL_Action::~BL_Action() delete m_ptrrna; } -void BL_Action::Play(const char* name, +bool BL_Action::Play(const char* name, float start, float end, short priority, @@ -118,7 +118,7 @@ void BL_Action::Play(const char* name, // Only start playing a new action if we're done, or if // the new action has a higher priority if (priority != 0 && !IsDone() && priority >= m_priority) - return; + return false; m_priority = priority; bAction* prev_action = m_action; @@ -128,7 +128,7 @@ void BL_Action::Play(const char* name, { printf("Failed to load action: %s\n", name); m_done = true; - return; + return false; } if (prev_action != m_action) @@ -178,6 +178,8 @@ void BL_Action::Play(const char* name, m_speed = playback_speed; m_done = false; + + return true; } void BL_Action::Stop() @@ -329,6 +331,9 @@ void BL_Action::Update(float curtime) game_blend_poses(m_pose, m_blendpose, weight); } + + // Handle layer blending + obj->SetPose(m_pose); obj->SetActiveAction(NULL, 0, curtime); diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h index de09ab13c68..c4544fcda44 100644 --- a/source/gameengine/Ketsji/BL_Action.h +++ b/source/gameengine/Ketsji/BL_Action.h @@ -78,7 +78,7 @@ public: BL_Action(class KX_GameObject* gameobj); ~BL_Action(); - void Play(const char* name, + bool Play(const char* name, float start, float end, short priority, diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp index 9e847b20c9d..dfa06bd19d5 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.cpp +++ b/source/gameengine/Ketsji/BL_ActionManager.cpp @@ -56,7 +56,7 @@ void BL_ActionManager::SetActionFrame(short layer, float frame) m_layers[layer]->SetFrame(frame); } -void BL_ActionManager::PlayAction(const char* name, +bool BL_ActionManager::PlayAction(const char* name, float start, float end, short layer, @@ -67,7 +67,7 @@ void BL_ActionManager::PlayAction(const char* name, short ipo_flags, float playback_speed) { - 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, blend_mode, 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 41907c20204..99053ba27a6 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.h +++ b/source/gameengine/Ketsji/BL_ActionManager.h @@ -42,7 +42,7 @@ public: BL_ActionManager(class KX_GameObject* obj); ~BL_ActionManager(); - void PlayAction(const char* name, + bool PlayAction(const char* name, float start, float end, short layer=0, diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 152efed7a4b..35fe956b0e8 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -360,7 +360,7 @@ BL_ActionManager* KX_GameObject::GetActionManager() return m_actionManager; } -void KX_GameObject::PlayAction(const char* name, +bool KX_GameObject::PlayAction(const char* name, float start, float end, short layer, @@ -371,7 +371,7 @@ void KX_GameObject::PlayAction(const char* name, short ipo_flags, float playback_speed) { - 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, blend_mode, ipo_flags, playback_speed); } void KX_GameObject::StopAction(short layer) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index b55b2bba60a..b43b5e02d45 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -211,7 +211,7 @@ public: /** * Adds an action to the object's action manager */ - void PlayAction(const char* name, + bool PlayAction(const char* name, float start, float end, short layer=0,