- some Transfer_Heights related optimizations.

* only call hw_CheckViewArea if the result is not known yet.
* check the map up front if it even contains heightsecs. This allows to shortcut the above check entirely for maps without sector transfers and will allow further optimizations.
This commit is contained in:
Christoph Oelckers 2018-05-01 09:02:24 +02:00
parent b35213741f
commit 3c49804c6c
7 changed files with 12 additions and 7 deletions

View file

@ -1483,6 +1483,7 @@ void G_InitLevelLocals ()
level.Music = info->Music; level.Music = info->Music;
level.musicorder = info->musicorder; level.musicorder = info->musicorder;
level.MusicVolume = 1.f; level.MusicVolume = 1.f;
level.HasHeightSecs = false;
level.LevelName = level.info->LookupLevelName(); level.LevelName = level.info->LookupLevelName();
level.NextMap = info->NextMap; level.NextMap = info->NextMap;

View file

@ -151,6 +151,7 @@ struct FLevelLocals
int8_t WallHorizLight; int8_t WallHorizLight;
bool FromSnapshot; // The current map was restored from a snapshot bool FromSnapshot; // The current map was restored from a snapshot
bool HasHeightSecs; // true if some Transfer_Heights effects are present in the map. If this is false, some checks in the renderer can be shortcut.
double teamdamage; double teamdamage;

View file

@ -140,7 +140,7 @@ void GLSceneDrawer::AddLine (seg_t *seg, bool portalclip)
else else
{ {
// clipping checks are only needed when the backsector is not the same as the front sector // clipping checks are only needed when the backsector is not the same as the front sector
in_area = hw_CheckViewArea(in_area, seg->v1, seg->v2, seg->frontsector, seg->backsector); if (in_area == area_default) in_area = hw_CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector);
backsector = hw_FakeFlat(seg->backsector, &bs, in_area, true); backsector = hw_FakeFlat(seg->backsector, &bs, in_area, true);

View file

@ -111,7 +111,7 @@ void GLSceneDrawer::SetViewArea()
} }
else else
{ {
in_area = area_default; // depends on exposed lower sectors in_area = level.HasHeightSecs? area_default : area_normal; // depends on exposed lower sectors, if map contains heightsecs.
} }
} }

View file

@ -153,13 +153,14 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
//========================================================================== //==========================================================================
// //
// check for levels with exposed lower areas // check for levels with exposed lower areas. May only be called if actual
// state is not known yet!
// //
//========================================================================== //==========================================================================
area_t hw_CheckViewArea(area_t in_area, vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector) area_t hw_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector)
{ {
if (in_area == area_default && if (
(backsector->heightsec && !(backsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) && (backsector->heightsec && !(backsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) &&
(!frontsector->heightsec || frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) (!frontsector->heightsec || frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC))
{ {
@ -176,7 +177,7 @@ area_t hw_CheckViewArea(area_t in_area, vertex_t *v1, vertex_t *v2, sector_t *fr
else else
return area_normal; return area_normal;
} }
return in_area; return area_default;
} }

View file

@ -12,5 +12,5 @@ enum area_t : int
// Global functions. Make them members of GLRenderer later? // Global functions. Make them members of GLRenderer later?
bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector); bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector);
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
area_t hw_CheckViewArea(area_t in_area, vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector); area_t hw_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector);

View file

@ -1343,6 +1343,7 @@ void P_SpawnSpecials (void)
case Transfer_Heights: case Transfer_Heights:
{ {
sec = line.frontsector; sec = line.frontsector;
if (line.args[1] & 2) if (line.args[1] & 2)
{ {
sec->MoreFlags |= SECF_FAKEFLOORONLY; sec->MoreFlags |= SECF_FAKEFLOORONLY;
@ -1363,6 +1364,7 @@ void P_SpawnSpecials (void)
{ {
sec->MoreFlags |= SECF_IGNOREHEIGHTSEC; sec->MoreFlags |= SECF_IGNOREHEIGHTSEC;
} }
else level.HasHeightSecs = true;
if (line.args[1] & 32) if (line.args[1] & 32)
{ {
sec->MoreFlags |= SECF_NOFAKELIGHT; sec->MoreFlags |= SECF_NOFAKELIGHT;