- 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
// NOTE: The first member variable *must* be snext.
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;
@ -1382,36 +1382,36 @@ public:
fixed_t _f_X() const
{
return __pos.x;
return FLOAT2FIXED(__Pos.X);
}
fixed_t _f_Y() const
{
return __pos.y;
return FLOAT2FIXED(__Pos.Y);
}
fixed_t _f_Z() const
{
return __pos.z;
return FLOAT2FIXED(__Pos.Z);
}
fixedvec3 _f_Pos() const
{
return __pos;
return{ _f_X(), _f_Y(), _f_Z() };
}
double X() const
{
return FIXED2DBL(__pos.x);
return __Pos.X;
}
double Y() const
{
return FIXED2DBL(__pos.y);
return __Pos.Y;
}
double Z() const
{
return FIXED2DBL(__pos.z);
return __Pos.Z;
}
DVector3 Pos() const
{
return DVector3(X(), Y(), Z());
return __Pos;
}
fixedvec3 _f_PosRelative(int grp) const;
@ -1459,11 +1459,11 @@ public:
}
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)
{
__pos.z += newz;
__Pos.Z += FIXED2DBL(newz);
}
double Top() const
{
@ -1475,53 +1475,49 @@ public:
}
void SetZ(double newz, bool moving = true)
{
__pos.z = FLOAT2FIXED(newz);
__Pos.Z = newz;
}
void AddZ(double newz, bool moving = true)
{
__pos.z += FLOAT2FIXED(newz);
if (!moving) PrevZ = __pos.z;
__Pos.Z += newz;
if (!moving) PrevZ = _f_Z();
}
// These are not for general use as they do not link the actor into the world!
void SetXY(fixed_t xx, fixed_t yy)
{
__pos.x = xx;
__pos.y = yy;
__Pos.X = FIXED2DBL(xx);
__Pos.Y = FIXED2DBL(yy);
}
void SetXY(const fixedvec2 &npos)
{
__pos.x = npos.x;
__pos.y = npos.y;
__Pos.X = FIXED2DBL(npos.x);
__Pos.Y = FIXED2DBL(npos.y);
}
void SetXY(const DVector2 &npos)
{
__pos.x = FLOAT2FIXED(npos.X);
__pos.y = FLOAT2FIXED(npos.Y);
__Pos.X = npos.X;
__Pos.Y = npos.Y;
}
void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz)
{
__pos.x = xx;
__pos.y = yy;
__pos.z = zz;
__Pos.X = FIXED2DBL(xx);
__Pos.Y = FIXED2DBL(yy);
__Pos.Z = FIXED2DBL(zz);
}
void SetXYZ(double xx, double yy, double zz)
{
__pos.x = FLOAT2FIXED(xx);
__pos.y = FLOAT2FIXED(yy);
__pos.z = FLOAT2FIXED(zz);
__Pos = { xx,yy,zz };
}
void SetXYZ(const fixedvec3 &npos)
{
__pos.x = npos.x;
__pos.y = npos.y;
__pos.z = npos.z;
__Pos.X = FIXED2DBL(npos.x);
__Pos.Y = FIXED2DBL(npos.y);
__Pos.Z = FIXED2DBL(npos.z);
}
void SetXYZ(const DVector3 &npos)
{
__pos.x = FLOAT2FIXED(npos.X);
__pos.y = FLOAT2FIXED(npos.Y);
__pos.z = FLOAT2FIXED(npos.Z);
__Pos = npos;
}
double VelXYToSpeed() const

View file

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

View file

@ -1336,22 +1336,22 @@ inline sector_t *P_PointInSector(const DVector2 &pos)
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
{
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
{
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
{
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)

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_TIDtoHate, TypeSInt32, VARF_Native, myoffsetof(AActor,TIDtoHate)));
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_Y, TypeFixed, 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_X, TypeFloat64, VARF_Native, myoffsetof(AActor,__Pos.X))); // 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, 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_VelY, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Y)));
symt.AddSymbol(new PField(NAME_VelZ, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Z)));