Fix bug with follow path system

This commit is contained in:
2023-12-07 11:35:35 +01:00
parent ddb562a62e
commit e7e4d1e4ce
4 changed files with 22 additions and 9 deletions

View File

@@ -132,6 +132,17 @@ bool pathfindAStar(const PathfindingDesc *desc) {
BZ_ASSERT(start.x >= 0 && start.x < map->width);
BZ_ASSERT(start.y >= 0 && start.y < map->height);
// Perform very cheap ray cast check
if (bzTileMapCanRayCastLine(map, desc->start, desc->target)) {
PathData *pathData = bzObjectPool(desc->pool);
BZ_ASSERT(pathData);
pathData->waypoints[0] = desc->target;
pathData->numWaypoints = 1;
pathData->next = NULL;
*desc->outPath = (Path) {pathData, 0};
return true;
}
i32 numTiles = map->width * map->height;
PathNodeRecord *closedSet = bzStackAlloc(desc->alloc, sizeof(*closedSet) * numTiles);