Skip to content

Commit

Permalink
core: concatenating enable_cached_guess and gjk_initial_guess
Browse files Browse the repository at this point in the history
  • Loading branch information
lmontaut committed Jun 2, 2022
1 parent bafec21 commit 492f0ff
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 70 deletions.
24 changes: 6 additions & 18 deletions include/hpp/fcl/narrowphase/narrowphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@ struct HPP_FCL_DLLAPI GJKSolver {
initialize_gjk(gjk, shape, s1, s2, guess, support_hint);

details::GJK::Status gjk_status = gjk.evaluate(shape, guess, support_hint);
if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
// TODO: use gjk_initial_guess instead
if (enable_cached_guess) {
if (gjk_initial_guess == GJKInitialGuess::CachedGuess ||
enable_cached_guess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
Expand Down Expand Up @@ -177,12 +173,8 @@ struct HPP_FCL_DLLAPI GJKSolver {
initialize_gjk(gjk, shape, s, tri, guess, support_hint);

details::GJK::Status gjk_status = gjk.evaluate(shape, guess, support_hint);
if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
// TODO: use gjk_initial_guess instead
if (enable_cached_guess) {
if (gjk_initial_guess == GJKInitialGuess::CachedGuess ||
enable_cached_guess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
Expand Down Expand Up @@ -254,12 +246,8 @@ struct HPP_FCL_DLLAPI GJKSolver {
initialize_gjk(gjk, shape, s1, s2, guess, support_hint);

details::GJK::Status gjk_status = gjk.evaluate(shape, guess, support_hint);
if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
// TODO: use gjk_initial_guess instead
if (enable_cached_guess) {
if (gjk_initial_guess == GJKInitialGuess::CachedGuess ||
enable_cached_guess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
Expand Down
29 changes: 6 additions & 23 deletions src/collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ std::size_t collide(const CollisionGeometry* o1, const Transform3f& tf1,
request.gjk_convergence_criterion_type;
solver.gjk_tolerance = request.gjk_tolerance;
solver.gjk_max_iterations = request.gjk_max_iterations;
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess) {
solver.cached_guess = request.cached_gjk_guess;
solver.support_func_cached_guess = request.cached_support_func_guess;
}
// TODO: use gjk_initial_guess instead
if (solver.enable_cached_guess) {
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess ||
solver.enable_cached_guess) {
solver.cached_guess = request.cached_gjk_guess;
solver.support_func_cached_guess = request.cached_support_func_guess;
}
Expand Down Expand Up @@ -136,12 +132,8 @@ std::size_t collide(const CollisionGeometry* o1, const Transform3f& tf1,
o1, tf1, o2, tf2, &solver, request, result);
}
}
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
}
// TODO: use gjk_initial_guess instead
if (solver.enable_cached_guess) {
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess ||
solver.enable_cached_guess) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
}
Expand Down Expand Up @@ -204,12 +196,8 @@ std::size_t ComputeCollision::operator()(const Transform3f& tf1,
{
GJKInitialGuess gjk_initial_guess = request.gjk_initial_guess;
solver.gjk_initial_guess = gjk_initial_guess;
if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
solver.cached_guess = request.cached_gjk_guess;
solver.support_func_cached_guess = request.cached_support_func_guess;
}
// TODO: use gjk_initial_guess instead
bool cached = request.enable_cached_gjk_guess;
bool cached = (gjk_initial_guess == GJKInitialGuess::CachedGuess ||
request.enable_cached_gjk_guess);
solver.enable_cached_guess = cached;
if (cached) {
solver.cached_guess = request.cached_gjk_guess;
Expand All @@ -232,11 +220,6 @@ std::size_t ComputeCollision::operator()(const Transform3f& tf1,
} else
res = run(tf1, tf2, request, result);

if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
}
// TODO: use gjk_initial_guess instead
if (cached) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
Expand Down
29 changes: 6 additions & 23 deletions src/distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ FCL_REAL distance(const CollisionGeometry* o1, const Transform3f& tf1,
request.gjk_convergence_criterion_type;
solver.gjk_tolerance = request.gjk_tolerance;
solver.gjk_max_iterations = request.gjk_max_iterations;
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess) {
solver.cached_guess = request.cached_gjk_guess;
solver.support_func_cached_guess = request.cached_support_func_guess;
}
// TODO: use gjk_initial_guess instead
if (solver.enable_cached_guess) {
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess ||
solver.enable_cached_guess) {
solver.cached_guess = request.cached_gjk_guess;
solver.support_func_cached_guess = request.cached_support_func_guess;
}
Expand Down Expand Up @@ -124,12 +120,8 @@ FCL_REAL distance(const CollisionGeometry* o1, const Transform3f& tf1,
o1, tf1, o2, tf2, &solver, request, result);
}
}
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
}
// TODO: use gjk_initial_guess instead
if (solver.enable_cached_guess) {
if (solver.gjk_initial_guess == GJKInitialGuess::CachedGuess ||
solver.enable_cached_guess) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
}
Expand Down Expand Up @@ -189,12 +181,8 @@ FCL_REAL ComputeDistance::operator()(const Transform3f& tf1,
DistanceResult& result) const {
GJKInitialGuess gjk_initial_guess = request.gjk_initial_guess;
solver.gjk_initial_guess = gjk_initial_guess;
if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
solver.cached_guess = request.cached_gjk_guess;
solver.support_func_cached_guess = request.cached_support_func_guess;
}
// TODO: use gjk_initial_guess instead
bool cached = request.enable_cached_gjk_guess;
bool cached = (gjk_initial_guess == GJKInitialGuess::CachedGuess ||
request.enable_cached_gjk_guess);
solver.enable_cached_guess = cached;
if (cached) {
solver.cached_guess = request.cached_gjk_guess;
Expand All @@ -216,11 +204,6 @@ FCL_REAL ComputeDistance::operator()(const Transform3f& tf1,
} else
res = run(tf1, tf2, request, result);

if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
}
// TODO: use gjk_initial_guess instead
if (cached) {
result.cached_gjk_guess = solver.cached_guess;
result.cached_support_func_guess = solver.support_func_cached_guess;
Expand Down
8 changes: 2 additions & 6 deletions src/narrowphase/narrowphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,8 @@ bool GJKSolver::shapeDistance<TriangleP, TriangleP>(
initialize_gjk(gjk, shape, t1, t2, guess, support_hint);

details::GJK::Status gjk_status = gjk.evaluate(shape, guess, support_hint);
if (gjk_initial_guess == GJKInitialGuess::CachedGuess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
// TODO: use gjk_initial_guess instead
if (enable_cached_guess) {
if (gjk_initial_guess == GJKInitialGuess::CachedGuess ||
enable_cached_guess) {
cached_guess = gjk.getGuessFromSimplex();
support_func_cached_guess = gjk.support_hint;
}
Expand Down

0 comments on commit 492f0ff

Please sign in to comment.