-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New and improved IK in Skeleton2D #40347
Closed
TwistedTwigleg
wants to merge
34
commits into
godotengine:master
from
TwistedTwigleg:GSOC_2020_Working_Branch_2D_IK
Closed
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7701450
Initial groundwork (squashed from verbose branch: https://github.com/…
TwistedTwigleg f222cac
Changes:
TwistedTwigleg 2a3de40
Changes:
TwistedTwigleg a5847a2
Changes:
TwistedTwigleg e614ca1
Changes:
TwistedTwigleg 283d16d
Changes:
TwistedTwigleg c9c4d52
Changes:
TwistedTwigleg 1c44aa0
Changes:
TwistedTwigleg 79f0b74
Changes:
TwistedTwigleg e9d6a64
Changes:
TwistedTwigleg a9748cf
Changes:
TwistedTwigleg d440335
Changes:
TwistedTwigleg 9c62f26
Changes:
TwistedTwigleg d564845
Changes:
TwistedTwigleg a31dcc3
Changes:
TwistedTwigleg a0cf8b4
Changes:
TwistedTwigleg 3695a89
Changes:
TwistedTwigleg 9e2e8a8
Changes:
TwistedTwigleg 677290c
Changes:
TwistedTwigleg 970ccb4
Changes:
TwistedTwigleg 93e1648
Changes after code review! (Huge thanks to AndreaCatania for the revi…
TwistedTwigleg ec24bdb
Changes to fix the issues that came up after the rebase and fixed for…
TwistedTwigleg 4456bf0
More changes based on review feedback! Huge thanks to AndreaCatania f…
TwistedTwigleg cc76c91
Changed the use of LocalVector to just Vector, so the CI on GitHub wo…
TwistedTwigleg 27f8022
Removed angle constraints from 2D FABRIK, as they were not working.
TwistedTwigleg c6c3e6c
Rebased with master and fixed issues preventing the PR from running o…
TwistedTwigleg d26d755
Took the 2D IK modifications and put them into their own files.
TwistedTwigleg 29c8e81
Removed _print_execution_error and instead use ERR_PRINT_ONCE with no…
TwistedTwigleg b3bda2d
Fixing small issue that occured after rebase. Not sure what happened,…
TwistedTwigleg aea42d0
Expose looking_at and set_rotation in Transform2D to GDScript, fix th…
TwistedTwigleg 022d1a3
Missed a merge conflict on the rebase.
TwistedTwigleg 6db3741
Changes based on review feedback:
TwistedTwigleg e9552be
Syntax changes to the documentation for Skeleton2D and several of the…
TwistedTwigleg 19f1b1e
Slight adjustment to the looking_at function in Transfrom2D
TwistedTwigleg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?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="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="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="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> | ||
<method name="setup_modification" qualifiers="virtual"> | ||
<return type="void"> | ||
</return> | ||
<argument index="0" name="modification_stack" type="SkeletonModificationStack2D"> | ||
</argument> | ||
<description> | ||
</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> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.