mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[7827] dd support 2d version for WorldObject::GetDistanceOrder.
This commit is contained in:
parent
788cdf9b3a
commit
592db69c0c
3 changed files with 15 additions and 7 deletions
|
|
@ -1162,17 +1162,25 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const
|
|||
return vMapManager->isInLineOfSight(GetMapId(), x, y, z+2.0f, ox, oy, oz+2.0f);
|
||||
}
|
||||
|
||||
bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2) const
|
||||
bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D /* = true */) const
|
||||
{
|
||||
float dx1 = GetPositionX() - obj1->GetPositionX();
|
||||
float dy1 = GetPositionY() - obj1->GetPositionY();
|
||||
float dz1 = GetPositionZ() - obj1->GetPositionZ();
|
||||
float distsq1 = dx1*dx1 + dy1*dy1 + dz1*dz1;
|
||||
float distsq1 = dx1*dx1 + dy1*dy1;
|
||||
if(is3D)
|
||||
{
|
||||
float dz1 = GetPositionZ() - obj1->GetPositionZ();
|
||||
distsq1 += dz1*dz1;
|
||||
}
|
||||
|
||||
float dx2 = GetPositionX() - obj2->GetPositionX();
|
||||
float dy2 = GetPositionY() - obj2->GetPositionY();
|
||||
float dz2 = GetPositionZ() - obj2->GetPositionZ();
|
||||
float distsq2 = dx2*dx2 + dy2*dy2 + dz2*dz2;
|
||||
float distsq2 = dx2*dx2 + dy2*dy2;
|
||||
if(is3D)
|
||||
{
|
||||
float dz2 = GetPositionZ() - obj2->GetPositionZ();
|
||||
distsq2 += dz2*dz2;
|
||||
}
|
||||
|
||||
return distsq1 < distsq2;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
|
|||
}
|
||||
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 GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D = true) const;
|
||||
bool IsInRange(WorldObject const* obj, float minRange, float maxRange) const;
|
||||
bool IsInRange2d(float x, float y, float minRange, float maxRange) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7826"
|
||||
#define REVISION_NR "7827"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue