Skip to content

Commit 20258d6

Browse files
committed
SupportSetFunc: fix convex-hull algo when size == 2
1 parent c2b18ab commit 20258d6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/narrowphase/support_functions.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -801,16 +801,14 @@ void getShapeSupportSetLinear(const ConvexBase* convex, SupportSet& support_set,
801801
const Vec3f& support_dir = support_set.getNormal();
802802
getShapeSupport<SupportOptions::NoSweptSphere>(convex, support_dir, support,
803803
hint, support_data);
804-
const FCL_REAL support_value = support.dot(support_dir);
804+
const FCL_REAL support_value = support_dir.dot(support);
805805

806806
const std::vector<Vec3f>& points = *(convex->points);
807-
assert(points.size() == (size_t)(convex->num_points));
808-
hint = 0;
809807
support_data.support_set.points().clear();
810808
support_data.support_set.direction = support_set.direction;
811809
support_data.support_set.tf = support_set.tf;
812-
for (const auto& point : points) {
813-
FCL_REAL dot = point.dot(support_dir);
810+
for (const Vec3f& point : points) {
811+
const FCL_REAL dot = support_dir.dot(point);
814812
if (support_value - dot <= tol) {
815813
if (_SupportOptions == SupportOptions::WithSweptSphere) {
816814
support_data.support_set.addPoint(
@@ -930,6 +928,11 @@ HPP_FCL_DLLAPI void computeSupportSetConvexHull(
930928
cvx_hull.clear();
931929

932930
if (cloud.size() <= 2) {
931+
if (cloud.size() == 2) {
932+
if (cloud[0](0) < cloud[1](0)) {
933+
std::swap(cloud[0], cloud[1]);
934+
}
935+
}
933936
// Point or segment, nothing to do.
934937
for (const Vec2f& point : cloud) {
935938
cvx_hull.emplace_back(point);

0 commit comments

Comments
 (0)