mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-20 19:02:34 +00:00
Merge branch 'alignment_v2' into 'master'
Consistent flat alignment Does what it says on the tin. Consistent between the three different plane drawers: * Software flat (previously the only one working as intended) * Software sloped (took a lot of work) * OpenGL flat and sloped (worked reasonably well but used different signs for some reason) Check out root/!LatestSRB2Files/srb2win_branch_flat2.exe, root/toaster/flatalignment.wad and any in-dev DSZ1 to test it all out. See merge request !78
This commit is contained in:
commit
c10c3d0441
3 changed files with 66 additions and 34 deletions
|
@ -641,13 +641,13 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
{
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize;
|
||||
angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT;
|
||||
angle = FOFsector->floorpic_angle;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize;
|
||||
angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT;
|
||||
angle = FOFsector->ceilingpic_angle;
|
||||
}
|
||||
}
|
||||
else if (gr_frontsector)
|
||||
|
@ -656,25 +656,19 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
{
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize;
|
||||
angle = gr_frontsector->floorpic_angle>>ANGLETOFINESHIFT;
|
||||
angle = gr_frontsector->floorpic_angle;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatsize;
|
||||
scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatsize;
|
||||
angle = gr_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT;
|
||||
angle = gr_frontsector->ceilingpic_angle;
|
||||
}
|
||||
}
|
||||
|
||||
if (angle) // Only needs to be done if there's an altered angle
|
||||
{
|
||||
|
||||
// This needs to be done so that it scrolls in a different direction after rotation like software
|
||||
tempxsow = FLOAT_TO_FIXED(scrollx);
|
||||
tempytow = FLOAT_TO_FIXED(scrolly);
|
||||
scrollx = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
|
||||
scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));
|
||||
|
||||
angle = InvAngle(angle)>>ANGLETOFINESHIFT;
|
||||
// This needs to be done so everything aligns after rotation
|
||||
// It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does
|
||||
tempxsow = FLOAT_TO_FIXED(flatxref);
|
||||
|
@ -687,7 +681,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
{
|
||||
// Hurdler: add scrolling texture on floor/ceiling
|
||||
v3d->sow = (float)((pv->x / fflatsize) - flatxref + scrollx);
|
||||
v3d->tow = (float)(flatyref - (pv->y / fflatsize) + scrolly);
|
||||
v3d->tow = (float)(-(pv->y / fflatsize) + flatyref + scrolly);
|
||||
|
||||
//v3d->sow = (float)(pv->x / fflatsize);
|
||||
//v3d->tow = (float)(pv->y / fflatsize);
|
||||
|
@ -698,7 +692,7 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
|||
tempxsow = FLOAT_TO_FIXED(v3d->sow);
|
||||
tempytow = FLOAT_TO_FIXED(v3d->tow);
|
||||
v3d->sow = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));
|
||||
v3d->tow = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle))));
|
||||
v3d->tow = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));
|
||||
}
|
||||
|
||||
//v3d->sow = (float)(v3d->sow - flatxref + scrollx);
|
||||
|
|
|
@ -5879,10 +5879,8 @@ void P_SpawnSpecials(INT32 fromnetsave)
|
|||
}
|
||||
else // Otherwise, set calculated offsets such that line's v1 is the apparent origin
|
||||
{
|
||||
fixed_t cosinecomponent = FINECOSINE(flatangle>>ANGLETOFINESHIFT);
|
||||
fixed_t sinecomponent = FINESINE(flatangle>>ANGLETOFINESHIFT);
|
||||
xoffs = (-FixedMul(lines[i].v1->x, cosinecomponent) % MAXFLATSIZE) + (FixedMul(lines[i].v1->y, sinecomponent) % MAXFLATSIZE); // No danger of overflow thanks to the strategically placed modulo operations.
|
||||
yoffs = (FixedMul(lines[i].v1->x, sinecomponent) % MAXFLATSIZE) + (FixedMul(lines[i].v1->y, cosinecomponent) % MAXFLATSIZE); // Ditto.
|
||||
xoffs = -lines[i].v1->x;
|
||||
yoffs = lines[i].v1->y;
|
||||
}
|
||||
|
||||
for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;)
|
||||
|
|
|
@ -445,17 +445,18 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
#ifdef ESLOPE
|
||||
if (slope); else // Don't mess with this right now if a slope is involved
|
||||
#endif
|
||||
if (plangle != 0)
|
||||
{
|
||||
// Add the view offset, rotated by the plane angle.
|
||||
angle_t angle = plangle>>ANGLETOFINESHIFT;
|
||||
xoff += FixedMul(viewx,FINECOSINE(angle))-FixedMul(viewy,FINESINE(angle));
|
||||
yoff += -FixedMul(viewx,FINESINE(angle))-FixedMul(viewy,FINECOSINE(angle));
|
||||
}
|
||||
else
|
||||
{
|
||||
xoff += viewx;
|
||||
yoff -= viewy;
|
||||
if (plangle != 0)
|
||||
{
|
||||
// Add the view offset, rotated by the plane angle.
|
||||
fixed_t cosinecomponent = FINECOSINE(plangle>>ANGLETOFINESHIFT);
|
||||
fixed_t sinecomponent = FINESINE(plangle>>ANGLETOFINESHIFT);
|
||||
fixed_t oldxoff = xoff;
|
||||
xoff = FixedMul(xoff,cosinecomponent)+FixedMul(yoff,sinecomponent);
|
||||
yoff = -FixedMul(oldxoff,sinecomponent)+FixedMul(yoff,cosinecomponent);
|
||||
}
|
||||
}
|
||||
|
||||
// This appears to fix the Nimbus Ruins sky bug.
|
||||
|
@ -483,6 +484,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
&& !pfloor && !check->ffloor
|
||||
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
|
||||
&& check->viewangle == viewangle
|
||||
&& check->plangle == plangle
|
||||
#ifdef ESLOPE
|
||||
&& check->slope == slope
|
||||
#endif
|
||||
|
@ -951,19 +953,57 @@ void R_DrawSinglePlane(visplane_t *pl)
|
|||
floatv3_t p, m, n;
|
||||
float ang;
|
||||
float vx, vy, vz;
|
||||
float fudge;
|
||||
// compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly
|
||||
// use this as a temp var to store P_GetZAt's return value each time
|
||||
fixed_t temp;
|
||||
|
||||
xoffs &= ((1 << (32-nflatshiftup))-1);
|
||||
yoffs &= ((1 << (32-nflatshiftup))-1);
|
||||
|
||||
xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
|
||||
yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
|
||||
|
||||
// Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red
|
||||
fudge = ((1<<nflatshiftup)+1.0f)/(1<<nflatshiftup);
|
||||
const float fudge = ((1<<nflatshiftup)+1.0f)/(1<<nflatshiftup);
|
||||
|
||||
angle_t hack = (pl->plangle & (ANGLE_90-1));
|
||||
|
||||
yoffs *= 1;
|
||||
|
||||
if (hack)
|
||||
{
|
||||
/*
|
||||
Essentially: We can't & the components along the regular axes when the plane is rotated.
|
||||
This is because the distance on each regular axis in order to loop is different.
|
||||
We rotate them, & the components, add them together, & them again, and then rotate them back.
|
||||
These three seperate & operations are done per axis in order to prevent overflows.
|
||||
toast 10/04/17
|
||||
*/
|
||||
const fixed_t cosinecomponent = FINECOSINE(hack>>ANGLETOFINESHIFT);
|
||||
const fixed_t sinecomponent = FINESINE(hack>>ANGLETOFINESHIFT);
|
||||
|
||||
const fixed_t modmask = ((1 << (32-nflatshiftup)) - 1);
|
||||
|
||||
fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask);
|
||||
fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask);
|
||||
|
||||
temp = ox & modmask;
|
||||
oy &= modmask;
|
||||
ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction
|
||||
oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent);
|
||||
|
||||
temp = xoffs;
|
||||
xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask);
|
||||
yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask);
|
||||
|
||||
temp = xoffs & modmask;
|
||||
yoffs &= modmask;
|
||||
xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto
|
||||
yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent);
|
||||
|
||||
xoffs -= (pl->slope->o.x - ox);
|
||||
yoffs += (pl->slope->o.y + oy);
|
||||
}
|
||||
else
|
||||
{
|
||||
xoffs &= ((1 << (32-nflatshiftup))-1);
|
||||
yoffs &= ((1 << (32-nflatshiftup))-1);
|
||||
xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
|
||||
yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
|
||||
}
|
||||
|
||||
xoffs = (fixed_t)(xoffs*fudge);
|
||||
yoffs = (fixed_t)(yoffs/fudge);
|
||||
|
|
Loading…
Reference in a new issue