Skip to content

Commit

Permalink
- Change spritetypebase::angle to a DRotator named Angles.
Browse files Browse the repository at this point in the history
* Major pre-requisite for the next steps I'm undertaking, let's get it into the branch now.
  • Loading branch information
mjr4077au committed Nov 26, 2022
1 parent 202c7a1 commit 2b654eb
Show file tree
Hide file tree
Showing 126 changed files with 1,462 additions and 1,462 deletions.
2 changes: 1 addition & 1 deletion source/core/actorlist.cpp
Expand Up @@ -379,7 +379,7 @@ void DCoreActor::initFromSprite(spritetype* mspr)
#define setter(flag, var) if (!(actorinfo->DefaultFlags & flag)) spr.var = mspr->var;

setter(DEFF_PICNUM, picnum);
setter(DEFF_ANG, angle);
setter(DEFF_ANG, Angles.Yaw);
setter(DEFF_INTANG, intangle);
setter(DEFF_XVEL, xint);
setter(DEFF_YVEL, yint);
Expand Down
6 changes: 3 additions & 3 deletions source/core/automap.cpp
Expand Up @@ -628,7 +628,7 @@ void DrawOverheadMap(const DVector2& plxy, const DAngle pl_angle, double const i
void DrawAutomapAlignmentFacing(const spritetype& spr, const DVector2& bpos, const DVector2& cangvect, const double czoom, const DVector2& xydim, const PalEntry& col)
{
auto v1 = OutAutomapVector(bpos, cangvect, czoom, xydim);
auto v2 = OutAutomapVector(spr.angle.ToVector() * 8., cangvect, czoom);
auto v2 = OutAutomapVector(spr.Angles.Yaw.ToVector() * 8., cangvect, czoom);
auto v3 = v2.Rotated90CW();
auto v4 = v1 + v2;

Expand All @@ -651,7 +651,7 @@ void DrawAutomapAlignmentWall(const spritetype& spr, const DVector2& bpos, const

if ((spr.cstat & CSTAT_SPRITE_XFLIP) > 0) xoff = -xoff;

auto sprvec = spr.angle.ToVector().Rotated90CW() * xrep;
auto sprvec = spr.Angles.Yaw.ToVector().Rotated90CW() * xrep;

auto b1 = bpos - sprvec * ((xspan * 0.5) + xoff);
auto b2 = b1 + sprvec * xspan;
Expand Down Expand Up @@ -687,7 +687,7 @@ void DrawAutomapAlignmentFloor(const spritetype& spr, const DVector2& bpos, cons
if ((spr.cstat & CSTAT_SPRITE_XFLIP) > 0) xoff = -xoff;
if ((spr.cstat & CSTAT_SPRITE_YFLIP) > 0) yoff = -yoff;

auto sprvec = spr.angle.ToVector();
auto sprvec = spr.Angles.Yaw.ToVector();
auto xscale = sprvec.Rotated90CW() * xspan * xrep;
auto yscale = sprvec * yspan * yrep;
auto xybase = DVector2(((xspan * 0.5) + xoff) * xrep, ((yspan * 0.5) + yoff) * yrep);
Expand Down
8 changes: 4 additions & 4 deletions source/core/coreactor.h
Expand Up @@ -83,12 +83,12 @@ class DCoreActor : public DObject

constexpr int int_ang() const
{
return spr.angle.Buildang();
return spr.Angles.Yaw.Buildang();
}

void norm_ang()
{
spr.angle = spr.angle.Normalized360();
spr.Angles.Yaw = spr.Angles.Yaw.Normalized360();
}

DVector3 interpolatedpos(double const interpfrac)
Expand All @@ -98,7 +98,7 @@ class DCoreActor : public DObject

DAngle interpolatedangle(double const interpfrac)
{
return interpolatedvalue(oang, spr.angle, interpfrac);
return interpolatedvalue(oang, spr.Angles.Yaw, interpfrac);
}

void backupz()
Expand All @@ -120,7 +120,7 @@ class DCoreActor : public DObject

void backupang()
{
oang = spr.angle;
oang = spr.Angles.Yaw;
}

void backuploc()
Expand Down
12 changes: 6 additions & 6 deletions source/core/gamefuncs.cpp
Expand Up @@ -87,7 +87,7 @@ bool calcChaseCamPos(DVector3& ppos, DCoreActor* act, sectortype** psect, DAngle
else
{
// same as wall calculation.
hpos.*c -= npos.*c * npos.XY().dot((act->spr.angle - DAngle90).ToVector().Rotated90CW()) * (1. / 1024.);
hpos.*c -= npos.*c * npos.XY().dot((act->spr.Angles.Yaw - DAngle90).ToVector().Rotated90CW()) * (1. / 1024.);
}
}

Expand Down Expand Up @@ -216,7 +216,7 @@ void GetWallSpritePosition(const spritetypebase* spr, const DVector2& pos, DVect
xoffset = tex->GetDisplayLeftOffset() + spr->xoffset;
}

auto p = spr->angle.ToVector().Rotated90CW() * spr->scale.X;
auto p = spr->Angles.Yaw.ToVector().Rotated90CW() * spr->scale.X;

if (spr->cstat & CSTAT_SPRITE_XFLIP) xoffset = -xoffset;
double origin = (width * 0.5) + xoffset;
Expand Down Expand Up @@ -265,8 +265,8 @@ void TGetFlatSpritePosition(const spritetypebase* spr, const DVector2& pos, DVec
double sprcenterx = (width * 0.5) + leftofs;
double sprcentery = (height * 0.5) + topofs;

double cosang = spr->angle.Cos();
double sinang = spr->angle.Sin();
double cosang = spr->Angles.Yaw.Cos();
double sinang = spr->Angles.Yaw.Sin();
double cosangslope = cosang / sloperatio;
double sinangslope = sinang / sloperatio;

Expand Down Expand Up @@ -954,7 +954,7 @@ bool checkRangeOfFloorSprite(DCoreActor* itActor, const DVector3& pos, double ma
GetFlatSpritePosition(itActor, itActor->spr.pos.XY(), out);

// expand the area to cover 'maxdist' units more on each side. (i.e. move the edges out)
auto expand = (itActor->spr.angle - DAngle45).ToVector() * (maxdist + 0.25); // that's surely not accurate but here we must match Build's original value.
auto expand = (itActor->spr.Angles.Yaw - DAngle45).ToVector() * (maxdist + 0.25); // that's surely not accurate but here we must match Build's original value.
out[0] += expand;
out[1] += expand.Rotated90CCW();
out[2] -= expand;
Expand Down Expand Up @@ -1354,7 +1354,7 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
tspr->yoffset = actor->spr.yoffset;
tspr->sectp = actor->spr.sectp;
tspr->statnum = actor->spr.statnum;
tspr->angle = actor->spr.angle;
tspr->Angles.Yaw = actor->spr.Angles.Yaw;
tspr->xint = actor->spr.xint;
tspr->yint = actor->spr.yint;
tspr->inittype = actor->spr.inittype; // not used by tsprites.
Expand Down
2 changes: 1 addition & 1 deletion source/core/gamefuncs.h
Expand Up @@ -414,7 +414,7 @@ inline int tspriteGetSlope(const tspritetype* spr)
inline double spriteGetZOfSlopef(const spritetypebase* tspr, const DVector2& pos, int heinum)
{
if (heinum == 0) return tspr->pos.Z;
return tspr->pos.Z + heinum * -tspr->angle.ToVector().dot(pos - tspr->pos.XY()) * (1. / SLOPEVAL_FACTOR);
return tspr->pos.Z + heinum * -tspr->Angles.Yaw.ToVector().dot(pos - tspr->pos.XY()) * (1. / SLOPEVAL_FACTOR);
}

//==========================================================================
Expand Down
6 changes: 3 additions & 3 deletions source/core/maploader.cpp
Expand Up @@ -316,7 +316,7 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)
secno = fr.ReadInt16();
spr.statnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = mapangle(spr.intangle);
spr.Angles.Yaw = mapangle(spr.intangle);
spr.intowner = fr.ReadInt16();
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
Expand Down Expand Up @@ -344,7 +344,7 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno)
spr.yoffset = fr.ReadInt8();
spr.picnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = mapangle(spr.intangle);
spr.Angles.Yaw = mapangle(spr.intangle);
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
spr.inittype = fr.ReadInt16();
Expand Down Expand Up @@ -373,7 +373,7 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno)
spr.scale = DVector2(x * REPEAT_SCALE, y * REPEAT_SCALE);
spr.picnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = mapangle(spr.intangle);
spr.Angles.Yaw = mapangle(spr.intangle);
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
spr.inittype = fr.ReadInt16();
Expand Down
2 changes: 1 addition & 1 deletion source/core/maptypes.h
Expand Up @@ -448,7 +448,7 @@ struct spritetypebase
DVector3 pos;

sectortype* sectp;
DAngle angle;
DRotator Angles;
DVector2 scale;

ESpriteFlags cstat;
Expand Down
2 changes: 1 addition & 1 deletion source/core/rendering/scene/hw_bunchdrawer.cpp
Expand Up @@ -686,7 +686,7 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal)
if ((actor->spr.cstat & (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_MASK)) != (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL) ||
(r_voxels && tiletovox[actor->spr.picnum] >= 0 && voxmodels[tiletovox[actor->spr.picnum]]) ||
(r_voxels && gi->Voxelize(actor->spr.picnum) > -1) ||
(actor->spr.angle.Cos() * viewvec.X) + (actor->spr.angle.Sin() * viewvec.Y) < 0)
(actor->spr.Angles.Yaw.Cos() * viewvec.X) + (actor->spr.Angles.Yaw.Sin() * viewvec.Y) < 0)
if (!renderAddTsprite(di->tsprites, actor))
break;
}
Expand Down
4 changes: 2 additions & 2 deletions source/core/rendering/scene/hw_drawinfo.cpp
Expand Up @@ -317,11 +317,11 @@ void HWDrawInfo::DispatchSprites()

if (actor->sprext.renderflags & SPREXT_AWAY1)
{
tspr->pos.XY() += tspr->angle.ToVector() * 0.125;
tspr->pos.XY() += tspr->Angles.Yaw.ToVector() * 0.125;
}
else if (actor->sprext.renderflags & SPREXT_AWAY2)
{
tspr->pos.XY() -= tspr->angle.ToVector() * 0.125;
tspr->pos.XY() -= tspr->Angles.Yaw.ToVector() * 0.125;
}

switch (tspr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK)
Expand Down
2 changes: 1 addition & 1 deletion source/core/rendering/scene/hw_sprites.cpp
Expand Up @@ -462,7 +462,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, tspritetype* spr, s
visibility = sectorVisibility(sector);
voxel = vox;

auto ang = spr->angle + ownerActor->sprext.rot.Yaw;
auto ang = spr->Angles.Yaw + ownerActor->sprext.rot.Yaw;
if ((spr->clipdist & TSPR_MDLROTATE) || rotate)
{
int myclock = (PlayClock << 3) + MulScale(4 << 3, (int)di->Viewpoint.TicFrac, 16);
Expand Down
6 changes: 3 additions & 3 deletions source/core/rendering/scene/hw_walls.cpp
Expand Up @@ -62,13 +62,13 @@ static walltype* IsOnWall(tspritetype* tspr, int height, DVector2& outpos)
{
// Intentionally include two sided walls. Even on them the sprite should be projected onto the wall for better results.
auto d = wal.delta();
auto deltaang = absangle(d.Angle(), tspr->angle);
auto deltaang = absangle(d.Angle(), tspr->Angles.Yaw);
const DAngle maxangdelta = DAngle360 / 1024;

// angle of the sprite must either be the wall's normal or the negative wall's normal to be aligned.
if (deltaang >= DAngle90 - maxangdelta && deltaang <= DAngle90 + maxangdelta)
{
if (!((tspr->angle.Buildang()) & 510))
if (!((tspr->Angles.Yaw.Buildang()) & 510))
{
// orthogonal lines do not check the actual position so that certain off-sector sprites get handled properly.
// In Wanton Destruction's airplane level there's such a sprite assigned to the wrong sector.
Expand Down Expand Up @@ -1101,7 +1101,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec
int HWWall::CheckWallSprite(tspritetype* spr, tspritetype* last)
{
// If the position changed we need to recalculate everything.
if (spr->pos.XY() != last->pos.XY() || spr->sectp != last->sectp || spr->angle != last->angle) return 3;
if (spr->pos.XY() != last->pos.XY() || spr->sectp != last->sectp || spr->Angles.Yaw != last->Angles.Yaw) return 3;

// if the horizontal orientation changes we need to recalculate the walls this attaches to, but not the positioning.
if (spr->scale.X != last->scale.X || spr->xoffset != last->xoffset || spr->picnum != last->picnum || ((spr->cstat ^ last->cstat) & CSTAT_SPRITE_XFLIP)) return 2;
Expand Down
4 changes: 2 additions & 2 deletions source/core/savegamehelp.cpp
Expand Up @@ -421,7 +421,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
("yoffset", c.yoffset, def->yoffset)
("statnum", c.statnum)
("sectnum", c.sectp)
("angle", c.angle, def->angle)
("angles", c.Angles, def->Angles)
("ang", c.intangle, def->intangle)
("owner", c.intowner, def->intowner)
("xvel", c.xint, def->xint)
Expand Down Expand Up @@ -636,7 +636,7 @@ void DCoreActor::Serialize(FSerializer& arc)
if (arc.isReading())
{
spsmooth = {};
backuppos();
backuploc();
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/core/thingdef_properties.cpp
Expand Up @@ -331,7 +331,7 @@ DEFINE_PROPERTY(statnum, I, CoreActor)
DEFINE_PROPERTY(angle, F, CoreActor)
{
PROP_INT_PARM(i, 0);
defaults->spr.angle = DAngle::fromDeg(i);
defaults->spr.Angles.Yaw = DAngle::fromDeg(i);
bag.Info->ActorInfo()->DefaultFlags |= DEFF_ANG;
}

Expand Down
4 changes: 2 additions & 2 deletions source/core/vmexports.cpp
Expand Up @@ -136,7 +136,7 @@ DEFINE_FIELD_NAMED_X(walltype, walltype, yrepeat, yrepeat)
DEFINE_FIELD_NAMED_X(tspritetype, tspritetype, sectp, sector)
DEFINE_FIELD_X(tspritetype, tspritetype, cstat)
DEFINE_FIELD_X(tspritetype, tspritetype, statnum)
DEFINE_FIELD_X(tspritetype, tspritetype, angle)
DEFINE_FIELD_NAMED_X(tspritetype, tspritetype, Angles.Yaw, angle)
DEFINE_FIELD_X(tspritetype, tspritetype, xint)
DEFINE_FIELD_X(tspritetype, tspritetype, yint)
DEFINE_FIELD_X(tspritetype, tspritetype, inittype)
Expand Down Expand Up @@ -629,7 +629,7 @@ DEFINE_FIELD_NAMED(DCoreActor, sprext.renderflags, renderflags)
DEFINE_FIELD_NAMED(DCoreActor, sprext.alpha, alpha)
DEFINE_FIELD_NAMED(DCoreActor, time, spawnindex)
DEFINE_FIELD(DCoreActor, spritesetindex)
DEFINE_FIELD_NAMED(DCoreActor, spr.angle, angle)
DEFINE_FIELD_NAMED(DCoreActor, spr.Angles.Yaw, angle)
DEFINE_FIELD(DCoreActor, vel)
DEFINE_FIELD(DCoreActor, viewzoffset)

Expand Down

0 comments on commit 2b654eb

Please sign in to comment.