From 3a0419703dcd2281d5cfe1fbd1872820d8ca0365 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 1 Mar 2024 20:11:51 +0100 Subject: [PATCH] use boxonlineside for non player mobjs --- src/p_map.c | 12 ++++++++++-- src/p_mobj.c | 26 +++++++++++++++++++++----- src/p_polyobj.c | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 1e81a2529..74c0df216 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1921,8 +1921,16 @@ static boolean PIT_CheckLine(line_t *ld) || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return true; - if (P_CircleOnLineSide(tmx, tmy, tmthing->radius, ld) != -1) - return true; + if (tmthing->player) + { + if (P_CircleOnLineSide(tmx, tmy, tmthing->radius, ld) != -1) + return true; + } + else + { + if (P_BoxOnLineSide(tmbbox, ld) != -1) + return true; + } if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { diff --git a/src/p_mobj.c b/src/p_mobj.c index fb1ed6dbc..8ec8f99c5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -559,9 +559,17 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; - - if (P_CircleOnLineSide(x, y, mobj->radius, ld) != -1) - continue; + + if (mobj->player) + { + if (P_CircleOnLineSide(x, y, mobj->radius, ld) != -1) + continue; + } + else + { + if (P_BoxOnLineSide(bbox, ld) != -1) + continue; + } if (lowest) finalheight = min(finalheight, HighestOnLine(mobj->radius, x, y, ld, slope, true)); @@ -623,8 +631,16 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; - if (P_CircleOnLineSide(x, y, mobj->radius, ld) != -1) - continue; + if (mobj->player) + { + if (P_CircleOnLineSide(x, y, mobj->radius, ld) != -1) + continue; + } + else + { + if (P_BoxOnLineSide(bbox, ld) != -1) + continue; + } if (lowest) finalheight = min(finalheight, HighestOnLine(mobj->radius, x, y, ld, slope, true)); diff --git a/src/p_polyobj.c b/src/p_polyobj.c index fed8d46ec..a5cd3a134 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -177,12 +177,26 @@ boolean P_PointInsidePolyobj(polyobj_t *po, fixed_t x, fixed_t y) // boolean P_MobjTouchingPolyobj(polyobj_t *po, mobj_t *mo) { + fixed_t mbbox[4]; size_t i; + + mbbox[BOXTOP] = mo->y + mo->radius; + mbbox[BOXBOTTOM] = mo->y - mo->radius; + mbbox[BOXRIGHT] = mo->x + mo->radius; + mbbox[BOXLEFT] = mo->x - mo->radius; for (i = 0; i < po->numLines; i++) { - if (P_CircleOnLineSide(mo->x, mo->y, mo->radius, po->lines[i]) == -1) - return true; + if (mo->player) + { + if (P_CircleOnLineSide(mo->x, mo->y, mo->radius, po->lines[i]) == -1) + return true; + } + else + { + if (P_BoxOnLineSide(mbbox, po->lines[i]) == -1) + return true; + } } return false; @@ -195,12 +209,26 @@ boolean P_MobjTouchingPolyobj(polyobj_t *po, mobj_t *mo) // boolean P_MobjInsidePolyobj(polyobj_t *po, mobj_t *mo) { + fixed_t mbbox[4]; size_t i; + + mbbox[BOXTOP] = mo->y + mo->radius; + mbbox[BOXBOTTOM] = mo->y - mo->radius; + mbbox[BOXRIGHT] = mo->x + mo->radius; + mbbox[BOXLEFT] = mo->x - mo->radius; for (i = 0; i < po->numLines; i++) { - if (P_CircleOnLineSide(mo->x, mo->y, mo->radius, po->lines[i]) == 0) - return false; + if (mo->player) + { + if (P_CircleOnLineSide(mo->x, mo->y, mo->radius, po->lines[i]) == 0) + return false; + } + else + { + if (P_BoxOnLineSide(mbbox, po->lines[i]) == 0) + return false; + } } return true;