Use more explicit floor/ceiling FOF sort

This commit is contained in:
Sally Coolatta 2023-05-13 04:13:35 -04:00
parent 5ac7926e39
commit 7cb0b74cac

View file

@ -748,36 +748,67 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open)
polybottom = INT32_MIN; polybottom = INT32_MIN;
} }
polymid = polybottom + (polytop - polybottom) / 2; switch (open->fofType)
delta1 = abs(mobj->z - polymid);
delta2 = abs(thingtop - polymid);
if (delta1 > delta2)
{ {
if (open->fofType != LO_FOF_FLOORS) case LO_FOF_FLOORS:
{ {
if (polybottom < open->ceiling) if (mobj->z >= polytop)
{ {
open->ceiling = polybottom; if (polytop > open->floor)
} {
else if (polybottom < open->highceiling) open->floor = polytop;
{ }
open->highceiling = polybottom; else if (polytop > open->lowfloor)
{
open->lowfloor = polytop;
}
} }
break;
} }
} case LO_FOF_CEILINGS:
else
{
if (open->fofType != LO_FOF_CEILINGS)
{ {
if (polytop > open->floor) if (thingtop <= polybottom)
{ {
open->floor = polytop; if (polybottom < open->ceiling)
{
open->ceiling = polybottom;
}
else if (polybottom < open->highceiling)
{
open->highceiling = polybottom;
}
} }
else if (polytop > open->lowfloor) break;
}
default:
{
polymid = polybottom + (polytop - polybottom) / 2;
delta1 = abs(mobj->z - polymid);
delta2 = abs(thingtop - polymid);
if (delta1 > delta2)
{ {
open->lowfloor = polytop; if (polybottom < open->ceiling)
{
open->ceiling = polybottom;
}
else if (polybottom < open->highceiling)
{
open->highceiling = polybottom;
}
} }
else
{
if (polytop > open->floor)
{
open->floor = polytop;
}
else if (polytop > open->lowfloor)
{
open->lowfloor = polytop;
}
}
break;
} }
} }
} }
@ -828,42 +859,69 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open)
bottomheight = P_GetFOFBottomZ(mobj, front, rover, tm.x, tm.y, linedef); bottomheight = P_GetFOFBottomZ(mobj, front, rover, tm.x, tm.y, linedef);
} }
midheight = bottomheight + (topheight - bottomheight) / 2; switch (open->fofType)
delta1 = abs(mobj->z - midheight);
delta2 = abs(thingtop - midheight);
if (delta1 > delta2)
{ {
if (open->fofType == LO_FOF_FLOORS) case LO_FOF_FLOORS:
{ {
continue; if (mobj->z >= topheight)
}
// thing is below FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_PLATFORM)
{
if (bottomheight < fofopen[FRONT].ceiling)
{ {
fofopen[FRONT].ceiling = bottomheight; if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_REVERSEPLATFORM)
fofopen[FRONT].ceilingrover = rover; {
if (topheight > fofopen[FRONT].floor)
{
fofopen[FRONT].floor = topheight;
fofopen[FRONT].floorrover = rover;
}
}
} }
break;
} }
} case LO_FOF_CEILINGS:
else
{
if (open->fofType == LO_FOF_CEILINGS)
{ {
continue; if (thingtop <= bottomheight)
}
// thing is above FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_REVERSEPLATFORM)
{
if (topheight > fofopen[FRONT].floor)
{ {
fofopen[FRONT].floor = topheight; if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_PLATFORM)
fofopen[FRONT].floorrover = rover; {
if (bottomheight < fofopen[FRONT].ceiling)
{
fofopen[FRONT].ceiling = bottomheight;
fofopen[FRONT].ceilingrover = rover;
}
}
} }
break;
}
default:
{
midheight = bottomheight + (topheight - bottomheight) / 2;
delta1 = abs(mobj->z - midheight);
delta2 = abs(thingtop - midheight);
if (delta1 > delta2)
{
// thing is below FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_PLATFORM)
{
if (bottomheight < fofopen[FRONT].ceiling)
{
fofopen[FRONT].ceiling = bottomheight;
fofopen[FRONT].ceilingrover = rover;
}
}
}
else
{
// thing is above FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_REVERSEPLATFORM)
{
if (topheight > fofopen[FRONT].floor)
{
fofopen[FRONT].floor = topheight;
fofopen[FRONT].floorrover = rover;
}
}
}
break;
} }
} }
} }
@ -893,42 +951,69 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj, opening_t *open)
bottomheight = P_GetFOFBottomZ(mobj, back, rover, tm.x, tm.y, linedef); bottomheight = P_GetFOFBottomZ(mobj, back, rover, tm.x, tm.y, linedef);
} }
midheight = bottomheight + (topheight - bottomheight) / 2; switch (open->fofType)
delta1 = abs(mobj->z - midheight);
delta2 = abs(thingtop - midheight);
if (delta1 > delta2)
{ {
if (open->fofType == LO_FOF_FLOORS) case LO_FOF_FLOORS:
{ {
continue; if (mobj->z >= topheight)
}
// thing is below FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_PLATFORM)
{
if (bottomheight < fofopen[BACK].ceiling)
{ {
fofopen[BACK].ceiling = bottomheight; if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_REVERSEPLATFORM)
fofopen[BACK].ceilingrover = rover; {
if (topheight > fofopen[BACK].floor)
{
fofopen[BACK].floor = topheight;
fofopen[BACK].floorrover = rover;
}
}
} }
break;
} }
} case LO_FOF_CEILINGS:
else
{
if (open->fofType == LO_FOF_CEILINGS)
{ {
continue; if (thingtop <= bottomheight)
}
// thing is above FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_REVERSEPLATFORM)
{
if (topheight > fofopen[BACK].floor)
{ {
fofopen[BACK].floor = topheight; if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_PLATFORM)
fofopen[BACK].floorrover = rover; {
if (bottomheight < fofopen[BACK].ceiling)
{
fofopen[BACK].ceiling = bottomheight;
fofopen[BACK].ceilingrover = rover;
}
}
} }
break;
}
default:
{
midheight = bottomheight + (topheight - bottomheight) / 2;
delta1 = abs(mobj->z - midheight);
delta2 = abs(thingtop - midheight);
if (delta1 > delta2)
{
// thing is below FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_PLATFORM)
{
if (bottomheight < fofopen[BACK].ceiling)
{
fofopen[BACK].ceiling = bottomheight;
fofopen[BACK].ceilingrover = rover;
}
}
}
else
{
// thing is above FOF
if ((rover->fofflags & FOF_INTANGIBLEFLATS) != FOF_REVERSEPLATFORM)
{
if (topheight > fofopen[BACK].floor)
{
fofopen[BACK].floor = topheight;
fofopen[BACK].floorrover = rover;
}
}
}
break;
} }
} }
} }