[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37770] branches/soc-2011-pepper/source/ gameengine: BGE Animations: Adding the concept of priority back.

Mitchell Stokes mogurijin at gmail.com
Fri Jun 24 00:12:49 CEST 2011


Revision: 37770
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37770
Author:   moguri
Date:     2011-06-23 22:12:49 +0000 (Thu, 23 Jun 2011)
Log Message:
-----------
BGE Animations: Adding the concept of priority back. Priority is handled on a per layer basis.

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

Modified: branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp	2011-06-23 22:11:25 UTC (rev 37769)
+++ branches/soc-2011-pepper/source/gameengine/Converter/BL_ActionActuator.cpp	2011-06-23 22:12:49 UTC (rev 37770)
@@ -184,7 +184,7 @@
 	if (!m_is_going && bPositiveEvent)
 	{		
 		m_is_going = true;
-		obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_blendin, play_mode, 0, m_ipo_flags);
+		obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, 0, m_ipo_flags);
 		if (m_end_reset)
 			obj->SetActionFrame(m_layer, m_localtime);
 	}
@@ -204,7 +204,7 @@
 		else if (m_playtype == ACT_ACTION_LOOP_END)
 		{
 			// Convert into a play and let it finish
-			obj->PlayAction(m_action->id.name+2, start, end, m_layer, 0, BL_Action::ACT_MODE_PLAY, 0, m_ipo_flags);
+			obj->PlayAction(m_action->id.name+2, start, end, m_layer, 0, 0, BL_Action::ACT_MODE_PLAY, 0, m_ipo_flags);
 			obj->SetActionFrame(m_layer, m_localtime);
 
 			return true;

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-06-23 22:11:25 UTC (rev 37769)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.cpp	2011-06-23 22:12:49 UTC (rev 37770)
@@ -60,6 +60,7 @@
 	m_blendframe(0.f),
 	m_blendstart(0.f),
 	m_speed(0.f),
+	m_priority(0),
 	m_ipo_flags(0),
 	m_pose(NULL),
 	m_blendpose(NULL),
@@ -105,12 +106,19 @@
 void BL_Action::Play(const char* name,
 					float start,
 					float end,
+					short priority,
 					float blendin,
 					short play_mode,
 					short blend_mode,
 					short ipo_flags,
 					float playback_speed)
 {
+
+	// Only start playing a new action if we're done, or if
+	// the new action has a higher priority
+	if (priority != 0 && !IsDone() && priority >= m_priority)
+		return;
+	m_priority = priority;
 	bAction* prev_action = m_action;
 
 	// First try to load the action

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-06-23 22:11:25 UTC (rev 37769)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_Action.h	2011-06-23 22:12:49 UTC (rev 37770)
@@ -56,6 +56,8 @@
 
 	float m_speed;
 
+	short m_priority;
+
 	short m_playmode;
 	short m_blendmode;
 
@@ -72,6 +74,7 @@
 	void Play(const char* name,
 			float start,
 			float end,
+			short priority,
 			float blendin,
 			short play_mode,
 			short blend_mode,

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp	2011-06-23 22:11:25 UTC (rev 37769)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.cpp	2011-06-23 22:12:49 UTC (rev 37770)
@@ -60,18 +60,14 @@
 								float start,
 								float end,
 								short layer,
+								short priority,
 								float blendin,
 								short play_mode,
 								short blend_mode,
 								short ipo_flags,
 								float playback_speed)
 {
-	// Remove a currently running action on this layer if there is one
-	if (m_layers[layer])
-		StopAction(layer);
-
-	// Create a new action
-	m_layers[layer]->Play(name, start, end, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
+	m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
 }
 
 void BL_ActionManager::StopAction(short layer)

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.h	2011-06-23 22:11:25 UTC (rev 37769)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/BL_ActionManager.h	2011-06-23 22:12:49 UTC (rev 37770)
@@ -46,6 +46,7 @@
 					float start,
 					float end,
 					short layer=0,
+					short priority=0,
 					float blendin=0.f,
 					short play_mode=0,
 					short blend_mode=0,

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp	2011-06-23 22:11:25 UTC (rev 37769)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.cpp	2011-06-23 22:12:49 UTC (rev 37770)
@@ -364,13 +364,14 @@
 								float start,
 								float end,
 								short layer,
+								short priority,
 								float blendin,
 								short play_mode,
 								short blend_mode,
 								short ipo_flags,
 								float playback_speed)
 {
-	GetActionManager()->PlayAction(name, start, end, layer, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
+	GetActionManager()->PlayAction(name, start, end, layer, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
 }
 
 void KX_GameObject::StopAction(short layer)
@@ -3034,19 +3035,19 @@
 }
 
 KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
-	"playAction(name, start_frame, end_frame, layer=0, blendin=0, play_mode=ACT_MODE_PLAY, blend_mode=ACT_BLEND_NONE, ipo_flags=0, speed=1.0)\n"
+	"playAction(name, start_frame, end_frame, layer=0, priority=0 blendin=0, play_mode=ACT_MODE_PLAY, blend_mode=ACT_BLEND_NONE, ipo_flags=0, speed=1.0)\n"
 	"plays an action\n")
 {
 	const char* name;
 	float start, end, blendin=0.f, speed=1.f;
-	short layer=0;
+	short layer=0, priority=0;
 	short ipo_flags=0;
 	short play_mode=0, blend_mode=0;
 
-	static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "blendin", "play_mode", "blend_mode", "ipo_flags", "speed", NULL};
+	static const char *kwlist[] = {"name", "start_frame", "end_frame", "layer", "priority", "blendin", "play_mode", "blend_mode", "ipo_flags", "speed", NULL};
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hfhhhf", const_cast<char**>(kwlist),
-									&name, &start, &end, &layer, &blendin, &play_mode, &blend_mode, &ipo_flags, &speed))
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhhhf", const_cast<char**>(kwlist),
+									&name, &start, &end, &layer, &priority, &blendin, &play_mode, &blend_mode, &ipo_flags, &speed))
 		return NULL;
 
 	if (layer < 0 || layer > MAX_ACTION_LAYERS)
@@ -3067,7 +3068,7 @@
 		blend_mode = BL_Action::ACT_BLEND_NONE;
 	}
 
-	PlayAction(name, start, end, layer, blendin, play_mode, blend_mode, ipo_flags, speed);
+	PlayAction(name, start, end, layer, priority, blendin, play_mode, blend_mode, ipo_flags, speed);
 
 	Py_RETURN_NONE;
 }

Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h	2011-06-23 22:11:25 UTC (rev 37769)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/KX_GameObject.h	2011-06-23 22:12:49 UTC (rev 37770)
@@ -215,6 +215,7 @@
 					float start,
 					float end,
 					short layer=0,
+					short priority=0,
 					float blendin=0.f,
 					short play_mode=0,
 					short blend_mode=0,




More information about the Bf-blender-cvs mailing list