diff options
author | TwistedTwigleg <beard.noah@gmail.com> | 2020-08-03 14:02:24 -0400 |
---|---|---|
committer | TwistedTwigleg <beard.noah@gmail.com> | 2021-06-05 15:19:51 -0400 |
commit | 8aa3c2f0918707c2243b86ac53c02c27ceb9a266 (patch) | |
tree | f25a24d54a7370e6f972729ea53131fb5f61f7c6 /doc | |
parent | 7085c0d80110c4c3f90fcc12f609650144e08712 (diff) |
New and improved IK system for Skeleton2D
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.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/Bone2D.xml | 69 | ||||
-rw-r--r-- | doc/classes/Node.xml | 6 | ||||
-rw-r--r-- | doc/classes/PhysicalBone2D.xml | 49 | ||||
-rw-r--r-- | doc/classes/Skeleton2D.xml | 54 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2D.xml | 104 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2DCCDIK.xml | 170 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2DFABRIK.xml | 108 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2DJiggle.xml | 232 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2DLookAt.xml | 107 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2DPhysicalBones.xml | 68 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2DStackHolder.xml | 32 | ||||
-rw-r--r-- | doc/classes/SkeletonModification2DTwoBoneIK.xml | 94 | ||||
-rw-r--r-- | doc/classes/SkeletonModificationStack2D.xml | 108 | ||||
-rw-r--r-- | doc/classes/Transform2D.xml | 35 |
14 files changed, 1225 insertions, 11 deletions
diff --git a/doc/classes/Bone2D.xml b/doc/classes/Bone2D.xml index 910d488dfd..93744ddad7 100644 --- a/doc/classes/Bone2D.xml +++ b/doc/classes/Bone2D.xml @@ -19,6 +19,28 @@ 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"> </return> @@ -26,6 +48,13 @@ 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"> </return> @@ -33,11 +62,45 @@ 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="default_length" type="float" setter="set_default_length" getter="get_default_length" default="16.0"> - Length of the bone's representation drawn in the editor's viewport in pixels. - </member> <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> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 523f3a0c17..c4447962df 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -969,6 +969,12 @@ <constant name="NOTIFICATION_POST_ENTER_TREE" value="27"> Notification received when the node is ready, just before [constant NOTIFICATION_READY] is received. Unlike the latter, it's sent every time the node enters tree, instead of only once. </constant> + <constant name="NOTIFICATION_EDITOR_PRE_SAVE" value="9001"> + Notification received right before the scene with the node is saved in the editor. This notification is only sent in the Godot editor and will not occur in exported projects. + </constant> + <constant name="NOTIFICATION_EDITOR_POST_SAVE" value="9002"> + Notification received right after the scene with the node is saved in the editor. This notification is only sent in the Godot editor and will not occur in exported projects. + </constant> <constant name="NOTIFICATION_WM_MOUSE_ENTER" value="1002"> Notification received from the OS when the mouse enters the game window. Implemented on desktop and web platforms. diff --git a/doc/classes/PhysicalBone2D.xml b/doc/classes/PhysicalBone2D.xml new file mode 100644 index 0000000000..cea75bad52 --- /dev/null +++ b/doc/classes/PhysicalBone2D.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="PhysicalBone2D" inherits="RigidBody2D" version="4.0"> + <brief_description> + A 2D node that can be used for physically aware bones in 2D. + </brief_description> + <description> + The [code]PhysicalBone2D[/code] node is a [RigidBody2D]-based node that can be used to make [Bone2D] nodes in a [Skeleton2D] react to physics. This node is very similar to the [PhysicalBone3D] node, just for 2D instead of 3D. + [b]Note:[/b] To have the Bone2D nodes visually follow the [code]PhysicalBone2D[/code] node, use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] node with the [Bone2D] nodes. + [b]Note:[/b] The PhysicalBone2D node does not automatically create a [Joint2D] node to keep [code]PhysicalBone2D[/code] nodes together. You will need to create these manually. For most cases, you want to use a [PinJoint2D] node. The [code]PhysicalBone2D[/code] node can automatically configure the [Joint2D] node once it's been created as a child node. + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_joint" qualifiers="const"> + <return type="Joint2D"> + </return> + <description> + Returns the first [Joint2D] child node, if one exists. This is mainly a helper function to make it easier to get the [Joint2D] that the [code]PhysicalBone2D[/code] is autoconfiguring. + </description> + </method> + <method name="is_simulating_physics" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns a boolean that indicates whether the [code]PhysicalBone2D[/code] node is running and simulating using the Godot 2D physics engine. When [code]true[/code], the PhysicalBone2D node is using physics. + </description> + </method> + </methods> + <members> + <member name="auto_configure_joint" type="bool" setter="set_auto_configure_joint" getter="get_auto_configure_joint" default="true"> + If [code]true[/code], the [code]PhysicalBone2D[/code] node will automatically configure the first [Joint2D] child node. The automatic configuration is limited to setting up the node properties and positioning the [Joint2D]. + </member> + <member name="bone2d_index" type="int" setter="set_bone2d_index" getter="get_bone2d_index" default="-1"> + The index of the [Bone2D] node that this [code]PhysicalBone2D[/code] node is supposed to be simulating. + </member> + <member name="bone2d_nodepath" type="NodePath" setter="set_bone2d_nodepath" getter="get_bone2d_nodepath" default="NodePath("")"> + The [NodePath] to the [Bone2D] node that this [code]PhysicalBone2D[/code] node is supposed to be simulating. + </member> + <member name="follow_bone_when_simulating" type="bool" setter="set_follow_bone_when_simulating" getter="get_follow_bone_when_simulating" default="false"> + If [code]true[/code], the [code]PhysicalBone2D[/code] will keep the transform of the bone it is bound to when simulating physics. + </member> + <member name="simulate_physics" type="bool" setter="set_simulate_physics" getter="get_simulate_physics" default="false"> + If [code]true[/code], the [code]PhysicalBone2D[/code] will start simulating using physics. If [code]false[/code], the [code]PhysicalBone2D[/code] will follow the transform of the [Bone2D] node. + [b]Note:[/b] To have the Bone2D nodes visually follow the [code]PhysicalBone2D[/code] node, use a [SkeletonModification2DPhysicalBones] modification on the [Skeleton2D] node with the [Bone2D] nodes. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/Skeleton2D.xml b/doc/classes/Skeleton2D.xml index 0ddbac9ba4..80db57d7d0 100644 --- a/doc/classes/Skeleton2D.xml +++ b/doc/classes/Skeleton2D.xml @@ -10,6 +10,17 @@ <link title="2D skeletons">https://docs.godotengine.org/en/latest/tutorials/animation/2d_skeletons.html</link> </tutorials> <methods> + <method name="execute_modifications"> + <return type="void"> + </return> + <argument index="0" name="execution_mode" type="float"> + </argument> + <argument index="1" name="execution_mode" type="int"> + </argument> + <description> + Executes all the modifications on the [SkeletonModificationStack2D], if the Skeleton3D has one assigned. + </description> + </method> <method name="get_bone"> <return type="Bone2D"> </return> @@ -26,6 +37,22 @@ Returns the number of [Bone2D] nodes in the node hierarchy parented by Skeleton2D. </description> </method> + <method name="get_bone_local_pose_override"> + <return type="Transform2D"> + </return> + <argument index="0" name="bone_idx" type="int"> + </argument> + <description> + Returns the local pose override transform for [code]bone_idx[/code]. + </description> + </method> + <method name="get_modification_stack" qualifiers="const"> + <return type="SkeletonModificationStack2D"> + </return> + <description> + Returns the [SkeletonModificationStack2D] attached to this skeleton, if one exists. + </description> + </method> <method name="get_skeleton" qualifiers="const"> <return type="RID"> </return> @@ -33,10 +60,37 @@ Returns the [RID] of a Skeleton2D instance. </description> </method> + <method name="set_bone_local_pose_override"> + <return type="void"> + </return> + <argument index="0" name="bone_idx" type="int"> + </argument> + <argument index="1" name="override_pose" type="Transform2D"> + </argument> + <argument index="2" name="strength" type="float"> + </argument> + <argument index="3" name="persistent" type="bool"> + </argument> + <description> + Sets the local pose transform, [code]pose[/code], for the bone at [code]bone_idx[/code]. + [code]amount[/code] is the interpolation strengh that will be used when applying the pose, and [code]persistent[/code] determines if the applied pose will remain. + [b]Note:[/b] The pose transform needs to be a local transform relative to the [Bone2D] node at [code]bone_idx[/code]! + </description> + </method> + <method name="set_modification_stack"> + <return type="void"> + </return> + <argument index="0" name="modification_stack" type="SkeletonModificationStack2D"> + </argument> + <description> + Sets the [SkeletonModificationStack2D] attached to this skeleton. + </description> + </method> </methods> <signals> <signal name="bone_setup_changed"> <description> + Emitted when the [Bone2D] setup attached to this skeletons changes. This is primarily used internally within the skeleton. </description> </signal> </signals> diff --git a/doc/classes/SkeletonModification2D.xml b/doc/classes/SkeletonModification2D.xml new file mode 100644 index 0000000000..8596dac76e --- /dev/null +++ b/doc/classes/SkeletonModification2D.xml @@ -0,0 +1,104 @@ +<?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> diff --git a/doc/classes/SkeletonModification2DCCDIK.xml b/doc/classes/SkeletonModification2DCCDIK.xml new file mode 100644 index 0000000000..014d366a42 --- /dev/null +++ b/doc/classes/SkeletonModification2DCCDIK.xml @@ -0,0 +1,170 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkeletonModification2DCCDIK" inherits="SkeletonModification2D" version="4.0"> + <brief_description> + A modification that uses CCDIK to manipulate a series of bones to reach a target in 2D. + </brief_description> + <description> + This [SkeletonModification2D] uses an algorithm called [b]C[/b]yclic [b]C[/b]oordinate [b]D[/b]escent [b]I[/b]nverse [b]K[/b]inematics, or CCDIK, to maniuplate a chain of bones in a [Skeleton2D] so it reaches a defined target. + CCDIK works by rotating a set of bones, typically called a "bone chain", on a single axis. Each bone is rotated to face the target from the tip (by default), which over a chain of bones allow it to rotate properly to reach the target. Because the bones only rotate on a single axis, CCDIK [i]can[/i] look more robotic than other IK solvers. + [b]Note:[/b] The CCDIK modifier has [code]ccdik_joints[/code], which are the data objects that hold the data for each joint in the CCDIK chain. This is different from a bone! CCDIK joints hold the data needed for each bone in the bone chain used by CCDIK. + CCDIK also fully supports angle constraints, allowing for more control over how a solution is met. + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_ccdik_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 CCDIK joint at [code]joint_idx[/code]. + </description> + </method> + <method name="get_ccdik_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 CCDIK joint at [code]joint_idx[/code]. + </description> + </method> + <method name="get_ccdik_joint_constraint_angle_invert" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns whether the CCDIK joint at [code]joint_idx[/code] uses an inverted joint constraint. See [method set_ccdik_joint_constraint_angle_invert] for details. + </description> + </method> + <method name="get_ccdik_joint_constraint_angle_max" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns the maximum angle constraint for the joint at [code]joint_idx[/code]. + </description> + </method> + <method name="get_ccdik_joint_constraint_angle_min" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns the minimum angle constraint for the joint at [code]joint_idx[/code]. + </description> + </method> + <method name="get_ccdik_joint_enable_constraint" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns whether angle constraints on the CCDIK joint at [code]joint_idx[/code] are enabled. + </description> + </method> + <method name="get_ccdik_joint_rotate_from_joint" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns whether the joint at [code]joint_idx[/code] is set to rotate from the joint, [code]true[/code], or to rotate from the tip, [code]false[/code]. The default is to rotate from the tip. + </description> + </method> + <method name="set_ccdik_joint_bone2d_node"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="bone2d_nodepath" type="NodePath"> + </argument> + <description> + Sets the [Bone2D] node assigned to the CCDIK joint at [code]joint_idx[/code]. + </description> + </method> + <method name="set_ccdik_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 CCDIK joint at [code]joint_idx[/code]. When possible, this will also update the [code]bone2d_node[/code] of the CCDIK joint based on data provided by the linked skeleton. + </description> + </method> + <method name="set_ccdik_joint_constraint_angle_invert"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="invert" type="bool"> + </argument> + <description> + Sets whether the CCDIK joint at [code]joint_idx[/code] uses an inverted joint constraint. + An inverted joint constraint only constraints the CCDIK joint to the angles [i]outside of[/i] the inputted minimum and maximum angles. For this reason, it is referred to as an inverted joint constraint, as it constraints the joint to the outside of the inputted values. + </description> + </method> + <method name="set_ccdik_joint_constraint_angle_max"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="angle_max" type="float"> + </argument> + <description> + Sets the maximum angle constraint for the joint at [code]joint_idx[/code]. + </description> + </method> + <method name="set_ccdik_joint_constraint_angle_min"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="angle_min" type="float"> + </argument> + <description> + Sets the minimum angle constraint for the joint at [code]joint_idx[/code]. + </description> + </method> + <method name="set_ccdik_joint_enable_constraint"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="enable_constraint" type="bool"> + </argument> + <description> + Determines whether angle constraints on the CCDIK joint at [code]joint_idx[/code] are enabled. When [code]true[/code], constraints will be enabled and taken into account when solving. + </description> + </method> + <method name="set_ccdik_joint_rotate_from_joint"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="rotate_from_joint" type="bool"> + </argument> + <description> + Sets whether the joint at [code]joint_idx[/code] is set to rotate from the joint, [code]true[/code], or to rotate from the tip, [code]false[/code]. + </description> + </method> + </methods> + <members> + <member name="ccdik_data_chain_length" type="int" setter="set_ccdik_data_chain_length" getter="get_ccdik_data_chain_length" default="0"> + The amount of CCDIK joints in the CCDIK modification. + </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 CCDIK modification. This node is what the CCDIK chain will attempt to rotate the bone chain to. + </member> + <member name="tip_nodepath" type="NodePath" setter="set_tip_node" getter="get_tip_node" default="NodePath("")"> + The end position of the CCDIK chain. Typically, this should be a child of a [Bone2D] node attached to the final [Bone2D] in the CCDIK chain. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/SkeletonModification2DFABRIK.xml b/doc/classes/SkeletonModification2DFABRIK.xml new file mode 100644 index 0000000000..62ab34b06f --- /dev/null +++ b/doc/classes/SkeletonModification2DFABRIK.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkeletonModification2DFABRIK" inherits="SkeletonModification2D" version="4.0"> + <brief_description> + A modification that uses FABRIK to manipulate a series of [Bone2D] nodes to reach a target. + </brief_description> + <description> + This [SkeletonModification2D] uses an algorithm called [b]F[/b]orward [b]A[/b]nd [b]B[/b]ackward [b]R[/b]eaching [b]I[/b]nverse [b]K[/b]inematics, or FABRIK, to rotate a bone chain so that it reaches a target. + FABRIK works by knowing the positions and lengths of a series of bones, typically called a "bone chain". It first starts by running a forward pass, which places the final bone at the target's position. Then all other bones are moved towards the tip bone, so they stay at the defined bone length away. Then a backwards pass is performed, where the root/first bone in the FABRIK chain is placed back at the origin. then all other bones are moved so they stay at the defined bone length away. This positions the bone chain so that it reaches the target when possible, but all of the bones stay the correct length away from each other. + Because of how FABRIK works, it often gives more natural results than those seen in [SkeletonModification2DCCDIK]. FABRIK also supports angle constraints, which are fully taken into account when solving. + [b]Note:[/b] The FABRIK modifier has [code]fabrik_joints[/code], which are the data objects that hold the data for each joint in the FABRIK chain. This is different from [Bone2D] nodes! FABRIK joints hold the data needed for each [Bone2D] in the bone chain used by FABRIK. + To help control how the FABRIK joints move, a magnet vector can be passed, which can nudge the bones in a certain direction prior to solving, giving a level of control over the final result. + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_fabrik_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 FABRIK joint at [code]joint_idx[/code]. + </description> + </method> + <method name="get_fabrik_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 FABRIK joint at [code]joint_idx[/code]. + </description> + </method> + <method name="get_fabrik_joint_magnet_position" qualifiers="const"> + <return type="Vector2"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns the magnet position vector for the joint at [code]joint_idx[/code]. + </description> + </method> + <method name="get_fabrik_joint_use_target_rotation" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns whether the joint is using the target's rotation rather than allowing FABRIK to rotate the joint. This option only applies to the tip/final joint in the chain. + </description> + </method> + <method name="set_fabrik_joint_bone2d_node"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="bone2d_nodepath" type="NodePath"> + </argument> + <description> + Sets the [Bone2D] node assigned to the FABRIK joint at [code]joint_idx[/code]. + </description> + </method> + <method name="set_fabrik_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 FABRIK joint at [code]joint_idx[/code]. When possible, this will also update the [code]bone2d_node[/code] of the FABRIK joint based on data provided by the linked skeleton. + </description> + </method> + <method name="set_fabrik_joint_magnet_position"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="magnet_position" type="Vector2"> + </argument> + <description> + Sets the magnet position vector for the joint at [code]joint_idx[/code]. + </description> + </method> + <method name="set_fabrik_joint_use_target_rotation"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="use_target_rotation" type="bool"> + </argument> + <description> + Sets whether the joint at [code]joint_idx[/code] will use the target node's rotation rather than letting FABRIK rotate the node. + [b]Note:[/b] This option only works for the tip/final joint in the chain. For all other nodes, this option will be ignored. + </description> + </method> + </methods> + <members> + <member name="fabrik_data_chain_length" type="int" setter="set_fabrik_data_chain_length" getter="get_fabrik_data_chain_length" default="0"> + The amount of FABRIK joints in the FABRIK modification. + </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 FABRIK modification. This node is what the FABRIK chain will attempt to rotate the bone chain to. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/SkeletonModification2DJiggle.xml b/doc/classes/SkeletonModification2DJiggle.xml new file mode 100644 index 0000000000..7f8cf2d4d9 --- /dev/null +++ b/doc/classes/SkeletonModification2DJiggle.xml @@ -0,0 +1,232 @@ +<?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> diff --git a/doc/classes/SkeletonModification2DLookAt.xml b/doc/classes/SkeletonModification2DLookAt.xml new file mode 100644 index 0000000000..b0fa0e5a01 --- /dev/null +++ b/doc/classes/SkeletonModification2DLookAt.xml @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkeletonModification2DLookAt" inherits="SkeletonModification2D" version="4.0"> + <brief_description> + A modification that rotates a [Bone2D] node to look at a target. + </brief_description> + <description> + This [SkeletonModification2D] rotates a bone to look a target. This is extremely helpful for moving character's head to look at the player, rotating a turret to look at a target, or any other case where you want to make a bone rotate towards something quickly and easily. + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_additional_rotation" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the amount of additional rotation that is applied after the LookAt modification executes. + </description> + </method> + <method name="get_constraint_angle_invert" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns whether the constraints to this modification are inverted or not. + </description> + </method> + <method name="get_constraint_angle_max" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the constraint's maximum allowed angle. + </description> + </method> + <method name="get_constraint_angle_min" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the constraint's minimum allowed angle. + </description> + </method> + <method name="get_enable_constraint" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns [code]true[/code] if the LookAt modification is using constraints. + </description> + </method> + <method name="set_additional_rotation"> + <return type="void"> + </return> + <argument index="0" name="rotation" type="float"> + </argument> + <description> + Sets the amount of additional rotation that is to be applied after executing the modification. This allows for offsetting the results by the inputted rotation amount. + </description> + </method> + <method name="set_constraint_angle_invert"> + <return type="void"> + </return> + <argument index="0" name="invert" type="bool"> + </argument> + <description> + When [code]true[/code], the modification will use an inverted joint constraint. + An inverted joint constraint only constraints the [Bone2D] to the angles [i]outside of[/i] the inputted minimum and maximum angles. For this reason, it is referred to as an inverted joint constraint, as it constraints the joint to the outside of the inputted values. + </description> + </method> + <method name="set_constraint_angle_max"> + <return type="void"> + </return> + <argument index="0" name="angle_max" type="float"> + </argument> + <description> + Sets the constraint's maximum allowed angle. + </description> + </method> + <method name="set_constraint_angle_min"> + <return type="void"> + </return> + <argument index="0" name="angle_min" type="float"> + </argument> + <description> + Sets the constraint's minimum allowed angle. + </description> + </method> + <method name="set_enable_constraint"> + <return type="void"> + </return> + <argument index="0" name="enable_constraint" type="bool"> + </argument> + <description> + Sets whether this modification will use constraints or not. When [code]true[/code], constraints will be applied when solving the LookAt modification. + </description> + </method> + </methods> + <members> + <member name="bone2d_node" type="NodePath" setter="set_bone2d_node" getter="get_bone2d_node" default="NodePath("")"> + The [Bone2D] node that the modification will operate on. + </member> + <member name="bone_index" type="int" setter="set_bone_index" getter="get_bone_index" default="-1"> + The index of the [Bone2D] node that the modification will oeprate on. + </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 LookAt modification. This node is what the modification will rotate the [Bone2D] to. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/SkeletonModification2DPhysicalBones.xml b/doc/classes/SkeletonModification2DPhysicalBones.xml new file mode 100644 index 0000000000..d8aaf09a8e --- /dev/null +++ b/doc/classes/SkeletonModification2DPhysicalBones.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkeletonModification2DPhysicalBones" inherits="SkeletonModification2D" version="4.0"> + <brief_description> + A modification that applies the transforms of [PhysicalBone2D] nodes to [Bone2D] nodes. + </brief_description> + <description> + This modification takes the transforms of [PhysicalBone2D] nodes and applies them to [Bone2D] nodes. This allows the [Bone2D] nodes to react to physics thanks to the linked [PhysicalBone2D] nodes. + </description> + <tutorials> + </tutorials> + <methods> + <method name="fetch_physical_bones"> + <return type="void"> + </return> + <description> + Empties the list of [PhysicalBone2D] nodes and populates it will all [PhysicalBone2D] nodes that are children of the [Skeleton2D]. + </description> + </method> + <method name="get_physical_bone_node" qualifiers="const"> + <return type="NodePath"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <description> + Returns the [PhysicalBone2D] node at [code]joint_idx[/code]. + </description> + </method> + <method name="set_physical_bone_node"> + <return type="void"> + </return> + <argument index="0" name="joint_idx" type="int"> + </argument> + <argument index="1" name="physicalbone2d_node" type="NodePath"> + </argument> + <description> + Sets the [PhysicalBone2D] node at [code]joint_idx[/code]. + [b]Note:[/b] This is just the index used for this modification, not the bone index used in the [Skeleton2D]. + </description> + </method> + <method name="start_simulation"> + <return type="void"> + </return> + <argument index="0" name="bones" type="StringName[]" default="[ ]"> + </argument> + <description> + Tell the [PhysicalBone2D] nodes to start simulating and interacting with the physics world. + Optionally, an array of bone names can be passed to this function, and that will cause only [PhysicalBone2D] nodes with those names to start simulating. + </description> + </method> + <method name="stop_simulation"> + <return type="void"> + </return> + <argument index="0" name="bones" type="StringName[]" default="[ ]"> + </argument> + <description> + Tell the [PhysicalBone2D] nodes to stop simulating and interacting with the physics world. + Optionally, an array of bone names can be passed to this function, and that will cause only [PhysicalBone2D] nodes with those names to stop simulating. + </description> + </method> + </methods> + <members> + <member name="physical_bone_chain_length" type="int" setter="set_physical_bone_chain_length" getter="get_physical_bone_chain_length" default="0"> + The amount of [PhysicalBone2D] nodes linked in this modification. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/SkeletonModification2DStackHolder.xml b/doc/classes/SkeletonModification2DStackHolder.xml new file mode 100644 index 0000000000..313cf81482 --- /dev/null +++ b/doc/classes/SkeletonModification2DStackHolder.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkeletonModification2DStackHolder" inherits="SkeletonModification2D" version="4.0"> + <brief_description> + A modification that holds and executes a [SkeletonModificationStack2D]. + </brief_description> + <description> + This [SkeletonModification2D] holds a reference to a [SkeletonModificationStack2D], allowing you to use multiple modification stacks on a single [Skeleton2D]. + [b]Note:[/b] The modifications in the held [SkeletonModificationStack2D] will only be executed if their execution mode matches the execution mode of the SkeletonModification2DStackHolder. + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_held_modification_stack" qualifiers="const"> + <return type="SkeletonModificationStack2D"> + </return> + <description> + Returns the [SkeletonModificationStack2D] that this modification is holding. + </description> + </method> + <method name="set_held_modification_stack"> + <return type="void"> + </return> + <argument index="0" name="held_modification_stack" type="SkeletonModificationStack2D"> + </argument> + <description> + Sets the [SkeletonModificationStack2D] that this modification is holding. This modification stack will then be executed when this modification is executed. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/SkeletonModification2DTwoBoneIK.xml b/doc/classes/SkeletonModification2DTwoBoneIK.xml new file mode 100644 index 0000000000..554515556b --- /dev/null +++ b/doc/classes/SkeletonModification2DTwoBoneIK.xml @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkeletonModification2DTwoBoneIK" inherits="SkeletonModification2D" version="4.0"> + <brief_description> + A modification that rotates two bones using the law of cosigns to reach the target. + </brief_description> + <description> + This [SkeletonModification2D] uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosigns and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three verticies of the triangle. Because the algorithm works by making a triangle, it can only opperate on two bones. + TwoBoneIK is great for arms, legs, and really any joints that can be represented by just two bones that bend to reach a target. This solver is more lightweight than [SkeletonModification2DFABRIK], but gives similar, natural looking results. + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_joint_one_bone2d_node" qualifiers="const"> + <return type="NodePath"> + </return> + <description> + Returns the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. + </description> + </method> + <method name="get_joint_one_bone_idx" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the index of the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. + </description> + </method> + <method name="get_joint_two_bone2d_node" qualifiers="const"> + <return type="NodePath"> + </return> + <description> + Returns the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. + </description> + </method> + <method name="get_joint_two_bone_idx" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the index of the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. + </description> + </method> + <method name="set_joint_one_bone2d_node"> + <return type="void"> + </return> + <argument index="0" name="bone2d_node" type="NodePath"> + </argument> + <description> + Sets the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. + </description> + </method> + <method name="set_joint_one_bone_idx"> + <return type="void"> + </return> + <argument index="0" name="bone_idx" type="int"> + </argument> + <description> + Sets the index of the [Bone2D] node that is being used as the first bone in the TwoBoneIK modification. + </description> + </method> + <method name="set_joint_two_bone2d_node"> + <return type="void"> + </return> + <argument index="0" name="bone2d_node" type="NodePath"> + </argument> + <description> + Sets the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. + </description> + </method> + <method name="set_joint_two_bone_idx"> + <return type="void"> + </return> + <argument index="0" name="bone_idx" type="int"> + </argument> + <description> + Sets the index of the [Bone2D] node that is being used as the second bone in the TwoBoneIK modification. + </description> + </method> + </methods> + <members> + <member name="flip_bend_direction" type="bool" setter="set_flip_bend_direction" getter="get_flip_bend_direction" default="false"> + If [code]true[/code], the bones in the modification will blend outward as opposed to inwards when contracting. If [code]false[/code], the bones will bend inwards when contracting. + </member> + <member name="target_maximum_distance" type="float" setter="set_target_maximum_distance" getter="get_target_maximum_distance" default="0.0"> + The maximum distance the target can be at. If the target is farther than this distance, the modification will solve as if it's at this maximum distance. When set to [code]0[/code], the modification will solve without distance constraints. + </member> + <member name="target_minimum_distance" type="float" setter="set_target_minimum_distance" getter="get_target_minimum_distance" default="0.0"> + The minimum distance the target can be at. If the target is closer than this distance, the modification will solve as if it's at this minimum distance. When set to [code]0[/code], the modification will solve without distance constraints. + </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 TwoBoneIK modification. This node is what the modification will use when bending the [Bone2D] nodes. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/SkeletonModificationStack2D.xml b/doc/classes/SkeletonModificationStack2D.xml new file mode 100644 index 0000000000..35b899fe08 --- /dev/null +++ b/doc/classes/SkeletonModificationStack2D.xml @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkeletonModificationStack2D" inherits="Resource" version="4.0"> + <brief_description> + A resource that holds a stack of [SkeletonModification2D]s. + </brief_description> + <description> + This resource is used by the Skeleton and holds a stack of [SkeletonModification2D]s. + This controls the order of the modifications and how they are applied. Modification order is especially important for full-body IK setups, as you need to execute the modifications in the correct order to get the desired results. For example, you want to execute a modification on the spine [i]before[/i] the arms on a humanoid skeleton. + This resource also controls how strongly all of the modifications are applied to the [Skeleton2D]. + </description> + <tutorials> + </tutorials> + <methods> + <method name="add_modification"> + <return type="void"> + </return> + <argument index="0" name="modification" type="SkeletonModification2D"> + </argument> + <description> + Adds the passed-in [SkeletonModification2D] to the stack. + </description> + </method> + <method name="delete_modification"> + <return type="void"> + </return> + <argument index="0" name="mod_idx" type="int"> + </argument> + <description> + Deletes the [SkeletonModification2D] at the index position [code]mod_idx[/code], if it exists. + </description> + </method> + <method name="enable_all_modifications"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + Enables all [SkeletonModification2D]s in the stack. + </description> + </method> + <method name="execute"> + <return type="void"> + </return> + <argument index="0" name="delta" type="float"> + </argument> + <argument index="1" name="execution_mode" type="int"> + </argument> + <description> + Executes all of the [SkeletonModification2D]s in the stack that use the same execution mode as the passed-in [code]execution_mode[/code], starting from index [code]0[/code] to [member modification_count]. + [b]Note:[/b] The order of the modifications can matter depending on the modifications. For example, modifications on a spine should operate before modifications on the arms in order to get proper results. + </description> + </method> + <method name="get_is_setup" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns a boolean that indiciates whether the modification stack is setup and can execute. + </description> + </method> + <method name="get_modification" qualifiers="const"> + <return type="SkeletonModification2D"> + </return> + <argument index="0" name="mod_idx" type="int"> + </argument> + <description> + Returns the [SkeletonModification2D] at the passed-in index, [code]mod_idx[/code]. + </description> + </method> + <method name="get_skeleton" qualifiers="const"> + <return type="Skeleton2D"> + </return> + <description> + Returns the [Skeleton2D] node that the SkeletonModificationStack2D is bound to. + </description> + </method> + <method name="set_modification"> + <return type="void"> + </return> + <argument index="0" name="mod_idx" type="int"> + </argument> + <argument index="1" name="modification" type="SkeletonModification2D"> + </argument> + <description> + Sets the modification at [code]mod_idx[/code] to the passed-in modification, [code]modification[/code]. + </description> + </method> + <method name="setup"> + <return type="void"> + </return> + <description> + Sets up the modification stack so it can execute. This function should be called by [Skeleton2D] and shouldn't be manually called unless you know what you are doing. + </description> + </method> + </methods> + <members> + <member name="enabled" type="bool" setter="set_enabled" getter="get_enabled" default="false"> + If [code]true[/code], the modification's in the stack will be called. This is handled automatically through the [Skeleton2D] node. + </member> + <member name="modification_count" type="int" setter="set_modification_count" getter="get_modification_count" default="0"> + The number of modifications in the stack. + </member> + <member name="strength" type="float" setter="set_strength" getter="get_strength" default="1.0"> + The interpolation strength of the modifications in stack. A value of [code]0[/code] will make it where the modifications are not applied, a strength of [code]0.5[/code] will be half applied, and a strength of [code]1[/code] will allow the modifications to be fully applied and override the [Skeleton2D] [Bone2D] poses. + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index e748ceb281..0dbf95376a 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -129,6 +129,16 @@ Returns [code]true[/code] if this transform and [code]transform[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component. </description> </method> + <method name="looking_at" qualifiers="const"> + <return type="Transform2D"> + </return> + <argument index="0" name="target" type="Vector2" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + </argument> + <description> + Returns a copy of the transform rotated such that it's rotation on the X-axis points towards the [code]target[/code] position. + Operations take place in global space. + </description> + </method> <method name="operator !=" qualifiers="operator"> <return type="bool"> </return> @@ -138,33 +148,33 @@ </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Vector2"> + <return type="PackedVector2Array"> </return> - <argument index="0" name="right" type="Vector2"> + <argument index="0" name="right" type="PackedVector2Array"> </argument> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Rect2"> + <return type="Transform2D"> </return> - <argument index="0" name="right" type="Rect2"> + <argument index="0" name="right" type="Transform2D"> </argument> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="Transform2D"> + <return type="Rect2"> </return> - <argument index="0" name="right" type="Transform2D"> + <argument index="0" name="right" type="Rect2"> </argument> <description> </description> </method> <method name="operator *" qualifiers="operator"> - <return type="PackedVector2Array"> + <return type="Vector2"> </return> - <argument index="0" name="right" type="PackedVector2Array"> + <argument index="0" name="right" type="Vector2"> </argument> <description> </description> @@ -210,6 +220,15 @@ Scales the transform by the given scale factor, using matrix multiplication. </description> </method> + <method name="set_rotation"> + <return type="void"> + </return> + <argument index="0" name="rotation" type="float"> + </argument> + <description> + Sets the transform's rotation (in radians). + </description> + </method> <method name="translated" qualifiers="const"> <return type="Transform2D"> </return> |