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

Fix get_bone_global_pose_no_override() returning incorrect values #77194

Merged
merged 1 commit into from
May 18, 2023

Conversation

lyuma
Copy link
Contributor

@lyuma lyuma commented May 18, 2023

A change introduced in

This is the cause of the bug in SkeletonIK3D

Fixes #60180
Fixes #65167
Fixes #74753
Fixes #77138
and probably more

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.

I double checked against the corresponding if statements from scene/3d/skeleton.cpp in 3.x, with the exception of ignoring the extra b.rest * multiply which is no longer used in 4.0

screenshot showing identical SkeletonIK3D output from 4.1 + patch and 3.5

@lyuma lyuma requested a review from a team as a code owner May 18, 2023 10:19
@YuriSizov YuriSizov added this to the 4.1 milestone May 18, 2023
@fire fire requested a review from a team May 18, 2023 11:45
Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested #74753 and it works.

Recording.2023-05-18.085512.mp4

@YuriSizov YuriSizov changed the title Fix get_bone_pose_global_no_override() Fix get_bone_pose_global_no_override() returning incorrect values May 18, 2023
@YuriSizov YuriSizov merged commit ca8bbf2 into godotengine:master May 18, 2023
@YuriSizov
Copy link
Contributor

Great find, thanks!

@lyuma lyuma deleted the pose_global_no_override branch May 19, 2023 10:35
@wagnerfs
Copy link

I'm not sure it quite fixes the IK though, still getting undesired rotations when acquiring the rest pose transform apparently

godot.windows.editor.x86_64_2023-05-19_21-11-23.mp4

@fire
Copy link
Member

fire commented May 20, 2023

What git commit is that and can you provide a test project?

@wagnerfs
Copy link

I'll drop the project tomorrow, and I cloned from master since it's already been merged, double checked the changed files to make sure I got the right thing

@wagnerfs
Copy link

Godot4-test2.zip
Took a bit to do an empty project with just the basics, lots of crashing related to tool mode and skeleton.
This project should be enough, it's just the bones, just hit PlayIK and you're gonna see the shoulder deform going nuts.

@lyuma
Copy link
Contributor Author

lyuma commented May 20, 2023

@wagnerfs I would encourage you to file a new issues.

This issue has already been closed and your problem is going to get lost and forgotten if it's left here only in a comment

I believe it looks like a separate bug from this issue. The IK would have been far more broken if you had not used latest master.

If you want to verify, can you test the same setup in Godot 3.5 or 3.6 and see if it acts the same? it should

@wagnerfs
Copy link

@lyuma Nah, tested on Godot 3 way before, but did it again just now to make sure, works perfectly on 3, same GLB file.
I do assume it's something to do with either the data retrieved by bone_pose methods or how the initial bone transform is stored, regardless I'll file a new issue when I get the chance, just wanted to point this didn't solve the issue because I was using @fire many bone IK solution and noticed it was deleted prior to this commit.

@YuriSizov
Copy link
Contributor

Cherry-picked for 4.0.4.

@lyuma lyuma changed the title Fix get_bone_pose_global_no_override() returning incorrect values Fix get_bone_global_pose_no_override() returning incorrect values Jul 22, 2023
@YuriSizov
Copy link
Contributor

The cherry-pick is going to be reverted for 4.0.4 stable in the end. Since this changes the behavior, even if it fixes a bug it's not fitting for a patch release and I made a mistake picking it in the first place. For a proper fix consider updating to 4.1, if this is important for your project.

@lyuma
Copy link
Contributor Author

lyuma commented Aug 3, 2023

Thank you for doing the revert. I think it's the right call. While this API now acts the same way it did in 3.x (which is why I originally felt a backport made sense), there are already a number of people who expect the 4.0 behavior, since it turns out to be a little more useful for some applications.

(I'm having growing doubts that the approach we picked is the right thing in the long term... while it fixes the single IK case, it makes it impossible to daisy chain IK solvers, since each one will solve based on the whole skeleton's rest pose. This whole discussion points to doing more work to design a proper IK solver system in future 4.x releases. )

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