From 92dabdc07d484e668df1b2138408bfbcfe0e0393 Mon Sep 17 00:00:00 2001 From: emMichael Alexander Ewert/em Date: Fri, 12 Dec 2014 15:39:16 -0800 Subject: [PATCH] Fix a couple of bugs in 2dConvex Hull algorithm. * Need to use atan2 so 3d angles are calculated properly after projection. * Need to handle case where the first tripple of points is non-convex, previously this would cause the algorithm to fail with only 1 point. --- src/LinearMath/btGrahamScan2dConvexHull.h | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/LinearMath/btGrahamScan2dConvexHull.h b/src/LinearMath/btGrahamScan2dConvexHull.h index e658c5cf0..13a79aa58 100644 --- a/src/LinearMath/btGrahamScan2dConvexHull.h +++ b/src/LinearMath/btGrahamScan2dConvexHull.h @@ -85,9 +85,17 @@ inline void GrahamScanConvexHull2D(btAlignedObjectArray& original originalPoints[0].m_angle = -1e30f; for (int i=1;i& original else hull.push_back(originalPoints[i]); } + + if( hull.size() == 1 ) + { + hull.push_back( originalPoints[i] ); + } } }