mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
Core/Position: code style cleanup of position.h; no change in functionality.
This commit is contained in:
@@ -3128,12 +3128,12 @@ void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float abs
|
||||
Trinity::NormalizeMapCoord(y);
|
||||
}
|
||||
|
||||
void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
|
||||
void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
|
||||
{
|
||||
GetNearPoint2D(x, y, distance2d+searcher_size, absAngle);
|
||||
z = GetPositionZ();
|
||||
// Should "searcher" be used instead of "this" when updating z coordinate ?
|
||||
UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
(searcher ? searcher : this)->UpdateAllowedPositionZ(x, y, z);
|
||||
|
||||
// if detection disabled, return first point
|
||||
if (!sWorld->getBoolConfig(CONFIG_DETECT_POS_COLLISION))
|
||||
@@ -3153,7 +3153,7 @@ void WorldObject::GetNearPoint(WorldObject const* /*searcher*/, float &x, float
|
||||
{
|
||||
GetNearPoint2D(x, y, distance2d + searcher_size, absAngle + angle);
|
||||
z = GetPositionZ();
|
||||
UpdateAllowedPositionZ(x, y, z);
|
||||
(searcher ? searcher : this)->UpdateAllowedPositionZ(x, y, z);
|
||||
if (IsWithinLOS(x, y, z))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
|
||||
|
||||
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const;
|
||||
void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const;
|
||||
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float angle = 0) const;
|
||||
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d = 0, float relAngle = 0) const;
|
||||
void MovePosition(Position &pos, float dist, float angle);
|
||||
Position GetNearPosition(float dist, float angle);
|
||||
void MovePositionToFirstCollision(Position &pos, float dist, float angle);
|
||||
|
||||
@@ -44,26 +44,6 @@ bool Position::IsPositionValid() const
|
||||
return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
|
||||
}
|
||||
|
||||
float Position::GetExactDist2d(const float x, const float y) const
|
||||
{
|
||||
return std::sqrt(GetExactDist2dSq(x, y));
|
||||
}
|
||||
|
||||
float Position::GetExactDist2d(Position const* pos) const
|
||||
{
|
||||
return std::sqrt(GetExactDist2dSq(pos));
|
||||
}
|
||||
|
||||
float Position::GetExactDist(float x, float y, float z) const
|
||||
{
|
||||
return std::sqrt(GetExactDistSq(x, y, z));
|
||||
}
|
||||
|
||||
float Position::GetExactDist(Position const* pos) const
|
||||
{
|
||||
return std::sqrt(GetExactDistSq(pos));
|
||||
}
|
||||
|
||||
void Position::GetPositionOffsetTo(Position const& endPos, Position& retOffset) const
|
||||
{
|
||||
float dx = endPos.GetPositionX() - GetPositionX();
|
||||
@@ -82,25 +62,6 @@ Position Position::GetPositionWithOffset(Position const& offset) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
float Position::GetAngle(Position const* pos) const
|
||||
{
|
||||
if (!pos)
|
||||
return 0;
|
||||
|
||||
return GetAngle(pos->GetPositionX(), pos->GetPositionY());
|
||||
}
|
||||
|
||||
// Return angle in range 0..2*pi
|
||||
float Position::GetAngle(float x, float y) const
|
||||
{
|
||||
float dx = x - GetPositionX();
|
||||
float dy = y - GetPositionY();
|
||||
|
||||
float ang = std::atan2(dy, dx);
|
||||
ang = (ang >= 0) ? ang : 2 * float(M_PI) + ang;
|
||||
return ang;
|
||||
}
|
||||
|
||||
void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) const
|
||||
{
|
||||
float dx = GetPositionX() - x;
|
||||
|
||||
@@ -61,36 +61,13 @@ private:
|
||||
|
||||
public:
|
||||
bool operator==(Position const& a);
|
||||
bool operator!=(Position const& a) { return !(operator==(a)); }
|
||||
|
||||
inline bool operator!=(Position const& a)
|
||||
{
|
||||
return !(operator==(a));
|
||||
}
|
||||
|
||||
void Relocate(float x, float y)
|
||||
{
|
||||
m_positionX = x; m_positionY = y;
|
||||
}
|
||||
|
||||
void Relocate(float x, float y, float z)
|
||||
{
|
||||
m_positionX = x; m_positionY = y; m_positionZ = z;
|
||||
}
|
||||
|
||||
void Relocate(float x, float y, float z, float orientation)
|
||||
{
|
||||
m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation);
|
||||
}
|
||||
|
||||
void Relocate(Position const& pos)
|
||||
{
|
||||
m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation);
|
||||
}
|
||||
|
||||
void Relocate(Position const* pos)
|
||||
{
|
||||
m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation);
|
||||
}
|
||||
void Relocate(float x, float y) { m_positionX = x; m_positionY = y; }
|
||||
void Relocate(float x, float y, float z) { m_positionX = x; m_positionY = y; m_positionZ = z; }
|
||||
void Relocate(float x, float y, float z, float o) { *this = { x,y,z,o }; }
|
||||
void Relocate(Position const& pos) { *this = pos; }
|
||||
void Relocate(Position const* pos) { *this = *pos; }
|
||||
|
||||
void RelocateOffset(Position const& offset);
|
||||
|
||||
@@ -104,21 +81,9 @@ public:
|
||||
float GetPositionZ() const { return m_positionZ; }
|
||||
float GetOrientation() const { return m_orientation; }
|
||||
|
||||
void GetPosition(float &x, float &y) const
|
||||
{
|
||||
x = m_positionX; y = m_positionY;
|
||||
}
|
||||
|
||||
void GetPosition(float &x, float &y, float &z) const
|
||||
{
|
||||
x = m_positionX; y = m_positionY; z = m_positionZ;
|
||||
}
|
||||
|
||||
void GetPosition(float &x, float &y, float &z, float &o) const
|
||||
{
|
||||
x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation;
|
||||
}
|
||||
|
||||
void GetPosition(float &x, float &y) const { x = m_positionX; y = m_positionY; }
|
||||
void GetPosition(float &x, float &y, float &z) const { GetPosition(x, y); z = m_positionZ; }
|
||||
void GetPosition(float &x, float &y, float &z, float &o) const { GetPosition(x, y, z); o = m_orientation; }
|
||||
Position GetPosition() const { return *this; }
|
||||
|
||||
Streamer<XY> PositionXYStream() { return Streamer<XY>(*this); }
|
||||
@@ -134,78 +99,50 @@ public:
|
||||
|
||||
float GetExactDist2dSq(const float x, const float y) const
|
||||
{
|
||||
float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy;
|
||||
float dx = m_positionX - x;
|
||||
float dy = m_positionY - y;
|
||||
return dx*dx + dy*dy;
|
||||
}
|
||||
float GetExactDist2dSq(Position const& pos) const { return GetExactDist2dSq(pos.m_positionX, pos.m_positionY); }
|
||||
float GetExactDist2dSq(Position const* pos) const { return GetExactDist2dSq(*pos); }
|
||||
|
||||
float GetExactDist2d(const float x, const float y) const;
|
||||
|
||||
float GetExactDist2dSq(Position const& pos) const
|
||||
{
|
||||
float dx = m_positionX - pos.m_positionX; float dy = m_positionY - pos.m_positionY; return dx*dx + dy*dy;
|
||||
}
|
||||
|
||||
float GetExactDist2d(Position const& pos) const
|
||||
{
|
||||
return std::sqrt(GetExactDist2dSq(pos));
|
||||
}
|
||||
|
||||
float GetExactDist2dSq(Position const* pos) const
|
||||
{
|
||||
float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy;
|
||||
}
|
||||
|
||||
float GetExactDist2d(Position const* pos) const;
|
||||
float GetExactDist2d(const float x, const float y) const { return std::sqrt(GetExactDist2dSq(x, y)); }
|
||||
float GetExactDist2d(Position const& pos) const { return GetExactDist2d(pos.m_positionX, pos.m_positionY); }
|
||||
float GetExactDist2d(Position const* pos) const { return GetExactDist2d(*pos); }
|
||||
|
||||
float GetExactDistSq(float x, float y, float z) const
|
||||
{
|
||||
float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz;
|
||||
float dz = m_positionZ - z;
|
||||
return GetExactDist2dSq(x, y) + dz*dz;
|
||||
}
|
||||
float GetExactDistSq(Position const& pos) const { return GetExactDistSq(pos.m_positionX, pos.m_positionY, pos.m_positionZ); }
|
||||
float GetExactDistSq(Position const* pos) const { return GetExactDistSq(*pos); }
|
||||
|
||||
float GetExactDist(float x, float y, float z) const;
|
||||
|
||||
float GetExactDistSq(Position const& pos) const
|
||||
{
|
||||
float dx = m_positionX - pos.m_positionX; float dy = m_positionY - pos.m_positionY; float dz = m_positionZ - pos.m_positionZ; return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
float GetExactDist(Position const& pos) const
|
||||
{
|
||||
return std::sqrt(GetExactDistSq(pos));
|
||||
}
|
||||
|
||||
float GetExactDistSq(Position const* pos) const
|
||||
{
|
||||
float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
float GetExactDist(Position const* pos) const;
|
||||
float GetExactDist(float x, float y, float z) const { return std::sqrt(GetExactDistSq(x, y, z)); }
|
||||
float GetExactDist(Position const& pos) const { return GetExactDist(pos.m_positionX, pos.m_positionY, pos.m_positionZ); }
|
||||
float GetExactDist(Position const* pos) const { return GetExactDist(*pos); }
|
||||
|
||||
void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const;
|
||||
Position GetPositionWithOffset(Position const& offset) const;
|
||||
|
||||
float GetAngle(Position const* pos) const;
|
||||
float GetAngle(Position const& pos) const
|
||||
float GetAngle(float x, float y) const
|
||||
{
|
||||
return GetAngle(pos.m_positionX, pos.m_positionY);
|
||||
}
|
||||
float GetAngle(float x, float y) const;
|
||||
float GetRelativeAngle(Position const* pos) const
|
||||
{
|
||||
return GetAngle(pos) - m_orientation;
|
||||
float dx = m_positionX - x;
|
||||
float dy = m_positionY - y;
|
||||
return NormalizeOrientation(std::atan2(dy, dx));
|
||||
}
|
||||
float GetAngle(Position const& pos) const { return GetAngle(pos.m_positionX, pos.m_positionY); }
|
||||
float GetAngle(Position const* pos) const { return GetAngle(*pos); }
|
||||
|
||||
float GetAbsoluteAngle(float relAngle) const { return NormalizeOrientation(relAngle + m_orientation); }
|
||||
float GetRelativeAngle(float absAngle) const { return NormalizeOrientation(absAngle - m_orientation); }
|
||||
float GetRelativeAngle(float x, float y) const { return GetRelativeAngle(GetAngle(x, y)); }
|
||||
float GetRelativeAngle(Position const* pos) const { return GetRelativeAngle(GetAngle(pos)); }
|
||||
|
||||
float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - m_orientation; }
|
||||
void GetSinCos(float x, float y, float &vsin, float &vcos) const;
|
||||
|
||||
bool IsInDist2d(float x, float y, float dist) const
|
||||
{
|
||||
return GetExactDist2dSq(x, y) < dist * dist;
|
||||
}
|
||||
|
||||
bool IsInDist2d(Position const* pos, float dist) const
|
||||
{
|
||||
return GetExactDist2dSq(pos) < dist * dist;
|
||||
}
|
||||
bool IsInDist2d(float x, float y, float dist) const { return GetExactDist2dSq(x, y) < dist * dist; }
|
||||
bool IsInDist2d(Position const* pos, float dist) const { return GetExactDist2dSq(pos) < dist * dist; }
|
||||
|
||||
bool IsInDist(float x, float y, float z, float dist) const { return GetExactDistSq(x, y, z) < dist * dist; }
|
||||
bool IsInDist(Position const& pos, float dist) const { return GetExactDistSq(pos) < dist * dist; }
|
||||
@@ -213,15 +150,14 @@ public:
|
||||
|
||||
bool IsWithinBox(Position const& center, float xradius, float yradius, float zradius) const;
|
||||
|
||||
/*
|
||||
search using this relation: dist2d < radius && abs(dz) < height
|
||||
*/
|
||||
// dist2d < radius && abs(dz) < height
|
||||
bool IsWithinDoubleVerticalCylinder(Position const* center, float radius, float height) const;
|
||||
|
||||
bool HasInArc(float arcangle, Position const* pos, float border = 2.0f) const;
|
||||
bool HasInLine(Position const* pos, float objSize, float width) const;
|
||||
std::string ToString() const;
|
||||
|
||||
// modulos a radian orientation to the range of 0..2PI
|
||||
// constrain arbitrary radian orientation to interval [0,2*PI)
|
||||
static float NormalizeOrientation(float o);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user