- renamed the flag bits for sector_t::MoreFlags, so that they are easier to distinguish from sector_t::Flags.

- precalculate if a sector's floor and ceiling plane overlap. This avoids rechecking this for each single call of hw_FakeFlat.
- vertices must be marked dirty every time they change after map setup. That means that ChangePlaneTexZ must do this as well, because it cannot rely on interpolation taking care of it.
- Having a 'dirty' argument for SetPlaneTexZ's ZScript version makes no sense. If the value changes from the script side the vertices must always be marked to be recalculated.

(cherry picked from commit 9bdb0f2e49)
This commit is contained in:
Christoph Oelckers 2018-05-01 11:29:29 +02:00 committed by drfrag666
parent 8a3a293bf8
commit 7b822807de
19 changed files with 143 additions and 116 deletions

View file

@ -1950,10 +1950,10 @@ sector_t * AM_FakeFlat(AActor *viewer, sector_t * sec, sector_t * dest)
else
{
in_area = pos.Z <= viewer->Sector->heightsec->floorplane.ZatPoint(pos) ? -1 :
(pos.Z > viewer->Sector->heightsec->ceilingplane.ZatPoint(pos) && !(viewer->Sector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? 1 : 0;
(pos.Z > viewer->Sector->heightsec->ceilingplane.ZatPoint(pos) && !(viewer->Sector->heightsec->MoreFlags&SECMF_FAKEFLOORONLY)) ? 1 : 0;
}
int diffTex = (sec->heightsec->MoreFlags & SECF_CLIPFAKEPLANES);
int diffTex = (sec->heightsec->MoreFlags & SECMF_CLIPFAKEPLANES);
sector_t * s = sec->heightsec;
memcpy(dest, sec, sizeof(sector_t));
@ -1965,14 +1965,14 @@ sector_t * AM_FakeFlat(AActor *viewer, sector_t * sec, sector_t * dest)
if (s->floorplane.CopyPlaneIfValid(&dest->floorplane, &sec->ceilingplane))
{
dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
}
else if (s->MoreFlags & SECF_FAKEFLOORONLY)
else if (s->MoreFlags & SECMF_FAKEFLOORONLY)
{
if (in_area == -1)
{
dest->Colormap = s->Colormap;
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor));
@ -1985,16 +1985,16 @@ sector_t * AM_FakeFlat(AActor *viewer, sector_t * sec, sector_t * dest)
}
else
{
dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->floorplane = s->floorplane;
}
if (in_area == -1)
{
dest->Colormap = s->Colormap;
dest->SetPlaneTexZ(sector_t::floor, sec->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZQuick(sector_t::floor, sec->GetPlaneTexZ(sector_t::floor));
dest->floorplane = sec->floorplane;
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
}
@ -2002,7 +2002,7 @@ sector_t * AM_FakeFlat(AActor *viewer, sector_t * sec, sector_t * dest)
dest->SetTexture(sector_t::floor, diffTex ? sec->GetTexture(sector_t::floor) : s->GetTexture(sector_t::floor), false);
dest->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor));
dest->ChangeFlags(sector_t::floor, -1, s->GetFlags(sector_t::floor));
@ -2011,9 +2011,9 @@ sector_t * AM_FakeFlat(AActor *viewer, sector_t * sec, sector_t * dest)
else if (in_area == 1)
{
dest->Colormap = s->Colormap;
dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling));
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling));
dest->floorplane = s->ceilingplane;
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
}
@ -2026,7 +2026,7 @@ sector_t * AM_FakeFlat(AActor *viewer, sector_t * sec, sector_t * dest)
dest->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
}
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor));
@ -2063,7 +2063,7 @@ void AM_drawSubsectors()
continue;
}
if ((!(subsectors[i].flags & SSECF_DRAWN) || (subsectors[i].render_sector->MoreFlags & SECF_HIDDEN)) && am_cheat == 0)
if ((!(subsectors[i].flags & SSECMF_DRAWN) || (subsectors[i].render_sector->MoreFlags & SECMF_HIDDEN)) && am_cheat == 0)
{
continue;
}
@ -2184,7 +2184,7 @@ void AM_drawSubsectors()
// If this subsector has not actually been seen yet (because you are cheating
// to see it on the map), tint and desaturate it.
if (!(subsectors[i].flags & SSECF_DRAWN))
if (!(subsectors[i].flags & SSECMF_DRAWN))
{
colormap.LightColor = PalEntry(
(colormap.LightColor.r + 255) / 2,
@ -3169,8 +3169,8 @@ void AM_drawAuthorMarkers ()
// Use more correct info if we have GL nodes available
if (mark->args[1] == 0 ||
(mark->args[1] == 1 && (hasglnodes ?
marked->subsector->flags & SSECF_DRAWN :
marked->Sector->MoreFlags & SECF_DRAWN)))
marked->subsector->flags & SSECMF_DRAWN :
marked->Sector->MoreFlags & SECMF_DRAWN)))
{
DrawMarker (tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X, mark->Scale.Y, mark->Translation,
mark->Alpha, mark->fillcolor, mark->RenderStyle);

View file

@ -106,11 +106,11 @@ void GLSceneDrawer::AddLine (seg_t *seg, bool portalclip)
if (seg->sidedef == NULL)
{
if (!(currentsubsector->flags & SSECF_DRAWN))
if (!(currentsubsector->flags & SSECMF_DRAWN))
{
if (clipper.SafeCheckRange(startAngle, endAngle))
{
currentsubsector->flags |= SSECF_DRAWN;
currentsubsector->flags |= SSECMF_DRAWN;
}
}
return;
@ -120,7 +120,7 @@ void GLSceneDrawer::AddLine (seg_t *seg, bool portalclip)
{
return;
}
currentsubsector->flags |= SSECF_DRAWN;
currentsubsector->flags |= SSECMF_DRAWN;
uint8_t ispoly = uint8_t(seg->sidedef->Flags & WALLF_POLYOBJ);
@ -144,7 +144,7 @@ void GLSceneDrawer::AddLine (seg_t *seg, bool portalclip)
}
backsector=currentsector;
}
else
else
{
// clipping checks are only needed when the backsector is not the same as the front sector
if (in_area == area_default) in_area = CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector);
@ -296,7 +296,7 @@ void GLSceneDrawer::AddLines(subsector_t * sub, sector_t * sector)
{
if (seg->linedef == NULL)
{
if (!(sub->flags & SSECF_DRAWN)) AddLine (seg, GLRenderer->mClipPortal != NULL);
if (!(sub->flags & SSECMF_DRAWN)) AddLine (seg, GLRenderer->mClipPortal != NULL);
}
else if (!(seg->sidedef->Flags & WALLF_POLYOBJ))
{
@ -483,7 +483,7 @@ void GLSceneDrawer::DoSubsector(subsector_t * sub)
{
RenderThings(sub, fakesector);
}
sector->MoreFlags |= SECF_DRAWN;
sector->MoreFlags |= SECMF_DRAWN;
}
if (gl_render_flats)

View file

@ -194,18 +194,15 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
{
// check for backsectors with the ceiling lower than the floor. These will create
// visual glitches because upper amd lower textures overlap.
if (back && sec->planes[sector_t::floor].TexZ > sec->planes[sector_t::ceiling].TexZ)
if (back && (sec->MoreFlags & SECMF_OVERLAPPING))
{
if (!sec->floorplane.isSlope() && !sec->ceilingplane.isSlope())
{
*dest = *sec;
dest->ceilingplane=sec->floorplane;
dest->ceilingplane.FlipVert();
dest->planes[sector_t::ceiling].TexZ = dest->planes[sector_t::floor].TexZ;
dest->ClearPortal(sector_t::ceiling);
dest->ClearPortal(sector_t::floor);
return dest;
}
*dest = *sec;
dest->ceilingplane = sec->floorplane;
dest->ceilingplane.FlipVert();
dest->planes[sector_t::ceiling].TexZ = dest->planes[sector_t::floor].TexZ;
dest->ClearPortal(sector_t::ceiling);
dest->ClearPortal(sector_t::floor);
return dest;
}
return sec;
}
@ -219,10 +216,10 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
if (in_area==area_above)
{
if (sec->heightsec->MoreFlags&SECF_FAKEFLOORONLY /*|| sec->GetTexture(sector_t::ceiling)==skyflatnum*/) in_area=area_normal;
if (sec->heightsec->MoreFlags&SECMF_FAKEFLOORONLY /*|| sec->GetTexture(sector_t::ceiling)==skyflatnum*/) in_area=area_normal;
}
int diffTex = (sec->heightsec->MoreFlags & SECF_CLIPFAKEPLANES);
int diffTex = (sec->heightsec->MoreFlags & SECMF_CLIPFAKEPLANES);
sector_t * s = sec->heightsec;
#if 0
@ -237,16 +234,16 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
if (s->floorplane.CopyPlaneIfValid (&dest->floorplane, &sec->ceilingplane))
{
dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor];
dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor];
}
else if (s->MoreFlags & SECF_FAKEFLOORONLY)
else if (s->MoreFlags & SECMF_FAKEFLOORONLY)
{
if (in_area==area_below)
{
dest->CopyColors(s);
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor));
@ -261,21 +258,21 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
}
else
{
dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::floor));
dest->floorplane = s->floorplane;
dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor];
dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor];
}
if (!(s->MoreFlags&SECF_FAKEFLOORONLY))
if (!(s->MoreFlags&SECMF_FAKEFLOORONLY))
{
if (diffTex)
{
if (s->ceilingplane.CopyPlaneIfValid (&dest->ceilingplane, &sec->floorplane))
{
dest->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false);
dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling];
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling];
}
@ -283,7 +280,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
else
{
dest->ceilingplane = s->ceilingplane;
dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling));
dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling];
dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling];
}
@ -292,8 +289,8 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
if (in_area==area_below)
{
dest->CopyColors(s);
dest->SetPlaneTexZ(sector_t::floor, sec->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZQuick(sector_t::floor, sec->GetPlaneTexZ(sector_t::floor));
dest->SetPlaneTexZQuick(sector_t::ceiling, s->GetPlaneTexZ(sector_t::floor));
dest->floorplane=sec->floorplane;
dest->ceilingplane=s->floorplane;
dest->ceilingplane.FlipVert();
@ -306,7 +303,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
dest->ClearPortal(sector_t::ceiling);
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
}
@ -333,7 +330,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
dest->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform;
}
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor));
dest->SetPlaneLight(sector_t::ceiling, s->GetPlaneLight(sector_t::ceiling));
@ -345,8 +342,8 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
else if (in_area == area_above)
{
dest->CopyColors(s);
dest->SetPlaneTexZ(sector_t::ceiling, sec->GetPlaneTexZ(sector_t::ceiling));
dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling));
dest->SetPlaneTexZQuick(sector_t::ceiling, sec->GetPlaneTexZ(sector_t::ceiling));
dest->SetPlaneTexZQuick(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling));
dest->ceilingplane = sec->ceilingplane;
dest->floorplane = s->ceilingplane;
dest->floorplane.FlipVert();
@ -359,7 +356,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
dest->ClearPortal(sector_t::floor);
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
}
@ -376,7 +373,7 @@ sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool bac
dest->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
}
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
dest->lightlevel = s->lightlevel;
dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor));

View file

@ -129,7 +129,7 @@ void GLSceneDrawer::SetViewArea()
{
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) &&
!(r_viewpoint.sector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above : area_normal;
!(r_viewpoint.sector->heightsec->MoreFlags&SECMF_FAKEFLOORONLY)) ? area_above : area_normal;
}
else
{

View file

@ -1337,7 +1337,7 @@ void P_SetRenderSector()
}
for(i = 0; i < numsectors; i++)
{
if (hidesec[i]) sectors[i].MoreFlags |= SECF_HIDDEN;
if (hidesec[i]) sectors[i].MoreFlags |= SECMF_HIDDEN;
}
delete [] hidesec;
#endif

View file

@ -2691,7 +2691,7 @@ bool P_TryMove(AActor *thing, const DVector2 &pos,
newsec->TriggerSectorActions(thing, SECSPAC_EyesDive);
}
if (!(hs->MoreFlags & SECF_FAKEFLOORONLY))
if (!(hs->MoreFlags & SECMF_FAKEFLOORONLY))
{
fakez = hs->ceilingplane.ZatPoint(pos);
if (!oldAboveFakeCeiling && eyez > fakez)
@ -6881,7 +6881,7 @@ bool P_ChangeSector(sector_t *sector, int crunch, double amt, int floorOrCeil, b
if (floorOrCeil != 2) sector->CheckPortalPlane(floorOrCeil); // check for portal obstructions after everything is done.
if (!cpos.nofit && !isreset /* && sector->MoreFlags & (SECF_UNDERWATERMASK)*/)
if (!cpos.nofit && !isreset /* && sector->MoreFlags & (SECMF_UNDERWATERMASK)*/)
{
// If this is a control sector for a deep water transfer, all actors in affected
// sectors need to have their waterlevel information updated and if applicable,

View file

@ -3275,7 +3275,7 @@ void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight
sec->TriggerSectorActions (mo, SECSPAC_EyesDive);
}
if (!(hs->MoreFlags & SECF_FAKEFLOORONLY))
if (!(hs->MoreFlags & SECMF_FAKEFLOORONLY))
{
waterz = hs->ceilingplane.ZatPoint(mo);
if (oldz <= waterz && newz > waterz)
@ -4745,7 +4745,7 @@ void AActor::SplashCheck()
return;
}
if (Sector->MoreFlags & SECF_UNDERWATER) // intentionally not SECF_UNDERWATERMASK
if (Sector->MoreFlags & SECMF_UNDERWATER) // intentionally not SECMF_UNDERWATERMASK
{
waterlevel = 3;
}
@ -4755,7 +4755,7 @@ void AActor::SplashCheck()
if (hsec != NULL)
{
fh = hsec->floorplane.ZatPoint(this);
//if (hsec->MoreFlags & SECF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors
//if (hsec->MoreFlags & SECMF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors
{
if (Z() < fh)
{
@ -4770,7 +4770,7 @@ void AActor::SplashCheck()
}
}
}
else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPoint(this)))
else if (!(hsec->MoreFlags & SECMF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPoint(this)))
{
waterlevel = 3;
}
@ -4847,7 +4847,7 @@ bool AActor::UpdateWaterLevel(bool dosplash)
return false;
}
if (Sector->MoreFlags & SECF_UNDERWATER) // intentionally not SECF_UNDERWATERMASK
if (Sector->MoreFlags & SECMF_UNDERWATER) // intentionally not SECMF_UNDERWATERMASK
{
waterlevel = 3;
}
@ -4857,7 +4857,7 @@ bool AActor::UpdateWaterLevel(bool dosplash)
if (hsec != NULL)
{
fh = hsec->floorplane.ZatPoint(this);
if (hsec->MoreFlags & SECF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors
if (hsec->MoreFlags & SECMF_UNDERWATERMASK) // also check Boom-style non-swimmable sectors
{
if (Z() < fh)
{
@ -4872,7 +4872,7 @@ bool AActor::UpdateWaterLevel(bool dosplash)
}
}
}
else if (!(hsec->MoreFlags & SECF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPoint(this)))
else if (!(hsec->MoreFlags & SECMF_FAKEFLOORONLY) && (Top() > hsec->ceilingplane.ZatPoint(this)))
{
waterlevel = 3;
}
@ -6576,7 +6576,7 @@ bool P_HitWater (AActor * thing, sector_t * sec, const DVector3 &pos, bool check
}
}
hsec = sec->GetHeightSec();
if (force || hsec == NULL || !(hsec->MoreFlags & SECF_CLIPFAKEPLANES))
if (force || hsec == NULL || !(hsec->MoreFlags & SECMF_CLIPFAKEPLANES))
{
terrainnum = sec->GetTerrain(sector_t::floor);
}

View file

@ -335,7 +335,7 @@ void RecalculateDrawnSubsectors()
if (sub.firstline[j].linedef != NULL &&
(sub.firstline[j].linedef->flags & ML_MAPPED))
{
sub.flags |= SSECF_DRAWN;
sub.flags |= SSECMF_DRAWN;
}
}
}
@ -364,7 +364,7 @@ FSerializer &SerializeSubsectors(FSerializer &arc, const char *key)
by = 0;
for (unsigned j = 0; j < 6; j++)
{
if (i + j < numsubsectors && (level.subsectors[i + j].flags & SSECF_DRAWN))
if (i + j < numsubsectors && (level.subsectors[i + j].flags & SSECMF_DRAWN))
{
by |= (1 << j);
}
@ -420,7 +420,7 @@ FSerializer &SerializeSubsectors(FSerializer &arc, const char *key)
{
if (sub + s < (int)numsubsectors && (by & (1 << s)))
{
level.subsectors[sub + s].flags |= SSECF_DRAWN;
level.subsectors[sub + s].flags |= SSECMF_DRAWN;
}
}
sub += 6;

View file

@ -1548,6 +1548,26 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
ACTION_RETURN_BOOL(self->TriggerSectorActions(thing, activation));
}
//===========================================================================
//
// checks if the floor is higher than the ceiling and sets a flag
// This condition needs to be tested by the hardware renderer,
// so always having its state available in a flag allows for easier optimization.
//
//===========================================================================
void sector_t::CheckOverlap()
{
if (planes[sector_t::floor].TexZ > planes[sector_t::ceiling].TexZ && !floorplane.isSlope() && !ceilingplane.isSlope())
{
MoreFlags |= SECMF_OVERLAPPING;
}
else
{
MoreFlags &= ~SECMF_OVERLAPPING;
}
}
//===========================================================================
//
//
@ -1752,7 +1772,7 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
PARAM_INT(pos);
PARAM_FLOAT(o);
PARAM_BOOL_DEF(dirty);
self->SetPlaneTexZ(pos, o, dirty);
self->SetPlaneTexZ(pos, o, true); // not setting 'dirty' here is a guaranteed cause for problems.
return 0;
}

View file

@ -4208,7 +4208,7 @@ void P_SetupLevel (const char *lumpname, int position)
{
if ((ff->flags & (FF_EXISTS | FF_RENDERPLANES)) == (FF_EXISTS | FF_RENDERPLANES))
{
s.MoreFlags |= SECF_IGNOREHEIGHTSEC; // mark the heightsec inactive.
s.MoreFlags |= SECMF_IGNOREHEIGHTSEC; // mark the heightsec inactive.
}
}
}

View file

@ -716,15 +716,15 @@ CUSTOM_CVAR (Bool, forcewater, false, CVAR_ARCHIVE|CVAR_SERVERINFO)
for (auto &sec : level.sectors)
{
sector_t *hsec = sec.GetHeightSec();
if (hsec && !(hsec->MoreFlags & SECF_UNDERWATER))
if (hsec && !(hsec->MoreFlags & SECMF_UNDERWATER))
{
if (self)
{
hsec->MoreFlags |= SECF_FORCEDUNDERWATER;
hsec->MoreFlags |= SECMF_FORCEDUNDERWATER;
}
else
{
hsec->MoreFlags &= ~SECF_FORCEDUNDERWATER;
hsec->MoreFlags &= ~SECMF_FORCEDUNDERWATER;
}
}
}
@ -1266,7 +1266,7 @@ void P_InitSectorSpecial(sector_t *sector, int special)
break;
case Sector_Hidden:
sector->MoreFlags |= SECF_HIDDEN;
sector->MoreFlags |= SECMF_HIDDEN;
break;
case Sector_Heal:
@ -1364,35 +1364,35 @@ void P_SpawnSpecials (void)
if (line.args[1] & 2)
{
sec->MoreFlags |= SECF_FAKEFLOORONLY;
sec->MoreFlags |= SECMF_FAKEFLOORONLY;
}
if (line.args[1] & 4)
{
sec->MoreFlags |= SECF_CLIPFAKEPLANES;
sec->MoreFlags |= SECMF_CLIPFAKEPLANES;
}
if (line.args[1] & 8)
{
sec->MoreFlags |= SECF_UNDERWATER;
sec->MoreFlags |= SECMF_UNDERWATER;
}
else if (forcewater)
{
sec->MoreFlags |= SECF_FORCEDUNDERWATER;
sec->MoreFlags |= SECMF_FORCEDUNDERWATER;
}
if (line.args[1] & 16)
{
sec->MoreFlags |= SECF_IGNOREHEIGHTSEC;
sec->MoreFlags |= SECMF_IGNOREHEIGHTSEC;
}
else level.HasHeightSecs = true;
if (line.args[1] & 32)
{
sec->MoreFlags |= SECF_NOFAKELIGHT;
sec->MoreFlags |= SECMF_NOFAKELIGHT;
}
FSectorTagIterator itr(line.args[0]);
while ((s = itr.Next()) >= 0)
{
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].MoreFlags |= (sec->MoreFlags & SECMF_IGNOREHEIGHTSEC); // copy this to the destination sector for easier checking.
level.sectors[s].AdjustFloorClip();
}
break;

View file

@ -1581,11 +1581,11 @@ public:
continue;
case NAME_hidden:
Flag(sec->MoreFlags, SECF_HIDDEN, key);
Flag(sec->MoreFlags, SECMF_HIDDEN, key);
break;
case NAME_Waterzone:
Flag(sec->MoreFlags, SECF_UNDERWATER, key);
Flag(sec->MoreFlags, SECMF_UNDERWATER, key);
break;
case NAME_floorplane_a:

View file

@ -131,7 +131,7 @@ void RenderPolyScene::RenderSectors()
void RenderPolyScene::RenderSubsector(PolyRenderThread *thread, subsector_t *sub, uint32_t subsectorDepth)
{
sector_t *frontsector = sub->sector;
frontsector->MoreFlags |= SECF_DRAWN;
frontsector->MoreFlags |= SECMF_DRAWN;
bool mainBSP = sub->polys == nullptr;
@ -234,7 +234,7 @@ void RenderPolyScene::RenderPolySubsector(PolyRenderThread *thread, subsector_t
if (!PolyRenderer::Instance()->DontMapLines && line->linedef)
{
line->linedef->flags |= ML_MAPPED;
sub->flags |= SSECF_DRAWN;
sub->flags |= SSECMF_DRAWN;
}
RenderPolyWall::RenderLine(thread, line, frontsector, subsectorDepth, CurrentViewpoint->StencilValue, thread->TranslucentObjects, thread->LinePortals, CurrentViewpoint->LinePortalsStart, CurrentViewpoint->PortalEnterLine);
@ -302,7 +302,7 @@ void RenderPolyScene::RenderLine(PolyRenderThread *thread, subsector_t *sub, seg
if (!PolyRenderer::Instance()->DontMapLines && line->linedef)
{
line->linedef->flags |= ML_MAPPED;
sub->flags |= SSECF_DRAWN;
sub->flags |= SSECMF_DRAWN;
}
// Render 3D floor sides
@ -425,7 +425,7 @@ PolyTransferHeights::PolyTransferHeights(subsector_t *sub) : Subsector(sub)
sector_t *heightsec = PolyRenderer::Instance()->Viewpoint.sector->heightsec;
bool underwater = (heightsec && heightsec->floorplane.PointOnSide(PolyRenderer::Instance()->Viewpoint.Pos) <= 0);
bool doorunderwater = false;
int diffTex = (s->MoreFlags & SECF_CLIPFAKEPLANES);
int diffTex = (s->MoreFlags & SECMF_CLIPFAKEPLANES);
// Replace sector being drawn with a copy to be hacked
tempsec = *sec;
@ -437,12 +437,12 @@ PolyTransferHeights::PolyTransferHeights(subsector_t *sub) : Subsector(sub)
{
tempsec.SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
}
else if (s->MoreFlags & SECF_FAKEFLOORONLY)
else if (s->MoreFlags & SECMF_FAKEFLOORONLY)
{
if (underwater)
{
tempsec.Colormap = s->Colormap;
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
tempsec.lightlevel = s->lightlevel;
@ -462,7 +462,7 @@ PolyTransferHeights::PolyTransferHeights(subsector_t *sub) : Subsector(sub)
tempsec.floorplane = s->floorplane;
}
if (!(s->MoreFlags & SECF_FAKEFLOORONLY))
if (!(s->MoreFlags & SECMF_FAKEFLOORONLY))
{
if (diffTex)
{
@ -513,7 +513,7 @@ PolyTransferHeights::PolyTransferHeights(subsector_t *sub) : Subsector(sub)
tempsec.planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform;
}
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
tempsec.lightlevel = s->lightlevel;
@ -522,7 +522,7 @@ PolyTransferHeights::PolyTransferHeights(subsector_t *sub) : Subsector(sub)
}
FakeSide = PolyWaterFakeSide::BelowFloor;
}
else if (heightsec && heightsec->ceilingplane.PointOnSide(PolyRenderer::Instance()->Viewpoint.Pos) <= 0 && orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY))
else if (heightsec && heightsec->ceilingplane.PointOnSide(PolyRenderer::Instance()->Viewpoint.Pos) <= 0 && orgceilz > refceilz && !(s->MoreFlags & SECMF_FAKEFLOORONLY))
{
// Above-ceiling hack
tempsec.ceilingplane = s->ceilingplane;
@ -542,7 +542,7 @@ PolyTransferHeights::PolyTransferHeights(subsector_t *sub) : Subsector(sub)
tempsec.planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
}
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
tempsec.lightlevel = s->lightlevel;

View file

@ -468,15 +468,16 @@ enum
// Internal sector flags
enum
{
SECF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor
SECF_CLIPFAKEPLANES = 4, // as a heightsec, clip planes to target sector's planes
SECF_NOFAKELIGHT = 8, // heightsec does not change lighting
SECF_IGNOREHEIGHTSEC= 16, // heightsec is only for triggering sector actions
SECF_UNDERWATER = 32, // sector is underwater
SECF_FORCEDUNDERWATER= 64, // sector is forced to be underwater
SECF_UNDERWATERMASK = 32+64,
SECF_DRAWN = 128, // sector has been drawn at least once
SECF_HIDDEN = 256, // Do not draw on textured automap
SECMF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor
SECMF_CLIPFAKEPLANES = 4, // as a heightsec, clip planes to target sector's planes
SECMF_NOFAKELIGHT = 8, // heightsec does not change lighting
SECMF_IGNOREHEIGHTSEC = 16, // heightsec is only for triggering sector actions
SECMF_UNDERWATER = 32, // sector is underwater
SECMF_FORCEDUNDERWATER = 64, // sector is forced to be underwater
SECMF_UNDERWATERMASK = 32+64,
SECMF_DRAWN = 128, // sector has been drawn at least once
SECMF_HIDDEN = 256, // Do not draw on textured automap
SECMF_OVERLAPPING = 512, // floor and ceiling overlap and require special renderer action.
};
enum
@ -656,7 +657,7 @@ public:
sector_t *GetHeightSec() const
{
return (MoreFlags & SECF_IGNOREHEIGHTSEC)? nullptr : heightsec;
return (MoreFlags & SECMF_IGNOREHEIGHTSEC)? nullptr : heightsec;
}
double GetFriction(int plane = sector_t::floor, double *movefac = NULL) const;
@ -847,15 +848,23 @@ public:
return planes[pos].TexZ;
}
void SetPlaneTexZQuick(int pos, double val) // For the *FakeFlat functions which do not need to have the overlap checked.
{
planes[pos].TexZ = val;
}
void SetPlaneTexZ(int pos, double val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code.
{
planes[pos].TexZ = val;
if (dirtify) SetAllVerticesDirty();
CheckOverlap();
}
void ChangePlaneTexZ(int pos, double val)
{
planes[pos].TexZ += val;
SetAllVerticesDirty();
CheckOverlap();
}
static inline short ClampLight(int level)
@ -926,6 +935,7 @@ public:
DVector2 GetPortalDisplacement(int plane);
int GetPortalType(int plane);
int GetOppositePortalGroup(int plane);
void CheckOverlap();
void SetVerticesDirty()
{
@ -1412,7 +1422,7 @@ struct seg_t
enum
{
SSECF_DEGENERATE = 1,
SSECF_DRAWN = 2,
SSECMF_DRAWN = 2,
SSECF_POLYORG = 4,
};

View file

@ -101,7 +101,7 @@ namespace swrenderer
{
if (Thread->ClipSegments->Check(WallC.sx1, WallC.sx2))
{
mSubsector->flags |= SSECF_DRAWN;
mSubsector->flags |= SSECMF_DRAWN;
}
return;
}
@ -171,11 +171,11 @@ namespace swrenderer
{
// When using GL nodes, do a clipping test for these lines so we can
// mark their subsectors as visible for automap texturing.
if (hasglnodes && !(mSubsector->flags & SSECF_DRAWN))
if (hasglnodes && !(mSubsector->flags & SSECMF_DRAWN))
{
if (Thread->ClipSegments->Check(WallC.sx1, WallC.sx2))
{
mSubsector->flags |= SSECF_DRAWN;
mSubsector->flags |= SSECMF_DRAWN;
}
}
return;
@ -187,7 +187,7 @@ namespace swrenderer
if (visible)
{
mSubsector->flags |= SSECF_DRAWN;
mSubsector->flags |= SSECMF_DRAWN;
}
}

View file

@ -155,7 +155,7 @@ namespace swrenderer
bool underwater = r_fakingunderwater ||
(heightsec && heightsec->floorplane.PointOnSide(Thread->Viewport->viewpoint.Pos) <= 0);
bool doorunderwater = false;
int diffTex = (s->MoreFlags & SECF_CLIPFAKEPLANES);
int diffTex = (s->MoreFlags & SECMF_CLIPFAKEPLANES);
// Replace sector being drawn with a copy to be hacked
*tempsec = *sec;
@ -167,12 +167,12 @@ namespace swrenderer
{
tempsec->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false);
}
else if (s->MoreFlags & SECF_FAKEFLOORONLY)
else if (s->MoreFlags & SECMF_FAKEFLOORONLY)
{
if (underwater)
{
tempsec->Colormap = s->Colormap;
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
tempsec->lightlevel = s->lightlevel;
@ -197,7 +197,7 @@ namespace swrenderer
tempsec->floorplane = s->floorplane;
}
if (!(s->MoreFlags & SECF_FAKEFLOORONLY))
if (!(s->MoreFlags & SECMF_FAKEFLOORONLY))
{
if (diffTex)
{
@ -271,7 +271,7 @@ namespace swrenderer
tempsec->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform;
}
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
tempsec->lightlevel = s->lightlevel;
@ -288,7 +288,7 @@ namespace swrenderer
FakeSide = WaterFakeSide::BelowFloor;
}
else if (heightsec && heightsec->ceilingplane.PointOnSide(Thread->Viewport->viewpoint.Pos) <= 0 &&
orgceilz > refceilz && !(s->MoreFlags & SECF_FAKEFLOORONLY))
orgceilz > refceilz && !(s->MoreFlags & SECMF_FAKEFLOORONLY))
{ // Above-ceiling hack
tempsec->ceilingplane = s->ceilingplane;
tempsec->floorplane = s->ceilingplane;
@ -307,7 +307,7 @@ namespace swrenderer
tempsec->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform;
}
if (!(s->MoreFlags & SECF_NOFAKELIGHT))
if (!(s->MoreFlags & SECMF_NOFAKELIGHT))
{
tempsec->lightlevel = s->lightlevel;
@ -517,7 +517,7 @@ namespace swrenderer
}
frontsector = sub->sector;
frontsector->MoreFlags |= SECF_DRAWN;
frontsector->MoreFlags |= SECMF_DRAWN;
count = sub->numlines;
line = sub->firstline;

View file

@ -128,7 +128,7 @@ namespace swrenderer
{
if (gzt < heightsec->floorplane.ZatPoint(pos))
return;
if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPoint(pos))
if (!(heightsec->MoreFlags & SECMF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPoint(pos))
return;
}
}

View file

@ -197,7 +197,7 @@ namespace swrenderer
hzb = MAX(hzb, hz);
}
}
if (spr->FakeFlatStat != WaterFakeSide::BelowFloor && !(spr->heightsec->MoreFlags & SECF_FAKEFLOORONLY))
if (spr->FakeFlatStat != WaterFakeSide::BelowFloor && !(spr->heightsec->MoreFlags & SECMF_FAKEFLOORONLY))
{
double hz = spr->heightsec->ceilingplane.ZatPoint(spr->gpos);
int h = xs_RoundToInt(viewport->CenterY - (hz - viewport->viewpoint.Pos.Z) * scale);

View file

@ -113,7 +113,7 @@ namespace swrenderer
{
if (gzt < heightsec->floorplane.ZatPoint(pos))
return;
if (!(heightsec->MoreFlags & SECF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPoint(pos))
if (!(heightsec->MoreFlags & SECMF_FAKEFLOORONLY) && gzb >= heightsec->ceilingplane.ZatPoint(pos))
return;
}
}