I can't seem to get ConvexHull shapes to collide with other shapes without penetration. Here's a brief video showing how it's not working. http://www.hurleyworks.com/media/flash/NewtonConvexHull/NewtonConvexHull.html.
And here's the code I'm using to create the ConvexHull, mostly taken from one of the Newton demo scenes. Can anyone tell me what I'm doing wrong? I'm using Newton 3 from the svn trunk, but I'm also seeing penetrations using the Newton 2.33 release.
-Bird
- Code: Select all
// createConvexHullShape
NewtonCollision * Newton3Engine::createConvexHullShape (const SpaceTime * const mesh,
const BodyDesc * const properties)
{ TRACE("Newton3Engine::createConvexHullShape")
dVector minBox(mesh->modelBound.min.data());
dVector maxBox(mesh->modelBound.max.data());
//calculate the box size and dimensions of the physics collision shape
dVector size (maxBox - minBox);
dVector origin ((maxBox + minBox).Scale (0.5f));
size.m_w = 1.0f;
origin.m_w = 1.0f;
// make a offset Matrix for this collision shape.
dMatrix offset (GetIdentityMatrix());
offset.m_posit = origin;
TriMesh * m = (TriMesh*)mesh;
VBuffer * vBuffer = m->getVertexBuffer();
int pointCount = vBuffer->getNumElements();
MeshOps ms;
dFloat * vertices = ms.extractVertices(m);
// now create a convex hull shape from the vertex geometry
NewtonCollision * shape = NewtonCreateConvexHull(world_, pointCount, vertices, 3 * sizeof (dFloat), 0.1f, mesh->id(), &offset[0][0]);
if( !shape )
debug( "Newton convex hull creation failed" );
// Newton owns the vertices
delete [] vertices;
return shape;
}

