I ran into this problem recently and thought I'd mention it here. According to the documentation, the vertex winding for a cpPolyShape should be clockwise. However, calculating the area for the same set of vertices using cpAreaForPoly() returns a negative number. You'd think if the vertices were listed in the correct order, the calculated area would be positive.
As a side question, why is the winding CW? Most other physics/collision engines are CCW since the cross-product of adjacent vertex vectors is non-negative. Just wondering...
Jeff
cpAreaForPoly() and cpPolyShape windings don't agree
-
- Posts: 1
- Joined: Fri Apr 01, 2011 10:01 am
- Contact:
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: cpAreaForPoly() and cpPolyShape windings don't agree
Why yes, yes it is. I've actually only used it once and was squaring the result... Whoops.
The winding is clockwise because that's how I implemented it like 5 years ago. (It hasn't changed much in that time either) I've actually thought about changing it, but that would be a huge pain to users. All of the collision detection code was built from the ground up by me, and I didn't really have any previous experience when I started it.
The winding is clockwise because that's how I implemented it like 5 years ago. (It hasn't changed much in that time either) I've actually thought about changing it, but that would be a huge pain to users. All of the collision detection code was built from the ground up by me, and I didn't really have any previous experience when I started it.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 8 guests