- tspritetype::pos access wrappers, part 2.

This commit is contained in:
Christoph Oelckers 2022-02-02 19:55:11 +01:00
parent 170387ab26
commit 810e722e5e
2 changed files with 55 additions and 59 deletions

View file

@ -95,14 +95,17 @@ tspritetype* viewInsertTSprite(tspriteArray& tsprites, sectortype* pSector, int
pTSprite->type = -int(tsprites.Size() - 1);
pTSprite->statnum = nStatnum;
pTSprite->sectp = pSector;
vec3_t pos = { 0,0,0 };
if (parentTSprite)
{
pTSprite->__int_pos = parentTSprite->__int_pos;
pos = parentTSprite->int_pos();
pTSprite->ownerActor = parentTSprite->ownerActor;
pTSprite->ang = parentTSprite->ang;
}
pTSprite->__int_pos.X += Cos(gCameraAng) >> 25;
pTSprite->__int_pos.Y += Sin(gCameraAng) >> 25;
pos.X += Cos(gCameraAng) >> 25;
pos.Y += Sin(gCameraAng) >> 25;
pTSprite->set_int_pos(pos);
return pTSprite;
}
@ -188,9 +191,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
int z = 0;
RotateYZ(&x, &y, &z, nRand1);
RotateXZ(&x, &y, &z, nRand2);
pNSprite->__int_pos.X = pTSprite->__int_pos.X + x;
pNSprite->__int_pos.Y = pTSprite->__int_pos.Y + y;
pNSprite->__int_pos.Z = pTSprite->__int_pos.Z + (z << 4);
pNSprite->set_int_pos({ pTSprite->int_pos().X + x, pTSprite->int_pos().Y + y, pTSprite->int_pos().Z + (z << 4) });
pNSprite->picnum = 1720;
pNSprite->shade = -128;
}
@ -220,7 +221,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
if (!pNSprite)
break;
pNSprite->__int_pos.Z = pTSprite->__int_pos.Z;
pNSprite->__int_pos.Z = pTSprite->int_pos().Z;
pNSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT;
pNSprite->shade = -128;
pNSprite->xrepeat = pTSprite->xrepeat;
@ -289,12 +290,10 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
int nLen = 128 + (i << 7);
int x = MulScale(nLen, Cos(nAng), 30);
pNSprite->__int_pos.X = pTSprite->__int_pos.X + x;
int y = MulScale(nLen, Sin(nAng), 30);
pNSprite->__int_pos.Y = pTSprite->__int_pos.Y + y;
pNSprite->__int_pos.Z = pTSprite->__int_pos.Z;
pNSprite->set_int_pos({ pTSprite->int_pos().X + x, pTSprite->int_pos().Y + y, pTSprite->int_pos().Z });
assert(pSector);
FindSector(pNSprite->__int_pos.X, pNSprite->__int_pos.Y, pNSprite->__int_pos.Z, &pSector);
FindSector(pNSprite->int_pos().X, pNSprite->int_pos().Y, pNSprite->int_pos().Z, &pSector);
pNSprite->sectp = pSector;
pNSprite->ownerActor = pTSprite->ownerActor;
pNSprite->picnum = pTSprite->picnum;
@ -315,7 +314,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
break;
pNSprite->shade = -128;
pNSprite->__int_pos.Z = pTSprite->__int_pos.Z;
pNSprite->__int_pos.Z = pTSprite->int_pos().Z;
pNSprite->picnum = 908;
pNSprite->statnum = kStatDecoration;
pNSprite->xrepeat = pNSprite->yrepeat = (tileWidth(pTSprite->picnum) * pTSprite->xrepeat) / 64;
@ -432,7 +431,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
pNSprite->shade = -128;
pNSprite->pal = 2;
pNSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT;
pNSprite->__int_pos.Z = pTSprite->__int_pos.Z;
pNSprite->__int_pos.Z = pTSprite->int_pos().Z;
pNSprite->xrepeat = pTSprite->xrepeat;
pNSprite->yrepeat = pTSprite->yrepeat;
pNSprite->picnum = 2427;
@ -445,11 +444,10 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
break;
sectortype* pSector = pTSprite->sectp;
pNSprite->__int_pos.X = pTSprite->__int_pos.X;
pNSprite->__int_pos.Y = pTSprite->__int_pos.Y;
pNSprite->__int_pos.Z = pSector->ceilingz;
pNSprite->set_int_pos({ pTSprite->int_pos().X, pTSprite->int_pos().Y, pSector->ceilingz });
pNSprite->picnum = 624;
pNSprite->shade = ((pTSprite->__int_pos.Z - pSector->ceilingz) >> 8) - 64;
pNSprite->shade = ((pTSprite->int_pos().Z - pSector->ceilingz) >> 8) - 64;
pNSprite->pal = 2;
pNSprite->xrepeat = pNSprite->yrepeat = 64;
pNSprite->cstat |= CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR | CSTAT_SPRITE_YFLIP | CSTAT_SPRITE_TRANSLUCENT;
@ -464,11 +462,9 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
break;
sectortype* pSector = pTSprite->sectp;
pNSprite->__int_pos.X = pTSprite->__int_pos.X;
pNSprite->__int_pos.Y = pTSprite->__int_pos.Y;
pNSprite->__int_pos.Z = pSector->floorz;
pNSprite->set_int_pos({ pTSprite->int_pos().X, pTSprite->int_pos().Y, pSector->floorz });
pNSprite->picnum = 624;
uint8_t nShade = (pSector->floorz - pTSprite->__int_pos.Z) >> 8;
uint8_t nShade = (pSector->floorz - pTSprite->int_pos().Z) >> 8;
pNSprite->shade = nShade - 32;
pNSprite->pal = 2;
pNSprite->xrepeat = pNSprite->yrepeat = nShade;
@ -483,7 +479,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
if (!pNSprite)
break;
pNSprite->__int_pos.Z = pTSprite->__int_pos.Z;
pNSprite->__int_pos.Z = pTSprite->int_pos().Z;
if (gDetail > 1)
pNSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP;
pNSprite->shade = ClipLow(pTSprite->shade - 32, -128);
@ -503,10 +499,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
if (!pNSprite)
break;
pNSprite->__int_pos.X = pTSprite->__int_pos.X;
pNSprite->__int_pos.Y = pTSprite->__int_pos.Y;
pNSprite->__int_pos.Z = pTSprite->__int_pos.Z - (32 << 8);
pNSprite->__int_pos.Z -= weaponIcon.zOffset << 8; // offset up
pNSprite->set_int_pos({ pTSprite->int_pos().X, pTSprite->int_pos().Y, pTSprite->int_pos().Z - (32 << 8) - (weaponIcon.zOffset << 8) });
pNSprite->picnum = nTile;
pNSprite->shade = pTSprite->shade;
pNSprite->xrepeat = 32;
@ -585,7 +578,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
if (cl_interpolate && owneractor->interpolated && !(pTSprite->flags & 512))
{
pTSprite->__int_pos = owneractor->interpolatedvec3(gInterpolate);
pTSprite->int_pos() = owneractor->interpolatedvec3(gInterpolate);
pTSprite->ang = owneractor->interpolatedang(gInterpolate);
}
int nAnim = 0;
@ -615,8 +608,8 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
pTSprite->cstat &= ~CSTAT_SPRITE_XFLIP;
break;
}
int dX = cX - pTSprite->__int_pos.X;
int dY = cY - pTSprite->__int_pos.Y;
int dX = cX - pTSprite->int_pos().X;
int dY = cY - pTSprite->int_pos().Y;
RotateVector(&dX, &dY, 128 - pTSprite->ang);
nAnim = GetOctant(dX, dY);
if (nAnim <= 4)
@ -637,8 +630,8 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
pTSprite->cstat &= ~CSTAT_SPRITE_XFLIP;
break;
}
int dX = cX - pTSprite->__int_pos.X;
int dY = cY - pTSprite->__int_pos.Y;
int dX = cX - pTSprite->int_pos().X;
int dY = cY - pTSprite->int_pos().Y;
RotateVector(&dX, &dY, 128 - pTSprite->ang);
nAnim = GetOctant(dX, dY);
break;
@ -654,7 +647,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
{
int top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
if (getflorzofslopeptr(pTSprite->sectp, pTSprite->__int_pos.X, pTSprite->__int_pos.Y) > bottom)
if (getflorzofslopeptr(pTSprite->sectp, pTSprite->int_pos().X, pTSprite->int_pos().Y) > bottom)
nAnim = 1;
}
break;
@ -855,12 +848,12 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
if (pTSprite->type != kMissileFlareRegular) break;
sectortype* pSector1 = pTSprite->sectp;
int zDiff = (pTSprite->__int_pos.Z - pSector1->ceilingz) >> 8;
int zDiff = (pTSprite->int_pos().Z - pSector1->ceilingz) >> 8;
if ((pSector1->ceilingstat & CSTAT_SECTOR_SKY) == 0 && zDiff < 64) {
viewAddEffect(tsprites, nTSprite, kViewEffectCeilGlow);
}
zDiff = (pSector1->floorz - pTSprite->__int_pos.Z) >> 8;
zDiff = (pSector1->floorz - pTSprite->int_pos().Z) >> 8;
if ((pSector1->floorstat & CSTAT_SECTOR_SKY) == 0 && zDiff < 64) {
viewAddEffect(tsprites, nTSprite, kViewEffectFloorGlow);
}
@ -936,7 +929,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
}
if (pTSprite->ownerActor != gView->actor || gViewPos != VIEWPOS_0) {
if (getflorzofslopeptr(pTSprite->sectp, pTSprite->__int_pos.X, pTSprite->__int_pos.Y) >= cZ)
if (getflorzofslopeptr(pTSprite->sectp, pTSprite->int_pos().X, pTSprite->int_pos().Y) >= cZ)
{
viewAddEffect(tsprites, nTSprite, kViewEffectShadow);
}
@ -968,7 +961,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
if (pTSprite->type < kThingBase || pTSprite->type >= kThingMax || owneractor->hit.florhit.type == kHitNone)
{
if ((pTSprite->flags & kPhysMove) && getflorzofslopeptr(pTSprite->sectp, pTSprite->__int_pos.X, pTSprite->__int_pos.Y) >= cZ)
if ((pTSprite->flags & kPhysMove) && getflorzofslopeptr(pTSprite->sectp, pTSprite->int_pos().X, pTSprite->int_pos().Y) >= cZ)
viewAddEffect(tsprites, nTSprite, kViewEffectShadow);
}
}
@ -984,8 +977,8 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
{
case 1:
{
int dX = cX - pTSprite->__int_pos.X;
int dY = cY - pTSprite->__int_pos.Y;
int dX = cX - pTSprite->int_pos().X;
int dY = cY - pTSprite->int_pos().Y;
RotateVector(&dX, &dY, 128 - pTSprite->ang);
nAnim = GetOctant(dX, dY);
if (nAnim <= 4)
@ -1001,8 +994,8 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
}
case 2:
{
int dX = cX - pTSprite->__int_pos.X;
int dY = cY - pTSprite->__int_pos.Y;
int dX = cX - pTSprite->int_pos().X;
int dY = cY - pTSprite->int_pos().Y;
RotateVector(&dX, &dY, 128 - pTSprite->ang);
nAnim = GetOctant(dX, dY);
break;

View file

@ -103,7 +103,7 @@ int GetRotation(tspriteArray& tsprites, int tSpriteNum, int viewx, int viewy)
// Get which of the 8 angles of the sprite to draw (0-7)
// rotation ranges from 0-7
angle2 = getangle(tsp->__int_pos.X - viewx, tsp->__int_pos.Y - viewy);
angle2 = getangle(tsp->int_pos().X - viewx, tsp->int_pos().Y - viewy);
rotation = ((tsp->ang + 3072 + 128 - angle2) & 2047);
rotation = (rotation >> 8) & 7;
@ -211,7 +211,7 @@ int DoShadowFindGroundPoint(tspritetype* tspr)
save_cstat = tspr->cstat;
tspr->cstat &= ~(CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN);
FAFgetzrangepoint(tspr->__int_pos.X, tspr->__int_pos.Y, tspr->__int_pos.Z, tspr->sectp, &hiz, &ceilhit, &loz, &florhit);
FAFgetzrangepoint(tspr->int_pos().X, tspr->int_pos().Y, tspr->int_pos().Z, tspr->sectp, &hiz, &ceilhit, &loz, &florhit);
tspr->cstat = save_cstat;
switch (florhit.type)
@ -263,7 +263,7 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, int viewz, int camang)
auto sect = tsp->sectp;
// make sure its the correct sector
// DoShadowFindGroundPoint calls FAFgetzrangepoint and this is sensitive
updatesector(tsp->__int_pos.X, tsp->__int_pos.Y, &sect);
updatesector(tsp->int_pos().X, tsp->int_pos().Y, &sect);
if (sect == nullptr)
{
@ -335,7 +335,7 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, int viewz, int camang)
else
{
// Alter the shadow's position so that it appears behind the sprite itself.
int look = getangle(tSpr->__int_pos.X - Player[screenpeek].si.X, tSpr->__int_pos.Y - Player[screenpeek].si.Y);
int look = getangle(tSpr->int_pos().X - Player[screenpeek].si.X, tSpr->int_pos().Y - Player[screenpeek].si.Y);
tSpr->__int_pos.X += bcos(look, -9);
tSpr->__int_pos.Y += bsin(look, -9);
}
@ -456,13 +456,14 @@ void WarpCopySprite(tspriteArray& tsprites)
tspritetype* newTSpr = renderAddTsprite(tsprites, itActor2);
newTSpr->statnum = 0;
xoff = itActor->int_pos().X - newTSpr->__int_pos.X;
yoff = itActor->int_pos().Y - newTSpr->__int_pos.Y;
zoff = itActor->int_pos().Z - newTSpr->__int_pos.Z;
xoff = itActor->int_pos().X - newTSpr->int_pos().X;
yoff = itActor->int_pos().Y - newTSpr->int_pos().Y;
zoff = itActor->int_pos().Z - newTSpr->int_pos().Z;
newTSpr->__int_pos.X = itActor1->int_pos().X - xoff;
newTSpr->__int_pos.Y = itActor1->int_pos().Y - yoff;
newTSpr->__int_pos.Z = itActor1->int_pos().Z - zoff;
newTSpr->set_int_pos({
itActor1->int_pos().X - xoff,
itActor1->int_pos().Y - yoff,
itActor1->int_pos().Z - zoff });
newTSpr->sectp = itActor1->sector();
}
@ -546,7 +547,7 @@ DSWActor* ConnectCopySprite(spritetypebase const* tsp)
testz = GetSpriteZOfTop(tsp) - Z(10);
if (testz < tsp->sectp->ceilingz)
updatesectorz(tsp->__int_pos.X, tsp->__int_pos.Y, testz, &newsector);
updatesectorz(tsp->int_pos().X, tsp->int_pos().Y, testz, &newsector);
if (newsector != nullptr && newsector != tsp->sectp)
{
@ -560,7 +561,7 @@ DSWActor* ConnectCopySprite(spritetypebase const* tsp)
testz = GetSpriteZOfBottom(tsp) + Z(10);
if (testz > tsp->sectp->floorz)
updatesectorz(tsp->__int_pos.X, tsp->__int_pos.Y, testz, &newsector);
updatesectorz(tsp->int_pos().X, tsp->int_pos().Y, testz, &newsector);
if (newsector != nullptr && newsector != tsp->sectp)
{
@ -757,20 +758,22 @@ void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int
if (pp->Flags & (PF_VIEW_FROM_OUTSIDE))
tsp->cstat |= (CSTAT_SPRITE_TRANSLUCENT);
vec3_t pos;
if (pp->Flags & (PF_CLIMBING))
{
// move sprite forward some so he looks like he's
// climbing
tsp->__int_pos.X = pp->si.X + MOVEx(128 + 80, tsp->ang);
tsp->__int_pos.Y = pp->si.Y + MOVEy(128 + 80, tsp->ang);
pos.X = pp->si.X + MOVEx(128 + 80, tsp->ang);
pos.Y = pp->si.Y + MOVEy(128 + 80, tsp->ang);
}
else
{
tsp->__int_pos.X = pp->si.X;
tsp->__int_pos.Y = pp->si.Y;
pos.X = pp->si.X;
pos.Y = pp->si.Y;
}
tsp->__int_pos.Z = tsp->__int_pos.Z + pp->si.Z;
pos.Z = tsp->int_pos().Z + pp->si.Z;
tsp->set_int_pos(pos);
tsp->ang = pp->siang;
//continue;
}
@ -905,8 +908,8 @@ void post_analyzesprites(tspriteArray& tsprites)
continue;
}
tsp->__int_pos.X = atsp->__int_pos.X;
tsp->__int_pos.Y = atsp->__int_pos.Y;
tsp->__int_pos.X = atsp->int_pos().X;
tsp->__int_pos.Y = atsp->int_pos().Y;
// statnum is priority - draw this ALWAYS first at 0
// statnum is priority - draw this ALWAYS last at MAXSTATUS
if ((atsp->extra & SPRX_BURNABLE))