mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-18 22:51:39 +00:00
- split DSectorEffect::MovePlane into MoveFloor and MoveCeiling.
What was the point of this strange setup anyway? MoveFloor and MoveCeiling were inlines calling the universal MovePlane, which had nothing better to do than a switch/case with two cases - floor and ceiling!
This commit is contained in:
parent
74c9a7bf67
commit
fb2234396c
2 changed files with 205 additions and 209 deletions
|
@ -155,8 +155,7 @@ bool DMover::MoveAttached(int crush, double move, int floorOrCeiling, bool reset
|
||||||
// (Use -1 to prevent it from trying to crush)
|
// (Use -1 to prevent it from trying to crush)
|
||||||
// dest is the desired d value for the plane
|
// dest is the desired d value for the plane
|
||||||
//
|
//
|
||||||
DMover::EResult DMover::MovePlane (double speed, double dest, int crush,
|
DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush)
|
||||||
int floorOrCeiling, int direction, bool hexencrush)
|
|
||||||
{
|
{
|
||||||
bool flag;
|
bool flag;
|
||||||
double lastpos;
|
double lastpos;
|
||||||
|
@ -164,227 +163,228 @@ DMover::EResult DMover::MovePlane (double speed, double dest, int crush,
|
||||||
double move;
|
double move;
|
||||||
//double destheight; //jff 02/04/98 used to keep floors/ceilings
|
//double destheight; //jff 02/04/98 used to keep floors/ceilings
|
||||||
// from moving thru each other
|
// from moving thru each other
|
||||||
switch (floorOrCeiling)
|
lastpos = m_Sector->floorplane.fD();
|
||||||
|
switch (direction)
|
||||||
{
|
{
|
||||||
case 0:
|
case -1:
|
||||||
// FLOOR
|
// DOWN
|
||||||
lastpos = m_Sector->floorplane.fD();
|
movedest = m_Sector->floorplane.GetChangedHeight(-speed);
|
||||||
switch (direction)
|
if (movedest >= dest)
|
||||||
{
|
{
|
||||||
case -1:
|
move = m_Sector->floorplane.HeightDiff(lastpos, dest);
|
||||||
// DOWN
|
|
||||||
movedest = m_Sector->floorplane.GetChangedHeight (-speed);
|
if (!MoveAttached(crush, move, 0, true)) return crushed;
|
||||||
if (movedest >= dest)
|
|
||||||
|
m_Sector->floorplane.setD(dest);
|
||||||
|
flag = P_ChangeSector(m_Sector, crush, move, 0, false);
|
||||||
|
if (flag)
|
||||||
{
|
{
|
||||||
move = m_Sector->floorplane.HeightDiff (lastpos, dest);
|
m_Sector->floorplane.setD(lastpos);
|
||||||
|
P_ChangeSector(m_Sector, crush, -move, 0, true);
|
||||||
if (!MoveAttached(crush, move, 0, true)) return crushed;
|
MoveAttached(crush, -move, 0, false);
|
||||||
|
|
||||||
m_Sector->floorplane.setD(dest);
|
|
||||||
flag = P_ChangeSector (m_Sector, crush, move, 0, false);
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
m_Sector->floorplane.setD(lastpos);
|
|
||||||
P_ChangeSector (m_Sector, crush, -move, 0, true);
|
|
||||||
MoveAttached(crush, -move, 0, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
|
|
||||||
m_Sector->AdjustFloorClip ();
|
|
||||||
}
|
|
||||||
return pastdest;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!MoveAttached(crush, -speed, 0, true)) return crushed;
|
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
|
||||||
|
m_Sector->AdjustFloorClip();
|
||||||
m_Sector->floorplane.setD(movedest);
|
|
||||||
|
|
||||||
flag = P_ChangeSector (m_Sector, crush, -speed, 0, false);
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
m_Sector->floorplane.setD(lastpos);
|
|
||||||
P_ChangeSector (m_Sector, crush, speed, 0, true);
|
|
||||||
MoveAttached(crush, speed, 0, false);
|
|
||||||
return crushed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff (lastpos));
|
|
||||||
m_Sector->AdjustFloorClip ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
return pastdest;
|
||||||
|
}
|
||||||
case 1:
|
else
|
||||||
// UP
|
{
|
||||||
// jff 02/04/98 keep floor from moving thru ceilings
|
if (!MoveAttached(crush, -speed, 0, true)) return crushed;
|
||||||
// [RH] not so easy with arbitrary planes
|
|
||||||
//destheight = (dest < m_Sector->ceilingheight) ? dest : m_Sector->ceilingheight;
|
m_Sector->floorplane.setD(movedest);
|
||||||
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
|
|
||||||
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.fD()))
|
flag = P_ChangeSector(m_Sector, crush, -speed, 0, false);
|
||||||
|
if (flag)
|
||||||
{
|
{
|
||||||
dest = -m_Sector->ceilingplane.fD();
|
m_Sector->floorplane.setD(lastpos);
|
||||||
}
|
P_ChangeSector(m_Sector, crush, speed, 0, true);
|
||||||
|
MoveAttached(crush, speed, 0, false);
|
||||||
movedest = m_Sector->floorplane.GetChangedHeight (speed);
|
return crushed;
|
||||||
|
|
||||||
if (movedest <= dest)
|
|
||||||
{
|
|
||||||
move = m_Sector->floorplane.HeightDiff (lastpos, dest);
|
|
||||||
|
|
||||||
if (!MoveAttached(crush, move, 0, true)) return crushed;
|
|
||||||
|
|
||||||
m_Sector->floorplane.setD(dest);
|
|
||||||
|
|
||||||
flag = P_ChangeSector (m_Sector, crush, move, 0, false);
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
m_Sector->floorplane.setD(lastpos);
|
|
||||||
P_ChangeSector (m_Sector, crush, -move, 0, true);
|
|
||||||
MoveAttached(crush, -move, 0, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
|
|
||||||
m_Sector->AdjustFloorClip ();
|
|
||||||
}
|
|
||||||
return pastdest;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!MoveAttached(crush, speed, 0, true)) return crushed;
|
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
|
||||||
|
m_Sector->AdjustFloorClip();
|
||||||
m_Sector->floorplane.setD(movedest);
|
|
||||||
|
|
||||||
// COULD GET CRUSHED
|
|
||||||
flag = P_ChangeSector (m_Sector, crush, speed, 0, false);
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
if (crush >= 0 && !hexencrush)
|
|
||||||
{
|
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff (lastpos));
|
|
||||||
m_Sector->AdjustFloorClip ();
|
|
||||||
return crushed;
|
|
||||||
}
|
|
||||||
m_Sector->floorplane.setD(lastpos);
|
|
||||||
P_ChangeSector (m_Sector, crush, -speed, 0, true);
|
|
||||||
MoveAttached(crush, -speed, 0, false);
|
|
||||||
return crushed;
|
|
||||||
}
|
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff (lastpos));
|
|
||||||
m_Sector->AdjustFloorClip ();
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
// CEILING
|
// UP
|
||||||
lastpos = m_Sector->ceilingplane.fD();
|
// jff 02/04/98 keep floor from moving thru ceilings
|
||||||
switch (direction)
|
// [RH] not so easy with arbitrary planes
|
||||||
|
//destheight = (dest < m_Sector->ceilingheight) ? dest : m_Sector->ceilingheight;
|
||||||
|
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
|
||||||
|
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.fD()))
|
||||||
{
|
{
|
||||||
case -1:
|
dest = -m_Sector->ceilingplane.fD();
|
||||||
// DOWN
|
}
|
||||||
// jff 02/04/98 keep ceiling from moving thru floors
|
|
||||||
// [RH] not so easy with arbitrary planes
|
movedest = m_Sector->floorplane.GetChangedHeight(speed);
|
||||||
//destheight = (dest > m_Sector->floorheight) ? dest : m_Sector->floorheight;
|
|
||||||
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
|
if (movedest <= dest)
|
||||||
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.fD()))
|
{
|
||||||
|
move = m_Sector->floorplane.HeightDiff(lastpos, dest);
|
||||||
|
|
||||||
|
if (!MoveAttached(crush, move, 0, true)) return crushed;
|
||||||
|
|
||||||
|
m_Sector->floorplane.setD(dest);
|
||||||
|
|
||||||
|
flag = P_ChangeSector(m_Sector, crush, move, 0, false);
|
||||||
|
if (flag)
|
||||||
{
|
{
|
||||||
dest = -m_Sector->floorplane.fD();
|
m_Sector->floorplane.setD(lastpos);
|
||||||
}
|
P_ChangeSector(m_Sector, crush, -move, 0, true);
|
||||||
movedest = m_Sector->ceilingplane.GetChangedHeight (-speed);
|
MoveAttached(crush, -move, 0, false);
|
||||||
if (movedest <= dest)
|
|
||||||
{
|
|
||||||
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
|
|
||||||
|
|
||||||
if (!MoveAttached(crush, move, 1, true)) return crushed;
|
|
||||||
|
|
||||||
m_Sector->ceilingplane.setD(dest);
|
|
||||||
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
|
|
||||||
|
|
||||||
if (flag)
|
|
||||||
{
|
|
||||||
m_Sector->ceilingplane.setD(lastpos);
|
|
||||||
P_ChangeSector (m_Sector, crush, -move, 1, true);
|
|
||||||
MoveAttached(crush, -move, 1, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
|
|
||||||
}
|
|
||||||
return pastdest;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!MoveAttached(crush, -speed, 1, true)) return crushed;
|
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
|
||||||
|
m_Sector->AdjustFloorClip();
|
||||||
|
}
|
||||||
|
return pastdest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!MoveAttached(crush, speed, 0, true)) return crushed;
|
||||||
|
|
||||||
m_Sector->ceilingplane.setD(movedest);
|
m_Sector->floorplane.setD(movedest);
|
||||||
|
|
||||||
// COULD GET CRUSHED
|
// COULD GET CRUSHED
|
||||||
flag = P_ChangeSector (m_Sector, crush, -speed, 1, false);
|
flag = P_ChangeSector(m_Sector, crush, speed, 0, false);
|
||||||
if (flag)
|
if (flag)
|
||||||
|
{
|
||||||
|
if (crush >= 0 && !hexencrush)
|
||||||
{
|
{
|
||||||
if (crush >= 0 && !hexencrush)
|
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
|
||||||
{
|
m_Sector->AdjustFloorClip();
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
|
||||||
return crushed;
|
|
||||||
}
|
|
||||||
m_Sector->ceilingplane.setD(lastpos);
|
|
||||||
P_ChangeSector (m_Sector, crush, speed, 1, true);
|
|
||||||
MoveAttached(crush, speed, 1, false);
|
|
||||||
return crushed;
|
return crushed;
|
||||||
}
|
}
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
m_Sector->floorplane.setD(lastpos);
|
||||||
|
P_ChangeSector(m_Sector, crush, -speed, 0, true);
|
||||||
|
MoveAttached(crush, -speed, 0, false);
|
||||||
|
return crushed;
|
||||||
}
|
}
|
||||||
break;
|
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
|
||||||
|
m_Sector->AdjustFloorClip();
|
||||||
case 1:
|
}
|
||||||
// UP
|
break;
|
||||||
movedest = m_Sector->ceilingplane.GetChangedHeight (speed);
|
}
|
||||||
if (movedest >= dest)
|
return ok;
|
||||||
{
|
}
|
||||||
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
|
|
||||||
|
DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush)
|
||||||
if (!MoveAttached(crush, move, 1, true)) return crushed;
|
{
|
||||||
|
bool flag;
|
||||||
m_Sector->ceilingplane.setD(dest);
|
double lastpos;
|
||||||
|
double movedest;
|
||||||
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
|
double move;
|
||||||
if (flag)
|
//double destheight; //jff 02/04/98 used to keep floors/ceilings
|
||||||
{
|
// from moving thru each other
|
||||||
m_Sector->ceilingplane.setD(lastpos);
|
|
||||||
P_ChangeSector (m_Sector, crush, move, 1, true);
|
lastpos = m_Sector->ceilingplane.fD();
|
||||||
MoveAttached(crush, move, 1, false);
|
switch (direction)
|
||||||
}
|
{
|
||||||
else
|
case -1:
|
||||||
{
|
// DOWN
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
|
// jff 02/04/98 keep ceiling from moving thru floors
|
||||||
}
|
// [RH] not so easy with arbitrary planes
|
||||||
return pastdest;
|
//destheight = (dest > m_Sector->floorheight) ? dest : m_Sector->floorheight;
|
||||||
}
|
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
|
||||||
else
|
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.fD()))
|
||||||
{
|
{
|
||||||
if (!MoveAttached(crush, speed, 1, true)) return crushed;
|
dest = -m_Sector->floorplane.fD();
|
||||||
|
}
|
||||||
m_Sector->ceilingplane.setD(movedest);
|
movedest = m_Sector->ceilingplane.GetChangedHeight (-speed);
|
||||||
|
if (movedest <= dest)
|
||||||
flag = P_ChangeSector (m_Sector, crush, speed, 1, false);
|
{
|
||||||
if (flag)
|
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
|
||||||
{
|
|
||||||
m_Sector->ceilingplane.setD(lastpos);
|
if (!MoveAttached(crush, move, 1, true)) return crushed;
|
||||||
P_ChangeSector (m_Sector, crush, -speed, 1, true);
|
|
||||||
MoveAttached(crush, -speed, 1, false);
|
m_Sector->ceilingplane.setD(dest);
|
||||||
return crushed;
|
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
|
||||||
}
|
|
||||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
if (flag)
|
||||||
}
|
{
|
||||||
break;
|
m_Sector->ceilingplane.setD(lastpos);
|
||||||
|
P_ChangeSector (m_Sector, crush, -move, 1, true);
|
||||||
|
MoveAttached(crush, -move, 1, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
|
||||||
|
}
|
||||||
|
return pastdest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!MoveAttached(crush, -speed, 1, true)) return crushed;
|
||||||
|
|
||||||
|
m_Sector->ceilingplane.setD(movedest);
|
||||||
|
|
||||||
|
// COULD GET CRUSHED
|
||||||
|
flag = P_ChangeSector (m_Sector, crush, -speed, 1, false);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
if (crush >= 0 && !hexencrush)
|
||||||
|
{
|
||||||
|
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
||||||
|
return crushed;
|
||||||
|
}
|
||||||
|
m_Sector->ceilingplane.setD(lastpos);
|
||||||
|
P_ChangeSector (m_Sector, crush, speed, 1, true);
|
||||||
|
MoveAttached(crush, speed, 1, false);
|
||||||
|
return crushed;
|
||||||
|
}
|
||||||
|
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
// UP
|
||||||
|
movedest = m_Sector->ceilingplane.GetChangedHeight (speed);
|
||||||
|
if (movedest >= dest)
|
||||||
|
{
|
||||||
|
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
|
||||||
|
|
||||||
|
if (!MoveAttached(crush, move, 1, true)) return crushed;
|
||||||
|
|
||||||
|
m_Sector->ceilingplane.setD(dest);
|
||||||
|
|
||||||
|
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
m_Sector->ceilingplane.setD(lastpos);
|
||||||
|
P_ChangeSector (m_Sector, crush, move, 1, true);
|
||||||
|
MoveAttached(crush, move, 1, false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
|
||||||
|
}
|
||||||
|
return pastdest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!MoveAttached(crush, speed, 1, true)) return crushed;
|
||||||
|
|
||||||
|
m_Sector->ceilingplane.setD(movedest);
|
||||||
|
|
||||||
|
flag = P_ChangeSector (m_Sector, crush, speed, 1, false);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
m_Sector->ceilingplane.setD(lastpos);
|
||||||
|
P_ChangeSector (m_Sector, crush, -speed, 1, true);
|
||||||
|
MoveAttached(crush, -speed, 1, false);
|
||||||
|
return crushed;
|
||||||
|
}
|
||||||
|
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,28 +31,24 @@ protected:
|
||||||
TObjPtr<DInterpolation> interpolation;
|
TObjPtr<DInterpolation> interpolation;
|
||||||
private:
|
private:
|
||||||
bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed);
|
bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed);
|
||||||
EResult MovePlane (double speed, double dest, int crush, int floorOrCeiling, int direction, bool hexencrush);
|
|
||||||
protected:
|
protected:
|
||||||
DMover ();
|
DMover ();
|
||||||
void Serialize (FArchive &arc);
|
void Serialize (FArchive &arc);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
void StopInterpolation(bool force = false);
|
void StopInterpolation(bool force = false);
|
||||||
inline EResult MoveFloor (double speed, double dest, int crush, int direction, bool hexencrush)
|
EResult MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush);
|
||||||
|
EResult MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush);
|
||||||
|
|
||||||
|
inline EResult MoveFloor(double speed, double dest, int direction)
|
||||||
{
|
{
|
||||||
return MovePlane (speed, dest, crush, 0, direction, hexencrush);
|
return MoveFloor(speed, dest, -1, direction, false);
|
||||||
}
|
}
|
||||||
inline EResult MoveFloor (double speed, double dest, int direction)
|
|
||||||
|
inline EResult MoveCeiling(double speed, double dest, int direction)
|
||||||
{
|
{
|
||||||
return MovePlane (speed, dest, -1, 0, direction, false);
|
return MoveCeiling(speed, dest, -1, direction, false);
|
||||||
}
|
|
||||||
inline EResult MoveCeiling (double speed, double dest, int crush, int direction, bool hexencrush)
|
|
||||||
{
|
|
||||||
return MovePlane (speed, dest, crush, 1, direction, hexencrush);
|
|
||||||
}
|
|
||||||
inline EResult MoveCeiling (double speed, double dest, int direction)
|
|
||||||
{
|
|
||||||
return MovePlane (speed, dest, -1, 1, direction, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DMovingFloor : public DMover
|
class DMovingFloor : public DMover
|
||||||
|
|
Loading…
Reference in a new issue