mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- use sector_t::GetHeightSec consistently and optimize it.
This was all over the place, with half of it using the function and half doing incomplete checks on the underlying variables. Also did some optimization on the IGNOREHEIGHTSEC flag: Putting it on the destination sector instead of the model sector makes the check even simpler and allows to precalculate the effect of 3D floors on the heightsec, which previously had to be run on every call and made the function too complex for inlining.
This commit is contained in:
parent
3c49804c6c
commit
f49c6cbde2
12 changed files with 35 additions and 40 deletions
|
@ -558,7 +558,7 @@ void FGLRenderer::DrawBlend(sector_t * viewsector, bool FixedColormap, bool doco
|
|||
{
|
||||
if (!viewsector->e->XFloor.ffloors.Size())
|
||||
{
|
||||
if (viewsector->heightsec && !(viewsector->MoreFlags&SECF_IGNOREHEIGHTSEC))
|
||||
if (viewsector->GetHeightSec())
|
||||
{
|
||||
auto s = viewsector->heightsec;
|
||||
blendv = s->floorplane.PointOnSide(r_viewpoint.Pos) < 0? s->bottommap : s->ceilingplane.PointOnSide(r_viewpoint.Pos) < 0 ? s->topmap : s->midmap;
|
||||
|
|
|
@ -497,7 +497,7 @@ void GLSceneDrawer::DoSubsector(subsector_t * sub)
|
|||
// but undetermined heightsec state. This can only happen if the
|
||||
// subsector is obstructed but not excluded due to a large bounding box.
|
||||
// Due to the way a BSP works such a subsector can never be visible
|
||||
if (!sector->heightsec || sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || in_area!=area_default)
|
||||
if (!sector->GetHeightSec() || in_area!=area_default)
|
||||
{
|
||||
if (sector != sub->render_sector)
|
||||
{
|
||||
|
|
|
@ -103,7 +103,7 @@ void GLSceneDrawer::SetViewArea()
|
|||
r_viewpoint.sector = R_PointInSubsector(r_viewpoint.Pos)->render_sector;
|
||||
|
||||
// Get the heightsec state from the render sector, not the current one!
|
||||
if (r_viewpoint.sector->heightsec && !(r_viewpoint.sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
if (r_viewpoint.sector->GetHeightSec())
|
||||
{
|
||||
in_area = r_viewpoint.Pos.Z <= r_viewpoint.sector->heightsec->floorplane.ZatPoint(r_viewpoint.Pos) ? area_below :
|
||||
(r_viewpoint.Pos.Z > r_viewpoint.sector->heightsec->ceilingplane.ZatPoint(r_viewpoint.Pos) &&
|
||||
|
|
|
@ -160,9 +160,7 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
|||
|
||||
area_t hw_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector)
|
||||
{
|
||||
if (
|
||||
(backsector->heightsec && !(backsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) &&
|
||||
(!frontsector->heightsec || frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
if (backsector->GetHeightSec() && !frontsector->GetHeightSec())
|
||||
{
|
||||
sector_t * s = backsector->heightsec;
|
||||
|
||||
|
@ -189,7 +187,7 @@ area_t hw_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, secto
|
|||
//==========================================================================
|
||||
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back)
|
||||
{
|
||||
if (!sec->heightsec || sec->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || sec->heightsec==sec)
|
||||
if (!sec->GetHeightSec() || sec->heightsec==sec)
|
||||
{
|
||||
// check for backsectors with the ceiling lower than the floor. These will create
|
||||
// visual glitches because upper amd lower textures overlap.
|
||||
|
|
|
@ -309,7 +309,7 @@ void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingp
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
else if (thing->Sector->GetHeightSec())
|
||||
{
|
||||
if (thing->flags2&MF2_ONMOBJ && thing->floorz ==
|
||||
thing->Sector->heightsec->floorplane.ZatPoint(thingpos))
|
||||
|
|
|
@ -1068,30 +1068,6 @@ FSectorPortal *sector_t::ValidatePortal(int which)
|
|||
//
|
||||
//=====================================================================================
|
||||
|
||||
sector_t *sector_t::GetHeightSec() const
|
||||
{
|
||||
if (heightsec == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (e && e->XFloor.ffloors.Size())
|
||||
{
|
||||
// If any of these fake floors render their planes, ignore heightsec.
|
||||
for (unsigned i = e->XFloor.ffloors.Size(); i-- > 0; )
|
||||
{
|
||||
if ((e->XFloor.ffloors[i]->flags & (FF_EXISTS | FF_RENDERPLANES)) == (FF_EXISTS | FF_RENDERPLANES))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
return heightsec;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(_Sector, GetHeightSec)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
|
||||
|
|
|
@ -4221,6 +4221,23 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
AnnounceGameStart ();
|
||||
}
|
||||
|
||||
// This check was previously done at run time each time the heightsec was checked.
|
||||
// However, since 3D floors are static data, we can easily precalculate this and store it in the sector's flags for quick access.
|
||||
for (auto &s : level.sectors)
|
||||
{
|
||||
if (s.heightsec != nullptr)
|
||||
{
|
||||
// If any of these 3D floors render their planes, ignore heightsec.
|
||||
for (auto &ff : s.e->XFloor.ffloors)
|
||||
{
|
||||
if ((ff->flags & (FF_EXISTS | FF_RENDERPLANES)) == (FF_EXISTS | FF_RENDERPLANES))
|
||||
{
|
||||
s.MoreFlags |= SECF_IGNOREHEIGHTSEC; // mark the heightsec inactive.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
P_ResetSightCounters (true);
|
||||
//Printf ("free memory: 0x%x\n", Z_FreeMemory());
|
||||
|
||||
|
|
|
@ -1374,6 +1374,7 @@ void P_SpawnSpecials (void)
|
|||
{
|
||||
level.sectors[s].heightsec = sec;
|
||||
sec->e->FakeFloor.Sectors.Push(&level.sectors[s]);
|
||||
level.sectors[s].MoreFlags |= (sec->MoreFlags & SECF_IGNOREHEIGHTSEC); // copy this to the destination sector for easier checking.
|
||||
level.sectors[s].AdjustFloorClip();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -182,7 +182,7 @@ double RenderPolySprite::GetSpriteFloorZ(AActor *thing, const DVector2 &thingpos
|
|||
return floorh;
|
||||
}
|
||||
|
||||
if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
if (thing->Sector->GetHeightSec())
|
||||
{
|
||||
if (thing->flags2&MF2_ONMOBJ && thing->floorz == thing->Sector->heightsec->floorplane.ZatPoint(thingpos))
|
||||
{
|
||||
|
@ -204,7 +204,7 @@ double RenderPolySprite::GetSpriteCeilingZ(AActor *thing, const DVector2 &thingp
|
|||
return ceilingh;
|
||||
}
|
||||
|
||||
if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
if (thing->Sector->GetHeightSec())
|
||||
{
|
||||
if (thing->flags2&MF2_ONMOBJ && thing->ceilingz == thing->Sector->heightsec->ceilingplane.ZatPoint(thingpos))
|
||||
{
|
||||
|
|
|
@ -654,7 +654,12 @@ public:
|
|||
void ClosestPoint(const DVector2 &pos, DVector2 &out) const;
|
||||
int GetFloorLight () const;
|
||||
int GetCeilingLight () const;
|
||||
sector_t *GetHeightSec() const;
|
||||
|
||||
sector_t *GetHeightSec() const
|
||||
{
|
||||
return (MoreFlags & SECF_IGNOREHEIGHTSEC)? nullptr : heightsec;
|
||||
}
|
||||
|
||||
double GetFriction(int plane = sector_t::floor, double *movefac = NULL) const;
|
||||
bool TriggerSectorActions(AActor *thing, int activation);
|
||||
|
||||
|
|
|
@ -554,8 +554,7 @@ namespace swrenderer
|
|||
VisiblePlane *ceilingplane = frontsector->ceilingplane.PointOnSide(Thread->Viewport->viewpoint.Pos) > 0 ||
|
||||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum ||
|
||||
portal != nullptr ||
|
||||
(frontsector->heightsec &&
|
||||
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
||||
(frontsector->GetHeightSec() &&
|
||||
frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ?
|
||||
Thread->PlaneList->FindPlane(frontsector->ceilingplane, // killough 3/8/98
|
||||
frontsector->GetTexture(sector_t::ceiling),
|
||||
|
@ -597,8 +596,7 @@ namespace swrenderer
|
|||
VisiblePlane *floorplane = frontsector->floorplane.PointOnSide(Thread->Viewport->viewpoint.Pos) > 0 || // killough 3/7/98
|
||||
frontsector->GetTexture(sector_t::floor) == skyflatnum ||
|
||||
portal != nullptr ||
|
||||
(frontsector->heightsec &&
|
||||
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
||||
(frontsector->GetHeightSec() &&
|
||||
frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ?
|
||||
Thread->PlaneList->FindPlane(frontsector->floorplane,
|
||||
frontsector->GetTexture(sector_t::floor),
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace swrenderer
|
|||
hzb = spr->gzb;
|
||||
}
|
||||
|
||||
if (spr->heightsec && !(spr->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
|
||||
if (spr->heightsec)
|
||||
{ // only things in specially marked sectors
|
||||
if (spr->FakeFlatStat != WaterFakeSide::AboveCeiling)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue