From 16b6fc9b5d59ac795e139b2a597da97953690d82 Mon Sep 17 00:00:00 2001 From: wiseoldman95 Date: Fri, 1 May 2015 18:53:24 +0300 Subject: PathFinding - Chunk querying optimization and improve cPath::IsSolid --- src/Mobs/Path.h | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'src/Mobs/Path.h') diff --git a/src/Mobs/Path.h b/src/Mobs/Path.h index 05fd59155..9927d0a34 100644 --- a/src/Mobs/Path.h +++ b/src/Mobs/Path.h @@ -18,12 +18,8 @@ Put this in your .cpp: #include -/* MCServer forward declarations */ -#ifndef COMPILING_PATHFIND_DEBUGGER - -// fwd: cChunkMap.h -typedef cItemCallback cChunkCallback; -#endif +//fwd: ../Chunk.h +class cChunk; /* Various little structs and classes */ enum class ePathFinderStatus {CALCULATING, PATH_FOUND, PATH_NOT_FOUND}; @@ -35,9 +31,6 @@ public: }; class cPath -#ifndef COMPILING_PATHFIND_DEBUGGER -: public cChunkCallback -#endif { public: /** Creates a pathfinder instance. A Mob will probably need a single pathfinder instance for its entire life. @@ -59,7 +52,7 @@ public: @param a_EndingPoint "The block where the Zombie's knees want to be". @param a_MaxSteps The maximum steps before giving up. */ cPath( - cWorld * a_World, + cChunk * a_Chunk, const Vector3d & a_StartingPoint, const Vector3d & a_EndingPoint, int a_MaxSteps, double a_BoundingBoxWidth = 1, double a_BoundingBoxHeight = 2, int a_MaxUp = 1, int a_MaxDown = 1 @@ -69,7 +62,7 @@ public: ~cPath(); /** Performs part of the path calculation and returns true if the path computation has finished. */ - ePathFinderStatus Step(); + ePathFinderStatus Step(cChunk * a_Chunk); /* Point retrieval functions, inlined for performance. */ /** Returns the next point in the path. */ @@ -147,15 +140,9 @@ private: std::vector m_PathPoints; void AddPoint(Vector3d a_Vector); - /* Interfacing with MCServer's world */ - cWorld * m_World; - #ifndef COMPILING_PATHFIND_DEBUGGER - Vector3d m_Item_CurrentBlock; // Read by Item();, it's the only way to "pass it" parameters -protected: - virtual bool Item(cChunk * a_Chunk) override; - - /* Interfacing with Irrlicht, has nothing to do with MCServer*/ - #else + /* Interfacing with the world */ + cChunk * m_Chunk; // Only valid inside Step()! + #ifdef COMPILING_PATHFIND_DEBUGGER #include "../path_irrlicht.cpp" #endif }; -- cgit v1.2.3