super smol optimizations

This commit is contained in:
Alug committed 2024-12-26 00:56:50 +01:00
1 parent 9bde946c55
commit 8776b36bb0
1 file changed
+34 -23
+34 -23
View File
@@ -2509,16 +2509,16 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{
float height; //constant y for all points on the convex flat polygon
FOutVector *v3d;
INT32 i;
INT32 i;
float flatxref,flatyref;
float fflatsize;
INT32 flatflag;
size_t len;
float scrollx = 0.0f, scrolly = 0.0f;
angle_t angle = 0;
float fflatsize;
INT32 flatflag;
size_t len;
float scrollx = 0.0f, scrolly = 0.0f;
angle_t angle = 0;
FSurfaceInfo Surf;
fixed_t tempxsow, tempytow;
size_t nrPlaneVerts;
fixed_t tempxsow, tempytow;
size_t nrPlaneVerts;
static FOutVector *planeVerts = NULL;
static UINT16 numAllocedPlaneVerts = 0;
@@ -2527,8 +2527,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
nrPlaneVerts = polysector->numVertices;
height = FIXED_TO_FLOAT(fixedheight);
if (nrPlaneVerts < 3) //not even a triangle ?
return;
@@ -2546,6 +2544,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts);
}
height = FIXED_TO_FLOAT(fixedheight);
len = W_LumpLength(lumpnum);
switch (len)
@@ -2743,7 +2743,6 @@ static void HWR_AddPolyObjectPlanes(void)
}
}
//
// HWR_DoCulling
// Hardware version of R_DoCulling
@@ -2756,6 +2755,7 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v
return false;
cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight);
if (cullheight->flags & ML_NOCLIMB) // Group culling
{
if (!viewcullheight)
@@ -3467,6 +3467,7 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts
// be mobj->z or mobj->z + mobj->height
wallVerts[2].y = wallVerts[3].y = (spr->gzt - basey) * gl_viewludsin + basey;
wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gl_viewludsin + basey;
// translate back to be around 0 before translating back
wallVerts[3].x += ((spr->gzt - basey) * gl_viewludcos) * gl_viewcos;
wallVerts[2].x += ((spr->gzt - basey) * gl_viewludcos) * gl_viewcos;
@@ -3853,13 +3854,14 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
sector_t *sector = spr->mobj->subsector->sector;
INT32 lightlevel = 255;
extracolormap_t *colormap = sector->extra_colormap;
const boolean fullbright = (spr->mobj->frame & FF_FULLBRIGHT);
if (!(spr->mobj->frame & FF_FULLBRIGHT))
if (!fullbright)
lightlevel = min(sector->lightlevel, 255);
HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite);
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT));
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !fullbright);
if (!cv_translucency.value) // translucency disabled
{
@@ -4317,6 +4319,7 @@ static void HWR_DrawSprites(void)
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
md2_t *md2;
if (spr->mobj->localskin)
{
if (spr->mobj->skinlocal)
@@ -4394,20 +4397,27 @@ static void HWR_AddSprites(sector_t *sec)
// --------------------------------------------------------------------------
static void HWR_AddPrecipitationSprites(void)
{
fixed_t drawdist;
fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT);
//const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale;
INT32 xl, xh, yl, yh, bx, by;
precipmobj_t *th;
fixed_t drawdist;
// save a little time on invisible weather
if (curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN)
{
return;
}
const fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT);
//const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale;
if (current_bsp_culling_distance)
drawdist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * precipscale);
else
drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale);
// No to infinite precipitation draw distance.
if (drawdist == 0 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN)
if (drawdist == 0)
{
return;
}
@@ -4476,11 +4486,6 @@ static void HWR_ProjectSprite(mobj_t *thing)
// uncapped/interpolation
interpmobjstate_t interp = {0};
const boolean mirrored = thing->mirrored;
const boolean vflip = (thing->eflags & MFE_VERTICALFLIP);
const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
if (cv_maxinterpdist.value)
dist = R_QuickCamDist(thing->x, thing->y);
@@ -4496,6 +4501,11 @@ static void HWR_ProjectSprite(mobj_t *thing)
if (interp.spritexscale < 1 || interp.spriteyscale < 1)
return;
const boolean mirrored = thing->mirrored;
const boolean vflip = (thing->eflags & MFE_VERTICALFLIP);
const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored);
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
this_scale = FIXED_TO_FLOAT(interp.scale);
spritexscale = FIXED_TO_FLOAT(interp.spritexscale);
spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale);
@@ -5263,6 +5273,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl
{
HWR_RenderPortal(portal, rootportal, fpov, player, stencil_level);
}
HWR_SetPortalState(GLPORTAL_INSIDE); // when portal walls are encountered in following bsp traversal, nothing should be drawn
}
else