Autogeometry and toConvexHull

Discuss any Chipmunk bugs here.

Autogeometry and toConvexHull

Postby ChAdams » Fri May 11, 2012 7:46 pm

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)
ChAdams
 
Posts: 23
Joined: Thu Apr 26, 2012 2:34 pm

Re: Autogeometry and toConvexHull

Postby slembcke » Sat May 12, 2012 12:20 pm

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/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Autogeometry and toConvexHull

Postby ChAdams » Sat May 12, 2012 2:26 pm

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.
ChAdams
 
Posts: 23
Joined: Thu Apr 26, 2012 2:34 pm


Return to Bugs

Who is online

Users browsing this forum: No registered users and 1 guest