X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=mathlib.h;h=0231e85ab1796f0c865bcd030fecaf4d8c4a39e5;hb=19f1b34facf77d7c0858b910e6579e635712e98a;hp=cece49c0cc1614e0f00fe3d5f00b92ae91cf9c56;hpb=8ddb66ffbe37b9fabd2cb30f36b7435deb3e9965;p=xonotic%2Fdarkplaces.git diff --git a/mathlib.h b/mathlib.h index cece49c0..0231e85a 100644 --- a/mathlib.h +++ b/mathlib.h @@ -52,8 +52,8 @@ extern vec3_t vec3_origin; #define lhrandom(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN)) #define invpow(base,number) (log(number) / log(base)) -#define bit2i(n) (((n & 0x55555555) != 0 ? 1 : 0) | ((n & 0x66666666) !=0 ? 2 : 0) | ((n & 0x78787878) != 0 ? 4 : 0) | ((n & 0x7F807F80) != 0 ? 8 : 0) | ((n & 0x7FFF8000) != 0 ? 16 : 0)) -#define log2i(n) (((n & 0xAAAAAAAA) != 0 ? 1 : 0) | ((n & 0xCCCCCCCC) != 0 ? 2 : 0) | ((n & 0xF0F0F0F0) != 0 ? 4 : 0) | ((n & 0xFF00FF00) != 0 ? 8 : 0) | ((n & 0xFFFF0000) != 0 ? 16 : 0)) +#define log2i(n) ((((n) & 0xAAAAAAAA) != 0 ? 1 : 0) | (((n) & 0xCCCCCCCC) != 0 ? 2 : 0) | (((n) & 0xF0F0F0F0) != 0 ? 4 : 0) | (((n) & 0xFF00FF00) != 0 ? 8 : 0) | (((n) & 0xFFFF0000) != 0 ? 16 : 0)) +#define bit2i(n) log2i((n) << 1) #define DEG2RAD(a) ((a) * ((float) M_PI / 180.0f)) #define RAD2DEG(a) ((a) * (180.0f / (float) M_PI)) @@ -202,7 +202,12 @@ 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); -int BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, const struct mplane_s *p); +int BoxOnPlaneSide(const vec3_t emins, const vec3_t emaxs, const struct mplane_s *p); +int BoxOnPlaneSide_Separate(const vec3_t emins, const vec3_t emaxs, const vec3_t normal, const vec_t dist); +void BoxPlaneCorners(const vec3_t emins, const vec3_t emaxs, const struct mplane_s *p, vec3_t outnear, vec3_t outfar); +void BoxPlaneCorners_Separate(const vec3_t emins, const vec3_t emaxs, const vec3_t normal, vec3_t outnear, vec3_t outfar); +void BoxPlaneCornerDistances(const vec3_t emins, const vec3_t emaxs, const struct mplane_s *p, vec_t *outnear, vec_t *outfar); +void BoxPlaneCornerDistances_Separate(const vec3_t emins, const vec3_t emaxs, const vec3_t normal, vec_t *outnear, vec_t *outfar); #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)