- use floats for wall panning offsets.

This commit is contained in:
Christoph Oelckers 2020-11-26 08:38:59 +01:00
parent 357199ecc1
commit 2cd3927613
18 changed files with 72 additions and 75 deletions

View File

@ -780,9 +780,9 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
pWall->shade = load.shade;
pWall->pal = load.pal;
pWall->xrepeat = load.xrepeat;
pWall->xpanning = load.xpanning;
pWall->xpan_ = load.xpanning;
pWall->yrepeat = load.yrepeat;
pWall->ypanning = load.ypanning;
pWall->ypan_ = load.ypanning;
if (wall[i].extra > 0)
{
@ -827,8 +827,8 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
pXWall->triggerVector = bitReader.readUnsigned(1);
pXWall->triggerTouch = bitReader.readUnsigned(1);
bitReader.readUnsigned(2);
pXWall->xpanFrac = bitReader.readUnsigned(8);
pXWall->ypanFrac = bitReader.readUnsigned(8);
pWall->xpan_ += bitReader.readUnsigned(8) / 256.f;
pWall->ypan_ += bitReader.readUnsigned(8) / 256.f;
pXWall->locked = bitReader.readUnsigned(1);
pXWall->dudeLockout = bitReader.readUnsigned(1);
bitReader.readUnsigned(4);

View File

@ -253,8 +253,6 @@ struct XWALL {
int8_t panXVel; // panX
int8_t panYVel; // panY
uint8_t key; // Key
uint8_t xpanFrac; // x panning frac
uint8_t ypanFrac; // y panning frac
};
struct MAPSIGNATURE {

View File

@ -558,7 +558,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
return 0;
nOffset = (nOffset*pWall->yrepeat) / 8;
nOffset += (nSizY*pWall->ypanning) / 256;
nOffset += int((nSizY*pWall->ypan_) / 256);
int nLength = approxDist(pWall->x - wall[pWall->point2].x, pWall->y - wall[pWall->point2].y);
int nHOffset;
if (pWall->cstat & 8)
@ -566,7 +566,7 @@ int VectorScan(spritetype *pSprite, int nOffset, int nZOffset, int dx, int dy, i
else
nHOffset = approxDist(gHitInfo.hitx - pWall->x, gHitInfo.hity - pWall->y);
nHOffset = pWall->xpanning + ((nHOffset*pWall->xrepeat) << 3) / nLength;
nHOffset = pWall->xpan() + ((nHOffset*pWall->xrepeat) << 3) / nLength;
nHOffset %= nSizX;
nOffset %= nSizY;
auto pData = tilePtr(nPicnum);

View File

@ -459,8 +459,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, XWALL& w, XWALL* d
("panxvel", w.panXVel, def->panXVel)
("panyvel", w.panYVel, def->panYVel)
("key", w.key, def->key)
("xpanfrac", w.xpanFrac, def->xpanFrac)
("ypanfrac", w.ypanFrac, def->ypanFrac)
.EndObject();
}
return arc;

View File

@ -1708,10 +1708,10 @@ void useObjResizer(XSPRITE* pXSource, short objType, int objIndex) {
wall[objIndex].yrepeat = ClipRange(pXSource->data2, 0, 255);
if (valueIsBetween(pXSource->data3, -1, 32767))
wall[objIndex].xpanning = ClipRange(pXSource->data3, 0, 255);
wall[objIndex].xpan_ = ClipRange(pXSource->data3, 0, 255);
if (valueIsBetween(pXSource->data4, -1, 65535))
wall[objIndex].ypanning = ClipRange(pXSource->data4, 0, 255);
wall[objIndex].ypan_ = ClipRange(pXSource->data4, 0, 255);
break;
}
@ -2573,9 +2573,9 @@ bool condCheckMixed(XSPRITE* pXCond, EVENT event, int cmpOp, bool PUSH) {
case 28: return (pObj->cstat & arg1);
case 29: return (pObj->hitag & arg1);
case 30: return condCmp(pObj->xrepeat, arg1, arg2, cmpOp);
case 31: return condCmp(pObj->xpanning, arg1, arg2, cmpOp);
case 31: return condCmp(pObj->xpan(), arg1, arg2, cmpOp);
case 32: return condCmp(pObj->yrepeat, arg1, arg2, cmpOp);
case 33: return condCmp(pObj->ypanning, arg1, arg2, cmpOp);
case 33: return condCmp(pObj->ypan(), arg1, arg2, cmpOp);
}
break;
}

View File

@ -319,14 +319,11 @@ void DoSectorPanning(void)
psy = mulscale16(psy, pXWall->busy);
}
int nTile = wall[nWall].picnum;
int px = (wall[nWall].xpanning<<8)+pXWall->xpanFrac;
int py = (wall[nWall].ypanning<<8)+pXWall->ypanFrac;
px += (psx << 2) / tileWidth(nTile);
py += (psy << 2) / tileHeight(nTile);
wall[nWall].xpanning = px>>8;
wall[nWall].ypanning = py>>8;
pXWall->xpanFrac = px&255;
pXWall->ypanFrac = py&255;
int px = (psx << 2) / tileWidth(nTile);
int py = (psy << 2) / tileHeight(nTile);
wall[nWall].addxpan(px * (1. / 256));
wall[nWall].addypan(py * (1. / 256));
}
}
}

View File

@ -80,12 +80,18 @@ struct walltype
uint16_t cstat;
int16_t picnum, overpicnum;
int8_t shade;
uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
uint8_t pal, xrepeat, yrepeat;
union {
int16_t lotag, type;
};
int16_t hitag;
int16_t extra;
float xpan_, ypan_;
int xpan() const { return int(xpan_); }
int ypan() const { return int(ypan_); }
void addxpan(float add) { xpan_ = fmod(xpan_ + add + 512, 256); } // +512 is for handling negative offsets
void addypan(float add) { ypan_ = fmod(ypan_ + add + 512, 256); } // +512 is for handling negative offsets
#if 0
// make sure we do not accidentally copy this

View File

@ -1163,7 +1163,7 @@ static void polymost_internal_nonparallaxed(vec2f_t n0, vec2f_t n1, float ryp0,
}
static void calc_ypanning(int32_t refposz, float ryp0, float ryp1,
float x0, float x1, uint8_t ypan, uint8_t yrepeat,
float x0, float x1, float ypan, uint8_t yrepeat,
int32_t dopancor, const vec2_16_t &tilesize)
{
float const t0 = ((float)(refposz-globalposz))*ryp0 + ghoriz;
@ -1331,7 +1331,7 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i
}
int const npot = (1<<(widthBits(globalpicnum))) != tileWidth(globalpicnum);
int const xpanning = (hw_parallaxskypanning?global_cf_xpanning:0);
int const xPanning = (hw_parallaxskypanning?global_cf_xpanning:0);
int picnumbak = globalpicnum;
ti = globalpicnum;
@ -1350,10 +1350,10 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i
{
fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
int tang = (y<<(11-dapskybits))&2047;
otex.u = otex.d*(t*((float)(tang)) * (1.f/2048.f) + xpanning) - xtex.u*fx;
otex.u = otex.d*(t*((float)(tang)) * (1.f/2048.f) + xPanning) - xtex.u*fx;
}
else
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + xpanning) - xtex.u*ghalfx;
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + xPanning) - xtex.u*ghalfx;
y++;
o.x = fx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
@ -2055,8 +2055,8 @@ static void polymost_drawalls(int32_t const bunch)
xtex.u = (t0*ryp0 - t1*ryp1)*gxyaspect*(float)wal->xrepeat*8.f / (x0-x1);
otex.u = t0*ryp0*gxyaspect*wal->xrepeat*8.0 - xtex.u*x0;
otex.u += (float)wal->xpanning*otex.d;
xtex.u += (float)wal->xpanning*xtex.d;
otex.u += (float)wal->xpan_*otex.d;
xtex.u += (float)wal->xpan_*xtex.d;
ytex.u = 0;
float const ogux = xtex.u, oguy = ytex.u, oguo = otex.u;
@ -2085,11 +2085,11 @@ static void polymost_drawalls(int32_t const bunch)
int i = (!(wal->cstat&4)) ? sector[nextsectnum].ceilingz : sec->ceilingz;
// over
calc_ypanning(i, ryp0, ryp1, x0, x1, wal->ypanning, wal->yrepeat, wal->cstat&4, tileSize(globalpicnum));
calc_ypanning(i, ryp0, ryp1, x0, x1, wal->ypan_, wal->yrepeat, wal->cstat&4, tileSize(globalpicnum));
if (wal->cstat&8) //xflip
{
float const t = (float)(wal->xrepeat*8 + wal->xpanning*2);
float const t = (float)(wal->xrepeat*8 + wal->xpan_*2);
xtex.u = xtex.d*t - xtex.u;
ytex.u = ytex.d*t - ytex.u;
otex.u = otex.d*t - otex.u;
@ -2108,9 +2108,9 @@ static void polymost_drawalls(int32_t const bunch)
else
{
nwal = (uwallptr_t)&wall[wal->nextwall];
otex.u += (float)(nwal->xpanning - wal->xpanning) * otex.d;
xtex.u += (float)(nwal->xpanning - wal->xpanning) * xtex.d;
ytex.u += (float)(nwal->xpanning - wal->xpanning) * ytex.d;
otex.u += (float)(nwal->xpan_ - wal->xpan_) * otex.d;
xtex.u += (float)(nwal->xpan_ - wal->xpan_) * xtex.d;
ytex.u += (float)(nwal->xpan_ - wal->xpan_) * ytex.d;
}
globalpicnum = nwal->picnum; globalshade = nwal->shade; globalfloorpal = globalpal = (int32_t)((uint8_t)nwal->pal);
GLInterface.SetVisibility(sectorVisibility(sectnum));
@ -2120,11 +2120,11 @@ static void polymost_drawalls(int32_t const bunch)
int i = (!(nwal->cstat&4)) ? sector[nextsectnum].floorz : sec->ceilingz;
// under
calc_ypanning(i, ryp0, ryp1, x0, x1, nwal->ypanning, wal->yrepeat, !(nwal->cstat&4), tileSize(globalpicnum));
calc_ypanning(i, ryp0, ryp1, x0, x1, nwal->ypan_, wal->yrepeat, !(nwal->cstat&4), tileSize(globalpicnum));
if (wal->cstat&8) //xflip
{
float const t = (float)(wal->xrepeat*8 + nwal->xpanning*2);
float const t = (float)(wal->xrepeat*8 + nwal->xpan_*2);
xtex.u = xtex.d*t - xtex.u;
ytex.u = ytex.d*t - ytex.u;
otex.u = otex.d*t - otex.u;
@ -2165,11 +2165,11 @@ static void polymost_drawalls(int32_t const bunch)
else { i = nwcs4 ? sec->ceilingz : sec->floorz; }
// white / 1-way
calc_ypanning(i, ryp0, ryp1, x0, x1, wal->ypanning, wal->yrepeat, nwcs4 && !maskingOneWay, tileSize(globalpicnum));
calc_ypanning(i, ryp0, ryp1, x0, x1, wal->ypan_, wal->yrepeat, nwcs4 && !maskingOneWay, tileSize(globalpicnum));
if (wal->cstat&8) //xflip
{
float const t = (float) (wal->xrepeat*8 + wal->xpanning*2);
float const t = (float) (wal->xrepeat*8 + wal->xpan_*2);
xtex.u = xtex.d*t - xtex.u;
ytex.u = ytex.d*t - ytex.u;
otex.u = otex.d*t - otex.u;
@ -2729,17 +2729,17 @@ static void polymost_drawmaskwallinternal(int32_t wallIndex)
//gux*x1 + guo = t1*wal->xrepeat*8*yp1
xtex.u = (t0*ryp0 - t1*ryp1)*gxyaspect*(float)wal->xrepeat*8.f / (x0-x1);
otex.u = t0*ryp0*gxyaspect*(float)wal->xrepeat*8.f - xtex.u*x0;
otex.u += (float)wal->xpanning*otex.d;
xtex.u += (float)wal->xpanning*xtex.d;
otex.u += (float)wal->xpan_*otex.d;
xtex.u += (float)wal->xpan_*xtex.d;
ytex.u = 0;
// mask
calc_ypanning((!(wal->cstat & 4)) ? max(nsec->ceilingz, sec->ceilingz) : min(nsec->floorz, sec->floorz), ryp0, ryp1,
x0, x1, wal->ypanning, wal->yrepeat, 0, tileSize(globalpicnum));
x0, x1, wal->ypan_, wal->yrepeat, 0, tileSize(globalpicnum));
if (wal->cstat&8) //xflip
{
float const t = (float)(wal->xrepeat*8 + wal->xpanning*2);
float const t = (float)(wal->xrepeat*8 + wal->xpan_*2);
xtex.u = xtex.d*t - xtex.u;
ytex.u = ytex.d*t - ytex.u;
otex.u = otex.d*t - otex.u;

View File

@ -23,6 +23,7 @@ enum EInterpolationType
void StartInterpolation(int index, int type);
void StopInterpolation(int index, int type);
void UpdateInterpolations();
void ClearInterpolations();
void DoInterpolations(double smoothratio);
void RestoreInterpolations();
void SerializeInterpolations(FSerializer& arc);

View File

@ -139,8 +139,8 @@ static void ReadWallV7(FileReader& fr, walltype& wall)
wall.pal = fr.ReadUInt8();
wall.xrepeat = fr.ReadUInt8();
wall.yrepeat = fr.ReadUInt8();
wall.xpanning = fr.ReadUInt8();
wall.ypanning = fr.ReadUInt8();
wall.xpan_ = fr.ReadUInt8();
wall.ypan_ = fr.ReadUInt8();
wall.lotag = fr.ReadInt16();
wall.hitag = fr.ReadInt16();
wall.extra = fr.ReadInt16();
@ -160,8 +160,8 @@ static void ReadWallV6(FileReader& fr, walltype& wall)
wall.cstat = fr.ReadUInt16();
wall.xrepeat = fr.ReadUInt8();
wall.yrepeat = fr.ReadUInt8();
wall.xpanning = fr.ReadUInt8();
wall.ypanning = fr.ReadUInt8();
wall.xpan_ = fr.ReadUInt8();
wall.ypan_ = fr.ReadUInt8();
wall.lotag = fr.ReadInt16();
wall.hitag = fr.ReadInt16();
wall.extra = fr.ReadInt16();
@ -178,8 +178,8 @@ static void ReadWallV5(FileReader& fr, walltype& wall)
wall.cstat = fr.ReadUInt16();
wall.xrepeat = fr.ReadUInt8();
wall.yrepeat = fr.ReadUInt8();
wall.xpanning = fr.ReadUInt8();
wall.ypanning = fr.ReadUInt8();
wall.xpan_ = fr.ReadUInt8();
wall.ypan_ = fr.ReadUInt8();
wall.nextsector = fr.ReadInt16();
wall.nextwall = fr.ReadInt16();

View File

@ -574,8 +574,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, walltype &c, walltype
("pal", c.pal, def->pal)
("xrepeat", c.xrepeat, def->xrepeat)
("yrepeat", c.yrepeat, def->yrepeat)
("xpanning", c.xpanning, def->xpanning)
("ypanning", c.ypanning, def->ypanning)
("xpanning", c.xpan_, def->xpan_)
("ypanning", c.ypan_, def->ypan_)
("lotag", c.lotag, def->lotag)
("hitag", c.hitag, def->hitag)
("extra", c.extra, def->extra)

View File

@ -697,8 +697,8 @@ void DoFlows()
{
short nWall = sFlowInfo[i].field_0;
wall[nWall].xpanning = sFlowInfo[i].field_4 >> 14;
wall[nWall].ypanning = sFlowInfo[i].field_8 >> 14;
wall[nWall].addxpan(sFlowInfo[i].field_4 / 16384.f);
wall[nWall].addypan(sFlowInfo[i].field_8 / 16384.f);
if (sFlowInfo[i].field_4 < 0)
{
@ -717,8 +717,8 @@ void DoFlows()
{
short nWall = sFlowInfo[i].field_0;
wall[nWall].xpanning = sFlowInfo[i].field_4 >> 14;
wall[nWall].ypanning = sFlowInfo[i].field_8 >> 14;
wall[nWall].addxpan(sFlowInfo[i].field_4 / 16384.f);
wall[nWall].addypan(sFlowInfo[i].field_8 / 16384.f);
if (sFlowInfo[i].field_4 >= sFlowInfo[i].field_14)
{

View File

@ -4175,8 +4175,8 @@ void destroyit(DDukeActor *actor)
wall[wi].shade = wall[wj].shade;
wall[wi].xrepeat = wall[wj].xrepeat;
wall[wi].yrepeat = wall[wj].yrepeat;
wall[wi].xpanning = wall[wj].xpanning;
wall[wi].ypanning = wall[wj].ypanning;
wall[wi].xpan_ = wall[wj].xpan_;
wall[wi].ypan_ = wall[wj].ypan_;
if (isRRRA() && wall[wi].nextwall != -1)
{
wall[wi].cstat = 0;

View File

@ -993,12 +993,12 @@ void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, s
else SetGameVarID((int)lVar2, wall[iWall].yrepeat, sActor, sPlayer);
break;
case WALL_XPANNING:
if (bSet) wall[iWall].xpanning = lValue;
else SetGameVarID((int)lVar2, wall[iWall].xpanning, sActor, sPlayer);
if (bSet) wall[iWall].xpan_ = lValue;
else SetGameVarID((int)lVar2, wall[iWall].xpan(), sActor, sPlayer);
break;
case WALL_YPANNING:
if (bSet) wall[iWall].ypanning = lValue;
else SetGameVarID((int)lVar2, wall[iWall].ypanning, sActor, sPlayer);
if (bSet) wall[iWall].ypan_ = lValue;
else SetGameVarID((int)lVar2, wall[iWall].ypan(), sActor, sPlayer);
break;
case WALL_LOTAG:
if (bSet) wall[iWall].lotag = lValue;

View File

@ -149,8 +149,8 @@ void animatewalls_d(void)
if (wall[i].cstat & 254)
{
wall[i].xpanning -= t >> 10; // bcos(t, -12);
wall[i].ypanning -= t >> 10; // bsin(t, -12);
wall[i].addxpan(-t / 4096.f); // bcos(t, -12);
wall[i].addypan(-t / 4096.f); // bsin(t, -12);
if (wall[i].extra == 1)
{

View File

@ -204,9 +204,9 @@ void animatewalls_r(void)
for (i = 0; i < MAXWALLS; i++)
{
if (wall[i].picnum == RRTILE7873)
wall[i].xpanning += 6;
wall[i].addxpan(6);
else if (wall[i].picnum == RRTILE7870)
wall[i].xpanning += 6;
wall[i].addxpan(6);
}
}
@ -264,8 +264,8 @@ void animatewalls_r(void)
if (wall[i].cstat & 254)
{
wall[i].xpanning -= t >> 10; // bcos(t, -12);
wall[i].ypanning -= t >> 10; // bsin(t, -12);
wall[i].addxpan(-t / 4096.f); // bcos(t, -12);
wall[i].addypan(-t / 4096.f); // bsin(t, -12);
if (wall[i].extra == 1)
{

View File

@ -60,8 +60,8 @@ void CopySectorWalls(short dest_sectnum, short src_sectnum)
wall[dest_wall_num].pal = wall[src_wall_num].pal;
wall[dest_wall_num].cstat = wall[src_wall_num].cstat;
wall[dest_wall_num].shade = wall[src_wall_num].shade;
wall[dest_wall_num].xpanning = wall[src_wall_num].xpanning;
wall[dest_wall_num].ypanning = wall[src_wall_num].ypanning;
wall[dest_wall_num].xpan_ = wall[src_wall_num].xpan_;
wall[dest_wall_num].ypan_ = wall[src_wall_num].ypan_;
wall[dest_wall_num].hitag = wall[src_wall_num].hitag;
wall[dest_wall_num].lotag = wall[src_wall_num].lotag;
wall[dest_wall_num].extra = wall[src_wall_num].extra;
@ -78,8 +78,8 @@ void CopySectorWalls(short dest_sectnum, short src_sectnum)
wall[dest_nextwall].pal = wall[src_nextwall].pal;
wall[dest_nextwall].cstat = wall[src_nextwall].cstat;
wall[dest_nextwall].shade = wall[src_nextwall].shade;
wall[dest_nextwall].xpanning = wall[src_nextwall].xpanning;
wall[dest_nextwall].ypanning = wall[src_nextwall].ypanning;
wall[dest_nextwall].xpan_ = wall[src_nextwall].xpan_;
wall[dest_nextwall].ypan_ = wall[src_nextwall].ypan_;
wall[dest_nextwall].hitag = wall[src_nextwall].hitag;
wall[dest_nextwall].lotag = wall[src_nextwall].lotag;
wall[dest_nextwall].extra = wall[src_nextwall].extra;

View File

@ -3236,11 +3236,8 @@ DoPanning(void)
nx = mulscale20(sp->xvel, bcos(sp->ang));
ny = mulscale20(sp->xvel, bsin(sp->ang));
wallp->xpanning += nx;
wallp->ypanning += ny;
wallp->xpanning &= 255;
wallp->ypanning &= 255;
wallp->addxpan(nx);
wallp->addypan(ny);
}
}