Autogeometry and toConvexHull

Discuss any Chipmunk bugs here.
Post Reply
ChAdams
Posts: 23
Joined: Thu Apr 26, 2012 2:34 pm
Contact:

Autogeometry and toConvexHull

Post by ChAdams »

ChipmunkPolyline > toConvexHull sometimes produces polygons which trigger polyshape validation failure.

in cpPolyShape.c:

Code: Select all

if(cpvcross(cpvsub(b, a), cpvsub(c, b)) > 0.0f)
I would suggest changing it to something like

Code: Select all

if(cpvcross(cpvsub(b, a), cpvsub(c, b)) > 0.000001f)
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Autogeometry and toConvexHull

Post by slembcke »

I had that come up a couple times too. It's fixed in the current Git versions because I just made it so that the convex hull algorithm is always run when creating poly shapes. I'm getting pretty close to releasing 6.1, so it should be pretty stable.

The issue in 6.0.3 is that slightly different measures are used in the convex hull algorithm and the validate function so there are floating point precision issues. The Git code also has a function that allows you to create convex hulls with a distance tolerance. Points on the hull that contribute to the shape by less than the tolerance are dropped, creating simpler polygons.

In case you had forgotten, there is information on the downloads page for accessing the Chipmunk Pro git repository:
http://chipmunk-physics.net/downloads.php
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
ChAdams
Posts: 23
Joined: Thu Apr 26, 2012 2:34 pm
Contact:

Re: Autogeometry and toConvexHull

Post by ChAdams »

Thanks, I'll check out the github version - although last time I tried to checkout chipmunk pro from git it wasn't able to pull, probably need to be using a different github client.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests