summaryrefslogtreecommitdiff
path: root/inc/shared/shared.h
diff options
context:
space:
mode:
Diffstat (limited to 'inc/shared/shared.h')
-rw-r--r--inc/shared/shared.h117
1 files changed, 1 insertions, 116 deletions
diff --git a/inc/shared/shared.h b/inc/shared/shared.h
index 372c792..d6633b2 100644
--- a/inc/shared/shared.h
+++ b/inc/shared/shared.h
@@ -43,6 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#endif
#include "shared/platform.h"
+#include "shared/matrix.h"
#define q_countof(a) (sizeof(a) / sizeof(a[0]))
@@ -131,14 +132,6 @@ MATHLIB
==============================================================
*/
-typedef float vec_t;
-typedef vec_t vec2_t[2];
-typedef vec_t vec3_t[3];
-typedef vec_t vec4_t[4];
-typedef vec_t vec5_t[5];
-
-typedef float mat4_t[16];
-
typedef union {
uint32_t u32;
uint8_t u8[4];
@@ -181,119 +174,11 @@ static inline float Q_fabs(float f)
#define DEG2RAD(a) (a * M_PI) / 180.0F
-#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
-#define CrossProduct(v1,v2,cross) \
- ((cross)[0]=(v1)[1]*(v2)[2]-(v1)[2]*(v2)[1], \
- (cross)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2], \
- (cross)[2]=(v1)[0]*(v2)[1]-(v1)[1]*(v2)[0])
-#define VectorSubtract(a,b,c) \
- ((c)[0]=(a)[0]-(b)[0], \
- (c)[1]=(a)[1]-(b)[1], \
- (c)[2]=(a)[2]-(b)[2])
-#define VectorAdd(a,b,c) \
- ((c)[0]=(a)[0]+(b)[0], \
- (c)[1]=(a)[1]+(b)[1], \
- (c)[2]=(a)[2]+(b)[2])
-#define VectorAdd3(a,b,c,d) \
- ((d)[0]=(a)[0]+(b)[0]+(c)[0], \
- (d)[1]=(a)[1]+(b)[1]+(c)[1], \
- (d)[2]=(a)[2]+(b)[2]+(c)[2])
-#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
-#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)
-#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
-#define VectorInverse(a) ((a)[0]=-(a)[0],(a)[1]=-(a)[1],(a)[2]=-(a)[2])
-#define VectorSet(v, x, y, z) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z))
-#define VectorAvg(a,b,c) \
- ((c)[0]=((a)[0]+(b)[0])*0.5f, \
- (c)[1]=((a)[1]+(b)[1])*0.5f, \
- (c)[2]=((a)[2]+(b)[2])*0.5f)
-#define VectorMA(a,b,c,d) \
- ((d)[0]=(a)[0]+(b)*(c)[0], \
- (d)[1]=(a)[1]+(b)*(c)[1], \
- (d)[2]=(a)[2]+(b)*(c)[2])
-#define VectorVectorMA(a,b,c,d) \
- ((d)[0]=(a)[0]+(b)[0]*(c)[0], \
- (d)[1]=(a)[1]+(b)[1]*(c)[1], \
- (d)[2]=(a)[2]+(b)[2]*(c)[2])
-#define VectorEmpty(v) ((v)[0]==0&&(v)[1]==0&&(v)[2]==0)
-#define VectorCompare(v1,v2) ((v1)[0]==(v2)[0]&&(v1)[1]==(v2)[1]&&(v1)[2]==(v2)[2])
-#define VectorLength(v) (sqrt(DotProduct((v),(v))))
-#define VectorLengthSquared(v) (DotProduct((v),(v)))
-#define VectorScale(in,scale,out) \
- ((out)[0]=(in)[0]*(scale), \
- (out)[1]=(in)[1]*(scale), \
- (out)[2]=(in)[2]*(scale))
-#define VectorVectorScale(in,scale,out) \
- ((out)[0]=(in)[0]*(scale)[0], \
- (out)[1]=(in)[1]*(scale)[1], \
- (out)[2]=(in)[2]*(scale)[2])
-#define DistanceSquared(v1,v2) \
- (((v1)[0]-(v2)[0])*((v1)[0]-(v2)[0])+ \
- ((v1)[1]-(v2)[1])*((v1)[1]-(v2)[1])+ \
- ((v1)[2]-(v2)[2])*((v1)[2]-(v2)[2]))
-#define Distance(v1,v2) (sqrt(DistanceSquared(v1,v2)))
-#define LerpAngles(a,b,c,d) \
- ((d)[0]=LerpAngle((a)[0],(b)[0],c), \
- (d)[1]=LerpAngle((a)[1],(b)[1],c), \
- (d)[2]=LerpAngle((a)[2],(b)[2],c))
-#define LerpVector(a,b,c,d) \
- ((d)[0]=(a)[0]+(c)*((b)[0]-(a)[0]), \
- (d)[1]=(a)[1]+(c)*((b)[1]-(a)[1]), \
- (d)[2]=(a)[2]+(c)*((b)[2]-(a)[2]))
-#define LerpVector2(a,b,c,d,e) \
- ((e)[0]=(a)[0]*(c)+(b)[0]*(d), \
- (e)[1]=(a)[1]*(c)+(b)[1]*(d), \
- (e)[2]=(a)[2]*(c)+(b)[2]*(d))
-#define PlaneDiff(v,p) (DotProduct(v,(p)->normal)-(p)->dist)
-
-#define Vector4Subtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3])
-#define Vector4Add(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3])
-#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
-#define Vector4Clear(a) ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0)
-#define Vector4Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2],(b)[3]=-(a)[3])
-#define Vector4Set(v, a, b, c, d) ((v)[0]=(a),(v)[1]=(b),(v)[2]=(c),(v)[3]=(d))
-
-void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
-vec_t VectorNormalize(vec3_t v); // returns vector length
-vec_t VectorNormalize2(vec3_t v, vec3_t out);
void ClearBounds(vec3_t mins, vec3_t maxs);
void AddPointToBounds(const vec3_t v, vec3_t mins, vec3_t maxs);
vec_t RadiusFromBounds(const vec3_t mins, const vec3_t maxs);
void UnionBounds(vec3_t a[2], vec3_t b[2], vec3_t c[2]);
-static inline void AnglesToAxis(vec3_t angles, vec3_t axis[3])
-{
- AngleVectors(angles, axis[0], axis[1], axis[2]);
- VectorInverse(axis[1]);
-}
-
-static inline void TransposeAxis(vec3_t axis[3])
-{
- vec_t temp;
-
- temp = axis[0][1];
- axis[0][1] = axis[1][0];
- axis[1][0] = temp;
-
- temp = axis[0][2];
- axis[0][2] = axis[2][0];
- axis[2][0] = temp;
-
- temp = axis[1][2];
- axis[1][2] = axis[2][1];
- axis[2][1] = temp;
-}
-
-static inline void RotatePoint(vec3_t point, vec3_t axis[3])
-{
- vec3_t temp;
-
- VectorCopy(point, temp);
- point[0] = DotProduct(temp, axis[0]);
- point[1] = DotProduct(temp, axis[1]);
- point[2] = DotProduct(temp, axis[2]);
-}
-
static inline unsigned npot32(unsigned k)
{
if (k == 0)