Commit dffd2cc4 authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

[EPA] Fix check for EPA failure.

parent 741f38bc
......@@ -309,7 +309,17 @@ private:
public:
enum Status {Valid, Touching, Degenerated, NonConvex, InvalidHull, OutOfFaces, OutOfVertices, AccuracyReached, FallBack, Failed};
enum Status {
Failed = 0,
Valid = 1,
AccuracyReached = 1 << 1 | Valid ,
Degenerated = 1 << 1 | Failed,
NonConvex = 2 << 1 | Failed,
InvalidHull = 3 << 1 | Failed,
OutOfFaces = 4 << 1 | Failed,
OutOfVertices = 5 << 1 | Failed,
FallBack = 6 << 1 | Failed
};
Status status;
GJK::Simplex result;
......@@ -336,6 +346,9 @@ public:
void initialize();
/// \return a Status which can be demangled using (status & Valid) or
/// (status & Failed). The other values provide a more detailled
/// status
Status evaluate(GJK& gjk, const Vec3f& guess);
/// Get the closest points on each object.
......
......@@ -80,7 +80,7 @@ namespace fcl
} else {
details::EPA epa(epa_max_face_num, epa_max_vertex_num, epa_max_iterations, epa_tolerance);
details::EPA::Status epa_status = epa.evaluate(gjk, -guess);
if(epa_status != details::EPA::Failed)
if(epa_status & details::EPA::Failed)
{
epa.getClosestPoints (shape, w0, w1);
if(penetration_depth) *penetration_depth = -epa.depth;
......@@ -140,7 +140,7 @@ namespace fcl
} else {
details::EPA epa(epa_max_face_num, epa_max_vertex_num, epa_max_iterations, epa_tolerance);
details::EPA::Status epa_status = epa.evaluate(gjk, -guess);
assert (epa_status != details::EPA::Failed); (void) epa_status;
assert (epa_status & details::EPA::Valid); (void) epa_status;
epa.getClosestPoints (shape, w0, w1);
distance = -epa.depth;
......@@ -226,7 +226,7 @@ namespace fcl
details::EPA epa(epa_max_face_num, epa_max_vertex_num,
epa_max_iterations, epa_tolerance);
details::EPA::Status epa_status = epa.evaluate(gjk, -guess);
if(epa_status != details::EPA::Failed)
if(epa_status & details::EPA::Valid)
{
Vec3f w0, w1;
epa.getClosestPoints (shape, w0, w1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment