Skip to content

Commit ee1a3a3

Browse files
authored
Merge pull request #325 from lmontaut/epa_fallback
core: add EPA::FallBack condition to shapeDistance computation
2 parents 272a1f4 + 9ae51ed commit ee1a3a3

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

include/hpp/fcl/narrowphase/gjk.h

+3
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ struct HPP_FCL_DLLAPI GJK {
254254
/// @brief Get GJK number of iterations.
255255
inline size_t getIterations() { return iterations; }
256256

257+
/// @brief Get GJK tolerance.
258+
inline FCL_REAL getTolerance() { return tolerance; }
259+
257260
private:
258261
SimplexV store_v[4];
259262
SimplexV* free_v[4];

include/hpp/fcl/narrowphase/narrowphase.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ struct HPP_FCL_DLLAPI GJKSolver {
313313
if (epa_status & details::EPA::Valid ||
314314
epa_status == details::EPA::OutOfFaces // Warnings
315315
|| epa_status == details::EPA::OutOfVertices // Warnings
316-
) {
316+
|| epa_status == details::EPA::FallBack) {
317317
Vec3f w0, w1;
318318
epa.getClosestPoints(shape, w0, w1);
319319
assert(epa.depth >= -eps);

src/narrowphase/gjk.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,13 @@ EPA::Status EPA::evaluate(GJK& gjk, const Vec3f& guess) {
16151615
}
16161616
}
16171617

1618+
// FallBack when the simplex given by GJK is of rank 1.
1619+
// Since the simplex only contains support points which convex
1620+
// combination describe the origin, the point in the simplex is actually
1621+
// the origin.
16181622
status = FallBack;
1623+
// TODO: define a better normal
1624+
assert(simplex.rank == 1 && simplex.vertex[0]->w.isZero(gjk.getTolerance()));
16191625
normal = -guess;
16201626
FCL_REAL nl = normal.norm();
16211627
if (nl > 0)

0 commit comments

Comments
 (0)