smoller opitmizations
This commit is contained in:
1 parent
4e995436c5
commit
e81cde8753
2 files changed
+61
-57
No files matched your search
+42
-39
@@ -2108,20 +2108,20 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
INT32 texnum;
|
||||
line_t * newline = NULL; // Multi-Property FOF
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope
|
||||
/// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C
|
||||
highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight;
|
||||
lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
lowcut = max(worldbottom, worldlow);
|
||||
highcut = min(worldtop, worldhigh);
|
||||
lowcutslope = max(worldbottomslope, worldlowslope);
|
||||
highcutslope = min(worldtopslope, worldhighslope);
|
||||
}
|
||||
else
|
||||
{
|
||||
///TODO add slope support (fixing cutoffs, proper wall clipping) - maybe just disable highcut/lowcut if either sector or FOF has a slope
|
||||
/// to allow fun plane intersecting in OGL? But then people would abuse that and make software look bad. :C
|
||||
highcut = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight;
|
||||
lowcut = gr_frontsector->floorheight > gr_backsector->floorheight ? gr_frontsector->floorheight : gr_backsector->floorheight;
|
||||
}
|
||||
|
||||
if (gr_backsector->ffloors)
|
||||
{
|
||||
@@ -2130,12 +2130,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || (rover->flags & FF_INVERTSIDES))
|
||||
continue;
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight)
|
||||
SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight)
|
||||
@@ -2143,6 +2138,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
|
||||
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
|
||||
|
||||
@@ -2158,14 +2158,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
l = P_GetFFloorBottomZAt(rover, v1x, v1y);
|
||||
lS = P_GetFFloorBottomZAt(rover, v2x, v2y);
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
// Adjust the heights so the FOF does not overlap with top and bottom textures.
|
||||
if (h >= highcut && hS >= highcutslope)
|
||||
@@ -2179,6 +2172,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
lS = lowcutslope;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
|
||||
//Hurdler: HW code starts here
|
||||
//FIXME: check if peging is correct
|
||||
@@ -2259,7 +2259,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
}
|
||||
@@ -2301,12 +2303,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_ALLSIDES))
|
||||
continue;
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight)
|
||||
SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight)
|
||||
@@ -2314,7 +2311,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (*rover->topheight < lowcut || *rover->bottomheight > highcut)
|
||||
continue;
|
||||
}
|
||||
|
||||
texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture);
|
||||
|
||||
@@ -2330,14 +2331,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
l = P_GetFFloorBottomZAt(rover, v1x, v1y);
|
||||
lS = P_GetFFloorBottomZAt(rover, v2x, v2y);
|
||||
|
||||
if (!cv_grfofcut.value)
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
else
|
||||
if (cv_grfofcut.value)
|
||||
{
|
||||
// Adjust the heights so the FOF does not overlap with top and bottom textures.
|
||||
if (h >= highcut && hS >= highcutslope)
|
||||
@@ -2351,6 +2345,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
lS = lowcutslope;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(*rover->t_slope) && !gr_frontsector->c_slope && !gr_backsector->c_slope && h > highcut)
|
||||
h = hS = highcut;
|
||||
if (!(*rover->b_slope) && !gr_frontsector->f_slope && !gr_backsector->f_slope && l < lowcut)
|
||||
l = lS = lowcut;
|
||||
}
|
||||
|
||||
//Hurdler: HW code starts here
|
||||
//FIXME: check if peging is correct
|
||||
@@ -2398,7 +2399,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
lightnum = rover->master->frontsector->lightlevel;
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
lightnum = colormap ? lightnum : HWR_CalcWallLight(lightnum, vs.x, vs.y, ve.x, ve.y);
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y);
|
||||
colormap = rover->master->frontsector->extra_colormap;
|
||||
}
|
||||
|
||||
+19
-18
@@ -652,7 +652,7 @@ void R_DrawMaskedColumn(column_t *column)
|
||||
if (dc_yh >= vid.height)
|
||||
dc_yh = vid.height - 1;
|
||||
|
||||
if (dc_yl <= dc_yh && dc_yl < vid.height && dc_yh > 0)
|
||||
if (dc_yl <= dc_yh && dc_yh > 0)
|
||||
{
|
||||
dc_source = (UINT8 *)column + 3;
|
||||
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
|
||||
@@ -664,7 +664,9 @@ void R_DrawMaskedColumn(column_t *column)
|
||||
dc_texturemid = basetexturemid;
|
||||
}
|
||||
|
||||
static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height
|
||||
|
||||
static void R_DrawFlippedMaskedColumn(column_t *column)
|
||||
{
|
||||
INT32 topscreen;
|
||||
INT32 bottomscreen;
|
||||
@@ -680,11 +682,10 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
topdelta = texheight-column->length-topdelta;
|
||||
topdelta = lengthcol-column->length-topdelta;
|
||||
topscreen = sprtopscreen + spryscale*topdelta;
|
||||
bottomscreen = sprbotscreen == INT32_MAX ? topscreen + spryscale*column->length
|
||||
: sprbotscreen + spryscale*column->length;
|
||||
|
||||
dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS;
|
||||
dc_yh = (bottomscreen-1)>>FRACBITS;
|
||||
|
||||
@@ -705,7 +706,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
if (dc_yh >= vid.height)
|
||||
dc_yh = vid.height - 1;
|
||||
|
||||
if (dc_yl <= dc_yh && dc_yl < vid.height && dc_yh > 0)
|
||||
if (dc_yl <= dc_yh && dc_yh > 0)
|
||||
{
|
||||
dc_source = ZZ_Alloc(column->length);
|
||||
for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s)
|
||||
@@ -727,7 +728,9 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight)
|
||||
static void R_DrawVisSprite(vissprite_t *vis)
|
||||
{
|
||||
column_t *column;
|
||||
void (*localcolfunc)(column_t *);
|
||||
INT32 texturecolumn;
|
||||
INT32 pwidth;
|
||||
fixed_t frac;
|
||||
patch_t *patch = vis->patch;
|
||||
fixed_t this_scale = vis->thingscale;
|
||||
@@ -871,11 +874,15 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
vis->x2 -= temp;
|
||||
}
|
||||
|
||||
localcolfunc = (vis->vflip) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn;
|
||||
lengthcol = patch->height;
|
||||
|
||||
// Split drawing loops for paper and non-paper to reduce conditional checks per sprite
|
||||
if (vis->scalestep)
|
||||
{
|
||||
fixed_t horzscale = FixedMul(vis->spritexscale, this_scale);
|
||||
fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale);
|
||||
pwidth = SHORT(patch->width);
|
||||
|
||||
// Papersprite drawing loop
|
||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep)
|
||||
@@ -883,37 +890,31 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF;
|
||||
texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
|
||||
|
||||
if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
|
||||
if (texturecolumn < 0 || texturecolumn >= pwidth)
|
||||
continue;
|
||||
|
||||
if (vis->xiscale < 0) // Flipped sprite
|
||||
texturecolumn = SHORT(patch->width) - 1 - texturecolumn;
|
||||
texturecolumn = pwidth - 1 - texturecolumn;
|
||||
|
||||
sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale));
|
||||
dc_iscale = (0xffffffffu / (unsigned)spryscale);
|
||||
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
|
||||
|
||||
if (vis->vflip)
|
||||
R_DrawFlippedMaskedColumn(column, patch->height);
|
||||
else
|
||||
R_DrawMaskedColumn(column);
|
||||
localcolfunc (column);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pwidth = SHORT(patch->width);
|
||||
|
||||
// Non-paper drawing loop
|
||||
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale)
|
||||
{
|
||||
#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x)))
|
||||
texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1);
|
||||
#undef CLAMP
|
||||
texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1);
|
||||
column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn]));
|
||||
|
||||
if (vis->vflip)
|
||||
R_DrawFlippedMaskedColumn(column, patch->height);
|
||||
else
|
||||
R_DrawMaskedColumn(column);
|
||||
localcolfunc (column);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user