Merge branch 'udmf-floor-ceiling-texture-scaling' into 'next'

Floor and ceiling texture scaling

See merge request STJr/SRB2!2221
This commit is contained in:
sphere 2023-12-11 22:15:36 +00:00
commit 55d257266d
11 changed files with 319 additions and 200 deletions

View file

@ -372,11 +372,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
INT32 i; INT32 i;
float height; // constant y for all points on the convex flat polygon 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 fflatwidth = 64.0f, fflatheight = 64.0f;
UINT16 flatflag = 63; float xscale = 1.0f, yscale = 1.0f;
boolean texflat = false;
float tempxsow, tempytow; float tempxsow, tempytow;
float scrollx = 0.0f, scrolly = 0.0f; float scrollx = 0.0f, scrolly = 0.0f;
@ -411,11 +409,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
slope = gl_frontsector->c_slope; slope = gl_frontsector->c_slope;
} }
// Set fixedheight to the slope's height from our viewpoint, if we have a slope height = FixedToFloat(fixedheight);
if (slope)
fixedheight = P_GetSlopeZAt(slope, viewx, viewy);
height = FIXED_TO_FLOAT(fixedheight);
// Allocate plane-vertex buffer if we need to // Allocate plane-vertex buffer if we need to
if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts)
@ -431,8 +425,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
if (levelflat->type == LEVELFLAT_FLAT) if (levelflat->type == LEVELFLAT_FLAT)
{ {
size_t len = W_LumpLength(levelflat->u.flat.lumpnum); size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
flatflag = R_GetFlatSize(len) - 1; unsigned flatflag = R_GetFlatSize(len);
fflatwidth = fflatheight = (float)(flatflag + 1); fflatwidth = fflatheight = (float)flatflag;
} }
else else
{ {
@ -446,29 +440,28 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
fflatwidth = levelflat->width; fflatwidth = levelflat->width;
fflatheight = levelflat->height; fflatheight = levelflat->height;
} }
texflat = true;
} }
} }
else // set no texture else // set no texture
HWR_SetCurrentTexture(NULL); HWR_SetCurrentTexture(NULL);
// reference point for flat texture coord for each vertex around the polygon
flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatwidth);
flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatheight);
// transform // transform
if (FOFsector != NULL) if (FOFsector != NULL)
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->floorxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->flooryoffset)/fflatheight; yscale = FixedToFloat(FOFsector->flooryscale);
scrollx = FixedToFloat(FOFsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->flooryoffset) / fflatheight;
angle = FOFsector->floorangle; angle = FOFsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(FOFsector->ceilingyscale);
scrollx = FixedToFloat(FOFsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->ceilingyoffset) / fflatheight;
angle = FOFsector->ceilingangle; angle = FOFsector->ceilingangle;
} }
} }
@ -476,41 +469,28 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->floorxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->flooryoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->flooryscale);
scrollx = FixedToFloat(gl_frontsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->flooryoffset) / fflatheight;
angle = gl_frontsector->floorangle; angle = gl_frontsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->ceilingyscale);
scrollx = FixedToFloat(gl_frontsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->ceilingyoffset) / fflatheight;
angle = gl_frontsector->ceilingangle; angle = gl_frontsector->ceilingangle;
} }
} }
if (angle) // Only needs to be done if there's an altered angle
{
tempxsow = flatxref;
tempytow = flatyref;
anglef = ANG2RAD(InvAngle(angle)); anglef = ANG2RAD(InvAngle(angle));
flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));
flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
}
#define SETUP3DVERT(vert, vx, vy) {\ #define SETUP3DVERT(vert, vx, vy) {\
/* Hurdler: add scrolling texture on floor/ceiling */\ /* Hurdler: add scrolling texture on floor/ceiling */\
if (texflat)\ vert->s = ((vx) / fflatwidth) + (scrollx / xscale);\
{\ vert->t = -((vy) / fflatheight) + (scrolly / yscale);\
vert->s = (float)((vx) / fflatwidth) + scrollx;\
vert->t = -(float)((vy) / fflatheight) + scrolly;\
}\
else\
{\
vert->s = (float)(((vx) / fflatwidth) - flatxref + scrollx);\
vert->t = (float)(flatyref - ((vy) / fflatheight) + scrolly);\
}\
\ \
/* Need to rotate before translate */\ /* Need to rotate before translate */\
if (angle) /* Only needs to be done if there's an altered angle */\ if (angle) /* Only needs to be done if there's an altered angle */\
@ -521,15 +501,18 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\ vert->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));\
}\ }\
\ \
vert->x = (vx);\ vert->s *= xscale;\
vert->y = height;\ vert->t *= yscale;\
vert->z = (vy);\
\ \
if (slope)\ if (slope)\
{\ {\
fixedheight = P_GetSlopeZAt(slope, FLOAT_TO_FIXED((vx)), FLOAT_TO_FIXED((vy)));\ fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\
vert->y = FIXED_TO_FLOAT(fixedheight);\ height = FixedToFloat(fixedheight);\
}\ }\
\
vert->x = (vx);\
vert->y = height;\
vert->z = (vy);\
} }
for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++) for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++)
@ -2725,11 +2708,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
INT32 i; INT32 i;
float height = FIXED_TO_FLOAT(fixedheight); // constant y for all points on the convex flat polygon 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 fflatwidth = 64.0f, fflatheight = 64.0f;
UINT16 flatflag = 63; float xscale = 1.0f, yscale = 1.0f;
boolean texflat = false;
float scrollx = 0.0f, scrolly = 0.0f; float scrollx = 0.0f, scrolly = 0.0f;
float tempxsow, tempytow, anglef = 0.0f; float tempxsow, tempytow, anglef = 0.0f;
@ -2760,8 +2740,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
if (levelflat->type == LEVELFLAT_FLAT) if (levelflat->type == LEVELFLAT_FLAT)
{ {
size_t len = W_LumpLength(levelflat->u.flat.lumpnum); size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
flatflag = R_GetFlatSize(len) - 1; unsigned flatflag = R_GetFlatSize(len);
fflatwidth = fflatheight = (float)(flatflag + 1); fflatwidth = fflatheight = (float)flatflag;
} }
else else
{ {
@ -2775,19 +2755,11 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
fflatwidth = levelflat->width; fflatwidth = levelflat->width;
fflatheight = levelflat->height; fflatheight = levelflat->height;
} }
texflat = true;
} }
} }
else // set no texture else // set no texture
HWR_SetCurrentTexture(NULL); HWR_SetCurrentTexture(NULL);
// reference point for flat texture coord for each vertex around the polygon
flatxref = FIXED_TO_FLOAT(polysector->origVerts[0].x);
flatyref = FIXED_TO_FLOAT(polysector->origVerts[0].y);
flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatwidth);
flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatheight);
// transform // transform
v3d = planeVerts; v3d = planeVerts;
@ -2795,14 +2767,18 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->floorxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->flooryoffset)/fflatheight; yscale = FixedToFloat(FOFsector->flooryscale);
scrollx = FixedToFloat(FOFsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->flooryoffset) / fflatheight;
angle = FOFsector->floorangle; angle = FOFsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(FOFsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(FOFsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(FOFsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(FOFsector->ceilingyscale);
scrollx = FixedToFloat(FOFsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(FOFsector->ceilingyoffset) / fflatheight;
angle = FOFsector->ceilingangle; angle = FOFsector->ceilingangle;
} }
} }
@ -2810,43 +2786,30 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
{ {
if (!isceiling) // it's a floor if (!isceiling) // it's a floor
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->floorxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->floorxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->flooryoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->flooryscale);
scrollx = FixedToFloat(gl_frontsector->floorxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->flooryoffset) / fflatheight;
angle = gl_frontsector->floorangle; angle = gl_frontsector->floorangle;
} }
else // it's a ceiling else // it's a ceiling
{ {
scrollx = FIXED_TO_FLOAT(gl_frontsector->ceilingxoffset)/fflatwidth; xscale = FixedToFloat(gl_frontsector->ceilingxscale);
scrolly = FIXED_TO_FLOAT(gl_frontsector->ceilingyoffset)/fflatheight; yscale = FixedToFloat(gl_frontsector->ceilingyscale);
scrollx = FixedToFloat(gl_frontsector->ceilingxoffset) / fflatwidth;
scrolly = FixedToFloat(gl_frontsector->ceilingyoffset) / fflatheight;
angle = gl_frontsector->ceilingangle; angle = gl_frontsector->ceilingangle;
} }
} }
if (angle) // Only needs to be done if there's an altered angle
{
tempxsow = flatxref;
tempytow = flatyref;
anglef = ANG2RAD(InvAngle(angle)); anglef = ANG2RAD(InvAngle(angle));
flatxref = (tempxsow * cos(anglef)) - (tempytow * sin(anglef));
flatyref = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
}
for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++) for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++)
{ {
// Go from the polysector's original vertex locations // Go from the polysector's original vertex locations
// Means the flat is offset based on the original vertex locations // Means the flat is offset based on the original vertex locations
if (texflat) v3d->s = (FixedToFloat(polysector->origVerts[i].x) / fflatwidth) + (scrollx / xscale);
{ v3d->t = -(FixedToFloat(polysector->origVerts[i].y) / fflatheight) + (scrolly / yscale);
v3d->s = (float)(FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) + scrollx;
v3d->t = -(float)(FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly;
}
else
{
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);
}
// Need to rotate before translate // Need to rotate before translate
if (angle) // Only needs to be done if there's an altered angle if (angle) // Only needs to be done if there's an altered angle
@ -2858,6 +2821,9 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
v3d->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef)); v3d->t = (tempxsow * sin(anglef)) + (tempytow * cos(anglef));
} }
v3d->s *= xscale;
v3d->t *= yscale;
v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x); v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x);
v3d->y = height; v3d->y = height;
v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y); v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y);

View file

@ -35,10 +35,14 @@ enum sector_e {
sector_floorpic, sector_floorpic,
sector_floorxoffset, sector_floorxoffset,
sector_flooryoffset, sector_flooryoffset,
sector_floorxscale,
sector_flooryscale,
sector_floorangle, sector_floorangle,
sector_ceilingpic, sector_ceilingpic,
sector_ceilingxoffset, sector_ceilingxoffset,
sector_ceilingyoffset, sector_ceilingyoffset,
sector_ceilingxscale,
sector_ceilingyscale,
sector_ceilingangle, sector_ceilingangle,
sector_lightlevel, sector_lightlevel,
sector_floorlightlevel, sector_floorlightlevel,
@ -74,10 +78,14 @@ static const char *const sector_opt[] = {
"floorpic", "floorpic",
"floorxoffset", "floorxoffset",
"flooryoffset", "flooryoffset",
"floorxscale",
"flooryscale",
"floorangle", "floorangle",
"ceilingpic", "ceilingpic",
"ceilingxoffset", "ceilingxoffset",
"ceilingyoffset", "ceilingyoffset",
"ceilingxscale",
"ceilingyscale",
"ceilingangle", "ceilingangle",
"lightlevel", "lightlevel",
"floorlightlevel", "floorlightlevel",
@ -188,14 +196,16 @@ enum side_e {
side_offsety_top, side_offsety_top,
side_offsetx_mid, side_offsetx_mid,
side_offsety_mid, side_offsety_mid,
side_offsetx_bottom,
side_offsetx_bot, side_offsetx_bot,
side_offsety_bottom,
side_offsety_bot, side_offsety_bot,
side_scalex_top, side_scalex_top,
side_scaley_top, side_scaley_top,
side_scalex_mid, side_scalex_mid,
side_scaley_mid, side_scaley_mid,
side_scalex_bot, side_scalex_bottom,
side_scaley_bot, side_scaley_bottom,
side_toptexture, side_toptexture,
side_bottomtexture, side_bottomtexture,
side_midtexture, side_midtexture,
@ -214,14 +224,16 @@ static const char *const side_opt[] = {
"offsety_top", "offsety_top",
"offsetx_mid", "offsetx_mid",
"offsety_mid", "offsety_mid",
"offsetx_bottom",
"offsetx_bot", "offsetx_bot",
"offsety_bottom",
"offsety_bot", "offsety_bot",
"scalex_top", "scalex_top",
"scaley_top", "scaley_top",
"scalex_mid", "scalex_mid",
"scaley_mid", "scaley_mid",
"scalex_bot", "scalex_bottom",
"scaley_bot", "scaley_bottom",
"toptexture", "toptexture",
"bottomtexture", "bottomtexture",
"midtexture", "midtexture",
@ -261,8 +273,16 @@ enum ffloor_e {
ffloor_topheight, ffloor_topheight,
ffloor_toppic, ffloor_toppic,
ffloor_toplightlevel, ffloor_toplightlevel,
ffloor_topxoffs,
ffloor_topyoffs,
ffloor_topxscale,
ffloor_topyscale,
ffloor_bottomheight, ffloor_bottomheight,
ffloor_bottompic, ffloor_bottompic,
ffloor_bottomxoffs,
ffloor_bottomyoffs,
ffloor_bottomxscale,
ffloor_bottomyscale,
ffloor_tslope, ffloor_tslope,
ffloor_bslope, ffloor_bslope,
ffloor_sector, ffloor_sector,
@ -287,8 +307,16 @@ static const char *const ffloor_opt[] = {
"topheight", "topheight",
"toppic", "toppic",
"toplightlevel", "toplightlevel",
"topxoffs",
"topyoffs",
"topxscale",
"topyscale",
"bottomheight", "bottomheight",
"bottompic", "bottompic",
"bottomxoffs",
"bottomyoffs",
"bottomxscale",
"bottomyscale",
"t_slope", "t_slope",
"b_slope", "b_slope",
"sector", // secnum pushed as control sector userdata "sector", // secnum pushed as control sector userdata
@ -668,20 +696,20 @@ static int sector_get(lua_State *L)
return 1; return 1;
} }
case sector_floorxoffset: case sector_floorxoffset:
{
lua_pushfixed(L, sector->floorxoffset); lua_pushfixed(L, sector->floorxoffset);
return 1; return 1;
}
case sector_flooryoffset: case sector_flooryoffset:
{
lua_pushfixed(L, sector->flooryoffset); lua_pushfixed(L, sector->flooryoffset);
return 1; return 1;
} case sector_floorxscale:
lua_pushfixed(L, sector->floorxscale);
return 1;
case sector_flooryscale:
lua_pushfixed(L, sector->flooryscale);
return 1;
case sector_floorangle: case sector_floorangle:
{
lua_pushangle(L, sector->floorangle); lua_pushangle(L, sector->floorangle);
return 1; return 1;
}
case sector_ceilingpic: // ceilingpic case sector_ceilingpic: // ceilingpic
{ {
levelflat_t *levelflat = &levelflats[sector->ceilingpic]; levelflat_t *levelflat = &levelflats[sector->ceilingpic];
@ -692,20 +720,20 @@ static int sector_get(lua_State *L)
return 1; return 1;
} }
case sector_ceilingxoffset: case sector_ceilingxoffset:
{
lua_pushfixed(L, sector->ceilingxoffset); lua_pushfixed(L, sector->ceilingxoffset);
return 1; return 1;
}
case sector_ceilingyoffset: case sector_ceilingyoffset:
{
lua_pushfixed(L, sector->ceilingyoffset); lua_pushfixed(L, sector->ceilingyoffset);
return 1; return 1;
} case sector_ceilingxscale:
lua_pushfixed(L, sector->ceilingxscale);
return 1;
case sector_ceilingyscale:
lua_pushfixed(L, sector->ceilingyscale);
return 1;
case sector_ceilingangle: case sector_ceilingangle:
{
lua_pushangle(L, sector->ceilingangle); lua_pushangle(L, sector->ceilingangle);
return 1; return 1;
}
case sector_lightlevel: case sector_lightlevel:
lua_pushinteger(L, sector->lightlevel); lua_pushinteger(L, sector->lightlevel);
return 1; return 1;
@ -857,6 +885,12 @@ static int sector_set(lua_State *L)
case sector_flooryoffset: case sector_flooryoffset:
sector->flooryoffset = luaL_checkfixed(L, 3); sector->flooryoffset = luaL_checkfixed(L, 3);
break; break;
case sector_floorxscale:
sector->floorxscale = luaL_checkfixed(L, 3);
break;
case sector_flooryscale:
sector->flooryscale = luaL_checkfixed(L, 3);
break;
case sector_floorangle: case sector_floorangle:
sector->floorangle = luaL_checkangle(L, 3); sector->floorangle = luaL_checkangle(L, 3);
break; break;
@ -869,6 +903,12 @@ static int sector_set(lua_State *L)
case sector_ceilingyoffset: case sector_ceilingyoffset:
sector->ceilingyoffset = luaL_checkfixed(L, 3); sector->ceilingyoffset = luaL_checkfixed(L, 3);
break; break;
case sector_ceilingxscale:
sector->ceilingxscale = luaL_checkfixed(L, 3);
break;
case sector_ceilingyscale:
sector->ceilingyscale = luaL_checkfixed(L, 3);
break;
case sector_ceilingangle: case sector_ceilingangle:
sector->ceilingangle = luaL_checkangle(L, 3); sector->ceilingangle = luaL_checkangle(L, 3);
break; break;
@ -1222,9 +1262,11 @@ static int side_get(lua_State *L)
case side_offsety_mid: case side_offsety_mid:
lua_pushfixed(L, side->offsety_mid); lua_pushfixed(L, side->offsety_mid);
return 1; return 1;
case side_offsetx_bottom:
case side_offsetx_bot: case side_offsetx_bot:
lua_pushfixed(L, side->offsetx_bottom); lua_pushfixed(L, side->offsetx_bottom);
return 1; return 1;
case side_offsety_bottom:
case side_offsety_bot: case side_offsety_bot:
lua_pushfixed(L, side->offsety_bottom); lua_pushfixed(L, side->offsety_bottom);
return 1; return 1;
@ -1240,10 +1282,10 @@ static int side_get(lua_State *L)
case side_scaley_mid: case side_scaley_mid:
lua_pushfixed(L, side->scaley_mid); lua_pushfixed(L, side->scaley_mid);
return 1; return 1;
case side_scalex_bot: case side_scalex_bottom:
lua_pushfixed(L, side->scalex_bottom); lua_pushfixed(L, side->scalex_bottom);
return 1; return 1;
case side_scaley_bot: case side_scaley_bottom:
lua_pushfixed(L, side->scaley_bottom); lua_pushfixed(L, side->scaley_bottom);
return 1; return 1;
case side_toptexture: case side_toptexture:
@ -1332,9 +1374,11 @@ static int side_set(lua_State *L)
side->offsety_mid = luaL_checkfixed(L, 3); side->offsety_mid = luaL_checkfixed(L, 3);
break; break;
case side_offsetx_bot: case side_offsetx_bot:
case side_offsetx_bottom:
side->offsetx_bottom = luaL_checkfixed(L, 3); side->offsetx_bottom = luaL_checkfixed(L, 3);
break; break;
case side_offsety_bot: case side_offsety_bot:
case side_offsety_bottom:
side->offsety_bottom = luaL_checkfixed(L, 3); side->offsety_bottom = luaL_checkfixed(L, 3);
break; break;
case side_scalex_top: case side_scalex_top:
@ -1349,10 +1393,10 @@ static int side_set(lua_State *L)
case side_scaley_mid: case side_scaley_mid:
side->scaley_mid = luaL_checkfixed(L, 3); side->scaley_mid = luaL_checkfixed(L, 3);
break; break;
case side_scalex_bot: case side_scalex_bottom:
side->scalex_bottom = luaL_checkfixed(L, 3); side->scalex_bottom = luaL_checkfixed(L, 3);
break; break;
case side_scaley_bot: case side_scaley_bottom:
side->scaley_bottom = luaL_checkfixed(L, 3); side->scaley_bottom = luaL_checkfixed(L, 3);
break; break;
case side_toptexture: case side_toptexture:
@ -2170,6 +2214,18 @@ static int ffloor_get(lua_State *L)
case ffloor_toplightlevel: case ffloor_toplightlevel:
lua_pushinteger(L, *ffloor->toplightlevel); lua_pushinteger(L, *ffloor->toplightlevel);
return 1; return 1;
case ffloor_topxoffs:
lua_pushfixed(L, *ffloor->topxoffs);
return 1;
case ffloor_topyoffs:
lua_pushfixed(L, *ffloor->topyoffs);
return 1;
case ffloor_topxscale:
lua_pushfixed(L, *ffloor->topxscale);
return 1;
case ffloor_topyscale:
lua_pushfixed(L, *ffloor->topyscale);
return 1;
case ffloor_bottomheight: case ffloor_bottomheight:
lua_pushfixed(L, *ffloor->bottomheight); lua_pushfixed(L, *ffloor->bottomheight);
return 1; return 1;
@ -2181,6 +2237,18 @@ static int ffloor_get(lua_State *L)
lua_pushlstring(L, levelflat->name, i); lua_pushlstring(L, levelflat->name, i);
return 1; return 1;
} }
case ffloor_bottomxoffs:
lua_pushfixed(L, *ffloor->bottomxoffs);
return 1;
case ffloor_bottomyoffs:
lua_pushfixed(L, *ffloor->bottomyoffs);
return 1;
case ffloor_bottomxscale:
lua_pushfixed(L, *ffloor->bottomxscale);
return 1;
case ffloor_bottomyscale:
lua_pushfixed(L, *ffloor->bottomyscale);
return 1;
case ffloor_tslope: case ffloor_tslope:
LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE); LUA_PushUserdata(L, *ffloor->t_slope, META_SLOPE);
return 1; return 1;
@ -2365,6 +2433,18 @@ static int ffloor_set(lua_State *L)
case ffloor_toplightlevel: case ffloor_toplightlevel:
*ffloor->toplightlevel = (INT16)luaL_checkinteger(L, 3); *ffloor->toplightlevel = (INT16)luaL_checkinteger(L, 3);
break; break;
case ffloor_topxoffs:
*ffloor->topxoffs = luaL_checkfixed(L, 3);
break;
case ffloor_topyoffs:
*ffloor->topyoffs = luaL_checkfixed(L, 3);
break;
case ffloor_topxscale:
*ffloor->topxscale = luaL_checkfixed(L, 3);
break;
case ffloor_topyscale:
*ffloor->topyscale = luaL_checkfixed(L, 3);
break;
case ffloor_bottomheight: { // bottomheight case ffloor_bottomheight: { // bottomheight
boolean flag; boolean flag;
fixed_t lastpos = *ffloor->bottomheight; fixed_t lastpos = *ffloor->bottomheight;
@ -2383,6 +2463,18 @@ static int ffloor_set(lua_State *L)
case ffloor_bottompic: case ffloor_bottompic:
*ffloor->bottompic = P_AddLevelFlatRuntime(luaL_checkstring(L, 3)); *ffloor->bottompic = P_AddLevelFlatRuntime(luaL_checkstring(L, 3));
break; break;
case ffloor_bottomxoffs:
*ffloor->bottomxoffs = luaL_checkfixed(L, 3);
break;
case ffloor_bottomyoffs:
*ffloor->bottomyoffs = luaL_checkfixed(L, 3);
break;
case ffloor_bottomxscale:
*ffloor->bottomxscale = luaL_checkfixed(L, 3);
break;
case ffloor_bottomyscale:
*ffloor->bottomyscale = luaL_checkfixed(L, 3);
break;
case ffloor_fofflags: { case ffloor_fofflags: {
ffloortype_e oldflags = ffloor->fofflags; // store FOF's old flags ffloortype_e oldflags = ffloor->fofflags; // store FOF's old flags
ffloor->fofflags = luaL_checkinteger(L, 3); ffloor->fofflags = luaL_checkinteger(L, 3);

View file

@ -867,6 +867,10 @@ static void P_NetUnArchiveWaypoints(void)
#define SD_TRIGGERTAG 0x02 #define SD_TRIGGERTAG 0x02
#define SD_TRIGGERER 0x04 #define SD_TRIGGERER 0x04
#define SD_GRAVITY 0x08 #define SD_GRAVITY 0x08
#define SD_FXSCALE 0x10
#define SD_FYSCALE 0x20
#define SD_CXSCALE 0x40
#define SD_CYSCALE 0x80
#define LD_FLAG 0x01 #define LD_FLAG 0x01
#define LD_SPECIAL 0x02 #define LD_SPECIAL 0x02
@ -1054,6 +1058,14 @@ static void ArchiveSectors(void)
diff2 |= SD_CXOFFS; diff2 |= SD_CXOFFS;
if (ss->ceilingyoffset != spawnss->ceilingyoffset) if (ss->ceilingyoffset != spawnss->ceilingyoffset)
diff2 |= SD_CYOFFS; diff2 |= SD_CYOFFS;
if (ss->floorxscale != spawnss->floorxscale)
diff2 |= SD_FXSCALE;
if (ss->flooryscale != spawnss->flooryscale)
diff2 |= SD_FYSCALE;
if (ss->ceilingxscale != spawnss->ceilingxscale)
diff2 |= SD_CXSCALE;
if (ss->ceilingyscale != spawnss->ceilingyscale)
diff2 |= SD_CYSCALE;
if (ss->floorangle != spawnss->floorangle) if (ss->floorangle != spawnss->floorangle)
diff2 |= SD_FLOORANG; diff2 |= SD_FLOORANG;
if (ss->ceilingangle != spawnss->ceilingangle) if (ss->ceilingangle != spawnss->ceilingangle)
@ -1164,6 +1176,14 @@ static void ArchiveSectors(void)
WRITEUINT8(save_p, ss->triggerer); WRITEUINT8(save_p, ss->triggerer);
if (diff4 & SD_GRAVITY) if (diff4 & SD_GRAVITY)
WRITEFIXED(save_p, ss->gravity); WRITEFIXED(save_p, ss->gravity);
if (diff4 & SD_FXSCALE)
WRITEFIXED(save_p, ss->floorxscale);
if (diff4 & SD_FYSCALE)
WRITEFIXED(save_p, ss->flooryscale);
if (diff4 & SD_CXSCALE)
WRITEFIXED(save_p, ss->ceilingxscale);
if (diff4 & SD_CYSCALE)
WRITEFIXED(save_p, ss->ceilingyscale);
if (diff & SD_FFLOORS) if (diff & SD_FFLOORS)
ArchiveFFloors(ss); ArchiveFFloors(ss);
} }
@ -1285,6 +1305,14 @@ static void UnArchiveSectors(void)
sectors[i].triggerer = READUINT8(save_p); sectors[i].triggerer = READUINT8(save_p);
if (diff4 & SD_GRAVITY) if (diff4 & SD_GRAVITY)
sectors[i].gravity = READFIXED(save_p); sectors[i].gravity = READFIXED(save_p);
if (diff4 & SD_FXSCALE)
sectors[i].floorxscale = READFIXED(save_p);
if (diff4 & SD_FYSCALE)
sectors[i].flooryscale = READFIXED(save_p);
if (diff4 & SD_CXSCALE)
sectors[i].ceilingxscale = READFIXED(save_p);
if (diff4 & SD_CYSCALE)
sectors[i].ceilingyscale = READFIXED(save_p);
if (diff & SD_FFLOORS) if (diff & SD_FFLOORS)
UnArchiveFFloors(&sectors[i]); UnArchiveFFloors(&sectors[i]);

View file

@ -1055,6 +1055,9 @@ static void P_LoadSectors(UINT8 *data)
ss->floorxoffset = ss->flooryoffset = 0; ss->floorxoffset = ss->flooryoffset = 0;
ss->ceilingxoffset = ss->ceilingyoffset = 0; ss->ceilingxoffset = ss->ceilingyoffset = 0;
ss->floorxscale = ss->flooryscale = FRACUNIT;
ss->ceilingxscale = ss->ceilingyscale = FRACUNIT;
ss->floorangle = ss->ceilingangle = 0; ss->floorangle = ss->ceilingangle = 0;
ss->floorlightlevel = ss->ceilinglightlevel = 0; ss->floorlightlevel = ss->ceilinglightlevel = 0;
@ -1696,6 +1699,14 @@ static void ParseTextmapSectorParameter(UINT32 i, const char *param, const char
sectors[i].ceilingxoffset = FLOAT_TO_FIXED(atof(val)); sectors[i].ceilingxoffset = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "ypanningceiling")) else if (fastcmp(param, "ypanningceiling"))
sectors[i].ceilingyoffset = FLOAT_TO_FIXED(atof(val)); sectors[i].ceilingyoffset = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "xscalefloor"))
sectors[i].floorxscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "yscalefloor"))
sectors[i].flooryscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "xscaleceiling"))
sectors[i].ceilingxscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "yscaleceiling"))
sectors[i].ceilingyscale = FLOAT_TO_FIXED(atof(val));
else if (fastcmp(param, "rotationfloor")) else if (fastcmp(param, "rotationfloor"))
sectors[i].floorangle = FixedAngle(FLOAT_TO_FIXED(atof(val))); sectors[i].floorangle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
else if (fastcmp(param, "rotationceiling")) else if (fastcmp(param, "rotationceiling"))
@ -2685,6 +2696,14 @@ static void P_WriteTextmap(void)
fprintf(f, "xpanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingxoffset)); fprintf(f, "xpanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingxoffset));
if (tempsec.ceilingyoffset != 0) if (tempsec.ceilingyoffset != 0)
fprintf(f, "ypanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingyoffset)); fprintf(f, "ypanningceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingyoffset));
if (tempsec.floorxscale != 0)
fprintf(f, "xscalefloor = %f;\n", FIXED_TO_FLOAT(tempsec.floorxscale));
if (tempsec.flooryscale != 0)
fprintf(f, "yscalefloor = %f;\n", FIXED_TO_FLOAT(tempsec.flooryscale));
if (tempsec.ceilingxscale != 0)
fprintf(f, "xscaleceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingxscale));
if (tempsec.ceilingyscale != 0)
fprintf(f, "yscaleceiling = %f;\n", FIXED_TO_FLOAT(tempsec.ceilingyscale));
if (wsectors[i].floorangle != 0) if (wsectors[i].floorangle != 0)
fprintf(f, "rotationfloor = %f;\n", FIXED_TO_FLOAT(AngleFixed(wsectors[i].floorangle))); fprintf(f, "rotationfloor = %f;\n", FIXED_TO_FLOAT(AngleFixed(wsectors[i].floorangle)));
if (wsectors[i].ceilingangle != 0) if (wsectors[i].ceilingangle != 0)
@ -2920,6 +2939,9 @@ static void P_LoadTextmap(void)
sc->floorxoffset = sc->flooryoffset = 0; sc->floorxoffset = sc->flooryoffset = 0;
sc->ceilingxoffset = sc->ceilingyoffset = 0; sc->ceilingxoffset = sc->ceilingyoffset = 0;
sc->floorxscale = sc->flooryscale = FRACUNIT;
sc->ceilingxscale = sc->ceilingyscale = FRACUNIT;
sc->floorangle = sc->ceilingangle = 0; sc->floorangle = sc->ceilingangle = 0;
sc->floorlightlevel = sc->ceilinglightlevel = 0; sc->floorlightlevel = sc->ceilinglightlevel = 0;

View file

@ -5605,6 +5605,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, I
fflr->bottompic = &sec2->floorpic; fflr->bottompic = &sec2->floorpic;
fflr->bottomxoffs = &sec2->floorxoffset; fflr->bottomxoffs = &sec2->floorxoffset;
fflr->bottomyoffs = &sec2->flooryoffset; fflr->bottomyoffs = &sec2->flooryoffset;
fflr->bottomxscale = &sec2->floorxscale;
fflr->bottomyscale = &sec2->flooryscale;
fflr->bottomangle = &sec2->floorangle; fflr->bottomangle = &sec2->floorangle;
// Add the ceiling // Add the ceiling
@ -5613,6 +5615,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, I
fflr->toplightlevel = &sec2->lightlevel; fflr->toplightlevel = &sec2->lightlevel;
fflr->topxoffs = &sec2->ceilingxoffset; fflr->topxoffs = &sec2->ceilingxoffset;
fflr->topyoffs = &sec2->ceilingyoffset; fflr->topyoffs = &sec2->ceilingyoffset;
fflr->topxscale = &sec2->ceilingxscale;
fflr->topyscale = &sec2->ceilingyscale;
fflr->topangle = &sec2->ceilingangle; fflr->topangle = &sec2->ceilingangle;
// Add slopes // Add slopes

View file

@ -277,6 +277,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = s->floorpic; tempsec->floorpic = s->floorpic;
tempsec->floorxoffset = s->floorxoffset; tempsec->floorxoffset = s->floorxoffset;
tempsec->flooryoffset = s->flooryoffset; tempsec->flooryoffset = s->flooryoffset;
tempsec->floorxscale = s->floorxscale;
tempsec->flooryscale = s->flooryscale;
tempsec->floorangle = s->floorangle; tempsec->floorangle = s->floorangle;
if (underwater) if (underwater)
@ -287,6 +289,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->ceilingpic = tempsec->floorpic; tempsec->ceilingpic = tempsec->floorpic;
tempsec->ceilingxoffset = tempsec->floorxoffset; tempsec->ceilingxoffset = tempsec->floorxoffset;
tempsec->ceilingyoffset = tempsec->flooryoffset; tempsec->ceilingyoffset = tempsec->flooryoffset;
tempsec->ceilingxscale = tempsec->floorxscale;
tempsec->ceilingyscale = tempsec->flooryscale;
tempsec->ceilingangle = tempsec->floorangle; tempsec->ceilingangle = tempsec->floorangle;
} }
else else
@ -294,6 +298,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->ceilingpic = s->ceilingpic; tempsec->ceilingpic = s->ceilingpic;
tempsec->ceilingxoffset = s->ceilingxoffset; tempsec->ceilingxoffset = s->ceilingxoffset;
tempsec->ceilingyoffset = s->ceilingyoffset; tempsec->ceilingyoffset = s->ceilingyoffset;
tempsec->ceilingxscale = s->ceilingxscale;
tempsec->ceilingyscale = s->ceilingyscale;
tempsec->ceilingangle = s->ceilingangle; tempsec->ceilingangle = s->ceilingangle;
} }
} }
@ -317,6 +323,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = tempsec->ceilingpic = s->ceilingpic; tempsec->floorpic = tempsec->ceilingpic = s->ceilingpic;
tempsec->floorxoffset = tempsec->ceilingxoffset = s->ceilingxoffset; tempsec->floorxoffset = tempsec->ceilingxoffset = s->ceilingxoffset;
tempsec->flooryoffset = tempsec->ceilingyoffset = s->ceilingyoffset; tempsec->flooryoffset = tempsec->ceilingyoffset = s->ceilingyoffset;
tempsec->floorxscale = tempsec->ceilingxscale = s->ceilingxscale;
tempsec->flooryscale = tempsec->ceilingyscale = s->ceilingyscale;
tempsec->floorangle = tempsec->ceilingangle = s->ceilingangle; tempsec->floorangle = tempsec->ceilingangle = s->ceilingangle;
if (s->floorpic == skyflatnum) // SKYFIX? if (s->floorpic == skyflatnum) // SKYFIX?
@ -325,6 +333,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = tempsec->ceilingpic; tempsec->floorpic = tempsec->ceilingpic;
tempsec->floorxoffset = tempsec->ceilingxoffset; tempsec->floorxoffset = tempsec->ceilingxoffset;
tempsec->flooryoffset = tempsec->ceilingyoffset; tempsec->flooryoffset = tempsec->ceilingyoffset;
tempsec->floorxscale = tempsec->ceilingxscale;
tempsec->flooryscale = tempsec->ceilingyscale;
tempsec->floorangle = tempsec->ceilingangle; tempsec->floorangle = tempsec->ceilingangle;
} }
else else
@ -333,6 +343,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
tempsec->floorpic = s->floorpic; tempsec->floorpic = s->floorpic;
tempsec->floorxoffset = s->floorxoffset; tempsec->floorxoffset = s->floorxoffset;
tempsec->flooryoffset = s->flooryoffset; tempsec->flooryoffset = s->flooryoffset;
tempsec->floorxscale = s->floorxscale;
tempsec->flooryscale = s->flooryscale;
tempsec->floorangle = s->floorangle; tempsec->floorangle = s->floorangle;
} }
@ -362,12 +374,16 @@ boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back)
&& back->c_slope == front->c_slope && back->c_slope == front->c_slope
&& back->lightlevel == front->lightlevel && back->lightlevel == front->lightlevel
&& !line->sidedef->midtexture && !line->sidedef->midtexture
// Check offsets too! // Check offsets and scale too!
&& back->floorxoffset == front->floorxoffset && back->floorxoffset == front->floorxoffset
&& back->flooryoffset == front->flooryoffset && back->flooryoffset == front->flooryoffset
&& back->floorxscale == front->floorxscale
&& back->flooryscale == front->flooryscale
&& back->floorangle == front->floorangle && back->floorangle == front->floorangle
&& back->ceilingxoffset == front->ceilingxoffset && back->ceilingxoffset == front->ceilingxoffset
&& back->ceilingyoffset == front->ceilingyoffset && back->ceilingyoffset == front->ceilingyoffset
&& back->ceilingxscale == front->ceilingxscale
&& back->ceilingyscale == front->ceilingyscale
&& back->ceilingangle == front->ceilingangle && back->ceilingangle == front->ceilingangle
// Consider altered lighting. // Consider altered lighting.
&& back->floorlightlevel == front->floorlightlevel && back->floorlightlevel == front->floorlightlevel
@ -909,7 +925,9 @@ static void R_Subsector(size_t num)
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum)) || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))
{ {
floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel, floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel,
frontsector->floorxoffset, frontsector->flooryoffset, frontsector->floorangle, floorcolormap, NULL, NULL, frontsector->f_slope); frontsector->floorxoffset, frontsector->flooryoffset,
frontsector->floorxscale, frontsector->flooryscale, frontsector->floorangle,
floorcolormap, NULL, NULL, frontsector->f_slope);
} }
else else
floorplane = NULL; floorplane = NULL;
@ -918,8 +936,9 @@ static void R_Subsector(size_t num)
|| frontsector->ceilingpic == skyflatnum || frontsector->ceilingpic == skyflatnum
|| (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum)) || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))
{ {
ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic, ceilingplane = R_FindPlane(frontsector->ceilingheight, frontsector->ceilingpic, ceilinglightlevel,
ceilinglightlevel, frontsector->ceilingxoffset, frontsector->ceilingyoffset, frontsector->ceilingangle, frontsector->ceilingxoffset, frontsector->ceilingyoffset,
frontsector->ceilingxscale, frontsector->ceilingyscale, frontsector->ceilingangle,
ceilingcolormap, NULL, NULL, frontsector->c_slope); ceilingcolormap, NULL, NULL, frontsector->c_slope);
} }
else else
@ -962,8 +981,9 @@ static void R_Subsector(size_t num)
viewz < heightcheck); viewz < heightcheck);
ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic,
*frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, *rover->bottomyoffs,
*rover->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->b_slope); *rover->bottomxscale, *rover->bottomyscale, *rover->bottomangle,
*frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->b_slope);
ffloor[numffloors].slope = *rover->b_slope; ffloor[numffloors].slope = *rover->b_slope;
@ -991,7 +1011,8 @@ static void R_Subsector(size_t num)
light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck); light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck);
ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic,
*frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs,
*rover->topxscale, *rover->topyscale, *rover->topangle,
*frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->t_slope); *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->t_slope);
ffloor[numffloors].slope = *rover->t_slope; ffloor[numffloors].slope = *rover->t_slope;
@ -1033,7 +1054,9 @@ static void R_Subsector(size_t num)
{ {
light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight);
ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic, ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic,
(light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->floorxoffset, polysec->flooryoffset, (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel),
polysec->floorxoffset, polysec->flooryoffset,
polysec->floorxscale, polysec->flooryscale,
polysec->floorangle-po->angle, polysec->floorangle-po->angle,
(light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po, (light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po,
NULL); // will ffloors be slopable eventually? NULL); // will ffloors be slopable eventually?
@ -1057,7 +1080,10 @@ static void R_Subsector(size_t num)
{ {
light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight);
ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic,
(light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceilingxoffset, polysec->ceilingyoffset, polysec->ceilingangle-po->angle, (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel),
polysec->ceilingxoffset, polysec->ceilingyoffset,
polysec->ceilingxscale, polysec->ceilingyscale,
polysec->ceilingangle-po->angle,
(light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po, (light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po,
NULL); // will ffloors be slopable eventually? NULL); // will ffloors be slopable eventually?

View file

@ -218,12 +218,16 @@ typedef struct ffloor_s
INT16 *toplightlevel; INT16 *toplightlevel;
fixed_t *topxoffs; fixed_t *topxoffs;
fixed_t *topyoffs; fixed_t *topyoffs;
fixed_t *topxscale;
fixed_t *topyscale;
angle_t *topangle; angle_t *topangle;
fixed_t *bottomheight; fixed_t *bottomheight;
INT32 *bottompic; INT32 *bottompic;
fixed_t *bottomxoffs; fixed_t *bottomxoffs;
fixed_t *bottomyoffs; fixed_t *bottomyoffs;
fixed_t *bottomxscale;
fixed_t *bottomyscale;
angle_t *bottomangle; angle_t *bottomangle;
// Pointers to pointers. Yup. // Pointers to pointers. Yup.
@ -429,6 +433,10 @@ typedef struct sector_s
fixed_t floorxoffset, flooryoffset; fixed_t floorxoffset, flooryoffset;
fixed_t ceilingxoffset, ceilingyoffset; fixed_t ceilingxoffset, ceilingyoffset;
// floor and ceiling texture scale
fixed_t floorxscale, flooryscale;
fixed_t ceilingxscale, ceilingyscale;
// flat angle // flat angle
angle_t floorangle; angle_t floorangle;
angle_t ceilingangle; angle_t ceilingangle;

View file

@ -83,11 +83,6 @@ static fixed_t planeheight;
fixed_t yslopetab[MAXVIDHEIGHT*16]; fixed_t yslopetab[MAXVIDHEIGHT*16];
fixed_t *yslope; fixed_t *yslope;
fixed_t cachedheight[MAXVIDHEIGHT];
fixed_t cacheddistance[MAXVIDHEIGHT];
fixed_t cachedxstep[MAXVIDHEIGHT];
fixed_t cachedystep[MAXVIDHEIGHT];
static fixed_t xoffs, yoffs; static fixed_t xoffs, yoffs;
static floatv3_t ds_slope_origin, ds_slope_u, ds_slope_v; static floatv3_t ds_slope_origin, ds_slope_u, ds_slope_v;
@ -159,37 +154,28 @@ static void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
planecos = FINECOSINE(angle); planecos = FINECOSINE(angle);
planesin = FINESINE(angle); planesin = FINESINE(angle);
if (planeheight != cachedheight[y]) // [RH] Notice that I dumped the caching scheme used by Doom.
{ // It did not offer any appreciable speedup.
cachedheight[y] = planeheight; distance = FixedMul(planeheight, yslope[y]);
cacheddistance[y] = distance = FixedMul(planeheight, yslope[y]);
span = abs(centery - y); span = abs(centery - y);
if (span) // Don't divide by zero if (span) // Don't divide by zero
{ {
ds_xstep = FixedMul(planesin, planeheight) / span; ds_xstep = FixedMul(planesin, planeheight) / span;
ds_ystep = FixedMul(planecos, planeheight) / span; ds_ystep = FixedMul(planecos, planeheight) / span;
ds_xstep = FixedMul(currentplane->xscale, ds_xstep);
ds_ystep = FixedMul(currentplane->yscale, ds_ystep);
} }
else else
ds_xstep = ds_ystep = FRACUNIT; ds_xstep = ds_ystep = FRACUNIT;
cachedxstep[y] = ds_xstep;
cachedystep[y] = ds_ystep;
}
else
{
distance = cacheddistance[y];
ds_xstep = cachedxstep[y];
ds_ystep = cachedystep[y];
}
// [RH] Instead of using the xtoviewangle array, I calculated the fractional values // [RH] Instead of using the xtoviewangle array, I calculated the fractional values
// at the middle of the screen, then used the calculated ds_xstep and ds_ystep // at the middle of the screen, then used the calculated ds_xstep and ds_ystep
// to step from those to the proper texture coordinate to start drawing at. // to step from those to the proper texture coordinate to start drawing at.
// That way, the texture coordinate is always calculated by its position // That way, the texture coordinate is always calculated by its position
// on the screen and not by its position relative to the edge of the visplane. // on the screen and not by its position relative to the edge of the visplane.
ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep; ds_xfrac = xoffs + FixedMul(currentplane->xscale, FixedMul(planecos, distance)) + (x1 - centerx) * ds_xstep;
ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep; ds_yfrac = yoffs - FixedMul(currentplane->yscale, FixedMul(planesin, distance)) + (x1 - centerx) * ds_ystep;
// Water ripple effect // Water ripple effect
if (planeripple.active) if (planeripple.active)
@ -275,10 +261,7 @@ static void R_MapFogPlane(INT32 y, INT32 x1, INT32 x2)
if (x1 >= vid.width) if (x1 >= vid.width)
x1 = vid.width - 1; x1 = vid.width - 1;
if (planeheight != cachedheight[y])
distance = FixedMul(planeheight, yslope[y]); distance = FixedMul(planeheight, yslope[y]);
else
distance = cacheddistance[y];
pindex = distance >> LIGHTZSHIFT; pindex = distance >> LIGHTZSHIFT;
if (pindex >= MAXLIGHTZ) if (pindex >= MAXLIGHTZ)
@ -361,9 +344,6 @@ void R_ClearPlanes(void)
{ {
freehead = &(*freehead)->next; freehead = &(*freehead)->next;
} }
// texture calculation
memset(cachedheight, 0, sizeof (cachedheight));
} }
static visplane_t *new_visplane(unsigned hash) static visplane_t *new_visplane(unsigned hash)
@ -391,7 +371,8 @@ static visplane_t *new_visplane(unsigned hash)
// If not, allocates another of them. // If not, allocates another of them.
// //
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap, fixed_t xoff, fixed_t yoff, fixed_t xscale, fixed_t yscale,
angle_t plangle, extracolormap_t *planecolormap,
ffloor_t *pfloor, polyobj_t *polyobj, pslope_t *slope) ffloor_t *pfloor, polyobj_t *polyobj, pslope_t *slope)
{ {
visplane_t *check; visplane_t *check;
@ -399,8 +380,9 @@ 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 if (!slope) // Don't mess with this right now if a slope is involved
{ {
xoff += viewx; xoff += FixedMul(viewx, xscale);
yoff -= viewy; yoff -= FixedMul(viewy, yscale);
if (plangle != 0) if (plangle != 0)
{ {
// Add the view offset, rotated by the plane angle. // Add the view offset, rotated by the plane angle.
@ -441,16 +423,16 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
hash = visplane_hash(picnum, lightlevel, height); hash = visplane_hash(picnum, lightlevel, height);
for (check = visplanes[hash]; check; check = check->next) for (check = visplanes[hash]; check; check = check->next)
{ {
if (polyobj != check->polyobj)
continue;
if (height == check->height && picnum == check->picnum if (height == check->height && picnum == check->picnum
&& lightlevel == check->lightlevel && lightlevel == check->lightlevel
&& xoff == check->xoffs && yoff == check->yoffs && xoff == check->xoffs && yoff == check->yoffs
&& xscale == check->xscale && yscale == check->yscale
&& planecolormap == check->extra_colormap && planecolormap == check->extra_colormap
&& check->viewx == viewx && check->viewy == viewy && check->viewz == viewz && check->viewx == viewx && check->viewy == viewy && check->viewz == viewz
&& check->viewangle == viewangle && check->viewangle == viewangle
&& check->plangle == plangle && check->plangle == plangle
&& check->slope == slope) && check->slope == slope
&& check->polyobj == polyobj)
{ {
return check; return check;
} }
@ -470,6 +452,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
check->maxx = -1; check->maxx = -1;
check->xoffs = xoff; check->xoffs = xoff;
check->yoffs = yoff; check->yoffs = yoff;
check->xscale = xscale;
check->yscale = yscale;
check->extra_colormap = planecolormap; check->extra_colormap = planecolormap;
check->ffloor = pfloor; check->ffloor = pfloor;
check->viewx = viewx; check->viewx = viewx;
@ -546,6 +530,8 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
new_pl->lightlevel = pl->lightlevel; new_pl->lightlevel = pl->lightlevel;
new_pl->xoffs = pl->xoffs; new_pl->xoffs = pl->xoffs;
new_pl->yoffs = pl->yoffs; new_pl->yoffs = pl->yoffs;
new_pl->xscale = pl->xscale;
new_pl->yscale = pl->yscale;
new_pl->extra_colormap = pl->extra_colormap; new_pl->extra_colormap = pl->extra_colormap;
new_pl->ffloor = pl->ffloor; new_pl->ffloor = pl->ffloor;
new_pl->viewx = pl->viewx; new_pl->viewx = pl->viewx;
@ -812,7 +798,16 @@ void R_SetTiltedSpan(INT32 span)
static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff) static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff)
{ {
R_SetTiltedSpan(y); R_SetTiltedSpan(y);
if (pl->xscale != FRACUNIT || pl->yscale != FRACUNIT)
{
R_SetScaledSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz,
FixedDiv(FRACUNIT, pl->xscale), FixedDiv(FRACUNIT, pl->yscale),
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); R_SetSlopePlane(pl->slope, pl->viewx, pl->viewy, pl->viewz, xoff, yoff, pl->viewangle, pl->plangle);
R_CalculateSlopeVectors(); R_CalculateSlopeVectors();
} }
@ -1000,13 +995,6 @@ void R_DrawSinglePlane(visplane_t *pl)
} }
} }
// Don't mess with angle on slopes! We'll handle this ourselves later
if (!pl->slope && viewangle != pl->viewangle+pl->plangle)
{
memset(cachedheight, 0, sizeof (cachedheight));
viewangle = pl->viewangle+pl->plangle;
}
mapfunc = R_MapPlane; mapfunc = R_MapPlane;
if (ds_solidcolor) if (ds_solidcolor)
@ -1043,7 +1031,7 @@ void R_DrawSinglePlane(visplane_t *pl)
{ {
mapfunc = R_MapTiltedPlane; mapfunc = R_MapTiltedPlane;
if (!pl->plangle && !ds_solidcolor) if (!pl->plangle && !ds_solidcolor && pl->xscale == FRACUNIT && pl->yscale == FRACUNIT)
{ {
if (ds_powersoftwo) if (ds_powersoftwo)
R_AdjustSlopeCoordinates(&pl->slope->o); R_AdjustSlopeCoordinates(&pl->slope->o);

View file

@ -49,6 +49,7 @@ typedef struct visplane_s
INT32 high, low; // R_PlaneBounds should set these. INT32 high, low; // R_PlaneBounds should set these.
fixed_t xoffs, yoffs; // Scrolling flats. fixed_t xoffs, yoffs; // Scrolling flats.
fixed_t xscale, yscale;
struct ffloor_s *ffloor; struct ffloor_s *ffloor;
polyobj_t *polyobj; polyobj_t *polyobj;
@ -62,10 +63,6 @@ extern visplane_t *ceilingplane;
// Visplane related. // Visplane related.
extern INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH]; extern INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH];
extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*16]; extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*16];
extern fixed_t cachedheight[MAXVIDHEIGHT];
extern fixed_t cacheddistance[MAXVIDHEIGHT];
extern fixed_t cachedxstep[MAXVIDHEIGHT];
extern fixed_t cachedystep[MAXVIDHEIGHT];
extern fixed_t *yslope; extern fixed_t *yslope;
extern lighttable_t **planezlight; extern lighttable_t **planezlight;
@ -75,8 +72,8 @@ void R_ClearPlanes(void);
void R_ClearFFloorClips (void); void R_ClearFFloorClips (void);
void R_DrawPlanes(void); void R_DrawPlanes(void);
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle, visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, fixed_t xscale, fixed_t yscale,
extracolormap_t *planecolormap, ffloor_t *ffloor, polyobj_t *polyobj, pslope_t *slope); angle_t plangle, extracolormap_t *planecolormap, ffloor_t *ffloor, polyobj_t *polyobj, pslope_t *slope);
visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop); visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop); void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_PlaneBounds(visplane_t *plane); void R_PlaneBounds(visplane_t *plane);

View file

@ -1981,6 +1981,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
//SoM: 3/22/2000: Check floor x and y offsets. //SoM: 3/22/2000: Check floor x and y offsets.
|| backsector->floorxoffset != frontsector->floorxoffset || backsector->floorxoffset != frontsector->floorxoffset
|| backsector->flooryoffset != frontsector->flooryoffset || backsector->flooryoffset != frontsector->flooryoffset
|| backsector->floorxscale != frontsector->floorxscale
|| backsector->flooryscale != frontsector->flooryscale
|| backsector->floorangle != frontsector->floorangle || backsector->floorangle != frontsector->floorangle
//SoM: 3/22/2000: Prevents bleeding. //SoM: 3/22/2000: Prevents bleeding.
|| (frontsector->heightsec != -1 && frontsector->floorpic != skyflatnum) || (frontsector->heightsec != -1 && frontsector->floorpic != skyflatnum)
@ -2014,6 +2016,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
//SoM: 3/22/2000: Check floor x and y offsets. //SoM: 3/22/2000: Check floor x and y offsets.
|| backsector->ceilingxoffset != frontsector->ceilingxoffset || backsector->ceilingxoffset != frontsector->ceilingxoffset
|| backsector->ceilingyoffset != frontsector->ceilingyoffset || backsector->ceilingyoffset != frontsector->ceilingyoffset
|| backsector->ceilingxscale != frontsector->ceilingxscale
|| backsector->ceilingyscale != frontsector->ceilingyscale
|| backsector->ceilingangle != frontsector->ceilingangle || backsector->ceilingangle != frontsector->ceilingangle
//SoM: 3/22/2000: Prevents bleeding. //SoM: 3/22/2000: Prevents bleeding.
|| (frontsector->heightsec != -1 && frontsector->ceilingpic != skyflatnum) || (frontsector->heightsec != -1 && frontsector->ceilingpic != skyflatnum)

View file

@ -391,8 +391,6 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
if (pSplat->angle) if (pSplat->angle)
{ {
memset(cachedheight, 0, sizeof(cachedheight));
// Add the view offset, rotated by the plane angle. // Add the view offset, rotated by the plane angle.
fixed_t a = -pSplat->verts[0].x + vis->viewpoint.x; fixed_t a = -pSplat->verts[0].x + vis->viewpoint.x;
fixed_t b = -pSplat->verts[0].y + vis->viewpoint.y; fixed_t b = -pSplat->verts[0].y + vis->viewpoint.y;
@ -547,10 +545,9 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
angle_t planecos = FINECOSINE(angle); angle_t planecos = FINECOSINE(angle);
angle_t planesin = FINESINE(angle); angle_t planesin = FINESINE(angle);
if (planeheight != cachedheight[y]) // [RH] Notice that I dumped the caching scheme used by Doom.
{ // It did not offer any appreciable speedup.
cachedheight[y] = planeheight; distance = FixedMul(planeheight, yslope[y]);
distance = cacheddistance[y] = FixedMul(planeheight, yslope[y]);
span = abs(centery - y); span = abs(centery - y);
if (span) // Don't divide by zero if (span) // Don't divide by zero
@ -561,16 +558,6 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
else else
xstep = ystep = FRACUNIT; xstep = ystep = FRACUNIT;
cachedxstep[y] = xstep;
cachedystep[y] = ystep;
}
else
{
distance = cacheddistance[y];
xstep = cachedxstep[y];
ystep = cachedystep[y];
}
ds_xstep = FixedDiv(xstep, pSplat->xscale); ds_xstep = FixedDiv(xstep, pSplat->xscale);
ds_ystep = FixedDiv(ystep, pSplat->yscale); ds_ystep = FixedDiv(ystep, pSplat->yscale);
@ -586,9 +573,6 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
rastertab[y].minx = INT32_MAX; rastertab[y].minx = INT32_MAX;
rastertab[y].maxx = INT32_MIN; rastertab[y].maxx = INT32_MIN;
} }
if (!ds_solidcolor && pSplat->angle && !pSplat->slope)
memset(cachedheight, 0, sizeof(cachedheight));
} }
static void prepare_rastertab(void) static void prepare_rastertab(void)