Patch for btQuantizedBvh when compiling with gcc

Post Reply
zkunda
Posts: 6
Joined: Mon Apr 19, 2010 12:59 pm

Patch for btQuantizedBvh when compiling with gcc

Post by zkunda »

Our project is using "bullet" in linux server for collision detection.
bug:
Create btBvhTriangleMeshShape with useQuantizedAabbCompression = true, we found incrrect collision detection result frequently. If useQuantizedAabbCompression = false, everything is just perfect. But it costs much more memory!
fix:
btQuantizedBvh.h

Code: Select all

int getTriangleIndex() const
{
       btAssert(isLeafNode());  // Get only the lower bits where the triangle index is stored
       return (m_escapeIndexOrTriangleIndex&~((~0)<<(31-MAX_NUM_PARTS_IN_BITS)));
} 
(~0)<<(31-MAX_NUM_PARTS_IN_BITS) should change to 0xffffffff<<(31-MAX_NUM_PARTS_IN_BITS)


(~0) is recognized as negative value in gcc probaly.
Shift operators for negative value is implementation-defined and gcc compiler implements defferent shift operation against visual studio c++(vs9) compiler
mi076
Posts: 144
Joined: Fri Aug 01, 2008 6:36 am
Location: Bonn, Germany

Re: Patch for btQuantizedBvh when compiling with gcc

Post by mi076 »

Have you opened an issue? I looked at C++ standard (open-std.org) and so far "<<" is undefined if on left side is negative value.
There is also one in btSoftBodyConcaveCollisionAlgorithm.h (line 48).
Thank you.
Post Reply