Overhaul pathfinding algorithm
This commit is contained in:
@@ -9,15 +9,15 @@ typedef struct PathNode {
|
||||
i32 weight; // fCost = g + h
|
||||
i32 gCost; // from start cost
|
||||
i32 hCost; // to target cost
|
||||
bool visited;
|
||||
TilePosition pos;
|
||||
} PathNode;
|
||||
|
||||
typedef struct PathClosedNode {
|
||||
typedef struct PathNodeRecord {
|
||||
bool visited : 1;
|
||||
bool open : 1;
|
||||
i8 x : 3;
|
||||
i8 y : 3;
|
||||
} PathClosedNode;
|
||||
} PathNodeRecord;
|
||||
|
||||
typedef struct PathfindingDesc {
|
||||
Position start;
|
||||
@@ -25,11 +25,11 @@ typedef struct PathfindingDesc {
|
||||
BzObjectPool *pool;
|
||||
BzTileMap *map;
|
||||
PathNode *openSet; // heap (size: width * height)
|
||||
PathClosedNode *closedSet; // size: width * height
|
||||
PathNodeRecord *closedSet; // size: width * height
|
||||
Path *outPath;
|
||||
} PathfindingDesc;
|
||||
|
||||
bool findPath(const PathfindingDesc *desc);
|
||||
bool pathfindAStar(const PathfindingDesc *desc);
|
||||
|
||||
// TODO: Flowfield
|
||||
void calculateFlowField();
|
||||
|
||||
Reference in New Issue
Block a user