From f03b4eec4c37eab75a5bd639279cfcc615105b01 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 23 Apr 2020 22:25:18 +0200 Subject: implemented skinned peds, no cutscene hands yet --- src/math/Quaternion.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/math') diff --git a/src/math/Quaternion.h b/src/math/Quaternion.h index fb37dc10..1d04bdff 100644 --- a/src/math/Quaternion.h +++ b/src/math/Quaternion.h @@ -10,6 +10,18 @@ public: float Magnitude(void) const { return Sqrt(x*x + y*y + z*z + w*w); } float MagnitudeSqr(void) const { return x*x + y*y + z*z + w*w; } + void Normalise(void) { + float sq = MagnitudeSqr(); + if(sq == 0.0f) + w = 1.0f; + else{ + float invsqrt = RecipSqrt(sq); + x *= invsqrt; + y *= invsqrt; + z *= invsqrt; + w *= invsqrt; + } + } const CQuaternion &operator+=(CQuaternion const &right) { x += right.x; -- cgit v1.2.3