summaryrefslogtreecommitdiffstats
path: root/src/Mobs/Path.cpp
diff options
context:
space:
mode:
authorSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-21 16:37:19 +0100
committerSafwat Halaby <SafwatHalaby@users.noreply.github.com>2015-12-21 16:37:19 +0100
commite6d74553a2a2f01037051651f8421e02579416aa (patch)
tree7e2691d58bb11479bd280155b4f5f62466082818 /src/Mobs/Path.cpp
parentMerge pull request #2783 from cuberite/seadragon91-patch-spawnpoint-fix (diff)
parentRevert "Changed cPath to have a reset method". (diff)
downloadcuberite-e6d74553a2a2f01037051651f8421e02579416aa.tar
cuberite-e6d74553a2a2f01037051651f8421e02579416aa.tar.gz
cuberite-e6d74553a2a2f01037051651f8421e02579416aa.tar.bz2
cuberite-e6d74553a2a2f01037051651f8421e02579416aa.tar.lz
cuberite-e6d74553a2a2f01037051651f8421e02579416aa.tar.xz
cuberite-e6d74553a2a2f01037051651f8421e02579416aa.tar.zst
cuberite-e6d74553a2a2f01037051651f8421e02579416aa.zip
Diffstat (limited to '')
-rw-r--r--src/Mobs/Path.cpp90
1 files changed, 28 insertions, 62 deletions
diff --git a/src/Mobs/Path.cpp b/src/Mobs/Path.cpp
index f3a0d6cf2..c0cffbeb4 100644
--- a/src/Mobs/Path.cpp
+++ b/src/Mobs/Path.cpp
@@ -39,7 +39,34 @@ cPath::cPath(
m_Chunk(&a_Chunk),
m_BadChunkFound(false)
{
- ResetImpl(a_StartingPoint, a_EndingPoint, a_BoundingBoxWidth, a_BoundingBoxHeight);
+ // TODO: if src not walkable OR dest not walkable, then abort.
+ // Borrow a new "isWalkable" from ProcessIfWalkable, make ProcessIfWalkable also call isWalkable
+
+ a_BoundingBoxWidth = 1; // Until we improve physics, if ever.
+
+ m_BoundingBoxWidth = CeilC(a_BoundingBoxWidth);
+ m_BoundingBoxHeight = CeilC(a_BoundingBoxHeight);
+ m_HalfWidth = a_BoundingBoxWidth / 2;
+
+ int HalfWidthInt = FloorC(a_BoundingBoxWidth / 2);
+ m_Source.x = FloorC(a_StartingPoint.x - HalfWidthInt);
+ m_Source.y = FloorC(a_StartingPoint.y);
+ m_Source.z = FloorC(a_StartingPoint.z - HalfWidthInt);
+
+ m_Destination.x = FloorC(a_EndingPoint.x - HalfWidthInt);
+ m_Destination.y = FloorC(a_EndingPoint.y);
+ m_Destination.z = FloorC(a_EndingPoint.z - HalfWidthInt);
+
+ if (GetCell(m_Source)->m_IsSolid || GetCell(m_Destination)->m_IsSolid)
+ {
+ m_Status = ePathFinderStatus::PATH_NOT_FOUND;
+ return;
+ }
+
+ m_NearestPointToTarget = GetCell(m_Source);
+ m_Status = ePathFinderStatus::CALCULATING;
+
+ ProcessCell(GetCell(m_Source), nullptr, 0);
}
cPath::cPath() : m_IsValid(false)
@@ -470,64 +497,3 @@ cPathCell * cPath::GetCell(const Vector3i & a_Location)
return &m_Map[a_Location];
}
}
-
-
-
-
-
-void cPath::ResetImpl(
- const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint,
- double a_BoundingBoxWidth, double a_BoundingBoxHeight
-)
-{
- // TODO: if src not walkable OR dest not walkable, then abort.
- // Borrow a new "isWalkable" from ProcessIfWalkable, make ProcessIfWalkable also call isWalkable
-
- a_BoundingBoxWidth = 1; // Until we improve physics, if ever.
-
- m_BoundingBoxWidth = CeilC(a_BoundingBoxWidth);
- m_BoundingBoxHeight = CeilC(a_BoundingBoxHeight);
- m_HalfWidth = a_BoundingBoxWidth / 2;
-
- int HalfWidthInt = FloorC(a_BoundingBoxWidth / 2);
- m_Source.x = FloorC(a_StartingPoint.x - HalfWidthInt);
- m_Source.y = FloorC(a_StartingPoint.y);
- m_Source.z = FloorC(a_StartingPoint.z - HalfWidthInt);
-
- m_Destination.x = FloorC(a_EndingPoint.x - HalfWidthInt);
- m_Destination.y = FloorC(a_EndingPoint.y);
- m_Destination.z = FloorC(a_EndingPoint.z - HalfWidthInt);
-
- if (GetCell(m_Source)->m_IsSolid || GetCell(m_Destination)->m_IsSolid)
- {
- m_Status = ePathFinderStatus::PATH_NOT_FOUND;
- return;
- }
-
- m_NearestPointToTarget = GetCell(m_Source);
- m_Status = ePathFinderStatus::CALCULATING;
-
- ProcessCell(GetCell(m_Source), nullptr, 0);
-}
-
-
-
-
-
-void cPath::Reset(
- cChunk & a_Chunk,
- const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps,
- double a_BoundingBoxWidth, double a_BoundingBoxHeight,
- int a_MaxUp, int a_MaxDown
-)
-{
- m_Map.clear();
- m_OpenList = decltype(m_OpenList){};
- m_StepsLeft = a_MaxSteps;
- m_IsValid = true;
- m_CurrentPoint = 0; // GetNextPoint increments this to 1, but that's fine, since the first cell is always a_StartingPoint
- m_Chunk = &a_Chunk;
- m_BadChunkFound = false;
- ResetImpl(a_StartingPoint, a_EndingPoint, a_BoundingBoxWidth, a_BoundingBoxHeight);
-}
-