diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 9357d9f42..6eab057f5 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 // ========================================================================== @@ -383,6 +387,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; + p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x); p1.y = FIXED_TO_FLOAT(lseg->side ? line->v2->y : line->v1->y); p2.x = FIXED_TO_FLOAT(lseg->side ? line->v1->x : line->v2->x); @@ -906,8 +913,8 @@ void HWR_CreatePlanePolygons(INT32 bspnum) I_FinishUpdate(); // page flip or blit buffer #endif - // reset the portal flag - gl_maphasportals = 0; + // reset the portal and horizonline flag + gl_maphasportals = gl_maphashorizonlines = 0; // find min/max boundaries of map //CONS_Debug(DBG_RENDER, "Looking for boundaries of map...\n"); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index bcda9216c..dd33dcdc9 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 @@ -5749,42 +5747,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); @@ -5792,9 +5755,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 2ffbfd506..29d17a5ca 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -175,6 +175,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 4c311024e..015fea71a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3012,7 +3012,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);