From e06b61e8d2c44bddaf146a85396bd6fbae3e1766 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jan 2025 22:17:15 +0100 Subject: [PATCH] revert "Faster z position checks for mobjs without collision" --- src/p_mobj.c | 10 ++++------ src/r_main.h | 44 -------------------------------------------- 2 files changed, 4 insertions(+), 50 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d8d34b243..904f61271 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -578,8 +578,6 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, ); } -#define NOCOLLISION ((mobj->flags & MF_NOBLOCKMAP) || (mobj->flags & MF_NOCLIPTHING)) - fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect) { I_Assert(mobj != NULL); @@ -611,7 +609,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (NOCOLLISION ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -690,7 +688,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (NOCOLLISION ? R_IsPointInSector(boundsec ? boundsec : sector, testx, testy) : R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -770,7 +768,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point @@ -849,7 +847,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f testy += y; // If the highest point is in the sector, then we have it easy! Just get the Z at that point - if (R_IsPointInSector(boundsec ? boundsec : sector, testx, testy)) + if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector)) return P_GetZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point diff --git a/src/r_main.h b/src/r_main.h index 53579c163..511450665 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -125,50 +125,6 @@ angle_t R_PlayerSliptideAngle(player_t *player); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); -// -// R_IsPointInSector -// -FUNCINLINE static ATTRINLINE boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y) -{ - size_t i; - size_t passes = 0; - - for (i = 0; i < sector->linecount; i++) - { - line_t *line = sector->lines[i]; - vertex_t *v1, *v2; - - if (line->frontsector == line->backsector) - continue; - - v1 = line->v1; - v2 = line->v2; - - // make sure v1 is below v2 - if (v1->y > v2->y) - { - vertex_t *tmp = v1; - v1 = v2; - v2 = tmp; - } - else if (v1->y == v2->y) // horizontal line, we can't match this - continue; - - if (v1->y < y && y <= v2->y) - { - // if the y axis in inside the line, find the point where we intersect on the x axis... - fixed_t vx = v1->x + (INT64)(v2->x - v1->x) * (y - v1->y) / (v2->y - v1->y); - - // ...and if that point is to the left of the point, count it as inside. - if (vx < x) - passes++; - } - } - - // and odd number of passes means we're inside the polygon. - return (boolean)(passes % 2); -} - // // R_PointInSubsector //