[Bf-blender-cvs] [2c369b1] master: BGE: Cleanup BL_Action.

Porteries Tristan noreply at git.blender.org
Mon Oct 19 20:27:07 CEST 2015


Commit: 2c369b149044be5be6dfe8d881855ba846fbecc0
Author: Porteries Tristan
Date:   Mon Oct 19 19:32:54 2015 +0200
Branches: master
https://developer.blender.org/rB2c369b149044be5be6dfe8d881855ba846fbecc0

BGE: Cleanup BL_Action.

- Rename m_localtime to m_localframe to avoid ambiguity : it's a count for the actual action frame, not time.
- Delete m_end : it's unused.

===================================================================

M	source/gameengine/Ketsji/BL_Action.cpp
M	source/gameengine/Ketsji/BL_Action.h

===================================================================

diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index 4d5b6a0..078a989 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -75,7 +75,7 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
 	m_startframe(0.f),
 	m_endframe(0.f),
 	m_endtime(0.f),
-	m_localtime(0.f),
+	m_localframe(0.f),
 	m_blendin(0.f),
 	m_blendframe(0.f),
 	m_blendstart(0.f),
@@ -261,12 +261,11 @@ bool BL_Action::Play(const char* name,
 
 	// Now that we have an action, we have something we can play
 	m_starttime = -1.f; // We get the start time on our first update
-	m_startframe = m_localtime = start;
+	m_startframe = m_localframe = start;
 	m_endframe = end;
 	m_blendin = blendin;
 	m_playmode = play_mode;
 	m_blendmode = blend_mode;
-	m_endtime = 0.f;
 	m_blendframe = 0.f;
 	m_blendstart = 0.f;
 	m_speed = playback_speed;
@@ -302,7 +301,7 @@ bAction *BL_Action::GetAction()
 
 float BL_Action::GetFrame()
 {
-	return m_localtime;
+	return m_localframe;
 }
 
 const char *BL_Action::GetName()
@@ -325,7 +324,7 @@ void BL_Action::SetFrame(float frame)
 	else if (frame > max(m_startframe, m_endframe))
 		frame = max(m_startframe, m_endframe);
 	
-	m_localtime = frame;
+	m_localframe = frame;
 	m_calc_localtime = false;
 }
 
@@ -347,12 +346,12 @@ void BL_Action::SetLocalTime(float curtime)
 	if (m_endframe < m_startframe)
 		dt = -dt;
 
-	m_localtime = m_startframe + dt;
+	m_localframe = m_startframe + dt;
 }
 
 void BL_Action::ResetStartTime(float curtime)
 {
-	float dt = (m_localtime > m_startframe) ? m_localtime - m_startframe : m_startframe - m_localtime;
+	float dt = (m_localframe > m_startframe) ? m_localframe - m_startframe : m_startframe - m_localframe;
 
 	m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed);
 	SetLocalTime(curtime);
@@ -400,7 +399,7 @@ void BL_Action::Update(float curtime)
 
 	curtime -= KX_KetsjiEngine::GetSuspendedDelta();
 
-	// Grab the start time here so we don't end up with a negative m_localtime when
+	// Grab the start time here so we don't end up with a negative m_localframe when
 	// suspending and resuming scenes.
 	if (m_starttime < 0)
 		m_starttime = curtime;
@@ -414,16 +413,16 @@ void BL_Action::Update(float curtime)
 	}
 
 	// Handle wrap around
-	if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) {
+	if (m_localframe < min(m_startframe, m_endframe) || m_localframe > max(m_startframe, m_endframe)) {
 		switch (m_playmode) {
 			case ACT_MODE_PLAY:
 				// Clamp
-				m_localtime = m_endframe;
+				m_localframe = m_endframe;
 				m_done = true;
 				break;
 			case ACT_MODE_LOOP:
 				// Put the time back to the beginning
-				m_localtime = m_startframe;
+				m_localframe = m_startframe;
 				m_starttime = curtime;
 				break;
 			case ACT_MODE_PING_PONG:
@@ -446,7 +445,7 @@ void BL_Action::Update(float curtime)
 			obj->GetPose(&m_blendpose);
 
 		// Extract the pose from the action
-		obj->SetPoseByAction(m_tmpaction, m_localtime);
+		obj->SetPoseByAction(m_tmpaction, m_localframe);
 
 		// Handle blending between armature actions
 		if (m_blendin && m_blendframe<m_blendin)
@@ -480,7 +479,7 @@ void BL_Action::Update(float curtime)
 			PointerRNA ptrrna;
 			RNA_id_pointer_create(&key->id, &ptrrna);
 
-			animsys_evaluate_action(&ptrrna, m_tmpaction, NULL, m_localtime);
+			animsys_evaluate_action(&ptrrna, m_tmpaction, NULL, m_localframe);
 
 			// Handle blending between shape actions
 			if (m_blendin && m_blendframe < m_blendin)
@@ -514,7 +513,7 @@ void BL_Action::Update(float curtime)
 	/* This function is not thread safe because of recursive scene graph transform
 	 * updates on children. e.g: If an object and one of its children is animated,
 	 * the both can write transform at the same time. A thread lock avoid problems. */
-	m_obj->UpdateIPO(m_localtime, m_ipo_flags & ACT_IPOFLAG_CHILD);
+	m_obj->UpdateIPO(m_localframe, m_ipo_flags & ACT_IPOFLAG_CHILD);
 	BLI_spin_unlock(&BL_ActionLock);
 
 	if (m_done)
diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h
index f6124b0..f41b2ef 100644
--- a/source/gameengine/Ketsji/BL_Action.h
+++ b/source/gameengine/Ketsji/BL_Action.h
@@ -48,9 +48,9 @@ private:
 
 	float m_startframe;
 	float m_endframe;
+	/// The current action frame.
+	float m_localframe;
 	float m_starttime;
-	float m_endtime;
-	float m_localtime;
 
 	float m_blendin;
 	float m_blendframe;




More information about the Bf-blender-cvs mailing list