gwnavruntime/math/fastmath.h Source File
Go to the documentation of this file.
9 #ifndef Navigation_FastMath_H
10 #define Navigation_FastMath_H
15 #if defined(KY_OS_XBOX360)
16 #include <ppcintrinsics.h>
20 #if defined(KY_OS_PS3)
21 #include <ppu_intrinsics.h>
35 #if defined(KY_OS_XBOX360)
42 #elif defined(KY_OS_PS3)
45 return __fsels(cmp, v1, v2);
49 #elif defined(KY_OS_WII)
60 return cmp >= 0.0f ? v1 : v2;
75 const KyInt32 signMask = a >> 31;
76 return x + ((y - x) & signMask);
85 const KyInt64 signMask = a >> 63;
86 return x + ((y - x) & signMask);
94 T Sel(T cmp, T v1, T v2);
113 KY_INLINE T
Min(
const T& a,
const T& b)
115 return (a < b) ? a : b;
121 KY_INLINE T
Max(
const T& a,
const T& b)
123 return (a < b) ? b : a;
128 template <
typename T>
129 KY_INLINE T
Min(
const T& a,
const T& b,
const T& c)
136 template <
typename T>
137 KY_INLINE T
Max(
const T& a,
const T& b,
const T& c)
144 #if defined(KY_OS_XBOX360) || defined(KY_OS_PS3) || defined(KY_OS_WII)
149 return Fsel(a - b, b, a);
155 return Fsel(a - b, a, b);
164 return Isel(a - b, b, a);
170 return Isel(a - b, a, b);
176 return Lsel(a - b, b, a);
182 return Lsel(a - b, a, b);
188 return (i * 0x0000AAAB) >> 17;
194 return i - 3 * FastDivisionBy3(i);
198 template <
typename T1,
typename T2 = T1>
202 KY_INLINE
bool operator()(
const T1& lhs,
const T2& rhs)
const {
return lhs < rhs; }
240 return acosf(normalizeDotProd);
250 return cosf(angleRad);
255 return sinf(angleRad);
KyInt32 Isel(KyInt32 a, KyInt32 x, KyInt32 y)
If a is greater than 0, returns x. Otherwise, returns y.
Definition: fastmath.h:70
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
T Min(const T &a, const T &b)
Returns the lesser of the two specified values.
Definition: fastmath.h:113
T Max(const T &a, const T &b)
Returns the greater of the two specified values.
Definition: fastmath.h:121
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
__int64 KyInt64
Type used internally to represent a 64-bit integer.
Definition: types.h:37
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
KyFloat32 Fsel(KyFloat32 cmp, KyFloat32 v1, KyFloat32 v2)
Ifcmp is greater than 0, returnsv1. Otherwise, returnsv2.
Definition: fastmath.h:58
KyInt64 Lsel(KyInt64 a, KyInt64 x, KyInt64 y)
If a is greater than 0, returns x. Otherwise, returns y.
Definition: fastmath.h:80