mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[10104] Cleaned up WorldObject::HasInArc
This commit is contained in:
parent
593f1e81b9
commit
11372496e5
3 changed files with 22 additions and 10 deletions
|
|
@ -112,6 +112,21 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
|
||||||
return IsValidMapCoord(loc.mapid,loc.coord_x,loc.coord_y,loc.coord_z,loc.orientation);
|
return IsValidMapCoord(loc.mapid,loc.coord_x,loc.coord_y,loc.coord_z,loc.orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// modulos a radian orientation to the range of 0..2PI
|
||||||
|
static float NormalizeOrientation(float o)
|
||||||
|
{
|
||||||
|
// fmod only supports positive numbers. Thus we have
|
||||||
|
// to emulate negative numbers
|
||||||
|
if(o < 0)
|
||||||
|
{
|
||||||
|
float mod = o *-1;
|
||||||
|
mod = fmod(mod, 2.0f*M_PI_F);
|
||||||
|
mod = -mod+2.0f*M_PI_F;
|
||||||
|
return mod;
|
||||||
|
}
|
||||||
|
return fmod(o, 2.0f*M_PI_F);
|
||||||
|
}
|
||||||
|
|
||||||
void RemoveAllObjectsInRemoveList();
|
void RemoveAllObjectsInRemoveList();
|
||||||
|
|
||||||
void LoadTransports();
|
void LoadTransports();
|
||||||
|
|
|
||||||
|
|
@ -1361,19 +1361,15 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
|
||||||
float arc = arcangle;
|
float arc = arcangle;
|
||||||
|
|
||||||
// move arc to range 0.. 2*pi
|
// move arc to range 0.. 2*pi
|
||||||
while( arc >= 2.0f * M_PI_F )
|
arc = MapManager::NormalizeOrientation(arc);
|
||||||
arc -= 2.0f * M_PI_F;
|
|
||||||
while( arc < 0 )
|
|
||||||
arc += 2.0f * M_PI_F;
|
|
||||||
|
|
||||||
float angle = GetAngle( obj );
|
float angle = GetAngle( obj );
|
||||||
angle -= m_orientation;
|
angle -= m_orientation;
|
||||||
|
|
||||||
// move angle to range -pi ... +pi
|
// move angle to range -pi ... +pi
|
||||||
while( angle > M_PI_F)
|
angle = MapManager::NormalizeOrientation(angle);
|
||||||
angle -= 2.0f * M_PI_F;
|
if(angle > M_PI_F)
|
||||||
while(angle < -M_PI_F)
|
angle -= 2.0f*M_PI_F;
|
||||||
angle += 2.0f * M_PI_F;
|
|
||||||
|
|
||||||
float lborder = -1 * (arc/2.0f); // in range -pi..0
|
float lborder = -1 * (arc/2.0f); // in range -pi..0
|
||||||
float rborder = (arc/2.0f); // in range 0..pi
|
float rborder = (arc/2.0f); // in range 0..pi
|
||||||
|
|
@ -1959,3 +1955,4 @@ bool WorldObject::IsControlledByPlayer() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10103"
|
#define REVISION_NR "10104"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue