From 600aec3449c7cc8aaaa19f1502c7549e97dc1023 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Nov 2023 14:48:53 -0800 Subject: [PATCH] renderhitbox: shown MF_PAPERCOLLISION correctly --- src/r_bbox.c | 43 +++++++++++++++++++++++++++---------------- src/r_things.cpp | 35 ++++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/src/r_bbox.c b/src/r_bbox.c index ce4f3d758..d484c3b51 100644 --- a/src/r_bbox.c +++ b/src/r_bbox.c @@ -204,29 +204,40 @@ void R_DrawThingBoundingBox(vissprite_t *vis) .color = R_GetBoundingBoxColor(vis->mobj), }; - // 1--3 - // | | - // 0--2 + if (vis->mobjflags & MF_PAPERCOLLISION) + { + // 0--1 - // left + draw_bbox_col(&bb, 0, tx - rc, ty - rs); // left + draw_bbox_col(&bb, 1, tx + rc, ty + rs); // right + draw_bbox_row(&bb, 0, 1); // connect both + } + else + { + // 1--3 + // | | + // 0--2 - draw_bbox_col(&bb, 0, tx, ty); // bottom - draw_bbox_col(&bb, 1, tx - rc, ty + rs); // top + // left - // right + draw_bbox_col(&bb, 0, tx, ty); // bottom + draw_bbox_col(&bb, 1, tx - rc, ty + rs); // top - tx += rs; - ty += rc; + // right - draw_bbox_col(&bb, 2, tx, ty); // bottom - draw_bbox_col(&bb, 3, tx - rc, ty + rs); // top + tx += rs; + ty += rc; - // connect all four columns + draw_bbox_col(&bb, 2, tx, ty); // bottom + draw_bbox_col(&bb, 3, tx - rc, ty + rs); // top - draw_bbox_row(&bb, 0, 1); - draw_bbox_row(&bb, 1, 3); - draw_bbox_row(&bb, 3, 2); - draw_bbox_row(&bb, 2, 0); + // connect all four columns + + draw_bbox_row(&bb, 0, 1); + draw_bbox_row(&bb, 1, 3); + draw_bbox_row(&bb, 3, 2); + draw_bbox_row(&bb, 2, 0); + } } static boolean is_tangible (mobj_t *thing) diff --git a/src/r_things.cpp b/src/r_things.cpp index deacfce92..37dcc3bf4 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1586,13 +1586,22 @@ static void R_ProjectBoundingBox(mobj_t *thing, vissprite_t *vis) R_InterpolateMobjState(thing, FRACUNIT, &interp); } - // 1--3 - // | | - // 0--2 - - // start in the (0) corner - gx = interp.x - thing->radius - viewx; - gy = interp.y - thing->radius - viewy; + if (thing->flags & MF_PAPERCOLLISION) + { + // 0--1 + // start in the middle + gx = interp.x - viewx; + gy = interp.y - viewy; + } + else + { + // 1--3 + // | | + // 0--2 + // start in the (0) corner + gx = interp.x - thing->radius - viewx; + gy = interp.y - thing->radius - viewy; + } tz = FixedMul(gx, viewcos) + FixedMul(gy, viewsin); @@ -1620,8 +1629,16 @@ static void R_ProjectBoundingBox(mobj_t *thing, vissprite_t *vis) box->gx = tx; box->gy = tz; - box->scale = 2 * FixedMul(thing->radius, viewsin); - box->xscale = 2 * FixedMul(thing->radius, viewcos); + if (thing->flags & MF_PAPERCOLLISION) + { + box->scale = FixedMul(thing->radius, FCOS(viewangle - interp.angle)); + box->xscale = FixedMul(thing->radius, FSIN(viewangle - interp.angle)); + } + else + { + box->scale = 2 * FixedMul(thing->radius, viewsin); + box->xscale = 2 * FixedMul(thing->radius, viewcos); + } box->pz = interp.z; box->pzt = box->pz + box->thingheight;