4646#if !(defined(_MSC_VER) && _MSC_VER < 1300)
4747#if defined(__has_include) && __has_include("gmath.h")
4848#include " gmath.h"
49- #define USE_DETERMINISTIC_MATH
5049#endif
5150#endif
5251
52+ #if !(defined(_MSC_VER) && _MSC_VER < 1300)
53+ #define USE_DETERMINISTIC_MATH
54+ #endif
55+
5356/*
5457** Some global constants.
5558*/
56- #define WWMATH_EPSILON 0 .0001f
57- #define WWMATH_EPSILON2 WWMATH_EPSILON * WWMATH_EPSILON
59+ #define WWMATH_EPSILON 0 .0001f
60+ #define WWMATH_EPSILON2 WWMATH_EPSILON * WWMATH_EPSILON
5861#define WWMATH_PI 3 .141592654f
59- #define WWMATH_TWO_PI 6 .283185308f
60- #define WWMATH_FLOAT_MAX (FLT_MAX)
61- #define WWMATH_FLOAT_MIN (FLT_MIN)
62- #define WWMATH_SQRT2 1 .414213562f
63- #define WWMATH_SQRT3 1 .732050808f
64- #define WWMATH_OOSQRT2 0 .707106781f
65- #define WWMATH_OOSQRT3 0 .577350269f
62+ #define WWMATH_TWO_PI 6 .283185308f
63+ #define WWMATH_FLOAT_MAX (FLT_MAX)
64+ #define WWMATH_FLOAT_MIN (FLT_MIN)
65+ #define WWMATH_SQRT2 1 .414213562f
66+ #define WWMATH_SQRT3 1 .732050808f
67+ #define WWMATH_OOSQRT2 0 .707106781f
68+ #define WWMATH_OOSQRT3 0 .577350269f
6669
6770/*
6871** Macros to convert between degrees and radians
@@ -168,6 +171,9 @@ static WWINLINE float Atan2(float y,float x) { return static_cast<float>(atan2(
168171
169172// Origin wrappers: replace bare CRT math calls in GameLogic.
170173// Each wrapper preserves the exact type (float vs double) of the vanilla CRT call.
174+ // Note: double overloads narrow to float before calling GameMath (gm_*f).
175+ // GameMath only provides float-precision functions. All call sites pass float-width
176+ // values, so the narrowing is lossless in practice.
171177#ifdef USE_DETERMINISTIC_MATH
172178 static WWINLINE double SqrtOrigin (double x) { return (double )gm_sqrtf ((float )x); }
173179 static WWINLINE float SqrtfOrigin (float x) { return gm_sqrtf (x); }
@@ -189,6 +195,10 @@ static WWINLINE float Atan2(float y,float x) { return static_cast<float>(atan2(
189195 static WWINLINE float CeilfOrigin (float x) { return gm_ceilf (x); }
190196 static WWINLINE float ExpfOrigin (float x) { return gm_expf (x); }
191197 static WWINLINE float Log10fOrigin (float x) { return gm_log10f (x); }
198+ static WWINLINE float LogfOrigin (float x) { return gm_logf (x); }
199+ static WWINLINE float SinhfOrigin (float x) { return gm_sinhf (x); }
200+ static WWINLINE float CoshfOrigin (float x) { return gm_coshf (x); }
201+ static WWINLINE float TanhfOrigin (float x) { return gm_tanhf (x); }
192202#else
193203 static WWINLINE double SqrtOrigin (double x) { return sqrt (x); }
194204 static WWINLINE float SqrtfOrigin (float x) { return sqrtf (x); }
@@ -210,6 +220,10 @@ static WWINLINE float Atan2(float y,float x) { return static_cast<float>(atan2(
210220 static WWINLINE float CeilfOrigin (float x) { return ceilf (x); }
211221 static WWINLINE float ExpfOrigin (float x) { return expf (x); }
212222 static WWINLINE float Log10fOrigin (float x) { return log10f (x); }
223+ static WWINLINE float LogfOrigin (float x) { return logf (x); }
224+ static WWINLINE float SinhfOrigin (float x) { return sinhf (x); }
225+ static WWINLINE float CoshfOrigin (float x) { return coshf (x); }
226+ static WWINLINE float TanhfOrigin (float x) { return tanhf (x); }
213227#endif
214228static WWINLINE float Sign (float val);
215229static WWINLINE float Ceil (float val) { return ceilf (val); }
0 commit comments