BGE: The Action Actuator can now make use of additive blending.

This commit is contained in:
Mitchell Stokes 2013-08-14 23:32:00 +00:00
parent 9afae77fed
commit 196d30e004
6 changed files with 27 additions and 4 deletions

@ -1465,6 +1465,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
row = uiLayoutRow(layout, FALSE); row = uiLayoutRow(layout, FALSE);
uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE); uiItemR(row, ptr, "layer", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE); uiItemR(row, ptr, "layer_weight", 0, NULL, ICON_NONE);
uiItemR(row, ptr, "blend_mode", 0, "", ICON_NONE);
uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE); uiItemPointerR(layout, ptr, "frame_property", &settings_ptr, "properties", NULL, ICON_NONE);

@ -59,7 +59,7 @@ typedef struct bActionActuator {
short layer; /* Animation layer */ short layer; /* Animation layer */
short end_reset; /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */ short end_reset; /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */
short strideaxis; /* Displacement axis */ short strideaxis; /* Displacement axis */
short pad; short blend_mode; /* Layer blending mode */
float stridelength; /* Displacement incurred by cycle */ // not in use float stridelength; /* Displacement incurred by cycle */ // not in use
float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */ float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */
} bActionActuator; } bActionActuator;
@ -341,6 +341,10 @@ typedef struct bActuator {
#define ACT_ACTION_FROM_PROP 6 #define ACT_ACTION_FROM_PROP 6
#define ACT_ACTION_MOTION 7 #define ACT_ACTION_MOTION 7
/* actionactuator->blend_mode */
#define ACT_ACTION_BLEND 0
#define ACT_ACTION_ADD 1
/* ipoactuator->type */ /* ipoactuator->type */
#define ACT_IPO_PLAY 0 #define ACT_IPO_PLAY 0
#define ACT_IPO_PINGPONG 1 #define ACT_IPO_PINGPONG 1

@ -593,6 +593,12 @@ static void rna_def_action_actuator(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL} {0, NULL, 0, NULL, NULL}
}; };
static EnumPropertyItem prop_blend_items[] = {
{ACT_ACTION_BLEND, "BLEND", 0, "Blend", ""},
{ACT_ACTION_ADD, "ADD", 0, "Add", ""},
{0, NULL, 0, NULL, NULL}
};
srna = RNA_def_struct(brna, "ActionActuator", "Actuator"); srna = RNA_def_struct(brna, "ActionActuator", "Actuator");
RNA_def_struct_ui_text(srna, "Action Actuator", "Actuator to control the object movement"); RNA_def_struct_ui_text(srna, "Action Actuator", "Actuator to control the object movement");
RNA_def_struct_sdna_from(srna, "bActionActuator", "data"); RNA_def_struct_sdna_from(srna, "bActionActuator", "data");
@ -656,7 +662,7 @@ static void rna_def_action_actuator(BlenderRNA *brna)
prop = RNA_def_property(srna, "layer_weight", PROP_FLOAT, PROP_NONE); prop = RNA_def_property(srna, "layer_weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_ui_text(prop, "Layer Weight", RNA_def_property_ui_text(prop, "Layer Weight",
"How much of the previous layer to blend into this one (0 = add mode)"); "How much of the previous layer to blend into this one");
RNA_def_property_update(prop, NC_LOGIC, NULL); RNA_def_property_update(prop, NC_LOGIC, NULL);
prop = RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE); prop = RNA_def_property(srna, "frame_property", PROP_STRING, PROP_NONE);
@ -691,6 +697,12 @@ static void rna_def_action_actuator(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Child", "Update Action on all children Objects as well"); RNA_def_property_ui_text(prop, "Child", "Update Action on all children Objects as well");
RNA_def_property_update(prop, NC_LOGIC, NULL); RNA_def_property_update(prop, NC_LOGIC, NULL);
prop = RNA_def_property(srna, "blend_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "blend_mode");
RNA_def_property_enum_items(prop, prop_blend_items);
RNA_def_property_ui_text(prop, "Blend Mode", "Determines how this layer is blended with previous layers");
RNA_def_property_update(prop, NC_LOGIC, NULL);
#ifdef __NLA_ACTION_BY_MOTION_ACTUATOR #ifdef __NLA_ACTION_BY_MOTION_ACTUATOR
prop = RNA_def_property(srna, "stride_length", PROP_FLOAT, PROP_NONE); prop = RNA_def_property(srna, "stride_length", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "stridelength"); RNA_def_property_float_sdna(prop, NULL, "stridelength");

@ -66,6 +66,7 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj,
float endtime, float endtime,
struct bAction *action, struct bAction *action,
short playtype, short playtype,
short blend_mode,
short blendin, short blendin,
short priority, short priority,
short layer, short layer,
@ -88,6 +89,7 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj,
m_stridelength(stride), m_stridelength(stride),
m_layer_weight(layer_weight), m_layer_weight(layer_weight),
m_playtype(playtype), m_playtype(playtype),
m_blendmode(blend_mode),
m_priority(priority), m_priority(priority),
m_layer(layer), m_layer(layer),
m_ipo_flags(ipo_flags), m_ipo_flags(ipo_flags),
@ -187,6 +189,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
bool bUseContinue = false; bool bUseContinue = false;
KX_GameObject *obj = (KX_GameObject*)GetParent(); KX_GameObject *obj = (KX_GameObject*)GetParent();
short playtype = BL_Action::ACT_MODE_PLAY; short playtype = BL_Action::ACT_MODE_PLAY;
short blendmode = (m_blendmode == ACT_ACTION_ADD) ? BL_Action::ACT_BLEND_ADD : BL_Action::ACT_BLEND_BLEND;
float start = m_startframe; float start = m_startframe;
float end = m_endframe; float end = m_endframe;
@ -283,7 +286,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
ResetStartTime(curtime); ResetStartTime(curtime);
} }
if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags)) if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags, 1.f, blendmode))
{ {
m_flag |= ACT_FLAG_ACTIVE; m_flag |= ACT_FLAG_ACTIVE;
if (bUseContinue) if (bUseContinue)
@ -328,7 +331,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
// Convert into a play action and play back to the beginning // Convert into a play action and play back to the beginning
end = start; end = start;
start = obj->GetActionFrame(m_layer); start = obj->GetActionFrame(m_layer);
obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags); obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags, 1.f, blendmode);
m_flag |= ACT_FLAG_PLAY_END; m_flag |= ACT_FLAG_PLAY_END;
break; break;

@ -48,6 +48,7 @@ public:
float endtime, float endtime,
struct bAction *action, struct bAction *action,
short playtype, short playtype,
short blend_mode,
short blendin, short blendin,
short priority, short priority,
short layer, short layer,
@ -129,6 +130,7 @@ protected:
float m_stridelength; float m_stridelength;
float m_layer_weight; float m_layer_weight;
short m_playtype; short m_playtype;
short m_blendmode;
short m_priority; short m_priority;
short m_layer; short m_layer;
short m_ipo_flags; short m_ipo_flags;

@ -225,6 +225,7 @@ void BL_ConvertActuators(const char* maggiename,
actact->end, actact->end,
actact->act, actact->act,
actact->type, // + 1, because Blender starts to count at zero, actact->type, // + 1, because Blender starts to count at zero,
actact->blend_mode,
actact->blendin, actact->blendin,
actact->priority, actact->priority,
actact->layer, actact->layer,