OregonCore  revision fb2a440-git
Your Favourite TBC server
Position Struct Reference

#include <Position.h>

+ Inheritance diagram for Position:

Classes

struct  PositionXYStreamer
 
struct  PositionXYZOStreamer
 
struct  PositionXYZStreamer
 

Public Member Functions

 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
bool operator== (Position const &a)
 
bool operator!= (Position const &a)
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float orientation)
 
void Relocate (Position const &pos)
 
void Relocate (Position const *pos)
 
void RelocateOffset (Position const &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYStreamer PositionXYStream ()
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (float x, float y) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *pos) const
 
float GetAngle (float x, float y) const
 
float GetRelativeAngle (Position const *pos) const
 
float GetRelativeAngle (float x, float y) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, Position const *pos, float border=2.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
std::string ToString () const
 

Static Public Member Functions

static float NormalizeOrientation (float o)
 

Public Attributes

float m_positionX
 
float m_positionY
 
float m_positionZ
 

Private Attributes

float m_orientation
 

Detailed Description

Definition at line 25 of file Position.h.

Constructor & Destructor Documentation

Position::Position ( float  x = 0,
float  y = 0,
float  z = 0,
float  o = 0 
)
inline

Definition at line 27 of file Position.h.

Referenced by WorldObject::GetHitSpherePointFor().

float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
static float NormalizeOrientation(float o)
Definition: Position.h:204
float m_positionZ
Definition: Position.h:52
float m_orientation
Definition: Position.h:55
Position::Position ( Position const &  loc)
inline

Definition at line 30 of file Position.h.

References Relocate().

30 { Relocate(loc); }
void Relocate(float x, float y)
Definition: Position.h:65

Member Function Documentation

float Position::GetAngle ( float  x,
float  y 
) const

Definition at line 72 of file Position.cpp.

References GetPositionX(), and GetPositionY().

73 {
74  float dx = x - GetPositionX();
75  float dy = y - GetPositionY();
76 
77  float ang = std::atan2(dy, dx);
78  ang = (ang >= 0) ? ang : 2 * float(M_PI) + ang;
79  return ang;
80 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionX() const
Definition: Position.h:97
float Position::GetExactDist ( float  x,
float  y,
float  z 
) const
inline

Definition at line 150 of file Position.h.

References GetExactDistSq().

Referenced by WorldObject::CanDetectStealthOf(), Spell::CheckRange(), and Spell::EffectDummy().

151  {
152  return std::sqrt(GetExactDistSq(x, y, z));
153  }
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:145
float Position::GetExactDist ( Position const *  pos) const
inline

Definition at line 160 of file Position.h.

References GetAngle(), GetExactDistSq(), GetPositionOffsetTo(), and GetPositionWithOffset().

161  {
162  return std::sqrt(GetExactDistSq(pos));
163  }
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:145
float Position::GetExactDist2d ( const float  x,
const float  y 
) const
inline

Definition at line 130 of file Position.h.

References GetExactDist2dSq().

Referenced by HasInLine().

131  {
132  return std::sqrt(GetExactDist2dSq(x, y));
133  }
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:125
float Position::GetExactDist2d ( Position const *  pos) const
inline

Definition at line 140 of file Position.h.

References GetExactDist2dSq().

141  {
142  return std::sqrt(GetExactDist2dSq(pos));
143  }
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:125
float Position::GetExactDist2dSq ( float  x,
float  y 
) const
inline

Definition at line 125 of file Position.h.

Referenced by GetExactDist2d(), GetExactDistSq(), IsInDist2d(), and Oregon::MessageDistDeliverer::Visit().

126  {
127  float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy;
128  }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float Position::GetExactDist2dSq ( Position const *  pos) const
inline

Definition at line 135 of file Position.h.

References m_positionX, and m_positionY.

136  {
137  float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy;
138  }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float Position::GetExactDistSq ( float  x,
float  y,
float  z 
) const
inline

Definition at line 145 of file Position.h.

References GetExactDist2dSq().

Referenced by GetExactDist(), IsInDist(), and TargetDistanceOrder::operator()().

146  {
147  float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz;
148  }
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:125
float m_positionZ
Definition: Position.h:52
float Position::GetExactDistSq ( Position const *  pos) const
inline

Definition at line 155 of file Position.h.

References m_positionX, m_positionY, and m_positionZ.

156  {
157  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;
158  }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
float Position::GetOrientation ( ) const
inline

Definition at line 100 of file Position.h.

References m_orientation.

Referenced by BattlegroundAB::_NodeDeOccupied(), Player::_SaveBGData(), Player::ActivateTaxiPathTo(), Unit::CastSpell(), Spell::CheckCast(), ObjectAccessor::ConvertCorpseForPlayer(), Pet::CreateBaseAtCreature(), Player::CreateCorpse(), Spell::EffectBind(), Spell::EffectDuel(), Spell::EffectDummy(), Spell::EffectMomentMove(), Spell::EffectScriptEffect(), Spell::EffectStuck(), Spell::EffectSummonDeadPet(), Spell::EffectSummonObject(), Spell::EffectSummonObjectWild(), Spell::EffectSummonPet(), Spell::EffectTeleportUnits(), Spell::EffectTeleUnitsFaceCaster(), Spell::EffectTransmitted(), BattlegroundAV::EventPlayerAssaultsPoint(), GetPositionOffsetTo(), Creature::GetRespawnPosition(), Spell::GetSummonPosition(), ChatHandler::HandleAddTeleCommand(), ChatHandler::HandleAppearCommand(), Aura::HandleAuraDummy(), WorldSession::HandleBattlegroundArenaJoin(), WorldSession::HandleBattlegroundJoinOpcode(), OutdoorPvPSI::HandleDropFlag(), ChatHandler::HandleGameObjectCommand(), ChatHandler::HandleGoGraveyardCommand(), ChatHandler::HandleGoGridCommand(), ChatHandler::HandleGoTriggerCommand(), ChatHandler::HandleGoXYCommand(), ChatHandler::HandleGoXYZCommand(), ChatHandler::HandleGoZoneXYCommand(), ChatHandler::HandleGPSCommand(), ChatHandler::HandleGroupSummonCommand(), ChatHandler::HandleMoveObjectCommand(), ChatHandler::HandleNpcAddCommand(), ChatHandler::HandleNpcMoveCommand(), WorldSession::HandlePlayerLogin(), ChatHandler::HandleSpellCrashTestCommand(), ChatHandler::HandleSummonCommand(), ChatHandler::HandleTempAddSpwCommand(), ChatHandler::HandleTempGameObjectCommand(), ChatHandler::HandleTurnObjectCommand(), ChatHandler::HandleWpModifyCommand(), ChatHandler::HandleWpShowCommand(), WorldObject::HasInArc(), GameObjectModel::initialize(), MapManager::IsValidMapCoord(), IsWithinBox(), Movement::MoveSplineInit::Launch(), Player::LoadFromDB(), Pet::LoadPetFromDB(), WorldObject::MovePosition(), WorldObject::MovePositionToFirstCollision(), operator<<(), Spell::prepare(), SmartScript::ProcessAction(), GameObjectModel::Relocate(), RelocateOffset(), Map::RemoveAllPlayers(), Player::RepopAtGraveyard(), Player::ResurectUsingRequestData(), Player::SaveRecallPosition(), Corpse::SaveToDB(), Creature::SaveToDB(), Player::SaveToDB(), WorldSession::SendSpiritResurrect(), Player::SetBattlegroundEntryPoint(), Unit::SetInCombatState(), Unit::SetPosition(), Player::SetPosition(), Spell::SetTargetMap(), Movement::MoveSplineInit::Stop(), Spell::SummonClassPet(), Map::SummonCreature(), Player::SummonIfPossible(), Player::TeleportTo(), Transport::TeleportTransport(), Aura::TriggerSpell(), RotateMovementGenerator::Update(), FlightPathMovementGenerator::Update(), WaypointMovementGenerator< T >::Update(), CinematicMgr::UpdateCinematicLocation(), GameObject::UpdateRotationFields(), GameObject::Use(), and MovementInfo::Write().

100 { return m_orientation; }
float m_orientation
Definition: Position.h:55
void Position::GetPosition ( float &  x,
float &  y,
float &  z 
) const
inline

Definition at line 107 of file Position.h.

References m_positionX, m_positionY, and m_positionZ.

108  {
109  x = m_positionX; y = m_positionY; z = m_positionZ;
110  }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
void Position::GetPosition ( float &  x,
float &  y,
float &  z,
float &  o 
) const
inline

Definition at line 112 of file Position.h.

References m_orientation, m_positionX, m_positionY, and m_positionZ.

113  {
115  }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
float m_orientation
Definition: Position.h:55
void Position::GetPositionOffsetTo ( Position const &  endPos,
Position retOffset 
) const

Definition at line 45 of file Position.cpp.

References GetOrientation(), GetPositionX(), GetPositionY(), GetPositionZ(), m_positionX, m_positionY, m_positionZ, and SetOrientation().

Referenced by GetExactDist().

46 {
47  float dx = endPos.GetPositionX() - GetPositionX();
48  float dy = endPos.GetPositionY() - GetPositionY();
49 
50  retOffset.m_positionX = dx * std::cos(GetOrientation()) + dy * std::sin(GetOrientation());
51  retOffset.m_positionY = dy * std::cos(GetOrientation()) - dx * std::sin(GetOrientation());
52  retOffset.m_positionZ = endPos.GetPositionZ() - GetPositionZ();
53  retOffset.SetOrientation(endPos.GetOrientation() - GetOrientation());
54 }
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
float m_positionX
Definition: Position.h:50
float GetOrientation() const
Definition: Position.h:100
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float m_positionZ
Definition: Position.h:52
float GetPositionX() const
Definition: Position.h:97
Position Position::GetPositionWithOffset ( Position const &  offset) const

Definition at line 56 of file Position.cpp.

References GetAngle(), GetPositionX(), GetPositionY(), and RelocateOffset().

Referenced by GetExactDist().

57 {
58  Position ret(*this);
59  ret.RelocateOffset(offset);
60  return ret;
61 }
float Position::GetPositionX ( ) const
inline

Definition at line 97 of file Position.h.

References m_positionX.

Referenced by Map::_FindGameObject(), WorldObject::_IsWithinDist(), Player::_SaveBGData(), Player::ActivateTaxiPathTo(), Map::ActiveObjectsNearGrid(), ObjectAccessor::AddCorpse(), Spell::AddGOTarget(), Map::AddPlayerToMap(), Map::AddToActive(), TotemAI::AttackStart(), WorldSession::BuildPartyMemberStatsChangedPacket(), WorldObject::BuildUpdate(), Spell::CalculateHitResults(), Creature::CallAssistance(), Creature::CallForHelp(), CreatureEventAI::CanCast(), GameObject::CastSpell(), Player::CheckAreaExploreAndOutdoor(), Spell::CheckCast(), Map::CheckGridIntegrity(), Spell::CheckItems(), Player::ContinueTaxiFlight(), ObjectAccessor::ConvertCorpseForPlayer(), Corpse::Create(), Pet::CreateBaseAtCreature(), Player::CreateCorpse(), DynamicObject::CreateDynamicObject(), CreatureEventAI::DoFindFriendlyCC(), CreatureEventAI::DoFindFriendlyMissingBuff(), Creature::DoFleeToGetAssistance(), CreatureEventAI::DoSelectLowestHpFriendly(), ScriptedAI::DoSpawnCreature(), Spell::EffectBind(), Spell::EffectDuel(), Spell::EffectDummy(), Spell::EffectMomentMove(), Spell::EffectResurrect(), Spell::EffectResurrectNew(), Spell::EffectStuck(), ScriptedAI::EnterEvadeIfOutOfCombatArea(), ChatHandler::ExecuteCommandInTable(), SmartScript::FindCreatureNear(), SmartScript::FindGameObjectNear(), GetAngle(), BattlegroundAB::GetClosestGraveYard(), BattlegroundEY::GetClosestGraveYard(), Battleground::GetClosestGraveYard(), WorldObject::GetCreatureListWithEntryInGrid(), WorldObject::GetDistanceOrder(), WorldObject::GetDistanceSqr(), SocialMgr::GetFriendInfo(), WorldObject::GetGameObjectListWithEntryInGrid(), WorldObject::GetHitSpherePointFor(), WorldObject::GetNearPoint2D(), ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(), ScriptedAI::GetPlayerAtMinimumRange(), GetPositionOffsetTo(), GetPositionWithOffset(), Creature::GetRespawnPosition(), GetSinCos(), ChatHandler::HandleAddTeleCommand(), Aura::HandleAuraDummy(), WorldSession::HandleBattlegroundArenaJoin(), WorldSession::HandleBattlegroundJoinOpcode(), WorldSession::HandleBattlegroundPlayerPositionsOpcode(), ChatHandler::HandleComeToMeCommand(), WorldSession::HandleCorpseQueryOpcode(), OutdoorPvPSI::HandleDropFlag(), Player::HandleFallDamage(), ChatHandler::HandleGameObjectCommand(), ChatHandler::HandleGPSCommand(), ChatHandler::HandleListCreatureCommand(), ChatHandler::HandleListObjectCommand(), ChatHandler::HandleMoveObjectCommand(), WorldSession::HandleMoveWorldportAckOpcode(), ChatHandler::HandleNearGraveCommand(), ChatHandler::HandleNearObjectCommand(), ChatHandler::HandleNpcAddCommand(), ChatHandler::HandleNpcInfoCommand(), ChatHandler::HandleNpcMoveCommand(), WorldSession::HandlePlayerLogin(), WorldSession::HandleRequestPartyMemberStatsOpcode(), ChatHandler::HandleRespawnCommand(), ChatHandler::HandleSendOpcodeCommand(), ChatHandler::HandleSetPoiCommand(), ChatHandler::HandleSpellCrashTestCommand(), ChatHandler::HandleSummonCommand(), ChatHandler::HandleTargetObjectCommand(), ChatHandler::HandleTempAddSpwCommand(), ChatHandler::HandleTempGameObjectCommand(), ChatHandler::HandleTurnObjectCommand(), ChatHandler::HandleWpAddCommand(), ChatHandler::HandleWpModifyCommand(), WorldObject::HasInArc(), HasInLine(), GameObjectModel::initialize(), WorldObject::IsInRange(), WorldObject::IsInRange2d(), WorldObject::IsInRange3d(), Unit::IsInWater(), Player::IsUnderWater(), Unit::IsUnderWater(), MapManager::IsValidMapCoord(), IsWithinBox(), Unit::IsWithinCombatRange(), Unit::IsWithinMeleeRange(), Movement::MoveSplineInit::Launch(), Corpse::LoadCorpseFromDB(), Player::LoadFromDB(), Pet::LoadPetFromDB(), GameObject::LookupFishingHoleAround(), WorldObject::MonsterSay(), WorldObject::MonsterTextEmote(), WorldObject::MonsterYell(), MotionMaster::MoveFall(), operator<<(), Map::PlayerRelocation(), SmartScript::ProcessAction(), GameObjectModel::Relocate(), RelocateOffset(), ObjectAccessor::RemoveCorpse(), Map::RemoveFromActive(), Player::RepopAtGraveyard(), Player::SaveRecallPosition(), Corpse::SaveToDB(), Creature::SaveToDB(), Player::SaveToDB(), Map::ScriptsProcess(), Creature::SelectNearestTarget(), Creature::SelectNearestTargetInAttackDistance(), WorldSession::SendLearnNewTaxiNode(), WorldSession::SendSpiritResurrect(), WorldSession::SendTaxiMenu(), WorldSession::SendTaxiStatus(), Player::SetBattlegroundEntryPoint(), Unit::SetFacingTo(), Unit::SetFacingToObject(), Player::SetHomebindToLocation(), Unit::SetInCombatState(), Unit::SetPosition(), Player::SetPosition(), Movement::MoveSplineInit::Stop(), Map::SummonCreature(), Player::SummonPet(), Map::SwitchGridContainers(), Player::TeleportTo(), CreatureAI::TriggerAlert(), GameObject::TriggeringLinkedGameObject(), Pet::Update(), Spell::update(), PathInfo::updateFilter(), Creature::UpdateMovementFlags(), GameObject::Use(), Oregon::DelayedUnitRelocation::Visit(), Cell::Visit(), Oregon::SpellNotifierCreatureAndPlayer::Visit(), Map::VisitNearbyCellsOf(), and MovementInfo::Write().

97 { return m_positionX; }
float m_positionX
Definition: Position.h:50
float Position::GetPositionY ( ) const
inline

Definition at line 98 of file Position.h.

References m_positionY.

Referenced by Map::_FindGameObject(), WorldObject::_IsWithinDist(), Player::_SaveBGData(), Player::ActivateTaxiPathTo(), Map::ActiveObjectsNearGrid(), ObjectAccessor::AddCorpse(), Spell::AddGOTarget(), Map::AddPlayerToMap(), Map::AddToActive(), TotemAI::AttackStart(), WorldSession::BuildPartyMemberStatsChangedPacket(), WorldObject::BuildUpdate(), Spell::CalculateHitResults(), Creature::CallAssistance(), Creature::CallForHelp(), CreatureEventAI::CanCast(), GameObject::CastSpell(), Player::CheckAreaExploreAndOutdoor(), Spell::CheckCast(), Map::CheckGridIntegrity(), Spell::CheckItems(), Player::ContinueTaxiFlight(), ObjectAccessor::ConvertCorpseForPlayer(), Corpse::Create(), Pet::CreateBaseAtCreature(), Player::CreateCorpse(), DynamicObject::CreateDynamicObject(), CreatureEventAI::DoFindFriendlyCC(), CreatureEventAI::DoFindFriendlyMissingBuff(), Creature::DoFleeToGetAssistance(), CreatureEventAI::DoSelectLowestHpFriendly(), ScriptedAI::DoSpawnCreature(), Spell::EffectBind(), Spell::EffectDuel(), Spell::EffectDummy(), Spell::EffectMomentMove(), Spell::EffectResurrect(), Spell::EffectResurrectNew(), Spell::EffectStuck(), ScriptedAI::EnterEvadeIfOutOfCombatArea(), ChatHandler::ExecuteCommandInTable(), SmartScript::FindCreatureNear(), SmartScript::FindGameObjectNear(), GetAngle(), BattlegroundAB::GetClosestGraveYard(), BattlegroundEY::GetClosestGraveYard(), Battleground::GetClosestGraveYard(), WorldObject::GetCreatureListWithEntryInGrid(), WorldObject::GetDistanceOrder(), WorldObject::GetDistanceSqr(), SocialMgr::GetFriendInfo(), WorldObject::GetGameObjectListWithEntryInGrid(), WorldObject::GetHitSpherePointFor(), WorldObject::GetNearPoint2D(), ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(), ScriptedAI::GetPlayerAtMinimumRange(), GetPositionOffsetTo(), GetPositionWithOffset(), Creature::GetRespawnPosition(), GetSinCos(), ChatHandler::HandleAddTeleCommand(), Aura::HandleAuraDummy(), WorldSession::HandleBattlegroundArenaJoin(), WorldSession::HandleBattlegroundJoinOpcode(), WorldSession::HandleBattlegroundPlayerPositionsOpcode(), ChatHandler::HandleComeToMeCommand(), WorldSession::HandleCorpseQueryOpcode(), OutdoorPvPSI::HandleDropFlag(), Player::HandleFallDamage(), ChatHandler::HandleGameObjectCommand(), ChatHandler::HandleGPSCommand(), ChatHandler::HandleListCreatureCommand(), ChatHandler::HandleListObjectCommand(), ChatHandler::HandleMoveObjectCommand(), WorldSession::HandleMoveWorldportAckOpcode(), ChatHandler::HandleNearGraveCommand(), ChatHandler::HandleNearObjectCommand(), ChatHandler::HandleNpcAddCommand(), ChatHandler::HandleNpcInfoCommand(), ChatHandler::HandleNpcMoveCommand(), WorldSession::HandlePlayerLogin(), WorldSession::HandleRequestPartyMemberStatsOpcode(), ChatHandler::HandleRespawnCommand(), ChatHandler::HandleSendOpcodeCommand(), ChatHandler::HandleSetPoiCommand(), ChatHandler::HandleSpellCrashTestCommand(), ChatHandler::HandleSummonCommand(), ChatHandler::HandleTargetObjectCommand(), ChatHandler::HandleTempAddSpwCommand(), ChatHandler::HandleTempGameObjectCommand(), ChatHandler::HandleTurnObjectCommand(), ChatHandler::HandleWpAddCommand(), ChatHandler::HandleWpModifyCommand(), WorldObject::HasInArc(), HasInLine(), GameObjectModel::initialize(), WorldObject::IsInRange(), WorldObject::IsInRange2d(), WorldObject::IsInRange3d(), Unit::IsInWater(), Player::IsUnderWater(), Unit::IsUnderWater(), MapManager::IsValidMapCoord(), IsWithinBox(), Unit::IsWithinCombatRange(), Unit::IsWithinMeleeRange(), Movement::MoveSplineInit::Launch(), Corpse::LoadCorpseFromDB(), Player::LoadFromDB(), Pet::LoadPetFromDB(), GameObject::LookupFishingHoleAround(), WorldObject::MonsterSay(), WorldObject::MonsterTextEmote(), WorldObject::MonsterYell(), MotionMaster::MoveFall(), operator<<(), Map::PlayerRelocation(), SmartScript::ProcessAction(), GameObjectModel::Relocate(), RelocateOffset(), ObjectAccessor::RemoveCorpse(), Map::RemoveFromActive(), Player::RepopAtGraveyard(), Player::SaveRecallPosition(), Corpse::SaveToDB(), Creature::SaveToDB(), Player::SaveToDB(), Map::ScriptsProcess(), Creature::SelectNearestTarget(), Creature::SelectNearestTargetInAttackDistance(), WorldSession::SendLearnNewTaxiNode(), WorldSession::SendSpiritResurrect(), WorldSession::SendTaxiMenu(), WorldSession::SendTaxiStatus(), Player::SetBattlegroundEntryPoint(), Unit::SetFacingTo(), Unit::SetFacingToObject(), Player::SetHomebindToLocation(), Unit::SetInCombatState(), Unit::SetPosition(), Player::SetPosition(), Movement::MoveSplineInit::Stop(), Map::SummonCreature(), Player::SummonPet(), Map::SwitchGridContainers(), Player::TeleportTo(), CreatureAI::TriggerAlert(), GameObject::TriggeringLinkedGameObject(), Pet::Update(), Spell::update(), PathInfo::updateFilter(), Creature::UpdateMovementFlags(), GameObject::Use(), Oregon::DelayedUnitRelocation::Visit(), Cell::Visit(), Oregon::SpellNotifierCreatureAndPlayer::Visit(), Map::VisitNearbyCellsOf(), and MovementInfo::Write().

98 { return m_positionY; }
float m_positionY
Definition: Position.h:51
float Position::GetPositionZ ( ) const
inline

Definition at line 99 of file Position.h.

References m_positionZ.

Referenced by WorldObject::_IsWithinDist(), Player::_SaveBGData(), Player::ActivateTaxiPathTo(), Spell::AddGOTarget(), Spell::CalculateHitResults(), CreatureEventAI::CanCast(), GameObject::CastSpell(), Player::CheckAreaExploreAndOutdoor(), Spell::CheckCast(), Player::ContinueTaxiFlight(), ObjectAccessor::ConvertCorpseForPlayer(), Pet::CreateBaseAtCreature(), Player::CreateCorpse(), Creature::DoFleeToGetAssistance(), ScriptedAI::DoSpawnCreature(), Spell::EffectBind(), Spell::EffectDuel(), Spell::EffectDummy(), Spell::EffectMomentMove(), Spell::EffectResurrect(), Spell::EffectResurrectNew(), Spell::EffectStuck(), ScriptedAI::EnterEvadeIfOutOfCombatArea(), ChatHandler::ExecuteCommandInTable(), BattlegroundEY::GetClosestGraveYard(), Battleground::GetClosestGraveYard(), WorldObject::GetDistanceOrder(), WorldObject::GetDistanceSqr(), WorldObject::GetDistanceZ(), SocialMgr::GetFriendInfo(), WorldObject::GetHitSpherePointFor(), WorldObject::GetNearPoint(), GetPositionOffsetTo(), Creature::GetRespawnPosition(), ChatHandler::HandleAddTeleCommand(), Aura::HandleAuraDummy(), Aura::HandleAuraFeatherFall(), WorldSession::HandleBattlegroundArenaJoin(), WorldSession::HandleBattlegroundJoinOpcode(), ChatHandler::HandleComeToMeCommand(), WorldSession::HandleCorpseQueryOpcode(), OutdoorPvPSI::HandleDropFlag(), Player::HandleFallDamage(), ChatHandler::HandleGameObjectCommand(), ChatHandler::HandleGPSCommand(), ChatHandler::HandleListCreatureCommand(), ChatHandler::HandleListObjectCommand(), ChatHandler::HandleMoveObjectCommand(), WorldSession::HandleMoveWorldportAckOpcode(), ChatHandler::HandleNearGraveCommand(), ChatHandler::HandleNearObjectCommand(), ChatHandler::HandleNpcAddCommand(), ChatHandler::HandleNpcInfoCommand(), ChatHandler::HandleNpcMoveCommand(), WorldSession::HandlePlayerLogin(), ChatHandler::HandleSendOpcodeCommand(), ChatHandler::HandleSpellCrashTestCommand(), ChatHandler::HandleSummonCommand(), ChatHandler::HandleTargetObjectCommand(), ChatHandler::HandleTempAddSpwCommand(), ChatHandler::HandleTempGameObjectCommand(), ChatHandler::HandleTurnObjectCommand(), ChatHandler::HandleWpAddCommand(), ChatHandler::HandleWpModifyCommand(), GameObjectModel::initialize(), WorldObject::IsInRange(), WorldObject::IsInRange3d(), Unit::IsInWater(), Player::IsUnderWater(), Unit::IsUnderWater(), MapManager::IsValidMapCoord(), IsWithinBox(), Unit::IsWithinCombatRange(), Unit::IsWithinMeleeRange(), Movement::MoveSplineInit::Launch(), Player::LoadFromDB(), MotionMaster::MoveFall(), operator<<(), SmartScript::ProcessAction(), GameObjectModel::Relocate(), RelocateOffset(), Player::RepopAtGraveyard(), Player::SaveRecallPosition(), Corpse::SaveToDB(), Creature::SaveToDB(), Player::SaveToDB(), WorldSession::SendLearnNewTaxiNode(), WorldSession::SendSpiritResurrect(), WorldSession::SendTaxiMenu(), WorldSession::SendTaxiStatus(), Player::SetBattlegroundEntryPoint(), Unit::SetFacingTo(), Unit::SetFacingToObject(), Player::SetFeatherFall(), Player::SetHomebindToLocation(), Unit::SetInCombatState(), Unit::SetPosition(), Player::SetPosition(), Movement::MoveSplineInit::Stop(), Map::SummonCreature(), Player::TeleportTo(), Pet::Update(), Spell::update(), PathInfo::updateFilter(), Creature::UpdateMovementFlags(), GameObject::Use(), Oregon::SpellNotifierCreatureAndPlayer::Visit(), and MovementInfo::Write().

99 { return m_positionZ; }
float m_positionZ
Definition: Position.h:52
float Position::GetRelativeAngle ( Position const *  pos) const
inline

Definition at line 170 of file Position.h.

References GetAngle(), and m_orientation.

Referenced by HasInLine().

171  {
172  return GetAngle(pos) - m_orientation;
173  }
float GetAngle(Position const *pos) const
float m_orientation
Definition: Position.h:55
float Position::GetRelativeAngle ( float  x,
float  y 
) const
inline

Definition at line 175 of file Position.h.

References GetAngle(), GetSinCos(), and m_orientation.

175 { return GetAngle(x, y) - m_orientation; }
float GetAngle(Position const *pos) const
float m_orientation
Definition: Position.h:55
void Position::GetSinCos ( float  x,
float  y,
float &  vsin,
float &  vcos 
) const

Definition at line 82 of file Position.cpp.

References GetPositionX(), GetPositionY(), and rand_norm().

Referenced by Spell::EffectKnockBack(), and GetRelativeAngle().

83 {
84  float dx = GetPositionX() - x;
85  float dy = GetPositionY() - y;
86 
87  if (std::fabs(dx) < 0.001f && std::fabs(dy) < 0.001f)
88  {
89  float angle = (float)rand_norm()*static_cast<float>(2 * M_PI);
90  vcos = std::cos(angle);
91  vsin = std::sin(angle);
92  }
93  else
94  {
95  float dist = std::sqrt((dx*dx) + (dy*dy));
96  vcos = dx / dist;
97  vsin = dy / dist;
98  }
99 }
double rand_norm()
Definition: Util.cpp:48
float GetPositionY() const
Definition: Position.h:98
float GetPositionX() const
Definition: Position.h:97
bool Position::HasInArc ( float  arcangle,
Position const *  pos,
float  border = 2.0f 
) const

Definition at line 129 of file Position.cpp.

References GetAngle(), m_orientation, and NormalizeOrientation().

Referenced by HasInLine(), and IsInDist().

130 {
131  // always have self in arc
132  if (obj == this)
133  return true;
134 
135  // move arc to range 0.. 2*pi
136  arc = NormalizeOrientation(arc);
137 
138  float angle = GetAngle(obj);
139  angle -= m_orientation;
140 
141  // move angle to range -pi ... +pi
142  angle = NormalizeOrientation(angle);
143  if (angle > float(M_PI))
144  angle -= 2.0f * float(M_PI);
145 
146  float lborder = -1 * (arc / border); // in range -pi..0
147  float rborder = (arc / border); // in range 0..pi
148  return ((angle >= lborder) && (angle <= rborder));
149 }
static float NormalizeOrientation(float o)
Definition: Position.h:204
float GetAngle(Position const *pos) const
float m_orientation
Definition: Position.h:55
bool Position::HasInLine ( Position const *  pos,
float  width 
) const

Definition at line 151 of file Position.cpp.

References GetExactDist2d(), GetPositionX(), GetPositionY(), GetRelativeAngle(), and HasInArc().

Referenced by IsInDist(), and Oregon::SpellNotifierCreatureAndPlayer::Visit().

152 {
153  if (!HasInArc(float(M_PI), pos))
154  return false;
155 
156  float angle = GetRelativeAngle(pos);
157  return std::fabs(std::sin(angle)) * GetExactDist2d(pos->GetPositionX(), pos->GetPositionY()) < width;
158 }
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:130
float GetRelativeAngle(Position const *pos) const
Definition: Position.h:170
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:129
bool Position::IsInDist ( float  x,
float  y,
float  z,
float  dist 
) const
inline

Definition at line 188 of file Position.h.

References GetExactDistSq().

Referenced by Creature::CanCreatureAttack().

189  {
190  return GetExactDistSq(x, y, z) < dist * dist;
191  }
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:145
bool Position::IsInDist ( Position const *  pos,
float  dist 
) const
inline

Definition at line 193 of file Position.h.

References GetExactDistSq(), HasInArc(), HasInLine(), IsWithinBox(), and ToString().

194  {
195  return GetExactDistSq(pos) < dist * dist;
196  }
float GetExactDistSq(float x, float y, float z) const
Definition: Position.h:145
bool Position::IsInDist2d ( float  x,
float  y,
float  dist 
) const
inline

Definition at line 178 of file Position.h.

References GetExactDist2dSq().

Referenced by Battleground::_CheckSafePositions(), and Creature::CanCreatureAttack().

179  {
180  return GetExactDist2dSq(x, y) < dist * dist;
181  }
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:125
bool Position::IsInDist2d ( Position const *  pos,
float  dist 
) const
inline

Definition at line 183 of file Position.h.

References GetExactDist2dSq().

184  {
185  return GetExactDist2dSq(pos) < dist * dist;
186  }
float GetExactDist2dSq(float x, float y) const
Definition: Position.h:125
bool Position::IsWithinBox ( const Position center,
float  xradius,
float  yradius,
float  zradius 
) const

Definition at line 101 of file Position.cpp.

References GetOrientation(), GetPositionX(), GetPositionY(), and GetPositionZ().

Referenced by Player::IsInAreaTriggerRadius(), and IsInDist().

102 {
103  // rotate the WorldObject position instead of rotating the whole cube, that way we can make a simplified
104  // is-in-cube check and we have to calculate only one point instead of 4
105 
106  // 2PI = 360*, keep in mind that ingame orientation is counter-clockwise
107  double rotation = 2 * M_PI - center.GetOrientation();
108  double sinVal = std::sin(rotation);
109  double cosVal = std::cos(rotation);
110 
111  float BoxDistX = GetPositionX() - center.GetPositionX();
112  float BoxDistY = GetPositionY() - center.GetPositionY();
113 
114  float rotX = float(center.GetPositionX() + BoxDistX * cosVal - BoxDistY*sinVal);
115  float rotY = float(center.GetPositionY() + BoxDistY * cosVal + BoxDistX*sinVal);
116 
117  // box edges are parallel to coordiante axis, so we can treat every dimension independently :D
118  float dz = GetPositionZ() - center.GetPositionZ();
119  float dx = rotX - center.GetPositionX();
120  float dy = rotY - center.GetPositionY();
121  if ((std::fabs(dx) > xradius) ||
122  (std::fabs(dy) > yradius) ||
123  (std::fabs(dz) > zradius))
124  return false;
125 
126  return true;
127 }
float GetOrientation() const
Definition: Position.h:100
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float GetPositionX() const
Definition: Position.h:97
static float Position::NormalizeOrientation ( float  o)
inlinestatic

Definition at line 204 of file Position.h.

References operator<<(), and operator>>().

Referenced by HasInArc(), and SetOrientation().

205  {
206  // fmod only supports positive numbers. Thus we have
207  // to emulate negative numbers
208  if (o < 0)
209  {
210  float mod = o *-1;
211  mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI));
212  mod = -mod + 2.0f * static_cast<float>(M_PI);
213  return mod;
214  }
215  return std::fmod(o, 2.0f * static_cast<float>(M_PI));
216  }
bool Position::operator!= ( Position const &  a)
inline

Definition at line 60 of file Position.h.

References operator==().

61  {
62  return !(operator==(a));
63  }
bool operator==(Position const &a)
Definition: Position.cpp:24
bool Position::operator== ( Position const &  a)

Definition at line 24 of file Position.cpp.

References m_orientation, m_positionX, m_positionY, and m_positionZ.

Referenced by operator!=(), and CoordPair< MAX_NUMBER_OF_GRIDS >::operator!=().

25 {
26  return (G3D::fuzzyEq(a.m_positionX, m_positionX) &&
27  G3D::fuzzyEq(a.m_positionY, m_positionY) &&
28  G3D::fuzzyEq(a.m_positionZ, m_positionZ) &&
29  G3D::fuzzyEq(a.m_orientation, m_orientation));
30 }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
float m_orientation
Definition: Position.h:55
Position::PositionXYStreamer Position::PositionXYStream ( )
inline

Definition at line 119 of file Position.h.

References Position::PositionXYStreamer::PositionXYStreamer().

119 { return PositionXYStreamer(*this); }
Position::PositionXYZOStreamer Position::PositionXYZOStream ( )
inline

Definition at line 121 of file Position.h.

References IsPositionValid().

121 { return PositionXYZOStreamer(*this); }
Position::PositionXYZStreamer Position::PositionXYZStream ( )
inline

Definition at line 120 of file Position.h.

120 { return PositionXYZStreamer(*this); }
void Position::Relocate ( float  x,
float  y,
float  z 
)
inline

Definition at line 70 of file Position.h.

71  {
72  m_positionX = x; m_positionY = y; m_positionZ = z;
73  }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
void Position::Relocate ( float  x,
float  y,
float  z,
float  orientation 
)
inline

Definition at line 75 of file Position.h.

References SetOrientation().

76  {
77  m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation);
78  }
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
void Position::Relocate ( Position const &  pos)
inline

Definition at line 80 of file Position.h.

References m_orientation, m_positionX, m_positionY, m_positionZ, and SetOrientation().

81  {
82  m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation);
83  }
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
void Position::Relocate ( Position const *  pos)
inline

Definition at line 85 of file Position.h.

References m_orientation, m_positionX, m_positionY, m_positionZ, RelocateOffset(), and SetOrientation().

86  {
87  m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation);
88  }
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
void Position::RelocateOffset ( Position const &  offset)

Definition at line 32 of file Position.cpp.

References GetOrientation(), GetPositionX(), GetPositionY(), GetPositionZ(), m_positionX, m_positionY, m_positionZ, and SetOrientation().

Referenced by GetPositionWithOffset(), and Relocate().

33 {
34  m_positionX = GetPositionX() + (offset.GetPositionX() * std::cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + float(M_PI)));
35  m_positionY = GetPositionY() + (offset.GetPositionY() * std::cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation()));
36  m_positionZ = GetPositionZ() + offset.GetPositionZ();
37  SetOrientation(GetOrientation() + offset.GetOrientation());
38 }
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
float m_positionX
Definition: Position.h:50
float GetOrientation() const
Definition: Position.h:100
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float m_positionZ
Definition: Position.h:52
float GetPositionX() const
Definition: Position.h:97
std::string Position::ToString ( ) const

Definition at line 160 of file Position.cpp.

References m_orientation, m_positionX, m_positionY, and m_positionZ.

Referenced by IsInDist().

161 {
162  std::stringstream sstr;
163  sstr << "X: " << m_positionX << " Y: " << m_positionY << " Z: " << m_positionZ << " O: " << m_orientation;
164  return sstr.str();
165 }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float m_positionZ
Definition: Position.h:52
float m_orientation
Definition: Position.h:55

Member Data Documentation

float Position::m_orientation
private

The documentation for this struct was generated from the following files: