From cec6dfc131aa69c38b3c58ec37b49a05f11f896b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Dec 2024 16:36:37 +0100 Subject: [PATCH] add P_CheckPositionShadow just for shadow mobjs its basically just R_GetShadowZ from the render based shadows from srb2 lmao hope this is synchsafe --- src/p_map.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 782aac138..8786f2f90 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1665,6 +1665,8 @@ static boolean PIT_CheckLine(line_t *ld) // MOVEMENT CLIPPING // ========================================================================= +static boolean P_CheckPositionShadow(mobj_t *thing, fixed_t x, fixed_t y); + // // P_CheckPosition // This is purely informative, nothing is modified @@ -1710,6 +1712,12 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) I_Error("Previously-removed Thing of type %u crashes P_CheckPosition!", thing->type); #endif + // crappy optimization lmao hope this works out + if (thing->type == MT_SHADOW) + { + return P_CheckPositionShadow(thing, x, y); + } + P_SetTarget(&tmthing, thing); tmflags = thing->flags; @@ -1949,6 +1957,108 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) return blockval; } +// P_CheckPosition but its actually R_GetShadowZ from SRB2 +// this checks for less and keeps everything simpler +// since i dont want VISUAL shadows crapping by checking for a crapton of stuff +static boolean P_CheckPositionShadow(mobj_t *thing, fixed_t x, fixed_t y) +{ + subsector_t *newsubsec; + + P_SetTarget(&tmthing, thing); + tmflags = thing->flags; + + tmx = x; + tmy = y; + + tmbbox[BOXTOP] = y + tmthing->radius; + tmbbox[BOXBOTTOM] = y - tmthing->radius; + tmbbox[BOXRIGHT] = x + tmthing->radius; + tmbbox[BOXLEFT] = x - tmthing->radius; + + if (thing->x != x || thing->y != y || thing->subsector == NULL) + newsubsec = R_PointInSubsector(x, y); + else + newsubsec = thing->subsector; + + ceilingline = blockingline = NULL; + + // The base floor / ceiling is from the subsector + // that contains the point. + // Any contacted lines the step closer together + // will adjust them. + tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; + tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; + tmfloorslope = newsubsec->sector->f_slope; + tmceilingslope = newsubsec->sector->c_slope; + + const fixed_t halfHeight = (thing->z + (thing->height >> 1)); + + // Check list of fake floors and see if tmfloorz/tmceilingz need to be altered. + if (newsubsec->sector->ffloors) + { + ffloor_t *rover; + + for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) + continue; + + topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL); + bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL); + + if (topheight < halfHeight && topheight > tmfloorz) + { + tmfloorz = tmdropoffz = topheight; + tmfloorslope = *rover->t_slope; + } + if (bottomheight > halfHeight && bottomheight < tmfloorz) + { + tmceilingz = tmdrpoffceilz = bottomheight; + tmceilingslope = *rover->b_slope; + } + } + } + + tmfloorthing = NULL; + tmhitthing = NULL; + + // Check polyobjects and see if groundz needs to be altered + // This isn't very precise, but the precise method was far too slow. + // (Polies are just naturally pretty flickery anyway :P) + polyobj_t *po = newsubsec->polyList; + fixed_t z; + + while (po) + { + if (!(po->flags & POF_RENDERPLANES) || !P_MobjInsidePolyobj(po, tmthing)) + { + po = (polyobj_t *)(po->link.next); + continue; + } + + // We're inside it! Yess... + z = po->lines[0]->backsector->floorheight; + if (z < halfHeight && z > tmfloorz) + { + tmfloorz = z; + tmfloorslope = NULL; + } + + z = po->lines[0]->backsector->ceilingheight; + if (z > halfHeight && z < tmfloorz) + { + tmceilingz = z; + tmceilingslope = NULL; + } + + po = (polyobj_t *)(po->link.next); + } + + return true; +} + static const fixed_t hoopblockdist = 16*FRACUNIT + 8*FRACUNIT; static const fixed_t hoophalfheight = (56*FRACUNIT)/2;