From 5ff2b525220f167a75b209d524c2700a8b45314f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 6 Apr 2025 09:36:48 +0200 Subject: [PATCH] more smoller optimizations save some unneeded floattofixed calls and move the linedef check earlier --- src/hardware/hw_cache.c | 2 +- src/hardware/hw_main.c | 20 ++++++++++++++------ src/r_things.c | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 824fd08e7..e67428920 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -994,7 +994,7 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) // search for the mipmap // skip the first (no colormap translated) - for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap; ) + for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap;) { glMipmap = glMipmap->nextcolormap; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 53b61778d..4bc74eca5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1330,28 +1330,32 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { vs.x = ((polyvertex_t *)gl_curline->pv1)->x; vs.y = ((polyvertex_t *)gl_curline->pv1)->y; + v1x = FLOAT_TO_FIXED(vs.x); + v1y = FLOAT_TO_FIXED(vs.y); } else { vs.x = FIXED_TO_FLOAT(gl_curline->v1->x); vs.y = FIXED_TO_FLOAT(gl_curline->v1->y); + v1x = gl_curline->v1->x; + v1y = gl_curline->v1->y; } + if (gl_curline->pv2) { ve.x = ((polyvertex_t *)gl_curline->pv2)->x; ve.y = ((polyvertex_t *)gl_curline->pv2)->y; + v2x = FLOAT_TO_FIXED(ve.x); + v2y = FLOAT_TO_FIXED(ve.y); } else { ve.x = FIXED_TO_FLOAT(gl_curline->v2->x); ve.y = FIXED_TO_FLOAT(gl_curline->v2->y); + v2x = gl_curline->v2->x; + v2y = gl_curline->v2->y; } - v1x = FLOAT_TO_FIXED(vs.x); - v1y = FLOAT_TO_FIXED(vs.y); - v2x = FLOAT_TO_FIXED(ve.x); - v2y = FLOAT_TO_FIXED(ve.y); - #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ end1 = P_GetZAt(slope, v1x, v1y); \ @@ -2315,6 +2319,9 @@ static void HWR_AddLine(seg_t *line) gl_curline = line; + if (!gl_curline->linedef) + return; + if (gl_curline->pv1) { v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); @@ -2325,6 +2332,7 @@ static void HWR_AddLine(seg_t *line) v1x = gl_curline->v1->x; v1y = gl_curline->v1->y; } + if (gl_curline->pv2) { v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); @@ -2341,7 +2349,7 @@ static void HWR_AddLine(seg_t *line) angle2 = R_PointToAngle64(v2x, v2y); // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! - if (angle2 - angle1 < ANGLE_180 || !gl_curline->linedef) + if (angle2 - angle1 < ANGLE_180) return; // PrBoom: use REAL clipping math YAYYYYYYY!!! diff --git a/src/r_things.c b/src/r_things.c index 881f5c2ed..23bd7d21a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2889,7 +2889,7 @@ void R_ClipSprites(void) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) + if (thing->sprite == SPR_NULL || (thing->flags2 & MF2_DONTDRAW)) return false; if (splitscreen)