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>2011-06-01 11:42:40 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-06-01 11:42:40 +0400
commit39bbf3854a5c91e3d8e410d01b34d4e88df20879 (patch)
tree63b5a746bb780fe54eb398f764ce90eed5f3cf7f /source/gameengine/Ketsji/BL_Action.cpp
parent6394261e54215d50b1e39e8ea45dcb63080f193e (diff)
BGE Animations: Reimplemented the continuous function of the action actuator.
* To do this, I've added Get/SetFrame() functions. * I've also cleaned up a little bit of the wrap around logic in BL_Action.cpp.
Diffstat (limited to 'source/gameengine/Ketsji/BL_Action.cpp')
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp33
1 files changed, 30 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index 5630179a049..77cb5de1398 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -27,6 +27,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include <cstdlib>
+
#include "BL_Action.h"
#include "BL_ArmatureObject.h"
#include "KX_IpoConvert.h"
@@ -106,6 +108,33 @@ void BL_Action::InitIPO()
m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, false);
}
+float BL_Action::GetFrame()
+{
+ return m_localtime;
+}
+
+void BL_Action::SetFrame(float frame)
+{
+ float dt;
+
+ // Clamp the frame to the start and end frame
+ if (frame < min(m_startframe, m_endframe))
+ frame = min(m_startframe, m_endframe);
+ else if (frame > max(m_startframe, m_endframe))
+ frame = max(m_startframe, m_endframe);
+
+ // We don't set m_localtime directly since it's recalculated
+ // in the next update. So, we modify the value (m_starttime)
+ // used to calculate m_localtime the next time SetLocalTime() is called.
+
+ dt = frame-m_startframe;
+
+ if (m_endframe < m_startframe)
+ dt = -dt;
+
+ m_starttime -= dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed);
+}
+
void BL_Action::SetLocalTime(float curtime)
{
float dt = (curtime-m_starttime)*KX_KetsjiEngine::GetAnimFrameRate()*m_speed;
@@ -127,9 +156,7 @@ void BL_Action::Update(float curtime)
SetLocalTime(curtime);
// Handle wrap around
- bool bforward = m_startframe < m_endframe;
- if (bforward && (m_localtime < m_startframe || m_localtime > m_endframe) ||
- !bforward && (m_localtime > m_startframe || m_localtime < m_endframe))
+ if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))
{
switch(m_playmode)
{