forked from bartvdbraak/blender
BGE Animations: Adding the concept of priority back. Priority is handled on a per layer basis.
This commit is contained in:
parent
0fbca841ef
commit
f1a2d46aa0
@ -184,7 +184,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
|
|||||||
if (!m_is_going && bPositiveEvent)
|
if (!m_is_going && bPositiveEvent)
|
||||||
{
|
{
|
||||||
m_is_going = true;
|
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)
|
if (m_end_reset)
|
||||||
obj->SetActionFrame(m_layer, m_localtime);
|
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)
|
else if (m_playtype == ACT_ACTION_LOOP_END)
|
||||||
{
|
{
|
||||||
// Convert into a play and let it finish
|
// 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);
|
obj->SetActionFrame(m_layer, m_localtime);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -60,6 +60,7 @@ BL_Action::BL_Action(class KX_GameObject* gameobj)
|
|||||||
m_blendframe(0.f),
|
m_blendframe(0.f),
|
||||||
m_blendstart(0.f),
|
m_blendstart(0.f),
|
||||||
m_speed(0.f),
|
m_speed(0.f),
|
||||||
|
m_priority(0),
|
||||||
m_ipo_flags(0),
|
m_ipo_flags(0),
|
||||||
m_pose(NULL),
|
m_pose(NULL),
|
||||||
m_blendpose(NULL),
|
m_blendpose(NULL),
|
||||||
@ -105,12 +106,19 @@ BL_Action::~BL_Action()
|
|||||||
void BL_Action::Play(const char* name,
|
void BL_Action::Play(const char* name,
|
||||||
float start,
|
float start,
|
||||||
float end,
|
float end,
|
||||||
|
short priority,
|
||||||
float blendin,
|
float blendin,
|
||||||
short play_mode,
|
short play_mode,
|
||||||
short blend_mode,
|
short blend_mode,
|
||||||
short ipo_flags,
|
short ipo_flags,
|
||||||
float playback_speed)
|
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;
|
bAction* prev_action = m_action;
|
||||||
|
|
||||||
// First try to load the action
|
// First try to load the action
|
||||||
|
@ -56,6 +56,8 @@ private:
|
|||||||
|
|
||||||
float m_speed;
|
float m_speed;
|
||||||
|
|
||||||
|
short m_priority;
|
||||||
|
|
||||||
short m_playmode;
|
short m_playmode;
|
||||||
short m_blendmode;
|
short m_blendmode;
|
||||||
|
|
||||||
@ -72,6 +74,7 @@ public:
|
|||||||
void Play(const char* name,
|
void Play(const char* name,
|
||||||
float start,
|
float start,
|
||||||
float end,
|
float end,
|
||||||
|
short priority,
|
||||||
float blendin,
|
float blendin,
|
||||||
short play_mode,
|
short play_mode,
|
||||||
short blend_mode,
|
short blend_mode,
|
||||||
|
@ -60,18 +60,14 @@ void BL_ActionManager::PlayAction(const char* name,
|
|||||||
float start,
|
float start,
|
||||||
float end,
|
float end,
|
||||||
short layer,
|
short layer,
|
||||||
|
short priority,
|
||||||
float blendin,
|
float blendin,
|
||||||
short play_mode,
|
short play_mode,
|
||||||
short blend_mode,
|
short blend_mode,
|
||||||
short ipo_flags,
|
short ipo_flags,
|
||||||
float playback_speed)
|
float playback_speed)
|
||||||
{
|
{
|
||||||
// Remove a currently running action on this layer if there is one
|
m_layers[layer]->Play(name, start, end, priority, blendin, play_mode, blend_mode, ipo_flags, playback_speed);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BL_ActionManager::StopAction(short layer)
|
void BL_ActionManager::StopAction(short layer)
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
float start,
|
float start,
|
||||||
float end,
|
float end,
|
||||||
short layer=0,
|
short layer=0,
|
||||||
|
short priority=0,
|
||||||
float blendin=0.f,
|
float blendin=0.f,
|
||||||
short play_mode=0,
|
short play_mode=0,
|
||||||
short blend_mode=0,
|
short blend_mode=0,
|
||||||
|
@ -364,13 +364,14 @@ void KX_GameObject::PlayAction(const char* name,
|
|||||||
float start,
|
float start,
|
||||||
float end,
|
float end,
|
||||||
short layer,
|
short layer,
|
||||||
|
short priority,
|
||||||
float blendin,
|
float blendin,
|
||||||
short play_mode,
|
short play_mode,
|
||||||
short blend_mode,
|
short blend_mode,
|
||||||
short ipo_flags,
|
short ipo_flags,
|
||||||
float playback_speed)
|
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)
|
void KX_GameObject::StopAction(short layer)
|
||||||
@ -3034,19 +3035,19 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage,
|
|||||||
}
|
}
|
||||||
|
|
||||||
KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
|
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")
|
"plays an action\n")
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
float start, end, blendin=0.f, speed=1.f;
|
float start, end, blendin=0.f, speed=1.f;
|
||||||
short layer=0;
|
short layer=0, priority=0;
|
||||||
short ipo_flags=0;
|
short ipo_flags=0;
|
||||||
short play_mode=0, blend_mode=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),
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sff|hhfhhhf", const_cast<char**>(kwlist),
|
||||||
&name, &start, &end, &layer, &blendin, &play_mode, &blend_mode, &ipo_flags, &speed))
|
&name, &start, &end, &layer, &priority, &blendin, &play_mode, &blend_mode, &ipo_flags, &speed))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (layer < 0 || layer > MAX_ACTION_LAYERS)
|
if (layer < 0 || layer > MAX_ACTION_LAYERS)
|
||||||
@ -3067,7 +3068,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, playAction,
|
|||||||
blend_mode = BL_Action::ACT_BLEND_NONE;
|
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;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,7 @@ public:
|
|||||||
float start,
|
float start,
|
||||||
float end,
|
float end,
|
||||||
short layer=0,
|
short layer=0,
|
||||||
|
short priority=0,
|
||||||
float blendin=0.f,
|
float blendin=0.f,
|
||||||
short play_mode=0,
|
short play_mode=0,
|
||||||
short blend_mode=0,
|
short blend_mode=0,
|
||||||
|
Loading…
Reference in New Issue
Block a user