ca2107f8a3
- wiggle fix now also fixes flats/floors
This commit is contained in:
twinaphex 2019-07-28 18:13:28 +02:00
parent 51ea3fa8e8
commit 1f49908a6f
3 changed files with 40 additions and 17 deletions

View File

@ -78,6 +78,7 @@ angle_t viewangle;
angle_t viewpitch;
fixed_t viewcos, viewsin;
player_t *viewplayer;
float viewfocratio; /*e6y: for more precise flat drawing */
fixed_t focallength;
int fieldofview;
fixed_t freelookviewheight;
@ -441,6 +442,8 @@ void R_ExecuteSetViewSize (void)
// proff 11/06/98: Added for high-res
projectiony = ((SCREENHEIGHT * centerx * 320) / 200) / SCREENWIDTH * FRACUNIT;
/* e6y: this is a precalculated value for more precise flats drawing (see R_MapPlane) */
viewfocratio = 1.6f / ((float)SCREENWIDTH / (float)SCREENHEIGHT);
R_InitBuffer (scaledviewwidth, viewheight);
R_InitTextureMapping();

View File

@ -52,9 +52,9 @@ extern fixed_t centeryfrac;
extern fixed_t viewheightfrac; //e6y: for correct clipping of things
extern fixed_t freelookviewheight;
extern fixed_t projection;
// proff 11/06/98: Added for high-res
extern fixed_t projectiony;
extern fixed_t projectiony; /* proff 11/06/98: Added for high-res */
extern int validcount;
extern float viewfocratio; /* e6y: for more precise flat drawing */
extern fixed_t skyiscale;
//

View File

@ -104,6 +104,9 @@ static fixed_t xoffs,yoffs; // killough 2/28/98: flat offsets
fixed_t yslope[MAX_SCREENHEIGHT], distscale[MAX_SCREENWIDTH];
/* forward declarations */
extern boolean r_wiggle_fix;
//
// R_InitPlanes
// Only at game startup.
@ -134,27 +137,44 @@ static void R_MapPlane(int y, int x1, int x2, draw_span_vars_t *dsvars)
fixed_t distance, length;
unsigned index;
if (planeheight != cachedheight[y])
if (!r_wiggle_fix)
{
cachedheight[y] = planeheight;
distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]);
dsvars->xstep = cachedxstep[y] = FixedMul (distance,basexscale);
dsvars->ystep = cachedystep[y] = FixedMul (distance,baseyscale);
if (planeheight != cachedheight[y])
{
cachedheight[y] = planeheight;
distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]);
dsvars->xstep = cachedxstep[y] = FixedMul (distance,basexscale);
dsvars->ystep = cachedystep[y] = FixedMul (distance,baseyscale);
}
else
{
distance = cacheddistance[y];
dsvars->xstep = cachedxstep[y];
dsvars->ystep = cachedystep[y];
}
length = FixedMul (distance,distscale[x1]);
angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
// killough 2/28/98: Add offsets
dsvars->xfrac = viewx + FixedMul(finecosine[angle], length) + xoffs;
dsvars->yfrac = -viewy - FixedMul(finesine[angle], length) + yoffs;
}
else
{
distance = cacheddistance[y];
dsvars->xstep = cachedxstep[y];
dsvars->ystep = cachedystep[y];
float slope, realy;
distance = FixedMul (planeheight, yslope[y]);
slope = (float)(planeheight / 65535.0f / D_abs(centery - y));
realy = (float)distance / 65536.0f;
dsvars->xstep = (unsigned int)(viewsin * slope * viewfocratio);
dsvars->ystep = (unsigned int)(viewcos * slope * viewfocratio);
dsvars->xfrac = viewx + xoffs + (int)(viewcos * realy) + (x1 - centerx) * dsvars->xstep;
dsvars->yfrac = -viewy + yoffs - (int)(viewsin * realy) + (x1 - centerx) * dsvars->ystep;
}
length = FixedMul (distance,distscale[x1]);
angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT;
// killough 2/28/98: Add offsets
dsvars->xfrac = viewx + FixedMul(finecosine[angle], length) + xoffs;
dsvars->yfrac = -viewy - FixedMul(finesine[angle], length) + yoffs;
if (drawvars.filterfloor == RDRAW_FILTER_LINEAR) {
dsvars->xfrac -= (FRACUNIT>>1);
dsvars->yfrac -= (FRACUNIT>>1);