diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 76231750c..9357d9f42 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -161,7 +161,7 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) return false; #else #define DIVLINE_VERTEX_DIFF 0.45f - float ep = DIVLINE_VERTEX_DIFF; + static const float ep = DIVLINE_VERTEX_DIFF; if (fabsf( p2->x - p1->x ) > ep ) return false; if (fabsf( p2->y - p1->y ) > ep ) @@ -283,6 +283,7 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line *backpoly = NULL; return; } + if (pe <= ps) I_Error("SplitPoly: invalid splitting line (%d %d)", ps, pe); @@ -368,7 +369,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) for (; count--; lseg++) { //x,y,dx,dy (like a divline) - line_t *line = lseg->linedef; + const line_t *line = lseg->linedef; // portal check if (!gl_maphasportals && line->special == PORTALSPECIAL && lseg->side == 0) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 0329ebc0e..346ed1d7c 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -121,7 +121,7 @@ static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end) boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) { - if(startAngle > endAngle) + if (startAngle > endAngle) { return (gld_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || gld_clipper_IsRangeVisible(0, endAngle)); } diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 9668b9223..fe9a5c241 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1093,7 +1093,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if ((endtop < endrealbot) && (top < realbot)) return; - lightlist_t *list = sector->lightlist; + const lightlist_t *list = sector->lightlist; if (!(list[i].flags & FF_NOSHADE)) { @@ -1431,9 +1431,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].z = wallVerts[1].z = ve.y; // x offset the texture - fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset; - float cliplow = (float)texturehpeg; - float cliphigh = (float)(texturehpeg + (gl_curline->flength*FRACUNIT)); + const fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset; + const float cliplow = (float)texturehpeg; + const float cliphigh = (float)(texturehpeg + (gl_curline->flength*FRACUNIT)); FUINT lightnum = gl_frontsector->lightlevel; extracolormap_t *colormap = gl_frontsector->extra_colormap; @@ -1444,7 +1444,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gl_frontsector) Surf.PolyColor.s.alpha = 255; - INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); + const INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); GLMapTexture_t *glTex = NULL; // two sided line @@ -1722,7 +1722,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // Find the wall's coordinates - fixed_t midtexheight = textureheight[gl_midtexture] * repeats; + const fixed_t midtexheight = textureheight[gl_midtexture] * repeats; if (gl_linedef->flags & ML_EFFECT2) { @@ -2048,6 +2048,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; } + FBITFIELD blendmode; if (roverflags & FF_FOG) @@ -3343,7 +3344,7 @@ static gl_vissprite_t gl_overflowsprite; static gl_vissprite_t *HWR_GetVisSprite(UINT32 num) { - UINT32 chunk = num >> VISSPRITECHUNKBITS; + const UINT32 chunk = num >> VISSPRITECHUNKBITS; // Allocate chunk if necessary if (!gl_visspritechunks[chunk]) @@ -3405,13 +3406,6 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t fixed_t slopez; float offset = 0; - // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again - const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); - if (spr->mobj) - this_scale = FixedToFloat(spr->mobj->scale); - if (hires) - this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale); - R_GetShadowZ(spr->mobj, &floorslope); mobjfloor = HWR_OpaqueFloorAtPos( @@ -3462,6 +3456,14 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t else floorheight = FixedInt(spr->mobj->z - mobjfloor); + // technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again + const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); + + if (spr->mobj) + this_scale = FixedToFloat(spr->mobj->scale); + if (hires) + this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale); + // create the sprite billboard // // 3--2 @@ -4194,8 +4196,8 @@ gl_vissprite_t* gl_vsprorder[MAXVISSPRITES]; // sorted and drawn together with transparent surfaces. static int CompareVisSprites(const void *p1, const void *p2) { - gl_vissprite_t* spr1 = *(gl_vissprite_t*const*)p1; - gl_vissprite_t* spr2 = *(gl_vissprite_t*const*)p2; + const gl_vissprite_t* spr1 = *(gl_vissprite_t*const*)p1; + const gl_vissprite_t* spr2 = *(gl_vissprite_t*const*)p2; int idiff; float fdiff; @@ -4373,8 +4375,8 @@ static void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *poly static int CompareDrawNodePlanes(const void *p1, const void *p2) { - INT32 n1 = *(const INT32*)p1; - INT32 n2 = *(const INT32*)p2; + const INT32 n1 = *(const INT32*)p1; + const INT32 n2 = *(const INT32*)p2; return ABS(drawnodes[n2].u.plane.fixedheight - viewz) - ABS(drawnodes[n1].u.plane.fixedheight - viewz); } @@ -4732,8 +4734,6 @@ static void HWR_ProjectSprite(mobj_t *thing) if (interp.spritexscale < 1 || interp.spriteyscale < 1) return; - const boolean papersprite = (thing->frame & FF_PAPERSPRITE); - INT32 blendmode; if (thing->frame & FF_BLENDMASK) blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; @@ -4747,6 +4747,8 @@ static void HWR_ProjectSprite(mobj_t *thing) return; } + const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + // transform the origin point tr_x = FixedToFloat(interp.x); tr_y = FixedToFloat(interp.y); @@ -4774,12 +4776,6 @@ static void HWR_ProjectSprite(mobj_t *thing) rot = (thing->frame & FF_FRAMEMASK); -#ifdef ROTSPRITE - // determine here if sprite should rotate for optimization - const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); -#endif - //Fab : 02-08-98: 'skin' override spritedef currently used for skin if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY) { @@ -4818,6 +4814,12 @@ static void HWR_ProjectSprite(mobj_t *thing) I_Error("sprframes NULL for sprite %d\n", thing->sprite); #endif +#ifdef ROTSPRITE + // determine here if sprite should rotate for optimization + const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); +#endif + if (sprframe->rotate != SRF_SINGLE || papersprite #ifdef ROTSPRITE || (shouldrotate) @@ -5269,13 +5271,13 @@ void HWR_BuildSkyDome(void) { int c, r; signed char yflip; - int row_count = 4; + static constexpr int row_count = 4; int col_count = 4; float delta; gl_sky_t *sky = &gl_sky; gl_skyvertex_t *vertex_p; - texture_t *texture = textures[texturetranslation[skytexture]]; + const texture_t *texture = textures[texturetranslation[skytexture]]; sky->detail = 16; col_count *= sky->detail; @@ -5484,7 +5486,7 @@ void HWR_SetTransform(float fpov) void HWR_ClearClipper(void) { - angle_t a1 = gld_FrustumAngle(gl_aimingangle); + const angle_t a1 = gld_FrustumAngle(gl_aimingangle); gld_clipper_Clear(); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); #ifdef HAVE_SPHEREFRUSTRUM @@ -5790,6 +5792,8 @@ 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; @@ -6043,7 +6047,7 @@ void HWR_Shutdown(void) static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) { FBITFIELD blendmode = blend; - UINT8 alpha = pSurf->PolyColor.s.alpha; // retain the alpha + const UINT8 alpha = pSurf->PolyColor.s.alpha; // retain the alpha INT32 shader = SHADER_NONE;