Merge pull request #148 from Indev450/checkposopti

Dont always call R_PointInSubsector if thing has not moved in P_CheckPosition
This commit was merged in pull request #148.
This commit is contained in:
Alug authored and GitHub committed 2025-01-11 01:37:07 +01:00
commit a1f185b0f0
2 files changed
+82 -53

No files matched your search

+40 -14
View File
@@ -1726,7 +1726,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
tmbbox[BOXRIGHT] = x + tmthing->radius;
tmbbox[BOXLEFT] = x - tmthing->radius;
newsubsec = R_PointInSubsector(x, y);
if (thing->x != x || thing->y != y || thing->subsector == NULL)
newsubsec = R_PointInSubsector(x, y);
else
newsubsec = thing->subsector;
ceilingline = blockingline = NULL;
@@ -1748,7 +1751,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
for (rover = newsubsec->sector->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
fixed_t topheight, bottomheight, midheight;
if (!(rover->flags & FF_EXISTS))
continue;
@@ -1813,10 +1816,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
continue;
}
delta1 = thing->z - (bottomheight
+ ((topheight - bottomheight)/2));
delta2 = thingtop - (bottomheight
+ ((topheight - bottomheight)/2));
midheight = (bottomheight + ((topheight - bottomheight)/2));
delta1 = thing->z - midheight;
delta2 = thingtop - midheight;
if (topheight > tmfloorz && abs(delta1) < abs(delta2)
&& !(rover->flags & FF_REVERSEPLATFORM))
@@ -1847,10 +1850,13 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
BMBOUNDFIX(xl, xh, yl, yh);
// Check polyobjects and see if tmfloorz/tmceilingz need to be altered
// do we really have to iterate through the complete blockmap for polyobjects if there are no polyobjects on the map?
if (numPolyObjects)
{
validcount++;
for (by = yl; by <= yh; by++)
{
for (bx = xl; bx <= xh; bx++)
{
INT32 offset;
@@ -1901,12 +1907,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
delta1 = thing->z - (polybottom + ((polytop - polybottom)/2));
delta2 = thingtop - (polybottom + ((polytop - polybottom)/2));
if (polytop > tmfloorz && abs(delta1) < abs(delta2)) {
if (polytop > tmfloorz && abs(delta1) < abs(delta2))
{
tmfloorz = tmdropoffz = polytop;
tmfloorslope = NULL;
}
if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) {
if (polybottom < tmceilingz && abs(delta1) >= abs(delta2))
{
tmceilingz = tmdrpoffceilz = polybottom;
tmceilingslope = NULL;
}
@@ -1914,6 +1922,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
plink = (polymaplink_t *)(plink->link.next);
}
}
}
}
// tmfloorthing is set when tmfloorz comes from a thing's top
@@ -1994,7 +2003,11 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
tmbbox[BOXRIGHT] = x + thiscam->radius;
tmbbox[BOXLEFT] = x - thiscam->radius;
newsubsec = R_PointInSubsector(x, y);
if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL)
newsubsec = R_PointInSubsector(x, y);
else
newsubsec = thiscam->subsector;
ceilingline = blockingline = NULL;
mapcampointer = thiscam;
@@ -2073,6 +2086,8 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
BMBOUNDFIX(xl, xh, yl, yh);
// Check polyobjects and see if tmfloorz/tmceilingz need to be altered
// do we really have to iterate through the complete blockmap for polyobjects if there are no polyobjects on the map?
if (numPolyObjects)
{
validcount++;
@@ -2164,7 +2179,8 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
//
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
{
subsector_t *s = R_PointInSubsector(x, y);
subsector_t *s;
boolean retval = true;
boolean itsatwodlevel = false;
UINT8 i;
@@ -2174,6 +2190,11 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
if (dedicated) // this crashes so don't even try it
return false;
if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL)
s = R_PointInSubsector(x, y);
else
s = thiscam->subsector;
if (twodlevel)
itsatwodlevel = true;
else
@@ -2367,10 +2388,13 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
radius = MAXRADIUS/2;
do {
if (thing->flags & MF_NOCLIP) {
if (thing->flags & MF_NOCLIP)
{
tryx = x;
tryy = y;
} else {
}
else
{
if (x-tryx > radius)
tryx += radius;
else if (x-tryx < -radius)
@@ -2514,14 +2538,16 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
if (!(thing->flags & MF_NOCLIPHEIGHT))
{
// Assign thing's standingslope if needed
if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) {
if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP))
{
if (!startingonground && tmfloorslope)
P_HandleSlopeLanding(thing, tmfloorslope);
if (thing->momz <= 0)
thing->standingslope = tmfloorslope;
}
else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) {
else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP))
{
if (!startingonground && tmceilingslope)
P_HandleSlopeLanding(thing, tmceilingslope);
+42 -39
View File
@@ -2480,55 +2480,58 @@ static void P_PlayerZMovement(mobj_t *mo)
msecnode_t *node;
boolean stopmovecut = false;
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
if (numPolyObjects)
{
sector_t *sec = node->m_sector;
subsector_t *newsubsec;
size_t i;
for (i = 0; i < numsubsectors; i++)
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
{
newsubsec = &subsectors[i];
sector_t *sec = node->m_sector;
subsector_t *newsubsec;
size_t i;
if (newsubsec->sector != sec)
continue;
if (!newsubsec->polyList)
continue;
polyobj_t *po = newsubsec->polyList;
sector_t *polysec;
while(po)
for (i = 0; i < numsubsectors; i++)
{
if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID))
{
po = (polyobj_t *)(po->link.next);
newsubsec = &subsectors[i];
if (newsubsec->sector != sec)
continue;
}
// We're inside it! Yess...
polysec = po->lines[0]->backsector;
// Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red
if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker)
stopmovecut = true;
if (!(po->flags & POF_LDEXEC))
{
po = (polyobj_t *)(po->link.next);
if (!newsubsec->polyList)
continue;
}
if (mo->z == polysec->ceilingheight)
polyobj_t *po = newsubsec->polyList;
sector_t *polysec;
while(po)
{
// We're landing on a PO, so check for
// a linedef executor.
// Trigger tags are 32000 + the PO's ID number.
P_LinedefExecute((INT16)(32000 + po->id), mo, NULL);
}
if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID))
{
po = (polyobj_t *)(po->link.next);
continue;
}
po = (polyobj_t *)(po->link.next);
// We're inside it! Yess...
polysec = po->lines[0]->backsector;
// Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red
if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker)
stopmovecut = true;
if (!(po->flags & POF_LDEXEC))
{
po = (polyobj_t *)(po->link.next);
continue;
}
if (mo->z == polysec->ceilingheight)
{
// We're landing on a PO, so check for
// a linedef executor.
// Trigger tags are 32000 + the PO's ID number.
P_LinedefExecute((INT16)(32000 + po->id), mo, NULL);
}
po = (polyobj_t *)(po->link.next);
}
}
}
}