Skip to content

Commit 6084270

Browse files
committed
One more little fix with an updated GamepadMotionHelpers for more responsive tiny adjustments on quaternions.
1 parent b8ed74c commit 6084270

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

JoyShockLibrary/GamepadMotion.hpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,22 +318,14 @@ namespace GamepadMotionHelpers
318318

319319
inline void Quat::Normalize()
320320
{
321-
//printf("Normalizing: %.4f, %.4f, %.4f, %.4f\n", w, x, y, z);
322-
const float length = sqrtf(x * x + y * y + z * z);
323-
float targetLength = 1.0f - w * w;
324-
if (targetLength <= 0.0f || length <= 0.0f)
325-
{
326-
Set(1.0f, 0.0f, 0.0f, 0.0f);
327-
return;
328-
}
329-
targetLength = sqrtf(targetLength);
330-
const float fixFactor = targetLength / length;
321+
const float length = sqrtf(w * w + x * x + y * y + z * z);
322+
const float fixFactor = 1.0f / length;
331323

324+
w *= fixFactor;
332325
x *= fixFactor;
333326
y *= fixFactor;
334327
z *= fixFactor;
335328

336-
//printf("Normalized: %.4f, %.4f, %.4f, %.4f\n", w, x, y, z);
337329
return;
338330
}
339331

0 commit comments

Comments
 (0)