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-07-05 09:22:02 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-07-05 09:22:02 +0400
commitceabc6d119caa8132182697bf655f595c468dc2e (patch)
treeeb97faa07b43f9d638875cc07d2026d6c448748a /source/gameengine/Ketsji/BL_Action.cpp
parentafd77d081aa9c9fb51e22961e962b13f90da6cd8 (diff)
BGE Animations: Various fixes and bits of cleanup to get the action actuator to behave more like it did in trunk. The Pepper version is still more sensitive to pulses than the trunk version, but this is more accurate. I might try to address this, but I'm not sure.
Diffstat (limited to 'source/gameengine/Ketsji/BL_Action.cpp')
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index 04d05d87c06..f1b53fc4151 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -62,8 +62,7 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
m_blendinpose(NULL),
m_sg_contr(NULL),
m_ptrrna(NULL),
- m_done(true),
- m_bcalc_local_time(true)
+ m_done(true)
{
if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
{
@@ -197,6 +196,11 @@ void BL_Action::InitIPO()
m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, m_ipo_flags & ACT_IPOFLAG_LOCAL);
}
+bAction *BL_Action::GetAction()
+{
+ return (IsDone()) ? NULL : m_action;
+}
+
float BL_Action::GetFrame()
{
return m_localtime;
@@ -204,14 +208,24 @@ 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;
+
+ if (m_endframe < m_startframe)
+ dt = -dt;
- m_localtime = frame;
- m_bcalc_local_time = false;
+ m_starttime -= dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed);
}
void BL_Action::SetLocalTime(float curtime)
@@ -263,16 +277,8 @@ void BL_Action::Update(float curtime)
if (m_done)
return;
- // We only want to calculate the current time if we weren't given a frame (e.g., from SetFrame())
- if (m_bcalc_local_time)
- {
- curtime -= KX_KetsjiEngine::GetSuspendedDelta();
- SetLocalTime(curtime);
- }
- else
- {
- m_bcalc_local_time = true;
- }
+ curtime -= KX_KetsjiEngine::GetSuspendedDelta();
+ SetLocalTime(curtime);
// Handle wrap around
if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))