mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-02 08:52:12 +00:00
Sloped plane adjustments
This commit is contained in:
parent
cc10c2a970
commit
e31331bed2
2 changed files with 14 additions and 116 deletions
|
@ -2325,7 +2325,7 @@ void R_InitColumnDrawers ()
|
|||
R_FillColumnHoriz = R_FillColumnHorizP_RGBA_C;
|
||||
|
||||
R_DrawFogBoundary = R_DrawFogBoundary_RGBA;
|
||||
R_MapTiltedPlane = R_MapColoredPlane_RGBA;
|
||||
R_MapTiltedPlane = R_MapTiltedPlane_RGBA;
|
||||
R_MapColoredPlane = R_MapColoredPlane_RGBA;
|
||||
R_DrawParticle = R_DrawParticle_RGBA;
|
||||
|
||||
|
@ -2422,7 +2422,7 @@ void R_InitColumnDrawers ()
|
|||
R_FillColumnHoriz = R_FillColumnHorizP_C;
|
||||
|
||||
R_DrawFogBoundary = R_DrawFogBoundary_C;
|
||||
R_MapTiltedPlane = R_MapColoredPlane_C;
|
||||
R_MapTiltedPlane = R_MapTiltedPlane_C;
|
||||
R_MapColoredPlane = R_MapColoredPlane_C;
|
||||
R_DrawParticle = R_DrawParticle_C;
|
||||
|
||||
|
|
126
src/r_plane.cpp
126
src/r_plane.cpp
|
@ -480,124 +480,22 @@ void R_MapTiltedPlane_C (int y, int x1)
|
|||
void R_MapTiltedPlane_RGBA (int y, int x1)
|
||||
{
|
||||
int x2 = spanend[y];
|
||||
int width = x2 - x1;
|
||||
double iz, uz, vz;
|
||||
uint32_t *fb;
|
||||
DWORD u, v;
|
||||
int i;
|
||||
|
||||
iz = plane_sz[2] + plane_sz[1]*(centery-y) + plane_sz[0]*(x1-centerx);
|
||||
// Slopes are broken currently in master.
|
||||
// Until R_DrawTiltedPlane is fixed we are just going to fill with a solid color.
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
if (plane_shade)
|
||||
uint32_t *source = (uint32_t*)ds_source;
|
||||
int source_width = 1 << ds_xbits;
|
||||
int source_height = 1 << ds_ybits;
|
||||
|
||||
uint32_t *dest = ylookup[y] + x1 + (uint32_t*)dc_destorg;
|
||||
|
||||
int count = x2 - x1 + 1;
|
||||
while (count > 0)
|
||||
{
|
||||
uz = (iz + plane_sz[0]*width) * planelightfloat;
|
||||
vz = iz * planelightfloat;
|
||||
R_CalcTiltedLighting (vz, uz, width);
|
||||
*(dest++) = source[0];
|
||||
count--;
|
||||
}
|
||||
|
||||
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
|
||||
vz = plane_sv[2] + plane_sv[1]*(centery-y) + plane_sv[0]*(x1-centerx);
|
||||
|
||||
fb = ylookup[y] + x1 + (uint32_t*)dc_destorg;
|
||||
|
||||
BYTE vshift = 32 - ds_ybits;
|
||||
BYTE ushift = vshift - ds_xbits;
|
||||
int umask = ((1 << ds_xbits) - 1) << ds_ybits;
|
||||
|
||||
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
||||
// Use it only to see how things are supposed to look.
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
double z = 1.f/iz;
|
||||
|
||||
u = SQWORD(uz*z) + pviewx;
|
||||
v = SQWORD(vz*z) + pviewy;
|
||||
R_SetDSColorMapLight(tiltlighting[i], 0, 0);
|
||||
fb[i++] = ds_colormap[ds_source[(v >> vshift) | ((u >> ushift) & umask)]];
|
||||
iz += plane_sz[0];
|
||||
uz += plane_su[0];
|
||||
vz += plane_sv[0];
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
//#define SPANSIZE 32
|
||||
//#define INVSPAN 0.03125f
|
||||
//#define SPANSIZE 8
|
||||
//#define INVSPAN 0.125f
|
||||
#define SPANSIZE 16
|
||||
#define INVSPAN 0.0625f
|
||||
|
||||
double startz = 1.f/iz;
|
||||
double startu = uz*startz;
|
||||
double startv = vz*startz;
|
||||
double izstep, uzstep, vzstep;
|
||||
|
||||
izstep = plane_sz[0] * SPANSIZE;
|
||||
uzstep = plane_su[0] * SPANSIZE;
|
||||
vzstep = plane_sv[0] * SPANSIZE;
|
||||
x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
{
|
||||
iz += izstep;
|
||||
uz += uzstep;
|
||||
vz += vzstep;
|
||||
|
||||
double endz = 1.f/iz;
|
||||
double endu = uz*endz;
|
||||
double endv = vz*endz;
|
||||
DWORD stepu = SQWORD((endu - startu) * INVSPAN);
|
||||
DWORD stepv = SQWORD((endv - startv) * INVSPAN);
|
||||
u = SQWORD(startu) + pviewx;
|
||||
v = SQWORD(startv) + pviewy;
|
||||
|
||||
for (i = SPANSIZE-1; i >= 0; i--)
|
||||
{
|
||||
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
|
||||
x1++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
startu = endu;
|
||||
startv = endv;
|
||||
width -= SPANSIZE;
|
||||
}
|
||||
if (width > 0)
|
||||
{
|
||||
if (width == 1)
|
||||
{
|
||||
u = SQWORD(startu);
|
||||
v = SQWORD(startv);
|
||||
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += plane_sz[0] * left;
|
||||
uz += plane_su[0] * left;
|
||||
vz += plane_sv[0] * left;
|
||||
|
||||
double endz = 1.f/iz;
|
||||
double endu = uz*endz;
|
||||
double endv = vz*endz;
|
||||
left = 1.f/left;
|
||||
DWORD stepu = SQWORD((endu - startu) * left);
|
||||
DWORD stepv = SQWORD((endv - startv) * left);
|
||||
u = SQWORD(startu) + pviewx;
|
||||
v = SQWORD(startv) + pviewy;
|
||||
|
||||
for (; width != 0; width--)
|
||||
{
|
||||
fb[x1] = *(tiltlighting[x1] + ds_source[(v >> vshift) | ((u >> ushift) & umask)]);
|
||||
x1++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue