fix #35; check edge validity;

This commit is contained in:
Irlan
2018-04-26 00:46:36 -03:00
parent 534448ea60
commit f882c8c68e
4 changed files with 21 additions and 7 deletions

View File

@@ -172,8 +172,8 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
// Create a convex hull.
// Allocate memory buffer for the worst case.
const u32 qhBufferSize = qhGetBufferSize(B3_MAX_HULL_VERTICES);
u8 qhBuffer[qhBufferSize];
u32 qhBufferSize = qhGetBufferSize(B3_MAX_HULL_VERTICES);
void* qhBuffer = b3Alloc(qhBufferSize);
// Build
qhHull hull;
@@ -191,6 +191,7 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
if (fs_count == B3_MAX_HULL_FACES)
{
// Face excess
b3Free(qhBuffer);
return;
}
@@ -206,6 +207,7 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
if (iv == B3_MAX_HULL_VERTICES)
{
// Vertex excess
b3Free(qhBuffer);
return;
}
@@ -214,6 +216,7 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
if (iedge == B3_MAX_HULL_EDGES)
{
// Half-edge excess
b3Free(qhBuffer);
return;
}
@@ -222,6 +225,7 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
if (itwin == B3_MAX_HULL_EDGES)
{
// Half-edge excess
b3Free(qhBuffer);
return;
}
@@ -271,6 +275,8 @@ void b3QHull::Set(const b3Vec3* points, u32 count)
++iface;
}
b3Free(qhBuffer);
B3_ASSERT(vs.count <= B3_MAX_HULL_VERTICES);
vertexCount = vs.count;

View File

@@ -768,6 +768,8 @@ void qhHull::Validate(const qhFace* face) const
const qhHalfEdge* edge = begin;
do
{
B3_ASSERT(edge->state != qhHalfEdge::e_deleted);
B3_ASSERT(edge->face == face);
qhHalfEdge* twin = edge->twin;