mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-23 02:42:38 +01:00
0f54517d69
- add StorePingInfo function - clean some FELONY.C code
83 lines
1.9 KiB
C
83 lines
1.9 KiB
C
#ifndef DR2MATH_H
|
|
#define DR2MATH_H
|
|
|
|
#include "ABS.H"
|
|
|
|
// Driver 2 math definitions
|
|
|
|
#define ONE 4096
|
|
#define ONE_BITS 12
|
|
|
|
#define PH_ONE 256
|
|
#define PH_ONE_BITS 8
|
|
|
|
// math constants
|
|
#if 0
|
|
|
|
// DO NOT USE IT unless you don't care about replays and chases
|
|
#define FIXED(a) (int(a) / ONE)
|
|
#define HFIXED(a) (int(a) / (ONE*2))
|
|
#define PH_FIXED(a) (int(a) / (PH_ONE))
|
|
|
|
#else
|
|
|
|
#define FixHalfRound(x, bits) (((x) + (1 << (bits-1))) >> bits)
|
|
#define FixFloorSigned(x, bits) ((x) / (1 << bits)) // in disassembly: ((int(x) < 0 ? int(x) + (1 << bits)-1 : int(x)) >> bits)
|
|
|
|
#define FIXEDH(a) FixHalfRound(a, ONE_BITS) // Fixed Half Round number
|
|
#define FIXED(a) ((a) >> ONE_BITS) // Fixed number (unsigned)
|
|
|
|
#endif
|
|
|
|
#define SetVec(_v, _x, _y, _z) \
|
|
{ \
|
|
(_v)->vx = _x; \
|
|
(_v)->vy = _y; \
|
|
(_v)->vz = _z; \
|
|
}
|
|
|
|
#define VecAdd(vecOut, vecLeft, vecRight) \
|
|
{ \
|
|
(vecOut)->vx = (vecLeft)->vx + (vecRight)->vx; \
|
|
(vecOut)->vy = (vecLeft)->vy + (vecRight)->vy; \
|
|
(vecOut)->vz = (vecLeft)->vz + (vecRight)->vz; \
|
|
}
|
|
|
|
#define VecSubtract(vecOut, vecLeft, vecRight) \
|
|
{ \
|
|
(vecOut)->vx = (vecLeft)->vx - (vecRight)->vx; \
|
|
(vecOut)->vy = (vecLeft)->vy - (vecRight)->vy; \
|
|
(vecOut)->vz = (vecLeft)->vz - (vecRight)->vz; \
|
|
}
|
|
|
|
#define VecAddEq(vecLeft, vecRight) \
|
|
{ \
|
|
(vecLeft)->vx += (vecRight)->vz; \
|
|
(vecLeft)->vy += (vecRight)->vy; \
|
|
(vecLeft)->vz += (vecRight)->vz; \
|
|
}
|
|
|
|
#define VecSubtractEq(vecLeft, vecRight) \
|
|
{ \
|
|
(vecLeft)->vx -= (vecRight)->vx; \
|
|
(vecLeft)->vy -= (vecRight)->vy; \
|
|
(vecLeft)->vz -= (vecRight)->vz; \
|
|
}
|
|
|
|
#define VecDivEq(vecLeft, vecRight) \
|
|
{ \
|
|
(vecLeft)->vx /= (vecRight)->vz; \
|
|
(vecLeft)->vy /= (vecRight)->vy; \
|
|
(vecLeft)->vz /= (vecRight)->vz; \
|
|
}
|
|
|
|
#define VecMulEq(vecLeft, vecRight) \
|
|
{ \
|
|
(vecLeft)->vx *= (vecRight)->vx; \
|
|
(vecLeft)->vy *= (vecRight)->vy; \
|
|
(vecLeft)->vz *= (vecRight)->vz; \
|
|
}
|
|
|
|
#define numberOf(sexToys) (sizeof(sexToys) / sizeof(sexToys[0]))
|
|
|
|
#endif // DR2MATH_H
|