]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - mathlib.h
whitespace
[xonotic/darkplaces.git] / mathlib.h
index fecf4eadb5d2a6e1252b513965296ad5e74603b8..cffbbbc88b8f9f3c3a511dd5664f8b95a54c6b6d 100644 (file)
--- a/mathlib.h
+++ b/mathlib.h
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #ifndef MATHLIB_H
 #define MATHLIB_H
 
+#include "qtypes.h"
+
 #ifndef M_PI
 #define M_PI           3.14159265358979323846  // matches value in gcc v2 math.h
 #endif
@@ -40,11 +42,11 @@ extern vec3_t vec3_origin;
 #define nanmask (255<<23)
 #define        IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
 
-#define bound(min,num,max) (num >= min ? (num < max ? num : max) : min)
+#define bound(min,num,max) ((num) >= (min) ? ((num) < (max) ? (num) : (max)) : (min))
 
 #ifndef min
-#define min(A,B) (A < B ? A : B)
-#define max(A,B) (A > B ? A : B)
+#define min(A,B) ((A) < (B) ? (A) : (B))
+#define max(A,B) ((A) > (B) ? (A) : (B))
 #endif
 
 #define lhrandom(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN))
@@ -154,22 +156,7 @@ void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up);
 void VectorVectorsDouble(const double *forward, double *right, double *up);
 
 void PlaneClassify(struct mplane_s *p);
-
-#define BOX_ON_PLANE_SIDE(emins, emaxs, p)     \
-       (((p)->type < 3)?                                               \
-       (                                                                               \
-               ((p)->dist <= (emins)[(p)->type])?      \
-                       1                                                               \
-               :                                                                       \
-               (                                                                       \
-                       ((p)->dist >= (emaxs)[(p)->type])?\
-                               2                                                       \
-                       :                                                               \
-                               3                                                       \
-               )                                                                       \
-       )                                                                               \
-       :                                                                               \
-               (p)->BoxOnPlaneSideFunc( (emins), (emaxs), (p)))
+int BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, const struct mplane_s *p);
 
 #define PlaneDist(point,plane)  ((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal))
 #define PlaneDiff(point,plane) (((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal)) - (plane)->dist)