BGE Animations: Adding a layer option to Action actuators.

This commit is contained in:
2011-06-11 01:03:03 +00:00
parent e67edaf6ac
commit 8e85491ab7
6 changed files with 21 additions and 7 deletions

View File

@@ -3699,6 +3699,9 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
uiItemR(row, ptr, "frame_blend_in", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "priority", 0, NULL, ICON_NONE);
row= uiLayoutRow(layout, 0);
uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE);
row= uiLayoutRow(layout, 0);
uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE);

View File

@@ -56,8 +56,10 @@ typedef struct bActionActuator {
char frameProp[32]; /* Set this property to the actions current frame */
short blendin; /* Number of frames of blending */
short priority; /* Execution priority */
short layer; /* Animation layer */
short end_reset; /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
short strideaxis; /* Displacement axis */
short pad[3];
float stridelength; /* Displacement incurred by cycle */ // not in use
} bActionActuator;

View File

@@ -616,6 +616,11 @@ static void rna_def_action_actuator(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Priority", "Execution priority - lower numbers will override actions with higher numbers. With 2 or more actions at once, the overriding channels must be lower in the stack");
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "layer", PROP_INT, PROP_NONE);
RNA_def_property_range(prop, 0, 4); /* This should match BL_ActionManager::MAX_ACTION_LAYERS */
RNA_def_property_ui_text(prop, "Layer", "The animation layer to play the action on");
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "frameProp");
RNA_def_property_ui_text(prop, "Frame Property", "Assign the action's current frame number to this property");

View File

@@ -180,9 +180,9 @@ 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, 0, m_blendin, play_mode);
obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_blendin, play_mode);
if (m_end_reset)
obj->SetActionFrame(0, m_localtime);
obj->SetActionFrame(m_layer, m_localtime);
}
else if (m_is_going && bNegativeEvent)
{
@@ -190,19 +190,19 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
if (!m_end_reset)
{
obj->StopAction(0);
obj->StopAction(m_layer);
return false;
}
m_localtime = obj->GetActionFrame(0);
obj->StopAction(0); // Stop the action after getting the frame
m_localtime = obj->GetActionFrame(m_layer);
obj->StopAction(m_layer); // Stop the action after getting the frame
}
// Handle a frame property if it's defined
if (m_framepropname[0] != 0)
{
CValue* oldprop = obj->GetProperty(m_framepropname);
CValue* newval = new CFloatValue(obj->GetActionFrame(0));
CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
if (oldprop)
oldprop->SetValue(newval);
else
@@ -215,7 +215,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
return true;
}
// Handle a finished animation
else if (m_is_going && obj->IsActionDone(0))
else if (m_is_going && obj->IsActionDone(m_layer))
{
return false;
}

View File

@@ -52,6 +52,7 @@ public:
short playtype,
short blendin,
short priority,
short layer,
short end_reset,
float stride)
: SCA_IActuator(gameobj, KX_ACT_ACTION),
@@ -69,6 +70,7 @@ public:
m_stridelength(stride),
m_playtype(playtype),
m_priority(priority),
m_layer(layer),
m_end_reset(end_reset),
m_is_going(false),
m_pose(NULL),
@@ -163,6 +165,7 @@ protected:
float m_stridelength;
short m_playtype;
short m_priority;
short m_layer;
bool m_end_reset;
bool m_is_going;
struct bPose* m_pose;

View File

@@ -205,6 +205,7 @@ void BL_ConvertActuators(char* maggiename,
actact->type, // + 1, because Blender starts to count at zero,
actact->blendin,
actact->priority,
actact->layer,
actact->end_reset,
actact->stridelength
// Ketsji at 1, because zero is reserved for "NoDef"