Merge branch 'texture-scaling-fixes' into 'next'

Fix various issues related to texture scaling

See merge request STJr/SRB2!2329
This commit is contained in:
Logan Aerl Arias 2024-03-04 13:30:11 +00:00
commit f4b862068c
16 changed files with 653 additions and 506 deletions

View file

@ -476,6 +476,18 @@ static void D_Display(void)
if (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction && curbghide && (!hidetitlemap)))
{
// draw the view directly
if (cv_debug)
{
r_renderwalls = cv_renderwalls.value;
r_renderfloors = cv_renderfloors.value;
r_renderthings = cv_renderthings.value;
}
else
{
r_renderwalls = true;
r_renderfloors = true;
r_renderthings = true;
}
if (!automapactive && !dedicated && cv_renderview.value)
{

View file

@ -339,6 +339,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
static FOutVector *planeVerts = NULL;
static UINT16 numAllocedPlaneVerts = 0;
if (!r_renderfloors)
return;
// no convex poly were generated for this subsector
if (!xsub->planepoly)
return;
@ -483,9 +486,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
PolyFlags |= PF_ColorMapped;
}
if (!cv_renderfloors.value)
return;
HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false);
if (subsector)
@ -668,7 +668,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL
{
INT32 shader = SHADER_NONE;
if (!cv_renderwalls.value)
if (!r_renderwalls)
return;
HWR_Lighting(pSurf, lightlevel, wallcolormap);
@ -709,7 +709,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y);
extracolormap_t *colormap = NULL;
if (!cv_renderwalls.value)
if (!r_renderwalls)
return;
realtop = top = wallVerts[3].y;
@ -914,6 +914,191 @@ static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
return true;
}
static void HWR_RenderMidtexture(INT32 gl_midtexture, float cliplow, float cliphigh, fixed_t worldtop, fixed_t worldbottom, fixed_t worldhigh, fixed_t worldlow, fixed_t worldtopslope, fixed_t worldbottomslope, fixed_t worldhighslope, fixed_t worldlowslope, UINT32 lightnum, FOutVector *inWallVerts)
{
FOutVector wallVerts[4];
FSurfaceInfo Surf;
Surf.PolyColor.s.alpha = 255;
// Determine if it's visible
if (!HWR_BlendMidtextureSurface(&Surf))
return;
fixed_t texheight = FixedDiv(textureheight[gl_midtexture], abs(gl_sidedef->scaley_mid));
INT32 repeats;
if (gl_sidedef->repeatcnt)
repeats = 1 + gl_sidedef->repeatcnt;
else if (gl_linedef->flags & ML_WRAPMIDTEX)
{
fixed_t high, low;
if (gl_frontsector->ceilingheight > gl_backsector->ceilingheight)
high = gl_backsector->ceilingheight;
else
high = gl_frontsector->ceilingheight;
if (gl_frontsector->floorheight > gl_backsector->floorheight)
low = gl_frontsector->floorheight;
else
low = gl_backsector->floorheight;
repeats = (high - low) / texheight;
if ((high - low) % texheight)
repeats++; // tile an extra time to fill the gap -- Monster Iestyn
}
else
repeats = 1;
GLMapTexture_t *grTex = HWR_GetTexture(gl_midtexture);
float xscale = FixedToFloat(gl_sidedef->scalex_mid);
float yscale = FixedToFloat(gl_sidedef->scaley_mid);
// SoM: a little note: 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
// From CB
if (gl_curline->polyseg)
{
// Change this when polyobjects support slopes
popentop = popentopslope = gl_curline->backsector->ceilingheight;
popenbottom = popenbottomslope = gl_curline->backsector->floorheight;
}
else
{
popentop = min(worldtop, worldhigh);
popenbottom = max(worldbottom, worldlow);
popentopslope = min(worldtopslope, worldhighslope);
popenbottomslope = max(worldbottomslope, worldlowslope);
}
// Find the wall's coordinates
fixed_t midtexheight = texheight * repeats;
fixed_t rowoffset = FixedDiv(gl_sidedef->rowoffset + gl_sidedef->offsety_mid, abs(gl_sidedef->scaley_mid));
// Texture is not skewed
if (gl_linedef->flags & ML_NOSKEW)
{
// Peg it to the floor
if (gl_linedef->flags & ML_MIDPEG)
{
polybottom = max(gl_frontsector->floorheight, gl_backsector->floorheight) + rowoffset;
polytop = polybottom + midtexheight;
}
// Peg it to the ceiling
else
{
polytop = min(gl_frontsector->ceilingheight, gl_backsector->ceilingheight) + rowoffset;
polybottom = polytop - midtexheight;
}
// The right side's coordinates are the the same as the left side
polytopslope = polytop;
polybottomslope = polybottom;
}
// Skew the texture, but peg it to the floor
else if (gl_linedef->flags & ML_MIDPEG)
{
polybottom = popenbottom + rowoffset;
polytop = polybottom + midtexheight;
polybottomslope = popenbottomslope + rowoffset;
polytopslope = polybottomslope + midtexheight;
}
// Skew it according to the ceiling's slope
else
{
polytop = popentop + rowoffset;
polybottom = polytop - midtexheight;
polytopslope = popentopslope + rowoffset;
polybottomslope = polytopslope - midtexheight;
}
// The cut-off values of a linedef can always be constant, since every line has an absoulute front and or back sector
if (gl_curline->polyseg)
{
lowcut = polybottom;
highcut = polytop;
lowcutslope = polybottomslope;
highcutslope = polytopslope;
}
else
{
lowcut = popenbottom;
highcut = popentop;
lowcutslope = popenbottomslope;
highcutslope = popentopslope;
}
fixed_t h = min(highcut, polytop);
fixed_t l = max(polybottom, lowcut);
fixed_t hS = min(highcutslope, polytopslope);
fixed_t lS = max(polybottomslope, lowcutslope);
// PEGGING
fixed_t texturevpeg, texturevpegslope;
if (gl_linedef->flags & ML_MIDPEG)
{
texturevpeg = midtexheight - h + polybottom;
texturevpegslope = midtexheight - hS + polybottomslope;
}
else
{
texturevpeg = polytop - h;
texturevpegslope = polytopslope - hS;
}
memcpy(wallVerts, inWallVerts, sizeof(wallVerts));
// Left side
wallVerts[3].t = texturevpeg * yscale * grTex->scaleY;
wallVerts[0].t = (h - l + texturevpeg) * yscale * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->textureoffset + gl_sidedef->offsetx_mid) * grTex->scaleX;
// Right side
wallVerts[2].t = texturevpegslope * yscale * grTex->scaleY;
wallVerts[1].t = (hS - lS + texturevpegslope) * yscale * grTex->scaleY;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->textureoffset + gl_sidedef->offsetx_mid) * grTex->scaleX;
// set top/bottom coords
// Take the texture peg into account, rather than changing the offsets past
// where the polygon might not be.
wallVerts[3].y = FIXED_TO_FLOAT(h);
wallVerts[0].y = FIXED_TO_FLOAT(l);
wallVerts[2].y = FIXED_TO_FLOAT(hS);
wallVerts[1].y = FIXED_TO_FLOAT(lS);
// TODO: Actually use the surface's flags so that I don't have to do this
FUINT blendmode = Surf.PolyFlags;
// Render midtextures on two-sided lines with a z-buffer offset.
// This will cause the midtexture appear on top, if a FOF overlaps with it.
blendmode |= PF_Decal;
extracolormap_t *colormap = gl_frontsector->extra_colormap;
if (gl_frontsector->numlights)
{
if (!(blendmode & PF_Masked))
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_TRANSLUCENT, NULL, blendmode);
else
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_CUTLEVEL, NULL, blendmode);
}
else if (!(blendmode & PF_Masked))
HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap);
}
// Sort of like GLWall::Process in GZDoom
static void HWR_ProcessSeg(void)
{
@ -979,9 +1164,8 @@ static void HWR_ProcessSeg(void)
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));
float cliplow = (float)gl_curline->offset;
float cliphigh = cliplow + (gl_curline->flength * FRACUNIT);
FUINT lightnum = gl_frontsector->lightlevel;
extracolormap_t *colormap = gl_frontsector->extra_colormap;
@ -997,6 +1181,7 @@ static void HWR_ProcessSeg(void)
if (gl_backsector)
{
INT32 gl_toptexture = 0, gl_bottomtexture = 0;
fixed_t texturevpeg;
SLOPEPARAMS(gl_backsector->c_slope, worldhigh, worldhighslope, gl_backsector->ceilingheight)
@ -1026,30 +1211,46 @@ static void HWR_ProcessSeg(void)
if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture)
{
grTex = HWR_GetTexture(gl_toptexture);
xscale = FixedToFloat(gl_sidedef->scalex_top);
yscale = FixedToFloat(gl_sidedef->scaley_top);
xscale = FixedToFloat(abs(gl_sidedef->scalex_top));
yscale = FixedToFloat(abs(gl_sidedef->scaley_top));
fixed_t texheight = FixedDiv(textureheight[gl_toptexture], gl_sidedef->scaley_top);
fixed_t offsetx_top = gl_sidedef->textureoffset + gl_sidedef->offsetx_top;
float left = cliplow * xscale;
float right = cliphigh * xscale;
if (gl_sidedef->scalex_top < 0)
{
left = -left;
right = -right;
offsetx_top = -offsetx_top;
}
fixed_t texheight = textureheight[gl_toptexture];
fixed_t texheightscaled = FixedDiv(texheight, abs(gl_sidedef->scaley_top));
// PEGGING
// FIXME: This is probably not correct?
if (gl_linedef->flags & ML_DONTPEGTOP)
texturevpeg = 0;
else if (gl_linedef->flags & ML_SKEWTD)
texturevpeg = worldhigh + texheight - worldtop;
else
texturevpeg = gl_backsector->ceilingheight + texheight - gl_frontsector->ceilingheight;
texturevpeg = gl_backsector->ceilingheight + texheightscaled - gl_frontsector->ceilingheight;
texturevpeg *= yscale;
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_top;
if (gl_sidedef->scaley_top < 0)
texturevpeg -= gl_sidedef->rowoffset + gl_sidedef->offsety_top;
else
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_top;
// 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 %= texheight;
texturevpeg %= texheightscaled;
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + (gl_frontsector->ceilingheight - gl_backsector->ceilingheight) * yscale) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_top) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_top) * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (left + offsetx_top) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (right + offsetx_top) * grTex->scaleX;
// Adjust t value for sloped walls
if (!(gl_linedef->flags & ML_SKEWTD))
@ -1074,6 +1275,14 @@ static void HWR_ProcessSeg(void)
wallVerts[2].t = wallVerts[1].t - (worldtopslope - worldhighslope) * yscale * grTex->scaleY;
}
if (gl_sidedef->scaley_top < 0)
{
wallVerts[0].t = -wallVerts[0].t;
wallVerts[1].t = -wallVerts[1].t;
wallVerts[2].t = -wallVerts[2].t;
wallVerts[3].t = -wallVerts[3].t;
}
// set top/bottom coords
wallVerts[3].y = FIXED_TO_FLOAT(worldtop);
wallVerts[0].y = FIXED_TO_FLOAT(worldhigh);
@ -1092,8 +1301,19 @@ static void HWR_ProcessSeg(void)
if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gl_bottomtexture)
{
grTex = HWR_GetTexture(gl_bottomtexture);
xscale = FixedToFloat(gl_sidedef->scalex_bottom);
yscale = FixedToFloat(gl_sidedef->scaley_bottom);
xscale = FixedToFloat(abs(gl_sidedef->scalex_bottom));
yscale = FixedToFloat(abs(gl_sidedef->scaley_bottom));
fixed_t offsetx_bottom = gl_sidedef->textureoffset + gl_sidedef->offsetx_bottom;
float left = cliplow * xscale;
float right = cliphigh * xscale;
if (gl_sidedef->scalex_bottom < 0)
{
left = -left;
right = -right;
offsetx_bottom = -offsetx_bottom;
}
// PEGGING
if (!(gl_linedef->flags & ML_DONTPEGBOTTOM))
@ -1105,15 +1325,18 @@ static void HWR_ProcessSeg(void)
texturevpeg *= yscale;
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_bottom;
if (gl_sidedef->scaley_bottom < 0)
texturevpeg -= gl_sidedef->rowoffset + gl_sidedef->offsety_bottom;
else
texturevpeg += gl_sidedef->rowoffset + gl_sidedef->offsety_bottom;
// 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 %= FixedDiv(textureheight[gl_bottomtexture], gl_sidedef->scaley_bottom);
texturevpeg %= FixedDiv(textureheight[gl_bottomtexture], abs(gl_sidedef->scaley_bottom));
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + (gl_backsector->floorheight - gl_frontsector->floorheight) * yscale) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_bottom) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_bottom) * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = (left + offsetx_bottom) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = (right + offsetx_bottom) * grTex->scaleX;
// Adjust t value for sloped walls
if (!(gl_linedef->flags & ML_SKEWTD))
@ -1137,6 +1360,14 @@ static void HWR_ProcessSeg(void)
wallVerts[1].t = (texturevpeg + (worldlowslope - worldbottomslope) * yscale) * grTex->scaleY;
}
if (gl_sidedef->scaley_bottom < 0)
{
wallVerts[0].t = -wallVerts[0].t;
wallVerts[1].t = -wallVerts[1].t;
wallVerts[2].t = -wallVerts[2].t;
wallVerts[3].t = -wallVerts[3].t;
}
// set top/bottom coords
wallVerts[3].y = FIXED_TO_FLOAT(worldlow);
wallVerts[0].y = FIXED_TO_FLOAT(worldbottom);
@ -1151,196 +1382,14 @@ static void HWR_ProcessSeg(void)
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
}
// Render midtexture if there's one. Determine if it's visible first, though
if (gl_midtexture && HWR_BlendMidtextureSurface(&Surf))
{
sector_t *front, *back;
fixed_t texheight = FixedDiv(textureheight[gl_midtexture], gl_sidedef->scaley_mid);
INT32 repeats;
// Render midtexture if there's one
if (gl_midtexture)
HWR_RenderMidtexture(gl_midtexture, cliplow, cliphigh, worldtop, worldbottom, worldhigh, worldlow, worldtopslope, worldbottomslope, worldhighslope, worldlowslope, lightnum, wallVerts);
if (gl_linedef->frontsector->heightsec != -1)
front = &sectors[gl_linedef->frontsector->heightsec];
else
front = gl_linedef->frontsector;
if (gl_linedef->backsector->heightsec != -1)
back = &sectors[gl_linedef->backsector->heightsec];
else
back = gl_linedef->backsector;
if (gl_sidedef->repeatcnt)
repeats = 1 + gl_sidedef->repeatcnt;
else if (gl_linedef->flags & ML_WRAPMIDTEX)
{
fixed_t high, low;
if (front->ceilingheight > back->ceilingheight)
high = back->ceilingheight;
else
high = front->ceilingheight;
if (front->floorheight > back->floorheight)
low = front->floorheight;
else
low = back->floorheight;
repeats = (high - low) / texheight;
if ((high - low) % texheight)
repeats++; // tile an extra time to fill the gap -- Monster Iestyn
}
else
repeats = 1;
grTex = HWR_GetTexture(gl_midtexture);
xscale = FixedToFloat(gl_sidedef->scalex_mid);
yscale = FixedToFloat(gl_sidedef->scaley_mid);
// SoM: a little note: 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
// From CB
if (gl_curline->polyseg)
{
popentop = popentopslope = back->ceilingheight;
popenbottom = popenbottomslope = back->floorheight;
}
else
{
popentop = min(worldtop, worldhigh);
popenbottom = max(worldbottom, worldlow);
popentopslope = min(worldtopslope, worldhighslope);
popenbottomslope = max(worldbottomslope, worldlowslope);
}
// Find the wall's coordinates
fixed_t midtexheight = texheight * repeats;
fixed_t rowoffset = FixedDiv(gl_sidedef->rowoffset + gl_sidedef->offsety_mid, gl_sidedef->scaley_mid);
// Texture is not skewed
if (gl_linedef->flags & ML_NOSKEW)
{
// Peg it to the floor
if (gl_linedef->flags & ML_MIDPEG)
{
polybottom = max(front->floorheight, back->floorheight) + rowoffset;
polytop = polybottom + midtexheight;
}
// Peg it to the ceiling
else
{
polytop = min(front->ceilingheight, back->ceilingheight) + rowoffset;
polybottom = polytop - midtexheight;
}
// The right side's coordinates are the the same as the left side
polytopslope = polytop;
polybottomslope = polybottom;
}
// Skew the texture, but peg it to the floor
else if (gl_linedef->flags & ML_MIDPEG)
{
polybottom = popenbottom + rowoffset;
polytop = polybottom + midtexheight;
polybottomslope = popenbottomslope + rowoffset;
polytopslope = polybottomslope + midtexheight;
}
// Skew it according to the ceiling's slope
else
{
polytop = popentop + rowoffset;
polybottom = polytop - midtexheight;
polytopslope = popentopslope + rowoffset;
polybottomslope = polytopslope - midtexheight;
}
// CB
// 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
if (gl_curline->polyseg)
{
lowcut = polybottom;
highcut = polytop;
lowcutslope = polybottomslope;
highcutslope = polytopslope;
}
else
{
// The cut-off values of a linedef can always be constant, since every line has an absoulute front and or back sector
lowcut = popenbottom;
highcut = popentop;
lowcutslope = popenbottomslope;
highcutslope = popentopslope;
}
h = min(highcut, polytop);
l = max(polybottom, lowcut);
hS = min(highcutslope, polytopslope);
lS = max(polybottomslope, lowcutslope);
// PEGGING
fixed_t texturevpegslope;
if (gl_linedef->flags & ML_MIDPEG)
{
texturevpeg = midtexheight - h + polybottom;
texturevpegslope = midtexheight - hS + polybottomslope;
}
else
{
texturevpeg = polytop - h;
texturevpegslope = polytopslope - hS;
}
// Left side
wallVerts[3].t = texturevpeg * yscale * grTex->scaleY;
wallVerts[0].t = (h - l + texturevpeg) * yscale * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
// Right side
wallVerts[2].t = texturevpegslope * yscale * grTex->scaleY;
wallVerts[1].t = (hS - lS + texturevpegslope) * yscale * grTex->scaleY;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
// set top/bottom coords
// Take the texture peg into account, rather than changing the offsets past
// where the polygon might not be.
wallVerts[3].y = FIXED_TO_FLOAT(h);
wallVerts[0].y = FIXED_TO_FLOAT(l);
wallVerts[2].y = FIXED_TO_FLOAT(hS);
wallVerts[1].y = FIXED_TO_FLOAT(lS);
// TODO: Actually use the surface's flags so that I don't have to do this
FUINT blendmode = Surf.PolyFlags;
// Render midtextures on two-sided lines with a z-buffer offset.
// This will cause the midtexture appear on top, if a FOF overlaps with it.
blendmode |= PF_Decal;
if (gl_frontsector->numlights)
{
if (!(blendmode & PF_Masked))
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_TRANSLUCENT, NULL, blendmode);
else
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FOF_CUTLEVEL, NULL, blendmode);
}
else if (!(blendmode & PF_Masked))
HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, blendmode, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, blendmode, lightnum, colormap);
}
// Sky culling
// No longer so much a mess as before!
if (!gl_curline->polyseg) // Don't do it for polyobjects
{
// Sky culling
// No longer so much a mess as before!
if (gl_frontsector->ceilingpic == skyflatnum
&& gl_backsector->ceilingpic != skyflatnum) // don't cull if back sector is also sky
{
@ -1384,8 +1433,8 @@ static void HWR_ProcessSeg(void)
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (texturevpeg + gl_frontsector->ceilingheight - gl_frontsector->floorheight) * grTex->scaleY;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->offsetx_mid) * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + gl_sidedef->textureoffset + gl_sidedef->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + gl_sidedef->textureoffset + gl_sidedef->offsetx_mid) * grTex->scaleX;
// Texture correction for slopes
if (gl_linedef->flags & ML_NOSKEW) {
@ -1448,8 +1497,9 @@ static void HWR_ProcessSeg(void)
// Used for height comparisons and etc across FOFs and slopes
fixed_t high1, highslope1, low1, lowslope1;
fixed_t texturehpeg = gl_sidedef->textureoffset + gl_sidedef->offsetx_mid;
INT32 texnum;
line_t * newline = NULL; // Multi-Property FOF
lowcut = max(worldbottom, worldlow);
highcut = min(worldtop, worldhigh);
@ -1483,16 +1533,14 @@ static void HWR_ProcessSeg(void)
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
continue;
side_t *side = &sides[rover->master->sidenum[0]];
side_t *side = R_GetFFloorSide(gl_curline, rover);
boolean do_texture_skew;
boolean dont_peg_bottom;
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum;
side = &sides[newline->sidenum[0]];
line_t *newline = R_GetFFloorLine(gl_curline, rover);
do_texture_skew = newline->flags & ML_SKEWTD;
dont_peg_bottom = newline->flags & ML_DONTPEGBOTTOM;
}
@ -1570,14 +1618,14 @@ static void HWR_ProcessSeg(void)
}
}
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + side->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + side->offsetx_mid) * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + texturehpeg + side->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + texturehpeg + side->offsetx_mid) * grTex->scaleX;
}
FBITFIELD blendmode;
if (rover->fofflags & FOF_FOG)
{
FBITFIELD blendmode;
blendmode = PF_Fog|PF_NoTexture;
lightnum = rover->master->frontsector->lightlevel;
@ -1593,7 +1641,7 @@ static void HWR_ProcessSeg(void)
}
else
{
FBITFIELD blendmode = PF_Masked;
blendmode = PF_Masked;
if ((rover->fofflags & FOF_TRANSLUCENT && !(rover->fofflags & FOF_SPLAT)) || rover->blend)
{
@ -1641,13 +1689,21 @@ static void HWR_ProcessSeg(void)
if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope))
continue;
side_t *side = &sides[rover->master->sidenum[0]];
side_t *side = R_GetFFloorSide(gl_curline, rover);
boolean do_texture_skew;
boolean dont_peg_bottom;
if (rover->master->flags & ML_TFERLINE)
{
size_t linenum = gl_curline->linedef-gl_backsector->lines[0];
newline = rover->master->frontsector->lines[0] + linenum;
side = &sides[newline->sidenum[0]];
line_t *newline = R_GetFFloorLine(gl_curline, rover);
do_texture_skew = newline->flags & ML_SKEWTD;
dont_peg_bottom = newline->flags & ML_DONTPEGBOTTOM;
}
else
{
do_texture_skew = rover->master->flags & ML_SKEWTD;
dont_peg_bottom = gl_curline->linedef->flags & ML_DONTPEGBOTTOM;
}
texnum = R_GetTextureNum(side->midtexture);
@ -1684,23 +1740,49 @@ static void HWR_ProcessSeg(void)
}
else
{
// Wow, how was this missing from OpenGL for so long?
// ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software
// -- Monster Iestyn 26/06/18
fixed_t texturevpeg = side->rowoffset + side->offsety_mid;
grTex = HWR_GetTexture(texnum);
xscale = FixedToFloat(side->scalex_mid);
yscale = FixedToFloat(side->scaley_mid);
fixed_t diff = (*rover->topheight - h) * yscale;
if (!do_texture_skew) // no skewing
{
if (dont_peg_bottom)
texturevpeg -= (*rover->topheight - *rover->bottomheight) * yscale;
wallVerts[3].t = wallVerts[2].t = (diff + side->rowoffset + side->offsety_mid) * grTex->scaleY;
wallVerts[0].t = wallVerts[1].t = (((h - l) * yscale) + (diff + side->rowoffset + side->offsety_mid)) * grTex->scaleY;
wallVerts[3].t = (((*rover->topheight - h) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[2].t = (((*rover->topheight - hS) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[0].t = (((*rover->topheight - l) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[1].t = (((*rover->topheight - lS) * yscale) + texturevpeg) * grTex->scaleY;
}
else
{
if (!dont_peg_bottom) // skew by top
{
wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY;
wallVerts[0].t = (((h - l) * yscale) + texturevpeg) * grTex->scaleY;
wallVerts[1].t = (((hS - lS) * yscale) + texturevpeg) * grTex->scaleY;
}
else // skew by bottom
{
wallVerts[0].t = wallVerts[1].t = texturevpeg * grTex->scaleY;
wallVerts[3].t = wallVerts[0].t - ((h - l) * yscale) * grTex->scaleY;
wallVerts[2].t = wallVerts[1].t - ((hS - lS) * yscale) * grTex->scaleY;
}
}
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + side->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + side->offsetx_mid) * grTex->scaleX;
wallVerts[0].s = wallVerts[3].s = ((cliplow * xscale) + texturehpeg + side->offsetx_mid) * grTex->scaleX;
wallVerts[2].s = wallVerts[1].s = ((cliphigh * xscale) + texturehpeg + side->offsetx_mid) * grTex->scaleX;
}
FBITFIELD blendmode;
if (rover->fofflags & FOF_FOG)
{
FBITFIELD blendmode;
blendmode = PF_Fog|PF_NoTexture;
lightnum = rover->master->frontsector->lightlevel;
@ -1716,7 +1798,7 @@ static void HWR_ProcessSeg(void)
}
else
{
FBITFIELD blendmode = PF_Masked;
blendmode = PF_Masked;
if ((rover->fofflags & FOF_TRANSLUCENT && !(rover->fofflags & FOF_SPLAT)) || rover->blend)
{
@ -1994,36 +2076,14 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord)
static inline void HWR_AddPolyObjectSegs(void)
{
size_t i, j;
seg_t *gl_fakeline = Z_Calloc(sizeof(seg_t), PU_STATIC, NULL);
polyvertex_t *pv1 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL);
polyvertex_t *pv2 = Z_Calloc(sizeof(polyvertex_t), PU_STATIC, NULL);
// Sort through all the polyobjects
for (i = 0; i < numpolys; ++i)
{
// Render the polyobject's lines
for (j = 0; j < po_ptrs[i]->segCount; ++j)
{
// Copy the info of a polyobject's seg, then convert it to OpenGL floating point
M_Memcpy(gl_fakeline, po_ptrs[i]->segs[j], sizeof(seg_t));
// Now convert the line to float and add it to be rendered
pv1->x = FIXED_TO_FLOAT(gl_fakeline->v1->x);
pv1->y = FIXED_TO_FLOAT(gl_fakeline->v1->y);
pv2->x = FIXED_TO_FLOAT(gl_fakeline->v2->x);
pv2->y = FIXED_TO_FLOAT(gl_fakeline->v2->y);
gl_fakeline->pv1 = pv1;
gl_fakeline->pv2 = pv2;
HWR_AddLine(gl_fakeline);
}
HWR_AddLine(po_ptrs[i]->segs[j]);
}
// Free temporary data no longer needed
Z_Free(pv2);
Z_Free(pv1);
Z_Free(gl_fakeline);
}
static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
@ -2048,13 +2108,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
static FOutVector *planeVerts = NULL;
static UINT16 numAllocedPlaneVerts = 0;
if (nrPlaneVerts < 3) // Not even a triangle?
if (!r_renderfloors || nrPlaneVerts < 3) // Not even a triangle?
return;
else if (nrPlaneVerts > (size_t)UINT16_MAX) // FIXME: exceeds plVerts size
{
CONS_Debug(DBG_RENDER, "polygon size of %s exceeds max value of %d vertices\n", sizeu1(nrPlaneVerts), UINT16_MAX);
return;
}
// Allocate plane-vertex buffer if we need to
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
@ -4226,7 +4281,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
// uncapped/interpolation
interpmobjstate_t interp = {0};
if (!cv_renderthings.value)
if (!r_renderthings)
return;
if (!thing)
@ -5771,7 +5826,7 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 te
{
static size_t allocedwalls = 0;
if (!cv_renderwalls.value)
if (!r_renderwalls)
return;
// Force realloc if buffer has been freed
@ -5802,7 +5857,7 @@ void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend,
INT32 shader = SHADER_NONE;
if (!cv_renderwalls.value)
if (!r_renderwalls)
return;
// Lighting is done here instead so that fog isn't drawn incorrectly on transparent walls after sorting

View file

@ -671,6 +671,13 @@ void D_RegisterClientCommands(void)
for (i = 0; i < MAXPLAYERS; i++)
sprintf(player_names[i], "Player %d", 1 + i);
CV_RegisterVar(&cv_gravity);
CV_RegisterVar(&cv_tailspickup);
CV_RegisterVar(&cv_allowmlook);
CV_RegisterVar(&cv_flipcam);
CV_RegisterVar(&cv_flipcam2);
CV_RegisterVar(&cv_movebob);
if (dedicated)
return;
@ -901,13 +908,6 @@ void D_RegisterClientCommands(void)
// screen.c
CV_RegisterVar(&cv_fullscreen);
CV_RegisterVar(&cv_renderview);
CV_RegisterVar(&cv_renderhitboxinterpolation);
CV_RegisterVar(&cv_renderhitboxgldepth);
CV_RegisterVar(&cv_renderhitbox);
CV_RegisterVar(&cv_renderwalls);
CV_RegisterVar(&cv_renderfloors);
CV_RegisterVar(&cv_renderthings);
CV_RegisterVar(&cv_renderer);
CV_RegisterVar(&cv_scr_depth);
CV_RegisterVar(&cv_scr_width);
@ -928,8 +928,6 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_opflags);
CV_RegisterVar(&cv_ophoopflags);
CV_RegisterVar(&cv_mapthingnum);
// CV_RegisterVar(&cv_grid);
// CV_RegisterVar(&cv_snapto);
CV_RegisterVar(&cv_freedemocamera);

View file

@ -94,7 +94,10 @@ extern consvar_t cv_inttime, cv_coopstarposts, cv_cooplives, cv_advancemap, cv_p
extern consvar_t cv_overtime;
extern consvar_t cv_startinglives;
// for F_finale.c
extern consvar_t cv_gravity, cv_movebob;
extern consvar_t cv_tailspickup;
// for f_finale.c
extern consvar_t cv_rollingdemos;
extern consvar_t cv_ringslinger, cv_soundtest;
@ -105,7 +108,6 @@ extern consvar_t cv_maxping;
extern consvar_t cv_pingtimeout;
extern consvar_t cv_showping;
extern consvar_t cv_skipmapcheck;
extern consvar_t cv_sleep;

View file

@ -283,7 +283,6 @@ void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, b
extern mapthing_t *itemrespawnque[ITEMQUESIZE];
extern tic_t itemrespawntime[ITEMQUESIZE];
extern size_t iquehead, iquetail;
extern consvar_t cv_gravity, cv_movebob;
mobjtype_t P_GetMobjtype(UINT16 mthingtype);

View file

@ -3328,8 +3328,6 @@ static void P_InitializeSeg(seg_t *seg)
seg->lightmaps = NULL; // list of static lightmap for this seg
#endif
seg->numlights = 0;
seg->rlights = NULL;
seg->polyseg = NULL;
seg->dontrenderme = false;
}

View file

@ -1382,10 +1382,9 @@ void R_RenderPortalHorizonLine(sector_t *sector)
|| frontsector->ceilingpic == skyflatnum
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))
{
ceilingplane = R_FindPlane(frontsector, frontsector->ceilingheight, frontsector->ceilingpic,
ceilinglightlevel, frontsector->ceilingxoffset, frontsector->ceilingxscale, frontsector->ceilingyscale,
frontsector->ceilingyoffset, frontsector->ceilingangle,
ceilingcolormap, NULL, NULL, NULL, NULL);
ceilingplane = R_FindPlane(frontsector, frontsector->ceilingheight, frontsector->ceilingpic, ceilinglightlevel,
frontsector->ceilingxoffset, frontsector->ceilingyoffset, frontsector->ceilingxscale, frontsector->ceilingyscale,
frontsector->ceilingangle, ceilingcolormap, NULL, NULL, NULL, NULL);
}
else
ceilingplane = NULL;

View file

@ -751,9 +751,6 @@ typedef struct seg_s
lightmap_t *lightmaps; // for static lightmap
#endif
// Why slow things down by calculating lightlists for every thick side?
size_t numlights;
r_lightlist_t *rlights;
polyobj_t *polyseg;
boolean dontrenderme;
boolean glseg;
@ -837,6 +834,7 @@ typedef struct drawseg_s
INT16 *sprtopclip;
INT16 *sprbottomclip;
fixed_t *maskedtexturecol;
fixed_t *maskedtextureheight; // For handling sloped midtextures
fixed_t *invscale;
struct visplane_s *ffloorplanes[MAXFFLOORS];
@ -848,8 +846,6 @@ typedef struct drawseg_s
UINT8 portalpass; // if > 0 and <= portalrender, do not affect sprite clipping
fixed_t maskedtextureheight[MAXVIDWIDTH]; // For handling sloped midtextures
vertex_t leftpos, rightpos; // Used for rendering FOF walls with slopes
} drawseg_t;

View file

@ -66,6 +66,10 @@ sector_t *viewsector;
player_t *viewplayer;
mobj_t *r_viewmobj;
boolean r_renderwalls;
boolean r_renderfloors;
boolean r_renderthings;
fixed_t rendertimefrac;
fixed_t renderdeltatics;
boolean renderisnewtic;
@ -149,8 +153,6 @@ consvar_t cv_flipcam2 = CVAR_INIT ("flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT,
consvar_t cv_shadow = CVAR_INIT ("shadow", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_skybox = CVAR_INIT ("skybox", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_ffloorclip = CVAR_INIT ("r_ffloorclip", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_spriteclip = CVAR_INIT ("r_spriteclip", "On", CV_SAVE, CV_OnOff, NULL);
consvar_t cv_allowmlook = CVAR_INIT ("allowmlook", "Yes", CV_NETVAR|CV_ALLOWLUA, CV_YesNo, NULL);
consvar_t cv_showhud = CVAR_INIT ("showhud", "Yes", CV_CALL|CV_ALLOWLUA, CV_YesNo, R_SetViewSize);
consvar_t cv_translucenthud = CVAR_INIT ("translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL);
@ -161,12 +163,17 @@ consvar_t cv_drawdist_nights = CVAR_INIT ("drawdist_nights", "2048", CV_SAVE, dr
consvar_t cv_drawdist_precip = CVAR_INIT ("drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL);
consvar_t cv_fov = CVAR_INIT ("fov", "90", CV_SAVE|CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange);
consvar_t cv_fovchange = CVAR_INIT ("fovchange", "Off", CV_SAVE, CV_OnOff, NULL);
// Okay, whoever said homremoval causes a performance hit should be shot.
consvar_t cv_homremoval = CVAR_INIT ("homremoval", "No", CV_SAVE, homremoval_cons_t, NULL);
consvar_t cv_maxportals = CVAR_INIT ("maxportals", "2", CV_SAVE, maxportals_cons_t, NULL);
consvar_t cv_renderview = CVAR_INIT ("renderview", "On", 0, CV_OnOff, NULL);
consvar_t cv_renderwalls = CVAR_INIT ("r_renderwalls", "On", 0, CV_OnOff, NULL);
consvar_t cv_renderfloors = CVAR_INIT ("r_renderfloors", "On", 0, CV_OnOff, NULL);
consvar_t cv_renderthings = CVAR_INIT ("r_renderthings", "On", 0, CV_OnOff, NULL);
consvar_t cv_ffloorclip = CVAR_INIT ("r_ffloorclip", "On", 0, CV_OnOff, NULL);
consvar_t cv_spriteclip = CVAR_INIT ("r_spriteclip", "On", 0, CV_OnOff, NULL);
consvar_t cv_homremoval = CVAR_INIT ("homremoval", "No", CV_SAVE, homremoval_cons_t, NULL);
consvar_t cv_renderstats = CVAR_INIT ("renderstats", "Off", 0, CV_OnOff, NULL);
void SplitScreen_OnChange(void)
@ -383,33 +390,26 @@ fixed_t R_PointToDist(fixed_t x, fixed_t y)
return R_PointToDist2(viewx, viewy, x, y);
}
//
// R_ScaleFromGlobalAngle
// Returns the texture mapping scale for the current line (horizontal span)
// at the given angle.
// rw_distance must be calculated first.
//
// killough 5/2/98: reformatted, cleaned up
//
// note: THIS IS USED ONLY FOR WALLS!
fixed_t R_ScaleFromGlobalAngle(angle_t visangle)
line_t *R_GetFFloorLine(const seg_t *seg, const ffloor_t *pfloor)
{
angle_t anglea = ANGLE_90 + (visangle-viewangle);
angle_t angleb = ANGLE_90 + (visangle-rw_normalangle);
fixed_t den = FixedMul(rw_distance, FINESINE(anglea>>ANGLETOFINESHIFT));
// proff 11/06/98: Changed for high-res
fixed_t num = FixedMul(projectiony, FINESINE(angleb>>ANGLETOFINESHIFT));
if (den > num>>16)
if (pfloor->master->flags & ML_TFERLINE)
{
num = FixedDiv(num, den);
if (num > 64*FRACUNIT)
return 64*FRACUNIT;
if (num < 256)
return 256;
return num;
size_t linenum = seg->linedef - pfloor->target->lines[0];
return pfloor->master->frontsector->lines[0] + linenum;
}
return 64*FRACUNIT;
else
return pfloor->master;
}
side_t *R_GetFFloorSide(const seg_t *seg, const ffloor_t *pfloor)
{
if (pfloor->master->flags & ML_TFERLINE)
{
line_t *newline = R_GetFFloorLine(seg, pfloor);
return &sides[newline->sidenum[0]];
}
else
return &sides[pfloor->master->sidenum[0]];
}
//
@ -1620,17 +1620,11 @@ void R_RenderPlayerView(player_t *player)
void R_RegisterEngineStuff(void)
{
CV_RegisterVar(&cv_gravity);
CV_RegisterVar(&cv_tailspickup);
CV_RegisterVar(&cv_allowmlook);
CV_RegisterVar(&cv_homremoval);
CV_RegisterVar(&cv_flipcam);
CV_RegisterVar(&cv_flipcam2);
// Enough for dedicated server
// Do nothing for dedicated server
if (dedicated)
return;
CV_RegisterVar(&cv_homremoval);
CV_RegisterVar(&cv_translucency);
CV_RegisterVar(&cv_drawdist);
CV_RegisterVar(&cv_drawdist_nights);
@ -1643,6 +1637,13 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_shadow);
CV_RegisterVar(&cv_skybox);
CV_RegisterVar(&cv_renderview);
CV_RegisterVar(&cv_renderhitboxinterpolation);
CV_RegisterVar(&cv_renderhitboxgldepth);
CV_RegisterVar(&cv_renderhitbox);
CV_RegisterVar(&cv_renderwalls);
CV_RegisterVar(&cv_renderfloors);
CV_RegisterVar(&cv_renderthings);
CV_RegisterVar(&cv_ffloorclip);
CV_RegisterVar(&cv_spriteclip);
@ -1681,8 +1682,6 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_maxportals);
CV_RegisterVar(&cv_movebob);
// Frame interpolation/uncapped
CV_RegisterVar(&cv_fpscap);
}

View file

@ -80,13 +80,15 @@ angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
fixed_t R_PointToDist(fixed_t x, fixed_t y);
fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1);
fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
boolean R_IsPointInSector(sector_t *sector, fixed_t x, fixed_t y);
subsector_t *R_PointInSubsector(fixed_t x, fixed_t y);
subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y);
boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph);
line_t *R_GetFFloorLine(const seg_t *seg, const ffloor_t *pfloor);
side_t *R_GetFFloorSide(const seg_t *seg, const ffloor_t *pfloor);
// Render stats
extern precise_t ps_prevframetime;// time when previous frame was rendered
@ -117,12 +119,18 @@ extern consvar_t cv_chasecam, cv_chasecam2;
extern consvar_t cv_flipcam, cv_flipcam2;
extern consvar_t cv_shadow;
extern consvar_t cv_ffloorclip, cv_spriteclip;
extern consvar_t cv_translucency;
extern consvar_t cv_drawdist, cv_drawdist_nights, cv_drawdist_precip;
extern consvar_t cv_fov, cv_fovchange;
extern consvar_t cv_skybox;
extern consvar_t cv_tailspickup;
extern consvar_t cv_renderview;
extern consvar_t cv_renderhitbox, cv_renderhitboxinterpolation, cv_renderhitboxgldepth;
extern consvar_t cv_renderwalls, cv_renderfloors, cv_renderthings;
extern consvar_t cv_ffloorclip, cv_spriteclip;
extern boolean r_renderwalls;
extern boolean r_renderfloors;
extern boolean r_renderthings;
// Called by startup code.
void R_Init(void);

View file

@ -603,6 +603,9 @@ void R_DrawPlanes(void)
visplane_t *pl;
INT32 i;
if (!r_renderfloors)
return;
R_UpdatePlaneRipple();
for (i = 0; i < MAXVISPLANES; i++, pl++)
@ -881,9 +884,6 @@ void R_DrawSinglePlane(visplane_t *pl)
if (!(pl->minx <= pl->maxx))
return;
if (!cv_renderfloors.value)
return;
// sky flat
if (pl->picnum == skyflatnum)
{

View file

@ -16,7 +16,6 @@
#include "r_sky.h"
#include "r_portal.h"
#include "r_splats.h"
#include "w_wad.h"
#include "z_zone.h"
@ -75,6 +74,8 @@ static fixed_t *maskedtextureheight = NULL;
static fixed_t *thicksidecol = NULL;
static fixed_t *invscale = NULL;
static boolean texcoltables;
//SoM: 3/23/2000: Use boom opening limit removal
static size_t numopenings;
static INT16 *openings, *lastopening;
@ -88,10 +89,6 @@ void R_ClearSegTables(void)
curtexturecolumntable = texturecolumntable;
}
// ==========================================================================
// R_RenderMaskedSegRange
// ==========================================================================
transnum_t R_GetLinedefTransTable(fixed_t alpha)
{
return (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1);
@ -111,10 +108,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
INT32 times, repeats;
INT64 overflow_test;
INT32 range;
UINT8 vertflip;
unsigned lengthcol;
if (!cv_renderwalls.value)
return;
fixed_t wall_scaley;
fixed_t scalestep;
fixed_t scale1;
// Calculate light table.
// Use different light tables
@ -163,9 +162,17 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
colfunc = colfuncs[COLDRAWFUNC_FUZZY];
}
fixed_t wall_scaley = sidedef->scaley_mid;
fixed_t scalestep = FixedDiv(ds->scalestep, wall_scaley);
fixed_t scale1 = FixedDiv(ds->scale1, wall_scaley);
vertflip = textures[texnum]->flip & 2;
wall_scaley = sidedef->scaley_mid;
if (wall_scaley < 0)
{
wall_scaley = -wall_scaley;
vertflip = !vertflip;
}
scalestep = FixedDiv(ds->scalestep, wall_scaley);
scale1 = FixedDiv(ds->scale1, wall_scaley);
range = max(ds->x2-ds->x1, 1);
rw_scalestep = scalestep;
@ -174,7 +181,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
// Texture must be cached
R_CheckTextureCache(texnum);
if (textures[texnum]->flip & 2) // vertically flipped?
if (vertflip) // vertically flipped?
colfunc_2s = R_DrawFlippedMaskedColumn;
else
colfunc_2s = R_DrawMaskedColumn; // render the usual 2sided single-patch packed texture
@ -470,6 +477,11 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor)
return false;
}
static fixed_t R_GetSlopeTextureSlide(pslope_t *slope, angle_t lineangle)
{
return FixedMul(slope->zdelta, FINECOSINE((lineangle-slope->xydirection)>>ANGLETOFINESHIFT));
}
//
// R_RenderThickSideRange
// Renders all the thick sides in the given range.
@ -494,19 +506,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
INT64 top_frac, top_step, bottom_frac, bottom_step;
// skew FOF walls with slopes?
fixed_t ffloortextureslide = 0;
INT32 oldx = -1;
fixed_t oldtexturecolumn = -1;
fixed_t left_top, left_bottom; // needed here for slope skewing
pslope_t *skewslope = NULL;
boolean do_texture_skew;
boolean dont_peg_bottom;
fixed_t wall_offsetx;
fixed_t wall_scalex, wall_scaley;
UINT8 vertflip;
unsigned lengthcol;
void (*colfunc_2s) (column_t *, unsigned);
if (!cv_renderwalls.value)
return;
// Calculate light table.
// Use different light tables
// for horizontal / vertical / diagonal. Diagonal?
@ -515,15 +526,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
curline = ds->curline;
backsector = pfloor->target;
frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector;
sidedef = &sides[pfloor->master->sidenum[0]];
sidedef = R_GetFFloorSide(curline, pfloor);
colfunc = colfuncs[BASEDRAWFUNC];
if (pfloor->master->flags & ML_TFERLINE)
{
size_t linenum = curline->linedef-backsector->lines[0];
line_t *newline = pfloor->master->frontsector->lines[0] + linenum;
sidedef = &sides[newline->sidenum[0]];
line_t *newline = R_GetFFloorLine(curline, pfloor);
do_texture_skew = newline->flags & ML_SKEWTD;
dont_peg_bottom = newline->flags & ML_DONTPEGBOTTOM;
}
@ -534,6 +543,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
}
texnum = R_GetTextureNum(sidedef->midtexture);
vertflip = textures[texnum]->flip & 2;
if (pfloor->fofflags & FOF_TRANSLUCENT)
{
@ -687,18 +697,25 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
wall_scalex = FixedDiv(FRACUNIT, sidedef->scalex_mid);
wall_scaley = sidedef->scaley_mid;
if (wall_scaley < 0)
{
wall_scaley = -wall_scaley;
vertflip = !vertflip;
}
thicksidecol = ffloortexturecolumn;
wall_offsetx = ds->offsetx + sidedef->offsetx_mid;
if (wall_scalex == FRACUNIT)
{
for (INT32 x = x1; x <= x2; x++)
thicksidecol[x] = ds->thicksidecol[x] + ds->offsetx;
thicksidecol[x] = ds->thicksidecol[x];
}
else
{
for (INT32 x = x1; x <= x2; x++)
thicksidecol[x] = FixedDiv(ds->thicksidecol[x], wall_scalex) + ds->offsetx;
thicksidecol[x] = FixedDiv(ds->thicksidecol[x], wall_scalex);
}
mfloorclip = ds->sprbottomclip;
@ -733,7 +750,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (skewslope)
{
angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y);
ffloortextureslide = FixedMul(skewslope->zdelta, FINECOSINE((lineangle-skewslope->xydirection)>>ANGLETOFINESHIFT));
ffloortextureslide = FixedMul(R_GetSlopeTextureSlide(skewslope, lineangle), wall_scaley);
}
dc_texturemid += offsetvalue;
@ -741,7 +758,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
// Texture must be cached
R_CheckTextureCache(texnum);
if (textures[texnum]->flip & 2) // vertically flipped?
if (vertflip) // vertically flipped?
colfunc_2s = R_DrawRepeatFlippedMaskedColumn;
else
colfunc_2s = R_DrawRepeatMaskedColumn;
@ -775,9 +792,9 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
// skew FOF walls
if (ffloortextureslide)
{
if (oldx != -1)
dc_texturemid += FixedMul(ffloortextureslide, thicksidecol[oldx]-thicksidecol[dc_x]);
oldx = dc_x;
if (oldtexturecolumn != -1)
dc_texturemid += FixedMul(ffloortextureslide, oldtexturecolumn-ds->thicksidecol[dc_x]);
oldtexturecolumn = ds->thicksidecol[dc_x];
}
// Calculate bounds
@ -814,7 +831,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
dc_iscale = FixedMul(0xffffffffu / (unsigned)spryscale, wall_scaley);
// Get data for the column
col = R_GetColumn(texnum, (thicksidecol[dc_x] >> FRACBITS));
col = R_GetColumn(texnum, ((thicksidecol[dc_x] + wall_offsetx) >> FRACBITS));
// SoM: New code does not rely on R_DrawColumnShadowed_8 which
// will (hopefully) put less strain on the stack.
@ -988,36 +1005,77 @@ static boolean R_FFloorCanClip(visffloor_t *pfloor)
#define HEIGHTBITS 12
#define HEIGHTUNIT (1<<HEIGHTBITS)
static void R_DrawRegularWall(UINT8 *source, INT32 height)
{
dc_source = source;
dc_texheight = height;
colfunc();
}
//profile stuff ---------------------------------------------------------
//#define TIMING
#ifdef TIMING
#include "p5prof.h"
INT64 mycount;
INT64 mytotal = 0;
UINT32 nombre = 100000;
//static char runtest[10][80];
#endif
//profile stuff ---------------------------------------------------------
static void R_DrawFlippedWall(UINT8 *source, INT32 height)
{
dc_texheight = height;
R_DrawFlippedPost(source, (unsigned)height, colfunc);
}
static void R_DrawNoWall(UINT8 *source, INT32 height)
{
(void)source;
(void)height;
}
static void R_RenderSegLoop (void)
{
angle_t angle;
fixed_t textureoffset;
size_t pindex;
INT32 yl;
INT32 yh;
size_t pindex;
INT32 yl;
INT32 yh;
INT32 mid;
INT32 mid;
fixed_t texturecolumn = 0;
fixed_t toptexturecolumn = 0;
fixed_t bottomtexturecolumn = 0;
fixed_t oldtexturecolumn = -1;
fixed_t oldtexturecolumn_top = -1;
fixed_t oldtexturecolumn_bottom = -1;
INT32 top;
INT32 bottom;
INT32 i;
INT32 top;
INT32 bottom;
INT32 i;
fixed_t topscaley = rw_toptexturescaley;
fixed_t midscaley = rw_midtexturescaley;
fixed_t bottomscaley = rw_bottomtexturescaley;
void (*drawtop)(UINT8 *, INT32) = R_DrawRegularWall;
void (*drawmiddle)(UINT8 *, INT32) = R_DrawRegularWall;
void (*drawbottom)(UINT8 *, INT32) = R_DrawRegularWall;
if (dc_numlights)
colfunc = colfuncs[COLDRAWFUNC_SHADOWED];
if (toptexture && topscaley < 0)
{
topscaley = -topscaley;
drawtop = R_DrawFlippedWall;
}
if (midtexture && midscaley < 0)
{
midscaley = -midscaley;
drawmiddle = R_DrawFlippedWall;
}
if (bottomtexture && bottomscaley < 0)
{
bottomscaley = -bottomscaley;
drawbottom = R_DrawFlippedWall;
}
if (!r_renderwalls)
{
drawtop = R_DrawNoWall;
drawmiddle = R_DrawNoWall;
drawbottom = R_DrawNoWall;
}
if (midtexture)
R_CheckTextureCache(midtexture);
@ -1252,32 +1310,14 @@ static void R_RenderSegLoop (void)
// single sided line
if (yl <= yh && yh >= 0 && yl < viewheight)
{
if (cv_renderwalls.value)
{
fixed_t offset = texturecolumn + rw_offsetx;
fixed_t offset = texturecolumn + rw_offsetx;
dc_yl = yl;
dc_yh = yh;
dc_texturemid = rw_midtexturemid;
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, rw_midtexturescaley);
dc_source = R_GetColumn(midtexture, offset >> FRACBITS)->pixels;
dc_texheight = textureheight[midtexture]>>FRACBITS;
//profile stuff ---------------------------------------------------------
#ifdef TIMING
ProfZeroTimer();
#endif
colfunc();
#ifdef TIMING
RDMSR(0x10,&mycount);
mytotal += mycount; //64bit add
if (nombre--==0)
I_Error("R_DrawColumn CPU Spy reports: 0x%d %d\n", *((INT32 *)&mytotal+1),
(INT32)mytotal);
#endif
//profile stuff ---------------------------------------------------------
}
dc_yl = yl;
dc_yh = yh;
dc_texturemid = rw_midtexturemid;
dc_texheight = textureheight[midtexture]>>FRACBITS;
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, midscaley);
drawmiddle(R_GetColumn(midtexture, offset >> FRACBITS)->pixels, dc_texheight);
// dont draw anything more for this column, since
// a midtexture blocks the view
@ -1321,21 +1361,17 @@ static void R_RenderSegLoop (void)
}
else if (mid >= 0) // safe to draw top texture
{
if (cv_renderwalls.value)
{
fixed_t offset = rw_offset_top;
if (rw_toptexturescalex < 0)
offset = -offset;
offset = toptexturecolumn + offset;
fixed_t offset = rw_offset_top;
if (rw_toptexturescalex < 0)
offset = -offset;
offset = toptexturecolumn + offset;
dc_yl = yl;
dc_yh = mid;
dc_texturemid = rw_toptexturemid;
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, rw_toptexturescaley);
dc_source = R_GetColumn(toptexture, offset >> FRACBITS)->pixels;
dc_texheight = textureheight[toptexture]>>FRACBITS;
colfunc();
}
dc_yl = yl;
dc_yh = mid;
dc_texturemid = rw_toptexturemid;
dc_texheight = textureheight[toptexture]>>FRACBITS;
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, topscaley);
drawtop(R_GetColumn(toptexture, offset >> FRACBITS)->pixels, dc_texheight);
ceilingclip[rw_x] = (INT16)mid;
}
else if (!rw_ceilingmarked) // entirely off top of screen
@ -1345,8 +1381,8 @@ static void R_RenderSegLoop (void)
ceilingclip[rw_x] = topclip;
if (oldtexturecolumn_top != -1)
rw_toptexturemid += FixedMul(rw_toptextureslide, oldtexturecolumn_top-toptexturecolumn);
oldtexturecolumn_top = toptexturecolumn;
rw_toptexturemid += FixedMul(rw_toptextureslide, oldtexturecolumn_top-textureoffset);
oldtexturecolumn_top = textureoffset;
}
else if (markceiling && (!rw_ceilingmarked)) // no top wall
ceilingclip[rw_x] = topclip;
@ -1372,21 +1408,17 @@ static void R_RenderSegLoop (void)
}
else if (mid < viewheight) // safe to draw bottom texture
{
if (cv_renderwalls.value)
{
fixed_t offset = rw_offset_bottom;
if (rw_bottomtexturescalex < 0)
offset = -offset;
offset = bottomtexturecolumn + offset;
fixed_t offset = rw_offset_bottom;
if (rw_bottomtexturescalex < 0)
offset = -offset;
offset = bottomtexturecolumn + offset;
dc_yl = mid;
dc_yh = yh;
dc_texturemid = rw_bottomtexturemid;
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, rw_bottomtexturescaley);
dc_source = R_GetColumn(bottomtexture, offset >> FRACBITS)->pixels;
dc_texheight = textureheight[bottomtexture]>>FRACBITS;
colfunc();
}
dc_yl = mid;
dc_yh = yh;
dc_texturemid = rw_bottomtexturemid;
dc_texheight = textureheight[bottomtexture]>>FRACBITS;
dc_iscale = FixedMul(0xffffffffu / (unsigned)rw_scale, bottomscaley);
drawbottom(R_GetColumn(bottomtexture, offset >> FRACBITS)->pixels, dc_texheight);
floorclip[rw_x] = (INT16)mid;
}
else if (!rw_floormarked) // entirely off bottom of screen
@ -1396,8 +1428,8 @@ static void R_RenderSegLoop (void)
floorclip[rw_x] = bottomclip;
if (oldtexturecolumn_bottom != -1)
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn_bottom-bottomtexturecolumn);
oldtexturecolumn_bottom = bottomtexturecolumn;
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn_bottom-textureoffset);
oldtexturecolumn_bottom = textureoffset;
}
else if (markfloor && (!rw_floormarked)) // no bottom wall
floorclip[rw_x] = bottomclip;
@ -1421,11 +1453,14 @@ static void R_RenderSegLoop (void)
{
if (oldtexturecolumn != -1)
{
rw_midtexturemid += FixedMul(rw_midtextureslide, oldtexturecolumn-texturecolumn);
rw_midtextureback += FixedMul(rw_midtexturebackslide, oldtexturecolumn-texturecolumn);
INT32 diff = oldtexturecolumn-textureoffset;
if (rw_invmidtexturescalex < 0)
diff = -diff;
rw_midtexturemid += FixedMul(rw_midtextureslide, diff);
rw_midtextureback += FixedMul(rw_midtexturebackslide, diff);
}
oldtexturecolumn = texturecolumn;
oldtexturecolumn = textureoffset;
}
if (invscale)
@ -1519,7 +1554,7 @@ static void R_AllocClippingTables(size_t range)
static void R_AllocTextureColumnTables(size_t range)
{
size_t pos = curtexturecolumntable - texturecolumntable;
size_t need = range * 3;
size_t need = range * 4;
if (pos + need < texturecolumntablesize)
return;
@ -1540,15 +1575,48 @@ static void R_AllocTextureColumnTables(size_t range)
for (drawseg_t *ds = drawsegs; ds < ds_p; ds++)
{
// Check if it's in range of the tables
if (ds->maskedtexturecol + ds->x1 >= oldtable && ds->maskedtexturecol + ds->x1 <= oldlast)
ds->maskedtexturecol = (ds->maskedtexturecol - oldtable) + texturecolumntable;
if (ds->thicksidecol + ds->x1 >= oldtable && ds->thicksidecol + ds->x1 <= oldlast)
ds->thicksidecol = (ds->thicksidecol - oldtable) + texturecolumntable;
if (ds->invscale + ds->x1 >= oldtable && ds->invscale + ds->x1 <= oldlast)
ds->invscale = (ds->invscale - oldtable) + texturecolumntable;
#define CHECK(which) \
if (which + ds->x1 >= oldtable && which + ds->x1 <= oldlast) \
which = (which - oldtable) + texturecolumntable
CHECK(ds->maskedtexturecol);
CHECK(ds->maskedtextureheight);
CHECK(ds->thicksidecol);
CHECK(ds->invscale);
#undef CHECK
}
}
//
// R_ScaleFromGlobalAngle
// Returns the texture mapping scale for the current line (horizontal span)
// at the given angle.
// rw_distance must be calculated first.
//
// killough 5/2/98: reformatted, cleaned up
//
// note: THIS IS USED ONLY FOR WALLS!
static fixed_t R_ScaleFromGlobalAngle(angle_t visangle)
{
angle_t anglea = ANGLE_90 + (visangle-viewangle);
angle_t angleb = ANGLE_90 + (visangle-rw_normalangle);
fixed_t den = FixedMul(rw_distance, FINESINE(anglea>>ANGLETOFINESHIFT));
// proff 11/06/98: Changed for high-res
fixed_t num = FixedMul(projectiony, FINESINE(angleb>>ANGLETOFINESHIFT));
if (den > num>>16)
{
num = FixedDiv(num, den);
if (num > 64*FRACUNIT)
return 64*FRACUNIT;
if (num < 256)
return 256;
return num;
}
return 64*FRACUNIT;
}
//
// R_StoreWallRange
// A wall segment will be drawn
@ -1720,11 +1788,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
midtexture = toptexture = bottomtexture = maskedtexture = 0;
ds_p->maskedtexturecol = NULL;
ds_p->maskedtextureheight = NULL;
ds_p->numthicksides = numthicksides = 0;
ds_p->thicksidecol = NULL;
ds_p->invscale = NULL;
ds_p->tsilheight = 0;
texcoltables = false;
numbackffloors = 0;
for (i = 0; i < MAXFFLOORS; i++)
@ -1750,16 +1821,19 @@ void R_StoreWallRange(INT32 start, INT32 stop)
angle_t lineangle = R_PointToAngle2(curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y);
if (frontsector->f_slope)
floorfrontslide = FixedMul(frontsector->f_slope->zdelta, FINECOSINE((lineangle-frontsector->f_slope->xydirection)>>ANGLETOFINESHIFT));
floorfrontslide = R_GetSlopeTextureSlide(frontsector->f_slope, lineangle);
if (frontsector->c_slope)
ceilingfrontslide = FixedMul(frontsector->c_slope->zdelta, FINECOSINE((lineangle-frontsector->c_slope->xydirection)>>ANGLETOFINESHIFT));
ceilingfrontslide = R_GetSlopeTextureSlide(frontsector->c_slope, lineangle);
if (backsector && backsector->f_slope)
floorbackslide = FixedMul(backsector->f_slope->zdelta, FINECOSINE((lineangle-backsector->f_slope->xydirection)>>ANGLETOFINESHIFT));
if (backsector)
{
if (backsector->f_slope)
floorbackslide = R_GetSlopeTextureSlide(backsector->f_slope, lineangle);
if (backsector && backsector->c_slope)
ceilingbackslide = FixedMul(backsector->c_slope->zdelta, FINECOSINE((lineangle-backsector->c_slope->xydirection)>>ANGLETOFINESHIFT));
if (backsector->c_slope)
ceilingbackslide = R_GetSlopeTextureSlide(backsector->c_slope, lineangle);
}
}
rw_midtexturescalex = sidedef->scalex_mid;
@ -1775,26 +1849,27 @@ void R_StoreWallRange(INT32 start, INT32 stop)
fixed_t rowoffset = sidedef->rowoffset + sidedef->offsety_mid;
fixed_t texheight = textureheight[midtexture];
fixed_t scaley = abs(rw_midtexturescaley);
if (rw_midtexturescaley > 0)
{
if (linedef->flags & ML_NOSKEW)
{
if (linedef->flags & ML_DONTPEGBOTTOM)
rw_midtexturemid = FixedMul(frontsector->floorheight - viewz, rw_midtexturescaley) + texheight;
rw_midtexturemid = FixedMul(frontsector->floorheight - viewz, scaley) + texheight;
else
rw_midtexturemid = FixedMul(frontsector->ceilingheight - viewz, rw_midtexturescaley);
rw_midtexturemid = FixedMul(frontsector->ceilingheight - viewz, scaley);
}
else if (linedef->flags & ML_DONTPEGBOTTOM)
{
rw_midtexturemid = FixedMul(worldbottom, rw_midtexturescaley) + texheight;
rw_midtextureslide = floorfrontslide;
rw_midtexturemid = FixedMul(worldbottom, scaley) + texheight;
rw_midtextureslide = FixedMul(floorfrontslide, scaley);
}
else
{
// top of texture at top
rw_midtexturemid = FixedMul(worldtop, rw_midtexturescaley);
rw_midtextureslide = ceilingfrontslide;
rw_midtexturemid = FixedMul(worldtop, scaley);
rw_midtextureslide = FixedMul(ceilingfrontslide, scaley);
}
}
else
@ -1805,20 +1880,20 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (linedef->flags & ML_NOSKEW)
{
if (linedef->flags & ML_DONTPEGBOTTOM)
rw_midtexturemid = FixedMul(frontsector->floorheight - viewz, rw_midtexturescaley);
rw_midtexturemid = FixedMul(frontsector->floorheight - viewz, scaley);
else
rw_midtexturemid = FixedMul(frontsector->ceilingheight - viewz, rw_midtexturescaley) + texheight;
rw_midtexturemid = FixedMul(frontsector->ceilingheight - viewz, scaley) + texheight;
}
else if (linedef->flags & ML_DONTPEGBOTTOM)
{
rw_midtexturemid = FixedMul(worldbottom, rw_midtexturescaley);
rw_midtextureslide = floorfrontslide;
rw_midtexturemid = FixedMul(worldbottom, scaley);
rw_midtextureslide = FixedMul(floorfrontslide, scaley);
}
else
{
// top of texture at top
rw_midtexturemid = FixedMul(worldtop, rw_midtexturescaley) + texheight;
rw_midtextureslide = ceilingfrontslide;
rw_midtexturemid = FixedMul(worldtop, scaley) + texheight;
rw_midtextureslide = FixedMul(ceilingfrontslide, scaley);
}
}
@ -2027,15 +2102,16 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{
// top of texture at top
rw_toptexturemid = worldtop;
rw_toptextureslide = ceilingfrontslide;
rw_toptextureslide = FixedMul(ceilingfrontslide, abs(rw_toptexturescaley));
}
else
{
rw_toptexturemid = worldhigh + texheight;
rw_toptextureslide = ceilingbackslide;
rw_toptextureslide = FixedMul(ceilingbackslide, abs(rw_toptexturescaley));
}
rw_toptexturemid = FixedMul(rw_toptexturemid, rw_toptexturescaley);
rw_toptexturemid = FixedMul(rw_toptexturemid, abs(rw_toptexturescaley));
rw_toptexturemid += toprowoffset;
}
// check BOTTOM TEXTURE
@ -2066,24 +2142,24 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// bottom of texture at bottom
// top of texture at top
rw_bottomtexturemid = worldbottom;
rw_bottomtextureslide = floorfrontslide;
rw_bottomtextureslide = FixedMul(floorfrontslide, abs(rw_bottomtexturescaley));
}
else
{
// top of texture at top
rw_bottomtexturemid = worldlow;
rw_bottomtextureslide = floorbackslide;
rw_bottomtextureslide = FixedMul(floorbackslide, abs(rw_bottomtexturescaley));
}
rw_bottomtexturemid = FixedMul(rw_bottomtexturemid, rw_bottomtexturescaley);
rw_bottomtexturemid = FixedMul(rw_bottomtexturemid, abs(rw_bottomtexturescaley));
rw_bottomtexturemid += botrowoffset;
}
rw_toptexturemid += toprowoffset;
rw_bottomtexturemid += botrowoffset;
// allocate space for masked texture tables
R_AllocTextureColumnTables(rw_stopx - start);
texcoltables = true;
if (frontsector && backsector && !Tag_Compare(&frontsector->tags, &backsector->tags) && (backsector->ffloors || frontsector->ffloors))
{
ffloor_t *rover;
@ -2282,7 +2358,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
ds_p->maskedtexturecol = maskedtexturecol = curtexturecolumntable - rw_x;
curtexturecolumntable += rw_stopx - rw_x;
maskedtextureheight = ds_p->maskedtextureheight; // note to red, this == &(ds_p->maskedtextureheight[0])
ds_p->maskedtextureheight = maskedtextureheight = curtexturecolumntable - rw_x;
curtexturecolumntable += rw_stopx - rw_x;
maskedtexture = true;
@ -2324,13 +2401,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
}
rw_midtexturemid = FixedMul(rw_midtexturemid, rw_midtexturescaley);
rw_midtextureback = FixedMul(rw_midtextureback, rw_midtexturescaley);
rw_midtexturemid = FixedMul(rw_midtexturemid, abs(rw_midtexturescaley));
rw_midtextureback = FixedMul(rw_midtextureback, abs(rw_midtexturescaley));
rw_midtextureslide = FixedMul(rw_midtextureslide, abs(rw_midtexturescaley));
rw_midtexturebackslide = FixedMul(rw_midtexturebackslide, abs(rw_midtexturescaley));
rw_midtexturemid += sidedef->rowoffset + sidedef->offsety_mid;
rw_midtextureback += sidedef->rowoffset + sidedef->offsety_mid;
maskedtexture = true;
}
}

View file

@ -658,12 +658,31 @@ void R_DrawMaskedColumn(column_t *column, unsigned lengthcol)
static UINT8 *flippedcol = NULL;
static size_t flippedcolsize = 0;
void R_DrawFlippedPost(UINT8 *source, unsigned length, void (*drawcolfunc)(void))
{
if (!length)
return;
if (!flippedcolsize || length > flippedcolsize)
{
flippedcolsize = length;
flippedcol = Z_Realloc(flippedcol, length, PU_STATIC, NULL);
}
dc_source = flippedcol;
for (UINT8 *s = (UINT8 *)source, *d = flippedcol+length-1; d >= flippedcol; s++)
*d-- = *s;
drawcolfunc();
}
void R_DrawFlippedMaskedColumn(column_t *column, unsigned lengthcol)
{
INT32 topscreen;
INT32 bottomscreen;
fixed_t basetexturemid = dc_texturemid;
UINT8 *d,*s;
INT32 topdelta;
for (unsigned i = 0; i < column->num_posts; i++)
{
@ -671,7 +690,7 @@ void R_DrawFlippedMaskedColumn(column_t *column, unsigned lengthcol)
if (!post->length)
continue;
INT32 topdelta = lengthcol-post->length-post->topdelta;
topdelta = lengthcol-post->length-post->topdelta;
topscreen = sprtopscreen + spryscale*topdelta;
bottomscreen = sprbotscreen == INT32_MAX ? topscreen + spryscale*post->length
: sprbotscreen + spryscale*post->length;
@ -698,18 +717,9 @@ void R_DrawFlippedMaskedColumn(column_t *column, unsigned lengthcol)
if (dc_yl <= dc_yh && dc_yh > 0)
{
if (post->length > flippedcolsize)
{
flippedcolsize = post->length;
flippedcol = Z_Realloc(flippedcol, flippedcolsize, PU_STATIC, NULL);
}
for (s = column->pixels+post->data_offset+post->length, d = flippedcol; d < flippedcol+post->length; --s)
*d++ = *s;
dc_source = flippedcol;
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
colfunc();
R_DrawFlippedPost(column->pixels + post->data_offset, post->length, colfunc);
}
}
@ -1527,7 +1537,7 @@ static void R_ProjectSprite(mobj_t *thing)
// uncapped/interpolation
interpmobjstate_t interp = {0};
if (!cv_renderthings.value)
if (!r_renderthings)
return;
// do interpolation
@ -2684,7 +2694,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
// Add the 3D floors, thicksides, and masked textures...
for (ds = drawsegs + mask->drawsegs[1]; ds-- > drawsegs + mask->drawsegs[0];)
{
if (ds->numthicksides)
if (ds->numthicksides && r_renderwalls)
{
for (i = 0; i < ds->numthicksides; i++)
{
@ -2703,17 +2713,19 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps
else {
// Put it in!
entry = R_CreateDrawNode(head);
entry->plane = plane;
entry->seg = ds;
if (r_renderwalls)
entry->seg = ds;
if (r_renderfloors)
entry->plane = plane;
}
ds->curline->polyseg->visplane = NULL;
}
if (ds->maskedtexturecol)
if (ds->maskedtexturecol && r_renderwalls)
{
entry = R_CreateDrawNode(head);
entry->seg = ds;
}
if (ds->numffloorplanes)
if (ds->numffloorplanes && r_renderfloors)
{
for (i = 0; i < ds->numffloorplanes; i++)
{
@ -3180,9 +3192,6 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port
(lowscale < spr->sortscale &&
!R_PointOnSegSide (spr->gx, spr->gy, ds->curline)))
{
// masked mid texture?
/*if (ds->maskedtexturecol)
R_RenderMaskedSegRange (ds, r1, r2);*/
// seg is behind sprite
continue;
}

View file

@ -48,6 +48,7 @@ extern fixed_t windowbottom;
void R_DrawMaskedColumn(column_t *column, unsigned lengthcol);
void R_DrawFlippedMaskedColumn(column_t *column, unsigned lengthcol);
void R_DrawFlippedPost(UINT8 *source, unsigned length, void (*drawcolfunc)(void));
// ----------------
// SPRITE RENDERING

View file

@ -72,11 +72,6 @@ consvar_t cv_scr_width_w = CVAR_INIT ("scr_width_w", "640", CV_SAVE, CV_Unsigned
consvar_t cv_scr_height_w = CVAR_INIT ("scr_height_w", "400", CV_SAVE, CV_Unsigned, NULL);
consvar_t cv_scr_depth = CVAR_INIT ("scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL);
consvar_t cv_renderview = CVAR_INIT ("renderview", "On", 0, CV_OnOff, NULL);
consvar_t cv_renderwalls = CVAR_INIT ("renderwalls", "On", CV_NOTINNET|CV_CHEAT, CV_OnOff, NULL);
consvar_t cv_renderfloors = CVAR_INIT ("renderfloors", "On", CV_NOTINNET|CV_CHEAT, CV_OnOff, NULL);
consvar_t cv_renderthings = CVAR_INIT ("renderthings", "On", CV_NOTINNET|CV_CHEAT, CV_OnOff, NULL);
CV_PossibleValue_t cv_renderer_t[] = {
{1, "Software"},
#ifdef HWRENDER

View file

@ -157,9 +157,7 @@ extern CV_PossibleValue_t cv_renderer_t[];
extern INT32 scr_bpp;
extern consvar_t cv_scr_width, cv_scr_height, cv_scr_width_w, cv_scr_height_w, cv_scr_depth, cv_fullscreen;
extern consvar_t cv_renderwalls, cv_renderfloors, cv_renderthings;
extern consvar_t cv_renderview, cv_renderer;
extern consvar_t cv_renderhitbox, cv_renderhitboxinterpolation, cv_renderhitboxgldepth;
extern consvar_t cv_renderer;
// wait for page flipping to end or not
extern consvar_t cv_vidwait;
extern consvar_t cv_timescale;