mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-29 23:27:12 +01:00
Relintai
521934ff55
This PR and commit adds a new IK system for 2D with the Skeleton2D node
that adds several new IK solvers, a way to control bones in a Skeleton2D
node similar to that in Skeleton3D. It also adds additional changes
and functionality.
This work was sponsored by GSoC 2020 and TwistedTwigleg.
Full list of changes:
* Adds a SkeletonModifier2D resource
* This resource is the base where all IK code is written and executed
* Has a function for clamping angles, since it is so commonly used
* Modifiers are unique when duplicated so it works with instancing
* Adds a SkeletonModifierStack2D resource
* This resource manages a series of SkeletonModification2Ds
* This is what the Skeleton2D directly interfaces with to make IK possible
* Adds SkeletonModifier2D resources for LookAt, CCDIK, FABRIK, Jiggle, and TwoBoneIK
* Each modification is in its own file
* There is also a SkeletonModifier2D resource that acts as a stack for using multiple stacks together
* Adds a PhysicalBone2D node
* Works similar to the PhysicalBone3D node, but uses a RigidBody2D node
* Changes to Skeleton2D listed below:
* Skeleton2D now holds a single SkeletonModificationStack2D for IK
* Skeleton2D now has a local_pose_override, which overrides the Bone2D position similar to how the overrides work in Skeleton3D
* Changes to Bone2D listed below:
* The default_length property has been changed to length. Length is the length of the bone to its child bone node
* New bone_angle property, which is the angle the bone has to its first child bone node
* Bone2D caches its transform when not modified by IK for IK interpolation purposes
* Bone2D draws its own editor gizmo, though this is stated to change in the future
* Changes to CanvasItemEditor listed below:
* Bone2D gizmo drawing code removed
* The 2D IK code is removed. Now Bone2D is the only bone system for 2D
* Transform2D now has a looking_at function for rotating to face a position
* Two new node notifications: NOTIFICATION_EDITOR_PRE_SAVE and NOTIFICATION_EDITOR_POST_SAVE
* These notifications only are called in the editor right before and after saving a scene
* Needed for not saving the IK position when executing IK in the editor
* Documentation for all the changes listed above.
- TwistedTwigleg
8aa3c2f091
108 lines
4.7 KiB
XML
108 lines
4.7 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="Bone2D" inherits="Node2D" version="3.5">
|
|
<brief_description>
|
|
Joint used with [Skeleton2D] to control and animate other nodes.
|
|
</brief_description>
|
|
<description>
|
|
Use a hierarchy of [code]Bone2D[/code] bound to a [Skeleton2D] to control, and animate other [Node2D] nodes.
|
|
You can use [code]Bone2D[/code] and [code]Skeleton2D[/code] nodes to animate 2D meshes created with the Polygon 2D UV editor.
|
|
Each bone has a [member rest] transform that you can reset to with [method apply_rest]. These rest poses are relative to the bone's parent.
|
|
If in the editor, you can set the rest pose of an entire skeleton using a menu option, from the code, you need to iterate over the bones to set their individual rest poses.
|
|
</description>
|
|
<tutorials>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="apply_rest">
|
|
<return type="void" />
|
|
<description>
|
|
Stores the node's current transforms in [member rest].
|
|
</description>
|
|
</method>
|
|
<method name="get_autocalculate_length_and_angle" qualifiers="const">
|
|
<return type="bool">
|
|
</return>
|
|
<description>
|
|
Returns whether this [code]Bone2D[/code] node is going to autocalculate its length and bone angle using its first [code]Bone2D[/code] child node, if one exists. If there are no [code]Bone2D[/code] children, then it cannot autocalculate these values and will print a warning.
|
|
</description>
|
|
</method>
|
|
<method name="get_bone_angle" qualifiers="const">
|
|
<return type="float">
|
|
</return>
|
|
<description>
|
|
Returns the angle of the bone in the [code]Bone2D[/code] node.
|
|
[b]Note:[/b] This is different from the [code]Bone2D[/code]'s rotation. The bone angle is the rotation of the bone shown by the [code]Bone2D[/code] gizmo, and because [code]Bone2D[/code] bones are based on positions, this can vary from the actual rotation of the [code]Bone2D[/code] node.
|
|
</description>
|
|
</method>
|
|
<method name="get_default_length" qualifiers="const">
|
|
<return type="float">
|
|
</return>
|
|
<description>
|
|
Deprecated. Please use [code]get_length[/code] instead.
|
|
</description>
|
|
</method>
|
|
<method name="get_index_in_skeleton" qualifiers="const">
|
|
<return type="int" />
|
|
<description>
|
|
Returns the node's index as part of the entire skeleton. See [Skeleton2D].
|
|
</description>
|
|
</method>
|
|
<method name="get_length" qualifiers="const">
|
|
<return type="float">
|
|
</return>
|
|
<description>
|
|
Returns the length of the bone in the [code]Bone2D[/code] node.
|
|
</description>
|
|
</method>
|
|
<method name="get_skeleton_rest" qualifiers="const">
|
|
<return type="Transform2D" />
|
|
<description>
|
|
Returns the node's [member rest] [code]Transform2D[/code] if it doesn't have a parent, or its rest pose relative to its parent.
|
|
</description>
|
|
</method>
|
|
<method name="set_autocalculate_length_and_angle">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="auto_calculate" type="bool">
|
|
</argument>
|
|
<description>
|
|
When set to [code]true[/code], the [code]Bone2D[/code] node will attempt to automatically calculate the bone angle and length using the first child [code]Bone2D[/code] node, if one exists. If none exist, the [code]Bone2D[/code] cannot automatically calculate these values and will print a warning.
|
|
</description>
|
|
</method>
|
|
<method name="set_bone_angle">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="angle" type="float">
|
|
</argument>
|
|
<description>
|
|
Sets the bone angle for the [code]Bone2D[/code] node. This is typically set to the rotation from the [code]Bone2D[/code] node to a child [code]Bone2D[/code] node.
|
|
[b]Note:[/b] This is different from the [code]Bone2D[/code]'s rotation. The bone angle is the rotation of the bone shown by the [code]Bone2D[/code] gizmo, and because [code]Bone2D[/code] bones are based on positions, this can vary from the actual rotation of the [code]Bone2D[/code] node.
|
|
</description>
|
|
</method>
|
|
<method name="set_default_length">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="default_length" type="float">
|
|
</argument>
|
|
<description>
|
|
Deprecated. Please use [code]set_length[/code] instead.
|
|
</description>
|
|
</method>
|
|
<method name="set_length">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="length" type="float">
|
|
</argument>
|
|
<description>
|
|
Sets the length of the bone in the [code]Bone2D[/code] node.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="rest" type="Transform2D" setter="set_rest" getter="get_rest" default="Transform2D( 0, 0, 0, 0, 0, 0 )">
|
|
Rest transform of the bone. You can reset the node's transforms to this value using [method apply_rest].
|
|
</member>
|
|
</members>
|
|
<constants>
|
|
</constants>
|
|
</class>
|