Problem with ConvexHull shape

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Problem with ConvexHull shape

Postby Bird » Tue Nov 22, 2011 1:39 am

Howdy,

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;
}
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am

Re: Problem with ConvexHull shape

Postby Julio Jerez » Tue Nov 22, 2011 9:27 am

is the video showing the mesh or the collsion shape?

a convex hull with a tolerance of 0.1 can be very different than the original mesh, 0.1 means the worse distance from the optimized hull to the perfect hull fomed by the point cloud will not excced 0.1 unit,
but that could be significant, try displaying the wireframe of the collsion shape.

The collision should be perferect all the time in all cases not expections.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Problem with ConvexHull shape

Postby Bird » Tue Nov 22, 2011 10:44 am

and conve hull with a torelace of 0.1 will be very diffrent that the collision mesh,
try displaying the wire frame of the collsion shape.


Setting a lower tolerance solved the penetration problem... I guess I should have read the NewtonCreateConvexHull comments a bit more closely. :)

Thanks very much for the help!

-Bird
Bird
 
Posts: 636
Joined: Tue Nov 22, 2011 1:27 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 404 guests