BGE: The Action Actuator can now make use of additive blending.
This commit is contained in:
parent
9afae77fed
commit
196d30e004
@ -1465,6 +1465,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr)
|
||||
row = uiLayoutRow(layout, FALSE);
|
||||
uiItemR(row, ptr, "layer", 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);
|
||||
|
||||
|
@ -59,7 +59,7 @@ typedef struct bActionActuator {
|
||||
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;
|
||||
short blend_mode; /* Layer blending mode */
|
||||
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) */
|
||||
} bActionActuator;
|
||||
@ -341,6 +341,10 @@ typedef struct bActuator {
|
||||
#define ACT_ACTION_FROM_PROP 6
|
||||
#define ACT_ACTION_MOTION 7
|
||||
|
||||
/* actionactuator->blend_mode */
|
||||
#define ACT_ACTION_BLEND 0
|
||||
#define ACT_ACTION_ADD 1
|
||||
|
||||
/* ipoactuator->type */
|
||||
#define ACT_IPO_PLAY 0
|
||||
#define ACT_IPO_PINGPONG 1
|
||||
|
@ -593,6 +593,12 @@ static void rna_def_action_actuator(BlenderRNA *brna)
|
||||
{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");
|
||||
RNA_def_struct_ui_text(srna, "Action Actuator", "Actuator to control the object movement");
|
||||
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);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
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);
|
||||
|
||||
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_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
|
||||
prop = RNA_def_property(srna, "stride_length", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "stridelength");
|
||||
|
@ -66,6 +66,7 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj,
|
||||
float endtime,
|
||||
struct bAction *action,
|
||||
short playtype,
|
||||
short blend_mode,
|
||||
short blendin,
|
||||
short priority,
|
||||
short layer,
|
||||
@ -88,6 +89,7 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject *gameobj,
|
||||
m_stridelength(stride),
|
||||
m_layer_weight(layer_weight),
|
||||
m_playtype(playtype),
|
||||
m_blendmode(blend_mode),
|
||||
m_priority(priority),
|
||||
m_layer(layer),
|
||||
m_ipo_flags(ipo_flags),
|
||||
@ -187,6 +189,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
|
||||
bool bUseContinue = false;
|
||||
KX_GameObject *obj = (KX_GameObject*)GetParent();
|
||||
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 end = m_endframe;
|
||||
|
||||
@ -283,7 +286,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
|
||||
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;
|
||||
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
|
||||
end = start;
|
||||
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;
|
||||
break;
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
float endtime,
|
||||
struct bAction *action,
|
||||
short playtype,
|
||||
short blend_mode,
|
||||
short blendin,
|
||||
short priority,
|
||||
short layer,
|
||||
@ -129,6 +130,7 @@ protected:
|
||||
float m_stridelength;
|
||||
float m_layer_weight;
|
||||
short m_playtype;
|
||||
short m_blendmode;
|
||||
short m_priority;
|
||||
short m_layer;
|
||||
short m_ipo_flags;
|
||||
|
@ -225,6 +225,7 @@ void BL_ConvertActuators(const char* maggiename,
|
||||
actact->end,
|
||||
actact->act,
|
||||
actact->type, // + 1, because Blender starts to count at zero,
|
||||
actact->blend_mode,
|
||||
actact->blendin,
|
||||
actact->priority,
|
||||
actact->layer,
|
||||
|
Loading…
Reference in New Issue
Block a user