- refactored P_FindFloorCeiling to be portal aware and cleaned up its interface.

A big problem with this function was that some flags required setting up some variables before calling it and others did not. It will now set everything up itself so all initializations to AActor::floorz and ceilingz that were made before these calls (which were all identical to begin with) could be removed and the internal initialization logic streamlined.
This commit is contained in:
Christoph Oelckers 2016-02-17 21:57:52 +01:00
parent bd09664d85
commit 884a265d4a
8 changed files with 23 additions and 46 deletions

View file

@ -82,7 +82,7 @@ void AFastProjectile::Tick ()
if (tm.ceilingline &&
tm.ceilingline->backsector &&
tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))
Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline)))
{
// Hack to prevent missiles exploding against the sky.
// Does not handle sky floors.

View file

@ -414,7 +414,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
// Move item back to its original location
fixed_t _x, _y;
sector_t *sec;
_x = self->SpawnPoint[0];
_y = self->SpawnPoint[1];
@ -422,12 +421,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
self->UnlinkFromWorld();
self->SetXY(_x, _y);
self->LinkToWorld(true);
sec = self->Sector;
self->dropoffz =
self->floorz = sec->floorplane.ZatPoint(_x, _y);
self->ceilingz = sec->ceilingplane.ZatPoint(_x, _y);
self->SetZ(self->floorz);
P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS | FFCF_NOPORTALS); // no pprtal checks here so that things get spawned in this sector.
self->SetZ(self->Sector->floorplane.ZatPoint(_x, _y));
P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS | FFCF_NOPORTALS); // no portal checks here so that things get spawned in this sector.
if (self->flags & MF_SPAWNCEILING)
{
@ -450,10 +445,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition)
{
self->SetZ(self->SpawnPoint[2] + self->floorz);
}
// Redo floor/ceiling check, in case of 3D floors
// we need to get the actual floor and ceiling heights including portals here
self->floorz = sec->LowestFloorAt(self, &self->floorsector);
self->ceilingz = sec->HighestCeilingAt(self, &self->ceilingsector);
// Redo floor/ceiling check, in case of 3D floors and portals
P_FindFloorCeiling(self, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT);
if (self->Z() < self->floorz)
{ // Do not reappear under the floor, even if that's where we were for the

View file

@ -558,7 +558,7 @@ bool P_Move (AActor *actor)
else
{ // The monster just hit the floor, so trigger any actions.
if (actor->floorsector->SecActTarget != NULL &&
actor->floorz == actor->floorsector->floorplane.ZatPoint(actor->PosRelative(actor->floorsector))
actor->floorz == actor->floorsector->floorplane.ZatPoint(actor->PosRelative(actor->floorsector)))
{
actor->floorsector->SecActTarget->TriggerAction(actor, SECSPAC_HitFloor);
}

View file

@ -238,21 +238,24 @@ static bool PIT_FindFloorCeiling(line_t *ld, const FBoundingBox &box, FCheckPosi
void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags)
{
sector_t *sec;
if (!(flags & FFCF_ONLYSPAWNPOS))
{
sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector;
sector_t *sec = !(flags & FFCF_SAMESECTOR) ? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector;
tmf.floorz = tmf.dropoffz = sec->LowestFloorAt(tmf.x, tmf.y, &tmf.floorsector);
tmf.ceilingz = sec->HighestCeilingAt(tmf.x, tmf.y, &tmf.ceilingsector);
tmf.floorpic = sec->GetTexture(sector_t::floor);
tmf.floorterrain = sec->GetTerrain(sector_t::floor);
tmf.ceilingpic = sec->GetTexture(sector_t::ceiling);
if (flags & FFCF_NOPORTALS)
{
tmf.thing->dropoffz = tmf.thing->floorz = sec->floorplane.ZatPoint(tmf.x, tmf.y);
tmf.thing->ceilingz = sec->ceilingplane.ZatPoint(tmf.x, tmf.y);
tmf.ceilingsector = tmf.floorsector = sec;
}
else
{
sec = tmf.thing->Sector;
tmf.floorz = tmf.dropoffz = sec->LowestFloorAt(tmf.x, tmf.y, &tmf.floorsector);
tmf.ceilingz = sec->HighestCeilingAt(tmf.x, tmf.y, &tmf.ceilingsector);
}
tmf.floorpic = tmf.floorsector->GetTexture(sector_t::floor);
tmf.floorterrain = tmf.floorsector->GetTerrain(sector_t::floor);
tmf.ceilingpic = tmf.ceilingsector->GetTexture(sector_t::ceiling);
tmf.sector = sec;
for (unsigned int i = 0; i<sec->e->XFloor.ffloors.Size(); i++)
{
@ -299,21 +302,8 @@ void P_FindFloorCeiling(AActor *actor, int flags)
{
flags |= FFCF_3DRESTRICT;
}
if (!(flags & FFCF_ONLYSPAWNPOS))
{
P_GetFloorCeilingZ(tmf, flags);
}
else
{
tmf.ceilingsector = tmf.floorsector = actor->Sector;
P_GetFloorCeilingZ(tmf, flags);
tmf.floorz = tmf.dropoffz = actor->floorz;
tmf.ceilingz = actor->ceilingz;
tmf.floorpic = actor->floorpic;
tmf.floorterrain = actor->floorterrain;
tmf.ceilingpic = actor->ceilingpic;
P_GetFloorCeilingZ(tmf, flags);
}
actor->floorz = tmf.floorz;
actor->dropoffz = tmf.dropoffz;
actor->ceilingz = tmf.ceilingz;

View file

@ -513,8 +513,6 @@ void AActor::SetOrigin (fixed_t ix, fixed_t iy, fixed_t iz, bool moving)
SetXYZ(ix, iy, iz);
if (moving) SetMovement(ix - X(), iy - Y(), iz - Z());
LinkToWorld ();
floorz = Sector->LowestFloorAt(ix, iy, &floorsector);
ceilingz = Sector->HighestCeilingAt(ix, iy, &ceilingsector);
P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS);
}

View file

@ -3558,7 +3558,7 @@ void AActor::Tick ()
for (node = touching_sectorlist; node; node = node->m_tnext)
{
const sector_t *sec = node->m_sector;
sector_t *sec = node->m_sector;
fixed_t scrollx, scrolly;
if (level.Scrolls != NULL)
@ -4172,8 +4172,6 @@ AActor *AActor::StaticSpawn (PClassActor *type, fixed_t ix, fixed_t iy, fixed_t
// z-coordinate.
if (!SpawningMapThing)
{
actor->ceilingz = actor->Sector->HighestCeilingAt(actor, &actor->ceilingsector);
actor->dropoffz = actor->floorz = actor->Sector->LowestFloorAt(actor, &actor->floorsector);
P_FindFloorCeiling(actor, FFCF_ONLYSPAWNPOS);
}
else

View file

@ -2299,7 +2299,7 @@ void DPusher::Tick ()
continue;
sector_t *hsec = sec->GetHeightSec();
fixedvec2 pos = thing->PosRelative(sec);
fixedvec3 pos = thing->PosRelative(sec);
if (m_Type == p_wind)
{
if (hsec == NULL)

View file

@ -769,10 +769,9 @@ void APlayerPawn::PostBeginPlay()
// Voodoo dolls: restore original floorz/ceilingz logic
if (player == NULL || player->mo != this)
{
dropoffz = floorz = Sector->floorplane.ZatPoint(this);
ceilingz = Sector->ceilingplane.ZatPoint(this);
P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS);
P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS|FFCF_NOPORTALS);
SetZ(floorz);
P_FindFloorCeiling(this, FFCF_ONLYSPAWNPOS);
}
else
{