mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-22 04:21:23 +00:00
Fix #1158
This commit is contained in:
parent
7893d08407
commit
6a4b26a04c
8 changed files with 271 additions and 295 deletions
19
src/r_draw.c
19
src/r_draw.c
|
@ -106,14 +106,13 @@ fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
|
|||
INT32 ds_waterofs, ds_bgofs;
|
||||
|
||||
UINT16 ds_flatwidth, ds_flatheight;
|
||||
boolean ds_powersoftwo, ds_solidcolor;
|
||||
boolean ds_powersoftwo, ds_solidcolor, ds_fog;
|
||||
|
||||
UINT8 *ds_source; // points to the start of a flat
|
||||
UINT8 *ds_transmap; // one of the translucency tables
|
||||
|
||||
// Vectors for Software's tilted slope drawers
|
||||
floatv3_t *ds_su, *ds_sv, *ds_sz;
|
||||
floatv3_t *ds_sup, *ds_svp, *ds_szp;
|
||||
floatv3_t ds_su, ds_sv, ds_sz, ds_slopelight;
|
||||
float focallengthf, zeroheight;
|
||||
|
||||
/** \brief Variable flat sizes
|
||||
|
@ -906,13 +905,15 @@ static void R_CalcTiltedLighting(fixed_t start, fixed_t end)
|
|||
}
|
||||
}
|
||||
|
||||
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan))
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
#define CALC_SLOPE_LIGHT { \
|
||||
float planelightfloat = PLANELIGHTFLOAT; \
|
||||
float lightstart, lightend; \
|
||||
lightend = (iz + ds_szp->x*width) * planelightfloat; \
|
||||
lightstart = iz * planelightfloat; \
|
||||
R_CalcTiltedLighting(FloatToFixed(lightstart), FloatToFixed(lightend)); \
|
||||
static void R_CalcSlopeLight(void)
|
||||
{
|
||||
float iz = ds_slopelight.z + ds_slopelight.y * (centery - ds_y) + ds_slopelight.x * (ds_x1 - centerx);
|
||||
float lightstart = iz * PLANELIGHTFLOAT;
|
||||
float lightend = (iz + ds_slopelight.x * (ds_x2 - ds_x1)) * PLANELIGHTFLOAT;
|
||||
R_CalcTiltedLighting(FloatToFixed(lightstart), FloatToFixed(lightend));
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
|
|
|
@ -61,7 +61,7 @@ extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
|
|||
extern INT32 ds_waterofs, ds_bgofs;
|
||||
|
||||
extern UINT16 ds_flatwidth, ds_flatheight;
|
||||
extern boolean ds_powersoftwo, ds_solidcolor;
|
||||
extern boolean ds_powersoftwo, ds_solidcolor, ds_fog;
|
||||
|
||||
extern UINT8 *ds_source;
|
||||
extern UINT8 *ds_transmap;
|
||||
|
@ -71,8 +71,7 @@ typedef struct {
|
|||
} floatv3_t;
|
||||
|
||||
// Vectors for Software's tilted slope drawers
|
||||
extern floatv3_t *ds_su, *ds_sv, *ds_sz;
|
||||
extern floatv3_t *ds_sup, *ds_svp, *ds_szp;
|
||||
extern floatv3_t ds_su, ds_sv, ds_sz, ds_slopelight;
|
||||
extern float focallengthf, zeroheight;
|
||||
|
||||
// Variable flat sizes
|
||||
|
@ -178,8 +177,6 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void);
|
|||
void R_DrawFogColumn_8(void);
|
||||
void R_DrawColumnShadowed_8(void);
|
||||
|
||||
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / zeroheight / 21.0f * FIXED_TO_FLOAT(fovtan))
|
||||
|
||||
void R_DrawSpan_8(void);
|
||||
void R_DrawTranslucentSpan_8(void);
|
||||
void R_DrawTiltedSpan_8(void);
|
||||
|
|
160
src/r_draw8.c
160
src/r_draw8.c
|
@ -676,12 +676,11 @@ void R_DrawTiltedSpan_8(void)
|
|||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = ds_source;
|
||||
|
@ -700,18 +699,18 @@ void R_DrawTiltedSpan_8(void)
|
|||
|
||||
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -753,9 +752,9 @@ void R_DrawTiltedSpan_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -799,12 +798,11 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
|||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = ds_source;
|
||||
|
@ -822,18 +820,18 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
|||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest);
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -875,9 +873,9 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -922,12 +920,11 @@ void R_DrawTiltedWaterSpan_8(void)
|
|||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||
|
@ -946,18 +943,18 @@ void R_DrawTiltedWaterSpan_8(void)
|
|||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++);
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -999,9 +996,9 @@ void R_DrawTiltedWaterSpan_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -1044,12 +1041,11 @@ void R_DrawTiltedSplat_8(void)
|
|||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = ds_source;
|
||||
|
@ -1071,18 +1067,18 @@ void R_DrawTiltedSplat_8(void)
|
|||
*dest = colormap[val];
|
||||
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -1128,9 +1124,9 @@ void R_DrawTiltedSplat_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -1613,9 +1609,9 @@ void R_DrawTiltedFloorSprite_8(void)
|
|||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = (UINT16 *)ds_source;
|
||||
|
@ -1626,9 +1622,9 @@ void R_DrawTiltedFloorSprite_8(void)
|
|||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -1673,9 +1669,9 @@ void R_DrawTiltedFloorSprite_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -1722,9 +1718,9 @@ void R_DrawTiltedTranslucentFloorSprite_8(void)
|
|||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = (UINT16 *)ds_source;
|
||||
|
@ -1735,9 +1731,9 @@ void R_DrawTiltedTranslucentFloorSprite_8(void)
|
|||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -1782,9 +1778,9 @@ void R_DrawTiltedTranslucentFloorSprite_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -2013,9 +2009,7 @@ void R_DrawTiltedFogSpan_8(void)
|
|||
|
||||
UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
|
||||
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
R_CalcSlopeLight();
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -2067,9 +2061,7 @@ void R_DrawTiltedSolidColorSpan_8(void)
|
|||
UINT8 source = ds_source[0];
|
||||
UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
|
||||
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
R_CalcSlopeLight();
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -2088,9 +2080,7 @@ void R_DrawTiltedTransSolidColorSpan_8(void)
|
|||
UINT8 source = ds_source[0];
|
||||
UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
|
||||
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
R_CalcSlopeLight();
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -2131,9 +2121,7 @@ void R_DrawTiltedWaterSolidColorSpan_8(void)
|
|||
UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
UINT8 *dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||
|
||||
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
R_CalcSlopeLight();
|
||||
|
||||
do
|
||||
{
|
||||
|
|
|
@ -114,12 +114,11 @@ void R_DrawTiltedSpan_NPO2_8(void)
|
|||
struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth);
|
||||
struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight);
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = ds_source;
|
||||
|
@ -154,18 +153,18 @@ void R_DrawTiltedSpan_NPO2_8(void)
|
|||
*dest = colormap[source[((y * ds_flatwidth) + x)]];
|
||||
}
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -239,9 +238,9 @@ void R_DrawTiltedSpan_NPO2_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -304,12 +303,11 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
|
|||
struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth);
|
||||
struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight);
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = ds_source;
|
||||
|
@ -343,18 +341,18 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
|
|||
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest);
|
||||
}
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -428,9 +426,9 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -492,12 +490,11 @@ void R_DrawTiltedSplat_NPO2_8(void)
|
|||
struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth);
|
||||
struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight);
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = ds_source;
|
||||
|
@ -536,18 +533,18 @@ void R_DrawTiltedSplat_NPO2_8(void)
|
|||
*dest = colormap[val];
|
||||
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -625,9 +622,9 @@ void R_DrawTiltedSplat_NPO2_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -970,9 +967,9 @@ void R_DrawTiltedFloorSprite_NPO2_8(void)
|
|||
struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth);
|
||||
struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight);
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = (UINT16 *)ds_source;
|
||||
|
@ -983,9 +980,9 @@ void R_DrawTiltedFloorSprite_NPO2_8(void)
|
|||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -1060,9 +1057,9 @@ void R_DrawTiltedFloorSprite_NPO2_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -1126,9 +1123,9 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void)
|
|||
struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth);
|
||||
struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight);
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
source = (UINT16 *)ds_source;
|
||||
|
@ -1139,9 +1136,9 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void)
|
|||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -1216,9 +1213,9 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
@ -1411,12 +1408,11 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
|
|||
struct libdivide_u32_t x_divider = libdivide_u32_gen(ds_flatwidth);
|
||||
struct libdivide_u32_t y_divider = libdivide_u32_gen(ds_flatheight);
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
||||
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
||||
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
||||
|
||||
CALC_SLOPE_LIGHT
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
R_CalcSlopeLight();
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||
|
@ -1451,18 +1447,18 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
|
|||
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
|
||||
}
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
iz += ds_sz.x;
|
||||
uz += ds_su.x;
|
||||
vz += ds_sv.x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
izstep = ds_sz.x * SPANSIZE;
|
||||
uzstep = ds_su.x * SPANSIZE;
|
||||
vzstep = ds_sv.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
|
@ -1536,9 +1532,9 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
|
|||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
iz += ds_sz.x * left;
|
||||
uz += ds_su.x * left;
|
||||
vz += ds_sv.x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
|
|
13
src/r_main.c
13
src/r_main.c
|
@ -957,16 +957,6 @@ void R_ExecuteSetViewSize(void)
|
|||
dy = FixedMul(abs(dy), fovtan);
|
||||
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
|
||||
}
|
||||
|
||||
if (ds_su)
|
||||
Z_Free(ds_su);
|
||||
if (ds_sv)
|
||||
Z_Free(ds_sv);
|
||||
if (ds_sz)
|
||||
Z_Free(ds_sz);
|
||||
|
||||
ds_su = ds_sv = ds_sz = NULL;
|
||||
ds_sup = ds_svp = ds_szp = NULL;
|
||||
}
|
||||
|
||||
memset(scalelight, 0xFF, sizeof(scalelight));
|
||||
|
@ -1012,9 +1002,6 @@ void R_Init(void)
|
|||
R_InitViewBorder();
|
||||
R_SetViewSize(); // setsizeneeded is set true
|
||||
|
||||
//I_OutputMsg("\nR_InitPlanes");
|
||||
R_InitPlanes();
|
||||
|
||||
// this is now done by SCR_Recalc() at the first mode set
|
||||
//I_OutputMsg("\nR_InitLightTables");
|
||||
R_InitLightTables();
|
||||
|
|
216
src/r_plane.c
216
src/r_plane.c
|
@ -84,16 +84,14 @@ fixed_t yslopetab[MAXVIDHEIGHT*16];
|
|||
fixed_t *yslope;
|
||||
|
||||
static fixed_t xoffs, yoffs;
|
||||
static floatv3_t ds_slope_origin, ds_slope_u, ds_slope_v;
|
||||
static floatv3_t slope_origin, slope_u, slope_v;
|
||||
static floatv3_t slope_lightu, slope_lightv;
|
||||
|
||||
//
|
||||
// R_InitPlanes
|
||||
// Only at game startup.
|
||||
//
|
||||
void R_InitPlanes(void)
|
||||
{
|
||||
// FIXME: unused
|
||||
}
|
||||
static void CalcSlopePlaneVectors(visplane_t *pl, fixed_t xoff, fixed_t yoff);
|
||||
static void CalcSlopeLightVectors(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t height, float ang, angle_t plangle);
|
||||
|
||||
static void DoSlopeCrossProducts(void);
|
||||
static void DoSlopeLightCrossProduct(void);
|
||||
|
||||
//
|
||||
// Water ripple effect
|
||||
|
@ -224,9 +222,9 @@ static void R_MapTiltedPlane(INT32 y, INT32 x1, INT32 x2)
|
|||
{
|
||||
ds_bgofs = R_CalculateRippleOffset(y);
|
||||
|
||||
ds_sup = &ds_su[y];
|
||||
ds_svp = &ds_sv[y];
|
||||
ds_szp = &ds_sz[y];
|
||||
R_CalculatePlaneRipple(currentplane->viewangle + currentplane->plangle);
|
||||
|
||||
CalcSlopePlaneVectors(currentplane, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac));
|
||||
|
||||
ds_bgofs >>= FRACBITS;
|
||||
|
||||
|
@ -672,8 +670,6 @@ static INT64 R_GetSlopeZAt(const pslope_t *slope, fixed_t x, fixed_t y)
|
|||
// Sets the texture origin vector of the sloped plane.
|
||||
static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, fixed_t angle)
|
||||
{
|
||||
floatv3_t *p = &ds_slope_origin;
|
||||
|
||||
INT64 vx = (INT64)xpos + (INT64)xoff;
|
||||
INT64 vy = (INT64)ypos - (INT64)yoff;
|
||||
|
||||
|
@ -681,125 +677,157 @@ static void R_SetSlopePlaneOrigin(pslope_t *slope, fixed_t xpos, fixed_t ypos, f
|
|||
float vyf = vy / (float)FRACUNIT;
|
||||
float ang = ANG2RAD(ANGLE_270 - angle);
|
||||
|
||||
// p is the texture origin in view space
|
||||
// slope_origin is the texture origin in view space
|
||||
// Don't add in the offsets at this stage, because doing so can result in
|
||||
// errors if the flat is rotated.
|
||||
p->x = vxf * cos(ang) - vyf * sin(ang);
|
||||
p->z = vxf * sin(ang) + vyf * cos(ang);
|
||||
p->y = (R_GetSlopeZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT;
|
||||
slope_origin.x = vxf * cos(ang) - vyf * sin(ang);
|
||||
slope_origin.z = vxf * sin(ang) + vyf * cos(ang);
|
||||
slope_origin.y = (R_GetSlopeZAt(slope, -xoff, yoff) - zpos) / (float)FRACUNIT;
|
||||
}
|
||||
|
||||
// This function calculates all of the vectors necessary for drawing a sloped plane.
|
||||
void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle)
|
||||
{
|
||||
// Potentially override other stuff for now cus we're mean. :< But draw a slope plane!
|
||||
// I copied ZDoom's code and adapted it to SRB2... -Red
|
||||
floatv3_t *m = &ds_slope_v, *n = &ds_slope_u;
|
||||
fixed_t height, temp;
|
||||
fixed_t height, z_at_xy;
|
||||
float ang;
|
||||
|
||||
R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle);
|
||||
height = P_GetSlopeZAt(slope, xpos, ypos);
|
||||
zeroheight = FixedToFloat(height - zpos);
|
||||
|
||||
// m is the v direction vector in view space
|
||||
ang = ANG2RAD(ANGLE_180 - (angle + plangle));
|
||||
m->x = cos(ang);
|
||||
m->z = sin(ang);
|
||||
|
||||
// n is the u direction vector in view space
|
||||
n->x = sin(ang);
|
||||
n->z = -cos(ang);
|
||||
CalcSlopeLightVectors(slope, xpos, ypos, height, ang, plangle);
|
||||
|
||||
if (ds_solidcolor || ds_fog)
|
||||
{
|
||||
DoSlopeLightCrossProduct();
|
||||
return;
|
||||
}
|
||||
|
||||
// slope_v is the v direction vector in view space
|
||||
slope_v.x = cos(ang);
|
||||
slope_v.z = sin(ang);
|
||||
|
||||
// slope_u is the u direction vector in view space
|
||||
slope_u.x = sin(ang);
|
||||
slope_u.z = -cos(ang);
|
||||
|
||||
plangle >>= ANGLETOFINESHIFT;
|
||||
temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle));
|
||||
m->y = FixedToFloat(temp - height);
|
||||
temp = P_GetSlopeZAt(slope, xpos + FINECOSINE(plangle), ypos - FINESINE(plangle));
|
||||
n->y = FixedToFloat(temp - height);
|
||||
z_at_xy = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle));
|
||||
slope_v.y = FixedToFloat(z_at_xy - height);
|
||||
z_at_xy = P_GetSlopeZAt(slope, xpos + FINECOSINE(plangle), ypos - FINESINE(plangle));
|
||||
slope_u.y = FixedToFloat(z_at_xy - height);
|
||||
|
||||
DoSlopeCrossProducts();
|
||||
DoSlopeLightCrossProduct();
|
||||
}
|
||||
|
||||
// This function calculates all of the vectors necessary for drawing a sloped and scaled plane.
|
||||
void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle)
|
||||
{
|
||||
floatv3_t *m = &ds_slope_v, *n = &ds_slope_u;
|
||||
fixed_t height, temp;
|
||||
fixed_t height, z_at_xy;
|
||||
|
||||
float xscale = FixedToFloat(xs);
|
||||
float yscale = FixedToFloat(ys);
|
||||
float ang;
|
||||
|
||||
R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle);
|
||||
height = P_GetSlopeZAt(slope, xpos, ypos);
|
||||
zeroheight = FixedToFloat(height - zpos);
|
||||
|
||||
// m is the v direction vector in view space
|
||||
ang = ANG2RAD(ANGLE_180 - (angle + plangle));
|
||||
m->x = yscale * cos(ang);
|
||||
m->z = yscale * sin(ang);
|
||||
|
||||
// n is the u direction vector in view space
|
||||
n->x = xscale * sin(ang);
|
||||
n->z = -xscale * cos(ang);
|
||||
CalcSlopeLightVectors(slope, xpos, ypos, height, ang, plangle);
|
||||
|
||||
ang = ANG2RAD(plangle);
|
||||
temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(yscale * sin(ang)), ypos + FloatToFixed(yscale * cos(ang)));
|
||||
m->y = FixedToFloat(temp - height);
|
||||
temp = P_GetSlopeZAt(slope, xpos + FloatToFixed(xscale * cos(ang)), ypos - FloatToFixed(xscale * sin(ang)));
|
||||
n->y = FixedToFloat(temp - height);
|
||||
if (ds_solidcolor || ds_fog)
|
||||
{
|
||||
DoSlopeLightCrossProduct();
|
||||
return;
|
||||
}
|
||||
|
||||
void R_CalculateSlopeVectors(void)
|
||||
float xscale = FixedToFloat(xs);
|
||||
float yscale = FixedToFloat(ys);
|
||||
|
||||
// m is the v direction vector in view space
|
||||
slope_v.x = yscale * cos(ang);
|
||||
slope_v.z = yscale * sin(ang);
|
||||
|
||||
// n is the u direction vector in view space
|
||||
slope_u.x = xscale * sin(ang);
|
||||
slope_u.z = -xscale * cos(ang);
|
||||
|
||||
ang = ANG2RAD(plangle);
|
||||
z_at_xy = P_GetSlopeZAt(slope, xpos + FloatToFixed(yscale * sin(ang)), ypos + FloatToFixed(yscale * cos(ang)));
|
||||
slope_v.y = FixedToFloat(z_at_xy - height);
|
||||
z_at_xy = P_GetSlopeZAt(slope, xpos + FloatToFixed(xscale * cos(ang)), ypos - FloatToFixed(xscale * sin(ang)));
|
||||
slope_u.y = FixedToFloat(z_at_xy - height);
|
||||
|
||||
DoSlopeCrossProducts();
|
||||
DoSlopeLightCrossProduct();
|
||||
}
|
||||
|
||||
static void CalcSlopeLightVectors(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t height, float ang, angle_t plangle)
|
||||
{
|
||||
float sfmult = 65536.f;
|
||||
fixed_t z_at_xy;
|
||||
|
||||
slope_lightv.x = cos(ang);
|
||||
slope_lightv.z = sin(ang);
|
||||
|
||||
slope_lightu.x = sin(ang);
|
||||
slope_lightu.z = -cos(ang);
|
||||
|
||||
plangle >>= ANGLETOFINESHIFT;
|
||||
z_at_xy = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle));
|
||||
slope_lightv.y = FixedToFloat(z_at_xy - height);
|
||||
z_at_xy = P_GetSlopeZAt(slope, xpos + FINECOSINE(plangle), ypos - FINESINE(plangle));
|
||||
slope_lightu.y = FixedToFloat(z_at_xy - height);
|
||||
}
|
||||
|
||||
// Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using.
|
||||
#define CROSS(d, v1, v2) \
|
||||
d->x = (v1.y * v2.z) - (v1.z * v2.y);\
|
||||
d->y = (v1.z * v2.x) - (v1.x * v2.z);\
|
||||
d->z = (v1.x * v2.y) - (v1.y * v2.x)
|
||||
CROSS(ds_sup, ds_slope_origin, ds_slope_v);
|
||||
CROSS(ds_svp, ds_slope_origin, ds_slope_u);
|
||||
CROSS(ds_szp, ds_slope_v, ds_slope_u);
|
||||
#undef CROSS
|
||||
d.x = (v1.y * v2.z) - (v1.z * v2.y);\
|
||||
d.y = (v1.z * v2.x) - (v1.x * v2.z);\
|
||||
d.z = (v1.x * v2.y) - (v1.y * v2.x)
|
||||
|
||||
ds_sup->z *= focallengthf;
|
||||
ds_svp->z *= focallengthf;
|
||||
ds_szp->z *= focallengthf;
|
||||
static void DoSlopeCrossProducts(void)
|
||||
{
|
||||
float sfmult = 65536.f;
|
||||
|
||||
CROSS(ds_su, slope_origin, slope_v);
|
||||
CROSS(ds_sv, slope_origin, slope_u);
|
||||
CROSS(ds_sz, slope_v, slope_u);
|
||||
|
||||
ds_su.z *= focallengthf;
|
||||
ds_sv.z *= focallengthf;
|
||||
ds_sz.z *= focallengthf;
|
||||
|
||||
if (ds_solidcolor)
|
||||
return;
|
||||
|
||||
// Premultiply the texture vectors with the scale factors
|
||||
if (ds_powersoftwo)
|
||||
sfmult *= (1 << nflatshiftup);
|
||||
sfmult *= 1 << nflatshiftup;
|
||||
|
||||
ds_sup->x *= sfmult;
|
||||
ds_sup->y *= sfmult;
|
||||
ds_sup->z *= sfmult;
|
||||
ds_svp->x *= sfmult;
|
||||
ds_svp->y *= sfmult;
|
||||
ds_svp->z *= sfmult;
|
||||
ds_su.x *= sfmult;
|
||||
ds_su.y *= sfmult;
|
||||
ds_su.z *= sfmult;
|
||||
ds_sv.x *= sfmult;
|
||||
ds_sv.y *= sfmult;
|
||||
ds_sv.z *= sfmult;
|
||||
}
|
||||
|
||||
void R_SetTiltedSpan(INT32 span)
|
||||
static void DoSlopeLightCrossProduct(void)
|
||||
{
|
||||
if (ds_su == NULL)
|
||||
ds_su = Z_Malloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL);
|
||||
if (ds_sv == NULL)
|
||||
ds_sv = Z_Malloc(sizeof(*ds_sv) * vid.height, PU_STATIC, NULL);
|
||||
if (ds_sz == NULL)
|
||||
ds_sz = Z_Malloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL);
|
||||
CROSS(ds_slopelight, slope_lightv, slope_lightu);
|
||||
|
||||
ds_sup = &ds_su[span];
|
||||
ds_svp = &ds_sv[span];
|
||||
ds_szp = &ds_sz[span];
|
||||
ds_slopelight.z *= focallengthf;
|
||||
}
|
||||
|
||||
static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff)
|
||||
{
|
||||
R_SetTiltedSpan(y);
|
||||
#undef CROSS
|
||||
|
||||
if (pl->xscale != FRACUNIT || pl->yscale != FRACUNIT)
|
||||
static void CalcSlopePlaneVectors(visplane_t *pl, fixed_t xoff, fixed_t yoff)
|
||||
{
|
||||
if (!ds_fog && (pl->xscale != FRACUNIT || pl->yscale != FRACUNIT))
|
||||
{
|
||||
R_SetScaledSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz,
|
||||
FixedDiv(FRACUNIT, pl->xscale), FixedDiv(FRACUNIT, pl->yscale),
|
||||
|
@ -807,8 +835,6 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_
|
|||
}
|
||||
else
|
||||
R_SetSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz, xoff, yoff, pl->viewangle, pl->plangle);
|
||||
|
||||
R_CalculateSlopeVectors();
|
||||
}
|
||||
|
||||
static inline void R_AdjustSlopeCoordinates(vector3_t *origin)
|
||||
|
@ -845,7 +871,6 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
INT32 light = 0;
|
||||
INT32 x, stop;
|
||||
ffloor_t *rover;
|
||||
boolean fog = false;
|
||||
INT32 spanfunctype = BASEDRAWFUNC;
|
||||
void (*mapfunc)(INT32, INT32, INT32);
|
||||
|
||||
|
@ -859,6 +884,8 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
return;
|
||||
}
|
||||
|
||||
ds_powersoftwo = ds_solidcolor = ds_fog = false;
|
||||
|
||||
planeripple.active = false;
|
||||
|
||||
if (pl->polyobj)
|
||||
|
@ -923,13 +950,13 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
}
|
||||
else if (pl->ffloor->fofflags & FOF_FOG)
|
||||
{
|
||||
fog = true;
|
||||
ds_fog = true;
|
||||
spanfunctype = SPANDRAWFUNC_FOG;
|
||||
light = (pl->lightlevel >> LIGHTSEGSHIFT);
|
||||
}
|
||||
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
|
||||
|
||||
if (pl->ffloor->fofflags & FOF_RIPPLE && !fog)
|
||||
if (pl->ffloor->fofflags & FOF_RIPPLE && !ds_fog)
|
||||
{
|
||||
planeripple.active = true;
|
||||
|
||||
|
@ -957,9 +984,7 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
light = (pl->lightlevel >> LIGHTSEGSHIFT);
|
||||
}
|
||||
|
||||
ds_powersoftwo = ds_solidcolor = false;
|
||||
|
||||
if (fog)
|
||||
if (ds_fog)
|
||||
{
|
||||
// Since all fog planes do is apply a colormap, it's not required
|
||||
// to know any information about their textures.
|
||||
|
@ -1025,7 +1050,7 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
|
||||
if (pl->slope)
|
||||
{
|
||||
if (fog)
|
||||
if (ds_fog)
|
||||
mapfunc = R_MapTiltedFogPlane;
|
||||
else
|
||||
{
|
||||
|
@ -1040,21 +1065,10 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
}
|
||||
}
|
||||
|
||||
if (planeripple.active)
|
||||
{
|
||||
if (!ds_fog && planeripple.active)
|
||||
planeheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz);
|
||||
|
||||
R_PlaneBounds(pl);
|
||||
|
||||
for (x = pl->high; x < pl->low; x++)
|
||||
{
|
||||
ds_bgofs = R_CalculateRippleOffset(x);
|
||||
R_CalculatePlaneRipple(pl->viewangle + pl->plangle);
|
||||
R_SetSlopePlaneVectors(pl, x, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac));
|
||||
}
|
||||
}
|
||||
else
|
||||
R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs);
|
||||
CalcSlopePlaneVectors(pl, xoffs, yoffs);
|
||||
|
||||
switch (spanfunctype)
|
||||
{
|
||||
|
|
|
@ -67,7 +67,6 @@ extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*16];
|
|||
extern fixed_t *yslope;
|
||||
extern lighttable_t **planezlight;
|
||||
|
||||
void R_InitPlanes(void);
|
||||
void R_ClearPlanes(void);
|
||||
void R_ClearFFloorClips (void);
|
||||
|
||||
|
@ -84,10 +83,6 @@ void R_DrawSinglePlane(visplane_t *pl);
|
|||
// Calculates the slope vectors needed for tilted span drawing.
|
||||
void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle);
|
||||
void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle);
|
||||
void R_CalculateSlopeVectors(void);
|
||||
|
||||
// Sets the slope vector pointers for the current tilted span.
|
||||
void R_SetTiltedSpan(INT32 span);
|
||||
|
||||
typedef struct planemgr_s
|
||||
{
|
||||
|
|
|
@ -369,7 +369,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
|
|||
ds_flatwidth = pSplat->width;
|
||||
ds_flatheight = pSplat->height;
|
||||
|
||||
ds_powersoftwo = ds_solidcolor = false;
|
||||
ds_powersoftwo = ds_solidcolor = ds_fog = false;
|
||||
|
||||
if (R_CheckSolidColorFlat())
|
||||
ds_solidcolor = true;
|
||||
|
@ -381,9 +381,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
|
|||
|
||||
if (pSplat->slope)
|
||||
{
|
||||
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_CalculateSlopeVectors();
|
||||
}
|
||||
else if (!ds_solidcolor)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue