Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix skies being shifted down a few pixels compared to Woof 12.0.2 #1608

Merged
merged 5 commits into from
Mar 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static fixed_t centerxfrac_nonwide;
static void R_InitTextureMapping(void)
{
register int i,x;
fixed_t slopefrac;
fixed_t slopefrac, limit;
angle_t fov;
double linearskyfactor;

Expand All @@ -285,13 +285,21 @@ static void R_InitTextureMapping(void)
// Calc focallength
// so FIELDOFVIEW angles covers SCREENWIDTH.

if (custom_fov == FOV_DEFAULT && centerxfrac == centerxfrac_nonwide)
if (custom_fov == FOV_DEFAULT)
{
fov = FIELDOFVIEW;
slopefrac = finetangent[FINEANGLES / 4 + fov / 2];
focallength = FixedDiv(centerxfrac_nonwide, slopefrac);
lightfocallength = centerxfrac_nonwide;
projection = centerxfrac_nonwide;
limit = FRACUNIT * 2;
skyiscale = FixedDiv(SCREENWIDTH, viewwidth_nonwide);

if (centerxfrac != centerxfrac_nonwide)
{
fov = atan((double)centerxfrac / centerxfrac_nonwide) * FINEANGLES / M_PI;
slopefrac = finetangent[FINEANGLES / 4 + fov / 2];
}
}
else
{
Expand All @@ -307,15 +315,17 @@ static void R_InitTextureMapping(void)
slopefrac = finetangent[FINEANGLES / 4 + fov / 2];
focallength = FixedDiv(centerxfrac, slopefrac);
projection = centerxfrac / slope;
limit = slopefrac;
skyiscale = (slope * 160.0 / FIXED2DOUBLE(centerxfrac)) * FRACUNIT;
}

for (i=0 ; i<FINEANGLES/2 ; i++)
{
int t;
if (finetangent[i] > slopefrac)
if (finetangent[i] > limit)
t = -1;
else
if (finetangent[i] < -slopefrac)
if (finetangent[i] < -limit)
t = viewwidth+1;
else
{
Expand Down Expand Up @@ -608,8 +618,6 @@ void R_ExecuteSetViewSize (void)
while (FixedMul(pspriteiscale, pspritescale) < FRACUNIT)
pspriteiscale++;

skyiscale = FixedDiv(160 << FRACBITS, focallength);

for (i=0 ; i<viewwidth ; i++)
{
fixed_t cosadj = abs(finecosine[xtoviewangle[i]>>ANGLETOFINESHIFT]);
Expand Down