Fix CMatrix<T>::getScale returning negative scale #15687
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 alsostd::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.)