summaryrefslogtreecommitdiff
path: root/core/math/math_funcs.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/math_funcs.h')
-rw-r--r--core/math/math_funcs.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h
index 078320d620..f96d3a909f 100644
--- a/core/math/math_funcs.h
+++ b/core/math/math_funcs.h
@@ -74,11 +74,13 @@ public:
static _ALWAYS_INLINE_ double tanh(double p_x) { return ::tanh(p_x); }
static _ALWAYS_INLINE_ float tanh(float p_x) { return ::tanhf(p_x); }
- static _ALWAYS_INLINE_ double asin(double p_x) { return ::asin(p_x); }
- static _ALWAYS_INLINE_ float asin(float p_x) { return ::asinf(p_x); }
+ // Always does clamping so always safe to use.
+ static _ALWAYS_INLINE_ double asin(double p_x) { return p_x < -1 ? (-Math_PI / 2) : (p_x > 1 ? (Math_PI / 2) : ::asin(p_x)); }
+ static _ALWAYS_INLINE_ float asin(float p_x) { return p_x < -1 ? (-Math_PI / 2) : (p_x > 1 ? (Math_PI / 2) : ::asinf(p_x)); }
- static _ALWAYS_INLINE_ double acos(double p_x) { return ::acos(p_x); }
- static _ALWAYS_INLINE_ float acos(float p_x) { return ::acosf(p_x); }
+ // Always does clamping so always safe to use.
+ static _ALWAYS_INLINE_ double acos(double p_x) { return p_x < -1 ? Math_PI : (p_x > 1 ? 0 : ::acos(p_x)); }
+ static _ALWAYS_INLINE_ float acos(float p_x) { return p_x < -1 ? Math_PI : (p_x > 1 ? 0 : ::acosf(p_x)); }
static _ALWAYS_INLINE_ double atan(double p_x) { return ::atan(p_x); }
static _ALWAYS_INLINE_ float atan(float p_x) { return ::atanf(p_x); }