1313*
1414****/
1515// mathlib.h
16-
16+ #pragma once
17+ #ifndef MATHLIB_H
18+ #define MATHLIB_H
1719#include <math.h>
1820
1921typedef float vec_t ;
20- # ifndef vec3_t
22+ typedef vec_t vec2_t [ 2 ];
2123typedef vec_t vec3_t [3 ];
22- #endif
2324typedef vec_t vec4_t [4 ]; // x,y,z,w
24- typedef vec_t vec5_t [5 ];
25-
26- typedef short vec_s_t ;
27- typedef vec_s_t vec3s_t [3 ];
28- typedef vec_s_t vec4s_t [4 ]; // x,y,z,w
29- typedef vec_s_t vec5s_t [5 ];
3025
31- typedef int fixed4_t ;
32- typedef int fixed8_t ;
33- typedef int fixed16_t ;
3426#ifndef M_PI
3527#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
3628#endif
3729
38- #ifdef __cplusplus
39- # ifdef min
40- # undef min
41- # endif
42-
43- # ifdef max
44- # undef max
45- # endif
46-
47- # ifdef clamp
48- # undef clamp
49- # endif
50- #endif
51-
5230struct mplane_s ;
5331
54- #if defined(CLIENT_DLL)
55- namespace cl {
56- #elif defined(SERVER_DLL)
57- namespace sv {
58- #elif defined(__cplusplus)
59- extern " C++" {
60- #endif
61-
62- extern vec3_t vec3_origin;
63- extern int nanmask;
32+ extern vec3_t vec3_origin ;
33+ extern int nanmask ;
6434
6535#define IS_NAN (x ) (((*(int *)&x)&nanmask)==nanmask)
6636
@@ -73,64 +43,42 @@ extern "C++" {
7343#define VectorCopy (a ,b ) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
7444#define VectorClear (a ) {(a)[0]=0.0;(a)[1]=0.0;(a)[2]=0.0;}
7545
76- void VectorMA (const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc);
77-
78- vec_t _DotProduct (vec3_t v1, vec3_t v2);
79- void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
80- void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
81- void _VectorCopy (vec3_t in, vec3_t out);
46+ void VectorMA (const vec3_t veca , float scale , const vec3_t vecb , vec3_t vecc );
8247
83- int VectorCompare (const vec3_t v1, const vec3_t v2);
84- float Length (const vec3_t v);
85- void CrossProduct (const vec3_t v1, const vec3_t v2, vec3_t cross);
86- float VectorNormalize (vec3_t v); // returns vector length
87- void VectorInverse (vec3_t v);
88- void VectorScale (const vec3_t in, vec_t scale, vec3_t out);
89- int Q_log2 (int val);
48+ vec_t _DotProduct (vec3_t v1 , vec3_t v2 );
49+ void _VectorSubtract (vec3_t veca , vec3_t vecb , vec3_t out );
50+ void _VectorAdd (vec3_t veca , vec3_t vecb , vec3_t out );
51+ void _VectorCopy (vec3_t in , vec3_t out );
9052
91- void R_ConcatRotations (float in1[3 ][3 ], float in2[3 ][3 ], float out[3 ][3 ]);
92- void R_ConcatTransforms (float in1[3 ][4 ], float in2[3 ][4 ], float out[3 ][4 ]);
53+ int VectorCompare (const vec3_t v1 , const vec3_t v2 );
54+ float Length (const vec3_t v );
55+ void CrossProduct (const vec3_t v1 , const vec3_t v2 , vec3_t cross );
56+ float VectorNormalize (vec3_t v ); // returns vector length
57+ void VectorInverse (vec3_t v );
58+ void VectorScale (const vec3_t in , vec_t scale , vec3_t out );
9359
94- // Here are some "manual" INLINE routines for doing floating point to integer conversions
95- extern short new_cw, old_cw ;
60+ void R_ConcatRotations ( float in1 [ 3 ][ 3 ], float in2 [ 3 ][ 3 ], float out [ 3 ][ 3 ]);
61+ void R_ConcatTransforms ( float in1 [ 3 ][ 4 ], float in2 [ 3 ][ 4 ], float out [ 3 ][ 4 ]) ;
9662
97- typedef union DLONG {
98- int i[2 ];
99- double d;
100- float f;
101- } DLONG;
102-
103- extern DLONG dlong;
104-
105-
106-
107- void FloorDivMod (double numer, double denom, int *quotient,
108- int *rem);
109- fixed16_t Invert24To16 (fixed16_t val);
110- int GreatestCommonDivisor (int i1, int i2);
111-
112- void AngleVectors (const float *angles, float *forward, float *right, float *up);
113- void AngleVectorsTranspose (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
63+ void AngleVectors (const vec3_t angles , vec3_t forward , vec3_t right , vec3_t up );
64+ void AngleVectorsTranspose (const vec3_t angles , vec3_t forward , vec3_t right , vec3_t up );
11465#define AngleIVectors AngleVectorsTranspose
11566
116- void AngleMatrix (const float * angles, float (*matrix)[4]);
117- void AngleIMatrix (const vec3_t angles, float (*matrix)[4]);
118- void VectorTransform (const vec_t * in1, float (* in2)[ 4], vec_t * out);
67+ void AngleMatrix (const vec3_t angles , float (* matrix )[4 ] );
68+ void AngleIMatrix (const vec3_t angles , float (* matrix )[4 ] );
69+ void VectorTransform (const vec3_t in1 , float in2 [ 3 ][ 4 ], vec3_t out );
11970
120- void NormalizeAngles (vec3_t angles);
121- void InterpolateAngles (vec3_t start, vec3_t end, vec3_t output, float frac);
122- float AngleBetweenVectors (const vec3_t v1, const vec3_t v2);
71+ void NormalizeAngles ( vec3_t angles );
72+ void InterpolateAngles ( vec3_t start , vec3_t end , vec3_t output , float frac );
73+ float AngleBetweenVectors ( const vec3_t v1 , const vec3_t v2 );
12374
75+ void VectorMatrix ( vec3_t forward , vec3_t right , vec3_t up );
76+ void VectorAngles ( const vec3_t forward , vec3_t angles );
12477
125- void VectorMatrix (vec3_t forward, vec3_t right, vec3_t up);
126- void VectorAngles (const vec3_t forward, vec3_t angles);
127-
128- int InvertMatrix (const float * m, float *out);
129-
130- int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
131- float anglemod (float a);
132-
78+ int InvertMatrix ( const float * m , float * out );
13379
80+ int BoxOnPlaneSide (vec3_t emins , vec3_t emaxs , struct mplane_s * plane );
81+ float anglemod (float a );
13482
13583#define BOX_ON_PLANE_SIDE (emins , emaxs , p ) \
13684 (((p)->type < 3)? \
@@ -147,7 +95,4 @@ extern "C++" {
14795 ) \
14896 : \
14997 BoxOnPlaneSide( (emins), (emaxs), (p)))
150-
151- #ifdef __cplusplus
152- }
153- #endif
98+ #endif // MATHLIB_H
0 commit comments