favreau / bullet

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

initializePolyhedralFeatures() looses small faces (with edge length < 0.03 units) #555

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
consider a btConvexHullShape whose convex hull contains lets say 4 coplanar 
points. think of a square with side length smaller than sqrt(0.001) units.

in initializePolyhedralFeatures() btConvexHullComputer::compute() will output 2 
coplanar triangle faces for these 4 points.

further below in initializePolyhedralFeatures() these 2 triangles are 
recognized to be coplanar and it is tried to merge them.

before calling GrahamScanConvexHull2D() a btAlignedObjectArray<GrahamVector2> 
orgpoints is filled with the vertices of these 2 triangles.

but not all vertices are fed into orgpoints because 
btConvexHullComputer::compute() re-uses vertices and there is no use in 
duplicated vertcies in the input for GrahamScanConvexHull2D().

to remove these duplicates there is a for() loop to check wether a new vertex 
is close to an already collected vertex. this check is done by this expression:
(rotatedPt-orgpoints[i]).length2()<0.001

for the above mentioned 4 vertices only 1 vertex will appear in orgpoints.

GrahamScanConvexHull2D() can not compute a face from only one vertex.

i would expect orgpoints' size to be at least something like 2 + 
number_of_triangle_faces.

because of the missing face the collision detection of bodies with these hull's 
don't work correct.

this was tested with bullet 2.79. see also the forum entry 
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=7511&p=25762#p25762

Original issue reported on code.google.com by fastest...@googlemail.com on 12 Oct 2011 at 2:03

GoogleCodeExporter commented 9 years ago
As you suggested on the forums, using the orgIndex is a better way to remove 
duplicate vertices

if (orgpoints[i].m_orgIndex == orgIndex)

fixed in latest trunk,
Thanks!
Erwin

Original comment by erwin.coumans on 12 Oct 2011 at 9:50