Fix bug with follow path system
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user