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