-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fixes #16480: Prevent exponential denormalization on Transform::rotate_axis
#17604
base: main
Are you sure you want to change the base?
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
@@ -314,7 +314,7 @@ impl Transform { | |||
/// If this [`Transform`] has a parent, the `axis` is relative to the rotation of the parent. | |||
#[inline] | |||
pub fn rotate_axis(&mut self, axis: Dir3, angle: f32) { | |||
self.rotate(Quat::from_axis_angle(axis.into(), angle)); | |||
self.rotation = ((Quat::from_axis_angle(axis.into(), angle)) * self.rotation).normalize(); |
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.
Link the issue here in a comment please; this normalization looks out of place otherwise.
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.
Done! Is it fine like this or should I add the full link?
0f2a51d
to
a4a1078
Compare
…form::rotate_axis`
a4a1078
to
e23fe5f
Compare
Objective
Fixes #16480
When repeatedly using
Transform::roatate_axis
and feeding aaxis
that is based on the currentTransform::rotation
, the floating point errors could accumulate exponentially, resulting in denormalized rotation, which panics.Solution
Normalize the quaternion in
Transform::rotate_axis
.Testing
I confirmed that this fixes the issue reported in #16480.