mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
- tspritetype::pos access wrappers, part 1.
This commit is contained in:
parent
dc94dedc6b
commit
170387ab26
10 changed files with 44 additions and 46 deletions
|
@ -475,6 +475,11 @@ struct spritetypebase
|
|||
{
|
||||
__int_pos = { x, y, z };
|
||||
}
|
||||
|
||||
const vec3_t int_pos() const
|
||||
{
|
||||
return __int_pos;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -495,11 +500,6 @@ struct tspritetype : public spritetypebase
|
|||
DCoreActor* ownerActor;
|
||||
int time;
|
||||
|
||||
const vec3_t int_pos() const
|
||||
{
|
||||
return __int_pos;
|
||||
}
|
||||
|
||||
void set_int_pos(const vec3_t& pos)
|
||||
{
|
||||
__int_pos = pos;
|
||||
|
|
|
@ -124,7 +124,7 @@ void HWFlat::MakeVertices(HWDrawInfo* di)
|
|||
int ofsz[4];
|
||||
auto cstat = Sprite->cstat;
|
||||
if (tspriteGetSlope(Sprite)) cstat &= ~CSTAT_SPRITE_YFLIP; // NBlood doesn't y-flip slope sprites.
|
||||
GetFlatSpritePosition(Sprite, Sprite->__int_pos.vec2, pos, ofsz, true);
|
||||
GetFlatSpritePosition(Sprite, Sprite->int_pos().vec2, pos, ofsz, true);
|
||||
Sprite->cstat = cstat;
|
||||
|
||||
auto ret = screen->mVertexData->AllocVertices(6);
|
||||
|
@ -177,7 +177,7 @@ void HWFlat::MakeVertices(HWDrawInfo* di)
|
|||
auto svp = &di->SlopeSpriteVertices[svi];
|
||||
|
||||
auto& vpt = di->Viewpoint;
|
||||
depth = (float)((Sprite->__int_pos.X * (1/16.f) - vpt.Pos.X) * vpt.TanCos + (Sprite->__int_pos.Y * (1 / -16.f) - vpt.Pos.Y) * vpt.TanSin);
|
||||
depth = (float)((Sprite->int_pos().X * (1/16.f) - vpt.Pos.X) * vpt.TanCos + (Sprite->int_pos().Y * (1 / -16.f) - vpt.Pos.Y) * vpt.TanSin);
|
||||
|
||||
for (unsigned j = 0; j < 4; j++)
|
||||
{
|
||||
|
@ -421,12 +421,12 @@ void HWFlat::ProcessFlatSprite(HWDrawInfo* di, tspritetype* sprite, sectortype*
|
|||
int tilenum = sprite->picnum;
|
||||
texture = tileGetTexture(tilenum);
|
||||
bool belowfloor = false;
|
||||
if (sprite->__int_pos.Z > sprite->sectp->floorz)
|
||||
if (sprite->int_pos().Z > sprite->sectp->floorz)
|
||||
{
|
||||
belowfloor = true;
|
||||
sprite->__int_pos.Z = sprite->sectp->floorz;
|
||||
sprite->int_pos().Z = sprite->sectp->floorz;
|
||||
}
|
||||
z = sprite->__int_pos.Z * (1 / -256.f);
|
||||
z = sprite->int_pos().Z * (1 / -256.f);
|
||||
if (z == di->Viewpoint.Pos.Z) return; // looking right at the edge.
|
||||
dynlightindex = -1;
|
||||
|
||||
|
|
|
@ -332,9 +332,9 @@ void HWSprite::Process(HWDrawInfo* di, tspritetype* spr, sectortype* sector, int
|
|||
|
||||
SetSpriteTranslucency(spr, alpha, RenderStyle);
|
||||
|
||||
x = spr->__int_pos.X * (1 / 16.f);
|
||||
z = spr->__int_pos.Z * (1 / -256.f);
|
||||
y = spr->__int_pos.Y * (1 / -16.f);
|
||||
x = spr->int_pos().X * (1 / 16.f);
|
||||
z = spr->int_pos().Z * (1 / -256.f);
|
||||
y = spr->int_pos().Y * (1 / -16.f);
|
||||
auto vp = di->Viewpoint;
|
||||
|
||||
if ((vp.Pos.XY() - DVector2(x, y)).LengthSquared() < 0.125) return;
|
||||
|
@ -395,9 +395,9 @@ void HWSprite::Process(HWDrawInfo* di, tspritetype* spr, sectortype* sector, int
|
|||
float viewvecX = vp.ViewVector.X;
|
||||
float viewvecY = vp.ViewVector.Y;
|
||||
|
||||
x = spr->__int_pos.X * (1 / 16.f);
|
||||
y = spr->__int_pos.Y * (1 / -16.f);
|
||||
z = spr->__int_pos.Z * (1 / -256.f);
|
||||
x = spr->int_pos().X * (1 / 16.f);
|
||||
y = spr->int_pos().Y * (1 / -16.f);
|
||||
z = spr->int_pos().Z * (1 / -256.f);
|
||||
|
||||
x1 = x - viewvecY * (xoff - (width * 0.5f));
|
||||
x2 = x - viewvecY * (xoff + (width * 0.5f));
|
||||
|
@ -504,13 +504,13 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, tspritetype* spr, s
|
|||
scalevec.Z *= sprzscale;
|
||||
translatevec.Z *= sprzscale;
|
||||
|
||||
float zpos = (float)(spr->__int_pos.Z + ownerActor->sprext.position_offset.Z);
|
||||
float zpos = (float)(spr->int_pos().Z + ownerActor->sprext.position_offset.Z);
|
||||
float zscale = ((spr->cstat & CSTAT_SPRITE_YFLIP) && (spr->ownerActor->spr.cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != 0) ? -4.f : 4.f;
|
||||
zpos -= (spr->yoffset * spr->yrepeat) * zscale * voxel->bscale;
|
||||
|
||||
x = (spr->__int_pos.X + ownerActor->sprext.position_offset.X) * (1 / 16.f);
|
||||
x = (spr->int_pos().X + ownerActor->sprext.position_offset.X) * (1 / 16.f);
|
||||
z = zpos * (1 / -256.f);
|
||||
y = (spr->__int_pos.Y + ownerActor->sprext.position_offset.Y) * (1 / -16.f);
|
||||
y = (spr->int_pos().Y + ownerActor->sprext.position_offset.Y) * (1 / -16.f);
|
||||
|
||||
float zoff = voxel->siz.Z * .5f;
|
||||
if (!(spr->cstat & CSTAT_SPRITE_YCENTER))
|
||||
|
|
|
@ -55,8 +55,8 @@ static walltype* IsOnWall(tspritetype* tspr, int height, DVector2& outpos)
|
|||
|
||||
auto sect = tspr->sectp;
|
||||
|
||||
float tx = tspr->__int_pos.X * (float)inttoworld;
|
||||
float ty = tspr->__int_pos.Y * (float)inttoworld;
|
||||
float tx = tspr->int_pos().X * (float)inttoworld;
|
||||
float ty = tspr->int_pos().Y * (float)inttoworld;
|
||||
|
||||
for(auto& wal : wallsofsector(sect))
|
||||
{
|
||||
|
@ -1128,9 +1128,9 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, tspritetype* spr, sectortype* sec
|
|||
seg = nullptr;
|
||||
Sprite = spr;
|
||||
vec2_t pos[2];
|
||||
int sprz = spr->__int_pos.Z;
|
||||
int sprz = spr->int_pos().Z;
|
||||
|
||||
GetWallSpritePosition(spr, spr->__int_pos.vec2, pos, true);
|
||||
GetWallSpritePosition(spr, spr->int_pos().vec2, pos, true);
|
||||
glseg.x1 = pos[0].X * (1 / 16.f);
|
||||
glseg.y1 = pos[0].Y * (1 / -16.f);
|
||||
glseg.x2 = pos[1].X * (1 / 16.f);
|
||||
|
|
|
@ -473,9 +473,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
|
|||
}
|
||||
auto pSprite = &sprites.sprites[i];
|
||||
*pSprite = {};
|
||||
pSprite->__int_pos.X = LittleLong(load.x);
|
||||
pSprite->__int_pos.Y = LittleLong(load.y);
|
||||
pSprite->__int_pos.Z = LittleLong(load.z);
|
||||
pSprite->SetMapPos(LittleLong(load.x), LittleLong(load.y), LittleLong(load.z));
|
||||
pSprite->cstat = ESpriteFlags::FromInt(LittleShort(load.cstat));
|
||||
pSprite->picnum = LittleShort(load.picnum);
|
||||
int secno = LittleShort(load.sectnum);
|
||||
|
|
|
@ -209,8 +209,8 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
|
|||
OwnerAc->int_pos().Y - ps[screenpeek].pos.Y);
|
||||
int sqb =
|
||||
getangle(
|
||||
OwnerAc->int_pos().X - t->__int_pos.X,
|
||||
OwnerAc->int_pos().Y - t->__int_pos.Y);
|
||||
OwnerAc->int_pos().X - t->int_pos().X,
|
||||
OwnerAc->int_pos().Y - t->int_pos().Y);
|
||||
|
||||
if (abs(getincangle(sqa, sqb)) > 512)
|
||||
if (ldist(OwnerAc, t) < ldist(ps[screenpeek].GetActor(), OwnerAc))
|
||||
|
@ -225,11 +225,9 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
|
|||
t->xrepeat = 0;
|
||||
else
|
||||
{
|
||||
t->ang = getangle(x - t->__int_pos.X, y - t->__int_pos.Y);
|
||||
t->__int_pos.X = OwnerAc->int_pos().X;
|
||||
t->__int_pos.Y = OwnerAc->int_pos().Y;
|
||||
t->__int_pos.X += bcos(t->ang, -10);
|
||||
t->__int_pos.Y += bsin(t->ang, -10);
|
||||
t->ang = getangle(x - t->int_pos().X, y - t->int_pos().Y);
|
||||
t->__int_pos.X = OwnerAc->int_pos().X + bcos(t->ang, -10);
|
||||
t->__int_pos.Y = OwnerAc->int_pos().Y + bsin(t->ang, -10);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -604,7 +602,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, int smoothrat
|
|||
else
|
||||
{
|
||||
// Alter the shadow's position so that it appears behind the sprite itself.
|
||||
int look = getangle(shadowspr->__int_pos.X - ps[screenpeek].pos.X, shadowspr->__int_pos.Y - ps[screenpeek].pos.Y);
|
||||
int look = getangle(shadowspr->int_pos() - ps[screenpeek].pos.X, shadowspr->__int_pos.Y - ps[screenpeek].pos.Y);
|
||||
shadowspr->__int_pos.X += bcos(look, -9);
|
||||
shadowspr->__int_pos.Y += bsin(look, -9);
|
||||
}
|
||||
|
|
|
@ -204,8 +204,8 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
|
|||
OwnerAc->int_pos().Y - ps[screenpeek].pos.Y);
|
||||
int sqb =
|
||||
getangle(
|
||||
OwnerAc->int_pos().X - t->__int_pos.X,
|
||||
OwnerAc->int_pos().Y - t->__int_pos.Y);
|
||||
OwnerAc->int_pos().X - t->int_pos().X,
|
||||
OwnerAc->int_pos().Y - t->int_pos().Y);
|
||||
|
||||
if (abs(getincangle(sqa, sqb)) > 512)
|
||||
if (ldist(OwnerAc, t) < ldist(ps[screenpeek].GetActor(), OwnerAc))
|
||||
|
@ -219,7 +219,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, int smoothrat
|
|||
t->xrepeat = 0;
|
||||
else
|
||||
{
|
||||
t->ang = getangle(x - t->__int_pos.X, y - t->__int_pos.Y);
|
||||
t->ang = getangle(x - t->int_pos().X, y - t->int_pos().Y);
|
||||
t->__int_pos.X = OwnerAc->int_pos().X;
|
||||
t->__int_pos.Y = OwnerAc->int_pos().Y;
|
||||
t->__int_pos.X += bcos(t->ang, -10);
|
||||
|
|
|
@ -105,8 +105,8 @@ inline int ldist(DDukeActor* s1, DDukeActor* s2)
|
|||
inline int ldist(const DDukeActor* s1, const tspritetype* s2)
|
||||
{
|
||||
int vx, vy;
|
||||
vx = s1->int_pos().X - s2->__int_pos.X;
|
||||
vy = s1->int_pos().Y - s2->__int_pos.Y;
|
||||
vx = s1->int_pos().X - s2->int_pos().X;
|
||||
vy = s1->int_pos().Y - s2->int_pos().Y;
|
||||
return(FindDistance2D(vx, vy) + 1);
|
||||
}
|
||||
inline int dist(DDukeActor* s1, DDukeActor* s2)
|
||||
|
|
|
@ -479,7 +479,7 @@ int seq_GetSeqPicnum(int16_t nSeq, int16_t edx, int16_t ebx)
|
|||
int seq_PlotArrowSequence(int nSprite, int16_t nSeq, int nVal)
|
||||
{
|
||||
tspritetype* pTSprite = mytspriteArray->get(nSprite);
|
||||
int nAngle = GetMyAngle(nCamerax - pTSprite->__int_pos.X, nCameray - pTSprite->__int_pos.Y);
|
||||
int nAngle = GetMyAngle(nCamerax - pTSprite->int_pos().X, nCameray - pTSprite->int_pos().Y);
|
||||
|
||||
int nSeqOffset = ((((pTSprite->ang + 512) - nAngle) + 128) & kAngleMask) >> 8;
|
||||
|
||||
|
@ -527,7 +527,8 @@ int seq_PlotArrowSequence(int nSprite, int16_t nSeq, int nVal)
|
|||
int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx)
|
||||
{
|
||||
tspritetype* pTSprite = mytspriteArray->get(nSprite);
|
||||
int nAngle = GetMyAngle(nCamerax - pTSprite->__int_pos.X, nCameray - pTSprite->__int_pos.Y);
|
||||
int nAngle = GetMyAngle(nCamerax - pTSprite->int_pos().X, nCameray - pTSprite->int_pos().Y);
|
||||
|
||||
|
||||
int val;
|
||||
|
||||
|
@ -580,7 +581,8 @@ int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx)
|
|||
}
|
||||
|
||||
tspritetype* tsp = mytspriteArray->newTSprite();
|
||||
tsp->__int_pos = pTSprite->__int_pos;
|
||||
tsp->set_int_pos(pTSprite->int_pos());
|
||||
|
||||
tsp->shade = shade;
|
||||
tsp->pal = pTSprite->pal;
|
||||
tsp->xrepeat = pTSprite->xrepeat;
|
||||
|
|
|
@ -242,15 +242,15 @@ inline int GetSpriteSizeToBottom(const spritetypebase* sp)
|
|||
inline int GetSpriteZOfTop(const spritetypebase* sp)
|
||||
{
|
||||
return (sp->cstat & CSTAT_SPRITE_YCENTER) ?
|
||||
sp->__int_pos.Z - GetSpriteSizeToTop(sp) :
|
||||
sp->__int_pos.Z - GetSpriteSizeZ(sp);
|
||||
sp->int_pos().Z - GetSpriteSizeToTop(sp) :
|
||||
sp->int_pos().Z - GetSpriteSizeZ(sp);
|
||||
}
|
||||
|
||||
inline int GetSpriteZOfBottom(const spritetypebase* sp)
|
||||
{
|
||||
return (sp->cstat & CSTAT_SPRITE_YCENTER) ?
|
||||
sp->__int_pos.Z + GetSpriteSizeToBottom(sp) :
|
||||
sp->__int_pos.Z;
|
||||
sp->int_pos().Z + GetSpriteSizeToBottom(sp) :
|
||||
sp->int_pos().Z;
|
||||
}
|
||||
|
||||
// mid and upper/lower sprite calculations
|
||||
|
|
Loading…
Reference in a new issue