comment, bugfix, and simplification

This commit is contained in:
Irlan 2018-04-17 03:11:35 -03:00
parent 9b01af3d70
commit 75fe47b453
2 changed files with 5 additions and 19 deletions

View File

@ -26,12 +26,9 @@ struct b3QHull : public b3Hull
b3QHull(); b3QHull();
~b3QHull(); ~b3QHull();
// Create a convex hull from a point list. // Create a convex hull from an array of points.
// If the point list defines a degenerate polyhedron // If the points define a degenerate polyhedron the hull is not overwritten.
// the old hull is not cleared.
//
// Coincident points are removed. // Coincident points are removed.
// Coplanar faces are merged.
void Set(const b3Vec3* points, u32 count); void Set(const b3Vec3* points, u32 count);
// Set this hull as a cylinder located at the origin. // Set this hull as a cylinder located at the origin.

View File

@ -151,7 +151,7 @@ static b3Vec3 b3ComputeCentroid(b3QHull* hull)
void b3QHull::Set(const b3Vec3* points, u32 count) void b3QHull::Set(const b3Vec3* points, u32 count)
{ {
// Copy points into local buffer, remove coincident points. // Copy points into local buffer, remove coincident points.
b3StackArray<b3Vec3, 256> ps; b3StackArray<b3Vec3, B3_MAX_HULL_FEATURES> ps;
for (u32 i = 0; i < count; ++i) for (u32 i = 0; i < count; ++i)
{ {
b3Vec3 p = points[i]; b3Vec3 p = points[i];
@ -209,19 +209,7 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
face = face->next; 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); b3Free(qh_memory);
return; return;
@ -230,6 +218,7 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
b3Free(vertices); b3Free(vertices);
b3Free(edges); b3Free(edges);
b3Free(faces); b3Free(faces);
b3Free(planes);
vertexCount = 0; vertexCount = 0;
vertices = (b3Vec3*)b3Alloc(V * sizeof(b3Vec3)); vertices = (b3Vec3*)b3Alloc(V * sizeof(b3Vec3));