From 370354f1de1b1539a041e97db80ceb5c171b8e65 Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Wed, 27 Dec 2023 23:57:59 +0200 Subject: [PATCH] Fix rotation change check in integrator (#284) # Objective In #272, the integrator was changed to update rotation only if `delta.w != 0.0`. However, in some cases, x, y, or z can be non-zero even if w is zero, like with `AngularVelocity(Vec3::X)`, and in those cases the rotation would incorrectly be ignored. ## Solution Make the condition stricter by also checking if x, y, and z are 0. Based on a quick test, this should also keep change detection working, which is what #272 was trying to address. --- src/plugins/integrator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/integrator.rs b/src/plugins/integrator.rs index 5d789ac5..fc55aeb5 100644 --- a/src/plugins/integrator.rs +++ b/src/plugins/integrator.rs @@ -228,7 +228,7 @@ fn integrate_rot(mut bodies: Query>, .extend(delta_secs * 0.5 * q.w); // avoid triggering bevy's change detection unnecessarily let delta = Quaternion::from_vec4(effective_dq); - if delta.w != 0.0 { + if delta != Quaternion::from_xyzw(0.0, 0.0, 0.0, 0.0) { rot.0 = (rot.0 + delta).normalize(); } }