- replaced all direct access to sector plane coefficients with wrapper functions.

This commit is contained in:
Christoph Oelckers 2016-03-29 12:40:41 +02:00
parent c7ae4688a3
commit 25f5e8449a
30 changed files with 247 additions and 246 deletions

View File

@ -168,7 +168,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
{
case 0:
// FLOOR
lastpos = m_Sector->floorplane.d;
lastpos = m_Sector->floorplane.fixD();
switch (direction)
{
case -1:
@ -180,11 +180,11 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
if (!MoveAttached(crush, move, 0, true)) return crushed;
m_Sector->floorplane.d = dest;
m_Sector->floorplane.setD(dest);
flag = P_ChangeSector (m_Sector, crush, move, 0, false);
if (flag)
{
m_Sector->floorplane.d = lastpos;
m_Sector->floorplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -move, 0, true);
MoveAttached(crush, -move, 0, false);
}
@ -199,12 +199,12 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
{
if (!MoveAttached(crush, -speed, 0, true)) return crushed;
m_Sector->floorplane.d = movedest;
m_Sector->floorplane.setD(movedest);
flag = P_ChangeSector (m_Sector, crush, -speed, 0, false);
if (flag)
{
m_Sector->floorplane.d = lastpos;
m_Sector->floorplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, speed, 0, true);
MoveAttached(crush, speed, 0, false);
return crushed;
@ -222,11 +222,10 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
// jff 02/04/98 keep floor from moving thru ceilings
// [RH] not so easy with arbitrary planes
//destheight = (dest < m_Sector->ceilingheight) ? dest : m_Sector->ceilingheight;
if ((m_Sector->ceilingplane.a | m_Sector->ceilingplane.b |
m_Sector->floorplane.a | m_Sector->floorplane.b) == 0 &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.d))
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.fixD()))
{
dest = -m_Sector->ceilingplane.d;
dest = -m_Sector->ceilingplane.fixD();
}
movedest = m_Sector->floorplane.GetChangedHeight (speed);
@ -237,12 +236,12 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
if (!MoveAttached(crush, move, 0, true)) return crushed;
m_Sector->floorplane.d = dest;
m_Sector->floorplane.setD(dest);
flag = P_ChangeSector (m_Sector, crush, move, 0, false);
if (flag)
{
m_Sector->floorplane.d = lastpos;
m_Sector->floorplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -move, 0, true);
MoveAttached(crush, -move, 0, false);
}
@ -257,7 +256,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
{
if (!MoveAttached(crush, speed, 0, true)) return crushed;
m_Sector->floorplane.d = movedest;
m_Sector->floorplane.setD(movedest);
// COULD GET CRUSHED
flag = P_ChangeSector (m_Sector, crush, speed, 0, false);
@ -269,7 +268,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
m_Sector->AdjustFloorClip ();
return crushed;
}
m_Sector->floorplane.d = lastpos;
m_Sector->floorplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -speed, 0, true);
MoveAttached(crush, -speed, 0, false);
return crushed;
@ -283,7 +282,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
case 1:
// CEILING
lastpos = m_Sector->ceilingplane.d;
lastpos = m_Sector->ceilingplane.fixD();
switch (direction)
{
case -1:
@ -291,11 +290,10 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
// jff 02/04/98 keep ceiling from moving thru floors
// [RH] not so easy with arbitrary planes
//destheight = (dest > m_Sector->floorheight) ? dest : m_Sector->floorheight;
if ((m_Sector->ceilingplane.a | m_Sector->ceilingplane.b |
m_Sector->floorplane.a | m_Sector->floorplane.b) == 0 &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.d))
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.fixD()))
{
dest = -m_Sector->floorplane.d;
dest = -m_Sector->floorplane.fixD();
}
movedest = m_Sector->ceilingplane.GetChangedHeight (-speed);
if (movedest <= dest)
@ -304,12 +302,12 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
if (!MoveAttached(crush, move, 1, true)) return crushed;
m_Sector->ceilingplane.d = dest;
m_Sector->ceilingplane.setD(dest);
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
if (flag)
{
m_Sector->ceilingplane.d = lastpos;
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -move, 1, true);
MoveAttached(crush, -move, 1, false);
}
@ -323,7 +321,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
{
if (!MoveAttached(crush, -speed, 1, true)) return crushed;
m_Sector->ceilingplane.d = movedest;
m_Sector->ceilingplane.setD(movedest);
// COULD GET CRUSHED
flag = P_ChangeSector (m_Sector, crush, -speed, 1, false);
@ -334,7 +332,7 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
return crushed;
}
m_Sector->ceilingplane.d = lastpos;
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, speed, 1, true);
MoveAttached(crush, speed, 1, false);
return crushed;
@ -352,12 +350,12 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
if (!MoveAttached(crush, move, 1, true)) return crushed;
m_Sector->ceilingplane.d = dest;
m_Sector->ceilingplane.setD(dest);
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
if (flag)
{
m_Sector->ceilingplane.d = lastpos;
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, move, 1, true);
MoveAttached(crush, move, 1, false);
}
@ -371,12 +369,12 @@ DMover::EResult DMover::MovePlane (fixed_t speed, fixed_t dest, int crush,
{
if (!MoveAttached(crush, speed, 1, true)) return crushed;
m_Sector->ceilingplane.d = movedest;
m_Sector->ceilingplane.setD(movedest);
flag = P_ChangeSector (m_Sector, crush, speed, 1, false);
if (flag)
{
m_Sector->ceilingplane.d = lastpos;
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -speed, 1, true);
MoveAttached(crush, -speed, 1, false);
return crushed;

View File

@ -1638,7 +1638,7 @@ public:
m_FloorDestDist = moveheight;
// Do not interpolate instant movement floors.
fixed_t movedist = abs(-sec->floorplane.d - moveheight);
fixed_t movedist = abs(-sec->floorplane.fixD() - moveheight);
if (m_Speed >= movedist)
{
StopInterpolation(true);
@ -1790,7 +1790,7 @@ public:
m_Direction=destheight>sec->GetPlaneTexZ(sector_t::ceiling)? 1:-1;
// Do not interpolate instant movement ceilings.
fixed_t movedist = abs(sec->ceilingplane.d - m_BottomHeight);
fixed_t movedist = abs(sec->ceilingplane.fixD() - m_BottomHeight);
if (m_Speed >= movedist)
{
StopInterpolation (true);

View File

@ -101,7 +101,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut)
fixed_t oldtheight = sec->floorplane.Zat0();
newheight = sec->FindLowestFloorSurrounding(&spot);
sec->floorplane.d = sec->floorplane.PointToDist (spot, newheight);
sec->floorplane.setD(sec->floorplane.PointToDist (spot, newheight));
fixed_t newtheight = sec->floorplane.Zat0();
sec->ChangePlaneTexZ(sector_t::floor, newtheight - oldtheight);
sec->CheckPortalPlane(sector_t::floor);

View File

@ -187,7 +187,7 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag
ffloor->top.vindex = ffloor->bottom.vindex = -1;
// The engine cannot handle sloped translucent floors. Sorry
if (ffloor->top.plane->a || ffloor->top.plane->b || ffloor->bottom.plane->a || ffloor->bottom.plane->b)
if (ffloor->top.plane->isSlope() || ffloor->bottom.plane->isSlope())
{
ffloor->alpha = OPAQUE;
ffloor->flags &= ~FF_ADDITIVETRANS;
@ -813,12 +813,12 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li
if (highestfloorplanes[0])
{
open.frontfloorplane = *highestfloorplanes[0];
if (open.frontfloorplane.c < 0) open.frontfloorplane.FlipVert();
if (open.frontfloorplane.fC() < 0) open.frontfloorplane.FlipVert();
}
if (highestfloorplanes[1])
{
open.backfloorplane = *highestfloorplanes[1];
if (open.backfloorplane.c < 0) open.backfloorplane.FlipVert();
if (open.backfloorplane.fC() < 0) open.backfloorplane.FlipVert();
}
}
@ -906,7 +906,7 @@ secplane_t P_FindFloorPlane(sector_t * sector, const DVector3 &pos)
if (rover->top.plane->ZatPoint(pos) == pos.Z)
{
retplane = *rover->top.plane;
if (retplane.c<0) retplane.FlipVert();
if (retplane.fC() < 0) retplane.FlipVert();
break;
}
}

View File

@ -1426,9 +1426,9 @@ DPlaneWatcher::DPlaneWatcher (AActor *it, line_t *line, int lineSide, bool ceili
{
plane = Sector->floorplane;
}
LastD = plane.d;
LastD = plane.fixD();
plane.ChangeHeight (height << FRACBITS);
WatchD = plane.d;
WatchD = plane.fixD();
}
else
{
@ -1458,11 +1458,11 @@ void DPlaneWatcher::Tick ()
if (bCeiling)
{
newd = Sector->ceilingplane.d;
newd = Sector->ceilingplane.fixD();
}
else
{
newd = Sector->floorplane.d;
newd = Sector->floorplane.fixD();
}
if ((LastD < WatchD && newd >= WatchD) ||

View File

@ -403,9 +403,7 @@ static void LoadSectors (sectortype *bsec)
sec->e = &sectors[0].e[i];
sec->SetPlaneTexZ(sector_t::floor, -(LittleLong(bsec->floorZ) << 8));
sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor);
sec->floorplane.c = FRACUNIT;
sec->floorplane.ic = FRACUNIT;
sec->floorplane.set(0, 0, -FRACUNIT, -sec->GetPlaneTexZ(sector_t::floor));
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->floorpicnum));
sec->SetTexture(sector_t::floor, TexMan.GetTexture (tnam, FTexture::TEX_Build));
sec->SetXScale(sector_t::floor, (bsec->floorstat & 8) ? FRACUNIT*2 : FRACUNIT);
@ -416,9 +414,7 @@ static void LoadSectors (sectortype *bsec)
sec->ChangeFlags(sector_t::floor, 0, PLANEF_ABSLIGHTING);
sec->SetPlaneTexZ(sector_t::ceiling, -(LittleLong(bsec->ceilingZ) << 8));
sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling);
sec->ceilingplane.c = -FRACUNIT;
sec->ceilingplane.ic = -FRACUNIT;
sec->ceilingplane.set(0, 0, -FRACUNIT, sec->GetPlaneTexZ(sector_t::ceiling));
mysnprintf (tnam, countof(tnam), "BTIL%04d", LittleShort(bsec->ceilingpicnum));
sec->SetTexture(sector_t::ceiling, TexMan.GetTexture (tnam, FTexture::TEX_Build));
if (bsec->ceilingstat & 1)
@ -826,17 +822,14 @@ static void CalcPlane (SlopeWork &slope, secplane_t &plane)
pt[1] = DVector3(slope.x[2] - slope.x[0], slope.y[0] - slope.y[2], (slope.z[2] - slope.z[0]) / 16);
pt[2] = (pt[0] ^ pt[1]).Unit();
if ((pt[2][2] < 0 && plane.c > 0) || (pt[2][2] > 0 && plane.c < 0))
if ((pt[2][2] < 0 && plane.fC() > 0) || (pt[2][2] > 0 && plane.fC() < 0))
{
pt[2] = -pt[2];
}
plane.a = FLOAT2FIXED(pt[2][0]);
plane.b = FLOAT2FIXED(pt[2][1]);
plane.c = FLOAT2FIXED(pt[2][2]);
plane.ic = DivScale32(1, plane.c);
plane.d = -TMulScale8
(plane.a, slope.x[0]<<4, plane.b, (-slope.y[0])<<4, plane.c, slope.z[0]);
plane.set(pt[2][0], pt[2][1], pt[2][2], 0.);
plane.setD(-TMulScale8
(plane.fixA(), slope.x[0]<<4, plane.fixB(), (-slope.y[0])<<4, plane.fixC(), slope.z[0]));
}
//==========================================================================

View File

@ -264,7 +264,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
{
case ceilCrushAndRaise:
case ceilCrushRaiseAndStay:
ceiling->m_TopHeight = sec->ceilingplane.d;
ceiling->m_TopHeight = sec->ceilingplane.fixD();
case ceilLowerAndCrush:
targheight = sec->FindHighestFloorPoint (&spot);
targheight += height;
@ -404,11 +404,11 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
if (ceiling->m_Direction < 0)
{
movedist = sec->ceilingplane.d - ceiling->m_BottomHeight;
movedist = sec->ceilingplane.fixD() - ceiling->m_BottomHeight;
}
else
{
movedist = ceiling->m_TopHeight - sec->ceilingplane.d;
movedist = ceiling->m_TopHeight - sec->ceilingplane.fixD();
}
if (ceiling->m_Speed >= movedist)
{

View File

@ -82,12 +82,12 @@ void DDoor::Tick ()
{
EResult res;
if (m_Sector->floorplane.d != m_OldFloorDist)
if (m_Sector->floorplane.fixD() != m_OldFloorDist)
{
if (!m_Sector->floordata || !m_Sector->floordata->IsKindOf(RUNTIME_CLASS(DPlat)) ||
!(barrier_cast<DPlat*>(m_Sector->floordata))->IsLift())
{
m_OldFloorDist = m_Sector->floorplane.d;
m_OldFloorDist = m_Sector->floorplane.fixD();
m_BotDist = m_Sector->ceilingplane.PointToDist (m_BotSpot,
m_Sector->floorplane.ZatPoint (m_BotSpot));
}
@ -140,10 +140,10 @@ void DDoor::Tick ()
res = MoveCeiling (m_Speed, m_BotDist, -1, m_Direction, false);
// killough 10/98: implement gradual lighting effects
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d)
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fixD())
{
EV_LightTurnOnPartway (m_LightTag,
FIXED2DBL(FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d, m_TopDist + m_Sector->floorplane.d)));
FIXED2DBL(FixedDiv (m_Sector->ceilingplane.fixD() + m_Sector->floorplane.fixD(), m_TopDist + m_Sector->floorplane.fixD())));
}
if (res == pastdest)
@ -186,10 +186,10 @@ void DDoor::Tick ()
res = MoveCeiling (m_Speed, m_TopDist, -1, m_Direction, false);
// killough 10/98: implement gradual lighting effects
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d)
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fixD())
{
EV_LightTurnOnPartway (m_LightTag,
FIXED2DBL(FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d, m_TopDist + m_Sector->floorplane.d)));
FIXED2DBL(FixedDiv (m_Sector->ceilingplane.fixD() + m_Sector->floorplane.fixD(), m_TopDist + m_Sector->floorplane.fixD())));
}
if (res == pastdest)
@ -376,12 +376,12 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
m_Direction = 1;
height = sec->FindLowestCeilingSurrounding (&spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4*FRACUNIT);
if (m_TopDist != sec->ceilingplane.d)
if (m_TopDist != sec->ceilingplane.fixD())
DoorSound (true);
break;
case doorCloseWaitOpen:
m_TopDist = sec->ceilingplane.d;
m_TopDist = sec->ceilingplane.fixD();
m_Direction = -1;
DoorSound (false);
break;
@ -397,8 +397,8 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
m_Type = DDoor::doorRaise;
height = sec->FindHighestFloorPoint (&m_BotSpot);
m_BotDist = sec->ceilingplane.PointToDist (m_BotSpot, height);
m_OldFloorDist = sec->floorplane.d;
m_TopDist = sec->ceilingplane.d;
m_OldFloorDist = sec->floorplane.fixD();
m_TopDist = sec->ceilingplane.fixD();
break;
}
@ -414,7 +414,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa
height = sec->FindLowestCeilingPoint(&m_BotSpot);
m_BotDist = sec->ceilingplane.PointToDist (m_BotSpot, height);
}
m_OldFloorDist = sec->floorplane.d;
m_OldFloorDist = sec->floorplane.fixD();
}
//============================================================================
@ -559,7 +559,7 @@ bool DAnimatedDoor::StartClosing ()
return false;
}
fixed_t topdist = m_Sector->ceilingplane.d;
fixed_t topdist = m_Sector->ceilingplane.fixD();
if (MoveCeiling (2048*FRACUNIT, m_BotDist, 0, -1, false) == crushed)
{
return false;
@ -722,7 +722,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay,
FTexture *tex = TexMan[picnum];
topdist = tex ? tex->GetScaledHeight() : 64;
topdist = m_Sector->ceilingplane.d - topdist * m_Sector->ceilingplane.c;
topdist = m_Sector->ceilingplane.fixD() - topdist * m_Sector->ceilingplane.fixC();
m_Status = Opening;
m_Speed = speed;
@ -733,7 +733,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay,
m_SetBlocking2 = !!(m_Line2->flags & ML_BLOCKING);
m_Line1->flags |= ML_BLOCKING;
m_Line2->flags |= ML_BLOCKING;
m_BotDist = m_Sector->ceilingplane.d;
m_BotDist = m_Sector->ceilingplane.fixD();
MoveCeiling (2048*FRACUNIT, topdist, 1);
if (m_DoorAnim->OpenSound != NAME_None)
{

View File

@ -312,7 +312,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
floor->m_Hexencrush = hexencrush;
floor->m_Speed = speed;
floor->m_ResetCount = 0; // [RH]
floor->m_OrgDist = sec->floorplane.d; // [RH]
floor->m_OrgDist = sec->floorplane.fixD(); // [RH]
switch (floortype)
{
@ -322,7 +322,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
// [RH] DOOM's turboLower type did this. I've just extended it
// to be applicable to all LowerToHighest types.
if (hereticlower || floor->m_FloorDestDist != sec->floorplane.d)
if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fixD())
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight+height);
break;
@ -358,7 +358,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorMoveToValue:
sec->FindHighestFloorPoint (&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, height);
floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.d) ? -1 : 1;
floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fixD()) ? -1 : 1;
break;
case DFloor::floorRaiseAndCrushDoom:
@ -475,9 +475,9 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
// Do not interpolate instant movement floors.
bool silent = false;
if ((floor->m_Direction>0 && floor->m_FloorDestDist>sec->floorplane.d) || // moving up but going down
(floor->m_Direction<0 && floor->m_FloorDestDist<sec->floorplane.d) || // moving down but going up
(floor->m_Speed >= abs(sec->floorplane.d - floor->m_FloorDestDist))) // moving in one step
if ((floor->m_Direction>0 && floor->m_FloorDestDist>sec->floorplane.fixD()) || // moving up but going down
(floor->m_Direction<0 && floor->m_FloorDestDist<sec->floorplane.fixD()) || // moving down but going up
(floor->m_Speed >= abs(sec->floorplane.fixD() - floor->m_FloorDestDist))) // moving in one step
{
floor->StopInterpolation(true);
@ -609,7 +609,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
stairstep = stairsize * floor->m_Direction;
floor->m_Type = DFloor::buildStair; //jff 3/31/98 do not leave uninited
floor->m_ResetCount = reset; // [RH] Tics until reset (0 if never)
floor->m_OrgDist = sec->floorplane.d; // [RH] Height to reset to
floor->m_OrgDist = sec->floorplane.fixD(); // [RH] Height to reset to
// [RH] Set up delay values
floor->m_Delay = delay;
floor->m_PauseTime = 0;
@ -731,7 +731,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
floor->m_Crush = (!(usespecials & DFloor::stairUseSpecials) && speed == 4*FRACUNIT) ? 10 : -1; //jff 2/27/98 fix uninitialized crush field
floor->m_Hexencrush = false;
floor->m_ResetCount = reset; // [RH] Tics until reset (0 if never)
floor->m_OrgDist = sec->floorplane.d; // [RH] Height to reset to
floor->m_OrgDist = sec->floorplane.fixD(); // [RH] Height to reset to
}
} while (ok);
// [RH] make sure the first sector doesn't point to a previous one, otherwise
@ -902,8 +902,8 @@ void DElevator::Tick ()
fixed_t oldfloor, oldceiling;
oldfloor = m_Sector->floorplane.d;
oldceiling = m_Sector->ceilingplane.d;
oldfloor = m_Sector->floorplane.fixD();
oldceiling = m_Sector->ceilingplane.fixD();
if (m_Direction < 0) // moving down
{
@ -1031,7 +1031,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (line->v1, newheight);
elevator->m_Direction =
elevator->m_FloorDestDist > sec->floorplane.d ? -1 : 1;
elevator->m_FloorDestDist > sec->floorplane.fixD() ? -1 : 1;
break;
// [RH] elevate up by a specific amount
@ -1204,9 +1204,9 @@ void DWaggleBase::DoWaggle (bool ceiling)
case WGLSTATE_REDUCE:
if ((m_Scale -= m_ScaleDelta) <= 0)
{ // Remove
dist = FixedMul (m_OriginalDist - plane->d, plane->ic);
dist = FixedDiv (m_OriginalDist - plane->fixD(), plane->fixC());
m_Sector->ChangePlaneTexZ(pos, -plane->HeightDiff (m_OriginalDist));
plane->d = m_OriginalDist;
plane->setD(m_OriginalDist);
P_ChangeSector (m_Sector, true, dist, ceiling, false);
if (ceiling)
{
@ -1236,8 +1236,8 @@ void DWaggleBase::DoWaggle (bool ceiling)
fixed_t mag = finesine[(m_Accumulator>>9)&8191]*8;
dist = plane->d;
plane->d = m_OriginalDist + plane->PointToDist (0, 0, FixedMul (mag, m_Scale));
dist = plane->fixD();
plane->setD(m_OriginalDist + plane->PointToDist (0, 0, FixedMul (mag, m_Scale)));
m_Sector->ChangePlaneTexZ(pos, plane->HeightDiff (dist));
dist = plane->HeightDiff (dist);
@ -1322,12 +1322,12 @@ bool EV_StartWaggle (int tag, line_t *line, int height, int speed, int offset,
if (ceiling)
{
waggle = new DCeilingWaggle (sector);
waggle->m_OriginalDist = sector->ceilingplane.d;
waggle->m_OriginalDist = sector->ceilingplane.fixD();
}
else
{
waggle = new DFloorWaggle (sector);
waggle->m_OriginalDist = sector->floorplane.d;
waggle->m_OriginalDist = sector->floorplane.fixD();
}
waggle->m_Accumulator = offset*FRACUNIT;
waggle->m_AccDelta = speed << (FRACBITS-6);

View File

@ -101,8 +101,7 @@ static bool MoveCeiling(sector_t *sector, int crush, fixed_t move)
if (P_ChangeSector(sector, crush, move, 1, true)) return false;
// Don't let the ceiling go below the floor
if ((sector->ceilingplane.a | sector->ceilingplane.b |
sector->floorplane.a | sector->floorplane.b) == 0 &&
if (!sector->ceilingplane.isSlope() && !sector->floorplane.isSlope() &&
sector->GetPlaneTexZ(sector_t::floor) > sector->GetPlaneTexZ(sector_t::ceiling)) return false;
return true;
@ -116,8 +115,7 @@ static bool MoveFloor(sector_t *sector, int crush, fixed_t move)
if (P_ChangeSector(sector, crush, move, 0, true)) return false;
// Don't let the floor go above the ceiling
if ((sector->ceilingplane.a | sector->ceilingplane.b |
sector->floorplane.a | sector->floorplane.b) == 0 &&
if (!sector->ceilingplane.isSlope() && !sector->floorplane.isSlope() &&
sector->GetPlaneTexZ(sector_t::floor) > sector->GetPlaneTexZ(sector_t::ceiling)) return false;
return true;

View File

@ -45,7 +45,7 @@ struct FTranslatedLineTarget;
#include <stdlib.h>
#define STEEPSLOPE 46342 // [RH] Minimum floorplane.c value for walking
#define STEEPSLOPE 46342 // [RH] Minimum floorplane.fixC() value for walking
#define BONUSADD 6

View File

@ -808,7 +808,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
if (!(tm.thing->flags & MF_DROPOFF) &&
!(tm.thing->flags & (MF_NOGRAVITY | MF_NOCLIP)))
{
if ((open.frontfloorplane.c < STEEPSLOPE) != (open.backfloorplane.c < STEEPSLOPE))
if ((open.frontfloorplane.fixC() < STEEPSLOPE) != (open.backfloorplane.fixC() < STEEPSLOPE))
{
// on the boundary of a steep slope
return false;
@ -2901,7 +2901,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
if (thisplanez > planezhere && thisplanez <= actor->Z() + actor->MaxStepHeight)
{
copyplane = *rover->top.plane;
if (copyplane.c < 0) copyplane.FlipVert();
if (copyplane.fC() < 0) copyplane.FlipVert();
plane = &copyplane;
planezhere = thisplanez;
}
@ -2918,7 +2918,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
if (thisplanez > planezhere && thisplanez <= actor->Z() + actor->MaxStepHeight)
{
copyplane = *rover->top.plane;
if (copyplane.c < 0) copyplane.FlipVert();
if (copyplane.fC() < 0) copyplane.FlipVert();
plane = &copyplane;
planezhere = thisplanez;
}
@ -2947,7 +2947,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
if (t < 0)
{ // Desired location is behind (below) the plane
// (i.e. Walking up the plane)
if (plane->c < STEEPSLOPE)
if (plane->fixC() < STEEPSLOPE)
{ // Can't climb up slopes of ~45 degrees or more
if (actor->flags & MF_NOCLIP)
{
@ -2958,12 +2958,12 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move)
const msecnode_t *node;
bool dopush = true;
if (plane->c > STEEPSLOPE * 2 / 3)
if (plane->fixC() > STEEPSLOPE * 2 / 3)
{
for (node = actor->touching_sectorlist; node; node = node->m_tnext)
{
sector_t *sec = node->m_sector;
if (sec->floorplane.c >= STEEPSLOPE)
if (sec->floorplane.fixC() >= STEEPSLOPE)
{
DVector3 pos = actor->PosRelative(sec) +move;

View File

@ -218,9 +218,9 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, co
}
else
{
if ((front->floorplane.a | front->floorplane.b) == 0)
if (!front->floorplane.isSlope())
usefront = true;
else if ((back->floorplane.a | front->floorplane.b) == 0)
else if (!back->floorplane.isSlope())
usefront = false;
else
usefront = !P_PointOnLineSide (*ref, linedef);

View File

@ -1530,7 +1530,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane)
}
}
if (plane.c < 0)
if (plane.fC() < 0)
{ // on ceiling
if (!(BounceFlags & BOUNCE_Ceilings))
return true;
@ -1582,7 +1582,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane)
FState *bouncestate;
names[0] = NAME_Bounce;
names[1] = plane.c < 0 ? NAME_Ceiling : NAME_Floor;
names[1] = plane.fC() < 0 ? NAME_Ceiling : NAME_Floor;
bouncestate = FindState(2, names);
if (bouncestate != NULL)
{
@ -1597,7 +1597,7 @@ bool AActor::FloorBounceMissile (secplane_t &plane)
}
else if (BounceFlags & (BOUNCE_AutoOff|BOUNCE_AutoOffFloorOnly))
{
if (plane.c > 0 || (BounceFlags & BOUNCE_AutoOff))
if (plane.fC() > 0 || (BounceFlags & BOUNCE_AutoOff))
{
// AutoOff only works when bouncing off a floor, not a ceiling (or in compatibility mode.)
if (!(flags & MF_NOGRAVITY) && (Vel.Z < 3))
@ -3644,18 +3644,18 @@ void AActor::Tick ()
// Check 3D floors as well
floorplane = P_FindFloorPlane(floorsector, PosAtZ(floorz));
if (floorplane.c < STEEPSLOPE &&
if (floorplane.fixC() < STEEPSLOPE &&
floorplane.ZatPoint (PosRelative(floorsector)) <= floorz)
{
const msecnode_t *node;
bool dopush = true;
if (floorplane.c > STEEPSLOPE*2/3)
if (floorplane.fixC() > STEEPSLOPE*2/3)
{
for (node = touching_sectorlist; node; node = node->m_tnext)
{
const sector_t *sec = node->m_sector;
if (sec->floorplane.c >= STEEPSLOPE)
if (sec->floorplane.fixC() >= STEEPSLOPE)
{
if (floorplane.ZatPoint(PosRelative(node->m_sector)) >= Z() - MaxStepHeight)
{

View File

@ -91,8 +91,8 @@ void DPillar::Tick ()
int r, s;
fixed_t oldfloor, oldceiling;
oldfloor = m_Sector->floorplane.d;
oldceiling = m_Sector->ceilingplane.d;
oldfloor = m_Sector->floorplane.fixD();
oldceiling = m_Sector->ceilingplane.fixD();
if (m_Type == pillarBuild)
{

View File

@ -198,7 +198,7 @@ void DPlat::Tick ()
case waiting:
if (m_Count > 0 && !--m_Count)
{
if (m_Sector->floorplane.d == m_Low)
if (m_Sector->floorplane.fixD() == m_Low)
m_Status = up;
else
m_Status = down;
@ -277,7 +277,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
//jff 1/26/98 Avoid raise plat bouncing a head off a ceiling and then
//going down forever -- default lower to plat height when triggered
plat->m_Low = sec->floorplane.d;
plat->m_Low = sec->floorplane.fixD();
if (change)
{
@ -292,7 +292,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
case DPlat::platRaiseAndStayLockout:
newheight = sec->FindNextHighestFloor (&spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.d;
plat->m_Low = sec->floorplane.fixD();
plat->m_Status = DPlat::up;
plat->PlayPlatSound ("Floor");
sec->ClearSpecial();
@ -302,7 +302,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
case DPlat::platUpByValueStay:
newheight = sec->floorplane.ZatPoint (0, 0) + height;
plat->m_High = sec->floorplane.PointToDist (0, 0, newheight);
plat->m_Low = sec->floorplane.d;
plat->m_Low = sec->floorplane.fixD();
plat->m_Status = DPlat::up;
plat->PlayPlatSound ("Floor");
break;
@ -310,7 +310,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
case DPlat::platDownByValue:
newheight = sec->floorplane.ZatPoint (0, 0) - height;
plat->m_Low = sec->floorplane.PointToDist (0, 0, newheight);
plat->m_High = sec->floorplane.d;
plat->m_High = sec->floorplane.fixD();
plat->m_Status = DPlat::down;
plat->PlayPlatSound ("Floor");
break;
@ -320,10 +320,10 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
newheight = sec->FindLowestFloorSurrounding (&spot) + lip*FRACUNIT;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.d)
plat->m_Low = sec->floorplane.d;
if (plat->m_Low < sec->floorplane.fixD())
plat->m_Low = sec->floorplane.fixD();
plat->m_High = sec->floorplane.d;
plat->m_High = sec->floorplane.fixD();
plat->m_Status = DPlat::down;
plat->PlayPlatSound (type == DPlat::platDownWaitUpStay ? "Platform" : "Floor");
break;
@ -338,10 +338,10 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
newheight = sec->FindHighestFloorSurrounding (&spot);
}
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.d;
plat->m_Low = sec->floorplane.fixD();
if (plat->m_High > sec->floorplane.d)
plat->m_High = sec->floorplane.d;
if (plat->m_High > sec->floorplane.fixD())
plat->m_High = sec->floorplane.fixD();
plat->m_Status = DPlat::up;
plat->PlayPlatSound ("Platform");
@ -351,14 +351,14 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
newheight = sec->FindLowestFloorSurrounding (&spot) + lip*FRACUNIT;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.d)
plat->m_Low = sec->floorplane.d;
if (plat->m_Low < sec->floorplane.fixD())
plat->m_Low = sec->floorplane.fixD();
newheight = sec->FindHighestFloorSurrounding (&spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_High > sec->floorplane.d)
plat->m_High = sec->floorplane.d;
if (plat->m_High > sec->floorplane.fixD())
plat->m_High = sec->floorplane.fixD();
plat->m_Status = pr_doplat() & 1 ? DPlat::up : DPlat::down;
@ -371,7 +371,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
// set up toggling between ceiling, floor inclusive
newheight = sec->FindLowestCeilingPoint (&spot);
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.d;
plat->m_High = sec->floorplane.fixD();
plat->m_Status = DPlat::down;
SN_StartSequence (sec, CHAN_FLOOR, "Silence", 0);
break;
@ -380,17 +380,17 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, int height,
newheight = sec->FindNextLowestFloor (&spot) + lip*FRACUNIT;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_Status = DPlat::down;
plat->m_High = sec->floorplane.d;
plat->m_High = sec->floorplane.fixD();
plat->PlayPlatSound ("Platform");
break;
case DPlat::platDownToLowestCeiling:
newheight = sec->FindLowestCeilingSurrounding (&spot);
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.d;
plat->m_High = sec->floorplane.fixD();
if (plat->m_Low < sec->floorplane.d)
plat->m_Low = sec->floorplane.d;
if (plat->m_Low < sec->floorplane.fixD())
plat->m_Low = sec->floorplane.fixD();
plat->m_Status = DPlat::down;
plat->PlayPlatSound ("Platform");

View File

@ -279,7 +279,7 @@ void DPusher::Tick ()
continue;
sector_t *hsec = sec->GetHeightSec();
fixedvec3 pos = thing->_f_PosRelative(sec);
DVector3 pos = thing->PosRelative(sec);
DVector2 pushvel;
if (m_Type == p_wind)
{
@ -296,7 +296,7 @@ void DPusher::Tick ()
}
else // special water sector
{
ht = hsec->floorplane.ZatPointF(pos);
ht = hsec->floorplane.ZatPoint(pos);
if (thing->Z() > ht) // above ground
{
pushvel = m_PushVec; // full force
@ -323,7 +323,7 @@ void DPusher::Tick ()
{ // special water sector
floor = &hsec->floorplane;
}
if (thing->Z() > floor->ZatPointF(pos))
if (thing->Z() > floor->ZatPoint(pos))
{ // above ground
pushvel.Zero(); // no force
}

View File

@ -617,14 +617,14 @@ fixed_t sector_t::FindHighestFloorPoint (vertex_t **v) const
fixed_t probeheight;
vertex_t *spot = NULL;
if ((floorplane.a | floorplane.b) == 0)
if (!floorplane.isSlope())
{
if (v != NULL)
{
if (linecount == 0) *v = &vertexes[0];
else *v = lines[0]->v1;
}
return -floorplane.d;
return floorplane.Zat0();
}
for (i = 0; i < linecount; i++)
@ -659,14 +659,14 @@ fixed_t sector_t::FindLowestCeilingPoint (vertex_t **v) const
fixed_t probeheight;
vertex_t *spot = NULL;
if ((ceilingplane.a | ceilingplane.b) == 0)
if (!ceilingplane.isSlope())
{
if (v != NULL)
{
if (linecount == 0) *v = &vertexes[0];
else *v = lines[0]->v1;
}
return ceilingplane.d;
return ceilingplane.fixD();
}
for (i = 0; i < linecount; i++)

View File

@ -1509,13 +1509,9 @@ void P_LoadSectors (MapData *map, FMissingTextureTracker &missingtex)
ss->e = &sectors[0].e[i];
if (!map->HasBehavior) ss->Flags |= SECF_FLOORDROP;
ss->SetPlaneTexZ(sector_t::floor, LittleShort(ms->floorheight)<<FRACBITS);
ss->floorplane.d = -ss->GetPlaneTexZ(sector_t::floor);
ss->floorplane.c = FRACUNIT;
ss->floorplane.ic = FRACUNIT;
ss->floorplane.set(0, 0, FRACUNIT, -ss->GetPlaneTexZ(sector_t::floor));
ss->SetPlaneTexZ(sector_t::ceiling, LittleShort(ms->ceilingheight)<<FRACBITS);
ss->ceilingplane.d = ss->GetPlaneTexZ(sector_t::ceiling);
ss->ceilingplane.c = -FRACUNIT;
ss->ceilingplane.ic = -FRACUNIT;
ss->ceilingplane.set(0, 0, -FRACUNIT, ss->GetPlaneTexZ(sector_t::ceiling));
SetTexture(ss, i, sector_t::floor, ms->floorpic, missingtex, true);
SetTexture(ss, i, sector_t::ceiling, ms->ceilingpic, missingtex, true);
ss->lightlevel = LittleShort(ms->lightlevel);

View File

@ -103,14 +103,10 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo
cross = -cross;
}
plane->a = FLOAT2FIXED (cross[0]);
plane->b = FLOAT2FIXED (cross[1]);
plane->c = FLOAT2FIXED (cross[2]);
//plane->ic = FLOAT2FIXED (1.f/cross[2]);
plane->ic = DivScale32 (1, plane->c);
plane->d = -TMulScale16 (plane->a, x,
plane->b, y,
plane->c, z);
plane->set(cross[0], cross[1], cross[2], 0.);
plane->setD(-TMulScale16 (plane->fixA(), x,
plane->fixB(), y,
plane->fixC(), z));
}
}
@ -203,14 +199,8 @@ void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi,
}
norm[2] = double(finesine[zang]) * 65536.f;
norm.MakeUnit();
plane->a = FLOAT2FIXED(norm[0]);
plane->b = FLOAT2FIXED(norm[1]);
plane->c = FLOAT2FIXED(norm[2]);
//plane->ic = (int)(65536.f / norm[2]);
plane->ic = DivScale32 (1, plane->c);
plane->d = -TMulScale16 (plane->a, x,
plane->b, y,
plane->c, z);
plane->set(norm[0], norm[1], norm[2], 0.);
plane->setD(-TMulScale16(plane->fixA(), x, plane->fixB(), y, plane->fixC(), z));
}
@ -255,15 +245,8 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int
cross = -cross;
}
srcplane->a = FLOAT2FIXED (cross[0]);
srcplane->b = FLOAT2FIXED (cross[1]);
srcplane->c = FLOAT2FIXED (cross[2]);
//plane->ic = FLOAT2FIXED (1.f/cross[2]);
srcplane->ic = DivScale32 (1, srcplane->c);
srcplane->d = -TMulScale16 (srcplane->a, x,
srcplane->b, y,
srcplane->c, z);
srcplane->set(cross[0], cross[1], cross[2], 0.);
srcplane->setD(-TMulScale16(srcplane->fixA(), x, srcplane->fixB(), y, srcplane->fixC(), z));
return;
}
}
@ -388,15 +371,12 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt,
cross = -cross;
}
secplane_t *srcplane = j==0? &sec->floorplane : &sec->ceilingplane;
secplane_t *plane = j==0? &sec->floorplane : &sec->ceilingplane;
srcplane->a = FLOAT2FIXED (cross[0]);
srcplane->b = FLOAT2FIXED (cross[1]);
srcplane->c = FLOAT2FIXED (cross[2]);
srcplane->ic = DivScale32 (1, srcplane->c);
srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].fixX(),
srcplane->b, vertexes[vi3].fixY(),
srcplane->c, FLOAT2FIXED(vt3.Z));
plane->set(cross[0], cross[1], cross[2], 0.);
plane->setD(-TMulScale16 (plane->fixA(), vertexes[vi3].fixX(),
plane->fixB(), vertexes[vi3].fixY(),
plane->fixC(), FLOAT2FIXED(vt3.Z)));
}
}
}
@ -546,14 +526,10 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which)
cross = -cross;
}
srcplane->a = FLOAT2FIXED (cross[0]);
srcplane->b = FLOAT2FIXED (cross[1]);
srcplane->c = FLOAT2FIXED (cross[2]);
//srcplane->ic = FLOAT2FIXED (1.f/cross[2]);
srcplane->ic = DivScale32 (1, srcplane->c);
srcplane->d = -TMulScale16 (srcplane->a, line->v1->fixX(),
srcplane->b, line->v1->fixY(),
srcplane->c, destheight);
srcplane->set(cross[0], cross[1], cross[2], 0.);
srcplane->setD(-TMulScale16 (srcplane->fixA(), line->v1->fixX(),
srcplane->fixB(), line->v1->fixY(),
srcplane->fixC(), destheight));
}
//===========================================================================

View File

@ -930,13 +930,13 @@ bool FTraceInfo::TraceTraverse (int ptflags)
bool FTraceInfo::CheckPlane (const secplane_t &plane)
{
fixed_t den = TMulScale16 (plane.a, Vx, plane.b, Vy, plane.c, Vz);
fixed_t den = TMulScale16 (plane.fixA(), Vx, plane.fixB(), Vy, plane.fixC(), Vz);
if (den != 0)
{
fixed_t num = TMulScale16 (plane.a, StartX,
plane.b, StartY,
plane.c, StartZ) + plane.d;
fixed_t num = TMulScale16 (plane.fixA(), StartX,
plane.fixB(), StartY,
plane.fixC(), StartZ) + plane.fixD();
fixed_t hitdist = FixedDiv (-num, den);

View File

@ -1600,39 +1600,22 @@ public:
// Reset the planes to their defaults if not all of the plane equation's parameters were found.
if (fplaneflags != 15)
{
sec->floorplane.a = sec->floorplane.b = 0;
sec->floorplane.d = -sec->GetPlaneTexZ(sector_t::floor);
sec->floorplane.c = FRACUNIT;
sec->floorplane.ic = FRACUNIT;
sec->floorplane.set(0, 0, FRACUNIT, -sec->GetPlaneTexZ(sector_t::floor));
}
else
{
double ulen = DVector3(fp[0], fp[1], fp[2]).Length();
// normalize the vector, it must have a length of 1
sec->floorplane.a = FLOAT2FIXED(fp[0] / ulen);
sec->floorplane.b = FLOAT2FIXED(fp[1] / ulen);
sec->floorplane.c = FLOAT2FIXED(fp[2] / ulen);
sec->floorplane.d = FLOAT2FIXED(fp[3] / ulen);
sec->floorplane.ic = FLOAT2FIXED(ulen / fp[2]);
DVector3 n = DVector3(fp[0], fp[1], fp[2]).Unit();
sec->floorplane.set(n.X, n.Y, n.Z, fp[3]);
}
if (cplaneflags != 15)
{
sec->ceilingplane.a = sec->ceilingplane.b = 0;
sec->ceilingplane.d = sec->GetPlaneTexZ(sector_t::ceiling);
sec->ceilingplane.c = -FRACUNIT;
sec->ceilingplane.ic = -FRACUNIT;
sec->ceilingplane.set(0, 0, -FRACUNIT, sec->GetPlaneTexZ(sector_t::ceiling));
}
else
{
double ulen = DVector3(cp[0], cp[1], cp[2]).Length();
// normalize the vector, it must have a length of 1
sec->ceilingplane.a = FLOAT2FIXED(cp[0] / ulen);
sec->ceilingplane.b = FLOAT2FIXED(cp[1] / ulen);
sec->ceilingplane.c = FLOAT2FIXED(cp[2] / ulen);
sec->ceilingplane.d = FLOAT2FIXED(cp[3] / ulen);
sec->ceilingplane.ic = FLOAT2FIXED(ulen / cp[2]);
DVector3 n = DVector3(cp[0], cp[1], cp[2]).Unit();
sec->ceilingplane.set(n.X, n.Y, n.Z, cp[3]);
}
if (lightcolor == -1 && fadecolor == -1 && desaturation == -1)

View File

@ -968,7 +968,7 @@ void P_CreateLinkedPortals()
if (box != NULL && box->special1 == SKYBOX_LINKEDPORTAL)
{
secplane_t &plane = j == 0 ? sectors[i].floorplane : sectors[i].ceilingplane;
if (plane.a || plane.b)
if (plane.isSlope())
{
// The engine cannot deal with portals on a sloped plane.
sectors[i].SkyBoxes[j] = NULL;

View File

@ -1168,7 +1168,7 @@ void R_Subsector (subsector_t *sub)
fakeFloor = frontsector->e->XFloor.ffloors[i];
if (!(fakeFloor->flags & FF_EXISTS)) continue;
if (!fakeFloor->model) continue;
if (fakeFloor->bottom.plane->a || fakeFloor->bottom.plane->b) continue;
if (fakeFloor->bottom.plane->isSlope()) continue;
if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES|FF_RENDERSIDES)))
{
R_3D_AddHeight(fakeFloor->top.plane, frontsector);
@ -1229,7 +1229,7 @@ void R_Subsector (subsector_t *sub)
fakeFloor = frontsector->e->XFloor.ffloors[i];
if (!(fakeFloor->flags & FF_EXISTS)) continue;
if (!fakeFloor->model) continue;
if (fakeFloor->top.plane->a || fakeFloor->top.plane->b) continue;
if (fakeFloor->top.plane->isSlope()) continue;
if (!(fakeFloor->flags & FF_NOSHADE) || (fakeFloor->flags & (FF_RENDERPLANES|FF_RENDERSIDES)))
{
R_3D_AddHeight(fakeFloor->bottom.plane, frontsector);

View File

@ -440,12 +440,12 @@ void DSectorPlaneInterpolation::UpdateInterpolation()
{
if (!ceiling)
{
oldheight = sector->floorplane.d;
oldheight = sector->floorplane.fixD();
oldtexz = sector->GetPlaneTexZ(sector_t::floor);
}
else
{
oldheight = sector->ceilingplane.d;
oldheight = sector->ceilingplane.fixD();
oldtexz = sector->GetPlaneTexZ(sector_t::ceiling);
}
}
@ -460,12 +460,12 @@ void DSectorPlaneInterpolation::Restore()
{
if (!ceiling)
{
sector->floorplane.d = bakheight;
sector->floorplane.setD(bakheight);
sector->SetPlaneTexZ(sector_t::floor, baktexz);
}
else
{
sector->ceilingplane.d = bakheight;
sector->ceilingplane.setD(bakheight);
sector->SetPlaneTexZ(sector_t::ceiling, baktexz);
}
P_RecalculateAttached3DFloors(sector);
@ -480,21 +480,21 @@ void DSectorPlaneInterpolation::Restore()
void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio)
{
fixed_t *pheight;
secplane_t *pplane;
int pos;
if (!ceiling)
{
pheight = &sector->floorplane.d;
pplane = &sector->floorplane;
pos = sector_t::floor;
}
else
{
pheight = &sector->ceilingplane.d;
pplane = &sector->ceilingplane;
pos = sector_t::ceiling;
}
bakheight = *pheight;
bakheight = pplane->fixD();
baktexz = sector->GetPlaneTexZ(pos);
if (refcount == 0 && oldheight == bakheight)
@ -503,7 +503,7 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio)
}
else
{
*pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio);
pplane->setD(oldheight + FixedMul(bakheight - oldheight, smoothratio));
sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio));
P_RecalculateAttached3DFloors(sector);
sector->CheckPortalPlane(pos);

View File

@ -274,26 +274,88 @@ class ASkyViewpoint;
struct secplane_t
{
friend FArchive &operator<< (FArchive &arc, secplane_t &plane);
// the plane is defined as a*x + b*y + c*z + d = 0
// ic is 1/c, for faster Z calculations
private:
fixed_t a, b, c, d, ic;
public:
void set(fixed_t aa, fixed_t bb, fixed_t cc, fixed_t dd)
{
a = aa;
b = bb;
c = cc;
d = dd;
ic = FixedDiv(FRACUNIT, c);
}
void set(double aa, double bb, double cc, double dd)
{
a = FLOAT2FIXED(aa);
b = FLOAT2FIXED(bb);
c = FLOAT2FIXED(cc);
d = FLOAT2FIXED(dd);
ic = FixedDiv(FRACUNIT, c);
}
void setD(fixed_t dd)
{
d = dd;
}
void changeD(fixed_t dd)
{
d += dd;
}
void setD(double dd)
{
d = FLOAT2FIXED(dd);
}
void changeD(double dd)
{
d += FLOAT2FIXED(dd);
}
fixed_t fixA() const
{
return a;
}
fixed_t fixB() const
{
return b;
}
fixed_t fixC() const
{
return c;
}
fixed_t fixD() const
{
return d;
}
fixed_t fixiC() const
{
return ic;
}
double fA() const
{
return FIXED2FLOAT(a);
return FIXED2DBL(a);
}
double fB() const
{
return FIXED2FLOAT(b);
return FIXED2DBL(b);
}
double fC() const
{
return FIXED2FLOAT(c);
return FIXED2DBL(c);
}
double fD() const
{
return FIXED2FLOAT(d);
return FIXED2DBL(d);
}
bool isSlope() const
@ -303,7 +365,7 @@ struct secplane_t
DVector3 Normal() const
{
return{ FIXED2FLOAT(a), FIXED2FLOAT(b), FIXED2FLOAT(c) };
return{ fA(), fB(), fC() };
}
// Returns < 0 : behind; == 0 : on; > 0 : in front

View File

@ -91,7 +91,7 @@ visplane_t *ceilingplane;
// Empirically verified to be fairly uniform:
#define visplane_hash(picnum,lightlevel,height) \
((unsigned)((picnum)*3+(lightlevel)+((height).d)*7) & (MAXVISPLANES-1))
((unsigned)((picnum)*3+(lightlevel)+((height).fixD())*7) & (MAXVISPLANES-1))
// These are copies of the main parameters used when drawing stacked sectors.
// When you change the main parameters, you should copy them here too *unless*
@ -601,13 +601,11 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
angle = 0;
alpha = 0;
additive = false;
plane.a = plane.b = plane.d = 0;
// [RH] Map floor skies and ceiling skies to separate visplanes. This isn't
// always necessary, but it is needed if a floor and ceiling sky are in the
// same column but separated by a wall. If they both try to reside in the
// same visplane, then only the floor sky will be drawn.
plane.c = height.c;
plane.ic = height.ic;
plane.set(0, 0, height.fixC(), 0);
isskybox = skybox != NULL && !skybox->bInSkybox;
}
else if (skybox != NULL && skybox->bAlways && !skybox->bInSkybox)
@ -1144,7 +1142,7 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
basecolormap = pl->colormap;
planeshade = LIGHT2SHADE(pl->lightlevel);
if (r_drawflat || ((pl->height.a == 0 && pl->height.b == 0) && !tilt))
if (r_drawflat || (!pl->height.isSlope() && !tilt))
{
R_DrawNormalPlane (pl, alpha, additive, masked);
}
@ -1566,7 +1564,7 @@ void R_DrawNormalPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
basexfrac = FixedMul (xscale, finecosine[planeang]) + x*xstepscale;
baseyfrac = FixedMul (yscale, -finesine[planeang]) + x*ystepscale;
planeheight = abs (FixedMul (pl->height.d, -pl->height.ic) - viewz);
planeheight = abs (FixedMul (pl->height.fixD(), -pl->height.fixiC()) - viewz);
GlobVis = FixedDiv (r_FloorVisibility, planeheight);
if (fixedlightlev >= 0)
@ -1722,7 +1720,7 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
planelightfloat = (r_TiltVisibility * lxscale * lyscale) / (fabs(pl->height.ZatPoint(FIXED2DBL(viewx), FIXED2DBL(viewy)) - FIXED2DBL(viewz))) / 65536.0;
if (pl->height.c > 0)
if (pl->height.fC() > 0)
planelightfloat = -planelightfloat;
if (fixedlightlev >= 0)

View File

@ -708,9 +708,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
// visible?
passed = 0;
if (!(rover->flags & FF_RENDERSIDES) ||
rover->top.plane->a || rover->top.plane->b ||
rover->bottom.plane->a || rover->bottom.plane->b ||
if (!(rover->flags & FF_RENDERSIDES) || rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
rover->top.plane->Zat0() <= sclipBottom ||
rover->bottom.plane->Zat0() >= ceilingheight ||
rover->top.plane->Zat0() <= floorheight)
@ -745,7 +743,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, it's bugged
if (fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
// visible?
if (fover->top.plane->Zat0() <= sclipBottom) continue; // no
@ -798,7 +796,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, it's bugged
if (fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
// visible?
if (fover->top.plane->Zat0() <= sclipBottom) continue; // no
@ -893,8 +891,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
// visible?
passed = 0;
if (!(rover->flags & FF_RENDERSIDES) ||
rover->top.plane->a || rover->top.plane->b ||
rover->bottom.plane->a || rover->bottom.plane->b ||
rover->top.plane->isSlope() || rover->bottom.plane->isSlope() ||
rover->bottom.plane->Zat0() >= sclipTop ||
rover->top.plane->Zat0() <= floorheight ||
rover->bottom.plane->Zat0() >= ceilingheight)
@ -923,7 +920,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, it's bugged
if (fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
// visible?
if (fover->bottom.plane->Zat0() >= sclipTop) continue; // no
@ -975,7 +972,7 @@ void R_RenderFakeWallRange (drawseg_t *ds, int x1, int x2)
if (!(fover->flags & FF_EXISTS)) continue;
if (!(fover->flags & FF_RENDERSIDES)) continue;
// no sloped walls, its bugged
if(fover->top.plane->a || fover->top.plane->b || fover->bottom.plane->a || fover->bottom.plane->b) continue;
if (fover->top.plane->isSlope() || fover->bottom.plane->isSlope()) continue;
// visible?
if (fover->bottom.plane->Zat0() >= sclipTop) continue; // no
@ -2269,7 +2266,7 @@ void R_NewWall (bool needlights)
int planeside;
planeside = frontsector->floorplane.PointOnSide(viewx, viewy, viewz);
if (frontsector->floorplane.c < 0) // 3D floors have the floor backwards
if (frontsector->floorplane.fixC() < 0) // 3D floors have the floor backwards
planeside = -planeside;
if (planeside <= 0) // above view plane
markfloor = false;
@ -2277,7 +2274,7 @@ void R_NewWall (bool needlights)
if (frontsector->GetTexture(sector_t::ceiling) != skyflatnum)
{
planeside = frontsector->ceilingplane.PointOnSide(viewx, viewy, viewz);
if (frontsector->ceilingplane.c > 0) // 3D floors have the ceiling backwards
if (frontsector->ceilingplane.fixC() > 0) // 3D floors have the ceiling backwards
planeside = -planeside;
if (planeside <= 0) // below view plane
markceiling = false;
@ -2767,9 +2764,9 @@ int OWallMost (short *mostbuf, fixed_t z, const FWallCoords *wallc)
int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc)
{
if ((plane.a | plane.b) == 0)
if (!plane.isSlope())
{
return OWallMost (mostbuf, ((plane.c < 0) ? plane.d : -plane.d) - viewz, wallc);
return OWallMost (mostbuf, plane.Zat0() - viewz, wallc);
}
fixed_t x, y, den, z1, z2, oz1, oz2;

View File

@ -1254,12 +1254,12 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside)
if(!(rover->flags & FF_SOLID) || rover->alpha != 255) continue;
if(!fakefloor)
{
if(!(rover->top.plane->a) && !(rover->top.plane->b))
if(!rover->top.plane->isSlope())
{
if(rover->top.plane->Zat0() <= thing->_f_Z()) fakefloor = rover;
}
}
if(!(rover->bottom.plane->a) && !(rover->bottom.plane->b))
if(!rover->bottom.plane->isSlope())
{
if(rover->bottom.plane->Zat0() >= thing->_f_Top()) fakeceiling = rover;
}

View File

@ -1107,7 +1107,7 @@ void R_SetupFrame (AActor *actor)
viewside = plane->PointOnSide(viewx, viewy, viewz);
// Reverse the direction of the test if the plane was downward facing.
// We want to know if the view is above it, whatever its orientation may be.
if (plane->c < 0)
if (plane->fC() < 0)
viewside = -viewside;
if (viewside > 0)
{