- more direct native functions for sector utilities.

This commit is contained in:
Christoph Oelckers 2018-11-29 17:38:58 +01:00
parent e3c13fe193
commit 62efe11a85
8 changed files with 128 additions and 127 deletions

View file

@ -264,7 +264,7 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break;
case DCeiling::ceilRaiseToHighest:
targheight = sec->FindHighestCeilingSurrounding (&spot);
targheight = FindHighestCeilingSurrounding (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1;
break;
@ -300,13 +300,13 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break;
case DCeiling::ceilLowerToHighestFloor:
targheight = sec->FindHighestFloorSurrounding (&spot) + height;
targheight = FindHighestFloorSurrounding (sec, &spot) + height;
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1;
break;
case DCeiling::ceilRaiseToHighestFloor:
targheight = sec->FindHighestFloorSurrounding (&spot);
targheight = FindHighestFloorSurrounding (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1;
break;
@ -326,25 +326,25 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break;
case DCeiling::ceilLowerToNearest:
targheight = sec->FindNextLowestCeiling (&spot);
targheight = FindNextLowestCeiling (sec, &spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1;
break;
case DCeiling::ceilRaiseToNearest:
targheight = sec->FindNextHighestCeiling (&spot);
targheight = FindNextHighestCeiling (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1;
break;
case DCeiling::ceilLowerToLowest:
targheight = sec->FindLowestCeilingSurrounding (&spot);
targheight = FindLowestCeilingSurrounding (sec, &spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1;
break;
case DCeiling::ceilRaiseToLowest:
targheight = sec->FindLowestCeilingSurrounding (&spot);
targheight = FindLowestCeilingSurrounding (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1;
break;
@ -362,7 +362,7 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break;
case DCeiling::ceilLowerToHighest:
targheight = sec->FindHighestCeilingSurrounding (&spot);
targheight = FindHighestCeilingSurrounding (sec, &spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1;
break;

View file

@ -359,7 +359,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag
{
case doorClose:
m_Direction = -1;
height = sec->FindLowestCeilingSurrounding (&spot);
height = FindLowestCeilingSurrounding (sec, &spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
DoorSound (false);
break;
@ -367,7 +367,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag
case doorOpen:
case doorRaise:
m_Direction = 1;
height = sec->FindLowestCeilingSurrounding (&spot);
height = FindLowestCeilingSurrounding (sec, &spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
if (m_TopDist != sec->ceilingplane.fD())
DoorSound (true);
@ -381,7 +381,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag
case doorWaitRaise:
m_Direction = 2;
height = sec->FindLowestCeilingSurrounding (&spot);
height = FindLowestCeilingSurrounding (sec, &spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
break;

View file

@ -300,7 +300,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
{
case DFloor::floorLowerToHighest:
floor->m_Direction = -1;
newheight = sec->FindHighestFloorSurrounding(&spot);
newheight = FindHighestFloorSurrounding(sec, &spot);
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.
@ -310,14 +310,14 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorLowerToLowest:
floor->m_Direction = -1;
newheight = sec->FindLowestFloorSurrounding(&spot);
newheight = FindLowestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
case DFloor::floorLowerToNearest:
//jff 02/03/30 support lowering floor to next lowest floor
floor->m_Direction = -1;
newheight = sec->FindNextLowestFloor(&spot);
newheight = FindNextLowestFloor(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
@ -347,7 +347,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
height = 8;
case DFloor::floorRaiseToLowestCeiling:
floor->m_Direction = 1;
newheight = sec->FindLowestCeilingSurrounding(&spot) - height;
newheight = FindLowestCeilingSurrounding(sec, &spot) - height;
ceilingheight = FindLowestCeilingPoint(sec, &spot2);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
if (sec->floorplane.ZatPointDist(spot2, floor->m_FloorDestDist) > ceilingheight)
@ -356,19 +356,19 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorRaiseToHighest:
floor->m_Direction = 1;
newheight = sec->FindHighestFloorSurrounding(&spot);
newheight = FindHighestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
case DFloor::floorRaiseToNearest:
floor->m_Direction = 1;
newheight = sec->FindNextHighestFloor(&spot);
newheight = FindNextHighestFloor(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
case DFloor::floorRaiseToLowest:
floor->m_Direction = 1;
newheight = sec->FindLowestFloorSurrounding(&spot);
newheight = FindLowestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
@ -386,7 +386,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorLowerToLowestCeiling:
floor->m_Direction = -1;
newheight = sec->FindLowestCeilingSurrounding(&spot);
newheight = FindLowestCeilingSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
@ -431,7 +431,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorLowerAndChange:
floor->m_Direction = -1;
newheight = sec->FindLowestFloorSurrounding(&spot);
newheight = FindLowestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
floor->m_Texture = sec->GetTexture(sector_t::floor);
// jff 1/24/98 make sure floor->m_NewSpecial gets initialized
@ -1037,7 +1037,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
// elevator down to next floor
case DElevator::elevateDown:
elevator->m_Direction = -1;
newheight = sec->FindNextLowestFloor (&spot);
newheight = FindNextLowestFloor (sec, &spot);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight);
@ -1046,7 +1046,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
// elevator up to next floor
case DElevator::elevateUp:
elevator->m_Direction = 1;
newheight = sec->FindNextHighestFloor (&spot);
newheight = FindNextHighestFloor (sec, &spot);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight);

View file

@ -157,7 +157,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, double speed,
// surrounding sectors
if (floordist == 0)
{
newheight = sector->FindLowestFloorSurrounding (&spot);
newheight = FindLowestFloorSurrounding (sector, &spot);
m_FloorTarget = sector->floorplane.PointToDist (spot, newheight);
floordist = sector->floorplane.ZatPoint (spot) - newheight;
}
@ -168,7 +168,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, double speed,
}
if (ceilingdist == 0)
{
newheight = sector->FindHighestCeilingSurrounding (&spot);
newheight = FindHighestCeilingSurrounding (sector, &spot);
m_CeilingTarget = sector->ceilingplane.PointToDist (spot, newheight);
ceilingdist = newheight - sector->ceilingplane.ZatPoint (spot);
}

View file

@ -279,7 +279,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
{
case DPlat::platRaiseAndStay:
case DPlat::platRaiseAndStayLockout:
newheight = sec->FindNextHighestFloor (&spot);
newheight = FindNextHighestFloor (sec, &spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.fD();
plat->m_Status = DPlat::up;
@ -306,7 +306,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
case DPlat::platDownWaitUpStay:
case DPlat::platDownWaitUpStayStone:
newheight = sec->FindLowestFloorSurrounding (&spot) + lip;
newheight = FindLowestFloorSurrounding (sec, &spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.fD())
@ -318,13 +318,13 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break;
case DPlat::platUpNearestWaitDownStay:
newheight = sec->FindNextHighestFloor (&spot);
newheight = FindNextHighestFloor (sec, &spot);
// Intentional fall-through
case DPlat::platUpWaitDownStay:
if (type == DPlat::platUpWaitDownStay)
{
newheight = sec->FindHighestFloorSurrounding (&spot);
newheight = FindHighestFloorSurrounding (sec, &spot);
}
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.fD();
@ -337,13 +337,13 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break;
case DPlat::platPerpetualRaise:
newheight = sec->FindLowestFloorSurrounding (&spot) + lip;
newheight = FindLowestFloorSurrounding (sec, &spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.fD())
plat->m_Low = sec->floorplane.fD();
newheight = sec->FindHighestFloorSurrounding (&spot);
newheight = FindHighestFloorSurrounding (sec, &spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_High > sec->floorplane.fD())
@ -366,7 +366,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break;
case DPlat::platDownToNearestFloor:
newheight = sec->FindNextLowestFloor (&spot) + lip;
newheight = FindNextLowestFloor (sec, &spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_Status = DPlat::down;
plat->m_High = sec->floorplane.fD();
@ -374,7 +374,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break;
case DPlat::platDownToLowestCeiling:
newheight = sec->FindLowestCeilingSurrounding (&spot);
newheight = FindLowestCeilingSurrounding (sec, &spot);
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.fD();

View file

@ -104,37 +104,37 @@ DEFINE_ACTION_FUNCTION(_Sector, NextSpecialSector)
// P_FindLowestFloorSurrounding()
// FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS
//
double sector_t::FindLowestFloorSurrounding (vertex_t **v) const
double FindLowestFloorSurrounding (const sector_t *sector, vertex_t **v)
{
sector_t *other;
double floor;
double ofloor;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1;
floor = floorplane.ZatPoint(spot);
spot = sector->Lines[0]->v1;
floor = sector->floorplane.ZatPoint(spot);
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
ofloor = other->floorplane.ZatPoint (check->v1);
if (ofloor < floor && ofloor < floorplane.ZatPoint (check->v1))
if (ofloor < floor && ofloor < sector->floorplane.ZatPoint (check->v1))
{
floor = ofloor;
spot = check->v1;
}
ofloor = other->floorplane.ZatPoint (check->v2);
if (ofloor < floor && ofloor < floorplane.ZatPoint (check->v2))
if (ofloor < floor && ofloor < sector->floorplane.ZatPoint (check->v2))
{
floor = ofloor;
spot = check->v2;
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return floor;
}
@ -143,21 +143,21 @@ double sector_t::FindLowestFloorSurrounding (vertex_t **v) const
// P_FindHighestFloorSurrounding()
// FIND HIGHEST FLOOR HEIGHT IN SURROUNDING SECTORS
//
double sector_t::FindHighestFloorSurrounding (vertex_t **v) const
double FindHighestFloorSurrounding (const sector_t *sector, vertex_t **v)
{
sector_t *other;
double floor;
double ofloor;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1;
spot = sector->Lines[0]->v1;
floor = -FLT_MAX;
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
ofloor = other->floorplane.ZatPoint (check->v1);
if (ofloor > floor)
@ -173,7 +173,7 @@ double sector_t::FindHighestFloorSurrounding (vertex_t **v) const
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return floor;
}
@ -188,7 +188,7 @@ double sector_t::FindHighestFloorSurrounding (vertex_t **v) const
//
// Rewritten by Lee Killough to avoid fixed array and to be faster
//
double sector_t::FindNextHighestFloor (vertex_t **v) const
double FindNextHighestFloor (const sector_t *sector, vertex_t **v)
{
double height;
double heightdiff;
@ -196,27 +196,27 @@ double sector_t::FindNextHighestFloor (vertex_t **v) const
sector_t *other;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1;
height = floorplane.ZatPoint(spot);
spot = sector->Lines[0]->v1;
height = sector->floorplane.ZatPoint(spot);
heightdiff = FLT_MAX;
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
ofloor = other->floorplane.ZatPoint (check->v1);
floor = floorplane.ZatPoint (check->v1);
if (ofloor > floor && ofloor - floor < heightdiff && !IsLinked(other, false))
floor = sector->floorplane.ZatPoint (check->v1);
if (ofloor > floor && ofloor - floor < heightdiff && !sector->IsLinked(other, false))
{
heightdiff = ofloor - floor;
height = ofloor;
spot = check->v1;
}
ofloor = other->floorplane.ZatPoint (check->v2);
floor = floorplane.ZatPoint (check->v2);
if (ofloor > floor && ofloor - floor < heightdiff && !IsLinked(other, false))
floor = sector->floorplane.ZatPoint (check->v2);
if (ofloor > floor && ofloor - floor < heightdiff && !sector->IsLinked(other, false))
{
heightdiff = ofloor - floor;
height = ofloor;
@ -224,7 +224,7 @@ double sector_t::FindNextHighestFloor (vertex_t **v) const
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return height;
}
@ -240,7 +240,7 @@ double sector_t::FindNextHighestFloor (vertex_t **v) const
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
double sector_t::FindNextLowestFloor (vertex_t **v) const
double FindNextLowestFloor (const sector_t *sector, vertex_t **v)
{
double height;
double heightdiff;
@ -248,27 +248,27 @@ double sector_t::FindNextLowestFloor (vertex_t **v) const
sector_t *other;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1;
height = floorplane.ZatPoint (spot);
spot = sector->Lines[0]->v1;
height = sector->floorplane.ZatPoint (spot);
heightdiff = FLT_MAX;
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
ofloor = other->floorplane.ZatPoint (check->v1);
floor = floorplane.ZatPoint (check->v1);
if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false))
floor = sector->floorplane.ZatPoint (check->v1);
if (ofloor < floor && floor - ofloor < heightdiff && !sector->IsLinked(other, false))
{
heightdiff = floor - ofloor;
height = ofloor;
spot = check->v1;
}
ofloor = other->floorplane.ZatPoint (check->v2);
floor = floorplane.ZatPoint(check->v2);
if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false))
floor = sector->floorplane.ZatPoint(check->v2);
if (ofloor < floor && floor - ofloor < heightdiff && !sector->IsLinked(other, false))
{
heightdiff = floor - ofloor;
height = ofloor;
@ -276,7 +276,7 @@ double sector_t::FindNextLowestFloor (vertex_t **v) const
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return height;
}
@ -292,7 +292,7 @@ double sector_t::FindNextLowestFloor (vertex_t **v) const
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
double sector_t::FindNextLowestCeiling (vertex_t **v) const
double FindNextLowestCeiling (const sector_t *sector, vertex_t **v)
{
double height;
double heightdiff;
@ -300,27 +300,27 @@ double sector_t::FindNextLowestCeiling (vertex_t **v) const
sector_t *other;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1;
height = ceilingplane.ZatPoint(spot);
spot = sector->Lines[0]->v1;
height = sector->ceilingplane.ZatPoint(spot);
heightdiff = FLT_MAX;
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
oceil = other->ceilingplane.ZatPoint(check->v1);
ceil = ceilingplane.ZatPoint(check->v1);
if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true))
ceil = sector->ceilingplane.ZatPoint(check->v1);
if (oceil < ceil && ceil - oceil < heightdiff && !sector->IsLinked(other, true))
{
heightdiff = ceil - oceil;
height = oceil;
spot = check->v1;
}
oceil = other->ceilingplane.ZatPoint(check->v2);
ceil = ceilingplane.ZatPoint(check->v2);
if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true))
ceil = sector->ceilingplane.ZatPoint(check->v2);
if (oceil < ceil && ceil - oceil < heightdiff && !sector->IsLinked(other, true))
{
heightdiff = ceil - oceil;
height = oceil;
@ -328,7 +328,7 @@ double sector_t::FindNextLowestCeiling (vertex_t **v) const
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return height;
}
@ -344,7 +344,7 @@ double sector_t::FindNextLowestCeiling (vertex_t **v) const
//
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
//
double sector_t::FindNextHighestCeiling (vertex_t **v) const
double FindNextHighestCeiling (const sector_t *sector, vertex_t **v)
{
double height;
double heightdiff;
@ -352,27 +352,27 @@ double sector_t::FindNextHighestCeiling (vertex_t **v) const
sector_t *other;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::ceiling);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::ceiling);
spot = Lines[0]->v1;
height = ceilingplane.ZatPoint(spot);
spot = sector->Lines[0]->v1;
height = sector->ceilingplane.ZatPoint(spot);
heightdiff = FLT_MAX;
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
oceil = other->ceilingplane.ZatPoint(check->v1);
ceil = ceilingplane.ZatPoint(check->v1);
if (oceil > ceil && oceil - ceil < heightdiff && !IsLinked(other, true))
ceil = sector->ceilingplane.ZatPoint(check->v1);
if (oceil > ceil && oceil - ceil < heightdiff && !sector->IsLinked(other, true))
{
heightdiff = oceil - ceil;
height = oceil;
spot = check->v1;
}
oceil = other->ceilingplane.ZatPoint(check->v2);
ceil = ceilingplane.ZatPoint(check->v2);
if (oceil > ceil && oceil - ceil < heightdiff && !IsLinked(other, true))
ceil = sector->ceilingplane.ZatPoint(check->v2);
if (oceil > ceil && oceil - ceil < heightdiff && !sector->IsLinked(other, true))
{
heightdiff = oceil - ceil;
height = oceil;
@ -380,7 +380,7 @@ double sector_t::FindNextHighestCeiling (vertex_t **v) const
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return height;
}
@ -389,21 +389,21 @@ double sector_t::FindNextHighestCeiling (vertex_t **v) const
//
// FIND LOWEST CEILING IN THE SURROUNDING SECTORS
//
double sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
double FindLowestCeilingSurrounding (const sector_t *sector, vertex_t **v)
{
double height;
double oceil;
sector_t *other;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::ceiling);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::ceiling);
spot = Lines[0]->v1;
spot = sector->Lines[0]->v1;
height = FLT_MAX;
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
oceil = other->ceilingplane.ZatPoint(check->v1);
if (oceil < height)
@ -419,7 +419,7 @@ double sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return height;
}
@ -428,21 +428,21 @@ double sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
//
// FIND HIGHEST CEILING IN THE SURROUNDING SECTORS
//
double sector_t::FindHighestCeilingSurrounding (vertex_t **v) const
double FindHighestCeilingSurrounding (const sector_t *sector, vertex_t **v)
{
double height;
double oceil;
sector_t *other;
vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::ceiling);
if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::ceiling);
spot = Lines[0]->v1;
spot = sector->Lines[0]->v1;
height = -FLT_MAX;
for (auto check : Lines)
for (auto check : sector->Lines)
{
if (NULL != (other = getNextSector (check, this)))
if (NULL != (other = getNextSector (check, sector)))
{
oceil = other->ceilingplane.ZatPoint(check->v1);
if (oceil > height)
@ -458,7 +458,7 @@ double sector_t::FindHighestCeilingSurrounding (vertex_t **v) const
}
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return height;
}

View file

@ -622,14 +622,7 @@ public:
}
bool IsLinked(sector_t *other, bool ceiling) const;
double FindLowestFloorSurrounding(vertex_t **v) const;
double FindHighestFloorSurrounding(vertex_t **v) const;
double FindNextHighestFloor(vertex_t **v) const;
double FindNextLowestFloor(vertex_t **v) const;
double FindLowestCeilingSurrounding(vertex_t **v) const; // jff 2/04/98
double FindHighestCeilingSurrounding(vertex_t **v) const; // jff 2/04/98
double FindNextLowestCeiling(vertex_t **v) const; // jff 2/04/98
double FindNextHighestCeiling(vertex_t **v) const; // jff 2/04/98
int FindMinSurroundingLight (int max) const;
sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH]
double FindHighestFloorPoint(vertex_t **v) const;
@ -1597,6 +1590,14 @@ inline void FColormap::CopyFrom3DLight(lightlist_t *light)
}
}
double FindLowestFloorSurrounding(const sector_t *sec, vertex_t **v);
double FindHighestFloorSurrounding(const sector_t *sec, vertex_t **v);
double FindNextHighestFloor(const sector_t *sec, vertex_t **v);
double FindNextLowestFloor(const sector_t *sec, vertex_t **v);
double FindLowestCeilingSurrounding(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindHighestCeilingSurrounding(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindNextLowestCeiling(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindNextHighestCeiling(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindShortestTextureAround(sector_t *sector); // jff 2/04/98
double FindShortestUpperAround(sector_t *sector); // jff 2/04/98

View file

@ -28,82 +28,82 @@
#include "p_local.h"
DEFINE_ACTION_FUNCTION(_Sector, FindLowestFloorSurrounding)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindLowestFloorSurrounding, FindLowestFloorSurrounding)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindLowestFloorSurrounding(&v);
double h = FindLowestFloorSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindHighestFloorSurrounding)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindHighestFloorSurrounding, FindHighestFloorSurrounding)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindHighestFloorSurrounding(&v);
double h = FindHighestFloorSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindNextHighestFloor)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextHighestFloor, FindNextHighestFloor)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindNextHighestFloor(&v);
double h = FindNextHighestFloor(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindNextLowestFloor)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextLowestFloor, FindNextLowestFloor)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindNextLowestFloor(&v);
double h = FindNextLowestFloor(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindNextLowestCeiling)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextLowestCeiling, FindNextLowestCeiling)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindNextLowestCeiling(&v);
double h = FindNextLowestCeiling(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindNextHighestCeiling)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextHighestCeiling, FindNextHighestCeiling)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindNextHighestCeiling(&v);
double h = FindNextHighestCeiling(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindLowestCeilingSurrounding)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindLowestCeilingSurrounding, FindLowestCeilingSurrounding)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindLowestCeilingSurrounding(&v);
double h = FindLowestCeilingSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindHighestCeilingSurrounding)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindHighestCeilingSurrounding, FindHighestCeilingSurrounding)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindHighestCeilingSurrounding(&v);
double h = FindHighestCeilingSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;