slight portal cleanup
This commit is contained in:
1 parent
58815ae9c4
commit
b19bc7d77e
1 file changed
+85
-92
+85
-92
@@ -116,11 +116,8 @@ consvar_t cv_grrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, grrenderdi
|
||||
NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_grportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_nostencil = {"nostencil", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_portalline = {"portalline", "0", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_portalonly = {"portalonly", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
CV_PossibleValue_t secbright_cons_t[] = {{0, "MIN"}, {255, "MAX"}, {0, NULL}};
|
||||
|
||||
CV_PossibleValue_t secbright_cons_t[] = {{0, "MIN"}, {255, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_secbright = {"secbright", "0", CV_SAVE, secbright_cons_t,
|
||||
NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
@@ -5389,7 +5386,7 @@ static void HWR_PortalClipping(gl_portal_t *portal)
|
||||
gld_clipper_SafeAddClipRange(angle2, angle1);
|
||||
}
|
||||
|
||||
enum
|
||||
enum
|
||||
{
|
||||
HWR_STENCIL_NORMAL,
|
||||
HWR_STENCIL_BEGIN,
|
||||
@@ -5401,7 +5398,7 @@ enum
|
||||
// Changes the current stencil state.
|
||||
static void HWR_SetStencilState(int state, int level)
|
||||
{
|
||||
if (!cv_nostencil.value && level > -1)
|
||||
if (level > -1)
|
||||
HWD.pfnSetSpecialState(HWD_SET_STENCIL_LEVEL, level);
|
||||
HWD.pfnSetSpecialState(HWD_SET_PORTAL_MODE, state);
|
||||
}
|
||||
@@ -5469,8 +5466,9 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
|
||||
gl_portal_t *gl_portal_temp;
|
||||
portallist.base = portallist.cap = NULL;
|
||||
const boolean skybox = (skyboxmo[0] && cv_skybox.value);
|
||||
boolean useportals = gr_maphasportals && cv_grportals.value && allow_portals;
|
||||
|
||||
if (cv_grportals.value && gr_maphasportals && allow_portals && stencil_level < cv_maxportals.value) // if recursion limit is not reached
|
||||
if (useportals && stencil_level < cv_maxportals.value) // if recursion limit is not reached
|
||||
{
|
||||
// search for portals in current frame
|
||||
currentportallist = &portallist;
|
||||
@@ -5490,8 +5488,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
|
||||
// note: if necessary, could sort the portals here?
|
||||
for (portal = portallist.base; portal; portal = portal->next)
|
||||
{
|
||||
if (cv_portalline.value && cv_portalline.value != portal->startline)
|
||||
continue;
|
||||
HWR_RenderPortal(portal, rootportal, fpov, player, stencil_level);
|
||||
}
|
||||
gr_portal = GRPORTAL_INSIDE;// when portal walls are encountered in following bsp traversal, nothing should be drawn
|
||||
@@ -5501,13 +5497,14 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
|
||||
|
||||
// draw normal things in current frame in current incremented stencil buffer area
|
||||
HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level);
|
||||
if (!cv_portalonly.value || rootportal)
|
||||
{
|
||||
HWR_SetTransform(fpov, player);
|
||||
|
||||
HWR_ClearClipper();
|
||||
HWR_ClearSprites();
|
||||
HWR_SetTransform(fpov, player);
|
||||
|
||||
HWR_ClearSprites();
|
||||
HWR_ClearClipper();
|
||||
|
||||
if (useportals)
|
||||
{
|
||||
if (!rootportal)
|
||||
portalclipline = NULL;
|
||||
else
|
||||
@@ -5515,70 +5512,72 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
|
||||
HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search
|
||||
HWR_PortalClipping(rootportal);
|
||||
}
|
||||
|
||||
// Set transform.
|
||||
HWD.pfnSetTransform(&atransform);
|
||||
|
||||
validcount++;
|
||||
|
||||
ps_numbspcalls.value.i = 0;
|
||||
ps_numpolyobjects.value.i = 0;
|
||||
PS_START_TIMING(ps_bsptime);
|
||||
|
||||
if (cv_grbatching.value)
|
||||
HWR_StartBatching();
|
||||
|
||||
if (!rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently
|
||||
gr_collect_skywalls = true;
|
||||
|
||||
// HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree.
|
||||
// This fixes specific effects not working, such as horizon lines.
|
||||
int oldgl_portal_state = gr_portal;
|
||||
|
||||
if (gr_portal != GRPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans
|
||||
gr_portal = GRPORTAL_INSIDE; // TURN IT OFF
|
||||
|
||||
// Recursively "render" the BSP tree.
|
||||
HWR_RenderBSPNode((INT32)numnodes-1);
|
||||
|
||||
// woo we back
|
||||
gr_portal = oldgl_portal_state;
|
||||
|
||||
if (allow_portals) // looks weird, but this is only true when its not skybox rendering skipping precip in skyboxes like software does
|
||||
HWR_AddPrecipitationSprites();
|
||||
|
||||
PS_STOP_TIMING(ps_bsptime);
|
||||
|
||||
if (cv_grbatching.value)
|
||||
HWR_RenderBatches();
|
||||
|
||||
if (skyWallVertexArraySize)// if there are skywalls to draw using the alternate method
|
||||
{
|
||||
HWR_SetStencilState(HWR_STENCIL_SKY, -1);
|
||||
HWR_DrawSkyWallList();
|
||||
HWR_SkyWallList_Clear();
|
||||
HWR_SetStencilState(HWR_STENCIL_NORMAL, 1);
|
||||
drewsky = false;
|
||||
HWR_DrawSkyBackground(fpov);
|
||||
HWR_SetStencilState(HWR_STENCIL_NORMAL, 0);
|
||||
HWD.pfnClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer
|
||||
HWR_SetTransform(fpov, player);// restore transform
|
||||
}
|
||||
gr_collect_skywalls = false;
|
||||
|
||||
ps_numsprites.value.i = gr_visspritecount;
|
||||
PS_START_TIMING(ps_hw_spritesorttime);
|
||||
HWR_SortVisSprites();
|
||||
PS_STOP_TIMING(ps_hw_spritesorttime);
|
||||
PS_START_TIMING(ps_hw_spritedrawtime);
|
||||
HWR_DrawSprites();
|
||||
PS_STOP_TIMING(ps_hw_spritedrawtime);
|
||||
|
||||
ps_numdrawnodes.value.i = 0;
|
||||
ps_hw_nodesorttime.value.p = 0;
|
||||
ps_hw_nodedrawtime.value.p = 0;
|
||||
HWR_RenderDrawNodes();
|
||||
}
|
||||
else
|
||||
portalclipline = NULL;
|
||||
|
||||
// Set transform.
|
||||
HWD.pfnSetTransform(&atransform);
|
||||
|
||||
validcount++;
|
||||
|
||||
ps_numbspcalls.value.i = 0;
|
||||
ps_numpolyobjects.value.i = 0;
|
||||
PS_START_TIMING(ps_bsptime);
|
||||
|
||||
if (cv_grbatching.value)
|
||||
HWR_StartBatching();
|
||||
|
||||
if (useportals && !rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently
|
||||
gr_collect_skywalls = true;
|
||||
|
||||
// HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree.
|
||||
// This fixes specific effects not working, such as horizon lines.
|
||||
int oldgl_portal_state = gr_portal;
|
||||
|
||||
if (gr_portal != GRPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans
|
||||
gr_portal = GRPORTAL_INSIDE; // TURN IT OFF
|
||||
|
||||
// Recursively "render" the BSP tree.
|
||||
HWR_RenderBSPNode((INT32)numnodes-1);
|
||||
|
||||
// woo we back
|
||||
gr_portal = oldgl_portal_state;
|
||||
|
||||
if (allow_portals) // looks weird, but this is only true when its not skybox rendering skipping precip in skyboxes like software does
|
||||
HWR_AddPrecipitationSprites();
|
||||
|
||||
PS_STOP_TIMING(ps_bsptime);
|
||||
|
||||
if (cv_grbatching.value)
|
||||
HWR_RenderBatches();
|
||||
|
||||
if (skyWallVertexArraySize) // if there are skywalls to draw using the alternate method
|
||||
{
|
||||
HWR_SetStencilState(HWR_STENCIL_SKY, -1);
|
||||
HWR_DrawSkyWallList();
|
||||
HWR_SkyWallList_Clear();
|
||||
HWR_SetStencilState(HWR_STENCIL_NORMAL, 1);
|
||||
drewsky = false;
|
||||
HWR_DrawSkyBackground(fpov);
|
||||
HWR_SetStencilState(HWR_STENCIL_NORMAL, 0);
|
||||
HWD.pfnClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer
|
||||
HWR_SetTransform(fpov, player);// restore transform
|
||||
}
|
||||
gr_collect_skywalls = false;
|
||||
|
||||
ps_numsprites.value.i = gr_visspritecount;
|
||||
PS_START_TIMING(ps_hw_spritesorttime);
|
||||
HWR_SortVisSprites();
|
||||
PS_STOP_TIMING(ps_hw_spritesorttime);
|
||||
PS_START_TIMING(ps_hw_spritedrawtime);
|
||||
HWR_DrawSprites();
|
||||
PS_STOP_TIMING(ps_hw_spritedrawtime);
|
||||
|
||||
ps_numdrawnodes.value.i = 0;
|
||||
ps_hw_nodesorttime.value.p = 0;
|
||||
ps_hw_nodedrawtime.value.p = 0;
|
||||
HWR_RenderDrawNodes();
|
||||
|
||||
// free memory from portal list allocated by calls to Add2Lines
|
||||
gl_portal_temp = portallist.base;
|
||||
@@ -5588,9 +5587,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
|
||||
Z_Free(gl_portal_temp);
|
||||
gl_portal_temp = nextportal;
|
||||
}
|
||||
|
||||
// TODO: batching at some point
|
||||
// TODO: is it okay if stencil test is on all the time even when its not needed?
|
||||
}
|
||||
|
||||
|
||||
@@ -5790,7 +5786,7 @@ void HWR_AddCommands(void)
|
||||
CV_RegisterVar(&cv_grfiltermode);
|
||||
CV_RegisterVar(&cv_granisotropicmode);
|
||||
CV_RegisterVar(&cv_grsolvetjoin);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grbatching);
|
||||
|
||||
CV_RegisterVar(&cv_splitwallfix);
|
||||
@@ -5800,25 +5796,22 @@ void HWR_AddCommands(void)
|
||||
CV_RegisterVar(&cv_grfakecontrast);
|
||||
CV_RegisterVar(&cv_grslopecontrast);
|
||||
CV_RegisterVar(&cv_grhorizonlines);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grfovchange);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grmdls);
|
||||
CV_RegisterVar(&cv_grfallbackplayermodel);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grspritebillboarding);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grshearing);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grshaders);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grportals);
|
||||
CV_RegisterVar(&cv_nostencil);
|
||||
CV_RegisterVar(&cv_portalline);
|
||||
CV_RegisterVar(&cv_portalonly);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_secbright);
|
||||
|
||||
|
||||
CV_RegisterVar(&cv_grpaletterendering);
|
||||
CV_RegisterVar(&cv_grpalettedepth);
|
||||
CV_RegisterVar(&cv_grflashpal);
|
||||
|
||||
Reference in new issue
Block a user