diff --git a/include/bounce/collision/shapes/qhull.h b/include/bounce/collision/shapes/qhull.h index b4ae149..d71b7cf 100644 --- a/include/bounce/collision/shapes/qhull.h +++ b/include/bounce/collision/shapes/qhull.h @@ -26,12 +26,9 @@ struct b3QHull : public b3Hull b3QHull(); ~b3QHull(); - // Create a convex hull from a point list. - // If the point list defines a degenerate polyhedron - // the old hull is not cleared. - // + // Create a convex hull from an array of points. + // If the points define a degenerate polyhedron the hull is not overwritten. // Coincident points are removed. - // Coplanar faces are merged. void Set(const b3Vec3* points, u32 count); // Set this hull as a cylinder located at the origin. diff --git a/src/bounce/collision/shapes/qhull.cpp b/src/bounce/collision/shapes/qhull.cpp index 8889233..1ad4083 100644 --- a/src/bounce/collision/shapes/qhull.cpp +++ b/src/bounce/collision/shapes/qhull.cpp @@ -151,7 +151,7 @@ static b3Vec3 b3ComputeCentroid(b3QHull* hull) void b3QHull::Set(const b3Vec3* points, u32 count) { // Copy points into local buffer, remove coincident points. - b3StackArray ps; + b3StackArray ps; for (u32 i = 0; i < count; ++i) { b3Vec3 p = points[i]; @@ -209,27 +209,16 @@ void b3QHull::Set(const b3Vec3* points, u32 count) face = face->next; } - if (V > B3_MAX_HULL_FEATURES) + if (V > B3_MAX_HULL_FEATURES || E > B3_MAX_HULL_FEATURES || F > B3_MAX_HULL_FEATURES) { b3Free(qh_memory); return; } - - if (E > B3_MAX_HULL_FEATURES) - { - b3Free(qh_memory); - return; - } - - if (F > B3_MAX_HULL_FEATURES) - { - b3Free(qh_memory); - return; - } b3Free(vertices); b3Free(edges); b3Free(faces); + b3Free(planes); vertexCount = 0; vertices = (b3Vec3*)b3Alloc(V * sizeof(b3Vec3));