Fix panic on Transform::lerp due to rotation not being normalized

This commit is contained in:
SeanOMik 2023-12-26 14:21:53 -05:00
parent 2805399fe4
commit 0a0ac0ae6f
Signed by: SeanOMik
GPG Key ID: FEC9E2FC15235964
1 changed files with 3 additions and 2 deletions

View File

@ -71,7 +71,7 @@ impl Transform {
/// Rotate this transform using a Quaternion
pub fn rotate(&mut self, rotation: Quat) {
self.rotation = rotation * self.rotation;
self.rotation = (rotation * self.rotation).normalize();
}
pub fn rotate_x(&mut self, angle: Angle) {
@ -96,7 +96,8 @@ impl Transform {
if alpha.is_finite() {
let mut res = self.clone();
res.translation = self.translation.lerp(rhs.translation, alpha);
res.rotation = self.rotation.lerp(rhs.rotation, alpha);
// normalize rotation here to avoid panics
res.rotation = self.rotation.lerp(rhs.rotation.normalize(), alpha);
res.scale = self.scale.lerp(rhs.scale, alpha);
res
} else {