8aa3c2f091
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.
104 lines
4.4 KiB
XML
104 lines
4.4 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="SkeletonModification2D" inherits="Resource" version="4.0">
|
|
<brief_description>
|
|
A resource that operates on [Bone2D] nodes in a [Skeleton2D].
|
|
</brief_description>
|
|
<description>
|
|
This resource provides an interface that can be expanded so code that operates on [Bone2D] nodes in a [Skeleton2D] can be mixed and matched together to create complex interactions.
|
|
This is used to provide Godot with a flexible and powerful Inverse Kinematics solution that can be adapted for many different uses.
|
|
</description>
|
|
<tutorials>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="_draw_editor_gizmo" qualifiers="virtual">
|
|
<return type="void">
|
|
</return>
|
|
<description>
|
|
Used for drawing [b]editor-only[/b] modification gizmos. This function will only be called in the Godot editor and can be overriden to draw custom gizmos.
|
|
[b]Note:[/b] You will need to use the Skeleton2D from [method SkeletonModificationStack2D.get_skeleton] and it's draw functions, as the [SkeletonModification2D] resource cannot draw on its own.
|
|
</description>
|
|
</method>
|
|
<method name="_execute" qualifiers="virtual">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="delta" type="float">
|
|
</argument>
|
|
<description>
|
|
Executes the given modification. This is where the modification performs whatever function it is designed to do.
|
|
</description>
|
|
</method>
|
|
<method name="_setup_modification" qualifiers="virtual">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="modification_stack" type="SkeletonModificationStack2D">
|
|
</argument>
|
|
<description>
|
|
Called when the modification is setup. This is where the modification performs initialization.
|
|
</description>
|
|
</method>
|
|
<method name="clamp_angle">
|
|
<return type="float">
|
|
</return>
|
|
<argument index="0" name="angle" type="float">
|
|
</argument>
|
|
<argument index="1" name="min" type="float">
|
|
</argument>
|
|
<argument index="2" name="max" type="float">
|
|
</argument>
|
|
<argument index="3" name="invert" type="bool">
|
|
</argument>
|
|
<description>
|
|
Takes a angle and clamps it so it is within the passed-in [code]min[/code] and [code]max[/code] range. [code]invert[/code] will inversely clamp the angle, clamping it to the range outside of the given bounds.
|
|
</description>
|
|
</method>
|
|
<method name="get_editor_draw_gizmo" qualifiers="const">
|
|
<return type="bool">
|
|
</return>
|
|
<description>
|
|
Returns whether this modification will call [method _draw_editor_gizmo] in the Godot editor to draw modification-specific gizmos.
|
|
</description>
|
|
</method>
|
|
<method name="get_is_setup" qualifiers="const">
|
|
<return type="bool">
|
|
</return>
|
|
<description>
|
|
Returns whether this modification has been successfully setup or not.
|
|
</description>
|
|
</method>
|
|
<method name="get_modification_stack">
|
|
<return type="SkeletonModificationStack2D">
|
|
</return>
|
|
<description>
|
|
Returns the [SkeletonModificationStack2D] that this modification is bound to. Through the modification stack, you can access the Skeleton3D the modification is operating on.
|
|
</description>
|
|
</method>
|
|
<method name="set_editor_draw_gizmo">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="draw_gizmo" type="bool">
|
|
</argument>
|
|
<description>
|
|
Sets whether this modification will call [method _draw_editor_gizmo] in the Godot editor to draw modification-specific gizmos.
|
|
</description>
|
|
</method>
|
|
<method name="set_is_setup">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="is_setup" type="bool">
|
|
</argument>
|
|
<description>
|
|
Manually allows you to set the setup state of the modification. This function should only rarely be used, as the [SkeletonModificationStack2D] the modification is bound to should handle setting the modification up.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="enabled" type="bool" setter="set_enabled" getter="get_enabled" default="true">
|
|
If [code]true[/code], the modification's [method _execute] function will be called by the [SkeletonModificationStack2D].
|
|
</member>
|
|
<member name="execution_mode" type="int" setter="set_execution_mode" getter="get_execution_mode" default="0">
|
|
The execution mode for the modification. This tells the modification stack when to execute the modification. Some modifications have settings that are only availible in certain execution modes.
|
|
</member>
|
|
</members>
|
|
<constants>
|
|
</constants>
|
|
</class>
|