diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 3c372169c..e80754d2a 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -48,6 +48,10 @@ typedef struct // if no portals are found, the portal scanning phase can be skipped while rendering, saving a bit of time. boolean gl_maphasportals = false; +// Determine on mapload if current map has any Horizonlines present +// so we can avoid rather hot checks in HWR_Subsector +boolean gl_maphashorizonlines = false; + // ========================================================================== // FLOOR & CEILING CONVEX POLYS GENERATION // ========================================================================== @@ -370,6 +374,9 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) gl_maphasportals = 1; } + if (!gl_maphashorizonlines && line->special == HORIZONSPECIAL) + gl_maphashorizonlines = true; + if (line->sidenum[1] != 0xffff) { if (sides[line->sidenum[0]].sector == sides[line->sidenum[1]].sector) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 77a03a985..fa9c87e74 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -97,8 +97,6 @@ line_t *gl_linedef; sector_t *gl_frontsector; sector_t *gl_backsector; -static boolean gl_maphashorizonlines = false; - // values for the far clipping plane static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; // values for bsp culling @@ -5777,42 +5775,7 @@ void HWR_RenderPlayerView(void) HWR_RenderFrame(player, false); } -// Determine on mapload if current map has any Horizonlines present -// so we can avoid rather hot checks in HWR_Subsector -static void HWR_CheckForHorizonLines(void) -{ - size_t i; - INT32 h; - - gl_maphashorizonlines = false; - - if (!cv_glhorizonlines.value) - return; - - for (i = 0; i < numsubsectors; i++) - { - subsector_t *subsec = &subsectors[i]; - - // sector checked already? - if (subsec->validcount == validcount) - continue; - - subsec->validcount = validcount; - - seg_t *line = &segs[subsec->firstline]; - - for (h = 0; h < subsec->numlines; h++, line++) - { - if (line->linedef->special != HORIZONSPECIAL) - continue; - - gl_maphashorizonlines = true; - break; - } - } -} - -void HWR_LoadLevel(boolean reloadinggamestate) +void HWR_LoadLevel(void) { HWR_CreatePlanePolygons((INT32)numnodes - 1); @@ -5820,9 +5783,6 @@ void HWR_LoadLevel(boolean reloadinggamestate) HWR_ClearSkyDome(); HWR_BuildSkyDome(); - if (!reloadinggamestate) - HWR_CheckForHorizonLines(); - if (HWR_ShouldUsePaletteRendering()) HWR_SetMapPalette(); } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 6a2af8791..c3cae5751 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -178,6 +178,7 @@ void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom // hw_bsp.c void HWR_CreatePlanePolygons(INT32 bspnum); extern boolean gl_maphasportals; +extern boolean gl_maphashorizonlines; // Console variables extern CV_PossibleValue_t glanisotropicmode_cons_t[]; diff --git a/src/p_setup.c b/src/p_setup.c index 7f6ecc69d..7122dca53 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2998,7 +2998,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) { HWR_FreeExtraSubsectors(); // Create plane polygons. - HWR_LoadLevel(reloadinggamestate); + HWR_LoadLevel(); } #endif diff --git a/src/p_setup.h b/src/p_setup.h index 8542aa8dc..5d4a3b9da 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -68,7 +68,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global); boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER -void HWR_LoadLevel(boolean reloadinggamestate); +void HWR_LoadLevel(void); #endif boolean P_AddWadFile(const char *wadfilename, boolean local);