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

IK is not deforming properly with some positions of target node #47803

Closed
wojtekpil opened this issue Apr 11, 2021 · 7 comments · Fixed by #48166
Closed

IK is not deforming properly with some positions of target node #47803

wojtekpil opened this issue Apr 11, 2021 · 7 comments · Fixed by #48166

Comments

@wojtekpil
Copy link
Contributor

wojtekpil commented Apr 11, 2021

Godot version:

Godot 3.x
7a9c14e

OS/device including version:

Linux, Elementary OS Hera / GTX1660Ti

Issue description:

Mesh between bones is twisted if target node is behind object. It seems to work properly in 3.2.4 rc4. All builds after this rc have some problems with mesh deformation.
Screenshot from 2021-04-11 18-58-40
Screenshot from 2021-04-11 19-00-38

Steps to reproduce:
Place IK target node behind model

Minimal reproduction project:

ik_experiments.zip

@akien-mga
Copy link
Member

CC @TwistedTwigleg

For the reference @wojtekpil tested latest 3.x which includes #47738 too (we debugged initially on Reddit).

@TwistedTwigleg
Copy link
Contributor

Looking at the project, it seems that it only occurs when the bone is past the half-way point and then the rotation is off by 180 degrees on the rotation axis the bone points in. From my experience, this generally occurs because one of the axes is negative relative to the bone (likely the X/Z in this case).
It also seems to only affect the root/first bone in this project, with the second and third being fine. Since it was happening prior to #47738 though, I do not think the solution there is the issue.

Looking at the 3D model itself, I think the issue is probably the bone's forward direction being -Z. This is the first time I've come across said bone forward direction in all my IK testing. I imported the .dae into Blender and exported it as a GLTF (which I have attached to this post) and using that makes everything work as expected.

Here's the GLTF file: StandardRun_GLTF_File.zip

Additionally, I tested the .dae and GLTF model in Twisted IK 2 and it has the same issue with the .dae model, despite Twisted IK 2 using a completely different solution for FABRIK than the one used in SkeletonIK. This furthers my belief that its the bone direction that is the issue and not the IK algorithm.

Also: I'm not sure why I was CC'ed here, as AndreaCatania wrote the code, I've only done a few tweaks to it. He would probably be better able to fix issues with the SkeletonIK node.

@akien-mga
Copy link
Member

Also: I'm not sure why I was CC'ed here, as AndreaCatania wrote the code, I've only done a few tweaks to it. He would probably be better able to fix issues with the SkeletonIK node.

Well I'm not an expert on this code, I mentioned the contributor who was most recently involved with changes to IK which could cause a regression. I'm also happy to CC @AndreaCatania if that's not related to your changes.

@TwistedTwigleg
Copy link
Contributor

Well I'm not an expert on this code, I mentioned the contributor who was most recently involved with changes to IK which could cause a regression. I'm also happy to CC @AndreaCatania if that's not related to your changes.

No worries, I'm not upset or anything. I was just wondering why I was CC'ed on it.

As I mentioned in my previous post, I do not think the issue is related to changes I made. It seems it was starting to occur after RC4, where the only change I had made was #40774. The only known bug from that change was the bone not being attached to animated skeletons. In #40774 I didn't change anything related to rotation, which seems to be the issue seen here.
#47738 does change root bone node rotation, but since it was occurring prior to this PR being merged, I am confident it is not the root of the issue.

I think the issue is related to the bone forward direction being -Z because using a GLTF file (with bone forward being Y+) seems to fix the issue. Why a -Z forward bone direction causes the issue is something I am unsure on though.

@wojtekpil
Copy link
Contributor Author

I am not sure if it this information can help, but all the models I tested were rigged with https://www.mixamo.com/ I think that this one was directly imported from website, and my second model from reddit post was generated using Godot Game Tools for Blender.

@akien-mga
Copy link
Member

I tested the latest version of #48251 and it does seem to fix this issue fully, to the best of my (limited) understanding. @wojtekpil Could you also try it out to confirm that it solves your issue? See #48251 (comment) to download a build artifact from that PR.

@akien-mga akien-mga modified the milestones: 3.3, 3.4 May 7, 2021
@wojtekpil
Copy link
Contributor Author

Hi @akien-mga, just tested the fix and everything seems to be working correctly! I had a bit of difficulty building this pull request from the sources but after cleaning it looks like everything is ok.

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.

4 participants