- use DAngle for actors

Note that intangle needs to be kept - primarily for SW's ST tags.
This commit is contained in:
Christoph Oelckers 2022-08-16 23:29:54 +02:00
parent bd6b0eaac5
commit fe6fcdff1f
14 changed files with 27 additions and 23 deletions

View file

@ -495,7 +495,7 @@ DEFINE_FIELD_NAMED(DCoreActor, spr.cstat, cstat)
DEFINE_FIELD_NAMED(DCoreActor, spr.cstat2, cstat2)
DEFINE_FIELD_NAMED(DCoreActor, spr.picnum, picnum)
DEFINE_FIELD_NAMED(DCoreActor, spr.statnum, statnum)
DEFINE_FIELD_NAMED(DCoreActor, spr.__int_angle, ang)
//DEFINE_FIELD_NAMED(DCoreActor, spr.angle, angle)
DEFINE_FIELD_NAMED(DCoreActor, spr.pos, pos)
DEFINE_FIELD_NAMED(DCoreActor, spr.xvel, xvel)
DEFINE_FIELD_NAMED(DCoreActor, spr.yvel, yvel)

View file

@ -109,22 +109,21 @@ public:
constexpr int16_t int_ang() const
{
return spr.__int_angle;
return spr.angle.Buildang();
}
void set_int_ang(int a)
{
spr.__int_angle = int16_t(a);
spr.angle = DAngle::fromBuild(a);
}
void add_int_ang(int a)
{
spr.__int_angle += int16_t(a);
spr.angle += DAngle::fromBuild(a);
}
void norm_ang()
{
spr.__int_angle &= 2047;
}
// Same as above but with invertex y and z axes to match the renderer's coordinate system.

View file

@ -569,7 +569,7 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
tspr->yoffset = actor->spr.yoffset;
tspr->sectp = actor->spr.sectp;
tspr->statnum = actor->spr.statnum;
tspr->__int_angle = actor->int_ang();
tspr->angle = actor->spr.angle;
tspr->xvel = actor->spr.xvel;
tspr->yvel = actor->spr.yvel;
tspr->zvel = actor->spr.zvel;

View file

@ -313,7 +313,8 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)
spr.yoffset = fr.ReadInt8();
secno = fr.ReadInt16();
spr.statnum = fr.ReadInt16();
spr.__int_angle = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.intowner = fr.ReadInt16();
spr.xvel = fr.ReadInt16();
spr.yvel = fr.ReadInt16();
@ -339,7 +340,8 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno)
spr.xoffset = fr.ReadInt8();
spr.yoffset = fr.ReadInt8();
spr.picnum = fr.ReadInt16();
spr.__int_angle = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.xvel = fr.ReadInt16();
spr.yvel = fr.ReadInt16();
spr.zvel = fr.ReadInt16();
@ -366,7 +368,8 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno)
spr.xrepeat = fr.ReadUInt8();
spr.yrepeat = fr.ReadUInt8();
spr.picnum = fr.ReadInt16();
spr.__int_angle = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.xvel = fr.ReadInt16();
spr.yvel = fr.ReadInt16();
spr.zvel = fr.ReadInt16();

View file

@ -460,11 +460,12 @@ struct spritetypebase
DVector3 pos;
sectortype* sectp;
DAngle angle;
ESpriteFlags cstat;
int16_t picnum;
int16_t statnum;
int16_t __int_angle;
int16_t intangle; // needs to be kept for SW's SP_TAG4
int16_t xvel;
int16_t yvel;
union { int16_t zvel, inittype; }; // inittype, type and flags are for Blood.
@ -495,22 +496,22 @@ struct spritetypebase
constexpr int16_t int_ang() const
{
return __int_angle;
return angle.Buildang();
}
void set_int_ang(int a)
{
__int_angle = int16_t(a);
angle = DAngle::fromDeg(a);
}
void add_int_ang(int a)
{
__int_angle += int16_t(a);
angle += DAngle::fromDeg(a);
}
void copy_ang(const spritetypebase* other)
{
__int_angle = other->int_ang();
angle = other->angle;
}
};

View file

@ -461,7 +461,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
("yoffset", c.yoffset, def->yoffset)
("statnum", c.statnum)
("sectnum", c.sectp)
("ang", c.__int_angle, def->__int_angle)
("angle", c.angle, def->angle)
("ang", c.intangle, def->intangle)
("owner", c.intowner, def->intowner)
("xvel", c.xvel, def->xvel)
("yvel", c.yvel, def->yvel)

View file

@ -337,7 +337,7 @@ DEFINE_PROPERTY(statnum, I, CoreActor)
DEFINE_PROPERTY(angle, I, CoreActor)
{
PROP_INT_PARM(i, 0);
bag.Info->ActorInfo()->defsprite.__int_angle = i;
bag.Info->ActorInfo()->defsprite.angle = DAngle::fromDeg(i);
bag.Info->ActorInfo()->DefaultFlags |= DEFF_ANG;
}

View file

@ -84,7 +84,7 @@ DEFINE_FIELD_X(walltype, walltype, yrepeat)
DEFINE_FIELD_NAMED_X(tspritetype, tspritetype, sectp, sector)
DEFINE_FIELD_X(tspritetype, tspritetype, cstat)
DEFINE_FIELD_X(tspritetype, tspritetype, statnum)
DEFINE_FIELD_NAMED_X(tspritetype, tspritetype, __int_angle, ang)
DEFINE_FIELD_X(tspritetype, tspritetype, angle)
DEFINE_FIELD_X(tspritetype, tspritetype, xvel)
DEFINE_FIELD_X(tspritetype, tspritetype, yvel)
DEFINE_FIELD_X(tspritetype, tspritetype, zvel)

View file

@ -477,7 +477,7 @@ void dbLoadMap(const char* pPath, int* pX, int* pY, int* pZ, short* pAngle, int*
pSprite->picnum = LittleShort(load.picnum);
int secno = LittleShort(load.sectnum);
pSprite->statnum = LittleShort(load.statnum);
pSprite->__int_angle = LittleShort(load.ang);
pSprite->angle = DAngle::fromBuild(LittleShort(load.ang));
pSprite->intowner = LittleShort(load.owner);
pSprite->xvel = LittleShort(load.index);
pSprite->yvel = LittleShort(load.yvel);

View file

@ -628,7 +628,7 @@ void ProcessSpriteTag(DExhumedActor* pActor, int nLotag, int nHitag)
{
auto pSector = pActor->sector();
pSector->Speed = nSpeed;
pSector->Flag |= pActor->spr.int_ang();
pSector->Flag |= pActor->spr.intangle;
DeleteActor(pActor);
return;

View file

@ -379,7 +379,7 @@ void StartRegenerate(DExhumedActor* pActor)
if (!(currentLevel->gameflags & LEVEL_EX_MULTI))
{
pActor->spr.__int_angle /= 5;
pActor->spr.intangle /= 5; // what is this?
}
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;

View file

@ -1998,7 +1998,7 @@ inline int TEST_BOOL11(DSWActor* sp) { return sp->spr.extra & SPRX_BOOL11; }
inline int16_t SP_TAG1(DSWActor* actor) { return actor->spr.hitag; }
inline int16_t& SP_TAG2(DSWActor* actor) { return actor->spr.lotag; }
inline uint8_t& SP_TAG3(DSWActor* actor) { return actor->spr.clipdist; }
inline int16_t& SP_TAG4(DSWActor* actor) { return actor->spr.__int_angle; } // this may not be transitioned to a real angular type
inline int16_t& SP_TAG4(DSWActor* actor) { return actor->spr.intangle; } // this may not be transitioned to a real angular type
inline int16_t& SP_TAG5(DSWActor* actor) { return actor->spr.xvel; }
inline int16_t& SP_TAG6(DSWActor* actor) { return actor->spr.yvel; }
inline uint8_t& SP_TAG7(DSWActor* actor) { return MSB_VAR(actor->spr.zvel); }

View file

@ -7,7 +7,7 @@ class CoreActor native
//native int16 picnum; // access is disabled to allow later refactoring.
native readonly Vector3 pos;
native readonly int16 statnum;
native int16 ang;
//native int16 ang;
native int16 xvel;
native int16 yvel;
native int16 zvel, inittype; // inittype, type and flags are for Blood.

View file

@ -276,7 +276,7 @@ struct tspritetype native
native int16 cstat;
//native int16 picnum;
native int16 statnum;
native int16 ang;
//native int16 ang;
/* these are not needed for tsprites
native int16 xvel;
native int16 yvel;