mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-26 06:11:01 +00:00
Make sector texture offsets not scale
This commit is contained in:
parent
b411b9e523
commit
89770d9821
2 changed files with 38 additions and 50 deletions
|
@ -373,8 +373,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
INT32 i;
|
||||
|
||||
float height; // constant y for all points on the convex flat polygon
|
||||
float flatxref, flatyref, anglef = 0.0f;
|
||||
float anglef = 0.0f;
|
||||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||
float xscale, yscale;
|
||||
|
||||
float tempxsow, tempytow;
|
||||
float scrollx = 0.0f, scrolly = 0.0f;
|
||||
|
@ -409,11 +410,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
slope = gl_frontsector->c_slope;
|
||||
}
|
||||
|
||||
// Set fixedheight to the slope's height from our viewpoint, if we have a slope
|
||||
if (slope)
|
||||
fixedheight = P_GetSlopeZAt(slope, viewx, viewy);
|
||||
|
||||
height = FIXED_TO_FLOAT(fixedheight);
|
||||
height = FixedToFloat(fixedheight);
|
||||
|
||||
// Allocate plane-vertex buffer if we need to
|
||||
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
|
||||
|
@ -449,25 +446,21 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
else // set no texture
|
||||
HWR_SetCurrentTexture(NULL);
|
||||
|
||||
// reference point for flat texture coord for each vertex around the polygon
|
||||
flatxref = 0.0;
|
||||
flatyref = 0.0;
|
||||
|
||||
// transform
|
||||
if (FOFsector != NULL)
|
||||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
fflatwidth /= FixedToFloat(FOFsector->floorxscale);
|
||||
fflatheight /= FixedToFloat(FOFsector->flooryscale);
|
||||
xscale = FixedToFloat(FOFsector->floorxscale);
|
||||
yscale = FixedToFloat(FOFsector->flooryscale);
|
||||
scrollx = FixedToFloat(FOFsector->floorxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(FOFsector->flooryoffset) / fflatheight;
|
||||
angle = FOFsector->floorangle;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
fflatwidth /= FixedToFloat(FOFsector->ceilingxscale);
|
||||
fflatheight /= FixedToFloat(FOFsector->ceilingyscale);
|
||||
xscale = FixedToFloat(FOFsector->ceilingxscale);
|
||||
yscale = FixedToFloat(FOFsector->ceilingyscale);
|
||||
scrollx = FixedToFloat(FOFsector->ceilingxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(FOFsector->ceilingyoffset) / fflatheight;
|
||||
angle = FOFsector->ceilingangle;
|
||||
|
@ -477,16 +470,16 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
fflatwidth /= FixedToFloat(gl_frontsector->floorxscale);
|
||||
fflatheight /= FixedToFloat(gl_frontsector->flooryscale);
|
||||
xscale = FixedToFloat(gl_frontsector->floorxscale);
|
||||
yscale = FixedToFloat(gl_frontsector->flooryscale);
|
||||
scrollx = FixedToFloat(gl_frontsector->floorxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(gl_frontsector->flooryoffset) / fflatheight;
|
||||
angle = gl_frontsector->floorangle;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
fflatwidth /= FixedToFloat(gl_frontsector->ceilingxscale);
|
||||
fflatheight /= FixedToFloat(gl_frontsector->ceilingyscale);
|
||||
xscale = FixedToFloat(gl_frontsector->ceilingxscale);
|
||||
yscale = FixedToFloat(gl_frontsector->ceilingyscale);
|
||||
scrollx = FixedToFloat(gl_frontsector->ceilingxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(gl_frontsector->ceilingyoffset) / fflatheight;
|
||||
angle = gl_frontsector->ceilingangle;
|
||||
|
@ -497,8 +490,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
|
||||
#define SETUP3DVERT(vert, vx, vy) {\
|
||||
/* Hurdler: add scrolling texture on floor/ceiling */\
|
||||
vert->s = (float)(((vx) / fflatwidth) - flatxref + scrollx);\
|
||||
vert->t = (float)(flatyref - ((vy) / fflatheight) + scrolly);\
|
||||
vert->s = ((vx) / fflatwidth) + (scrollx / xscale);\
|
||||
vert->t = -((vy) / fflatheight) + (scrolly / yscale);\
|
||||
\
|
||||
/* Need to rotate before translate */\
|
||||
if (angle) /* Only needs to be done if there's an altered angle */\
|
||||
|
@ -509,15 +502,18 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
|||
vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\
|
||||
}\
|
||||
\
|
||||
vert->x = (vx);\
|
||||
vert->y = height;\
|
||||
vert->z = (vy);\
|
||||
vert->s *= xscale;\
|
||||
vert->t *= yscale;\
|
||||
\
|
||||
if (slope)\
|
||||
{\
|
||||
fixedheight = P_GetSlopeZAt(slope, FLOAT_TO_FIXED((vx)), FLOAT_TO_FIXED((vy)));\
|
||||
vert->y = FIXED_TO_FLOAT(fixedheight);\
|
||||
fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
|
||||
height = FixedToFloat(fixedheight);\
|
||||
}\
|
||||
\
|
||||
vert->x = (vx);\
|
||||
vert->y = height;\
|
||||
vert->z = (vy);\
|
||||
}
|
||||
|
||||
for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++)
|
||||
|
@ -2649,8 +2645,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
INT32 i;
|
||||
|
||||
float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon
|
||||
float flatxref, flatyref;
|
||||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||
float xscale, yscale;
|
||||
|
||||
float scrollx = 0.0f, scrolly = 0.0f;
|
||||
float tempxsow, tempytow, anglef = 0.0f;
|
||||
|
@ -2701,11 +2697,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
else // set no texture
|
||||
HWR_SetCurrentTexture(NULL);
|
||||
|
||||
// reference point for flat texture coord for each vertex around the polygon
|
||||
flatxref = 0.0;
|
||||
flatyref = 0.0;
|
||||
|
||||
|
||||
// transform
|
||||
v3d = planeVerts;
|
||||
|
||||
|
@ -2713,16 +2704,16 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
fflatwidth /= FixedToFloat(FOFsector->floorxscale);
|
||||
fflatheight /= FixedToFloat(FOFsector->flooryscale);
|
||||
xscale = FixedToFloat(FOFsector->floorxscale);
|
||||
yscale = FixedToFloat(FOFsector->flooryscale);
|
||||
scrollx = FixedToFloat(FOFsector->floorxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(FOFsector->flooryoffset) / fflatheight;
|
||||
angle = FOFsector->floorangle;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
fflatwidth /= FixedToFloat(FOFsector->ceilingxscale);
|
||||
fflatheight /= FixedToFloat(FOFsector->ceilingyscale);
|
||||
xscale = FixedToFloat(FOFsector->ceilingxscale);
|
||||
yscale = FixedToFloat(FOFsector->ceilingyscale);
|
||||
scrollx = FixedToFloat(FOFsector->ceilingxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(FOFsector->ceilingyoffset) / fflatheight;
|
||||
angle = FOFsector->ceilingangle;
|
||||
|
@ -2732,16 +2723,16 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
{
|
||||
if (!isceiling) // it's a floor
|
||||
{
|
||||
fflatwidth /= FixedToFloat(gl_frontsector->floorxscale);
|
||||
fflatheight /= FixedToFloat(gl_frontsector->flooryscale);
|
||||
xscale = FixedToFloat(gl_frontsector->floorxscale);
|
||||
yscale = FixedToFloat(gl_frontsector->flooryscale);
|
||||
scrollx = FixedToFloat(gl_frontsector->floorxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(gl_frontsector->flooryoffset) / fflatheight;
|
||||
angle = gl_frontsector->floorangle;
|
||||
}
|
||||
else // it's a ceiling
|
||||
{
|
||||
fflatwidth /= FixedToFloat(gl_frontsector->ceilingxscale);
|
||||
fflatheight /= FixedToFloat(gl_frontsector->ceilingyscale);
|
||||
xscale = FixedToFloat(gl_frontsector->ceilingxscale);
|
||||
yscale = FixedToFloat(gl_frontsector->ceilingyscale);
|
||||
scrollx = FixedToFloat(gl_frontsector->ceilingxoffset) / fflatwidth;
|
||||
scrolly = FixedToFloat(gl_frontsector->ceilingyoffset) / fflatheight;
|
||||
angle = gl_frontsector->ceilingangle;
|
||||
|
@ -2754,8 +2745,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
{
|
||||
// Go from the polysector's original vertex locations
|
||||
// Means the flat is offset based on the original vertex locations
|
||||
v3d->s = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx);
|
||||
v3d->t = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly);
|
||||
v3d->s = (FixedToFloat(polysector->origVerts[i].x) / fflatwidth) + (scrollx / xscale);
|
||||
v3d->t = -(FixedToFloat(polysector->origVerts[i].y) / fflatheight) + (scrolly / yscale);
|
||||
|
||||
// Need to rotate before translate
|
||||
if (angle) // Only needs to be done if there's an altered angle
|
||||
|
@ -2767,6 +2758,9 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||
v3d->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
|
||||
}
|
||||
|
||||
v3d->s *= xscale;
|
||||
v3d->t *= yscale;
|
||||
|
||||
v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x);
|
||||
v3d->y = height;
|
||||
v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y);
|
||||
|
|
|
@ -380,8 +380,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
|
||||
if (!slope) // Don't mess with this right now if a slope is involved
|
||||
{
|
||||
xoff += viewx;
|
||||
yoff -= viewy;
|
||||
xoff += FixedMul(viewx, xscale);
|
||||
yoff -= FixedMul(viewy, yscale);
|
||||
|
||||
if (plangle != 0)
|
||||
{
|
||||
|
@ -411,12 +411,6 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
|||
}
|
||||
}
|
||||
|
||||
if (!slope)
|
||||
{
|
||||
xoff = FixedMul(xoff, xscale);
|
||||
yoff = FixedMul(yoff, yscale);
|
||||
}
|
||||
|
||||
// This appears to fix the Nimbus Ruins sky bug.
|
||||
if (picnum == skyflatnum && pfloor)
|
||||
{
|
||||
|
@ -809,7 +803,7 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_
|
|||
{
|
||||
R_SetScaledSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz,
|
||||
FixedDiv(FRACUNIT, pl->xscale), FixedDiv(FRACUNIT, pl->yscale),
|
||||
xoff, yoff, pl->viewangle, pl->plangle);
|
||||
FixedDiv(xoff, pl->xscale), FixedDiv(yoff, pl->yscale), pl->viewangle, pl->plangle);
|
||||
}
|
||||
else
|
||||
R_SetSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz, xoff, yoff, pl->viewangle, pl->plangle);
|
||||
|
|
Loading…
Reference in a new issue