mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 20:23:53 +00:00
Remove the max input limit & cleanup AnimationNodeTransition API
This commit is contained in:
parent
a3dae9e548
commit
d27005f80e
@ -68,10 +68,10 @@
|
|||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="add_input">
|
<method name="add_input">
|
||||||
<return type="void" />
|
<return type="bool" />
|
||||||
<param index="0" name="name" type="String" />
|
<param index="0" name="name" type="String" />
|
||||||
<description>
|
<description>
|
||||||
Adds an input to the node. This is only useful for nodes created for use in an [AnimationNodeBlendTree].
|
Adds an input to the node. This is only useful for nodes created for use in an [AnimationNodeBlendTree]. If the addition fails, returns [code]false[/code].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="blend_animation">
|
<method name="blend_animation">
|
||||||
@ -115,13 +115,20 @@
|
|||||||
Blend another animation node (in case this node contains children animation nodes). This function is only useful if you inherit from [AnimationRootNode] instead, else editors will not display your node for addition.
|
Blend another animation node (in case this node contains children animation nodes). This function is only useful if you inherit from [AnimationRootNode] instead, else editors will not display your node for addition.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="find_input" qualifiers="const">
|
||||||
|
<return type="int" />
|
||||||
|
<param index="0" name="name" type="String" />
|
||||||
|
<description>
|
||||||
|
Returns the input index which corresponds to [param name]. If not found, returns [code]-1[/code].
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="get_input_count" qualifiers="const">
|
<method name="get_input_count" qualifiers="const">
|
||||||
<return type="int" />
|
<return type="int" />
|
||||||
<description>
|
<description>
|
||||||
Amount of inputs in this node, only useful for nodes that go into [AnimationNodeBlendTree].
|
Amount of inputs in this node, only useful for nodes that go into [AnimationNodeBlendTree].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="get_input_name">
|
<method name="get_input_name" qualifiers="const">
|
||||||
<return type="String" />
|
<return type="String" />
|
||||||
<param index="0" name="input" type="int" />
|
<param index="0" name="input" type="int" />
|
||||||
<description>
|
<description>
|
||||||
@ -157,6 +164,14 @@
|
|||||||
Adds or removes a path for the filter.
|
Adds or removes a path for the filter.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="set_input_name">
|
||||||
|
<return type="bool" />
|
||||||
|
<param index="0" name="input" type="int" />
|
||||||
|
<param index="1" name="name" type="String" />
|
||||||
|
<description>
|
||||||
|
Sets the name of the input at the given [param input] index. If the setting fails, returns [code]false[/code].
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="set_parameter">
|
<method name="set_parameter">
|
||||||
<return type="void" />
|
<return type="void" />
|
||||||
<param index="0" name="name" type="StringName" />
|
<param index="0" name="name" type="StringName" />
|
||||||
|
@ -12,20 +12,6 @@
|
|||||||
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
|
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<methods>
|
<methods>
|
||||||
<method name="find_input_caption" qualifiers="const">
|
|
||||||
<return type="int" />
|
|
||||||
<param index="0" name="caption" type="String" />
|
|
||||||
<description>
|
|
||||||
Returns the input index which corresponds to [param caption]. If not found, returns [code]-1[/code].
|
|
||||||
</description>
|
|
||||||
</method>
|
|
||||||
<method name="get_input_caption" qualifiers="const">
|
|
||||||
<return type="String" />
|
|
||||||
<param index="0" name="input" type="int" />
|
|
||||||
<description>
|
|
||||||
Returns the name of the input at the given [param input] index. This name is displayed in the editor next to the node input.
|
|
||||||
</description>
|
|
||||||
</method>
|
|
||||||
<method name="is_input_set_as_auto_advance" qualifiers="const">
|
<method name="is_input_set_as_auto_advance" qualifiers="const">
|
||||||
<return type="bool" />
|
<return type="bool" />
|
||||||
<param index="0" name="input" type="int" />
|
<param index="0" name="input" type="int" />
|
||||||
@ -41,18 +27,10 @@
|
|||||||
Enables or disables auto-advance for the given [param input] index. If enabled, state changes to the next input after playing the animation once. If enabled for the last input state, it loops to the first.
|
Enables or disables auto-advance for the given [param input] index. If enabled, state changes to the next input after playing the animation once. If enabled for the last input state, it loops to the first.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
<method name="set_input_caption">
|
|
||||||
<return type="void" />
|
|
||||||
<param index="0" name="input" type="int" />
|
|
||||||
<param index="1" name="caption" type="String" />
|
|
||||||
<description>
|
|
||||||
Sets the name of the input at the given [param input] index. This name is displayed in the editor next to the node input.
|
|
||||||
</description>
|
|
||||||
</method>
|
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="enabled_inputs" type="int" setter="set_enabled_inputs" getter="get_enabled_inputs" default="0">
|
<member name="input_count" type="int" setter="set_input_count" getter="get_input_count" default="0">
|
||||||
The number of enabled input ports for this node. The maximum is [code]31[/code].
|
The number of enabled input ports for this node.
|
||||||
</member>
|
</member>
|
||||||
<member name="reset" type="bool" setter="set_reset" getter="is_reset" default="true">
|
<member name="reset" type="bool" setter="set_reset" getter="is_reset" default="true">
|
||||||
If [code]true[/code], the destination animation is played back from the beginning when switched.
|
If [code]true[/code], the destination animation is played back from the beginning when switched.
|
||||||
|
@ -644,9 +644,62 @@ AnimationNodeTimeSeek::AnimationNodeTimeSeek() {
|
|||||||
|
|
||||||
/////////////////////////////////////////////////
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool AnimationNodeTransition::_set(const StringName &p_path, const Variant &p_value) {
|
||||||
|
String path = p_path;
|
||||||
|
|
||||||
|
if (!path.begins_with("input_")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int which = path.get_slicec('/', 0).get_slicec('_', 1).to_int();
|
||||||
|
String what = path.get_slicec('/', 1);
|
||||||
|
|
||||||
|
if (which == get_input_count() && what == "name") {
|
||||||
|
if (add_input(p_value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ERR_FAIL_INDEX_V(which, get_input_count(), false);
|
||||||
|
|
||||||
|
if (what == "name") {
|
||||||
|
set_input_name(which, p_value);
|
||||||
|
} else if (what == "auto_advance") {
|
||||||
|
set_input_as_auto_advance(which, p_value);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AnimationNodeTransition::_get(const StringName &p_path, Variant &r_ret) const {
|
||||||
|
String path = p_path;
|
||||||
|
|
||||||
|
if (!path.begins_with("input_")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int which = path.get_slicec('/', 0).get_slicec('_', 1).to_int();
|
||||||
|
String what = path.get_slicec('/', 1);
|
||||||
|
|
||||||
|
ERR_FAIL_INDEX_V(which, get_input_count(), false);
|
||||||
|
|
||||||
|
if (what == "name") {
|
||||||
|
r_ret = get_input_name(which);
|
||||||
|
} else if (what == "auto_advance") {
|
||||||
|
r_ret = is_input_set_as_auto_advance(which);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void AnimationNodeTransition::get_parameter_list(List<PropertyInfo> *r_list) const {
|
void AnimationNodeTransition::get_parameter_list(List<PropertyInfo> *r_list) const {
|
||||||
String anims;
|
String anims;
|
||||||
for (int i = 0; i < enabled_inputs; i++) {
|
for (int i = 0; i < get_input_count(); i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
anims += ",";
|
anims += ",";
|
||||||
}
|
}
|
||||||
@ -684,56 +737,37 @@ String AnimationNodeTransition::get_caption() const {
|
|||||||
return "Transition";
|
return "Transition";
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNodeTransition::_update_inputs() {
|
void AnimationNodeTransition::set_input_count(int p_inputs) {
|
||||||
while (get_input_count() < enabled_inputs) {
|
for (int i = get_input_count(); i < p_inputs; i++) {
|
||||||
add_input(inputs[get_input_count()].name);
|
add_input("state_" + itos(i));
|
||||||
}
|
}
|
||||||
|
while (get_input_count() > p_inputs) {
|
||||||
while (get_input_count() > enabled_inputs) {
|
|
||||||
remove_input(get_input_count() - 1);
|
remove_input(get_input_count() - 1);
|
||||||
}
|
}
|
||||||
|
notify_property_list_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNodeTransition::set_enabled_inputs(int p_inputs) {
|
bool AnimationNodeTransition::add_input(const String &p_name) {
|
||||||
ERR_FAIL_INDEX(p_inputs, MAX_INPUTS);
|
if (AnimationNode::add_input(p_name)) {
|
||||||
enabled_inputs = p_inputs;
|
input_as_auto_advance.push_back(false);
|
||||||
_update_inputs();
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AnimationNodeTransition::get_enabled_inputs() {
|
void AnimationNodeTransition::remove_input(int p_index) {
|
||||||
return enabled_inputs;
|
input_as_auto_advance.remove_at(p_index);
|
||||||
|
AnimationNode::remove_input(p_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNodeTransition::set_input_as_auto_advance(int p_input, bool p_enable) {
|
void AnimationNodeTransition::set_input_as_auto_advance(int p_input, bool p_enable) {
|
||||||
ERR_FAIL_INDEX(p_input, MAX_INPUTS);
|
ERR_FAIL_INDEX(p_input, get_input_count());
|
||||||
inputs[p_input].auto_advance = p_enable;
|
input_as_auto_advance.write[p_input] = p_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnimationNodeTransition::is_input_set_as_auto_advance(int p_input) const {
|
bool AnimationNodeTransition::is_input_set_as_auto_advance(int p_input) const {
|
||||||
ERR_FAIL_INDEX_V(p_input, MAX_INPUTS, false);
|
ERR_FAIL_INDEX_V(p_input, get_input_count(), false);
|
||||||
return inputs[p_input].auto_advance;
|
return input_as_auto_advance[p_input];
|
||||||
}
|
|
||||||
|
|
||||||
void AnimationNodeTransition::set_input_caption(int p_input, const String &p_name) {
|
|
||||||
ERR_FAIL_INDEX(p_input, MAX_INPUTS);
|
|
||||||
inputs[p_input].name = p_name;
|
|
||||||
set_input_name(p_input, p_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
String AnimationNodeTransition::get_input_caption(int p_input) const {
|
|
||||||
ERR_FAIL_INDEX_V(p_input, MAX_INPUTS, String());
|
|
||||||
return inputs[p_input].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AnimationNodeTransition::find_input_caption(const String &p_name) const {
|
|
||||||
int idx = -1;
|
|
||||||
for (int i = 0; i < MAX_INPUTS; i++) {
|
|
||||||
if (inputs[i].name == p_name) {
|
|
||||||
idx = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return idx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNodeTransition::set_xfade_time(double p_fade) {
|
void AnimationNodeTransition::set_xfade_time(double p_fade) {
|
||||||
@ -772,7 +806,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
|
|||||||
bool restart = false;
|
bool restart = false;
|
||||||
|
|
||||||
if (!cur_transition_request.is_empty()) {
|
if (!cur_transition_request.is_empty()) {
|
||||||
int new_idx = find_input_caption(cur_transition_request);
|
int new_idx = find_input(cur_transition_request);
|
||||||
if (new_idx >= 0) {
|
if (new_idx >= 0) {
|
||||||
if (cur_current_index == new_idx) {
|
if (cur_current_index == new_idx) {
|
||||||
// Transition to same state.
|
// Transition to same state.
|
||||||
@ -807,14 +841,14 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
|
|||||||
cur_time = 0;
|
cur_time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur_current_index < 0 || cur_current_index >= enabled_inputs || cur_prev_index >= enabled_inputs) {
|
if (cur_current_index < 0 || cur_current_index >= get_input_count() || cur_prev_index >= get_input_count()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rem = 0.0;
|
double rem = 0.0;
|
||||||
|
|
||||||
if (sync) {
|
if (sync) {
|
||||||
for (int i = 0; i < enabled_inputs; i++) {
|
for (int i = 0; i < get_input_count(); i++) {
|
||||||
if (i != cur_current_index && i != cur_prev_index) {
|
if (i != cur_current_index && i != cur_prev_index) {
|
||||||
blend_input(i, p_time, p_seek, p_is_external_seeking, 0, FILTER_IGNORE, true);
|
blend_input(i, p_time, p_seek, p_is_external_seeking, 0, FILTER_IGNORE, true);
|
||||||
}
|
}
|
||||||
@ -831,8 +865,8 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
|
|||||||
cur_time += p_time;
|
cur_time += p_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inputs[cur_current_index].auto_advance && rem <= xfade_time) {
|
if (input_as_auto_advance[cur_current_index] && rem <= xfade_time) {
|
||||||
set_parameter(transition_request, get_input_caption((cur_current_index + 1) % enabled_inputs));
|
set_parameter(transition_request, get_input_name((cur_current_index + 1) % get_input_count()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // cross-fading from prev to current
|
} else { // cross-fading from prev to current
|
||||||
@ -869,29 +903,19 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_is_ex
|
|||||||
return rem;
|
return rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNodeTransition::_validate_property(PropertyInfo &p_property) const {
|
void AnimationNodeTransition::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||||
if (p_property.name.begins_with("input_")) {
|
for (int i = 0; i < get_input_count(); i++) {
|
||||||
String n = p_property.name.get_slicec('/', 0).get_slicec('_', 1);
|
p_list->push_back(PropertyInfo(Variant::STRING, "input_" + itos(i) + "/name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL));
|
||||||
if (n != "count") {
|
p_list->push_back(PropertyInfo(Variant::BOOL, "input_" + itos(i) + "/auto_advance", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL));
|
||||||
int idx = n.to_int();
|
|
||||||
if (idx >= enabled_inputs) {
|
|
||||||
p_property.usage = PROPERTY_USAGE_NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNodeTransition::_bind_methods() {
|
void AnimationNodeTransition::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_enabled_inputs", "amount"), &AnimationNodeTransition::set_enabled_inputs);
|
ClassDB::bind_method(D_METHOD("set_input_count", "input_count"), &AnimationNodeTransition::set_input_count);
|
||||||
ClassDB::bind_method(D_METHOD("get_enabled_inputs"), &AnimationNodeTransition::get_enabled_inputs);
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_input_as_auto_advance", "input", "enable"), &AnimationNodeTransition::set_input_as_auto_advance);
|
ClassDB::bind_method(D_METHOD("set_input_as_auto_advance", "input", "enable"), &AnimationNodeTransition::set_input_as_auto_advance);
|
||||||
ClassDB::bind_method(D_METHOD("is_input_set_as_auto_advance", "input"), &AnimationNodeTransition::is_input_set_as_auto_advance);
|
ClassDB::bind_method(D_METHOD("is_input_set_as_auto_advance", "input"), &AnimationNodeTransition::is_input_set_as_auto_advance);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_input_caption", "input", "caption"), &AnimationNodeTransition::set_input_caption);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_input_caption", "input"), &AnimationNodeTransition::get_input_caption);
|
|
||||||
ClassDB::bind_method(D_METHOD("find_input_caption", "caption"), &AnimationNodeTransition::find_input_caption);
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_xfade_time", "time"), &AnimationNodeTransition::set_xfade_time);
|
ClassDB::bind_method(D_METHOD("set_xfade_time", "time"), &AnimationNodeTransition::set_xfade_time);
|
||||||
ClassDB::bind_method(D_METHOD("get_xfade_time"), &AnimationNodeTransition::get_xfade_time);
|
ClassDB::bind_method(D_METHOD("get_xfade_time"), &AnimationNodeTransition::get_xfade_time);
|
||||||
|
|
||||||
@ -901,21 +925,13 @@ void AnimationNodeTransition::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_reset", "reset"), &AnimationNodeTransition::set_reset);
|
ClassDB::bind_method(D_METHOD("set_reset", "reset"), &AnimationNodeTransition::set_reset);
|
||||||
ClassDB::bind_method(D_METHOD("is_reset"), &AnimationNodeTransition::is_reset);
|
ClassDB::bind_method(D_METHOD("is_reset"), &AnimationNodeTransition::is_reset);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "enabled_inputs", PROPERTY_HINT_RANGE, "0,31,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_enabled_inputs", "get_enabled_inputs");
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "xfade_time", PROPERTY_HINT_RANGE, "0,120,0.01,suffix:s"), "set_xfade_time", "get_xfade_time");
|
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "xfade_time", PROPERTY_HINT_RANGE, "0,120,0.01,suffix:s"), "set_xfade_time", "get_xfade_time");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "xfade_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_xfade_curve", "get_xfade_curve");
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "xfade_curve", PROPERTY_HINT_RESOURCE_TYPE, "Curve"), "set_xfade_curve", "get_xfade_curve");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reset"), "set_reset", "is_reset");
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reset"), "set_reset", "is_reset");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "input_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_ARRAY | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED, "Inputs,input_"), "set_input_count", "get_input_count");
|
||||||
for (int i = 0; i < MAX_INPUTS; i++) {
|
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::STRING, "input_" + itos(i) + "/name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_input_caption", "get_input_caption", i);
|
|
||||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "input_" + itos(i) + "/auto_advance", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_input_as_auto_advance", "is_input_set_as_auto_advance", i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationNodeTransition::AnimationNodeTransition() {
|
AnimationNodeTransition::AnimationNodeTransition() {
|
||||||
for (int i = 0; i < MAX_INPUTS; i++) {
|
|
||||||
inputs[i].name = "state " + itos(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
@ -276,16 +276,7 @@ public:
|
|||||||
class AnimationNodeTransition : public AnimationNodeSync {
|
class AnimationNodeTransition : public AnimationNodeSync {
|
||||||
GDCLASS(AnimationNodeTransition, AnimationNodeSync);
|
GDCLASS(AnimationNodeTransition, AnimationNodeSync);
|
||||||
|
|
||||||
enum {
|
Vector<bool> input_as_auto_advance;
|
||||||
MAX_INPUTS = 32
|
|
||||||
};
|
|
||||||
struct InputData {
|
|
||||||
String name;
|
|
||||||
bool auto_advance = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
InputData inputs[MAX_INPUTS];
|
|
||||||
int enabled_inputs = 0;
|
|
||||||
|
|
||||||
StringName time = "time";
|
StringName time = "time";
|
||||||
StringName prev_xfading = "prev_xfading";
|
StringName prev_xfading = "prev_xfading";
|
||||||
@ -301,11 +292,11 @@ class AnimationNodeTransition : public AnimationNodeSync {
|
|||||||
Ref<Curve> xfade_curve;
|
Ref<Curve> xfade_curve;
|
||||||
bool reset = true;
|
bool reset = true;
|
||||||
|
|
||||||
void _update_inputs();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool _get(const StringName &p_path, Variant &r_ret) const;
|
||||||
|
bool _set(const StringName &p_path, const Variant &p_value);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
void _validate_property(PropertyInfo &p_property) const;
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
|
virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
|
||||||
@ -314,16 +305,14 @@ public:
|
|||||||
|
|
||||||
virtual String get_caption() const override;
|
virtual String get_caption() const override;
|
||||||
|
|
||||||
void set_enabled_inputs(int p_inputs);
|
void set_input_count(int p_inputs);
|
||||||
int get_enabled_inputs();
|
|
||||||
|
virtual bool add_input(const String &p_name) override;
|
||||||
|
virtual void remove_input(int p_index) override;
|
||||||
|
|
||||||
void set_input_as_auto_advance(int p_input, bool p_enable);
|
void set_input_as_auto_advance(int p_input, bool p_enable);
|
||||||
bool is_input_set_as_auto_advance(int p_input) const;
|
bool is_input_set_as_auto_advance(int p_input) const;
|
||||||
|
|
||||||
void set_input_caption(int p_input, const String &p_name);
|
|
||||||
String get_input_caption(int p_input) const;
|
|
||||||
int find_input_caption(const String &p_name) const;
|
|
||||||
|
|
||||||
void set_xfade_time(double p_fade);
|
void set_xfade_time(double p_fade);
|
||||||
double get_xfade_time() const;
|
double get_xfade_time() const;
|
||||||
|
|
||||||
|
@ -303,36 +303,21 @@ double AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Stri
|
|||||||
return p_node->_pre_process(new_path, new_parent, state, p_time, p_seek, p_is_external_seeking, p_connections);
|
return p_node->_pre_process(new_path, new_parent, state, p_time, p_seek, p_is_external_seeking, p_connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AnimationNode::get_input_count() const {
|
|
||||||
return inputs.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
String AnimationNode::get_input_name(int p_input) {
|
|
||||||
ERR_FAIL_INDEX_V(p_input, inputs.size(), String());
|
|
||||||
return inputs[p_input].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
String AnimationNode::get_caption() const {
|
String AnimationNode::get_caption() const {
|
||||||
String ret = "Node";
|
String ret = "Node";
|
||||||
GDVIRTUAL_CALL(_get_caption, ret);
|
GDVIRTUAL_CALL(_get_caption, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNode::add_input(const String &p_name) {
|
bool AnimationNode::add_input(const String &p_name) {
|
||||||
//root nodes can't add inputs
|
//root nodes can't add inputs
|
||||||
ERR_FAIL_COND(Object::cast_to<AnimationRootNode>(this) != nullptr);
|
ERR_FAIL_COND_V(Object::cast_to<AnimationRootNode>(this) != nullptr, false);
|
||||||
Input input;
|
Input input;
|
||||||
ERR_FAIL_COND(p_name.contains(".") || p_name.contains("/"));
|
ERR_FAIL_COND_V(p_name.contains(".") || p_name.contains("/"), false);
|
||||||
input.name = p_name;
|
input.name = p_name;
|
||||||
inputs.push_back(input);
|
inputs.push_back(input);
|
||||||
emit_changed();
|
emit_changed();
|
||||||
}
|
return true;
|
||||||
|
|
||||||
void AnimationNode::set_input_name(int p_input, const String &p_name) {
|
|
||||||
ERR_FAIL_INDEX(p_input, inputs.size());
|
|
||||||
ERR_FAIL_COND(p_name.contains(".") || p_name.contains("/"));
|
|
||||||
inputs.write[p_input].name = p_name;
|
|
||||||
emit_changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNode::remove_input(int p_index) {
|
void AnimationNode::remove_input(int p_index) {
|
||||||
@ -341,6 +326,34 @@ void AnimationNode::remove_input(int p_index) {
|
|||||||
emit_changed();
|
emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AnimationNode::set_input_name(int p_input, const String &p_name) {
|
||||||
|
ERR_FAIL_INDEX_V(p_input, inputs.size(), false);
|
||||||
|
ERR_FAIL_COND_V(p_name.contains(".") || p_name.contains("/"), false);
|
||||||
|
inputs.write[p_input].name = p_name;
|
||||||
|
emit_changed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String AnimationNode::get_input_name(int p_input) const {
|
||||||
|
ERR_FAIL_INDEX_V(p_input, inputs.size(), String());
|
||||||
|
return inputs[p_input].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int AnimationNode::get_input_count() const {
|
||||||
|
return inputs.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int AnimationNode::find_input(const String &p_name) const {
|
||||||
|
int idx = -1;
|
||||||
|
for (int i = 0; i < inputs.size(); i++) {
|
||||||
|
if (inputs[i].name == p_name) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
|
||||||
double AnimationNode::process(double p_time, bool p_seek, bool p_is_external_seeking) {
|
double AnimationNode::process(double p_time, bool p_seek, bool p_is_external_seeking) {
|
||||||
double ret = 0;
|
double ret = 0;
|
||||||
GDVIRTUAL_CALL(_process, p_time, p_seek, p_is_external_seeking, ret);
|
GDVIRTUAL_CALL(_process, p_time, p_seek, p_is_external_seeking, ret);
|
||||||
@ -404,11 +417,12 @@ Ref<AnimationNode> AnimationNode::get_child_by_name(const StringName &p_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNode::_bind_methods() {
|
void AnimationNode::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_input_count"), &AnimationNode::get_input_count);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_input_name", "input"), &AnimationNode::get_input_name);
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("add_input", "name"), &AnimationNode::add_input);
|
ClassDB::bind_method(D_METHOD("add_input", "name"), &AnimationNode::add_input);
|
||||||
ClassDB::bind_method(D_METHOD("remove_input", "index"), &AnimationNode::remove_input);
|
ClassDB::bind_method(D_METHOD("remove_input", "index"), &AnimationNode::remove_input);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_input_name", "input", "name"), &AnimationNode::set_input_name);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_input_name", "input"), &AnimationNode::get_input_name);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_input_count"), &AnimationNode::get_input_count);
|
||||||
|
ClassDB::bind_method(D_METHOD("find_input", "name"), &AnimationNode::find_input);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_filter_path", "path", "enable"), &AnimationNode::set_filter_path);
|
ClassDB::bind_method(D_METHOD("set_filter_path", "path", "enable"), &AnimationNode::set_filter_path);
|
||||||
ClassDB::bind_method(D_METHOD("is_path_filtered", "path"), &AnimationNode::is_path_filtered);
|
ClassDB::bind_method(D_METHOD("is_path_filtered", "path"), &AnimationNode::is_path_filtered);
|
||||||
|
@ -141,12 +141,12 @@ public:
|
|||||||
virtual double process(double p_time, bool p_seek, bool p_is_external_seeking);
|
virtual double process(double p_time, bool p_seek, bool p_is_external_seeking);
|
||||||
virtual String get_caption() const;
|
virtual String get_caption() const;
|
||||||
|
|
||||||
|
virtual bool add_input(const String &p_name);
|
||||||
|
virtual void remove_input(int p_index);
|
||||||
|
virtual bool set_input_name(int p_input, const String &p_name);
|
||||||
|
virtual String get_input_name(int p_input) const;
|
||||||
int get_input_count() const;
|
int get_input_count() const;
|
||||||
String get_input_name(int p_input);
|
int find_input(const String &p_name) const;
|
||||||
|
|
||||||
void add_input(const String &p_name);
|
|
||||||
void set_input_name(int p_input, const String &p_name);
|
|
||||||
void remove_input(int p_index);
|
|
||||||
|
|
||||||
void set_filter_path(const NodePath &p_path, bool p_enable);
|
void set_filter_path(const NodePath &p_path, bool p_enable);
|
||||||
bool is_path_filtered(const NodePath &p_path) const;
|
bool is_path_filtered(const NodePath &p_path) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user