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

Fixes #16480: Prevent exponential denormalization on Transform::rotate_axis #17604

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/bevy_transform/src/components/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ impl Transform {
#[inline]
pub fn rotate_axis(&mut self, axis: Dir3, angle: f32) {
self.rotate(Quat::from_axis_angle(axis.into(), angle));
// Normalize rotation due to potential for exponential denormalization (#16480)
self.rotation = self.rotation.normalize();
}

/// Rotates this [`Transform`] around the `X` axis by `angle` (in radians).
Expand Down Expand Up @@ -353,6 +355,8 @@ impl Transform {
#[inline]
pub fn rotate_local_axis(&mut self, axis: Dir3, angle: f32) {
self.rotate_local(Quat::from_axis_angle(axis.into(), angle));
// Normalize rotation due to potential for exponential denormalization (#16480)
self.rotation = self.rotation.normalize();
}

/// Rotates this [`Transform`] around its local `X` axis by `angle` (in radians).
Expand Down