Cleanup smoothPath function

This commit is contained in:
2023-11-25 11:30:28 +01:00
parent 6240eeea1c
commit 6fe4449adf

View File

@@ -52,11 +52,12 @@ static void smoothPath(BzTileMap *map, PathData *pathData, BzObjectPool *pool) {
#define NEXT_WAYPOINT(path, idx, len) \
do { \
if (idx >= len) { \
idx++; \
if (idx >= len) { \
path = path->next; \
idx = 0; \
if (path) len = path->numWaypoints; \
} \
} \
} while (0)
PathData *currPath = pathData;
@@ -68,12 +69,9 @@ do { \
size_t nextPathLen = nextPath->numWaypoints;
// Second element
currIdx++;
NEXT_WAYPOINT(currPath, currIdx, currPathLen);
// Third element
nextIdx++;
NEXT_WAYPOINT(nextPath, nextIdx, nextPathLen);
nextIdx++;
NEXT_WAYPOINT(nextPath, nextIdx, nextPathLen);
outPath->numWaypoints = 1;
@@ -82,9 +80,6 @@ do { \
Position nextPos = nextPath->waypoints[nextIdx];
lastPos = nextPos;
currIdx++;
nextIdx++;
NEXT_WAYPOINT(currPath, currIdx, currPathLen);
NEXT_WAYPOINT(nextPath, nextIdx, nextPathLen);