Skip to content
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

Skeleton IK 3D Interpolation #60180

Closed
Taiseibutsu opened this issue Apr 12, 2022 · 8 comments · Fixed by #77194
Closed

Skeleton IK 3D Interpolation #60180

Taiseibutsu opened this issue Apr 12, 2022 · 8 comments · Fixed by #77194

Comments

@Taiseibutsu
Copy link

Taiseibutsu commented Apr 12, 2022

Godot version

4.0.alpha6.official [e4f0fc5]

System information

Arch Linux, Nvidia Geforce 1080Ti

Issue description

Skeleton Ik 3D Interpolation does not assign the interpolation of the IK chain.
It assign it to 1 and only controls the override tip rotation.

0001-0313.mp4
Rotation also seemed identical as override tip magnet solution
0001-0313.mp4

Steps to reproduce

Normal use of
Skeleton3D.interpolation or Skeleton3D.set_interpolation()

Minimal reproduction project

skeleton3D_interpolation.zip

@Calinou
Copy link
Member

Calinou commented Apr 12, 2022

Is the behavior in Godot 3.4.4 considered correct here?

@Taiseibutsu
Copy link
Author

Taiseibutsu commented Apr 12, 2022

Yes, previous video was using magnet, that was it looked weird, the video for reference now it's default IK, used as it's similar on how the rotation tip behaves.

referenced old video with magnet usage:
0001-0313.mp4

@Calinou Calinou added this to the 4.0 milestone Apr 12, 2022
@fire
Copy link
Member

fire commented Apr 13, 2022

There is two systems for IK in godot engine.

The SkeletonIK3D is the older system. The newer system is pending modifications due to review by @lyuma and @TokageItLab.

So both are in limbo.

@TokageItLab
Copy link
Member

@fire There is similar issue in #59554. CC @TwistedTwigleg

@lyuma
Copy link
Contributor

lyuma commented Jan 14, 2023

I'll try and take a look at this, since I intend to keep SkeletonIK3D for 4.0 and it should be able to work the same as 3.5

My guess is these issues are casued by the change to make bone_pose include the bone_rest, while they were separate in 3.x

@TokageItLab TokageItLab modified the milestones: 4.0, 4.x Feb 17, 2023
@patrykkalinowski
Copy link

Hey, is this planned to be fixed in 4.0 or do we wait for replacement system?

patrykkalinowski added a commit to patrykkalinowski/godot-xr-kit that referenced this issue Apr 4, 2023
does not work yet due to bug in Godot: godotengine/godot#60180
@lyuma
Copy link
Contributor

lyuma commented May 18, 2023

Did a little experiment to port SkeletonIK3D to GDScript where the same bug can be replicated. It took only an hour or so.
skeletonik3dimpl.gd

I know it doesn't solve this bug, but if I'm really stuck, my plan is to do the same to the 3.x implementation. it may be easier to replicate the same behavior or debug if I have both implementations side-by-side.

People weren't particularly fond of SkeletonIK3D in 3.x either, but it might be a starting point.

@lyuma
Copy link
Contributor

lyuma commented May 18, 2023

I found the bug.

I'm attaching a zip with the test 4.1 project with SkeletonIK3D node, GDScript port of 4.0 skeleton_ik_3d and GDScript port of 3.x skeleton_ik_3d (the only difference is how the rest pose forward direction is calculated)
skeleton3D_interpolation.zip

I already applied the bugfix to the gd files in the attached projects. Search for if true: and bring back the original condition or make it if false to reproduce the bug.

And finally, I performed a backport by hand of the tscn to 3.x so we can run it on the classic engine and confirm behavior is the same, which is now is.
skeleton_interpolation_3.x.zip

The cause of the bug is get_bone_pose_global_no_override was inadvertently broken in 2021 due to a typo in the forward port of 3.x #48251 to master #48166 , and then the typo was concealed later in #51368 due to removing what then appeared to be duplicate code.

See the bug here in skeleton_3d.cpp
3.x:

	if (b.parent >= 0) {
		b.pose_global = bonesptr[b.parent].pose_global * pose;
		b.pose_global_no_override = bonesptr[b.parent].pose_global_no_override * pose;

master:

	if (b.parent >= 0) {
		b.pose_global = bonesptr[b.parent].pose_global * pose;
		b.pose_global_no_override = bonesptr[b.parent].pose_global * pose;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants