mirror of
https://github.com/mangosfour/server.git
synced 2025-12-22 04:37:01 +00:00
[7826] Avoid use GetDistance* that used slow sqrt call where possible, other related speedups.
This commit is contained in:
parent
ff80f14d2d
commit
788cdf9b3a
21 changed files with 158 additions and 93 deletions
|
|
@ -424,18 +424,31 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
|||
virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); }
|
||||
|
||||
float GetDistance( const WorldObject* obj ) const;
|
||||
float GetDistance(const float x, const float y, const float z) const;
|
||||
float GetDistance(float x, float y, float z) const;
|
||||
float GetDistance2d(const WorldObject* obj) const;
|
||||
float GetDistance2d(const float x, const float y) const;
|
||||
float GetDistance2d(float x, float y) const;
|
||||
float GetDistanceZ(const WorldObject* obj) const;
|
||||
bool IsInMap(const WorldObject* obj) const
|
||||
{
|
||||
return IsInWorld() && obj->IsInWorld() && GetMapId()==obj->GetMapId() &&
|
||||
GetInstanceId()==obj->GetInstanceId() && InSamePhase(obj);
|
||||
}
|
||||
bool IsWithinDistInMap(const WorldObject* obj, const float dist2compare, const bool is3D = true) const;
|
||||
bool IsWithinLOS(const float x, const float y, const float z ) const;
|
||||
bool IsWithinDist(float x, float y, float z, float dist2compare, bool is3D = true) const;
|
||||
bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D) const;
|
||||
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const
|
||||
// use only if you will sure about placing both object at same map
|
||||
{
|
||||
return obj && _IsWithinDist(obj,dist2compare,is3D);
|
||||
}
|
||||
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const
|
||||
{
|
||||
return obj && IsInMap(obj) && _IsWithinDist(obj,dist2compare,is3D);
|
||||
}
|
||||
bool IsWithinLOS(float x, float y, float z) const;
|
||||
bool IsWithinLOSInMap(const WorldObject* obj) const;
|
||||
bool GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2) const;
|
||||
bool IsInRange(WorldObject const* obj, float minRange, float maxRange) const;
|
||||
bool IsInRange2d(float x, float y, float minRange, float maxRange) const;
|
||||
|
||||
float GetAngle( const WorldObject* obj ) const;
|
||||
float GetAngle( const float x, const float y ) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue