Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2015-10-07 08:16:22 +0300
committerMitchell Stokes <mogurijin@gmail.com>2015-10-07 08:22:47 +0300
commit0d36233dd81c92d98b2e665d04a8034e7b27aba0 (patch)
tree5f30e202b3a44d9d543019fe337490e8926195b1 /source/gameengine/Ketsji
parente4e8e359a15401a90f54db7131c1690a1bff385a (diff)
Fix for T41536: 2.71 getActionFrame no longer returns frames accurately
We now keep actions around when they are finished playing so scripts can still get access to information such as the current frame. Playing a new action in the same layer still overwrites the previous action as before this commit. Using an explicit KX_GameObject.stopAction() will free the memory. The action is also freed when the KX_GameObject is freed as before.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp5
-rw-r--r--source/gameengine/Ketsji/BL_Action.h4
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.cpp28
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.h5
4 files changed, 10 insertions, 32 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index 12a1caee221..507476dbd0e 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -268,11 +268,6 @@ bool BL_Action::Play(const char* name,
return true;
}
-void BL_Action::Stop()
-{
- m_done = true;
-}
-
bool BL_Action::IsDone()
{
return m_done;
diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h
index 379dd52df5b..7a404416758 100644
--- a/source/gameengine/Ketsji/BL_Action.h
+++ b/source/gameengine/Ketsji/BL_Action.h
@@ -94,10 +94,6 @@ public:
float playback_speed,
short blend_mode);
/**
- * Stop playing the action
- */
- void Stop();
- /**
* Whether or not the action is still playing
*/
bool IsDone();
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
index 9e4690548d3..4249db55b45 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ b/source/gameengine/Ketsji/BL_ActionManager.cpp
@@ -53,14 +53,6 @@ BL_Action *BL_ActionManager::GetAction(short layer)
return (it != m_layers.end()) ? it->second : 0;
}
-BL_Action* BL_ActionManager::AddAction(short layer)
-{
- BL_Action *action = new BL_Action(m_obj);
- m_layers[layer] = action;
-
- return action;
-}
-
float BL_ActionManager::GetActionFrame(short layer)
{
BL_Action *action = GetAction(layer);
@@ -116,8 +108,10 @@ bool BL_ActionManager::PlayAction(const char* name,
{
// Only this method will create layer if non-existent
BL_Action *action = GetAction(layer);
- if (!action)
- action = AddAction(layer);
+ if (!action) {
+ action = new BL_Action(m_obj);
+ m_layers[layer] = action;
+ }
// Disable layer blending on the first layer
if (layer == 0) layer_weight = -1.f;
@@ -129,7 +123,10 @@ void BL_ActionManager::StopAction(short layer)
{
BL_Action *action = GetAction(layer);
- if (action) action->Stop();
+ if (action) {
+ m_layers.erase(layer);
+ delete action;
+ }
}
void BL_ActionManager::RemoveTaggedActions()
@@ -158,15 +155,10 @@ void BL_ActionManager::Update(float curtime)
m_prevUpdate = curtime;
BL_ActionMap::iterator it;
- for (it = m_layers.begin(); it != m_layers.end(); )
+ for (it = m_layers.begin(); it != m_layers.end(); ++it)
{
- if (it->second->IsDone()) {
- delete it->second;
- m_layers.erase(it++);
- }
- else {
+ if (!it->second->IsDone()) {
it->second->Update(curtime);
- ++it;
}
}
}
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
index 97d6d88cf22..1292938d8f4 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ b/source/gameengine/Ketsji/BL_ActionManager.h
@@ -59,11 +59,6 @@ private:
*/
BL_Action* GetAction(short layer);
- /**
- * Add new action with given layer
- */
- BL_Action* AddAction(short layer);
-
public:
BL_ActionManager(class KX_GameObject* obj);
~BL_ActionManager();