From 986596e0d40c2a8130d250da336b6730a9dffabf Mon Sep 17 00:00:00 2001 From: Walter Julius Hennecke Date: Mon, 9 Dec 2013 22:05:33 +0100 Subject: [PATCH] Fixed an error and added an additional function. --- code/game/bg_collision.c | 12 +++++++++++- code/game/bg_collision.h | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/code/game/bg_collision.c b/code/game/bg_collision.c index 24384b3..ed88239 100644 --- a/code/game/bg_collision.c +++ b/code/game/bg_collision.c @@ -4,7 +4,7 @@ #define QUADRANT_LEFT 0 #define QUADRANT_RIGHT 1 #define QUADRANT_MIDDLE 2 -qboolean BG_LineBoxIntersection(vec3_t mins, vec2_t maxs, vec3_t origin, vec3_t dir, vec_t* hit) { +qboolean BG_LineBoxIntersection(vec3_t mins, vec3_t maxs, vec3_t origin, vec3_t dir, vec_t* hit) { qboolean inside; char quadrant[3]; int i; @@ -64,3 +64,13 @@ qboolean BG_LineBoxIntersection(vec3_t mins, vec2_t maxs, vec3_t origin, vec3_t return qtrue; } + +qboolean BG_IsInBox(vec3_t pos, vec3_t mins, vec3_t maxs) { + if( pos[0] <= maxs[0] && pos[0] >= mins[0] && + pos[1] <= maxs[1] && pos[1] >= mins[1] && + pos[2] <= maxs[2] && pos[2] >= mins[2]) { + return qtrue; + } + + return qfalse; +} diff --git a/code/game/bg_collision.h b/code/game/bg_collision.h index 926b8a3..7cde892 100644 --- a/code/game/bg_collision.h +++ b/code/game/bg_collision.h @@ -3,6 +3,7 @@ #include "q_shared.h" -qboolean BG_LineBoxIntersection(vec3_t mins, vec2_t maxs, vec3_t origin, vec3_t dir, vec_t* hit); +qboolean BG_LineBoxIntersection(vec3_t mins, vec3_t maxs, vec3_t origin, vec3_t dir, vec_t* hit); +qboolean BG_IsInBox(vec3_t pos, vec3_t mins, vec3_t maxs); #endif \ No newline at end of file