[7826] Avoid use GetDistance* that used slow sqrt call where possible, other related speedups.

This commit is contained in:
VladimirMangos 2009-05-14 18:16:03 +04:00
parent ff80f14d2d
commit 788cdf9b3a
21 changed files with 158 additions and 93 deletions

View file

@ -1778,12 +1778,12 @@ bool Creature::IsOutOfThreatArea(Unit* pVictim) const
if(sMapStore.LookupEntry(GetMapId())->IsDungeon())
return false;
float length = pVictim->GetDistance(CombatStartX,CombatStartY,CombatStartZ);
float AttackDist = GetAttackDistance(pVictim);
uint32 ThreatRadius = sWorld.getConfig(CONFIG_THREAT_RADIUS);
//Use AttackDistance in distance check if threat radius is lower. This prevents creature bounce in and out of combat every update tick.
return ( length > (ThreatRadius > AttackDist ? ThreatRadius : AttackDist));
return !pVictim->IsWithinDist(CombatStartX,CombatStartY,CombatStartZ,
ThreatRadius > AttackDist ? ThreatRadius : AttackDist);
}
CreatureDataAddon const* Creature::GetCreatureAddon() const