From 4772db0b12cd0660032e1fd1f6f37c68846ba256 Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Thu, 23 May 2024 21:14:31 +0200 Subject: [PATCH] unhardcoded PI related constants in util.qc one digit in hardcoded constant was off, change causes no actual difference when using single or double precision floats --- qcsrc/common/util.qc | 4 ++-- qcsrc/lib/warpzone/mathlib.qh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index ca120d295..fca4c32f6 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -457,8 +457,8 @@ vector decompressShortVector(int data) } else { - q = .19634954084936207740 * q; - p = .19634954084936207740 * p - 1.57079632679489661922; + q = M_PI_16 * q; + p = M_PI_16 * p - M_PI_2; out.x = cos(q) * cos(p); out.y = sin(q) * cos(p); out.z = -sin(p); diff --git a/qcsrc/lib/warpzone/mathlib.qh b/qcsrc/lib/warpzone/mathlib.qh index f5d8f63e7..11517d909 100644 --- a/qcsrc/lib/warpzone/mathlib.qh +++ b/qcsrc/lib/warpzone/mathlib.qh @@ -108,6 +108,7 @@ const float M_LN10 = 2.30258509299404568402; /* log_e 10 */ #define M_PI 3.14159265358979323846 /* pi */ const float M_PI_2 = 1.57079632679489661923; /* pi/2 */ const float M_PI_4 = 0.78539816339744830962; /* pi/4 */ +const float M_PI_16 = 0.19634954084936207740; /* pi/16 */ const float M_1_PI = 0.31830988618379067154; /* 1/pi */ const float M_2_PI = 0.63661977236758134308; /* 2/pi */ const float M_2_SQRTPI = 1.12837916709551257390; /* 2/sqrt(pi) */ -- 2.39.2