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.
232 lines
9.6 KiB
XML
232 lines
9.6 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="SkeletonModification2DJiggle" inherits="SkeletonModification2D" version="4.0">
|
|
<brief_description>
|
|
A modification that jiggles [Bone2D] nodes as they move towards a target.
|
|
</brief_description>
|
|
<description>
|
|
This modification moves a series of bones, typically called a bone chain, towards a target. What makes this modification special is that it calculates the velocity and acceleration for each bone in the bone chain, and runs a very light physics-like calculation using the inputted values. This allows the bones to overshoot the target and "jiggle" around. It can be configured to act more like a spring, or sway around like cloth might.
|
|
This modification is useful for adding additional motion to things like hair, the edges of clothing, and more. It has several settings to that allow control over how the joint moves when the target moves.
|
|
[b]Note:[/b] The Jiggle modifier has [code]jiggle_joints[/code], which are the data objects that hold the data for each joint in the Jiggle chain. This is different from than [Bone2D] nodes! Jiggle joints hold the data needed for each [Bone2D] in the bone chain used by the Jiggle modification.
|
|
</description>
|
|
<tutorials>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="get_collision_mask" qualifiers="const">
|
|
<return type="int">
|
|
</return>
|
|
<description>
|
|
Returns the collision mask used by the Jiggle modifier when collisions are enabled.
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_bone2d_node" qualifiers="const">
|
|
<return type="NodePath">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns the [Bone2D] node assigned to the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_bone_index" qualifiers="const">
|
|
<return type="int">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns the index of the [Bone2D] node assigned to the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_damping" qualifiers="const">
|
|
<return type="float">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns the amount of damping of the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_gravity" qualifiers="const">
|
|
<return type="Vector2">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns a [Vector2] representing the amount of gravity the Jiggle joint at [code]joint_idx[/code] is influenced by.
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_mass" qualifiers="const">
|
|
<return type="float">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns the amount of mass of the jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_override" qualifiers="const">
|
|
<return type="bool">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns a boolean that indiciates whether the joint at [code]joint_idx[/code] is overriding the default Jiggle joint data defined in the modification.
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_stiffness" qualifiers="const">
|
|
<return type="float">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns the stiffness of the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="get_jiggle_joint_use_gravity" qualifiers="const">
|
|
<return type="bool">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Returns a boolean that indiciates whether the joint at [code]joint_idx[/code] is using gravity or not.
|
|
</description>
|
|
</method>
|
|
<method name="get_use_colliders" qualifiers="const">
|
|
<return type="bool">
|
|
</return>
|
|
<description>
|
|
Returns whether the jiggle modifier is taking physics colliders into account when solving.
|
|
</description>
|
|
</method>
|
|
<method name="set_collision_mask">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="collision_mask" type="int">
|
|
</argument>
|
|
<description>
|
|
Sets the collision mask that the Jiggle modifier will use when reacting to colliders, if the Jiggle modifier is set to take colliders into account.
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_bone2d_node">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="bone2d_node" type="NodePath">
|
|
</argument>
|
|
<description>
|
|
Sets the [Bone2D] node assigned to the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_bone_index">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="bone_idx" type="int">
|
|
</argument>
|
|
<description>
|
|
Sets the bone index, [code]bone_index[/code], of the Jiggle joint at [code]joint_idx[/code]. When possible, this will also update the [code]bone2d_node[/code] of the Jiggle joint based on data provided by the linked skeleton.
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_damping">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="damping" type="float">
|
|
</argument>
|
|
<description>
|
|
Sets the amount of dampening of the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_gravity">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="gravity" type="Vector2">
|
|
</argument>
|
|
<description>
|
|
Sets the gravity vector of the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_mass">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="mass" type="float">
|
|
</argument>
|
|
<description>
|
|
Sets the of mass of the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_override">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="override" type="bool">
|
|
</argument>
|
|
<description>
|
|
Sets whether the Jiggle joint at [code]joint_idx[/code] should override the default Jiggle joint settings. Setting this to [code]true[/code] will make the joint use its own settings rather than the default ones attached to the modification.
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_stiffness">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="stiffness" type="float">
|
|
</argument>
|
|
<description>
|
|
Sets the of stiffness of the Jiggle joint at [code]joint_idx[/code].
|
|
</description>
|
|
</method>
|
|
<method name="set_jiggle_joint_use_gravity">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="joint_idx" type="int">
|
|
</argument>
|
|
<argument index="1" name="use_gravity" type="bool">
|
|
</argument>
|
|
<description>
|
|
Sets whether the Jiggle joint at [code]joint_idx[/code] should use gravity.
|
|
</description>
|
|
</method>
|
|
<method name="set_use_colliders">
|
|
<return type="void">
|
|
</return>
|
|
<argument index="0" name="use_colliders" type="bool">
|
|
</argument>
|
|
<description>
|
|
If [code]true[/code], the Jiggle modifier will take colliders into account, keeping them from entering into these collision objects.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="damping" type="float" setter="set_damping" getter="get_damping" default="0.75">
|
|
The default amount of dampening applied to the Jiggle joints, if they are not overriden. Higher values lead to more of the calculated velocity being applied.
|
|
</member>
|
|
<member name="gravity" type="Vector2" setter="set_gravity" getter="get_gravity" default="Vector2( 0, 6 )">
|
|
The default amount of gravity applied to the Jiggle joints, if they are not overriden.
|
|
</member>
|
|
<member name="jiggle_data_chain_length" type="int" setter="set_jiggle_data_chain_length" getter="get_jiggle_data_chain_length" default="0">
|
|
The amount of Jiggle joints in the Jiggle modification.
|
|
</member>
|
|
<member name="mass" type="float" setter="set_mass" getter="get_mass" default="0.75">
|
|
The default amount of mass assigned to the Jiggle joints, if they are not overriden. Higher values lead to faster movements and more overshooting.
|
|
</member>
|
|
<member name="stiffness" type="float" setter="set_stiffness" getter="get_stiffness" default="3.0">
|
|
The default amount of stiffness assigned to the Jiggle joints, if they are not overriden. Higher values act more like springs, quickly moving into the correct position.
|
|
</member>
|
|
<member name="target_nodepath" type="NodePath" setter="set_target_node" getter="get_target_node" default="NodePath("")">
|
|
The NodePath to the node that is the target for the Jiggle modification. This node is what the Jiggle chain will attempt to rotate the bone chain to.
|
|
</member>
|
|
<member name="use_gravity" type="bool" setter="set_use_gravity" getter="get_use_gravity" default="false">
|
|
Whether the gravity vector, [member gravity], should be applied to the Jiggle joints, assuming they are not overriding the default settings.
|
|
</member>
|
|
</members>
|
|
<constants>
|
|
</constants>
|
|
</class>
|