From df802194e956f0fd399c1a20352678d597fb278d Mon Sep 17 00:00:00 2001 From: Olivier Lanneluc Date: Fri, 3 May 2013 15:51:05 +0200 Subject: digital/io-hub/src/common-cc/path.cc: clean up the endpoints index enum 1. move enum about endpoints index 2. add nb of endpoints constant in the enum 3. use the enum constant instead of hard-coded index 4. change next_node type to match astar structure --- digital/io-hub/src/common-cc/path.cc | 8 +------- digital/io-hub/src/common-cc/path.hh | 11 ++++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'digital/io-hub') diff --git a/digital/io-hub/src/common-cc/path.cc b/digital/io-hub/src/common-cc/path.cc index 151eedd0..411ce9de 100644 --- a/digital/io-hub/src/common-cc/path.cc +++ b/digital/io-hub/src/common-cc/path.cc @@ -56,12 +56,6 @@ extern "C" { #define PATH_IN_CIRCLE(pOINT, cENTER, rADIUS) \ (distance_point_point((pOINT), (cENTER)) <= (rADIUS)) -/** Static nodes index for the endpoints */ -enum { - PATH_NAVPOINT_SRC_IDX = 0, - PATH_NAVPOINT_DST_IDX -}; - static int32_t pos_dot_product(vect_t* pa, vect_t* pb, vect_t* pc, vect_t* pd) { vect_t vab = *pb; vect_sub(&vab, pa); @@ -287,7 +281,7 @@ void Path::compute(weight_t escape) if (path_found) { /* Store next node to go to */ - next_node = astar_nodes[0].prev; + next_node = astar_nodes[PATH_NAVPOINT_SRC_IDX].prev; #ifdef PATH_DEBUG /* Log and display the path found */ diff --git a/digital/io-hub/src/common-cc/path.hh b/digital/io-hub/src/common-cc/path.hh index 1232cda1..28b5a8d8 100644 --- a/digital/io-hub/src/common-cc/path.hh +++ b/digital/io-hub/src/common-cc/path.hh @@ -31,6 +31,13 @@ extern "C" { #include "modules/path/astar/astar.h" } +/** Static nodes index for the endpoints */ +enum { + PATH_NAVPOINT_SRC_IDX = 0, + PATH_NAVPOINT_DST_IDX, + PATH_RESERVED_NAVPOINTS_NB +}; + /** Obstacle */ typedef struct path_obstacle_t { @@ -87,8 +94,6 @@ class Path /** Number of points for the cake */ static const int PATH_CAKE_NAVPOINTS_NB = 14; #endif - /** Number of reserved points for the 2 endpoints */ - static const int PATH_RESERVED_NAVPOINTS_NB = 2; /** Number of navigation points layers for the cake. */ static const int PATH_CAKE_NAVPOINTS_LAYERS = 1; /** Number of navigation points layers for each obstacle. */ @@ -121,7 +126,7 @@ class Path /** List of nodes used for A*. */ struct astar_node_t astar_nodes[PATH_NAVPOINTS_NB]; /** Which node to look at for next step. */ - int next_node; + uint8_t next_node; /** TRUE when a path has been found */ bool path_found; }; -- cgit v1.2.3