diff --git a/doc/gjk.py b/doc/gjk.py index a7f172af619a2fa05774a5134cf8b874cb18589d..07587a0cbd4a3c7f2ab69e264f072946140ebeb9 100644 --- a/doc/gjk.py +++ b/doc/gjk.py @@ -234,7 +234,7 @@ def printOrder (order, indent = "", start=True,file=sys.stdout): print ("bool GJK::projectTetrahedraOrigin(const Simplex& current, Simplex& next)", file=file) print ("{", file=file) print (indent+"// The code of this function was generated using doc/gjk.py", file=file) - print (indent+"const int a = 3, b = 2, c = 1, d = 0;", file=file) + print (indent+"const vertex_id_t a = 3, b = 2, c = 1, d = 0;", file=file) for l in "abcd": print (indent+"const Vec3f& {} (current.vertex[{}]->w);".format(l.upper(),l), file=file) print (indent+"const FCL_REAL aa = A.squaredNorm();".format(l), file=file) diff --git a/include/hpp/fcl/narrowphase/gjk.h b/include/hpp/fcl/narrowphase/gjk.h index 46ecc26eab558cef5b35fe4ef43e709c8e956338..f6baebc0495cb14f91561eecc0b802a597b71830 100644 --- a/include/hpp/fcl/narrowphase/gjk.h +++ b/include/hpp/fcl/narrowphase/gjk.h @@ -118,12 +118,14 @@ struct GJK Vec3f w; }; + typedef unsigned char vertex_id_t; + struct Simplex { /// @brief simplex vertex SimplexV* vertex[4]; /// @brief size of simplex (number of vertices) - short rank; + vertex_id_t rank; Simplex() {} }; @@ -182,8 +184,8 @@ struct GJK private: SimplexV store_v[4]; SimplexV* free_v[4]; - short nfree; - short current; + vertex_id_t nfree; + vertex_id_t current; Simplex* simplex; Status status; diff --git a/src/narrowphase/gjk.cpp b/src/narrowphase/gjk.cpp index 9db577c471f7237298e08ede37046659b96bf51a..27a266aa31583f56717d093850f9b0057de5be87 100644 --- a/src/narrowphase/gjk.cpp +++ b/src/narrowphase/gjk.cpp @@ -367,7 +367,7 @@ bool GJK::getClosestPoints (const Simplex& simplex, Vec3f& w0, Vec3f& w1) { SimplexV* const* vs = simplex.vertex; - for (short i = 0; i < simplex.rank; ++i) { + for (vertex_id_t i = 0; i < simplex.rank; ++i) { assert (vs[i]->w.isApprox (vs[i]->w0 - vs[i]->w1)); } @@ -413,7 +413,7 @@ bool GJK::getClosestPoints (const Simplex& simplex, Vec3f& w0, Vec3f& w1) } w0.setZero(); w1.setZero(); - for (short i = 0; i < simplex.rank; ++i) { + for (vertex_id_t i = 0; i < simplex.rank; ++i) { w0 += projection.parameterization[i] * vs[i]->w0; w1 += projection.parameterization[i] * vs[i]->w1; } @@ -444,7 +444,7 @@ GJK::Status GJK::evaluate(const MinkowskiDiff& shape_, const Vec3f& guess) do { - short next = (short)(1 - current); + vertex_id_t next = (vertex_id_t)(1 - current); Simplex& curr_simplex = simplices[current]; Simplex& next_simplex = simplices[next]; @@ -586,7 +586,7 @@ bool GJK::encloseOrigin() } inline void originToPoint ( - const GJK::Simplex& current, int a, + const GJK::Simplex& current, GJK::vertex_id_t a, const Vec3f& A, GJK::Simplex& next, Vec3f& ray) @@ -598,7 +598,7 @@ inline void originToPoint ( } inline void originToSegment ( - const GJK::Simplex& current, int a, int b, + const GJK::Simplex& current, GJK::vertex_id_t a, GJK::vertex_id_t b, const Vec3f& A, const Vec3f& B, const Vec3f& AB, const FCL_REAL& ABdotAO, @@ -618,7 +618,7 @@ inline void originToSegment ( inline void originToTriangle ( const GJK::Simplex& current, - int a, int b, int c, + GJK::vertex_id_t a, GJK::vertex_id_t b, GJK::vertex_id_t c, const Vec3f& ABC, const FCL_REAL& ABCdotAO, GJK::Simplex& next, @@ -643,7 +643,7 @@ inline void originToTriangle ( bool GJK::projectLineOrigin(const Simplex& current, Simplex& next) { - const int a = 1, b = 0; + const vertex_id_t a = 1, b = 0; // A is the last point we added. const Vec3f& A = current.vertex[a]->w; const Vec3f& B = current.vertex[b]->w; @@ -663,7 +663,7 @@ bool GJK::projectLineOrigin(const Simplex& current, Simplex& next) bool GJK::projectTriangleOrigin(const Simplex& current, Simplex& next) { - const int a = 2, b = 1, c = 0; + const vertex_id_t a = 2, b = 1, c = 0; // A is the last point we added. const Vec3f& A = current.vertex[a]->w, B = current.vertex[b]->w, @@ -710,7 +710,7 @@ bool GJK::projectTriangleOrigin(const Simplex& current, Simplex& next) bool GJK::projectTetrahedraOrigin(const Simplex& current, Simplex& next) { // The code of this function was generated using doc/gjk.py - const int a = 3, b = 2, c = 1, d = 0; + const vertex_id_t a = 3, b = 2, c = 1, d = 0; const Vec3f& A (current.vertex[a]->w); const Vec3f& B (current.vertex[b]->w); const Vec3f& C (current.vertex[c]->w);