From 033abdc59f6385c49891909d44f1c1fc146e59a9 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Tue, 13 Sep 2022 19:59:17 -0700 Subject: [PATCH] 2D and 3D Skeleton modification docs, and small fixes. Mark SkeletonModificationStack3D and related as deprecated. Mark local bone override and axis functions deprecated in Skeleton3D api. Fix array property glitch in SkeletonModificationStack2D Mark SkeletonModificationStack2D and related APIs as experimental. Mark SkeletonIK3D as deprecated. --- doc/class.xsd | 8 ++++ doc/classes/BoneAttachment3D.xml | 10 +++-- doc/classes/Skeleton3D.xml | 28 ++++++++------ doc/classes/SkeletonIK3D.xml | 37 ++++++++++++++++++- doc/classes/SkeletonModification2D.xml | 2 +- doc/classes/SkeletonModification2DCCDIK.xml | 2 +- doc/classes/SkeletonModification2DFABRIK.xml | 2 +- doc/classes/SkeletonModification2DJiggle.xml | 2 +- doc/classes/SkeletonModification2DLookAt.xml | 2 +- .../SkeletonModification2DPhysicalBones.xml | 3 +- .../SkeletonModification2DStackHolder.xml | 2 +- .../SkeletonModification2DTwoBoneIK.xml | 2 +- doc/classes/SkeletonModification3D.xml | 2 +- doc/classes/SkeletonModification3DCCDIK.xml | 2 +- doc/classes/SkeletonModification3DFABRIK.xml | 2 +- doc/classes/SkeletonModification3DJiggle.xml | 2 +- doc/classes/SkeletonModification3DLookAt.xml | 2 +- .../SkeletonModification3DStackHolder.xml | 2 +- .../SkeletonModification3DTwoBoneIK.xml | 2 +- doc/classes/SkeletonModificationStack2D.xml | 2 +- doc/classes/SkeletonModificationStack3D.xml | 2 +- editor/doc_tools.cpp | 28 ++++++-------- .../skeleton_modification_stack_2d.cpp | 6 +-- 23 files changed, 99 insertions(+), 53 deletions(-) diff --git a/doc/class.xsd b/doc/class.xsd index 7681ddad3d1..d29d053006d 100644 --- a/doc/class.xsd +++ b/doc/class.xsd @@ -95,6 +95,8 @@ + + @@ -114,6 +116,8 @@ + + @@ -156,6 +160,8 @@ + + @@ -256,6 +262,8 @@ + + diff --git a/doc/classes/BoneAttachment3D.xml b/doc/classes/BoneAttachment3D.xml index dc3d448621d..f29525038e3 100644 --- a/doc/classes/BoneAttachment3D.xml +++ b/doc/classes/BoneAttachment3D.xml @@ -16,10 +16,11 @@ Returns the [NodePath] to the external [Skeleton3D] node, if one has been set. - + - Returns the override mode for the BoneAttachment3D node. + Deprecated. Local pose overrides will be removed. + Returns the override mode for the BoneAttachment3D node (0=global / 1=local). @@ -48,11 +49,12 @@ Sets the [NodePath] to the external skeleton that the BoneAttachment3D node should use. The external [Skeleton3D] node is only used when [code]use_external_skeleton[/code] is set to [code]true[/code]. - + - Sets the override mode for the BoneAttachment3D node. The override mode defines which of the bone poses the BoneAttachment3D node will override. + Deprecated. Local pose overrides will be removed. + Sets the override mode for the BoneAttachment3D node (0=global / 1=local). The override mode defines which of the bone poses the BoneAttachment3D node will override. diff --git a/doc/classes/Skeleton3D.xml b/doc/classes/Skeleton3D.xml index 5a0766263a0..3bd0e04b925 100644 --- a/doc/classes/Skeleton3D.xml +++ b/doc/classes/Skeleton3D.xml @@ -32,9 +32,10 @@ Removes the global pose override on all bones in the skeleton. - + + Deprecated. Local pose overrides will be removed. Removes the local pose override on all bones in the skeleton. @@ -43,7 +44,7 @@ - + @@ -58,7 +59,7 @@ Returns the bone index that matches [param name] as its name. - + Force updates the bone transforms/poses for all bones in the skeleton. @@ -166,7 +167,7 @@ Returns the rest transform for a bone [param bone_idx]. - + Returns the modification stack attached to this skeleton, if one exists. @@ -178,7 +179,7 @@ Returns an array with all of the bones that are parentless. Another way to look at this is that it returns the indexes of all the bones that are not dependent or modified by other bones in the Skeleton. - + @@ -187,15 +188,16 @@ This can be used to easily convert a global pose from [method get_bone_global_pose] to a global transform in [method set_bone_local_pose_override]. - + + Deprecated. Use [Node3D] apis instead. Takes the passed-in global pose and converts it to a world transform. This can be used to easily convert a global pose from [method get_bone_global_pose] to a global transform usable with a node's transform, like [member Node3D.global_transform] for example. - + @@ -211,7 +213,7 @@ Returns whether the bone pose for the bone at [param bone_idx] is enabled. - + @@ -293,16 +295,17 @@ Sets the global pose transform, [param pose], for the bone at [param bone_idx]. [param amount] is the interpolation strength that will be used when applying the pose, and [param persistent] determines if the applied pose will remain. - [b]Note:[/b] The pose transform needs to be a global pose! Use [method world_transform_to_global_pose] to convert a world transform, like one you can get from a [Node3D], to a global pose. + [b]Note:[/b] The pose transform needs to be a global pose! To convert a world transform from a [Node3D] to a global bone pose, multiply the [method Transform3D.affine_inverse] of the node's [member Node3D.global_transform] by the desired world transform - + + Deprecated. Local pose overrides will be removed. Sets the local pose transform, [param pose], for the bone at [param bone_idx]. [param amount] is the interpolation strength that will be used when applying the pose, and [param persistent] determines if the applied pose will remain. [b]Note:[/b] The pose transform needs to be a local pose! Use [method global_pose_to_local_pose] to convert a global pose to a local pose. @@ -353,7 +356,7 @@ Sets the rest transform for bone [param bone_idx]. - + @@ -367,10 +370,11 @@ Unparents the bone at [param bone_idx] and sets its rest position to that of its parent prior to being reset. - + + Deprecated. Use [Node3D] apis instead. Takes the passed-in global transform and converts it to a global pose. This can be used to easily convert a global transform from [member Node3D.global_transform] to a global pose usable with [method set_bone_global_pose_override], for example. diff --git a/doc/classes/SkeletonIK3D.xml b/doc/classes/SkeletonIK3D.xml index 788ba3e2482..1d50a97954c 100644 --- a/doc/classes/SkeletonIK3D.xml +++ b/doc/classes/SkeletonIK3D.xml @@ -1,8 +1,29 @@ - + + SkeletonIK3D is used to place the end bone of a [Skeleton3D] bone chain at a certain point in 3D by rotating all bones in the chain accordingly. + SkeletonIK3D is used to place the end bone of a [Skeleton3D] bone chain at a certain point in 3D by rotating all bones in the chain accordingly. A typical scenario for IK in games is to place a characters feet on the ground or a characters hands on a currently hold 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 [code]interpolation[/code] property. + [codeblock] + # Apply IK effect automatically on every new frame (not the current) + skeleton_ik_node.start() + + # Apply IK effect only on the current frame + skeleton_ik_node.start(true) + + # Stop IK effect and reset bones_global_pose_override on Skeleton + skeleton_ik_node.stop() + + # Apply full IK effect + skeleton_ik_node.set_interpolation(1.0) + + # Apply half IK effect + skeleton_ik_node.set_interpolation(0.5) + + # Apply zero IK effect (a value at or below 0.01 also removes bones_global_pose_override on Skeleton) + skeleton_ik_node.set_interpolation(0.0) + [/codeblock] https://godotengine.org/asset-library/asset/523 @@ -11,45 +32,59 @@ + Returns the parent [Skeleton3D] Node that was present when SkeletonIK entered the [SceneTree]. Returns null if the parent node was not a [Skeleton3D] Node when SkeletonIK3D entered the [SceneTree]. + Returns [code]true[/code] if SkeletonIK is applying IK effects on continues frames to the [Skeleton3D] bones. Returns [code]false[/code] if SkeletonIK is stopped or [method start] was used with the [code]one_time[/code] parameter set to [code]true[/code]. + Starts applying IK effects on each frame to the [Skeleton3D] bones but will only take effect starting on the next frame. If [code]one_time[/code] is [code]true[/code], this will take effect immediately but also reset on the next frame. + Stops applying IK effects on each frame to the [Skeleton3D] bones and also calls [method Skeleton3D.clear_bones_global_pose_override] to remove existing overrides on all bones. + 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]. + 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. + Number of iteration loops used by the IK solver to produce more accurate (and elegant) bone chain results. + The minimum distance between bone and goal target. If the distance is below this value, the IK solver stops further iterations. + If [code]true[/code] overwrites the rotation of the tip bone with the rotation of the [member target] (or [member target_node] if defined). + The name of the current root bone, the first bone in the IK chain. + First target of the IK chain where the tip bone is placed and, if [member override_tip_basis] is [code]true[/code], how the tip bone is rotated. If a [member target_node] path is available the nodes transform is used instead and this property is ignored. + Target node [NodePath] for the IK chain. If available, the node's current [Transform3D] is used instead of the [member target] property. + The name of the current tip bone, the last bone in the IK chain placed at the [member target] transform (or [member target_node] if defined). + If [code]true[/code], instructs the IK solver to consider the secondary magnet target (pole target) when calculating the bone chain. Use the magnet position (pole target) to control the bending of the IK chain. diff --git a/doc/classes/SkeletonModification2D.xml b/doc/classes/SkeletonModification2D.xml index 46d32aef416..77aaf0213be 100644 --- a/doc/classes/SkeletonModification2D.xml +++ b/doc/classes/SkeletonModification2D.xml @@ -1,5 +1,5 @@ - + A resource that operates on [Bone2D] nodes in a [Skeleton2D]. diff --git a/doc/classes/SkeletonModification2DCCDIK.xml b/doc/classes/SkeletonModification2DCCDIK.xml index c8fee3f94dc..0d80b1b9144 100644 --- a/doc/classes/SkeletonModification2DCCDIK.xml +++ b/doc/classes/SkeletonModification2DCCDIK.xml @@ -1,5 +1,5 @@ - + A modification that uses CCDIK to manipulate a series of bones to reach a target in 2D. diff --git a/doc/classes/SkeletonModification2DFABRIK.xml b/doc/classes/SkeletonModification2DFABRIK.xml index ff3a65fe1a6..8d1cd4b4d4f 100644 --- a/doc/classes/SkeletonModification2DFABRIK.xml +++ b/doc/classes/SkeletonModification2DFABRIK.xml @@ -1,5 +1,5 @@ - + A modification that uses FABRIK to manipulate a series of [Bone2D] nodes to reach a target. diff --git a/doc/classes/SkeletonModification2DJiggle.xml b/doc/classes/SkeletonModification2DJiggle.xml index 7329b2d8650..3321fffe1b3 100644 --- a/doc/classes/SkeletonModification2DJiggle.xml +++ b/doc/classes/SkeletonModification2DJiggle.xml @@ -1,5 +1,5 @@ - + A modification that jiggles [Bone2D] nodes as they move towards a target. diff --git a/doc/classes/SkeletonModification2DLookAt.xml b/doc/classes/SkeletonModification2DLookAt.xml index 4747b06056a..136fed37deb 100644 --- a/doc/classes/SkeletonModification2DLookAt.xml +++ b/doc/classes/SkeletonModification2DLookAt.xml @@ -1,5 +1,5 @@ - + A modification that rotates a [Bone2D] node to look at a target. diff --git a/doc/classes/SkeletonModification2DPhysicalBones.xml b/doc/classes/SkeletonModification2DPhysicalBones.xml index d5f46b2ea09..209602e974e 100644 --- a/doc/classes/SkeletonModification2DPhysicalBones.xml +++ b/doc/classes/SkeletonModification2DPhysicalBones.xml @@ -1,10 +1,11 @@ - + A modification that applies the transforms of [PhysicalBone2D] nodes to [Bone2D] nodes. 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. + Experimental. Physical bones may be changed in the future to perform the position update of [Bone2D] on their own. diff --git a/doc/classes/SkeletonModification2DStackHolder.xml b/doc/classes/SkeletonModification2DStackHolder.xml index 791dea2fb12..85df111c0d9 100644 --- a/doc/classes/SkeletonModification2DStackHolder.xml +++ b/doc/classes/SkeletonModification2DStackHolder.xml @@ -1,5 +1,5 @@ - + A modification that holds and executes a [SkeletonModificationStack2D]. diff --git a/doc/classes/SkeletonModification2DTwoBoneIK.xml b/doc/classes/SkeletonModification2DTwoBoneIK.xml index edd5431a0ca..c476d71d442 100644 --- a/doc/classes/SkeletonModification2DTwoBoneIK.xml +++ b/doc/classes/SkeletonModification2DTwoBoneIK.xml @@ -1,5 +1,5 @@ - + A modification that rotates two bones using the law of cosigns to reach the target. diff --git a/doc/classes/SkeletonModification3D.xml b/doc/classes/SkeletonModification3D.xml index 84571796511..25431ea96f1 100644 --- a/doc/classes/SkeletonModification3D.xml +++ b/doc/classes/SkeletonModification3D.xml @@ -1,5 +1,5 @@ - + A resource that operates on bones in a [Skeleton3D]. diff --git a/doc/classes/SkeletonModification3DCCDIK.xml b/doc/classes/SkeletonModification3DCCDIK.xml index dec0fbe99fc..90b2e78449c 100644 --- a/doc/classes/SkeletonModification3DCCDIK.xml +++ b/doc/classes/SkeletonModification3DCCDIK.xml @@ -1,5 +1,5 @@ - + A modification that uses CCDIK to manipulate a series of bones to reach a target. diff --git a/doc/classes/SkeletonModification3DFABRIK.xml b/doc/classes/SkeletonModification3DFABRIK.xml index 325cc2a12ed..a2bec2b559e 100644 --- a/doc/classes/SkeletonModification3DFABRIK.xml +++ b/doc/classes/SkeletonModification3DFABRIK.xml @@ -1,5 +1,5 @@ - + A modification that uses FABRIK to manipulate a series of bones to reach a target. diff --git a/doc/classes/SkeletonModification3DJiggle.xml b/doc/classes/SkeletonModification3DJiggle.xml index ef469d42eaa..304f08bb20c 100644 --- a/doc/classes/SkeletonModification3DJiggle.xml +++ b/doc/classes/SkeletonModification3DJiggle.xml @@ -1,5 +1,5 @@ - + A modification that jiggles bones as they move towards a target. diff --git a/doc/classes/SkeletonModification3DLookAt.xml b/doc/classes/SkeletonModification3DLookAt.xml index 3602cfad955..aeed953ca99 100644 --- a/doc/classes/SkeletonModification3DLookAt.xml +++ b/doc/classes/SkeletonModification3DLookAt.xml @@ -1,5 +1,5 @@ - + A modification that rotates a bone to look at a target. diff --git a/doc/classes/SkeletonModification3DStackHolder.xml b/doc/classes/SkeletonModification3DStackHolder.xml index 24240236a45..9448e2c783c 100644 --- a/doc/classes/SkeletonModification3DStackHolder.xml +++ b/doc/classes/SkeletonModification3DStackHolder.xml @@ -1,5 +1,5 @@ - + A modification that holds and executes a [SkeletonModificationStack3D]. diff --git a/doc/classes/SkeletonModification3DTwoBoneIK.xml b/doc/classes/SkeletonModification3DTwoBoneIK.xml index 6618ebbcfb7..0e7ffd5c804 100644 --- a/doc/classes/SkeletonModification3DTwoBoneIK.xml +++ b/doc/classes/SkeletonModification3DTwoBoneIK.xml @@ -1,5 +1,5 @@ - + A modification that moves two bones to reach the target. diff --git a/doc/classes/SkeletonModificationStack2D.xml b/doc/classes/SkeletonModificationStack2D.xml index 950e52e6227..d96833e335f 100644 --- a/doc/classes/SkeletonModificationStack2D.xml +++ b/doc/classes/SkeletonModificationStack2D.xml @@ -1,5 +1,5 @@ - + A resource that holds a stack of [SkeletonModification2D]s. diff --git a/doc/classes/SkeletonModificationStack3D.xml b/doc/classes/SkeletonModificationStack3D.xml index 34c7099bca2..9eaeeefd8e1 100644 --- a/doc/classes/SkeletonModificationStack3D.xml +++ b/doc/classes/SkeletonModificationStack3D.xml @@ -1,5 +1,5 @@ - + A resource that holds a stack of [SkeletonModification3D]s. diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 9f655ab00ab..7d6eb186dc4 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -1162,13 +1162,11 @@ Error DocTools::_load(Ref parser) { } if (parser->has_attribute("is_deprecated")) { - String result = parser->get_attribute_value("is_deprecated"); - c.is_deprecated = (result == "true" || result == "True" || result == "TRUE" || result == "1"); + c.is_deprecated = parser->get_attribute_value("is_deprecated").to_lower() == "true"; } if (parser->has_attribute("is_experimental")) { - String result = parser->get_attribute_value("is_experimental"); - c.is_experimental = (result == "true" || result == "True" || result == "TRUE" || result == "1"); + c.is_experimental = parser->get_attribute_value("is_experimental").to_lower() == "true"; } while (parser->read() == OK) { @@ -1315,12 +1313,10 @@ Error DocTools::_load(Ref parser) { constant2.is_bitfield = parser->get_attribute_value("is_bitfield").to_lower() == "true"; } if (parser->has_attribute("is_deprecated")) { - String result = parser->get_attribute_value("is_deprecated"); - constant2.is_deprecated = (result == "true" || result == "True" || result == "TRUE" || result == "1"); + constant2.is_deprecated = parser->get_attribute_value("is_deprecated").to_lower() == "true"; } if (parser->has_attribute("is_experimental")) { - String result = parser->get_attribute_value("is_experimental"); - constant2.is_experimental = (result == "true" || result == "True" || result == "TRUE" || result == "1"); + constant2.is_experimental = parser->get_attribute_value("is_experimental").to_lower() == "true"; } if (!parser->is_empty()) { parser->read(); @@ -1376,10 +1372,10 @@ static void _write_method_doc(Ref f, const String &p_name, Vector"); @@ -1446,10 +1442,10 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap p_mod) { ERR_FAIL_INDEX(p_mod_idx, modifications.size()); - if (p_mod == nullptr) { - modifications.insert(p_mod_idx, nullptr); + if (p_mod.is_null()) { + modifications.write[p_mod_idx] = Ref(); } else { + modifications.write[p_mod_idx] = p_mod; p_mod->_setup_modification(this); - modifications.insert(p_mod_idx, p_mod); } #ifdef TOOLS_ENABLED