[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37778] branches/soc-2011-pepper/source/ gameengine/Ketsji: BGE Animations: Making BL_Action::SetFrame() not so dependent on timing.

Mitchell Stokes mogurijin at gmail.com
Fri Jun 24 01:19:40 CEST 2011


Revision: 37778
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37778
Author:   moguri
Date:     2011-06-23 23:19:39 +0000 (Thu, 23 Jun 2011)
Log Message:
-----------
BGE Animations: Making BL_Action::SetFrame() not so dependent on timing. This should smooth out things like setActionFrame().

Modified Paths:
--------------
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
    branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-06-23 23:18:53 UTC (rev 37777)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-06-23 23:19:39 UTC (rev 37778)
@@ -66,7 +66,8 @@
 	m_blendpose(NULL),
 	m_sg_contr(NULL),
 	m_ptrrna(NULL),
-	m_done(true)
+	m_done(true),
+	m_bcalc_local_time(true)
 {
 	if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE)
 	{
@@ -184,6 +185,10 @@
 	else if (frame > max(m_startframe, m_endframe))
 		frame = max(m_startframe, m_endframe);
 
+	m_localtime = frame;
+	m_bcalc_local_time = false;
+
+#if 0
 	// 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.
@@ -194,6 +199,7 @@
 		dt = -dt;
 
 	m_starttime -= dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed);
+#endif
 }
 
 void BL_Action::SetLocalTime(float curtime)
@@ -212,10 +218,17 @@
 	if (m_done)
 		return;
 
-	curtime -= KX_KetsjiEngine::GetSuspendedDelta();
+	// We only want to calculate the current time 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;
+	}
 
-	SetLocalTime(curtime);
-
 	// Handle wrap around
 	if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))
 	{

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-06-23 23:18:53 UTC (rev 37777)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-06-23 23:19:39 UTC (rev 37778)
@@ -64,6 +64,7 @@
 	short m_ipo_flags;
 
 	bool m_done;
+	bool m_bcalc_local_time;
 
 	void InitIPO();
 	void SetLocalTime(float curtime);




More information about the Bf-blender-cvs mailing list