- made AActor::__pos a genuine float vatiable.

This commit is contained in:
Christoph Oelckers 2016-03-25 15:43:20 +01:00
parent 3a598d672e
commit 8cdfbeea01
4 changed files with 36 additions and 42 deletions

View file

@ -1089,7 +1089,7 @@ public:
// info for drawing // info for drawing
// NOTE: The first member variable *must* be snext. // NOTE: The first member variable *must* be snext.
AActor *snext, **sprev; // links in sector (if needed) AActor *snext, **sprev; // links in sector (if needed)
fixedvec3 __pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions. DVector3 __Pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions.
/* /*
angle_t angle; angle_t angle;
@ -1382,36 +1382,36 @@ public:
fixed_t _f_X() const fixed_t _f_X() const
{ {
return __pos.x; return FLOAT2FIXED(__Pos.X);
} }
fixed_t _f_Y() const fixed_t _f_Y() const
{ {
return __pos.y; return FLOAT2FIXED(__Pos.Y);
} }
fixed_t _f_Z() const fixed_t _f_Z() const
{ {
return __pos.z; return FLOAT2FIXED(__Pos.Z);
} }
fixedvec3 _f_Pos() const fixedvec3 _f_Pos() const
{ {
return __pos; return{ _f_X(), _f_Y(), _f_Z() };
} }
double X() const double X() const
{ {
return FIXED2DBL(__pos.x); return __Pos.X;
} }
double Y() const double Y() const
{ {
return FIXED2DBL(__pos.y); return __Pos.Y;
} }
double Z() const double Z() const
{ {
return FIXED2DBL(__pos.z); return __Pos.Z;
} }
DVector3 Pos() const DVector3 Pos() const
{ {
return DVector3(X(), Y(), Z()); return __Pos;
} }
fixedvec3 _f_PosRelative(int grp) const; fixedvec3 _f_PosRelative(int grp) const;
@ -1459,11 +1459,11 @@ public:
} }
void _f_SetZ(fixed_t newz, bool moving = true) void _f_SetZ(fixed_t newz, bool moving = true)
{ {
__pos.z = newz; __Pos.Z = FIXED2DBL(newz);
} }
void _f_AddZ(fixed_t newz, bool moving = true) void _f_AddZ(fixed_t newz, bool moving = true)
{ {
__pos.z += newz; __Pos.Z += FIXED2DBL(newz);
} }
double Top() const double Top() const
{ {
@ -1475,53 +1475,49 @@ public:
} }
void SetZ(double newz, bool moving = true) void SetZ(double newz, bool moving = true)
{ {
__pos.z = FLOAT2FIXED(newz); __Pos.Z = newz;
} }
void AddZ(double newz, bool moving = true) void AddZ(double newz, bool moving = true)
{ {
__pos.z += FLOAT2FIXED(newz); __Pos.Z += newz;
if (!moving) PrevZ = __pos.z; if (!moving) PrevZ = _f_Z();
} }
// These are not for general use as they do not link the actor into the world! // These are not for general use as they do not link the actor into the world!
void SetXY(fixed_t xx, fixed_t yy) void SetXY(fixed_t xx, fixed_t yy)
{ {
__pos.x = xx; __Pos.X = FIXED2DBL(xx);
__pos.y = yy; __Pos.Y = FIXED2DBL(yy);
} }
void SetXY(const fixedvec2 &npos) void SetXY(const fixedvec2 &npos)
{ {
__pos.x = npos.x; __Pos.X = FIXED2DBL(npos.x);
__pos.y = npos.y; __Pos.Y = FIXED2DBL(npos.y);
} }
void SetXY(const DVector2 &npos) void SetXY(const DVector2 &npos)
{ {
__pos.x = FLOAT2FIXED(npos.X); __Pos.X = npos.X;
__pos.y = FLOAT2FIXED(npos.Y); __Pos.Y = npos.Y;
} }
void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz)
{ {
__pos.x = xx; __Pos.X = FIXED2DBL(xx);
__pos.y = yy; __Pos.Y = FIXED2DBL(yy);
__pos.z = zz; __Pos.Z = FIXED2DBL(zz);
} }
void SetXYZ(double xx, double yy, double zz) void SetXYZ(double xx, double yy, double zz)
{ {
__pos.x = FLOAT2FIXED(xx); __Pos = { xx,yy,zz };
__pos.y = FLOAT2FIXED(yy);
__pos.z = FLOAT2FIXED(zz);
} }
void SetXYZ(const fixedvec3 &npos) void SetXYZ(const fixedvec3 &npos)
{ {
__pos.x = npos.x; __Pos.X = FIXED2DBL(npos.x);
__pos.y = npos.y; __Pos.Y = FIXED2DBL(npos.y);
__pos.z = npos.z; __Pos.Z = FIXED2DBL(npos.z);
} }
void SetXYZ(const DVector3 &npos) void SetXYZ(const DVector3 &npos)
{ {
__pos.x = FLOAT2FIXED(npos.X); __Pos = npos;
__pos.y = FLOAT2FIXED(npos.Y);
__pos.z = FLOAT2FIXED(npos.Z);
} }
double VelXYToSpeed() const double VelXYToSpeed() const

View file

@ -235,9 +235,7 @@ void AActor::Serialize(FArchive &arc)
sprite = arc.ReadSprite(); sprite = arc.ReadSprite();
} }
arc << __pos.x arc << __Pos
<< __pos.y
<< __pos.z
<< Angles.Yaw << Angles.Yaw
<< Angles.Pitch << Angles.Pitch
<< Angles.Roll << Angles.Roll

View file

@ -1336,22 +1336,22 @@ inline sector_t *P_PointInSector(const DVector2 &pos)
inline fixedvec3 AActor::_f_PosRelative(int portalgroup) const inline fixedvec3 AActor::_f_PosRelative(int portalgroup) const
{ {
return __pos + Displacements.getOffset(Sector->PortalGroup, portalgroup); return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup);
} }
inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const
{ {
return __pos + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup); return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
} }
inline fixedvec3 AActor::_f_PosRelative(sector_t *sec) const inline fixedvec3 AActor::_f_PosRelative(sector_t *sec) const
{ {
return __pos + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup); return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
} }
inline fixedvec3 AActor::_f_PosRelative(line_t *line) const inline fixedvec3 AActor::_f_PosRelative(line_t *line) const
{ {
return __pos + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup); return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
} }
inline fixedvec3 _f_PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refsec = NULL) inline fixedvec3 _f_PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refsec = NULL)

View file

@ -632,9 +632,9 @@ void InitThingdef()
symt.AddSymbol(new PField(NAME_TID, TypeSInt32, VARF_Native, myoffsetof(AActor,tid))); symt.AddSymbol(new PField(NAME_TID, TypeSInt32, VARF_Native, myoffsetof(AActor,tid)));
symt.AddSymbol(new PField(NAME_TIDtoHate, TypeSInt32, VARF_Native, myoffsetof(AActor,TIDtoHate))); symt.AddSymbol(new PField(NAME_TIDtoHate, TypeSInt32, VARF_Native, myoffsetof(AActor,TIDtoHate)));
symt.AddSymbol(new PField(NAME_WaterLevel, TypeSInt32, VARF_Native, myoffsetof(AActor,waterlevel))); symt.AddSymbol(new PField(NAME_WaterLevel, TypeSInt32, VARF_Native, myoffsetof(AActor,waterlevel)));
symt.AddSymbol(new PField(NAME_X, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.x))); // must remain read-only! symt.AddSymbol(new PField(NAME_X, TypeFloat64, VARF_Native, myoffsetof(AActor,__Pos.X))); // must remain read-only!
symt.AddSymbol(new PField(NAME_Y, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.y))); // must remain read-only! symt.AddSymbol(new PField(NAME_Y, TypeFloat64, VARF_Native, myoffsetof(AActor,__Pos.Y))); // must remain read-only!
symt.AddSymbol(new PField(NAME_Z, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.z))); // must remain read-only! symt.AddSymbol(new PField(NAME_Z, TypeFloat64, VARF_Native, myoffsetof(AActor,__Pos.Z))); // must remain read-only!
symt.AddSymbol(new PField(NAME_VelX, TypeFloat64, VARF_Native, myoffsetof(AActor,Vel.X))); symt.AddSymbol(new PField(NAME_VelX, TypeFloat64, VARF_Native, myoffsetof(AActor,Vel.X)));
symt.AddSymbol(new PField(NAME_VelY, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Y))); symt.AddSymbol(new PField(NAME_VelY, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Y)));
symt.AddSymbol(new PField(NAME_VelZ, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Z))); symt.AddSymbol(new PField(NAME_VelZ, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Z)));