From c9c8205644253e5aea712dfd893a39499fc773de Mon Sep 17 00:00:00 2001
From: "Silc Lizard (Tokage) Renew"
<61938263+TokageItLab@users.noreply.github.com>
Date: Sun, 30 Apr 2023 23:32:18 +0900
Subject: [PATCH] Implement NodeSub2 to AnimationTree & improve mathematical
Nodes
---
doc/classes/AnimationNode.xml | 34 +++++++--------
doc/classes/AnimationNodeAdd2.xml | 4 +-
doc/classes/AnimationNodeAdd3.xml | 9 ++--
doc/classes/AnimationNodeBlend2.xml | 3 +-
doc/classes/AnimationNodeBlend3.xml | 11 ++---
doc/classes/AnimationNodeBlendSpace1D.xml | 2 +-
doc/classes/AnimationNodeBlendSpace2D.xml | 2 +-
doc/classes/AnimationNodeBlendTree.xml | 22 +++++-----
doc/classes/AnimationNodeOneShot.xml | 2 +-
doc/classes/AnimationNodeStateMachine.xml | 20 ++++-----
doc/classes/AnimationNodeSub2.xml | 15 +++++++
doc/classes/AnimationNodeTimeSeek.xml | 2 +-
doc/classes/AnimationNodeTransition.xml | 4 +-
.../animation_blend_tree_editor_plugin.cpp | 1 +
scene/animation/animation_blend_tree.cpp | 41 +++++++++++++++++--
scene/animation/animation_blend_tree.h | 20 +++++++++
scene/animation/animation_tree.cpp | 2 +-
scene/register_scene_types.cpp | 1 +
18 files changed, 135 insertions(+), 60 deletions(-)
create mode 100644 doc/classes/AnimationNodeSub2.xml
diff --git a/doc/classes/AnimationNode.xml b/doc/classes/AnimationNode.xml
index cb6a4f30f9b..a86ec396ee6 100644
--- a/doc/classes/AnimationNode.xml
+++ b/doc/classes/AnimationNode.xml
@@ -5,7 +5,7 @@
Base resource for [AnimationTree] nodes. In general, it's not used directly, but you can create custom ones with custom blending formulas.
- Inherit this when creating nodes mainly for use in [AnimationNodeBlendTree], otherwise [AnimationRootNode] should be used instead.
+ Inherit this when creating animation nodes mainly for use in [AnimationNodeBlendTree], otherwise [AnimationRootNode] should be used instead.
$DOCS_URL/tutorials/animation/animation_tree.html
@@ -14,46 +14,46 @@
- When inheriting from [AnimationRootNode], implement this virtual method to override the text caption for this node.
+ When inheriting from [AnimationRootNode], implement this virtual method to override the text caption for this animation node.
- When inheriting from [AnimationRootNode], implement this virtual method to return a child node by its [param name].
+ When inheriting from [AnimationRootNode], implement this virtual method to return a child animation node by its [param name].
- When inheriting from [AnimationRootNode], implement this virtual method to return all children nodes in order as a [code]name: node[/code] dictionary.
+ When inheriting from [AnimationRootNode], implement this virtual method to return all children animation nodes in order as a [code]name: node[/code] dictionary.
- When inheriting from [AnimationRootNode], implement this virtual method to return the default value of a [param parameter]. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees.
+ When inheriting from [AnimationRootNode], implement this virtual method to return the default value of a [param parameter]. Parameters are custom local memory used for your animation nodes, given a resource can be reused in multiple trees.
- When inheriting from [AnimationRootNode], implement this virtual method to return a list of the properties on this node. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees. Format is similar to [method Object.get_property_list].
+ When inheriting from [AnimationRootNode], implement this virtual method to return a list of the properties on this animation node. Parameters are custom local memory used for your animation nodes, given a resource can be reused in multiple trees. Format is similar to [method Object.get_property_list].
- When inheriting from [AnimationRootNode], implement this virtual method to return whether the blend tree editor should display filter editing on this node.
+ When inheriting from [AnimationRootNode], implement this virtual method to return whether the blend tree editor should display filter editing on this animation node.
- 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.
+ 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 animation nodes, given a resource can be reused in multiple trees.
@@ -63,7 +63,7 @@
- When inheriting from [AnimationRootNode], implement this virtual method to run some code when this node is processed. The [param time] parameter is a relative delta, unless [param seek] is [code]true[/code], in which case it is absolute.
+ When inheriting from [AnimationRootNode], implement this virtual method to run some code when this animation node is processed. The [param time] parameter is a relative delta, unless [param seek] is [code]true[/code], in which case it is absolute.
Here, call the [method blend_input], [method blend_node] or [method blend_animation] functions. You can also use [method get_parameter] and [method set_parameter] to modify local memory.
This function should return the time left for the current animation to finish (if unsure, pass the value from the main blend being called).
@@ -72,7 +72,7 @@
- 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].
+ Adds an input to the animation node. This is only useful for animation nodes created for use in an [AnimationNodeBlendTree]. If the addition fails, returns [code]false[/code].
@@ -100,7 +100,7 @@
- Blend an input. This is only useful for nodes created for an [AnimationNodeBlendTree]. The [param time] parameter is a relative delta, unless [param seek] is [code]true[/code], in which case it is absolute. A filter mode may be optionally passed (see [enum FilterAction] for options).
+ Blend an input. This is only useful for animation nodes created for an [AnimationNodeBlendTree]. The [param time] parameter is a relative delta, unless [param seek] is [code]true[/code], in which case it is absolute. A filter mode may be optionally passed (see [enum FilterAction] for options).
@@ -115,7 +115,7 @@
- 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 animation node contains children animation nodes). This function is only useful if you inherit from [AnimationRootNode] instead, else editors will not display your animation node for addition.
@@ -128,7 +128,7 @@
- Amount of inputs in this node, only useful for nodes that go into [AnimationNodeBlendTree].
+ Amount of inputs in this animation node, only useful for animation nodes that go into [AnimationNodeBlendTree].
@@ -142,7 +142,7 @@
- Gets the value of a parameter. Parameters are custom local memory used for your nodes, given a resource can be reused in multiple trees.
+ Gets the value of a parameter. Parameters are custom local memory used for your animation nodes, given a resource can be reused in multiple trees.
@@ -194,7 +194,7 @@
- Emitted by nodes that inherit from this class and that have an internal tree when one of their nodes removes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
+ Emitted by nodes that inherit from this class and that have an internal tree when one of their animation nodes removes. The animation nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
@@ -202,12 +202,12 @@
- Emitted by nodes that inherit from this class and that have an internal tree when one of their node names changes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
+ Emitted by nodes that inherit from this class and that have an internal tree when one of their animation node names changes. The animation nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
- Emitted by nodes that inherit from this class and that have an internal tree when one of their nodes changes. The nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], [AnimationNodeBlendTree] and [AnimationNodeTransition].
+ Emitted by nodes that inherit from this class and that have an internal tree when one of their animation nodes changes. The animation nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], [AnimationNodeBlendTree] and [AnimationNodeTransition].
diff --git a/doc/classes/AnimationNodeAdd2.xml b/doc/classes/AnimationNodeAdd2.xml
index 68bbe8090bd..3aaf772716f 100644
--- a/doc/classes/AnimationNodeAdd2.xml
+++ b/doc/classes/AnimationNodeAdd2.xml
@@ -4,7 +4,9 @@
Blends two animations additively inside of an [AnimationNodeBlendTree].
- A resource to add to an [AnimationNodeBlendTree]. Blends two animations additively based on an amount value in the [code][0.0, 1.0][/code] range.
+ A resource to add to an [AnimationNodeBlendTree]. Blends two animations additively based on the amount value.
+ If the amount is greater than [code]1.0[/code], the animation connected to "in" port is blended with the amplified animation connected to "add" port.
+ If the amount is less than [code]0.0[/code], the animation connected to "in" port is blended with the inverted animation connected to "add" port.
$DOCS_URL/tutorials/animation/animation_tree.html
diff --git a/doc/classes/AnimationNodeAdd3.xml b/doc/classes/AnimationNodeAdd3.xml
index 1e51a8a4c59..7048c2329c4 100644
--- a/doc/classes/AnimationNodeAdd3.xml
+++ b/doc/classes/AnimationNodeAdd3.xml
@@ -4,11 +4,12 @@
Blends two of three animations additively inside of an [AnimationNodeBlendTree].
- A resource to add to an [AnimationNodeBlendTree]. Blends two animations together additively out of three based on a value in the [code][-1.0, 1.0][/code] range.
- This node has three inputs:
+ A resource to add to an [AnimationNodeBlendTree]. Blends two animations out of three additively out of three based on the amounmt value.
+ This animation node has three inputs:
- The base animation to add to
- - A -add animation to blend with when the blend amount is in the [code][-1.0, 0.0][/code] range.
- - A +add animation to blend with when the blend amount is in the [code][0.0, 1.0][/code] range
+ - A "-add" animation to blend with when the blend amount is negative
+ - A "+add" animation to blend with when the blend amount is positive
+ If the absolute value of the amount is greater than [code]1.0[/code], the animation connected to "in" port is blended with the amplified animation connected to "-add"/"+add" port.
$DOCS_URL/tutorials/animation/animation_tree.html
diff --git a/doc/classes/AnimationNodeBlend2.xml b/doc/classes/AnimationNodeBlend2.xml
index 1460f5f055d..db27a7d87db 100644
--- a/doc/classes/AnimationNodeBlend2.xml
+++ b/doc/classes/AnimationNodeBlend2.xml
@@ -4,7 +4,8 @@
Blends two animations linearly inside of an [AnimationNodeBlendTree].
- A resource to add to an [AnimationNodeBlendTree]. Blends two animations linearly based on an amount value in the [code][0.0, 1.0][/code] range.
+ A resource to add to an [AnimationNodeBlendTree]. Blends two animations linearly based on the amount value.
+ In general, the blend value should be in the [code][0.0, 1.0][/code] range. Values outside of this range can blend amplified or inverted animations, however, [AnimationNodeAdd2] works better for this purpose.
$DOCS_URL/tutorials/animation/animation_tree.html
diff --git a/doc/classes/AnimationNodeBlend3.xml b/doc/classes/AnimationNodeBlend3.xml
index 34c4b8566a9..b7a54032389 100644
--- a/doc/classes/AnimationNodeBlend3.xml
+++ b/doc/classes/AnimationNodeBlend3.xml
@@ -4,11 +4,12 @@
Blends two of three animations linearly inside of an [AnimationNodeBlendTree].
- A resource to add to an [AnimationNodeBlendTree]. Blends two animations together linearly out of three based on a value in the [code][-1.0, 1.0][/code] range.
- This node has three inputs:
- - The base animation
- - A -blend animation to blend with when the blend amount is in the [code][-1.0, 0.0][/code] range.
- - A +blend animation to blend with when the blend amount is in the [code][0.0, 1.0][/code] range
+ A resource to add to an [AnimationNodeBlendTree]. Blends two animations out of three linearly out of three based on the amounmt value.
+ This animation node has three inputs:
+ - The base animation to blend with
+ - A "-blend" animation to blend with when the blend amount is negative value
+ - A "+blend" animation to blend with when the blend amount is positive value
+ In general, the blend value should be in the [code][-1.0, 1.0][/code] range. Values outside of this range can blend amplified animations, however, [AnimationNodeAdd3] works better for this purpose.
$DOCS_URL/tutorials/animation/animation_tree.html
diff --git a/doc/classes/AnimationNodeBlendSpace1D.xml b/doc/classes/AnimationNodeBlendSpace1D.xml
index aa15ac03d9c..02f0053380b 100644
--- a/doc/classes/AnimationNodeBlendSpace1D.xml
+++ b/doc/classes/AnimationNodeBlendSpace1D.xml
@@ -91,7 +91,7 @@
The interpolation between animations is linear.
- The blend space plays the animation of the node the blending position is closest to. Useful for frame-by-frame 2D animations.
+ The blend space plays the animation of the animation node which blending position is closest to. Useful for frame-by-frame 2D animations.
Similar to [constant BLEND_MODE_DISCRETE], but starts the new animation at the last animation's playback position.
diff --git a/doc/classes/AnimationNodeBlendSpace2D.xml b/doc/classes/AnimationNodeBlendSpace2D.xml
index 27dff11e88d..46606f12b03 100644
--- a/doc/classes/AnimationNodeBlendSpace2D.xml
+++ b/doc/classes/AnimationNodeBlendSpace2D.xml
@@ -136,7 +136,7 @@
The interpolation between animations is linear.
- The blend space plays the animation of the node the blending position is closest to. Useful for frame-by-frame 2D animations.
+ The blend space plays the animation of the animation node which blending position is closest to. Useful for frame-by-frame 2D animations.
Similar to [constant BLEND_MODE_DISCRETE], but starts the new animation at the last animation's playback position.
diff --git a/doc/classes/AnimationNodeBlendTree.xml b/doc/classes/AnimationNodeBlendTree.xml
index 9ae34e80381..4b3bf4c8060 100644
--- a/doc/classes/AnimationNodeBlendTree.xml
+++ b/doc/classes/AnimationNodeBlendTree.xml
@@ -1,10 +1,10 @@
- A sub-tree of blend type [AnimationNode]s used for complex animations. Used by [AnimationTree].
+ A sub-tree of many type [AnimationNode]s used for complex animations. Used by [AnimationTree].
- This node may contain a sub-tree of any other blend type nodes, such as [AnimationNodeTransition], [AnimationNodeBlend2], [AnimationNodeBlend3], [AnimationNodeOneShot], etc. This is one of the most commonly used animation node roots.
+ This animation node may contain a sub-tree of any other type animation nodes, such as [AnimationNodeTransition], [AnimationNodeBlend2], [AnimationNodeBlend3], [AnimationNodeOneShot], etc. This is one of the most commonly used animation node roots.
An [AnimationNodeOutput] node named [code]output[/code] is created by default.
@@ -17,7 +17,7 @@
- Adds an [AnimationNode] at the given [param position]. The [param name] is used to identify the created sub-node later.
+ Adds an [AnimationNode] at the given [param position]. The [param name] is used to identify the created sub animation node later.
@@ -34,35 +34,35 @@
- Disconnects the node connected to the specified input.
+ Disconnects the animation node connected to the specified input.
- Returns the sub-node with the specified [param name].
+ Returns the sub animation node with the specified [param name].
- Returns the position of the sub-node with the specified [param name].
+ Returns the position of the sub animation node with the specified [param name].
- Returns [code]true[/code] if a sub-node with specified [param name] exists.
+ Returns [code]true[/code] if a sub animation node with specified [param name] exists.
- Removes a sub-node.
+ Removes a sub animation node.
@@ -70,7 +70,7 @@
- Changes the name of a sub-node.
+ Changes the name of a sub animation node.
@@ -78,13 +78,13 @@
- Modifies the position of a sub-node.
+ Modifies the position of a sub animation node.
- The global offset of all sub-nodes.
+ The global offset of all sub animation nodes.
diff --git a/doc/classes/AnimationNodeOneShot.xml b/doc/classes/AnimationNodeOneShot.xml
index bdf2f18431f..7e5e61e56bc 100644
--- a/doc/classes/AnimationNodeOneShot.xml
+++ b/doc/classes/AnimationNodeOneShot.xml
@@ -4,7 +4,7 @@
Plays an animation once in an [AnimationNodeBlendTree].
- A resource to add to an [AnimationNodeBlendTree]. This node will execute a sub-animation and return once it finishes. Blend times for fading in and out can be customized, as well as filters.
+ A resource to add to an [AnimationNodeBlendTree]. This animation node will execute a sub-animation and return once it finishes. Blend times for fading in and out can be customized, as well as filters.
After setting the request and changing the animation playback, the one-shot node automatically clears the request on the next process frame by setting its [code]request[/code] value to [constant ONE_SHOT_REQUEST_NONE].
[codeblocks]
[gdscript]
diff --git a/doc/classes/AnimationNodeStateMachine.xml b/doc/classes/AnimationNodeStateMachine.xml
index 9459c31b3b7..b2b9166c380 100644
--- a/doc/classes/AnimationNodeStateMachine.xml
+++ b/doc/classes/AnimationNodeStateMachine.xml
@@ -4,7 +4,7 @@
A state machine with multiple [AnimationRootNode]s, used by [AnimationTree].
- Contains multiple [AnimationRootNode]s representing animation states, connected in a graph. Node transitions can be configured to happen automatically or via code, using a shortest-path algorithm. Retrieve the [AnimationNodeStateMachinePlayback] object from the [AnimationTree] node to control it programmatically.
+ Contains multiple [AnimationRootNode]s representing animation states, connected in a graph. State transitions can be configured to happen automatically or via code, using a shortest-path algorithm. Retrieve the [AnimationNodeStateMachinePlayback] object from the [AnimationTree] node to control it programmatically.
[b]Example:[/b]
[codeblocks]
[gdscript]
@@ -27,7 +27,7 @@
- Adds a new node to the graph. The [param position] is used for display in the editor.
+ Adds a new animation node to the graph. The [param position] is used for display in the editor.
@@ -36,7 +36,7 @@
- Adds a transition between the given nodes.
+ Adds a transition between the given animation nodes.
@@ -63,7 +63,7 @@
- Returns the given node's coordinates. Used for display in the editor.
+ Returns the given animation node's coordinates. Used for display in the editor.
@@ -97,7 +97,7 @@
- Returns [code]true[/code] if the graph contains the given node.
+ Returns [code]true[/code] if the graph contains the given animation node.
@@ -105,14 +105,14 @@
- Returns [code]true[/code] if there is a transition between the given nodes.
+ Returns [code]true[/code] if there is a transition between the given animation nodes.
- Deletes the given node from the graph.
+ Deletes the given animation node from the graph.
@@ -120,7 +120,7 @@
- Deletes the transition between the two specified nodes.
+ Deletes the transition between the two specified animation nodes.
@@ -135,7 +135,7 @@
- Renames the given node.
+ Renames the given animation node.
@@ -157,7 +157,7 @@
- Sets the node's coordinates. Used for display in the editor.
+ Sets the animation node's coordinates. Used for display in the editor.
diff --git a/doc/classes/AnimationNodeSub2.xml b/doc/classes/AnimationNodeSub2.xml
new file mode 100644
index 00000000000..f913526a236
--- /dev/null
+++ b/doc/classes/AnimationNodeSub2.xml
@@ -0,0 +1,15 @@
+
+
+
+ Blends two animations subtractively inside of an [AnimationNodeBlendTree].
+
+
+ A resource to add to an [AnimationNodeBlendTree]. Blends two animations subtractively based on the amount value.
+ This animation node is usually used for pre-calculation to cancel out any extra poses from the animation for the "add" animation source in [AnimationNodeAdd2] or [AnimationNodeAdd3].
+ In general, the blend value should be in the [code][0.0, 1.0][/code] range, but values outside of this range can be used for amplified or inverted animations.
+ [b]Note:[/b] This calculation is different from using a negative value in [AnimationNodeAdd2], since the transformation matrices do not satisfy the commutative law. [AnimationNodeSub2] multiplies the transformation matrix of the inverted animation from the left side, while negative [AnimationNodeAdd2] multiplies it from the right side.
+
+
+ $DOCS_URL/tutorials/animation/animation_tree.html
+
+
diff --git a/doc/classes/AnimationNodeTimeSeek.xml b/doc/classes/AnimationNodeTimeSeek.xml
index 3098fa76625..053e2e0bb2b 100644
--- a/doc/classes/AnimationNodeTimeSeek.xml
+++ b/doc/classes/AnimationNodeTimeSeek.xml
@@ -4,7 +4,7 @@
A time-seeking animation node used in [AnimationTree].
- This node can be used to cause a seek command to happen to any sub-children of the animation graph. Use this node type to play an [Animation] from the start or a certain playback position inside the [AnimationNodeBlendTree].
+ This animation node can be used to cause a seek command to happen to any sub-children of the animation graph. Use to play an [Animation] from the start or a certain playback position inside the [AnimationNodeBlendTree].
After setting the time and changing the animation playback, the time seek node automatically goes into sleep mode on the next process frame by setting its [code]seek_request[/code] value to [code]-1.0[/code].
[codeblocks]
[gdscript]
diff --git a/doc/classes/AnimationNodeTransition.xml b/doc/classes/AnimationNodeTransition.xml
index 481ea9ff59e..0d97f128aba 100644
--- a/doc/classes/AnimationNodeTransition.xml
+++ b/doc/classes/AnimationNodeTransition.xml
@@ -20,7 +20,7 @@
animation_tree["parameters/Transition/current_state"]
# Get current state index (read-only).
- animation_tree.get("parameters/Transition/current_index"))
+ animation_tree.get("parameters/Transition/current_index")
# Alternative syntax (same result as above).
animation_tree["parameters/Transition/current_index"]
[/gdscript]
@@ -78,7 +78,7 @@
If [code]true[/code], allows transition to the self state. When the reset option is enabled in input, the animation is restarted. If [code]false[/code], nothing happens on the transition to the self state.
- The number of enabled input ports for this node.
+ The number of enabled input ports for this animation node.
Determines how cross-fading between animations is eased. If empty, the transition will be linear.
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 9dff5127ae5..ea210872f7c 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -1109,6 +1109,7 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() {
add_options.push_back(AddOption("Add3", "AnimationNodeAdd3", 3));
add_options.push_back(AddOption("Blend2", "AnimationNodeBlend2", 2));
add_options.push_back(AddOption("Blend3", "AnimationNodeBlend3", 3));
+ add_options.push_back(AddOption("Sub2", "AnimationNodeSub2", 2));
add_options.push_back(AddOption("TimeSeek", "AnimationNodeTimeSeek", 1));
add_options.push_back(AddOption("TimeScale", "AnimationNodeTimeScale", 1));
add_options.push_back(AddOption("Transition", "AnimationNodeTransition"));
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index 5936fbc2c08..c1b1e6c287c 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -527,7 +527,7 @@ AnimationNodeOneShot::AnimationNodeOneShot() {
////////////////////////////////////////////////
void AnimationNodeAdd2::get_parameter_list(List *r_list) const {
- r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "0,1,0.01"));
+ r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "0,1,0.01,or_less,or_greater"));
}
Variant AnimationNodeAdd2::get_parameter_default_value(const StringName &p_parameter) const {
@@ -561,7 +561,7 @@ AnimationNodeAdd2::AnimationNodeAdd2() {
////////////////////////////////////////////////
void AnimationNodeAdd3::get_parameter_list(List *r_list) const {
- r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "-1,1,0.01"));
+ r_list->push_back(PropertyInfo(Variant::FLOAT, add_amount, PROPERTY_HINT_RANGE, "-1,1,0.01,or_less,or_greater"));
}
Variant AnimationNodeAdd3::get_parameter_default_value(const StringName &p_parameter) const {
@@ -597,7 +597,7 @@ AnimationNodeAdd3::AnimationNodeAdd3() {
/////////////////////////////////////////////
void AnimationNodeBlend2::get_parameter_list(List *r_list) const {
- r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "0,1,0.01"));
+ r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "0,1,0.01,or_less,or_greater"));
}
Variant AnimationNodeBlend2::get_parameter_default_value(const StringName &p_parameter) const {
@@ -632,7 +632,7 @@ AnimationNodeBlend2::AnimationNodeBlend2() {
//////////////////////////////////////
void AnimationNodeBlend3::get_parameter_list(List *r_list) const {
- r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "-1,1,0.01"));
+ r_list->push_back(PropertyInfo(Variant::FLOAT, blend_amount, PROPERTY_HINT_RANGE, "-1,1,0.01,or_less,or_greater"));
}
Variant AnimationNodeBlend3::get_parameter_default_value(const StringName &p_parameter) const {
@@ -661,6 +661,39 @@ AnimationNodeBlend3::AnimationNodeBlend3() {
add_input("+blend");
}
+////////////////////////////////////////////////
+
+void AnimationNodeSub2::get_parameter_list(List *r_list) const {
+ r_list->push_back(PropertyInfo(Variant::FLOAT, sub_amount, PROPERTY_HINT_RANGE, "0,1,0.01,or_less,or_greater"));
+}
+
+Variant AnimationNodeSub2::get_parameter_default_value(const StringName &p_parameter) const {
+ return 0;
+}
+
+String AnimationNodeSub2::get_caption() const {
+ return "Sub2";
+}
+
+bool AnimationNodeSub2::has_filter() const {
+ return true;
+}
+
+double AnimationNodeSub2::_process(double p_time, bool p_seek, bool p_is_external_seeking, bool p_test_only) {
+ double amount = get_parameter(sub_amount);
+ // Out = Sub.Transform3D^(-1) * In.Transform3D
+ blend_input(1, p_time, p_seek, p_is_external_seeking, -amount, FILTER_PASS, sync, p_test_only);
+ return blend_input(0, p_time, p_seek, p_is_external_seeking, 1.0, FILTER_IGNORE, sync, p_test_only);
+}
+
+void AnimationNodeSub2::_bind_methods() {
+}
+
+AnimationNodeSub2::AnimationNodeSub2() {
+ add_input("in");
+ add_input("sub");
+}
+
/////////////////////////////////
void AnimationNodeTimeScale::get_parameter_list(List *r_list) const {
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 25b001e9732..2139af8a968 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -246,6 +246,26 @@ public:
AnimationNodeBlend3();
};
+class AnimationNodeSub2 : public AnimationNodeSync {
+ GDCLASS(AnimationNodeSub2, AnimationNodeSync);
+
+ StringName sub_amount = PNAME("sub_amount");
+
+protected:
+ static void _bind_methods();
+
+public:
+ void get_parameter_list(List *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
+
+ virtual String get_caption() const override;
+
+ virtual bool has_filter() const override;
+ virtual double _process(double p_time, bool p_seek, bool p_is_external_seeking, bool p_test_only = false) override;
+
+ AnimationNodeSub2();
+};
+
class AnimationNodeTimeScale : public AnimationNode {
GDCLASS(AnimationNodeTimeScale, AnimationNode);
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 5d4d58f283b..3e62dbc1a55 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -281,7 +281,7 @@ double AnimationNode::_blend_node(const StringName &p_subpath, const Vector