From 888aa8bf729e7b8a38bc9fec778d3d679da57077 Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Wed, 31 Jan 2024 16:27:01 -0300 Subject: [PATCH] Fixes: - Fixed regression in R_RenderMaskedSegRange - OpenGL: Only render edges on two-sided lines if they are textured --- src/hardware/hw_main.c | 14 ++++++++++++++ src/r_segs.c | 24 +++++++++--------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ec00398be..706a2415a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1968,6 +1968,9 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gl_backsector) { INT32 gl_toptexture = 0, gl_bottomtexture = 0; + + boolean has_top = false, has_bottom = false; + fixed_t texturevpeg; SLOPEPARAMS(gl_backsector->c_slope, worldhigh, worldhighslope, gl_backsector->ceilingheight) @@ -2079,6 +2082,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); + + has_top = true; } // check BOTTOM TEXTURE @@ -2164,6 +2169,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); + + has_bottom = true; } // Render midtexture if there's one @@ -2174,7 +2181,14 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { // Render extra textures for (unsigned i = 0; i < NUM_WALL_OVERLAYS; i++) + { + if (IS_TOP_EDGE_TEXTURE(i) && !has_top) + continue; + if (IS_BOTTOM_EDGE_TEXTURE(i) && !has_bottom) + continue; + HWR_RenderExtraTexture(i, gl_sidedef, gl_frontsector, gl_backsector, NULL, NULL, vs, ve, cliplow, cliphigh, Surf, PF_Masked); + } // Sky culling // No longer so much a mess as before! diff --git a/src/r_segs.c b/src/r_segs.c index 156f4f4eb..fc244534a 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -285,8 +285,6 @@ INT32 R_GetOverlayTextureRepeats(unsigned which, side_t *side, INT32 texnum, sec // Setup lighting based on the presence/lack-of 3D floors. static void R_PrepareMaskedSegLightlist(drawseg_t *ds, INT32 range) { - lightlist_t *light; - r_lightlist_t *rlight; INT32 lightnum; dc_numlights = 0; @@ -294,7 +292,7 @@ static void R_PrepareMaskedSegLightlist(drawseg_t *ds, INT32 range) if (frontsector->numlights) { dc_numlights = frontsector->numlights; - if (dc_numlights >= dc_maxlights) + if (dc_numlights > dc_maxlights) { dc_maxlights = dc_numlights; dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL); @@ -302,20 +300,14 @@ static void R_PrepareMaskedSegLightlist(drawseg_t *ds, INT32 range) for (INT32 i = 0; i < dc_numlights; i++) { - fixed_t leftheight, rightheight; - light = &frontsector->lightlist[i]; - rlight = &dc_lightlist[i]; - leftheight = P_GetLightZAt(light, ds-> leftpos.x, ds-> leftpos.y); - rightheight = P_GetLightZAt(light, ds->rightpos.x, ds->rightpos.y); - - leftheight -= viewz; - rightheight -= viewz; + lightlist_t *light = &frontsector->lightlist[i]; + r_lightlist_t *rlight = &dc_lightlist[i]; + fixed_t leftheight = P_GetLightZAt(light, ds-> leftpos.x, ds-> leftpos.y) - viewz; + fixed_t rightheight = P_GetLightZAt(light, ds->rightpos.x, ds->rightpos.y) - viewz; rlight->height = (centeryfrac) - FixedMul(leftheight , ds->scale1); rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - //if (x1 > ds->x1) - //rlight->height -= (x1 - ds->x1)*rlight->heightstep; rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->lightlevel = *light->lightlevel; rlight->extra_colormap = *light->extra_colormap; @@ -469,6 +461,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; } + dc_transmap = NULL; + if (blendmode == AST_FOG) { colfunc = colfuncs[COLDRAWFUNC_FOG]; @@ -479,7 +473,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) { if (blendmode) dc_transmap = R_GetBlendTable(blendmode, blendlevel); - else + else if (blendlevel > 0 && blendlevel < 10) dc_transmap = R_GetTranslucencyTable(blendlevel); if (dc_transmap) @@ -3265,7 +3259,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (frontsector->numlights) { dc_numlights = frontsector->numlights; - if (dc_numlights >= dc_maxlights) + if (dc_numlights > dc_maxlights) { dc_maxlights = dc_numlights; dc_lightlist = Z_Realloc(dc_lightlist, sizeof (*dc_lightlist) * dc_maxlights, PU_STATIC, NULL);