pass parameters as const &

sceneinput
dteviot 10 years ago
parent 7644a46ded
commit 21e249cb92

@ -87,14 +87,14 @@ namespace
namespace MWMechanics namespace MWMechanics
{ {
float sqrDistanceIgnoreZ(ESM::Pathgrid::Point point, float x, float y) float sqrDistanceIgnoreZ(const ESM::Pathgrid::Point& point, float x, float y)
{ {
x -= point.mX; x -= point.mX;
y -= point.mY; y -= point.mY;
return (x * x + y * y); return (x * x + y * y);
} }
float distance(ESM::Pathgrid::Point point, float x, float y, float z) float distance(const ESM::Pathgrid::Point& point, float x, float y, float z)
{ {
x -= point.mX; x -= point.mX;
y -= point.mY; y -= point.mY;
@ -102,7 +102,7 @@ namespace MWMechanics
return sqrt(x * x + y * y + z * z); return sqrt(x * x + y * y + z * z);
} }
float distance(ESM::Pathgrid::Point a, ESM::Pathgrid::Point b) float distance(const ESM::Pathgrid::Point& a, const ESM::Pathgrid::Point& b)
{ {
float x = static_cast<float>(a.mX - b.mX); float x = static_cast<float>(a.mX - b.mX);
float y = static_cast<float>(a.mY - b.mY); float y = static_cast<float>(a.mY - b.mY);
@ -272,7 +272,7 @@ namespace MWMechanics
if(mPath.empty()) if(mPath.empty())
return true; return true;
ESM::Pathgrid::Point nextPoint = *mPath.begin(); const ESM::Pathgrid::Point& nextPoint = *mPath.begin();
if (sqrDistanceIgnoreZ(nextPoint, x, y) < tolerance*tolerance) if (sqrDistanceIgnoreZ(nextPoint, x, y) < tolerance*tolerance)
{ {
mPath.pop_front(); mPath.pop_front();

@ -12,8 +12,8 @@ namespace MWWorld
namespace MWMechanics namespace MWMechanics
{ {
float distance(ESM::Pathgrid::Point point, float x, float y, float); float distance(const ESM::Pathgrid::Point& point, float x, float y, float);
float distance(ESM::Pathgrid::Point a, ESM::Pathgrid::Point b); float distance(const ESM::Pathgrid::Point& a, const ESM::Pathgrid::Point& b);
class PathFinder class PathFinder
{ {
public: public:

Loading…
Cancel
Save