From 4bf5691cad3518d5328b04dc6d469bd0c250730e Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 7 Dec 2015 15:02:18 -0800 Subject: [PATCH] experimenting with shobboxes --- quakespasm/Quake/gl_rmain.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/quakespasm/Quake/gl_rmain.c b/quakespasm/Quake/gl_rmain.c index fad620b4..b7e4ebb7 100644 --- a/quakespasm/Quake/gl_rmain.c +++ b/quakespasm/Quake/gl_rmain.c @@ -756,6 +756,39 @@ void R_ShowBoundingBoxes (void) VectorAdd (ed->v.mins, ed->v.origin, mins); VectorAdd (ed->v.maxs, ed->v.origin, maxs); R_EmitWireBox (mins, maxs); + + // show the fixed-size, bsp hull bbox + if (r_showbboxes.value >= 2) + { + vec3_t size, offset, hullbbox_origin; + edict_t *world; + hull_t *hull; + + world = sv.edicts; + + glColor3f(1, 0, 0); + + // Pick the world hull that this entity clips against + VectorSubtract(ed->v.maxs, ed->v.mins, size); + if (size[0] < 3) + hull = &sv.worldmodel->hulls[0]; + else if (size[0] <= 32) + hull = &sv.worldmodel->hulls[1]; + else + hull = &sv.worldmodel->hulls[2]; + + // calculate an offset value to center the origin + VectorSubtract(hull->clip_mins, ed->v.mins, offset); + VectorAdd(offset, world->v.origin, offset); + + // now, offset would be added to ed->v.origin and tested against the hull. + VectorAdd(offset, ed->v.origin, hullbbox_origin); + + VectorAdd(hull->clip_mins, hullbbox_origin, mins); + VectorAdd(hull->clip_maxs, hullbbox_origin, maxs); + R_EmitWireBox(mins, maxs); + glColor3f(1, 1, 1); + } } }