-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
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 Quaternion
arc constructor to check dot & Add test for same Vector3
s
#101797
Conversation
2ee22e1
to
650d019
Compare
Quaternion
arc constructor to check dot & Add test for same Vector3
s
650d019
to
e3f56fe
Compare
190f944
to
a6a3b8f
Compare
a6a3b8f
to
4bc2dc5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine for fixing the bug, although would be good to have someone else check with another set of eyes.
There's a few things that could be checked out if going to town for performance, but probably not necessary.
For instance you could evaluate whether checking both conditions with:
if (ABS(d) > ALMOST_ONE)
Made a difference. You could then do a second check for polarity.
The idea being ABS cheaper than a comparison. But that would require looking at assembly / profiles and I don't think it's necessary unless someone is super keen.
By the way, can confirm compiler uses two separate constants for the positive and negative, I checked the assembly.
I liked the unit test added for the error case. |
4bc2dc5
to
0ae5418
Compare
Adopted abs with comments on the second comparison. |
It was fine before, but the pattern I was suggesting is more:
This is thus using ABS and a single branch for most cases, instead of two branches. But this isn't really hugely important unless you've profiled the two in bottlenecks (the original could be faster for instance), and the math checks will likely dwarf this. Going to this level to make sensible decisions you would need to be looking at assembly and benchmarks, and I don't think this is warranted at this stage, so either the previous implementation you did (where we approved) or the above would be fine, there will likely be a hair's breadth between them. The optimizer may well do this from your current PR anyway, but in the current commit it is less clear what you are asking the compiler to do. |
0ae5418
to
27e2328
Compare
Thanks! |
We removed the dot check in the review for the performance, but did not consider the case of the same vector. So fix to add the dot check. Also, add a test for the same vectors.