- make sector panning variables floats and added some convenience wrappers.

This commit is contained in:
Christoph Oelckers 2020-11-25 20:52:06 +01:00
parent 82d80f3f07
commit d545eb7aa9
17 changed files with 96 additions and 99 deletions

View file

@ -647,12 +647,12 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
pSector->extra = LittleShort(load.extra);
pSector->ceilingshade = load.ceilingshade;
pSector->ceilingpal = load.ceilingpal;
pSector->ceilingxpanning = load.ceilingxpanning;
pSector->ceilingypanning = load.ceilingypanning;
pSector->ceilingxpan_ = load.ceilingxpanning;
pSector->ceilingypan_ = load.ceilingypanning;
pSector->floorshade = load.floorshade;
pSector->floorpal = load.floorpal;
pSector->floorxpanning = load.floorxpanning;
pSector->floorypanning = load.floorypanning;
pSector->floorxpan_ = load.floorxpanning;
pSector->floorypan_ = load.floorypanning;
pSector->visibility = load.visibility;
qsector_filler[i] = load.fogpal;
pSector->fogpal = 0;
@ -734,12 +734,12 @@ void dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, shor
pXSector->marker0 = bitReader.readUnsigned(16);
pXSector->marker1 = bitReader.readUnsigned(16);
pXSector->Crush = bitReader.readUnsigned(1);
pXSector->ceilXPanFrac = bitReader.readUnsigned(8);
pXSector->ceilYPanFrac = bitReader.readUnsigned(8);
pXSector->floorXPanFrac = bitReader.readUnsigned(8);
pSector->ceilingxpan_ += bitReader.readUnsigned(8) / 256.f;
pSector->ceilingypan_ += bitReader.readUnsigned(8) / 256.f;
pSector->floorxpan_ += bitReader.readUnsigned(8) / 256.f;
pXSector->damageType = bitReader.readUnsigned(3);
pXSector->floorpal = bitReader.readUnsigned(4);
pXSector->floorYPanFrac = bitReader.readUnsigned(8);
pSector->floorypan_ = bitReader.readUnsigned(8) / 256.f;
pXSector->locked = bitReader.readUnsigned(1);
pXSector->windVel = bitReader.readUnsigned(10);
pXSector->windAng = bitReader.readUnsigned(11);

View file

@ -213,12 +213,8 @@ struct XSECTOR {
uint8_t Depth; // Depth
uint8_t Key; // Key
uint8_t ceilpal; // Ceil pal2
uint8_t ceilXPanFrac; // Ceiling x panning frac
uint8_t ceilYPanFrac; // Ceiling y panning frac
uint8_t floorXPanFrac; // Floor x panning frac
uint8_t damageType; // DamageType
uint8_t floorpal; // Floor pal2
uint8_t floorYPanFrac; // Floor y panning frac
uint8_t bobZRange; // Motion Z range
};

View file

@ -510,10 +510,6 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, XSECTOR& w, XSECTO
("depth", w.Depth, def->Depth)
("key", w.Key, def->Key)
("ceilpal", w.ceilpal, def->ceilpal)
("ceilxpanfrac", w.ceilXPanFrac, def->ceilXPanFrac)
("ceilypanfrac", w.ceilYPanFrac, def->ceilYPanFrac)
("floorxpanfrac", w.floorXPanFrac, def->floorXPanFrac)
("floorypanfrac", w.floorYPanFrac, def->floorYPanFrac)
("floorpal", w.floorpal, def->floorpal)
("damagetype", w.damageType, def->damageType)
("bobzrange", w.bobZRange, def->bobZRange)

View file

@ -1648,16 +1648,16 @@ void useObjResizer(XSPRITE* pXSource, short objType, int objIndex) {
// for sectors
case 6:
if (valueIsBetween(pXSource->data1, -1, 32767))
sector[objIndex].floorxpanning = ClipRange(pXSource->data1, 0, 255);
sector[objIndex].floorxpan_ = ClipRange(pXSource->data1, 0, 255);
if (valueIsBetween(pXSource->data2, -1, 32767))
sector[objIndex].floorypanning = ClipRange(pXSource->data2, 0, 255);
sector[objIndex].floorypan_ = ClipRange(pXSource->data2, 0, 255);
if (valueIsBetween(pXSource->data3, -1, 32767))
sector[objIndex].ceilingxpanning = ClipRange(pXSource->data3, 0, 255);
sector[objIndex].ceilingxpan_ = ClipRange(pXSource->data3, 0, 255);
if (valueIsBetween(pXSource->data4, -1, 65535))
sector[objIndex].ceilingypanning = ClipRange(pXSource->data4, 0, 255);
sector[objIndex].ceilingypan_ = ClipRange(pXSource->data4, 0, 255);
break;
// for sprites
case 3:
@ -2627,10 +2627,10 @@ bool condCheckMixed(XSPRITE* pXCond, EVENT event, int cmpOp, bool PUSH) {
}
break;
case 29: return (pObj->hitag & arg1);
case 30: return condCmp(pObj->floorxpanning, arg1, arg2, cmpOp);
case 31: return condCmp(pObj->ceilingxpanning, arg1, arg2, cmpOp);
case 32: return condCmp(pObj->floorypanning, arg1, arg2, cmpOp);
case 33: return condCmp(pObj->ceilingypanning, arg1, arg2, cmpOp);
case 30: return condCmp(pObj->floorxpan(), arg1, arg2, cmpOp);
case 31: return condCmp(pObj->ceilingxpan(), arg1, arg2, cmpOp);
case 32: return condCmp(pObj->floorypan(), arg1, arg2, cmpOp);
case 33: return condCmp(pObj->ceilingypan(), arg1, arg2, cmpOp);
}
break;
}

View file

@ -280,34 +280,26 @@ void DoSectorPanning(void)
if (pXSector->panFloor) // Floor
{
int nTile = pSector->floorpicnum;
int px = (pSector->floorxpanning << 8) + pXSector->floorXPanFrac;
int py = (pSector->floorypanning << 8) + pXSector->floorYPanFrac;
if (pSector->floorstat & 64)
angle -= 512;
int xBits = tileWidth(nTile) >> int((pSector->floorstat & 8) != 0);
px += mulscale30(speed << 2, Cos(angle)) / xBits;
int px = mulscale30(speed << 2, Cos(angle)) / xBits;
int yBits = tileHeight(nTile) >> int((pSector->floorstat & 8) != 0);
py -= mulscale30(speed << 2, Sin(angle)) / yBits;
pSector->floorxpanning = px >> 8;
pSector->floorypanning = py >> 8;
pXSector->floorXPanFrac = px & 255;
pXSector->floorYPanFrac = py & 255;
int py = mulscale30(speed << 2, Sin(angle)) / yBits;
pSector->addfloorxpan(px * (1. / 256));
pSector->addfloorypan(-py * (1. / 256));
}
if (pXSector->panCeiling) // Ceiling
{
int nTile = pSector->ceilingpicnum;
int px = (pSector->ceilingxpanning << 8) + pXSector->ceilXPanFrac;
int py = (pSector->ceilingypanning << 8) + pXSector->ceilYPanFrac;
if (pSector->ceilingstat & 64)
angle -= 512;
int xBits = tileWidth(nTile) >> int((pSector->floorstat & 8) != 0);
px += mulscale30(speed << 2, Cos(angle)) / xBits;
int yBits = tileHeight(nTile) >> int((pSector->floorstat & 8) != 0);
py -= mulscale30(speed << 2, Sin(angle)) / yBits;
pSector->ceilingxpanning = px >> 8;
pSector->ceilingypanning = py >> 8;
pXSector->ceilXPanFrac = px & 255;
pXSector->ceilYPanFrac = py & 255;
int xBits = tileWidth(nTile) >> int((pSector->ceilingstat & 8) != 0);
int px = mulscale30(speed << 2, Cos(angle)) / xBits;
int yBits = tileHeight(nTile) >> int((pSector->ceilingstat & 8) != 0);
int py = mulscale30(speed << 2, Sin(angle)) / yBits;
pSector->addceilingxpan(px * (1. / 256));
pSector->addceilingypan(-py * (1. / 256));
}
}
}

View file

@ -29,16 +29,27 @@ struct sectortype
uint16_t ceilingstat, floorstat;
int16_t ceilingpicnum, ceilingheinum;
int8_t ceilingshade;
uint8_t ceilingpal, /*CM_FLOORZ:*/ ceilingxpanning, ceilingypanning;
uint8_t ceilingpal; /*CM_FLOORZ:*/
int16_t floorpicnum, floorheinum;
int8_t floorshade;
uint8_t floorpal, floorxpanning, floorypanning;
uint8_t floorpal;;
uint8_t /*CM_CEILINGZ:*/ visibility, fogpal;
union {
int16_t lotag, type;
};
int16_t hitag;
int16_t extra;
float ceilingxpan_, ceilingypan_, floorxpan_, floorypan_;
int ceilingxpan() const { return int(ceilingxpan_); }
int ceilingypan() const { return int(ceilingypan_); }
int floorxpan() const { return int(floorxpan_); }
int floorypan() const { return int(floorypan_); }
void addfloorxpan(float add) { floorxpan_ = fmod(floorxpan_ + add + 512, 256); } // +512 is for handling negative offsets
void addfloorypan(float add) { floorypan_ = fmod(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets
void addceilingxpan(float add) { ceilingxpan_ = fmod(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets
void addceilingypan(float add) { ceilingypan_ = fmod(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets
};
//cstat:

View file

@ -1749,8 +1749,8 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
asm2 = (globalx2<<globalyshift);
globalx1 <<= globalxshift;
globaly2 <<= globalyshift;
set_globalpos(((int64_t) globalposx<<(20+globalxshift))+(((uint32_t) sec->floorxpanning)<<24),
((int64_t) globalposy<<(20+globalyshift))-(((uint32_t) sec->floorypanning)<<24),
set_globalpos(((int64_t) globalposx<<(20+globalxshift))+(((uint32_t) sec->floorxpan())<<24),
((int64_t) globalposy<<(20+globalyshift))-(((uint32_t) sec->floorypan())<<24),
globalposz);
renderFillPolygon(npoints);
}

View file

@ -1578,7 +1578,9 @@ static void polymost_drawalls(int32_t const bunch)
global_cf_fogpal = sec->fogpal;
global_cf_shade = sec->floorshade, global_cf_pal = sec->floorpal; global_cf_z = sec->floorz; // REFACT
global_cf_xpanning = sec->floorxpanning; global_cf_ypanning = sec->floorypanning, global_cf_heinum = sec->floorheinum;
global_cf_xpanning = sec->floorxpan_;
global_cf_ypanning = sec->floorypan_;
global_cf_heinum = sec->floorheinum;
global_getzofslope_func = &fgetflorzofslope;
if (globalpicnum >= r_rortexture && globalpicnum < r_rortexture + r_rortexturerange && r_rorphase == 0)
@ -1818,7 +1820,9 @@ static void polymost_drawalls(int32_t const bunch)
global_cf_fogpal = sec->fogpal;
global_cf_shade = sec->ceilingshade, global_cf_pal = sec->ceilingpal; global_cf_z = sec->ceilingz; // REFACT
global_cf_xpanning = sec->ceilingxpanning; global_cf_ypanning = sec->ceilingypanning, global_cf_heinum = sec->ceilingheinum;
global_cf_xpanning = sec->ceilingxpan_;
global_cf_ypanning = sec->ceilingypan_,
global_cf_heinum = sec->ceilingheinum;
global_getzofslope_func = &fgetceilzofslope;
if (globalpicnum >= r_rortexture && globalpicnum < r_rortexture + r_rortexturerange && r_rorphase == 0)

View file

@ -55,14 +55,14 @@ static void ReadSectorV7(FileReader& fr, sectortype& sect)
sect.ceilingheinum = fr.ReadUInt16();
sect.ceilingshade = fr.ReadInt8();
sect.ceilingpal = fr.ReadUInt8();
sect.ceilingxpanning = fr.ReadUInt8();
sect.ceilingypanning = fr.ReadUInt8();
sect.ceilingxpan_ = fr.ReadUInt8();
sect.ceilingypan_ = fr.ReadUInt8();
sect.floorpicnum = fr.ReadUInt16();
sect.floorheinum = fr.ReadUInt16();
sect.floorshade = fr.ReadInt8();
sect.floorpal = fr.ReadUInt8();
sect.floorxpanning = fr.ReadUInt8();
sect.floorypanning = fr.ReadUInt8();
sect.floorxpan_ = fr.ReadUInt8();
sect.floorypan_ = fr.ReadUInt8();
sect.visibility = fr.ReadUInt8();
sect.fogpal = fr.ReadUInt8(); // note: currently unused, except for Blood.
sect.lotag = fr.ReadInt16();
@ -82,10 +82,10 @@ static void ReadSectorV6(FileReader& fr, sectortype& sect)
sect.floorz = fr.ReadInt32();
sect.ceilingshade = fr.ReadInt8();
sect.floorshade = fr.ReadInt8();
sect.ceilingxpanning = fr.ReadUInt8();
sect.floorxpanning = fr.ReadUInt8();
sect.ceilingypanning = fr.ReadUInt8();
sect.floorypanning = fr.ReadUInt8();
sect.ceilingxpan_ = fr.ReadUInt8();
sect.floorxpan_ = fr.ReadUInt8();
sect.ceilingypan_ = fr.ReadUInt8();
sect.floorypan_ = fr.ReadUInt8();
sect.ceilingstat = fr.ReadUInt8();
sect.floorstat = fr.ReadUInt8();
sect.ceilingpal = fr.ReadUInt8();
@ -109,10 +109,10 @@ static void ReadSectorV5(FileReader& fr, sectortype& sect)
sect.floorz = fr.ReadInt32();
sect.ceilingshade = fr.ReadInt8();
sect.floorshade = fr.ReadInt8();
sect.ceilingxpanning = fr.ReadUInt8();
sect.floorxpanning = fr.ReadUInt8();
sect.ceilingypanning = fr.ReadUInt8();
sect.floorypanning = fr.ReadUInt8();
sect.ceilingxpan_ = fr.ReadUInt8();
sect.floorxpan_ = fr.ReadUInt8();
sect.ceilingypan_ = fr.ReadUInt8();
sect.floorypan_ = fr.ReadUInt8();
sect.ceilingstat = fr.ReadUInt8();
sect.floorstat = fr.ReadUInt8();
sect.ceilingpal = fr.ReadUInt8();

View file

@ -539,14 +539,14 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort
("ceilingheinum", c.ceilingheinum, def->ceilingheinum)
("ceilingshade", c.ceilingshade, def->ceilingshade)
("ceilingpal", c.ceilingpal, def->ceilingpal)
("ceilingxpanning", c.ceilingxpanning, def->ceilingxpanning)
("ceilingypanning", c.ceilingypanning, def->ceilingypanning)
("ceilingxpanning", c.ceilingxpan_, def->ceilingxpan_)
("ceilingypanning", c.ceilingypan_, def->ceilingypan_)
("floorpicnum", c.floorpicnum, def->floorpicnum)
("floorheinum", c.floorheinum, def->floorheinum)
("floorshade", c.floorshade, def->floorshade)
("floorpal", c.floorpal, def->floorpal)
("floorxpanning", c.floorxpanning, def->floorxpanning)
("floorypanning", c.floorypanning, def->floorypanning)
("floorxpanning", c.floorxpan_, def->floorxpan_)
("floorypanning", c.floorypan_, def->floorypan_)
("visibility", c.visibility, def->visibility)
("fogpal", c.fogpal, def->fogpal)
("lotag", c.lotag, def->lotag)

View file

@ -676,8 +676,8 @@ void DoFlows()
sFlowInfo[i].field_8 &= sFlowInfo[i].field_18;
short nSector = sFlowInfo[i].field_0;
sector[nSector].floorxpanning = sFlowInfo[i].field_4 >> 14;
sector[nSector].floorypanning = sFlowInfo[i].field_8 >> 14;
sector[nSector].addfloorxpan(sFlowInfo[i].field_4 / 16384.f);
sector[nSector].addfloorypan(sFlowInfo[i].field_8 / 16384.f);
break;
}
@ -685,8 +685,8 @@ void DoFlows()
{
short nSector = sFlowInfo[i].field_0;
sector[nSector].ceilingxpanning = sFlowInfo[i].field_4 >> 14;
sector[nSector].ceilingypanning = sFlowInfo[i].field_8 >> 14;
sector[nSector].addceilingxpan(sFlowInfo[i].field_4 / 16384.f);
sector[nSector].addceilingypan(sFlowInfo[i].field_8 / 16384.f);
sFlowInfo[i].field_4 &= sFlowInfo[i].field_14;
sFlowInfo[i].field_8 &= sFlowInfo[i].field_18;

View file

@ -4335,11 +4335,11 @@ void handle_se20(DDukeActor* actor)
setsprite(ps[p].GetActor(), ps[p].posx, ps[p].posy, ps[p].posz + PHEIGHT);
}
sc->floorxpanning -= x >> 3;
sc->floorypanning -= l >> 3;
sc->addfloorxpan(-x / 8.f);
sc->addfloorypan(-l / 8.f);
sc->ceilingxpanning -= x >> 3;
sc->ceilingypanning -= l >> 3;
sc->addceilingxpan(-x / 8.f);
sc->addceilingypan(-l / 8.f);
}
}
@ -4601,7 +4601,7 @@ void handle_se24(DDukeActor *actor, int16_t *list1, int16_t *list2, int TRIPBOMB
}
}
}
sector[actor->s.sectnum].floorxpanning += actor->s.yvel >> 7;
sector[actor->s.sectnum].addfloorxpan(actor->s.yvel / 128.f);
}
//---------------------------------------------------------------------------

View file

@ -4191,14 +4191,14 @@ void destroyit(DDukeActor *actor)
sector[sectnum].ceilingheinum = sector[it_sect].ceilingheinum;
sector[sectnum].ceilingshade = sector[it_sect].ceilingshade;
sector[sectnum].ceilingpal = sector[it_sect].ceilingpal;
sector[sectnum].ceilingxpanning = sector[it_sect].ceilingxpanning;
sector[sectnum].ceilingypanning = sector[it_sect].ceilingypanning;
sector[sectnum].ceilingxpan_ = sector[it_sect].ceilingxpan_;
sector[sectnum].ceilingypan_ = sector[it_sect].ceilingypan_;
sector[sectnum].floorpicnum = sector[it_sect].floorpicnum;
sector[sectnum].floorheinum = sector[it_sect].floorheinum;
sector[sectnum].floorshade = sector[it_sect].floorshade;
sector[sectnum].floorpal = sector[it_sect].floorpal;
sector[sectnum].floorxpanning = sector[it_sect].floorxpanning;
sector[sectnum].floorypanning = sector[it_sect].floorypanning;
sector[sectnum].floorxpan_ = sector[it_sect].floorxpan_;
sector[sectnum].floorypan_ = sector[it_sect].floorypan_;
sector[sectnum].visibility = sector[it_sect].visibility;
sectorextra[sectnum] = sectorextra[it_sect]; // TRANSITIONAL: at least rename this.
sector[sectnum].lotag = sector[it_sect].lotag;

View file

@ -1083,8 +1083,12 @@ void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
else SetGameVarID((int)lVar2, sector[iSector].ceilingpal, sActor, sPlayer);
break;
case SECTOR_CEILINGXPANNING:
if (bSet) sector[iSector].ceilingxpanning = lValue;
else SetGameVarID((int)lVar2, sector[iSector].ceilingypanning, sActor, sPlayer);
if (bSet) sector[iSector].ceilingxpan_ = lValue;
else SetGameVarID((int)lVar2, sector[iSector].ceilingxpan(), sActor, sPlayer);
break;
case SECTOR_CEILINGYPANNING:
if (bSet) sector[iSector].ceilingypan_ = lValue;
else SetGameVarID((int)lVar2, sector[iSector].ceilingypan(), sActor, sPlayer);
break;
case SECTOR_FLOORPICNUM:
if (bSet) sector[iSector].floorpicnum = lValue;
@ -1103,12 +1107,12 @@ void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
else SetGameVarID((int)lVar2, sector[iSector].floorpal, sActor, sPlayer);
break;
case SECTOR_FLOORXPANNING:
if (bSet) sector[iSector].floorxpanning = lValue;
else SetGameVarID((int)lVar2, sector[iSector].floorxpanning, sActor, sPlayer);
if (bSet) sector[iSector].floorxpan_ = lValue;
else SetGameVarID((int)lVar2, sector[iSector].floorxpan(), sActor, sPlayer);
break;
case SECTOR_FLOORYPANNING:
if (bSet) sector[iSector].floorypanning = lValue;
else SetGameVarID((int)lVar2, sector[iSector].floorypanning, sActor, sPlayer);
if (bSet) sector[iSector].floorypan_ = lValue;
else SetGameVarID((int)lVar2, sector[iSector].floorypan(), sActor, sPlayer);
break;
case SECTOR_VISIBILITY:
if (bSet) sector[iSector].visibility = lValue;

View file

@ -1259,8 +1259,8 @@ void moveclouds(double smoothratio)
cloudy += ps[screenpeek].angle.ang.bsin(-9);
for (int i = 0; i < numclouds; i++)
{
sector[clouds[i]].ceilingxpanning = cloudx >> 6;
sector[clouds[i]].ceilingypanning = cloudy >> 6;
sector[clouds[i]].addceilingxpan(cloudx / 64.f);
sector[clouds[i]].addceilingypan(cloudy / 64.f);
}
}
}

View file

@ -233,11 +233,11 @@ void CopySectorMatch(short match)
dsectp->floorpal = ssectp->floorpal;
dsectp->ceilingpal = ssectp->ceilingpal;
dsectp->floorxpanning = ssectp->floorxpanning;
dsectp->ceilingxpanning = ssectp->ceilingxpanning;
dsectp->floorxpan_ = ssectp->floorxpan_;
dsectp->ceilingxpan_ = ssectp->ceilingxpan_;
dsectp->floorypanning = ssectp->floorypanning;
dsectp->ceilingypanning = ssectp->ceilingypanning;
dsectp->floorypan_ = ssectp->floorypan_;
dsectp->ceilingypan_ = ssectp->ceilingypan_;
dsectp->floorstat = ssectp->floorstat;
dsectp->ceilingstat = ssectp->ceilingstat;

View file

@ -3210,11 +3210,8 @@ DoPanning(void)
nx = mulscale20(sp->xvel, bcos(sp->ang));
ny = mulscale20(sp->xvel, bsin(sp->ang));
sectp->floorxpanning += nx;
sectp->floorypanning += ny;
sectp->floorxpanning &= 255;
sectp->floorypanning &= 255;
sectp->addfloorxpan(nx);
sectp->addfloorypan(ny);
}
it.Reset(STAT_CEILING_PAN);
@ -3226,11 +3223,8 @@ DoPanning(void)
nx = mulscale20(sp->xvel, bcos(sp->ang));
ny = mulscale20(sp->xvel, bsin(sp->ang));
sectp->ceilingxpanning += nx;
sectp->ceilingypanning += ny;
sectp->ceilingxpanning &= 255;
sectp->ceilingypanning &= 255;
sectp->addceilingxpan(nx);
sectp->addceilingypan(ny);
}
it.Reset(STAT_WALL_PAN);