Repository navigation
[raymath] Fix MatrixCompose() rotating vectors with already overwritten components - #6187
Merged
Merged
Conversation
Owner
|
@ethanstoner oh! good catch! thanks for the review! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#6133 inlined
Vector3RotateByQuaternion()intoMatrixCompose(), but the inlined version writes each component in place and the next line reads it back:Vector3RotateByQuaternion()writes to a separateresult, so it never had this problem. Most rotations now give a wrong matrix (a 180 degree turn about the X, Y or Z axis happens to come out right). With a 90 degree rotation about Z, the first column comes out all zeros.This keeps a copy of each vector (
temp) and reads from it, so the formulas are the same onesVector3RotateByQuaternion()uses.Test, comparing against scale, then rotation, then translation built from existing raymath functions:
Before (master):
After:
The "after" numbers match what
MatrixCompose()returned before #6133. raymath has no automated tests, so I checked this with the standalone program above (built as both C99 and C++), and I rebuilt the library and a few models examples on Linux with gcc. On Windows the program also builds with MinGW gcc and MSVC and gives the same numbers.