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-06-24 02:12:49 +0400
committerMitchell Stokes <mogurijin@gmail.com>2011-06-24 02:12:49 +0400
commitf1a2d46aa0194d831ee8e0a69ee36a3ca669e6f5 (patch)
tree0c578f6b5cb061694e1886adbcc7cd4080ee9419
parent0fbca841efa832c769e023a5e23267bfb00954f7 (diff)
BGE Animations: Adding the concept of priority back. Priority is handled on a per layer basis.
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp4
-rw-r--r--source/gameengine/Ketsji/BL_Action.cpp8
-rw-r--r--source/gameengine/Ketsji/BL_Action.h3
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.cpp8
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.h1
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp15
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h1
7 files changed, 25 insertions, 15 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index d1f500abebd..3368e43c9e8 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -184,7 +184,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
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 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
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;
diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp
index 8f77d2728b2..06cf0318859 100644
--- a/source/gameengine/Ketsji/BL_Action.cpp
+++ b/source/gameengine/Ketsji/BL_Action.cpp
@@ -60,6 +60,7 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
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 @@ BL_Action::~BL_Action()
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
diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h
index fc80d9bea34..b5d9f0566cd 100644
--- a/source/gameengine/Ketsji/BL_Action.h
+++ b/source/gameengine/Ketsji/BL_Action.h
@@ -56,6 +56,8 @@ private:
float m_speed;
+ short m_priority;
+
short m_playmode;
short m_blendmode;
@@ -72,6 +74,7 @@ public:
void Play(const char* name,
float start,
float end,
+ short priority,
float blendin,
short play_mode,
short blend_mode,
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
index 935e9129d21..9e847b20c9d 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ b/source/gameengine/Ketsji/BL_ActionManager.cpp
@@ -60,18 +60,14 @@ void BL_ActionManager::PlayAction(const char* name,
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)
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
index f4ef43d3801..41907c20204 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ b/source/gameengine/Ketsji/BL_ActionManager.h
@@ -46,6 +46,7 @@ public:
float start,
float end,
short layer=0,
+ short priority=0,
float blendin=0.f,
short play_mode=0,
short blend_mode=0,
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index aa0ce14a3cc..175a2b6ccdf 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -364,13 +364,14 @@ void KX_GameObject::PlayAction(const char* name,
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_VARARGS(KX_GameObject, sendMessage,
}
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 @@ KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
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;
}
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index b97dad1a35e..b5ece5f8ac8 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -215,6 +215,7 @@ public:
float start,
float end,
short layer=0,
+ short priority=0,
float blendin=0.f,
short play_mode=0,
short blend_mode=0,