summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Path.h
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-05-24 18:27:05 +0200
committertycho <work.tycho@gmail.com>2015-05-24 18:27:05 +0200
commita6ccee594822bc2da5fcf1df9159d54b4040c155 (patch)
tree232b6454e74d8730853a7e29ac3d535dddc4ddaa /src/Mobs/Path.h
parentFix other clang 3.6 commit (diff)
parentMerge pull request #2114 from cengizIO/master (diff)
downloadcuberite-a6ccee594822bc2da5fcf1df9159d54b4040c155.tar
cuberite-a6ccee594822bc2da5fcf1df9159d54b4040c155.tar.gz
cuberite-a6ccee594822bc2da5fcf1df9159d54b4040c155.tar.bz2
cuberite-a6ccee594822bc2da5fcf1df9159d54b4040c155.tar.lz
cuberite-a6ccee594822bc2da5fcf1df9159d54b4040c155.tar.xz
cuberite-a6ccee594822bc2da5fcf1df9159d54b4040c155.tar.zst
cuberite-a6ccee594822bc2da5fcf1df9159d54b4040c155.zip
Diffstat (limited to 'src/Mobs/Path.h')
-rw-r--r--src/Mobs/Path.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h
index db74eaba2..c250eece2 100644
--- a/src/Mobs/Path.h
+++ b/src/Mobs/Path.h
@@ -68,8 +68,8 @@ public:
@param a_MaxSteps The maximum steps before giving up. */
cPath(
cChunk & a_Chunk,
- const Vector3i & a_StartingPoint, const Vector3i & a_EndingPoint, int a_MaxSteps,
- double a_BoundingBoxWidth = 1, double a_BoundingBoxHeight = 2,
+ const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps,
+ double a_BoundingBoxWidth, double a_BoundingBoxHeight,
int a_MaxUp = 1, int a_MaxDown = 1
);
@@ -89,10 +89,11 @@ public:
/* Point retrieval functions, inlined for performance. */
/** Returns the next point in the path. */
- inline Vector3i GetNextPoint()
+ inline Vector3d GetNextPoint()
{
ASSERT(m_Status == ePathFinderStatus::PATH_FOUND);
- return m_PathPoints[m_PathPoints.size() - 1 - (++m_CurrentPoint)];
+ Vector3i Point = m_PathPoints[m_PathPoints.size() - 1 - (++m_CurrentPoint)];
+ return Vector3d(Point.x + m_HalfWidth, Point.y, Point.z + m_HalfWidth);
}
/** Checks whether this is the last point or not. Never call getnextPoint when this is true. */
inline bool IsLastPoint()
@@ -106,11 +107,12 @@ public:
return (m_CurrentPoint == 0);
}
/** Get the point at a_index. Remark: Internally, the indexes are reversed. */
- inline Vector3i GetPoint(size_t a_index)
+ inline Vector3d GetPoint(size_t a_index)
{
ASSERT(m_Status == ePathFinderStatus::PATH_FOUND);
ASSERT(a_index < m_PathPoints.size());
- return m_PathPoints[m_PathPoints.size() - 1 - a_index];
+ Vector3i Point = m_PathPoints[m_PathPoints.size() - 1 - a_index];
+ return Vector3d(Point.x + m_HalfWidth, Point.y, Point.z + m_HalfWidth);
}
/** Returns the total number of points this path has. */
inline size_t GetPointCount()
@@ -161,6 +163,9 @@ private:
std::unordered_map<Vector3i, cPathCell, VectorHasher> m_Map;
Vector3i m_Destination;
Vector3i m_Source;
+ int m_BoundingBoxWidth;
+ int m_BoundingBoxHeight;
+ double m_HalfWidth;
int m_StepsLeft;
cPathCell * m_NearestPointToTarget;
cFastRandom m_Rand;