Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow AnimationStateMachine / AnimationNode to restart when transitioning to the same state #71418

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/classes/AnimationNode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@
When inheriting from [AnimationRootNode], implement this virtual method to return whether the blend tree editor should display filter editing on this node.
</description>
</method>
<method name="_is_parameter_read_only" qualifiers="virtual const">
<return type="bool" />
<param index="0" name="parameter" type="StringName" />
<description>
When inheriting from [AnimationRootNode], implement this virtual method to return whether the [param parameter] is read-only. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees.
</description>
</method>
<method name="_process" qualifiers="virtual const">
<return type="float" />
<param index="0" name="time" type="float" />
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/AnimationNodeOneShot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
</member>
</members>
<constants>
<constant name="ONE_SHOT_REQUEST_NONE" value="0" enum="OneShotRequest">
</constant>
<constant name="ONE_SHOT_REQUEST_FIRE" value="1" enum="OneShotRequest">
</constant>
<constant name="ONE_SHOT_REQUEST_ABORT" value="2" enum="OneShotRequest">
</constant>
<constant name="MIX_MODE_BLEND" value="0" enum="MixMode">
</constant>
<constant name="MIX_MODE_ADD" value="1" enum="MixMode">
Expand Down
11 changes: 11 additions & 0 deletions doc/classes/AnimationNodeStateMachinePlayback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@
Returns [code]true[/code] if an animation is playing.
</description>
</method>
<method name="next">
<return type="void" />
<description>
If there is a next path by travel or auto advance, immediately transitions from the current state to the next state.
</description>
</method>
<method name="start">
<return type="void" />
<param index="0" name="node" type="StringName" />
<param index="1" name="reset" type="bool" default="true" />
<description>
Starts playing the given animation.
If [param reset] is [code]true[/code], the animation is played from the beginning.
</description>
</method>
<method name="stop">
Expand All @@ -66,8 +74,11 @@
<method name="travel">
<return type="void" />
<param index="0" name="to_node" type="StringName" />
<param index="1" name="reset_on_teleport" type="bool" default="true" />
<description>
Transitions from the current state to another one, following the shortest path.
If the path does not connect from the current state, the animation will play after the state teleports.
If [param reset_on_teleport] is [code]true[/code], the animation is played from the beginning when the travel cause a teleportation.
</description>
</method>
</methods>
Expand Down
3 changes: 3 additions & 0 deletions doc/classes/AnimationNodeStateMachineTransition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<member name="priority" type="int" setter="set_priority" getter="get_priority" default="1">
Lower priority transitions are preferred when travelling through the tree via [method AnimationNodeStateMachinePlayback.travel] or [member advance_mode] is set to [constant ADVANCE_MODE_AUTO].
</member>
<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.
</member>
<member name="switch_mode" type="int" setter="set_switch_mode" getter="get_switch_mode" enum="AnimationNodeStateMachineTransition.SwitchMode" default="0">
The transition type.
</member>
Expand Down
8 changes: 7 additions & 1 deletion doc/classes/AnimationNodeTransition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
<link title="Third Person Shooter Demo">https://godotengine.org/asset-library/asset/678</link>
</tutorials>
<methods>
<method name="find_input_caption" qualifiers="const">
<return type="int" />
<param index="0" name="caption" type="String" />
<description>
</description>
</method>
<method name="get_input_caption" qualifiers="const">
<return type="String" />
<param index="0" name="input" type="int" />
Expand Down Expand Up @@ -43,7 +49,7 @@
<member name="enabled_inputs" type="int" setter="set_enabled_inputs" getter="get_enabled_inputs" default="0">
The number of enabled input ports for this node.
</member>
<member name="from_start" type="bool" setter="set_from_start" getter="is_from_start" 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.
</member>
<member name="xfade_curve" type="Curve" setter="set_xfade_curve" getter="get_xfade_curve">
Expand Down
9 changes: 7 additions & 2 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,17 @@ void EditorPropertyTextEnum::_notification(int p_what) {
}

EditorPropertyTextEnum::EditorPropertyTextEnum() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to explain what this is for. Maybe some example screen of the change to show the problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, wait a second, there are screens that can be broken by it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Here it is. Previous TextEnum had a problem with minimum_size not being obtained correctly since the containers existed in parallel. This PR fixes that by adding a wrapper container.

HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);

default_layout = memnew(HBoxContainer);
add_child(default_layout);
default_layout->set_h_size_flags(SIZE_EXPAND_FILL);
hb->add_child(default_layout);

edit_custom_layout = memnew(HBoxContainer);
edit_custom_layout->set_h_size_flags(SIZE_EXPAND_FILL);
edit_custom_layout->hide();
add_child(edit_custom_layout);
hb->add_child(edit_custom_layout);

option_button = memnew(OptionButton);
option_button->set_h_size_flags(SIZE_EXPAND_FILL);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_blend_tree_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void AnimationNodeBlendTreeEditor::update_graph() {
String base_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E) + "/" + F.name;
EditorProperty *prop = EditorInspector::instantiate_property_editor(tree, F.type, base_path, F.hint, F.hint_string, F.usage);
if (prop) {
prop->set_read_only(read_only);
prop->set_read_only(read_only || (F.usage & PROPERTY_USAGE_READ_ONLY));
prop->set_object_and_property(tree, base_path);
prop->update_property();
prop->set_name_split_ratio(0);
Expand Down
Loading