Merge branch 'zmaster'
This commit is contained in:
commit
bb4bd76257
15 changed files with 259 additions and 116 deletions
107
src/actor.h
107
src/actor.h
|
|
@ -818,22 +818,28 @@ public:
|
|||
return ( abs(X() - other->X()) < blockdist && abs(Y() - other->Y()) < blockdist);
|
||||
}
|
||||
|
||||
// 'absolute' is reserved for a linked portal implementation which needs
|
||||
// to distinguish between portal-aware and portal-unaware distance calculation.
|
||||
fixed_t AproxDistance(AActor *other, bool absolute = false)
|
||||
{
|
||||
return P_AproxDistance(X() - other->X(), Y() - other->Y());
|
||||
}
|
||||
|
||||
// same with 'ref' here.
|
||||
fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
|
||||
fixed_t AproxDistance(fixed_t otherx, fixed_t othery)
|
||||
{
|
||||
return P_AproxDistance(X() - otherx, Y() - othery);
|
||||
}
|
||||
|
||||
fixed_t AngleTo(fixed_t otherx, fixed_t othery)
|
||||
{
|
||||
return R_PointToAngle2(X(), Y(), otherx, othery);
|
||||
}
|
||||
|
||||
// 'absolute' is reserved for a linked portal implementation which needs
|
||||
// to distinguish between portal-aware and portal-unaware distance calculation.
|
||||
fixed_t AproxDistance(AActor *other, bool absolute = false)
|
||||
{
|
||||
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||
return P_AproxDistance(X() - otherpos.x, Y() - otherpos.y);
|
||||
}
|
||||
|
||||
fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false)
|
||||
{
|
||||
return P_AproxDistance(X() - other->X() + xadd, Y() - other->Y() + yadd);
|
||||
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||
return P_AproxDistance(X() - otherpos.x + xadd, Y() - otherpos.y + yadd);
|
||||
}
|
||||
|
||||
fixed_t AproxDistance3D(AActor *other, bool absolute = false)
|
||||
|
|
@ -844,18 +850,21 @@ public:
|
|||
// more precise, but slower version, being used in a few places
|
||||
fixed_t Distance2D(AActor *other, bool absolute = false)
|
||||
{
|
||||
return xs_RoundToInt(TVector2<double>(X() - other->X(), Y() - other->Y()).Length());
|
||||
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||
return xs_RoundToInt(TVector2<double>(X() - otherpos.x, Y() - otherpos.y).Length());
|
||||
}
|
||||
|
||||
// a full 3D version of the above
|
||||
fixed_t Distance3D(AActor *other, bool absolute = false)
|
||||
{
|
||||
return xs_RoundToInt(TVector3<double>(X() - other->X(), Y() - other->Y(), Z() - other->Z()).Length());
|
||||
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||
return xs_RoundToInt(TVector3<double>(X() - otherpos.x, Y() - otherpos.y, Z() - otherpos.z).Length());
|
||||
}
|
||||
|
||||
angle_t AngleTo(AActor *other, bool absolute = false) const
|
||||
angle_t AngleTo(AActor *other, bool absolute = false)
|
||||
{
|
||||
return R_PointToAngle2(X(), Y(), other->X(), other->Y());
|
||||
fixedvec3 otherpos = absolute ? other->Pos() : other->PosRelative(this);
|
||||
return R_PointToAngle2(X(), Y(), otherpos.x, otherpos.y);
|
||||
}
|
||||
|
||||
angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const
|
||||
|
|
@ -863,53 +872,71 @@ public:
|
|||
return R_PointToAngle2(X(), Y(), other->X() + oxofs, other->Y() + oyofs);
|
||||
}
|
||||
|
||||
fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL)
|
||||
{
|
||||
return R_PointToAngle2(X(), Y(), otherx, othery);
|
||||
}
|
||||
|
||||
fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false)
|
||||
{
|
||||
return R_PointToAngle2(myx, myy, other->X(), other->Y());
|
||||
}
|
||||
|
||||
fixedvec2 Vec2To(AActor *other) const
|
||||
{
|
||||
fixedvec2 ret = { other->X() - X(), other->Y() - Y() };
|
||||
fixedvec3 otherpos = other->PosRelative(this);
|
||||
fixedvec2 ret = { otherpos.x - X(), otherpos.y - Y() };
|
||||
return ret;
|
||||
}
|
||||
|
||||
fixedvec3 Vec3To(AActor *other) const
|
||||
{
|
||||
fixedvec3 ret = { other->X() - X(), other->Y() - Y(), other->Z() - Z() };
|
||||
fixedvec3 otherpos = other->PosRelative(this);
|
||||
fixedvec3 ret = { otherpos.x - X(), otherpos.y - Y(), otherpos.z - Z() };
|
||||
return ret;
|
||||
}
|
||||
|
||||
fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const
|
||||
fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false)
|
||||
{
|
||||
fixedvec2 ret = { X() + dx, Y() + dy };
|
||||
return ret;
|
||||
if (absolute)
|
||||
{
|
||||
fixedvec2 ret = { X() + dx, Y() + dy };
|
||||
return ret;
|
||||
}
|
||||
else return P_GetOffsetPosition(this, dx, dy);
|
||||
}
|
||||
|
||||
|
||||
fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const
|
||||
fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false)
|
||||
{
|
||||
fixedvec2 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
|
||||
Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) };
|
||||
return ret;
|
||||
if (absolute)
|
||||
{
|
||||
fixedvec2 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
|
||||
Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) };
|
||||
return ret;
|
||||
}
|
||||
else return P_GetOffsetPosition(this, FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]));
|
||||
}
|
||||
|
||||
fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const
|
||||
fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false)
|
||||
{
|
||||
fixedvec3 ret = { X() + dx, Y() + dy, Z() + dz };
|
||||
return ret;
|
||||
if (absolute)
|
||||
{
|
||||
fixedvec3 ret = { X() + dx, Y() + dy, Z() + dz };
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
fixedvec2 op = P_GetOffsetPosition(this, dx, dy);
|
||||
fixedvec3 pos = { op.x, op.y, Z() + dz };
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const
|
||||
fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false)
|
||||
{
|
||||
fixedvec3 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
|
||||
if (absolute)
|
||||
{
|
||||
fixedvec3 ret = { X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]),
|
||||
Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), Z() + dz };
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
fixedvec2 op = P_GetOffsetPosition(this, FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]));
|
||||
fixedvec3 pos = { op.x, op.y, Z() + dz };
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
|
||||
void ClearInterpolation();
|
||||
|
|
@ -1190,7 +1217,7 @@ public:
|
|||
return __pos;
|
||||
}
|
||||
|
||||
fixedvec3 PosRelative(AActor *other) const;
|
||||
fixedvec3 PosRelative(const AActor *other) const;
|
||||
fixedvec3 PosRelative(sector_t *sec) const;
|
||||
fixedvec3 PosRelative(line_t *line) const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue