Added explicit xyz_heading overrides for the 4 distance functions

This commit is contained in:
Arthur Ice 2015-01-17 16:08:45 -08:00
parent 77badffa29
commit a135a3d597
4 changed files with 36 additions and 3 deletions

View File

@ -721,10 +721,10 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_
continue;
if (spells[spell_id].targettype == ST_Ring) {
dist_targ = ComparativeDistance(curmob->GetPosition(), caster->GetTargetRingLocation());
dist_targ = ComparativeDistance(static_cast<xyz_location>(curmob->GetPosition()), caster->GetTargetRingLocation());
}
else if (center) {
dist_targ = ComparativeDistance(static_cast<xyz_location>(curmob->GetPosition()), static_cast<xyz_location>(center->GetPosition()));
dist_targ = ComparativeDistance(curmob->GetPosition(), center->GetPosition());
}
if (dist_targ > dist2) //make sure they are in range

View File

@ -1558,7 +1558,7 @@ Client *EntityList::GetRandomClient(const xyz_location& location, float Distance
for (auto it = client_list.begin();it != client_list.end(); ++it)
if ((it->second != ExcludeClient) && (ComparativeDistance(it->second->GetPosition(), location) <= Distance))
if ((it->second != ExcludeClient) && (ComparativeDistance(static_cast<xyz_location>(it->second->GetPosition()), location) <= Distance))
ClientsInRange.push_back(it->second);
if (ClientsInRange.empty())

View File

@ -145,6 +145,13 @@ float ComparativeDistance(const xyz_location& point1, const xyz_location& point2
return diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z;
}
/**
* Produces the non square root'ed distance between the two points.
*/
float ComparativeDistance(const xyz_heading& point1, const xyz_heading& point2) {
ComparativeDistance(static_cast<xyz_location>(point1), static_cast<xyz_location>(point2));
}
/**
* Produces the distance between the two points.
*/
@ -152,6 +159,13 @@ float Distance(const xyz_location& point1, const xyz_location& point2) {
return sqrt(ComparativeDistance(point1, point2));
}
/**
* Produces the distance between the two points.
*/
float Distance(const xyz_heading& point1, const xyz_heading& point2) {
Distance(static_cast<xyz_location>(point1), static_cast<xyz_location>(point2));
}
/**
* Produces the distance between the two points within the XY plane.
*/
@ -159,6 +173,13 @@ float DistanceNoZ(const xyz_location& point1, const xyz_location& point2) {
return Distance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
}
/**
* Produces the distance between the two points within the XY plane.
*/
float DistanceNoZ(const xyz_heading& point1, const xyz_heading& point2) {
return Distance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
}
/**
* Produces the non square root'ed distance between the two points within the XY plane.
*/
@ -166,6 +187,13 @@ float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& poi
return ComparativeDistance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
}
/**
* Produces the non square root'ed distance between the two points within the XY plane.
*/
float ComparativeDistanceNoZ(const xyz_heading& point1, const xyz_heading& point2) {
return ComparativeDistance(static_cast<xy_location>(point1),static_cast<xy_location>(point2));
}
/**
* Determines if 'position' is within (inclusive) the axis aligned
* box (3 dimensional) formed from the points minimum and maximum.

View File

@ -94,4 +94,9 @@ float Distance(const xyz_location& point1, const xyz_location& point2);
float DistanceNoZ(const xyz_location& point1, const xyz_location& point2);
float ComparativeDistanceNoZ(const xyz_location& point1, const xyz_location& point2);
float ComparativeDistance(const xyz_heading& point1, const xyz_heading& point2);
float Distance(const xyz_heading& point1, const xyz_heading& point2);
float DistanceNoZ(const xyz_heading& point1, const xyz_heading& point2);
float ComparativeDistanceNoZ(const xyz_heading& point1, const xyz_heading& point2);
#endif