Skip to content

Commit 7e08477

Browse files
authored
Merge pull request godotengine#87888 from TokageItLab/animation-post-processable
Implement a base class `SkeletonModifier3D` as refactoring for nodes that may modify `Skeleton3D`
2 parents f6a78f8 + 04dd299 commit 7e08477

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1525
-676
lines changed

doc/classes/AnimationMixer.xml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<param index="0" name="name" type="StringName" />
8181
<description>
8282
Returns the first [AnimationLibrary] with key [param name] or [code]null[/code] if not found.
83-
To get the [AnimationPlayer]'s global animation library, use [code]get_animation_library("")[/code].
83+
To get the [AnimationMixer]'s global animation library, use [code]get_animation_library("")[/code].
8484
</description>
8585
</method>
8686
<method name="get_animation_library_list" qualifiers="const">
@@ -239,14 +239,14 @@
239239
<return type="bool" />
240240
<param index="0" name="name" type="StringName" />
241241
<description>
242-
Returns [code]true[/code] if the [AnimationPlayer] stores an [Animation] with key [param name].
242+
Returns [code]true[/code] if the [AnimationMixer] stores an [Animation] with key [param name].
243243
</description>
244244
</method>
245245
<method name="has_animation_library" qualifiers="const">
246246
<return type="bool" />
247247
<param index="0" name="name" type="StringName" />
248248
<description>
249-
Returns [code]true[/code] if the [AnimationPlayer] stores an [AnimationLibrary] with key [param name].
249+
Returns [code]true[/code] if the [AnimationMixer] stores an [AnimationLibrary] with key [param name].
250250
</description>
251251
</method>
252252
<method name="remove_animation_library">
@@ -333,9 +333,14 @@
333333
Notifies when the caches have been cleared, either automatically, or manually via [method clear_caches].
334334
</description>
335335
</signal>
336+
<signal name="mixer_applied">
337+
<description>
338+
Notifies when the blending result related have been applied to the target objects.
339+
</description>
340+
</signal>
336341
<signal name="mixer_updated">
337342
<description>
338-
Editor only. Notifies when the property have been updated to update dummy [AnimationPlayer] in animation player editor.
343+
Notifies when the property related process have been updated.
339344
</description>
340345
</signal>
341346
</signals>

doc/classes/BoneAttachment3D.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
</member>
5353
<member name="override_pose" type="bool" setter="set_override_pose" getter="get_override_pose" default="false">
5454
Whether the BoneAttachment3D node will override the bone pose of the bone it is attached to. When set to [code]true[/code], the BoneAttachment3D node can change the pose of the bone. When set to [code]false[/code], the BoneAttachment3D will always be set to the bone's transform.
55+
[b]Note:[/b] This override performs interruptively in the skeleton update process using signals due to the old design. It may cause unintended behavior when used at the same time with [SkeletonModifier3D].
5556
</member>
5657
</members>
5758
</class>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="PhysicalBoneSimulator3D" inherits="SkeletonModifier3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3+
<brief_description>
4+
Node that can be the parent of [PhysicalBone3D] and can apply the simulation results to [Skeleton3D].
5+
</brief_description>
6+
<description>
7+
Node that can be the parent of [PhysicalBone3D] and can apply the simulation results to [Skeleton3D].
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="is_simulating_physics" qualifiers="const">
13+
<return type="bool" />
14+
<description>
15+
Returns a boolean that indicates whether the [PhysicalBoneSimulator3D] is running and simulating.
16+
</description>
17+
</method>
18+
<method name="physical_bones_add_collision_exception">
19+
<return type="void" />
20+
<param index="0" name="exception" type="RID" />
21+
<description>
22+
Adds a collision exception to the physical bone.
23+
Works just like the [RigidBody3D] node.
24+
</description>
25+
</method>
26+
<method name="physical_bones_remove_collision_exception">
27+
<return type="void" />
28+
<param index="0" name="exception" type="RID" />
29+
<description>
30+
Removes a collision exception to the physical bone.
31+
Works just like the [RigidBody3D] node.
32+
</description>
33+
</method>
34+
<method name="physical_bones_start_simulation">
35+
<return type="void" />
36+
<param index="0" name="bones" type="StringName[]" default="[]" />
37+
<description>
38+
Tells the [PhysicalBone3D] nodes in the Skeleton to start simulating and reacting to the physics world.
39+
Optionally, a list of bone names can be passed-in, allowing only the passed-in bones to be simulated.
40+
</description>
41+
</method>
42+
<method name="physical_bones_stop_simulation">
43+
<return type="void" />
44+
<description>
45+
Tells the [PhysicalBone3D] nodes in the Skeleton to stop simulating.
46+
</description>
47+
</method>
48+
</methods>
49+
</class>

doc/classes/Skeleton3D.xml

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Clear all the bones in this skeleton.
2828
</description>
2929
</method>
30-
<method name="clear_bones_global_pose_override">
30+
<method name="clear_bones_global_pose_override" deprecated="">
3131
<return type="void" />
3232
<description>
3333
Removes the global pose override on all bones in the skeleton.
@@ -58,6 +58,11 @@
5858
Force updates the bone transform for the bone at [param bone_idx] and all of its children.
5959
</description>
6060
</method>
61+
<method name="get_animate_physical_bones" qualifiers="const" deprecated="">
62+
<return type="bool" />
63+
<description>
64+
</description>
65+
</method>
6166
<method name="get_bone_children" qualifiers="const">
6267
<return type="PackedInt32Array" />
6368
<param index="0" name="bone_idx" type="int" />
@@ -76,16 +81,17 @@
7681
<param index="0" name="bone_idx" type="int" />
7782
<description>
7883
Returns the overall transform of the specified bone, with respect to the skeleton. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.
84+
[b]Note:[/b] This is the global pose you set to the skeleton in the process, the final global pose can get overridden by modifiers in the deferred process, if you want to access the final global pose, use [signal SkeletonModifier3D.modification_processed].
7985
</description>
8086
</method>
81-
<method name="get_bone_global_pose_no_override" qualifiers="const">
87+
<method name="get_bone_global_pose_no_override" qualifiers="const" deprecated="">
8288
<return type="Transform3D" />
8389
<param index="0" name="bone_idx" type="int" />
8490
<description>
8591
Returns the overall transform of the specified bone, with respect to the skeleton, but without any global pose overrides. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.
8692
</description>
8793
</method>
88-
<method name="get_bone_global_pose_override" qualifiers="const">
94+
<method name="get_bone_global_pose_override" qualifiers="const" deprecated="">
8995
<return type="Transform3D" />
9096
<param index="0" name="bone_idx" type="int" />
9197
<description>
@@ -119,6 +125,7 @@
119125
<param index="0" name="bone_idx" type="int" />
120126
<description>
121127
Returns the pose transform of the specified bone.
128+
[b]Note:[/b] This is the pose you set to the skeleton in the process, the final pose can get overridden by modifiers in the deferred process, if you want to access the final pose, use [signal SkeletonModifier3D.modification_processed].
122129
</description>
123130
</method>
124131
<method name="get_bone_pose_position" qualifiers="const">
@@ -176,31 +183,31 @@
176183
Returns all bones in the skeleton to their rest poses.
177184
</description>
178185
</method>
179-
<method name="physical_bones_add_collision_exception">
186+
<method name="physical_bones_add_collision_exception" deprecated="">
180187
<return type="void" />
181188
<param index="0" name="exception" type="RID" />
182189
<description>
183190
Adds a collision exception to the physical bone.
184191
Works just like the [RigidBody3D] node.
185192
</description>
186193
</method>
187-
<method name="physical_bones_remove_collision_exception">
194+
<method name="physical_bones_remove_collision_exception" deprecated="">
188195
<return type="void" />
189196
<param index="0" name="exception" type="RID" />
190197
<description>
191198
Removes a collision exception to the physical bone.
192199
Works just like the [RigidBody3D] node.
193200
</description>
194201
</method>
195-
<method name="physical_bones_start_simulation">
202+
<method name="physical_bones_start_simulation" deprecated="">
196203
<return type="void" />
197204
<param index="0" name="bones" type="StringName[]" default="[]" />
198205
<description>
199206
Tells the [PhysicalBone3D] nodes in the Skeleton to start simulating and reacting to the physics world.
200207
Optionally, a list of bone names can be passed-in, allowing only the passed-in bones to be simulated.
201208
</description>
202209
</method>
203-
<method name="physical_bones_stop_simulation">
210+
<method name="physical_bones_stop_simulation" deprecated="">
204211
<return type="void" />
205212
<description>
206213
Tells the [PhysicalBone3D] nodes in the Skeleton to stop simulating.
@@ -226,6 +233,12 @@
226233
Sets all bone poses to rests.
227234
</description>
228235
</method>
236+
<method name="set_animate_physical_bones" deprecated="">
237+
<return type="void" />
238+
<param index="0" name="enabled" type="bool" />
239+
<description>
240+
</description>
241+
</method>
229242
<method name="set_bone_enabled">
230243
<return type="void" />
231244
<param index="0" name="bone_idx" type="int" />
@@ -234,7 +247,16 @@
234247
Disables the pose for the bone at [param bone_idx] if [code]false[/code], enables the bone pose if [code]true[/code].
235248
</description>
236249
</method>
237-
<method name="set_bone_global_pose_override">
250+
<method name="set_bone_global_pose">
251+
<return type="void" />
252+
<param index="0" name="bone_idx" type="int" />
253+
<param index="1" name="pose" type="Transform3D" />
254+
<description>
255+
Sets the global pose transform, [param pose], for the bone at [param bone_idx].
256+
[b]Note:[/b] If other bone poses have been changed, this method executes an update process and will cause performance to deteriorate. If you know that multiple global poses will be applied, consider using [method set_bone_pose] with precalculation.
257+
</description>
258+
</method>
259+
<method name="set_bone_global_pose_override" deprecated="">
238260
<return type="void" />
239261
<param index="0" name="bone_idx" type="int" />
240262
<param index="1" name="pose" type="Transform3D" />
@@ -251,6 +273,7 @@
251273
<param index="0" name="bone_idx" type="int" />
252274
<param index="1" name="name" type="String" />
253275
<description>
276+
Sets the bone name, [param name], for the bone at [param bone_idx].
254277
</description>
255278
</method>
256279
<method name="set_bone_parent">
@@ -262,6 +285,14 @@
262285
[b]Note:[/b] [param parent_idx] must be less than [param bone_idx].
263286
</description>
264287
</method>
288+
<method name="set_bone_pose">
289+
<return type="void" />
290+
<param index="0" name="bone_idx" type="int" />
291+
<param index="1" name="pose" type="Transform3D" />
292+
<description>
293+
Sets the pose transform, [param pose], for the bone at [param bone_idx].
294+
</description>
295+
</method>
265296
<method name="set_bone_pose_position">
266297
<return type="void" />
267298
<param index="0" name="bone_idx" type="int" />
@@ -303,7 +334,8 @@
303334
</method>
304335
</methods>
305336
<members>
306-
<member name="animate_physical_bones" type="bool" setter="set_animate_physical_bones" getter="get_animate_physical_bones" default="true">
337+
<member name="modifier_callback_mode_process" type="int" setter="set_modifier_callback_mode_process" getter="get_modifier_callback_mode_process" enum="Skeleton3D.ModifierCallbackModeProcess" default="1">
338+
Sets the processing timing for the Modifier.
307339
</member>
308340
<member name="motion_scale" type="float" setter="set_motion_scale" getter="get_motion_scale" default="1.0">
309341
Multiplies the 3D position track animation.
@@ -320,6 +352,10 @@
320352
Emitted when the bone at [param bone_idx] is toggled with [method set_bone_enabled]. Use [method is_bone_enabled] to check the new value.
321353
</description>
322354
</signal>
355+
<signal name="bone_list_changed">
356+
<description>
357+
</description>
358+
</signal>
323359
<signal name="bone_pose_changed">
324360
<param index="0" name="bone_idx" type="int" />
325361
<description>
@@ -342,5 +378,11 @@
342378
Notification received when this skeleton's pose needs to be updated.
343379
This notification is received [i]before[/i] the related [signal pose_updated] signal.
344380
</constant>
381+
<constant name="MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS" value="0" enum="ModifierCallbackModeProcess">
382+
Set a flag to process modification during physics frames (see [constant Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS]).
383+
</constant>
384+
<constant name="MODIFIER_CALLBACK_MODE_PROCESS_IDLE" value="1" enum="ModifierCallbackModeProcess">
385+
Set a flag to process modification during process frames (see [constant Node.NOTIFICATION_INTERNAL_PROCESS]).
386+
</constant>
345387
</constants>
346388
</class>

doc/classes/SkeletonIK3D.xml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<class name="SkeletonIK3D" inherits="Node" deprecated="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
2+
<class name="SkeletonIK3D" inherits="SkeletonModifier3D" deprecated="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
33
<brief_description>
44
A node used to rotate all bones of a [Skeleton3D] bone chain a way that places the end bone at a desired 3D position.
55
</brief_description>
66
<description>
7-
SkeletonIK3D is used to rotate all bones of a [Skeleton3D] bone chain a way that places the end bone at a desired 3D position. A typical scenario for IK in games is to place a character's feet on the ground or a character's hands on a currently held object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the [Skeleton3D] [code]bones_global_pose_override[/code] property for all affected bones in the chain. If fully applied, this overwrites any bone transform from [Animation]s or bone custom poses set by users. The applied amount can be controlled with the [member interpolation] property.
7+
SkeletonIK3D is used to rotate all bones of a [Skeleton3D] bone chain a way that places the end bone at a desired 3D position. A typical scenario for IK in games is to place a character's feet on the ground or a character's hands on a currently held object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the [Skeleton3D] [code]bones_global_pose_override[/code] property for all affected bones in the chain. If fully applied, this overwrites any bone transform from [Animation]s or bone custom poses set by users. The applied amount can be controlled with the [member SkeletonModifier3D.influence] property.
88
[codeblock]
99
# Apply IK effect automatically on every new frame (not the current)
1010
skeleton_ik_node.start()
@@ -16,13 +16,13 @@
1616
skeleton_ik_node.stop()
1717

1818
# Apply full IK effect
19-
skeleton_ik_node.set_interpolation(1.0)
19+
skeleton_ik_node.set_influence(1.0)
2020

2121
# Apply half IK effect
22-
skeleton_ik_node.set_interpolation(0.5)
22+
skeleton_ik_node.set_influence(0.5)
2323

2424
# Apply zero IK effect (a value at or below 0.01 also removes bones_global_pose_override on Skeleton)
25-
skeleton_ik_node.set_interpolation(0.0)
25+
skeleton_ik_node.set_influence(0.0)
2626
[/codeblock]
2727
</description>
2828
<tutorials>
@@ -56,9 +56,6 @@
5656
</method>
5757
</methods>
5858
<members>
59-
<member name="interpolation" type="float" setter="set_interpolation" getter="get_interpolation" default="1.0">
60-
Interpolation value for how much the IK results are applied to the current skeleton bone chain. A value of [code]1.0[/code] will overwrite all skeleton bone transforms completely while a value of [code]0.0[/code] will visually disable the SkeletonIK. A value at or below [code]0.01[/code] also calls [method Skeleton3D.clear_bones_global_pose_override].
61-
</member>
6259
<member name="magnet" type="Vector3" setter="set_magnet_position" getter="get_magnet_position" default="Vector3(0, 0, 0)">
6360
Secondary target position (first is [member target] property or [member target_node]) for the IK chain. Use magnet position (pole target) to control the bending of the IK chain. Only works if the bone chain has more than 2 bones. The middle chain bone position will be linearly interpolated with the magnet position.
6461
</member>

doc/classes/SkeletonModifier3D.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="SkeletonModifier3D" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3+
<brief_description>
4+
A Node that may modify Skeleton3D's bone.
5+
</brief_description>
6+
<description>
7+
[SkeletonModifier3D] retrieves a target [Skeleton3D] by having a [Skeleton3D] parent.
8+
If there is [AnimationMixer], modification always performs after playback process of the [AnimationMixer].
9+
</description>
10+
<tutorials>
11+
</tutorials>
12+
<members>
13+
<member name="active" type="bool" setter="set_active" getter="is_active" default="true">
14+
If [code]true[/code], the [SkeletonModifier3D] will be processing.
15+
</member>
16+
<member name="influence" type="float" setter="set_influence" getter="get_influence" default="1.0">
17+
Sets the influence of the modification.
18+
[b]Note:[/b] This value is used by [Skeleton3D] to blend, so the [SkeletonModifier3D] should always apply only 100% of the result without interpolation.
19+
</member>
20+
</members>
21+
<signals>
22+
<signal name="modification_processed">
23+
<description>
24+
Notifies when the modification have been finished.
25+
[b]Note:[/b] If you want to get the modified bone pose by the modifier, you must use [method Skeleton3D.get_bone_pose] or [method Skeleton3D.get_bone_global_pose] at the moment this signal is fired.
26+
</description>
27+
</signal>
28+
</signals>
29+
</class>

doc/classes/XRBodyModifier3D.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<class name="XRBodyModifier3D" inherits="Node3D" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
2+
<class name="XRBodyModifier3D" inherits="SkeletonModifier3D" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
33
<brief_description>
44
A node for driving body meshes from [XRBodyTracker] data.
55
</brief_description>
@@ -24,9 +24,6 @@
2424
<member name="show_when_tracked" type="bool" setter="set_show_when_tracked" getter="get_show_when_tracked" default="true">
2525
If true then the nodes visibility is determined by whether tracking data is available.
2626
</member>
27-
<member name="target" type="NodePath" setter="set_target" getter="get_target" default="NodePath(&quot;&quot;)">
28-
A [NodePath] to a [Skeleton3D] to animate.
29-
</member>
3027
</members>
3128
<constants>
3229
<constant name="BODY_UPDATE_UPPER_BODY" value="1" enum="BodyUpdate" is_bitfield="true">

doc/classes/XRHandModifier3D.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<class name="XRHandModifier3D" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
2+
<class name="XRHandModifier3D" inherits="SkeletonModifier3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
33
<brief_description>
44
A node for driving hand meshes from [XRHandTracker] data.
55
</brief_description>
@@ -18,9 +18,6 @@
1818
<member name="hand_tracker" type="StringName" setter="set_hand_tracker" getter="get_hand_tracker" default="&amp;&quot;/user/left&quot;">
1919
The name of the [XRHandTracker] registered with [XRServer] to obtain the hand tracking data from.
2020
</member>
21-
<member name="target" type="NodePath" setter="set_target" getter="get_target" default="NodePath(&quot;&quot;)">
22-
A [NodePath] to a [Skeleton3D] to animate.
23-
</member>
2421
</members>
2522
<constants>
2623
<constant name="BONE_UPDATE_FULL" value="0" enum="BoneUpdate">

0 commit comments

Comments
 (0)