X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=mathlib.h;h=cffbbbc88b8f9f3c3a511dd5664f8b95a54c6b6d;hb=bb147ba5d00e3cfe4e6904bc7e891802f75e6177;hp=65c187b3ab542c4d5fc76d5c9fdab7e7f444d500;hpb=ae8de3cef4ea00ae7e9051acb60cc884a5e86a29;p=xonotic%2Fdarkplaces.git diff --git a/mathlib.h b/mathlib.h index 65c187b3..cffbbbc8 100644 --- a/mathlib.h +++ b/mathlib.h @@ -42,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)) @@ -156,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)