13#ifndef SCRIPTS_INCLUDE__ENGINE_MATH_H
14#define SCRIPTS_INCLUDE__ENGINE_MATH_H
16#define RAD2DEG(rad) ((rad) / WWMATH_PI * 180)
17#define DEG2RAD(deg) ((deg) / 180.f * WWMATH_PI)
18#define divideRoundUp(x, y) (((x) + (y) - 1) / (y))
22inline unsigned long F2DW(
float f)
24 return *((
unsigned long*)&f);
27inline unsigned long F2DW(
float* f)
29 return *((
unsigned long*)f);
32template<
typename T>
inline T sqr(T value)
37template<
typename T>
inline T clamp(T value, T min, T max)
48template<
typename T>
inline T wrap(T value, T min, T max)
50 return (max - min) % (value - min) + min;
53template<>
inline float wrap<float>(
float value,
float min,
float max)
55 return fmod(max - min, value - min) + min;
60template<
typename T>
inline T lerp(T a, T b,
float fraction)
62 return a + (T)((b - a) * fraction);
67inline bool isPowerOfTwo(
int number)
69 return number != 0 && ((number - 1) & number) == 0;
74inline uint GetColorUInt(
int a,
int r,
int g,
int b)
76 return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
79inline float sgn(
float x)
81 return (x < 0.0f) ? -1.0f : 1.0f;
84int SCRIPTS_API Find_POT_LT(
int i);
93Vector3 rayPlaneIntersect(
const Vector3& rayDirection,
const Vector3& planeOrigin);
102Vector3 rayPlaneIntersect(
const Vector3& rayDirection,
const Vector3& planeNormal,
const float planeDistance);