mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- floatified AActor::Prev plus the stuff using it.
- rewrote some coordinate functions in AActor to use real float math instead of converting back and forth between float and fixed.
This commit is contained in:
parent
2b33601d00
commit
1125101b37
13 changed files with 108 additions and 92 deletions
57
src/actor.h
57
src/actor.h
|
@ -742,13 +742,13 @@ public:
|
||||||
// What species am I?
|
// What species am I?
|
||||||
virtual FName GetSpecies();
|
virtual FName GetSpecies();
|
||||||
|
|
||||||
double GetBobOffset(fixed_t ticfrac = 0) const
|
double GetBobOffset(double ticfrac = 0) const
|
||||||
{
|
{
|
||||||
if (!(flags2 & MF2_FLOATBOB))
|
if (!(flags2 & MF2_FLOATBOB))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return BobSin(FloatBobPhase + level.maptime + FIXED2FLOAT(ticfrac));
|
return BobSin(FloatBobPhase + level.maptime + ticfrac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -850,8 +850,8 @@ public:
|
||||||
// more precise, but slower version, being used in a few places
|
// more precise, but slower version, being used in a few places
|
||||||
double Distance2D(AActor *other, bool absolute = false)
|
double Distance2D(AActor *other, bool absolute = false)
|
||||||
{
|
{
|
||||||
fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this);
|
DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||||
return (DVector2(_f_X() - otherpos.x, _f_Y() - otherpos.y).Length())/FRACUNIT;
|
return (Pos().XY() - otherpos).Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
double Distance2D(double x, double y) const
|
double Distance2D(double x, double y) const
|
||||||
|
@ -860,10 +860,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// a full 3D version of the above
|
// a full 3D version of the above
|
||||||
fixed_t Distance3D(AActor *other, bool absolute = false)
|
double Distance3D(AActor *other, bool absolute = false)
|
||||||
{
|
{
|
||||||
fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this);
|
DVector3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||||
return xs_RoundToInt(DVector3(_f_X() - otherpos.x, _f_Y() - otherpos.y, _f_Z() - otherpos.z).Length());
|
return (Pos() - otherpos).Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
angle_t __f_AngleTo(AActor *other, bool absolute = false)
|
angle_t __f_AngleTo(AActor *other, bool absolute = false)
|
||||||
|
@ -879,19 +879,20 @@ public:
|
||||||
|
|
||||||
DAngle AngleTo(AActor *other, bool absolute = false)
|
DAngle AngleTo(AActor *other, bool absolute = false)
|
||||||
{
|
{
|
||||||
fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this);
|
DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||||
return VecToAngle(otherpos.x - _f_X(), otherpos.y - _f_Y());
|
return VecToAngle(otherpos - Pos().XY());
|
||||||
}
|
}
|
||||||
|
|
||||||
DAngle AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
|
DAngle AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
|
||||||
{
|
{
|
||||||
fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this);
|
fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this);
|
||||||
return VecToAngle(otherpos.y + oxofs - _f_Y(), otherpos.x + oyofs - _f_X());
|
return VecToAngle(otherpos.x + oxofs - _f_X(), otherpos.y + oyofs - _f_Y());
|
||||||
}
|
}
|
||||||
|
|
||||||
DAngle AngleTo(AActor *other, double oxofs, double oyofs, bool absolute = false) const
|
DAngle AngleTo(AActor *other, double oxofs, double oyofs, bool absolute = false) const
|
||||||
{
|
{
|
||||||
return FIXED2DBL(AngleTo(other, FLOAT2FIXED(oxofs), FLOAT2FIXED(oyofs), absolute));
|
DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||||
|
return VecToAngle(otherpos - Pos() + DVector2(oxofs, oyofs));
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedvec2 _f_Vec2To(AActor *other) const
|
fixedvec2 _f_Vec2To(AActor *other) const
|
||||||
|
@ -910,14 +911,12 @@ public:
|
||||||
|
|
||||||
DVector2 Vec2To(AActor *other) const
|
DVector2 Vec2To(AActor *other) const
|
||||||
{
|
{
|
||||||
fixedvec3 otherpos = other->_f_PosRelative(this);
|
return other->PosRelative(this) - Pos();
|
||||||
return{ FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DVector3 Vec3To(AActor *other) const
|
DVector3 Vec3To(AActor *other) const
|
||||||
{
|
{
|
||||||
fixedvec3 otherpos = other->_f_PosRelative(this);
|
return other->PosRelative(this) - Pos();
|
||||||
return { FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()), FIXED2DBL(otherpos.z - _f_Z()) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false)
|
fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false)
|
||||||
|
@ -1089,14 +1088,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)
|
||||||
DVector3 __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;
|
|
||||||
fixed_t pitch;
|
|
||||||
angle_t roll; // This was fixed_t before, which is probably wrong
|
|
||||||
fixedvec3 vel;
|
|
||||||
*/
|
|
||||||
|
|
||||||
DRotator Angles;
|
DRotator Angles;
|
||||||
DVector3 Vel;
|
DVector3 Vel;
|
||||||
|
@ -1321,8 +1313,7 @@ public:
|
||||||
FDecalBase *DecalGenerator;
|
FDecalBase *DecalGenerator;
|
||||||
|
|
||||||
// [RH] Used to interpolate the view to get >35 FPS
|
// [RH] Used to interpolate the view to get >35 FPS
|
||||||
fixed_t PrevX, PrevY, PrevZ;
|
DVector3 Prev;
|
||||||
//angle_t PrevAngle;
|
|
||||||
DRotator PrevAngles;
|
DRotator PrevAngles;
|
||||||
int PrevPortalGroup;
|
int PrevPortalGroup;
|
||||||
|
|
||||||
|
@ -1419,6 +1410,11 @@ public:
|
||||||
fixedvec3 _f_PosRelative(sector_t *sec) const;
|
fixedvec3 _f_PosRelative(sector_t *sec) const;
|
||||||
fixedvec3 _f_PosRelative(line_t *line) const;
|
fixedvec3 _f_PosRelative(line_t *line) const;
|
||||||
|
|
||||||
|
DVector3 PosRelative(int grp) const;
|
||||||
|
DVector3 PosRelative(const AActor *other) const;
|
||||||
|
DVector3 PosRelative(sector_t *sec) const;
|
||||||
|
DVector3 PosRelative(line_t *line) const;
|
||||||
|
|
||||||
fixed_t SoundX() const
|
fixed_t SoundX() const
|
||||||
{
|
{
|
||||||
return _f_X();
|
return _f_X();
|
||||||
|
@ -1431,14 +1427,9 @@ public:
|
||||||
{
|
{
|
||||||
return _f_Z();
|
return _f_Z();
|
||||||
}
|
}
|
||||||
fixedvec3 InterpolatedPosition(fixed_t ticFrac) const
|
DVector3 InterpolatedPosition(double ticFrac) const
|
||||||
{
|
{
|
||||||
fixedvec3 ret;
|
return Prev + (ticFrac * (Pos() - Prev));
|
||||||
|
|
||||||
ret.x = PrevX + FixedMul (ticFrac, _f_X() - PrevX);
|
|
||||||
ret.y = PrevY + FixedMul (ticFrac, _f_Y() - PrevY);
|
|
||||||
ret.z = PrevZ + FixedMul (ticFrac, _f_Z() - PrevZ);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
fixedvec3 PosPlusZ(fixed_t zadd) const
|
fixedvec3 PosPlusZ(fixed_t zadd) const
|
||||||
{
|
{
|
||||||
|
@ -1480,7 +1471,7 @@ public:
|
||||||
void AddZ(double newz, bool moving = true)
|
void AddZ(double newz, bool moving = true)
|
||||||
{
|
{
|
||||||
__Pos.Z += newz;
|
__Pos.Z += newz;
|
||||||
if (!moving) PrevZ = _f_Z();
|
if (!moving) Prev.Z = 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!
|
||||||
|
|
|
@ -2429,7 +2429,7 @@ void AM_drawWalls (bool allmap)
|
||||||
bool portalmode = numportalgroups > 0 && pg != MapPortalGroup;
|
bool portalmode = numportalgroups > 0 && pg != MapPortalGroup;
|
||||||
if (pg == p)
|
if (pg == p)
|
||||||
{
|
{
|
||||||
offset = Displacements.getOffset(pg, MapPortalGroup);
|
offset = Displacements._f_getOffset(pg, MapPortalGroup);
|
||||||
}
|
}
|
||||||
else if (p == -1 && (pg == MapPortalGroup || !am_portaloverlay))
|
else if (p == -1 && (pg == MapPortalGroup || !am_portaloverlay))
|
||||||
{
|
{
|
||||||
|
|
|
@ -2545,8 +2545,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele
|
||||||
if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove)
|
if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove)
|
||||||
{
|
{
|
||||||
// CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions.
|
// CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions.
|
||||||
fixed_t oldX = actor->_f_X();
|
DVector2 old = actor->Pos();
|
||||||
fixed_t oldY = actor->_f_Y();
|
|
||||||
int oldgroup = actor->PrevPortalGroup;
|
int oldgroup = actor->PrevPortalGroup;
|
||||||
FTextureID oldFloor = actor->floorpic;
|
FTextureID oldFloor = actor->floorpic;
|
||||||
|
|
||||||
|
@ -2559,12 +2558,12 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele
|
||||||
// (copied from A_SerpentChase - it applies to everything with CANTLEAVEFLOORPIC!)
|
// (copied from A_SerpentChase - it applies to everything with CANTLEAVEFLOORPIC!)
|
||||||
if (actor->flags2&MF2_CANTLEAVEFLOORPIC && actor->floorpic != oldFloor )
|
if (actor->flags2&MF2_CANTLEAVEFLOORPIC && actor->floorpic != oldFloor )
|
||||||
{
|
{
|
||||||
if (P_TryMove(actor, oldX, oldY, false))
|
if (P_TryMove(actor, old, false))
|
||||||
{
|
{
|
||||||
if (nomonsterinterpolation)
|
if (nomonsterinterpolation)
|
||||||
{
|
{
|
||||||
actor->PrevX = oldX;
|
actor->Prev.X = old.X;
|
||||||
actor->PrevY = oldY;
|
actor->Prev.Y = old.Y;
|
||||||
actor->PrevPortalGroup = oldgroup;
|
actor->PrevPortalGroup = oldgroup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2299,8 +2299,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y,
|
||||||
{
|
{
|
||||||
thing->UnlinkFromWorld();
|
thing->UnlinkFromWorld();
|
||||||
thing->SetXY(tm.x + port->mXDisplacement, tm.y + port->mYDisplacement);
|
thing->SetXY(tm.x + port->mXDisplacement, tm.y + port->mYDisplacement);
|
||||||
thing->PrevX += port->mXDisplacement;
|
thing->Prev.X += FIXED2DBL(port->mXDisplacement);
|
||||||
thing->PrevY += port->mYDisplacement;
|
thing->Prev.Y += FIXED2DBL(port->mYDisplacement);
|
||||||
thing->LinkToWorld();
|
thing->LinkToWorld();
|
||||||
P_FindFloorCeiling(thing);
|
P_FindFloorCeiling(thing);
|
||||||
portalcrossed = true;
|
portalcrossed = true;
|
||||||
|
|
|
@ -870,7 +870,7 @@ bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item)
|
||||||
|
|
||||||
void FMultiBlockLinesIterator::startIteratorForGroup(int group)
|
void FMultiBlockLinesIterator::startIteratorForGroup(int group)
|
||||||
{
|
{
|
||||||
offset = Displacements.getOffset(basegroup, group);
|
offset = Displacements._f_getOffset(basegroup, group);
|
||||||
offset.x += checkpoint.x;
|
offset.x += checkpoint.x;
|
||||||
offset.y += checkpoint.y;
|
offset.y += checkpoint.y;
|
||||||
cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(offset.x, offset.y);
|
cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(offset.x, offset.y);
|
||||||
|
@ -1104,7 +1104,7 @@ bool FMultiBlockThingsIterator::Next(FMultiBlockThingsIterator::CheckResult *ite
|
||||||
if (thing != NULL)
|
if (thing != NULL)
|
||||||
{
|
{
|
||||||
item->thing = thing;
|
item->thing = thing;
|
||||||
item->position = checkpoint + Displacements.getOffset(basegroup, thing->Sector->PortalGroup);
|
item->position = checkpoint + Displacements._f_getOffset(basegroup, thing->Sector->PortalGroup);
|
||||||
item->portalflags = portalflags;
|
item->portalflags = portalflags;
|
||||||
|
|
||||||
// same as above in floating point. This is here so that this stuff can be converted piece by piece.
|
// same as above in floating point. This is here so that this stuff can be converted piece by piece.
|
||||||
|
@ -1146,7 +1146,7 @@ bool FMultiBlockThingsIterator::Next(FMultiBlockThingsIterator::CheckResult *ite
|
||||||
|
|
||||||
void FMultiBlockThingsIterator::startIteratorForGroup(int group)
|
void FMultiBlockThingsIterator::startIteratorForGroup(int group)
|
||||||
{
|
{
|
||||||
fixedvec2 offset = Displacements.getOffset(basegroup, group);
|
fixedvec2 offset = Displacements._f_getOffset(basegroup, group);
|
||||||
offset.x += checkpoint.x;
|
offset.x += checkpoint.x;
|
||||||
offset.y += checkpoint.y;
|
offset.y += checkpoint.y;
|
||||||
bbox.setBox(offset.x, offset.y, checkpoint.z);
|
bbox.setBox(offset.x, offset.y, checkpoint.z);
|
||||||
|
|
|
@ -2816,7 +2816,7 @@ void P_NightmareRespawn (AActor *mobj)
|
||||||
|
|
||||||
mo->skillrespawncount = mobj->skillrespawncount;
|
mo->skillrespawncount = mobj->skillrespawncount;
|
||||||
|
|
||||||
mo->PrevZ = FLOAT2FIXED(z); // Do not interpolate Z position if we changed it since spawning.
|
mo->Prev.Z = z; // Do not interpolate Z position if we changed it since spawning.
|
||||||
|
|
||||||
// spawn a teleport fog at old spot because of removal of the body?
|
// spawn a teleport fog at old spot because of removal of the body?
|
||||||
P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true);
|
P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true);
|
||||||
|
@ -3294,13 +3294,11 @@ void AActor::CheckPortalTransition(bool islinked)
|
||||||
AActor *port = Sector->SkyBoxes[sector_t::ceiling];
|
AActor *port = Sector->SkyBoxes[sector_t::ceiling];
|
||||||
if (Z() > port->specialf1)
|
if (Z() > port->specialf1)
|
||||||
{
|
{
|
||||||
fixedvec3 oldpos = _f_Pos();
|
DVector3 oldpos = Pos();
|
||||||
if (islinked && !moved) UnlinkFromWorld();
|
if (islinked && !moved) UnlinkFromWorld();
|
||||||
SetXYZ(_f_PosRelative(port->Sector));
|
SetXYZ(PosRelative(port->Sector));
|
||||||
PrevX += _f_X() - oldpos.x;
|
Prev = Pos() - oldpos;
|
||||||
PrevY += _f_Y() - oldpos.y;
|
Sector = P_PointInSector(Pos());
|
||||||
PrevZ += _f_Z() - oldpos.z;
|
|
||||||
Sector = P_PointInSector(_f_X(), _f_Y());
|
|
||||||
PrevPortalGroup = Sector->PortalGroup;
|
PrevPortalGroup = Sector->PortalGroup;
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
@ -3313,13 +3311,11 @@ void AActor::CheckPortalTransition(bool islinked)
|
||||||
AActor *port = Sector->SkyBoxes[sector_t::floor];
|
AActor *port = Sector->SkyBoxes[sector_t::floor];
|
||||||
if (Z() < port->specialf1 && floorz < port->specialf1)
|
if (Z() < port->specialf1 && floorz < port->specialf1)
|
||||||
{
|
{
|
||||||
fixedvec3 oldpos = _f_Pos();
|
DVector3 oldpos = Pos();
|
||||||
if (islinked && !moved) UnlinkFromWorld();
|
if (islinked && !moved) UnlinkFromWorld();
|
||||||
SetXYZ(_f_PosRelative(port->Sector));
|
SetXYZ(PosRelative(port->Sector));
|
||||||
PrevX += _f_X() - oldpos.x;
|
Prev = Pos() - oldpos;
|
||||||
PrevY += _f_Y() - oldpos.y;
|
Sector = P_PointInSector(Pos());
|
||||||
PrevZ += _f_Z() - oldpos.z;
|
|
||||||
Sector = P_PointInSector(_f_X(), _f_Y());
|
|
||||||
PrevPortalGroup = Sector->PortalGroup;
|
PrevPortalGroup = Sector->PortalGroup;
|
||||||
moved = true;
|
moved = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -757,32 +757,26 @@ int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, do
|
||||||
caller->Vel.Zero();
|
caller->Vel.Zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // needs fixing
|
|
||||||
// this is no fun with line portals
|
// this is no fun with line portals
|
||||||
if (flags & WARPF_WARPINTERPOLATION)
|
if (flags & WARPF_WARPINTERPOLATION)
|
||||||
{
|
{
|
||||||
// This just translates the movement but doesn't change the vector
|
// This just translates the movement but doesn't change the vector
|
||||||
fixedvec3 displacedold = old + Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup);
|
DVector3 displacedold = old + Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup);
|
||||||
caller->PrevX += caller->_f_X() - displacedold.x;
|
caller->Prev += caller->Pos() - displacedold;
|
||||||
caller->PrevY += caller->_f_Y() - displacedold.y;
|
|
||||||
caller->PrevZ += caller->_f_Z() - displacedold.z;
|
|
||||||
caller->PrevPortalGroup = caller->Sector->PortalGroup;
|
caller->PrevPortalGroup = caller->Sector->PortalGroup;
|
||||||
}
|
}
|
||||||
else if (flags & WARPF_COPYINTERPOLATION)
|
else if (flags & WARPF_COPYINTERPOLATION)
|
||||||
{
|
{
|
||||||
// Map both positions of the reference actor to the current portal group
|
// Map both positions of the reference actor to the current portal group
|
||||||
fixedvec3 displacedold = old + Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup);
|
DVector3 displacedold = old + Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup);
|
||||||
fixedvec3 displacedref = old + Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup);
|
DVector3 displacedref = old + Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup);
|
||||||
caller->PrevX = caller->_f_X() + displacedold.x - displacedref.x;
|
caller->Prev = caller->Pos() + displacedold - displacedref;
|
||||||
caller->PrevY = caller->_f_Y() + displacedold.y - displacedref.y;
|
|
||||||
caller->PrevZ = caller->_f_Z() + displacedold.z - displacedref.z;
|
|
||||||
caller->PrevPortalGroup = caller->Sector->PortalGroup;
|
caller->PrevPortalGroup = caller->Sector->PortalGroup;
|
||||||
}
|
}
|
||||||
else if (!(flags & WARPF_INTERPOLATE))
|
else if (!(flags & WARPF_INTERPOLATE))
|
||||||
{
|
{
|
||||||
caller->ClearInterpolation();
|
caller->ClearInterpolation();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB))
|
if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
|
||||||
while (!wsec->PortalBlocksMovement(sector_t::ceiling) && upperz > FLOAT2FIXED(wsec->SkyBoxes[sector_t::ceiling]->specialf1))
|
while (!wsec->PortalBlocksMovement(sector_t::ceiling) && upperz > FLOAT2FIXED(wsec->SkyBoxes[sector_t::ceiling]->specialf1))
|
||||||
{
|
{
|
||||||
sector_t *othersec = wsec->SkyBoxes[sector_t::ceiling]->Sector;
|
sector_t *othersec = wsec->SkyBoxes[sector_t::ceiling]->Sector;
|
||||||
fixedvec2 pos = Displacements.getOffset(startgroup, othersec->PortalGroup);
|
fixedvec2 pos = Displacements._f_getOffset(startgroup, othersec->PortalGroup);
|
||||||
fixed_t dx = position.x + pos.x;
|
fixed_t dx = position.x + pos.x;
|
||||||
fixed_t dy = position.y + pos.y;
|
fixed_t dy = position.y + pos.y;
|
||||||
processMask.setBit(othersec->PortalGroup);
|
processMask.setBit(othersec->PortalGroup);
|
||||||
|
@ -1221,7 +1221,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
|
||||||
while (!wsec->PortalBlocksMovement(sector_t::floor) && position.z < FLOAT2FIXED(wsec->SkyBoxes[sector_t::floor]->specialf1))
|
while (!wsec->PortalBlocksMovement(sector_t::floor) && position.z < FLOAT2FIXED(wsec->SkyBoxes[sector_t::floor]->specialf1))
|
||||||
{
|
{
|
||||||
sector_t *othersec = wsec->SkyBoxes[sector_t::floor]->Sector;
|
sector_t *othersec = wsec->SkyBoxes[sector_t::floor]->Sector;
|
||||||
fixedvec2 pos = Displacements.getOffset(startgroup, othersec->PortalGroup);
|
fixedvec2 pos = Displacements._f_getOffset(startgroup, othersec->PortalGroup);
|
||||||
fixed_t dx = position.x + pos.x;
|
fixed_t dx = position.x + pos.x;
|
||||||
fixed_t dy = position.y + pos.y;
|
fixed_t dy = position.y + pos.y;
|
||||||
processMask.setBit(othersec->PortalGroup | FPortalGroupArray::LOWER);
|
processMask.setBit(othersec->PortalGroup | FPortalGroupArray::LOWER);
|
||||||
|
@ -1236,7 +1236,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t
|
||||||
int thisgroup = startgroup;
|
int thisgroup = startgroup;
|
||||||
for (unsigned i = 0; i < groupsToCheck.Size();i++)
|
for (unsigned i = 0; i < groupsToCheck.Size();i++)
|
||||||
{
|
{
|
||||||
fixedvec2 disp = Displacements.getOffset(startgroup, thisgroup & ~FPortalGroupArray::FLAT);
|
fixedvec2 disp = Displacements._f_getOffset(startgroup, thisgroup & ~FPortalGroupArray::FLAT);
|
||||||
FBoundingBox box(position.x + disp.x, position.y + disp.y, checkradius);
|
FBoundingBox box(position.x + disp.x, position.y + disp.y, checkradius);
|
||||||
FBlockLinesIterator it(box);
|
FBlockLinesIterator it(box);
|
||||||
line_t *ld;
|
line_t *ld;
|
||||||
|
|
14
src/portal.h
14
src/portal.h
|
@ -54,7 +54,7 @@ struct FDisplacementTable
|
||||||
return data[x + size*y];
|
return data[x + size*y];
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedvec2 getOffset(int x, int y) const
|
fixedvec2 _f_getOffset(int x, int y) const
|
||||||
{
|
{
|
||||||
if (x == y)
|
if (x == y)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +63,18 @@ struct FDisplacementTable
|
||||||
}
|
}
|
||||||
return data[x + size*y].pos;
|
return data[x + size*y].pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DVector2 getOffset(int x, int y) const
|
||||||
|
{
|
||||||
|
if (x == y)
|
||||||
|
{
|
||||||
|
DVector2 nulvec = { 0,0 };
|
||||||
|
return nulvec; // shortcut for the most common case
|
||||||
|
}
|
||||||
|
fixedvec2 &p = data[x + size*y].pos;
|
||||||
|
return{ FIXED2DBL(p.x), FIXED2DBL(p.y) };
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FDisplacementTable Displacements;
|
extern FDisplacementTable Displacements;
|
||||||
|
|
42
src/r_defs.h
42
src/r_defs.h
|
@ -838,12 +838,12 @@ struct sector_t
|
||||||
// These may only be called if the portal has been validated
|
// These may only be called if the portal has been validated
|
||||||
fixedvec2 FloorDisplacement()
|
fixedvec2 FloorDisplacement()
|
||||||
{
|
{
|
||||||
return Displacements.getOffset(PortalGroup, SkyBoxes[sector_t::floor]->Sector->PortalGroup);
|
return Displacements._f_getOffset(PortalGroup, SkyBoxes[sector_t::floor]->Sector->PortalGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixedvec2 CeilingDisplacement()
|
fixedvec2 CeilingDisplacement()
|
||||||
{
|
{
|
||||||
return Displacements.getOffset(PortalGroup, SkyBoxes[sector_t::ceiling]->Sector->PortalGroup);
|
return Displacements._f_getOffset(PortalGroup, SkyBoxes[sector_t::ceiling]->Sector->PortalGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetTerrain(int pos) const;
|
int GetTerrain(int pos) const;
|
||||||
|
@ -1336,34 +1336,58 @@ 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 _f_Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup);
|
return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, portalgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const
|
inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const
|
||||||
{
|
{
|
||||||
return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
|
return _f_Pos() + Displacements._f_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 _f_Pos() + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
|
return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, sec->PortalGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fixedvec3 AActor::_f_PosRelative(line_t *line) const
|
inline fixedvec3 AActor::_f_PosRelative(line_t *line) const
|
||||||
{
|
{
|
||||||
return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
|
return _f_Pos() + Displacements._f_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)
|
||||||
|
{
|
||||||
|
return pos + Displacements._f_getOffset(refsec->PortalGroup, line->frontsector->PortalGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DVector3 AActor::PosRelative(int portalgroup) const
|
||||||
|
{
|
||||||
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DVector3 AActor::PosRelative(const AActor *other) const
|
||||||
|
{
|
||||||
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DVector3 AActor::PosRelative(sector_t *sec) const
|
||||||
|
{
|
||||||
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DVector3 AActor::PosRelative(line_t *line) const
|
||||||
|
{
|
||||||
|
return Pos() + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline DVector3 PosRelative(const DVector3 &pos, line_t *line, sector_t *refsec = NULL)
|
||||||
{
|
{
|
||||||
return pos + Displacements.getOffset(refsec->PortalGroup, line->frontsector->PortalGroup);
|
return pos + Displacements.getOffset(refsec->PortalGroup, line->frontsector->PortalGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void AActor::ClearInterpolation()
|
inline void AActor::ClearInterpolation()
|
||||||
{
|
{
|
||||||
PrevX = _f_X();
|
Prev = Pos();
|
||||||
PrevY = _f_Y();
|
|
||||||
PrevZ = _f_Z();
|
|
||||||
PrevAngles = Angles;
|
PrevAngles = Angles;
|
||||||
if (Sector) PrevPortalGroup = Sector->PortalGroup;
|
if (Sector) PrevPortalGroup = Sector->PortalGroup;
|
||||||
else PrevPortalGroup = 0;
|
else PrevPortalGroup = 0;
|
||||||
|
|
|
@ -1239,10 +1239,10 @@ void R_DrawSkyBoxes ()
|
||||||
extralight = 0;
|
extralight = 0;
|
||||||
R_SetVisibility (sky->args[0] * 0.25f);
|
R_SetVisibility (sky->args[0] * 0.25f);
|
||||||
|
|
||||||
fixedvec3 viewpos = sky->InterpolatedPosition(r_TicFrac);
|
DVector3 viewpos = sky->InterpolatedPosition(r_TicFracF);
|
||||||
viewx = viewpos.x;
|
viewx = FLOAT2FIXED(viewpos.X);
|
||||||
viewy = viewpos.y;
|
viewy = FLOAT2FIXED(viewpos.Y);
|
||||||
viewz = viewpos.z;
|
viewz = FLOAT2FIXED(viewpos.Z);
|
||||||
viewangle = savedangle + (sky->PrevAngles.Yaw + (sky->Angles.Yaw * r_TicFracF) - sky->PrevAngles.Yaw).BAMs();
|
viewangle = savedangle + (sky->PrevAngles.Yaw + (sky->Angles.Yaw * r_TicFracF) - sky->PrevAngles.Yaw).BAMs();
|
||||||
|
|
||||||
R_CopyStackedViewParameters();
|
R_CopyStackedViewParameters();
|
||||||
|
@ -1251,8 +1251,8 @@ void R_DrawSkyBoxes ()
|
||||||
{
|
{
|
||||||
extralight = pl->extralight;
|
extralight = pl->extralight;
|
||||||
R_SetVisibility (pl->visibility);
|
R_SetVisibility (pl->visibility);
|
||||||
viewx = pl->viewx - sky->Mate->_f_X() + sky->_f_X();
|
viewx = pl->viewx - FLOAT2FIXED(sky->Mate->X() + sky->X());
|
||||||
viewy = pl->viewy - sky->Mate->_f_Y() + sky->_f_Y();
|
viewy = pl->viewy - FLOAT2FIXED(sky->Mate->Y() + sky->Y());
|
||||||
viewz = pl->viewz;
|
viewz = pl->viewz;
|
||||||
viewangle = pl->viewangle;
|
viewangle = pl->viewangle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -767,10 +767,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// [RH] Interpolate the sprite's position to make it look smooth
|
// [RH] Interpolate the sprite's position to make it look smooth
|
||||||
fixedvec3 pos = thing->InterpolatedPosition(r_TicFrac);
|
DVector3 pos = thing->InterpolatedPosition(r_TicFracF);
|
||||||
fx = pos.x;
|
fx = FLOAT2FIXED(pos.X);
|
||||||
fy = pos.y;
|
fy = FLOAT2FIXED(pos.Y);
|
||||||
fz = pos.z + thing->_f_GetBobOffset(r_TicFrac);
|
fz = FLOAT2FIXED(pos.Z + thing->GetBobOffset(r_TicFracF));
|
||||||
|
|
||||||
tex = NULL;
|
tex = NULL;
|
||||||
voxel = NULL;
|
voxel = NULL;
|
||||||
|
|
|
@ -652,7 +652,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fixedvec2 disp = Displacements.getOffset(oldgroup, newgroup);
|
fixedvec2 disp = Displacements._f_getOffset(oldgroup, newgroup);
|
||||||
viewx = iview->oviewx + FixedMul(frac, iview->nviewx - iview->oviewx - disp.x);
|
viewx = iview->oviewx + FixedMul(frac, iview->nviewx - iview->oviewx - disp.x);
|
||||||
viewy = iview->oviewy + FixedMul(frac, iview->nviewy - iview->oviewy - disp.y);
|
viewy = iview->oviewy + FixedMul(frac, iview->nviewy - iview->oviewy - disp.y);
|
||||||
viewz = iview->oviewz + FixedMul(frac, iview->nviewz - iview->oviewz);
|
viewz = iview->oviewz + FixedMul(frac, iview->nviewz - iview->oviewz);
|
||||||
|
|
Loading…
Reference in a new issue