From 9314a24cb22de1aefcc95189d415ed4ff38f94cb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 02:37:08 +0200 Subject: [PATCH 01/12] use highly optmized (but slightly inaccurate) version of R_PointOnSide for rendering --- src/hardware/hw_main.c | 2 +- src/r_bsp.c | 3 ++- src/r_main.h | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 99821ca6c..96662c3cc 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3325,7 +3325,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) bsp = &nodes[bspnum]; // Decide which side the view point is on. - side = R_PointOnSide(viewx, viewy, bsp); + side = R_PointOnSideRender(viewx, viewy, bsp); // Recursively divide front space. if (HWR_PortalCheckBBox(bsp->bbox[side])) diff --git a/src/r_bsp.c b/src/r_bsp.c index 586aa3799..20380acb5 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1319,7 +1319,8 @@ void R_RenderBSPNode(INT32 bspnum) bsp = &nodes[bspnum]; // Decide which side the view point is on. - side = R_PointOnSide(viewx, viewy, bsp); + side = R_PointOnSideRender(viewx, viewy, bsp); + // Recursively divide front space. R_RenderBSPNode(bsp->children[side]); diff --git a/src/r_main.h b/src/r_main.h index 22c073992..43927e909 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -74,6 +74,12 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // Utility functions. INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node); +FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideRender(fixed_t x, fixed_t y, const node_t *node) +{ + // use cross product to determine side quickly + return (INT64)(y - node->y) * node->dx - (INT64)(x - node->x) * node->dy > 0; +} + FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) { fixed_t lx = line->v1->x; From 8cbf798de8407b5264093e533e7cf389a3dab8e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 22 Oct 2024 20:20:30 +0200 Subject: [PATCH 02/12] redo rain sound overflow fix https://git.do.srb2.org/KartKrew/RingRacers/-/commit/3eac1fed0f44a8285a9f6b82a12e86997bbb0d34 --- src/p_mobj.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 6d97a0f57..5b7d25fd2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10284,7 +10284,7 @@ void P_PrecipitationEffects(void) INT32 volume; size_t i; - boolean sounds_rain = true; + boolean rainsfx = true; boolean sounds_thunder = true; boolean effects_lightning = true; boolean lightningStrike = false; @@ -10317,7 +10317,7 @@ void P_PrecipitationEffects(void) effects_lightning = false; break; case PRECIP_STORM_NORAIN: // no rain, lightning and thunder allowed - sounds_rain = false; + rainsfx = false; case PRECIP_STORM: // everything. break; default: @@ -10325,6 +10325,8 @@ void P_PrecipitationEffects(void) return; } + boolean sounds_rain = (rainsfx && (!leveltime || leveltime % 80 == 1)); + // Currently thunderstorming with lightning, and we're sounding the thunder... // and where there's thunder, there's gotta be lightning! if (effects_lightning && lightningStrike) @@ -10344,38 +10346,57 @@ void P_PrecipitationEffects(void) if (sound_disabled) return; // Sound off? D'aw, no fun. + if (!sounds_rain && !sounds_thunder) + return; // no need to calculate volume at ALL + if (players[displayplayers[0]].mo->subsector->sector->ceilingpic == skyflatnum) volume = 255; // Sky above? We get it full blast. else { /* GCC is optimizing away y >= yl, FUCK YOU */ - volatile fixed_t x, y, yl, yh, xl, xh; + INT64 x, y, yl, yh, xl, xh; fixed_t closedist, newdist; // Essentially check in a 1024 unit radius of the player for an outdoor area. - yl = players[displayplayers[0]].mo->y - 1024*FRACUNIT; - yh = players[displayplayers[0]].mo->y + 1024*FRACUNIT; - xl = players[displayplayers[0]].mo->x - 1024*FRACUNIT; - xh = players[displayplayers[0]].mo->x + 1024*FRACUNIT; - closedist = 2048*FRACUNIT; +#define RADIUSSTEP (64*FRACUNIT) +#define SEARCHRADIUS (16*RADIUSSTEP) + yl = yh = players[displayplayers[0]].mo->y; + yl -= SEARCHRADIUS; + while (yl < INT32_MIN) + yl += RADIUSSTEP; + yh += SEARCHRADIUS; + while (yh > INT32_MAX) + yh -= RADIUSSTEP; - for (y = yl; y >= yl && y <= yh; y += FRACUNIT*64) - for (x = xl; x >= xl && x <= xh; x += FRACUNIT*64) + xl = xh = players[displayplayers[0]].mo->x; + xl -= SEARCHRADIUS; + while (xl < INT32_MIN) + xl += RADIUSSTEP; + xh += SEARCHRADIUS; + while (xh > INT32_MAX) + xh -= RADIUSSTEP; + + closedist = SEARCHRADIUS*2; +#undef SEARCHRADIUS + for (y = yl; y <= yh; y += RADIUSSTEP) + for (x = xl; x <= xh; x += RADIUSSTEP) { - if (R_PointInSubsector(x, y)->sector->ceilingpic != skyflatnum) // Found the outdoors! + if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors! continue; - newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, x, y, 0); + newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0); + if (newdist < closedist) closedist = newdist; } volume = 255 - (closedist>>(FRACBITS+2)); } +#undef RADIUSSTEP volume = CLAMP(volume, 0, 255); - if (sounds_rain && (!leveltime || leveltime % 80 == 1)) + if (sounds_rain) S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume); if (!sounds_thunder) From 63ca366bd8d5a16bbc9abc5103dce0874d553e65 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 13:00:22 +0200 Subject: [PATCH 03/12] dont play rain sounds when weather is disabled --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 5b7d25fd2..b79c4e0b2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10325,7 +10325,7 @@ void P_PrecipitationEffects(void) return; } - boolean sounds_rain = (rainsfx && (!leveltime || leveltime % 80 == 1)); + boolean sounds_rain = ((cv_drawdist_precip.value != 0) && rainsfx && (!leveltime || leveltime % 80 == 1)); // Currently thunderstorming with lightning, and we're sounding the thunder... // and where there's thunder, there's gotta be lightning! From c5c6f6b820fa76e0057ea98affbe49759ee08b23 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 15:25:07 +0200 Subject: [PATCH 04/12] this does nothing --- src/d_main.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1dfe3eafa..faa7e012a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -99,7 +99,6 @@ UINT8 window_notinfocus = false; // DEMO LOOP // //static INT32 demosequence; -static const char *pagename = "MAP1PIC"; static char *startupwadfiles[MAX_WADFILES]; static char *startuppwads[MAX_WADFILES]; @@ -2071,7 +2070,6 @@ void D_SRB2Main(void) if (dedicated && server) { - pagename = "TITLESKY"; levelstarttic = gametic; G_SetGamestate(GS_LEVEL); if (!P_SetupLevel(false, false)) From 6f8342b9a86de7bb3feb0ded014a98d764657ca3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 21:33:04 +0200 Subject: [PATCH 05/12] remove cv_splitwallfix tbh i dont think anyone even knows about this, never heard any complains, never had any issues, neither visually or performancewise. its just clutter at this point --- src/hardware/hw_main.c | 27 ++++++--------------------- src/hardware/hw_main.h | 1 - src/m_menu.c | 5 ----- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 96662c3cc..929eb78e3 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -106,8 +106,6 @@ consvar_t cv_grbatching = {"gr_batching", "On", 0, CV_OnOff, NULL, 0, NULL, NULL consvar_t cv_grframebuffer = {"gr_framebuffer", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, CV_grframebuffer_OnChange, 0, NULL, NULL, 0, 0, NULL}; #endif -consvar_t cv_splitwallfix = {"splitwallfix", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - static CV_PossibleValue_t grrenderdistance_cons_t[] = { {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, {6, "12288"}, {7, "16384"}, {0, NULL}}; @@ -1094,7 +1092,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, // Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle. // To avoid division by zero, which would result in a NaN, we check if the vertical difference // between the two vertices is not zero. - if (fpclassify(top - bot) == FP_ZERO && cv_splitwallfix.value) + if (fpclassify(top - bot) == FP_ZERO) pegmul = 0.0; else pegmul = (pegb - pegt) / (top - bot); @@ -1104,7 +1102,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, endpegt = wallVerts[2].t; endpegb = wallVerts[1].t; - if (fpclassify(endtop - endbot) == FP_ZERO && cv_splitwallfix.value) + if (fpclassify(endtop - endbot) == FP_ZERO) endpegmul = 0.0; else endpegmul = (endpegb - endpegt) / (endtop - endbot); @@ -1177,13 +1175,10 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, endbheight = endrealbot; } - if (cv_splitwallfix.value) - { - if (endbheight > endtop) - endbot = endtop; - } + if (endbheight > endtop) + endbot = endtop; - if ((endbheight >= endtop && bheight >= top && !cv_splitwallfix.value) || (bheight >= top && cv_splitwallfix.value)) + if (bheight >= top) continue; // Found a break @@ -1193,15 +1188,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (bot < realbot) bot = realbot; - if (cv_splitwallfix.value) - endbot = min(max(endbheight, endrealbot), endtop); - else - { - endbot = endbheight; - - if (endbot < endrealbot) - endbot = endrealbot; - } + endbot = min(max(endbheight, endrealbot), endtop); Surf->PolyColor.s.alpha = alpha; @@ -5689,8 +5676,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grbatching); - CV_RegisterVar(&cv_splitwallfix); - CV_RegisterVar(&cv_grrenderdistance); CV_RegisterVar(&cv_grfakecontrast); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 2abb6dda6..5c3877e56 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -152,7 +152,6 @@ extern consvar_t cv_grshaders; #ifdef USE_FBO_OGL extern consvar_t cv_grframebuffer; #endif -extern consvar_t cv_splitwallfix; extern consvar_t cv_grshearing; extern consvar_t cv_grfov; extern consvar_t cv_grmdls; diff --git a/src/m_menu.c b/src/m_menu.c index 94b5f8f3b..b2a61831d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1498,8 +1498,6 @@ static menuitem_t OP_ExpOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_grframebuffer, 110}, #endif {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_grpalettedepth, 130}, - - {IT_STRING | IT_CVAR, NULL, "Splitwall/Slope texture fix", &cv_splitwallfix, 150}, #endif }; @@ -1517,7 +1515,6 @@ static const char* OP_ExpTooltips[] = "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.", #endif "Change the depth of the Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", - "Fixes issues that resulted in Textures sticking from the ground sometimes.\n This may be CPU heavy and result in worse performance in some cases.", #endif }; @@ -1535,7 +1532,6 @@ enum op_exp_fbo, #endif op_exp_paldepth, - op_exp_spltwal, #endif }; @@ -4724,7 +4720,6 @@ void M_Init(void) #ifdef USE_FBO_OGL OP_ExpOptionsMenu[op_exp_fbo].status = IT_DISABLED; #endif - OP_ExpOptionsMenu[op_exp_spltwal].status = IT_DISABLED; } if (rendermode == render_opengl) From 85f036a45b9e6c92e715b41940b396164d3810e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 19:02:48 +0200 Subject: [PATCH 06/12] dont always calc this twice --- src/hardware/hw_main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 929eb78e3..2c8408959 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1075,6 +1075,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, float endpegt, endpegb, endpegmul; float endheight = 0.0f, endbheight = 0.0f; + float diff; + fixed_t v1x = FloatToFixed(wallVerts[0].x); fixed_t v1y = FloatToFixed(wallVerts[0].z); fixed_t v2x = FloatToFixed(wallVerts[1].x); @@ -1086,26 +1088,30 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; + diff = top - bot; + pegt = wallVerts[3].t; pegb = wallVerts[0].t; // Lactozilla: If both heights of a side lay on the same position, then this wall is a triangle. // To avoid division by zero, which would result in a NaN, we check if the vertical difference // between the two vertices is not zero. - if (fpclassify(top - bot) == FP_ZERO) + if (fpclassify(diff) == FP_ZERO) pegmul = 0.0; else - pegmul = (pegb - pegt) / (top - bot); + pegmul = (pegb - pegt) / diff; endrealtop = endtop = wallVerts[2].y; endrealbot = endbot = wallVerts[1].y; + diff = endtop - endbot; + endpegt = wallVerts[2].t; endpegb = wallVerts[1].t; - if (fpclassify(endtop - endbot) == FP_ZERO) + if (fpclassify(diff) == FP_ZERO) endpegmul = 0.0; else - endpegmul = (endpegb - endpegt) / (endtop - endbot); + endpegmul = (endpegb - endpegt) / diff; for (INT32 i = 0; i < sector->numlights; i++) { From 24dd6ba675319e5acf3c2f7bb0815134984dab07 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 19:51:55 +0200 Subject: [PATCH 07/12] cleanup HWR_ProcessSeg stuff was quite the mess --- src/hardware/hw_main.c | 198 ++++++++++++++++++++--------------------- 1 file changed, 95 insertions(+), 103 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2c8408959..63832d7b9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1422,14 +1422,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t worldhighslope = 0, worldlowslope = 0; fixed_t v1x, v1y, v2x, v2y; - float cliplow = 0.0f, cliphigh = 0.0f; fixed_t h, l; // 3D sides and 2s middle textures fixed_t hS, lS; - FUINT lightnum = 0; // shut up compiler - extracolormap_t *colormap; - FSurfaceInfo Surf; - boolean noencore = false; gr_sidedef = gr_curline->sidedef; @@ -1485,18 +1480,19 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // x offset the texture fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; - cliplow = (float)texturehpeg; - cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); + float cliplow = (float)texturehpeg; + float cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); - lightnum = gr_frontsector->lightlevel; - colormap = gr_frontsector->extra_colormap; + FUINT lightnum = gr_frontsector->lightlevel; + extracolormap_t *colormap = gr_frontsector->extra_colormap; lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); + FSurfaceInfo Surf; + Surf.PolyColor.s.alpha = 255; + if (gr_linedef->flags & ML_TFERLINE) noencore = true; - Surf.PolyColor.s.alpha = 255; - INT32 gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); GLMapTexture_t *grTex = NULL; @@ -1505,6 +1501,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { INT32 gr_toptexture = 0, gr_bottomtexture = 0; + fixed_t texturevpeg; + SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) @@ -1520,8 +1518,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { // Both front and back sectors are sky, needs skywall from the frontsector's ceiling, but only if the // backsector is lower - if ((worldhigh <= worldtop && worldhighslope <= worldtopslope)// Assuming ESLOPE is always on with my changes - && (worldhigh != worldtop || worldhighslope != worldtopslope)) + if ((worldhigh <= worldtop && worldhighslope <= worldtopslope) // Assuming ESLOPE is always on with my changes + && (worldhigh != worldtop || worldhighslope != worldtopslope)) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race { wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); @@ -1597,51 +1595,47 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // check TOP TEXTURE if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gr_toptexture) { + // PEGGING + if (gr_linedef->flags & ML_DONTPEGTOP) + texturevpeg = 0; + else if (gr_linedef->flags & ML_EFFECT1) + texturevpeg = worldhigh + textureheight[gr_toptexture] - worldtop; + else + texturevpeg = gr_backsector->ceilingheight + textureheight[gr_toptexture] - gr_frontsector->ceilingheight; + + texturevpeg += gr_sidedef->rowoffset; + + // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway + texturevpeg %= textureheight[gr_toptexture]; + + grTex = HWR_GetTexture(gr_toptexture, gr_linedef->flags & ML_TFERLINE); + + wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Adjust t value for sloped walls + if (!(gr_linedef->flags & ML_EFFECT1)) { - fixed_t texturevpegtop; // top - - grTex = HWR_GetTexture(gr_toptexture, gr_linedef->flags & ML_TFERLINE); - - // PEGGING - if (gr_linedef->flags & ML_DONTPEGTOP) - texturevpegtop = 0; - else if (gr_linedef->flags & ML_EFFECT1) - texturevpegtop = worldhigh + textureheight[gr_sidedef->toptexture] - worldtop; - else - texturevpegtop = gr_backsector->ceilingheight + textureheight[gr_sidedef->toptexture] - gr_frontsector->ceilingheight; - - texturevpegtop += gr_sidedef->rowoffset; - - // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegtop %= SHORT(textures[gr_toptexture]->height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegtop + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Adjust t value for sloped walls - if (!(gr_linedef->flags & ML_EFFECT1)) - { - // Unskewed - wallVerts[3].t -= (worldtop - gr_frontsector->ceilingheight) * grTex->scaleY; - wallVerts[2].t -= (worldtopslope - gr_frontsector->ceilingheight) * grTex->scaleY; - wallVerts[0].t -= (worldhigh - gr_backsector->ceilingheight) * grTex->scaleY; - wallVerts[1].t -= (worldhighslope - gr_backsector->ceilingheight) * grTex->scaleY; - } - else if (gr_linedef->flags & ML_DONTPEGTOP) - { - // Skewed by top - wallVerts[0].t = (texturevpegtop + worldtop - worldhigh) * grTex->scaleY; - wallVerts[1].t = (texturevpegtop + worldtopslope - worldhighslope) * grTex->scaleY; - } - else - { - // Skewed by bottom - wallVerts[0].t = wallVerts[1].t = (texturevpegtop + worldtop - worldhigh) * grTex->scaleY; - wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY; - wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY; - } + // Unskewed + wallVerts[3].t -= (worldtop - gr_frontsector->ceilingheight) * grTex->scaleY; + wallVerts[2].t -= (worldtopslope - gr_frontsector->ceilingheight) * grTex->scaleY; + wallVerts[0].t -= (worldhigh - gr_backsector->ceilingheight) * grTex->scaleY; + wallVerts[1].t -= (worldhighslope - gr_backsector->ceilingheight) * grTex->scaleY; + } + else if (gr_linedef->flags & ML_DONTPEGTOP) + { + // Skewed by top + wallVerts[0].t = (texturevpeg + worldtop - worldhigh) * grTex->scaleY; + wallVerts[1].t = (texturevpeg + worldtopslope - worldhighslope) * grTex->scaleY; + } + else + { + // Skewed by bottom + wallVerts[0].t = wallVerts[1].t = (texturevpeg + worldtop - worldhigh) * grTex->scaleY; + wallVerts[3].t = wallVerts[0].t - (worldtop - worldhigh) * grTex->scaleY; + wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * grTex->scaleY; } // set top/bottom coords @@ -1659,27 +1653,25 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // check BOTTOM TEXTURE - if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! + if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) { - fixed_t texturevpegbottom = 0; // bottom + // PEGGING + if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) + texturevpeg = 0; + else if (gr_linedef->flags & ML_EFFECT1) + texturevpeg = worldbottom - worldlow; + else + texturevpeg = gr_frontsector->floorheight - gr_backsector->floorheight; + + texturevpeg += gr_sidedef->rowoffset; + + // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway + texturevpeg %= textureheight[gr_bottomtexture]; grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); - // PEGGING - if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) - texturevpegbottom = 0; - else if (gr_linedef->flags & ML_EFFECT1) - texturevpegbottom = worldbottom - worldlow; - else - texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; - - texturevpegbottom += gr_sidedef->rowoffset; - - // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; @@ -1695,15 +1687,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else if (gr_linedef->flags & ML_DONTPEGBOTTOM) { // Skewed by bottom - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this + wallVerts[0].t = wallVerts[1].t = (texturevpeg + worldlow - worldbottom) * grTex->scaleY; wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; } else { // Skewed by top - wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; + wallVerts[0].t = (texturevpeg + worldlow - worldbottom) * grTex->scaleY; + wallVerts[1].t = (texturevpeg + worldlowslope - worldbottomslope) * grTex->scaleY; } // set top/bottom coords @@ -1751,23 +1742,21 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else low = back->floorheight; - repeats = (high - low)/textureheight[gr_sidedef->midtexture]; - if ((high-low)%textureheight[gr_sidedef->midtexture]) + repeats = (high - low) / textureheight[gr_midtexture]; + if ((high - low) % textureheight[gr_midtexture]) repeats++; // tile an extra time to fill the gap -- Monster Iestyn } else repeats = 1; - fixed_t midtexheight = textureheight[gr_midtexture] * repeats; - fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut; - fixed_t popentopslope, popenbottomslope, polytopslope, polybottomslope, lowcutslope, highcutslope; - // SoM: a little note: This code re-arranging will // fix the bug in Nimrod map02. popentop and popenbottom // record the limits the texture can be displayed in. // polytop and polybottom, are the ideal (i.e. unclipped) // heights of the polygon, and h & l, are the final (clipped) // poly coords. + fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut; + fixed_t popentopslope, popenbottomslope, polytopslope, polybottomslope, lowcutslope, highcutslope; // NOTE: With polyobjects, whenever you need to check the properties of the polyobject sector it belongs to, // you must use the linedef's backsector to be correct @@ -1781,39 +1770,40 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { popentop = min(worldtop, worldhigh); popenbottom = max(worldbottom, worldlow); - popentopslope = min(worldtopslope, worldhighslope); popenbottomslope = max(worldbottomslope, worldlowslope); } + // Find the wall's coordinates + fixed_t midtexheight = textureheight[gr_midtexture] * repeats; + if (gr_linedef->flags & ML_EFFECT2) { - if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) + if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) // Peg it to the floor { polybottom = max(front->floorheight, back->floorheight) + gr_sidedef->rowoffset; - polybottomslope = polybottom; polytop = polybottom + midtexheight; - polytopslope = polytop; } - else + else // Peg it to the ceiling { polytop = min(front->ceilingheight, back->ceilingheight) + gr_sidedef->rowoffset; - polytopslope = polytop; polybottom = polytop - midtexheight; - polybottomslope = polybottom; } + + // The right side's coordinates are the the same as the left side + polytopslope = polytop; + polybottomslope = polybottom; } - else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) + else if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) // Skew the texture, but peg it to the floor { polybottom = popenbottom + gr_sidedef->rowoffset; polytop = polybottom + midtexheight; polybottomslope = popenbottomslope + gr_sidedef->rowoffset; polytopslope = polybottomslope + midtexheight; } - else + else // Skew it according to the ceiling's slope { polytop = popentop + gr_sidedef->rowoffset; - polybottom = polytop - textureheight[gr_midtexture]*repeats; polybottom = polytop - midtexheight; polytopslope = popentopslope + gr_sidedef->rowoffset; polybottomslope = polytopslope - midtexheight; @@ -1844,9 +1834,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lS = max(polybottomslope, lowcutslope); // PEGGING - fixed_t texturevpeg, texturevpegslope; - - grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + fixed_t texturevpegslope; if (!!(gr_linedef->flags & ML_DONTPEGBOTTOM) ^ !!(gr_linedef->flags & ML_EFFECT3)) { @@ -1859,11 +1847,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texturevpegslope = polytopslope - hS; } + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + + // Left side wallVerts[3].t = texturevpeg * grTex->scaleY; wallVerts[0].t = (h - l + texturevpeg) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + + // Right side wallVerts[2].t = texturevpegslope * grTex->scaleY; wallVerts[1].t = (hS - lS + texturevpegslope) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; // set top/bottom coords @@ -1958,22 +1951,21 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_DrawSkyWall(wallVerts, &Surf); } - // Single sided lines are simple for skywalls, just need to draw from the top or bottom of the sector if there's - // a sky flat if (!gr_curline->polyseg) { if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector { - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(INT32_MAX); + wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space wallVerts[0].y = FIXED_TO_FLOAT(worldtop); wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); + HWR_DrawSkyWall(wallVerts, &Surf); } if (gr_frontsector->floorpic == skyflatnum) { wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); + wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space HWR_DrawSkyWall(wallVerts, &Surf); } @@ -1981,7 +1973,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } //Hurdler: 3d-floors test - if (!gl_drawing_stencil && gr_frontsector && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors)) + if (!gl_drawing_stencil && gr_backsector && gr_frontsector->tag != gr_backsector->tag && (gr_backsector->ffloors || gr_frontsector->ffloors)) { ffloor_t * rover; fixed_t highcut = 0, lowcut = 0; From ad1c3e63a4eb254cb96b878ccc4549d349de79ef Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 20:37:11 +0200 Subject: [PATCH 08/12] why not reuse those? --- src/hardware/hw_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 63832d7b9..088b34d2c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2105,9 +2105,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); - Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); + Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(lightnum, colormap); + + lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); @@ -2219,9 +2220,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; - lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); - Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(rover->master->frontsector->lightlevel, rover->master->frontsector->extra_colormap); + Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(lightnum, colormap); + + lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gr_curline); if (gr_backsector->numlights) HWR_SplitWall(gr_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, 0); From 5ff0c09868c3c4a62d4396bc013a1fdf12dec5b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Oct 2024 21:28:08 +0200 Subject: [PATCH 09/12] just check for noencore bool in hwr_processseg instead of checked line flags everytime --- src/hardware/hw_main.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 088b34d2c..9acc0342a 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1425,11 +1425,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t h, l; // 3D sides and 2s middle textures fixed_t hS, lS; - boolean noencore = false; - gr_sidedef = gr_curline->sidedef; gr_linedef = gr_curline->linedef; + const boolean noencore = (gr_linedef->flags & ML_TFERLINE); + if (gr_curline->pv1) { vs.x = ((polyvertex_t *)gr_curline->pv1)->x; @@ -1490,9 +1490,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FSurfaceInfo Surf; Surf.PolyColor.s.alpha = 255; - if (gr_linedef->flags & ML_TFERLINE) - noencore = true; - INT32 gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); GLMapTexture_t *grTex = NULL; @@ -1608,7 +1605,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway texturevpeg %= textureheight[gr_toptexture]; - grTex = HWR_GetTexture(gr_toptexture, gr_linedef->flags & ML_TFERLINE); + grTex = HWR_GetTexture(gr_toptexture, noencore); wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_backsector->ceilingheight) * grTex->scaleY; @@ -1645,9 +1642,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); if (!gl_drawing_stencil && gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_toptexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_toptexture, noencore, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -1668,7 +1665,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway texturevpeg %= textureheight[gr_bottomtexture]; - grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); + grTex = HWR_GetTexture(gr_bottomtexture, noencore); wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; @@ -1704,9 +1701,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); if (!gl_drawing_stencil && gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_bottomtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); else if (!gl_drawing_stencil && grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_bottomtexture, noencore, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -1847,7 +1844,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom texturevpegslope = polytopslope - hS; } - grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + grTex = HWR_GetTexture(gr_midtexture, noencore); // Left side wallVerts[3].t = texturevpeg * grTex->scaleY; @@ -1875,9 +1872,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode |= PF_Decal; if (!gl_drawing_stencil && gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, noencore, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, noencore, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap); } @@ -1897,7 +1894,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else texturevpeg = gr_sidedef->rowoffset; // top of texture at top - grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + grTex = HWR_GetTexture(gr_midtexture, noencore); wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; @@ -1930,11 +1927,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); if (gr_frontsector->numlights) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); else // I don't think that solid walls can use translucent linedef types... { if (grTex->mipmap.flags & TF_TRANSPARENT) - HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, noencore, PF_Environment, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } @@ -2130,7 +2127,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { if (blendmode != PF_Masked) - HWR_AddTransparentWall(wallVerts, &Surf, texnum, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); + HWR_AddTransparentWall(wallVerts, &Surf, texnum, noencore, blendmode, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } From 9f79429d033730663763dea81678ac695d5f1455 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Oct 2024 23:03:18 +0200 Subject: [PATCH 10/12] slight cleanup + make static + smol optimize ogl sprite drawers --- src/hardware/hw_main.c | 28 +++++++++++++++------------- src/hardware/hw_main.h | 6 ------ src/r_things.c | 4 ++-- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9acc0342a..eb7053e27 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -4480,9 +4480,10 @@ static void HWR_RenderDrawNodes(void) // -------------------------------------------------------------------------- // Draw all vissprites // -------------------------------------------------------------------------- -void HWR_DrawSprites(void) +static void HWR_DrawSprites(void) { UINT32 i; + for (i = 0; i < gr_visspritecount; i++) { gr_vissprite_t *spr = gr_vsprorder[i]; @@ -4526,7 +4527,7 @@ void HWR_DrawSprites(void) // HWR_AddSprites // During BSP traversal, this adds sprites by sector. // -------------------------------------------------------------------------- -void HWR_AddSprites(sector_t *sec) +static void HWR_AddSprites(sector_t *sec) { mobj_t *thing; fixed_t limit_dist; @@ -4613,7 +4614,7 @@ static void HWR_AddPrecipitationSprites(void) // Generates a vissprite for a thing if it might be visible. // -------------------------------------------------------------------------- // BP why not use xtoviexangle/viewangletox like in bsp ?.... -void HWR_ProjectSprite(mobj_t *thing) +static void HWR_ProjectSprite(mobj_t *thing) { gr_vissprite_t *vis; float tr_x, tr_y; @@ -4650,12 +4651,12 @@ void HWR_ProjectSprite(mobj_t *thing) angle_t sliptiderollangle = 0; #endif - // uncapped/interpolation - interpmobjstate_t interp = {0}; - if (!thing) return; + // uncapped/interpolation + interpmobjstate_t interp = {0}; + vflip = (thing->eflags & MFE_VERTICALFLIP); mirrored = thing->mirrored; hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); @@ -4760,9 +4761,9 @@ void HWR_ProjectSprite(mobj_t *thing) else { // choose a different rotation based on player view - if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right + if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right rot = 6; // F7 slot - else if ((ang >= ANGLE_180) && (sprframe->rotate & SRF_LEFT)) // See from left + else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left rot = 2; // F3 slot else // Normal behaviour rot = (ang+ANGLE_202h)>>29; @@ -4881,13 +4882,12 @@ void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { if (gr_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? - FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : - gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) + FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : + gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) return; - if (gr_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? - gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : - FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) + gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : + FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) return; } @@ -4897,7 +4897,9 @@ void HWR_ProjectSprite(mobj_t *thing) vis->x2 = x2; vis->z1 = z1; vis->z2 = z2; + vis->tz = tz; // Keep tz for the simple sprite sorting that happens + vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST vis->flip = flip; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 5c3877e56..3ef901941 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -131,12 +131,6 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo * pSurf, INT32 t void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf); void HWR_DrawSkyBackground(float fpov); -// hw_main.c: Sprites -void HWR_AddSprites(sector_t *sec); -void HWR_ProjectSprite(mobj_t *thing); -//void HWR_ProjectPrecipitationSprite(precipmobj_t *thing); -void HWR_DrawSprites(void); - // hw_bsp.c void HWR_CreatePlanePolygons(INT32 bspnum); extern boolean gr_maphasportals; diff --git a/src/r_things.c b/src/r_things.c index 7274a9993..17d198801 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1285,9 +1285,9 @@ static void R_ProjectSprite(mobj_t *thing) // choose a different rotation based on player view //ang = R_PointToAngle (interp.x, interp.y) - interpangle; - if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right + if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right rot = 6; // F7 slot - else if ((ang >= ANGLE_180) && (sprframe->rotate & SRF_LEFT)) // See from left + else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left rot = 2; // F3 slot else // Normal behaviour rot = (ang+ANGLE_202h)>>29; From d6602747aee9ef9e53d6e3f4d64c4bd5f24f9705 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Oct 2024 23:05:20 +0200 Subject: [PATCH 11/12] oops forgor lol --- src/hardware/hw_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index eb7053e27..0923151c0 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -295,6 +295,8 @@ ps_metric_t ps_hw_numcolors = {0}; ps_metric_t ps_hw_batchsorttime = {0}; ps_metric_t ps_hw_batchdrawtime = {0}; +static void HWR_AddSprites(sector_t *sec); +static void HWR_ProjectSprite(mobj_t *thing); static void HWR_AddPrecipitationSprites(void); static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing); From b862d835a58fdf5c3d5e48083f7f07ef5d7c6897 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Oct 2024 02:08:17 +0200 Subject: [PATCH 12/12] save one calc lol --- src/p_mobj.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index b79c4e0b2..d738008b8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9987,10 +9987,13 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype if (mobj->floorz != starting_floorz) mobj->precipflags |= PCF_FOF; - else if (GETSECSPECIAL(mobj->subsector->sector->special, 1) == 7 - || GETSECSPECIAL(mobj->subsector->sector->special, 1) == 6 - || mobj->subsector->sector->floorpic == skyflatnum) - mobj->precipflags |= PCF_PIT; + else + { + INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1); + + if (special == 7 || special == 6 || mobj->subsector->sector->floorpic == skyflatnum) + mobj->precipflags |= PCF_PIT; + } R_ResetPrecipitationMobjInterpolationState(mobj);