playX / box2d

Automatically exported from code.google.com/p/box2d
0 stars 0 forks source link

Stack corruption if three or more points are collinear in b2PolygonShape. #326

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a polygon fixture using the following vertices:
(0,0)
(10,10)
(5,5)
(3,3)
(any set where 3 or more vertices are collinear)

2. These vertices are collinear and are expected to be incorrect.
3. "b2PolygonShape::Set()" will fail because it uses the gift-wrapping 
algorithm as described here 
(http://en.wikipedia.org/wiki/Gift_wrapping_algorithm) which assumes no three 
points are collinear.  This results in a stack corruption if this is the case.

What is the expected output? What do you see instead?
The polygon to be set as degenerate.

What version of the product are you using? On what operating system?
v2.3.0

Please provide any additional information below.

It would be extremely valuable to be able to explicitly check an arbitrary set 
of points for validity using Box2Ds code i.e. "b2PolygonShape::Validate (const 
b2Vec2* vertices, int32 count)".  This could not only include degenerate checks 
but other checks such as valid area which is done when calculating the centroid 
of said polygon (area > b2_epsilon).

Original issue reported on code.google.com by melv....@gmail.com on 13 Jan 2014 at 9:10

GoogleCodeExporter commented 9 years ago
Completed: At revision: 304  

Fix for issue 326. Added test to check for collinear points in the convex hull 
code.

Original comment by erinca...@gmail.com on 5 Apr 2014 at 6:35