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 CMatrix<T>::getScale returning negative scale #15687

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

appgurueu
Copy link
Contributor

@appgurueu appgurueu commented Jan 16, 2025

CMatrix<T>::getScale could previously, due to an "optimization" of dubious value, return negative values straight from the diagonal. This fixes that and simplifies the implementation a bit, removing the "optimization" entirely. (We could also std::abs it, but I don't see much of a point in that.)

After this fix, getting matrix rotations is a bit simpler, and a workaround which was only needed because we blindly shoveled a possibly negative scale into bone scene nodes (and thus had a rotation which didn't match that) can go.

There will be follow-up PRs.

To do

This PR is Ready for Review.

How to test

Play a bit with 3rd person with mods such as headanim that trigger the EJUOR_CONTROL code path, check that the bug the workaround fixed isn't back.

(As for how I conjecture the workaround ever worked to begin with: I believe the recalculation might create an error large enough that the flawed optimization doesn't trigger anymore.)

Copy link
Collaborator

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

lgtm i guess

@sfan5 sfan5 merged commit 8719a81 into luanti-org:master Jan 17, 2025
16 checks passed
@appgurueu appgurueu deleted the fix-scale branch January 18, 2025 00:15
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.

2 participants