mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-26 13:10:59 +00:00
- Restore the original Doom algorithm for calculating xtoviewangle[] for the inner 90 degrees
of the field of vision, since it reduces the chances of duplicate sky columns output next to each other compared to a straight tangent-to-angle calculation. SVN r3189 (trunk)
This commit is contained in:
parent
fd225e168c
commit
65977c2d0c
1 changed files with 48 additions and 11 deletions
|
@ -425,6 +425,31 @@ void R_InitTables (void)
|
||||||
memcpy (&finesine[FINEANGLES], &finesine[0], sizeof(angle_t)*FINEANGLES/4);
|
memcpy (&finesine[FINEANGLES], &finesine[0], sizeof(angle_t)*FINEANGLES/4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// viewangletox
|
||||||
|
//
|
||||||
|
// Used solely for construction the xtoviewangle table.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
static inline int viewangletox(int i)
|
||||||
|
{
|
||||||
|
if (finetangent[i] > FRACUNIT*2)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (finetangent[i] < -FRACUNIT*2)
|
||||||
|
{
|
||||||
|
return viewwidth+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int t = FixedMul(finetangent[i], FocalLengthX);
|
||||||
|
t = (centerxfrac - t + FRACUNIT-1) >> FRACBITS;
|
||||||
|
return clamp(t, -1, viewwidth+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
@ -434,8 +459,7 @@ void R_InitTables (void)
|
||||||
|
|
||||||
void R_InitTextureMapping ()
|
void R_InitTextureMapping ()
|
||||||
{
|
{
|
||||||
int i;
|
int i, x;
|
||||||
fixed_t slope;
|
|
||||||
int fov = FieldOfView;
|
int fov = FieldOfView;
|
||||||
|
|
||||||
// For widescreen displays, increase the FOV so that the middle part of the
|
// For widescreen displays, increase the FOV so that the middle part of the
|
||||||
|
@ -464,24 +488,37 @@ void R_InitTextureMapping ()
|
||||||
// This is 1/FocalTangent before the widescreen extension of FOV.
|
// This is 1/FocalTangent before the widescreen extension of FOV.
|
||||||
viewingrangerecip = DivScale32(1, finetangent[FINEANGLES/4+(FieldOfView/2)]);
|
viewingrangerecip = DivScale32(1, finetangent[FINEANGLES/4+(FieldOfView/2)]);
|
||||||
|
|
||||||
// Now generate xtoviewangle for sky texture mapping.
|
|
||||||
// [RH] Do not generate viewangletox, because texture mapping is no
|
// [RH] Do not generate viewangletox, because texture mapping is no
|
||||||
// longer done with trig, so it's not needed.
|
// longer done with trig, so it's not needed.
|
||||||
const int t = MIN<int> ((FocalLengthX >> FRACBITS) + centerx, viewwidth);
|
|
||||||
const fixed_t slopestep = hitan / centerx;
|
// Now generate xtoviewangle for sky texture mapping.
|
||||||
|
// We do this with a hybrid approach: The center 90 degree span is
|
||||||
|
// constructed as per the original code:
|
||||||
|
// Scan xtoviewangle to find the smallest view angle that maps to x.
|
||||||
|
// (viewangletox is sorted in non-increasing order.)
|
||||||
|
// This reduces the chances of "doubling-up" of texture columns in
|
||||||
|
// the drawn sky texture.
|
||||||
|
// The remaining arcs are done with tantoangle instead.
|
||||||
|
|
||||||
|
const int t1 = MAX<int>(centerx - (FocalLengthX >> FRACBITS), 0);
|
||||||
|
const int t2 = MIN<int>(centerx + (FocalLengthX >> FRACBITS), viewwidth);
|
||||||
const fixed_t dfocus = FocalLengthX >> DBITS;
|
const fixed_t dfocus = FocalLengthX >> DBITS;
|
||||||
|
|
||||||
for (i = centerx, slope = 0; i <= t; i++, slope += slopestep)
|
for (i = 0, x = t2; x >= t1; --x)
|
||||||
{
|
{
|
||||||
xtoviewangle[i] = (angle_t)-(signed)tantoangle[slope >> DBITS];
|
while(viewangletox(i) > x)
|
||||||
|
{
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
for (; i <= viewwidth; i++)
|
xtoviewangle[x] = (i << ANGLETOFINESHIFT) - ANGLE_90;
|
||||||
{
|
|
||||||
xtoviewangle[i] = ANG270+tantoangle[dfocus / (i - centerx)];
|
|
||||||
}
|
}
|
||||||
for (i = 0; i < centerx; i++)
|
for (x = t2 + 1; x <= viewwidth; ++x)
|
||||||
{
|
{
|
||||||
xtoviewangle[i] = (angle_t)(-(signed)xtoviewangle[viewwidth-i]);
|
xtoviewangle[x] = ANGLE_270 + tantoangle[dfocus / (x - centerx)];
|
||||||
|
}
|
||||||
|
for (x = 0; x < t1; ++x)
|
||||||
|
{
|
||||||
|
xtoviewangle[x] = (angle_t)(-(signed)xtoviewangle[viewwidth - x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue