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

Fixed lerp of Transform2D which caused losing of skew #64418

Closed
wants to merge 2 commits into from

Conversation

bombzj
Copy link

@bombzj bombzj commented Aug 15, 2022

This PR fixes #64252. With this PR, the test project produces correct result of ((1, 0), (1, 1), (0, 0)),

@bombzj bombzj requested a review from a team as a code owner August 15, 2022 05:04
@aaronfranke
Copy link
Member

It would also be appreciated to add tests to the tests file located at tests/core/math/test_transform_2d.h.

@aaronfranke aaronfranke added this to the 4.0 milestone Aug 15, 2022
@bombzj bombzj requested a review from a team as a code owner August 15, 2022 05:49
@bombzj
Copy link
Author

bombzj commented Aug 16, 2022

It would also be appreciated to add tests to the tests file located at tests/core/math/test_transform_2d.h.

Unit test committed. Is there anything else required for this PR?

@deakcor
Copy link
Contributor

deakcor commented Jan 12, 2023

Tested, working perfectly, thank you.

before
image

after
image

@TokageItLab
Copy link
Member

This fix seems to still be needed, but I am not sure if deconstructing to scale/rot/skew and reconstructing Transform2D from that is the right way. There may be a possibility that the reconstruction may break the accuracy of the 2D Basis.

It may need to be clarified which accuracy should be prioritized. I remember Node3D separating the basis from the scale.

@reduz Do you have any ideas?

@aaronfranke
Copy link
Member

Upon closer investigation, the behavior in this PR is not correct. Test code:

Screenshot 2023-01-28 at 5 30 04 PM

The behavior in this PR:

godot.macos.editor.arm64.-.interp.DEBUG.-.28.January.2023.mp4

The correct behavior (will submit a PR shortly):

godot.macos.editor.arm64.-.interp.DEBUG.-.28.January.2023.1.mp4

The code for the correct behavior:

Screenshot 2023-01-28 at 5 46 11 PM

@TokageItLab but I am not sure if deconstructing to scale/rot/skew and reconstructing Transform2D from that is the right way. There may be a possibility that the reconstruction may break the accuracy of the 2D Basis.

We have to deconstruct and reconstruct in order to make this work with all of the edge cases. The simplest approach would be to slerp the Basis vectors, but this produces the same incorrect behavior as the first video.

@TokageItLab
Copy link
Member

@aaronfranke Can that be applied to Transform3D::interpolate_with?

Shear seems to be able to be extracted as shown in this article, so it might be worthwhile to reconstruct Transform3D using a same approach.

As far as I remember, Transform3D and Transform2D interpolate_with is only used in limited areas (Skeleton?). So accuracy issue like separating scales in Node3D, may not be a problem here.

@aaronfranke
Copy link
Member

aaronfranke commented Jan 29, 2023

@TokageItLab Right now we do not have any support for getting or setting skew/shear in Transform3D or Basis. If that is desired, it's a separate feature request.

For this issue/PR it makes sense to support skew in Transform2D interpolation since there is already support for getting and setting the skew in Transform2D.

@TokageItLab
Copy link
Member

TokageItLab commented Jan 29, 2023

@aaronfranke In Node3D, Skew is allowed (supported) if RotationMode is Basis. The axes and gizmo are not orthogonal, but its rotation with skew is definitely definable (since rotation by gizmo is performed correctly) and should be supported.
image

@aaronfranke
Copy link
Member

@TokageItLab Sure, but since there is no high-level decomposition of the skew from the matrix, we either need to add that first so that we can do the decomposition, or use a more complicated interpolation approach.

@TokageItLab
Copy link
Member

TokageItLab commented Jan 29, 2023

@aaronfranke Yes, I think we should. How do you think @reduz?

@akien-mga
Copy link
Member

Superseded by #72287.

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

Successfully merging this pull request may close these issues.

Interpolation of shearing Transform2D getting unintended results
5 participants