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-08-08 08:28:30 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-08-08 08:28:30 +0400
commit8883702f8a3b57d0316811e9412bd46ce0dd9c0d (patch)
tree0aff4a8eaee6ad9e9d1fbd6e60c85fa6a81149df /source/gameengine/Ketsji/BL_Action.cpp
parenta8096ef0acb780d5a6d93aef422ce3d82877a60c (diff)
BGE Animations: Various compatibility fixes:
* Blendin for Loop End works even after a negative pulse. Flipper could still use some work in this area. * Continuous works a lot better. * BL_Action::SetFrame() should work a little smoother.
Diffstat (limited to 'source/gameengine/Ketsji/BL_Action.cpp')
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp43
1 files changed, 31 insertions, 12 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index caffd3cd8ca..4cf6f982006 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -67,7 +67,8 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
m_priority(0),
m_playmode(0),
m_ipo_flags(0),
- m_done(true)
+ m_done(true),
+ m_calc_localtime(true)
{
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
@@ -215,24 +216,25 @@ float BL_Action::GetFrame()
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;
+ m_localtime = frame;
+ m_calc_localtime = false;
+}
- if (m_endframe < m_startframe)
- dt = -dt;
+void BL_Action::SetPlayMode(short play_mode)
+{
+ m_playmode = play_mode;
+}
- m_starttime -= dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed);
+void BL_Action::SetTimes(float start, float end)
+{
+ m_startframe = start;
+ m_endframe = end;
}
void BL_Action::SetLocalTime(float curtime)
@@ -245,6 +247,16 @@ void BL_Action::SetLocalTime(float curtime)
m_localtime = m_startframe + dt;
}
+void BL_Action::ResetStartTime(float curtime)
+{
+ float dt = m_localtime - m_startframe;
+
+ m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed);
+ printf("Before: %f, ", m_localtime);
+ SetLocalTime(curtime);
+ printf("After: %f\n", m_localtime);
+}
+
void BL_Action::IncrementBlending(float curtime)
{
// Setup m_blendstart if we need to
@@ -285,7 +297,14 @@ void BL_Action::Update(float curtime)
return;
curtime -= KX_KetsjiEngine::GetSuspendedDelta();
- SetLocalTime(curtime);
+
+ if (m_calc_localtime)
+ SetLocalTime(curtime);
+ else
+ {
+ ResetStartTime(curtime);
+ m_calc_localtime = true;
+ }
// Handle wrap around
if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))