Skip to content
Snippets Groups Projects
Commit 0952d313 authored by sphere's avatar sphere
Browse files

Merge branch 'fix-1x1-floorsprite-draw' into 'next'

Fix floorsprite rendering with 1x1 images

Closes #1052

See merge request !2141
parents 0f914a4e 27021d29
Branches
Tags
No related merge requests found
...@@ -314,9 +314,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr ...@@ -314,9 +314,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
fixed_t planeheight = 0; fixed_t planeheight = 0;
fixed_t step; fixed_t step;
int spanfunctype = SPANDRAWFUNC_SPRITE; int spanfunctype;
prepare_rastertab();
#define RASTERPARAMS(vnum1, vnum2, tv1, tv2, tc, dir) \ #define RASTERPARAMS(vnum1, vnum2, tv1, tv2, tc, dir) \
x1 = verts[vnum1].x; \ x1 = verts[vnum1].x; \
...@@ -367,21 +365,15 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr ...@@ -367,21 +365,15 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
if (ry1 > maxy) \ if (ry1 > maxy) \
maxy = ry1; maxy = ry1;
// do segment a -> top of texture
RASTERPARAMS(3,2,0,pSplat->width-1,0,0);
// do segment b -> right side of texture
RASTERPARAMS(2,1,0,pSplat->width-1,pSplat->height-1,0);
// do segment c -> bottom of texture
RASTERPARAMS(1,0,pSplat->width-1,0,pSplat->height-1,0);
// do segment d -> left side of texture
RASTERPARAMS(0,3,pSplat->width-1,0,0,1);
ds_source = (UINT8 *)pSplat->pic; ds_source = (UINT8 *)pSplat->pic;
ds_flatwidth = pSplat->width; ds_flatwidth = pSplat->width;
ds_flatheight = pSplat->height; ds_flatheight = pSplat->height;
ds_powersoftwo = false;
if (R_CheckPowersOfTwo()) ds_powersoftwo = ds_solidcolor = false;
if (R_CheckSolidColorFlat())
ds_solidcolor = true;
else if (R_CheckPowersOfTwo())
{ {
R_SetFlatVars(ds_flatwidth * ds_flatheight); R_SetFlatVars(ds_flatwidth * ds_flatheight);
ds_powersoftwo = true; ds_powersoftwo = true;
...@@ -392,9 +384,8 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr ...@@ -392,9 +384,8 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
R_SetTiltedSpan(0); R_SetTiltedSpan(0);
R_SetScaledSlopePlane(pSplat->slope, vis->viewpoint.x, vis->viewpoint.y, vis->viewpoint.z, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewpoint.angle, pSplat->angle); R_SetScaledSlopePlane(pSplat->slope, vis->viewpoint.x, vis->viewpoint.y, vis->viewpoint.z, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewpoint.angle, pSplat->angle);
R_CalculateSlopeVectors(); R_CalculateSlopeVectors();
spanfunctype = SPANDRAWFUNC_TILTEDSPRITE;
} }
else else if (!ds_solidcolor)
{ {
planeheight = abs(pSplat->z - vis->viewpoint.z); planeheight = abs(pSplat->z - vis->viewpoint.z);
...@@ -429,23 +420,70 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr ...@@ -429,23 +420,70 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps]; ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps];
} }
if (vis->transmap) ds_transmap = vis->transmap;
// Determine which R_DrawWhatever to use
// Solid color
if (ds_solidcolor)
{ {
ds_transmap = vis->transmap; UINT16 px = *(UINT16 *)ds_source;
// Uh, it's not visible.
if (!(px & 0xFF00))
return;
// Pixel color is contained in the lower 8 bits (upper 8 are the opacity), so advance the pointer
ds_source++;
if (pSplat->slope)
{
if (ds_transmap)
spanfunctype = SPANDRAWFUNC_TILTEDTRANSSOLID;
else
spanfunctype = SPANDRAWFUNC_TILTEDSOLID;
}
else
{
if (ds_transmap)
spanfunctype = SPANDRAWFUNC_TRANSSOLID;
else
spanfunctype = SPANDRAWFUNC_SOLID;
}
}
// Transparent
else if (ds_transmap)
{
if (pSplat->slope) if (pSplat->slope)
spanfunctype = SPANDRAWFUNC_TILTEDTRANSSPRITE; spanfunctype = SPANDRAWFUNC_TILTEDTRANSSPRITE;
else else
spanfunctype = SPANDRAWFUNC_TRANSSPRITE; spanfunctype = SPANDRAWFUNC_TRANSSPRITE;
} }
// Opaque
else else
ds_transmap = NULL; {
if (pSplat->slope)
spanfunctype = SPANDRAWFUNC_TILTEDSPRITE;
else
spanfunctype = SPANDRAWFUNC_SPRITE;
}
if (ds_powersoftwo) if (ds_powersoftwo || ds_solidcolor)
spanfunc = spanfuncs[spanfunctype]; spanfunc = spanfuncs[spanfunctype];
else else
spanfunc = spanfuncs_npo2[spanfunctype]; spanfunc = spanfuncs_npo2[spanfunctype];
prepare_rastertab();
// do segment a -> top of texture
RASTERPARAMS(3,2,0,pSplat->width-1,0,0);
// do segment b -> right side of texture
RASTERPARAMS(2,1,0,pSplat->width-1,pSplat->height-1,0);
// do segment c -> bottom of texture
RASTERPARAMS(1,0,pSplat->width-1,0,pSplat->height-1,0);
// do segment d -> left side of texture
RASTERPARAMS(0,3,pSplat->width-1,0,0,1);
if (maxy >= vid.height) if (maxy >= vid.height)
maxy = vid.height-1; maxy = vid.height-1;
...@@ -500,7 +538,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr ...@@ -500,7 +538,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
if (x2 < x1) if (x2 < x1)
continue; continue;
if (!pSplat->slope) if (!ds_solidcolor && !pSplat->slope)
{ {
fixed_t xstep, ystep; fixed_t xstep, ystep;
fixed_t distance, span; fixed_t distance, span;
...@@ -549,7 +587,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr ...@@ -549,7 +587,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
rastertab[y].maxx = INT32_MIN; rastertab[y].maxx = INT32_MIN;
} }
if (pSplat->angle && !pSplat->slope) if (!ds_solidcolor && pSplat->angle && !pSplat->slope)
memset(cachedheight, 0, sizeof(cachedheight)); memset(cachedheight, 0, sizeof(cachedheight));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment