Remove multiple colliders, add spatial index component

This commit is contained in:
2023-11-17 15:13:30 +01:00
parent 208cdc6b6f
commit 021df6d77a
11 changed files with 122 additions and 95 deletions

View File

@@ -54,7 +54,7 @@ bool findPath(const PathfindingDesc *desc) {
if (y < 0 || y >= map->height ||
x < 0 || x >= map->width)
continue;
if (bzTileMapGetCollider(map, x, y).shapes[0].type != BZ_TILE_SHAPE_NONE)
if (bzTileMapGetCollider(map, x, y).type != BZ_TILE_SHAPE_NONE)
continue;
Visited *curVisited = &visited[y * map->width + x];
if (curVisited->visited)
@@ -91,6 +91,7 @@ bool findPath(const PathfindingDesc *desc) {
pathData->next = NULL;
i32 numWaypoints = 0;
// Write path
// TODO: Write end pos
while (pos.x != desc->start.x || pos.y != desc->start.y) {
Position waypoint = {
pos.x * map->tileWidth + map->tileWidth * 0.5f,
@@ -113,6 +114,10 @@ bool findPath(const PathfindingDesc *desc) {
pos.y -= visit.y;
pathLen++;
}
if (pathLen == 0) {
bzObjectPoolRelease(desc->pool, pathData);
pathData = NULL;
}
out->paths = pathData;
// Reverse paths