mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +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.
(cherry picked from commit f49c6cbde2
)
# Conflicts:
# src/gl/renderer/gl_renderer.cpp
# src/hwrenderer/scene/hw_sprites.cpp
This commit is contained in:
parent
e5aca6dfa4
commit
8a3a293bf8
11 changed files with 35 additions and 40 deletions
|
@ -495,7 +495,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)
|
||||
{
|
||||
|
|
|
@ -163,9 +163,7 @@ bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
|||
|
||||
area_t GLSceneDrawer::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;
|
||||
|
||||
|
@ -192,7 +190,7 @@ area_t GLSceneDrawer::CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *fronts
|
|||
//==========================================================================
|
||||
sector_t * gl_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.
|
||||
|
|
|
@ -125,7 +125,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) &&
|
||||
|
@ -557,7 +557,7 @@ void GLSceneDrawer::DrawBlend(sector_t * viewsector)
|
|||
{
|
||||
if (!viewsector->e->XFloor.ffloors.Size())
|
||||
{
|
||||
if (viewsector->heightsec && !(viewsector->MoreFlags&SECF_IGNOREHEIGHTSEC))
|
||||
if (viewsector->GetHeightSec())
|
||||
{
|
||||
switch (in_area)
|
||||
{
|
||||
|
|
|
@ -617,7 +617,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))
|
||||
|
|
|
@ -1069,30 +1069,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);
|
||||
|
|
|
@ -4197,6 +4197,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());
|
||||
|
||||
|
|
|
@ -1392,6 +1392,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))
|
||||
{
|
||||
|
|
|
@ -653,7 +653,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