Collision detection in double precision mode

mspong
Posts: 6
Joined: Tue May 05, 2009 11:25 pm

Collision detection in double precision mode

Post by mspong »

I've been using bullet successfully in single-precision mode, but I rebuilt it in double-precision and my collision detection is no longer working.

The objects in question are a btSphereShape and a btCompoundShape made up of btConvexHullShape objects loaded from .obj files. Drawing debug info shows the collision shapes are in the correct locations, but the sphere falls right through the meshes.

Is there anything I need to change besides recompiling the library and defining BT_USE_DOUBLE_PRECISION to make this work correctly?
ola
Posts: 169
Joined: Sun Jan 14, 2007 7:56 pm
Location: Norway

Re: Collision detection in double precision mode

Post by ola »

Currently double-precision Bullet assumes that your mesh is in double precision format too (rarely the case in real life). So maybe you got into the same issue as me, see this post:
http://www.bulletphysics.com/Bullet/php ... f=9&t=3412

I created a patch earlier which is posted here, maybe it could help you out (it's not been applied to the SVN trunk version of Bullet yet). You can find it at the issue tracker:
http://code.google.com/p/bullet/issues/detail?id=213

Hope that helps,
Ola
mspong
Posts: 6
Joined: Tue May 05, 2009 11:25 pm

Re: Collision detection in double precision mode

Post by mspong »

The meshes are in the correct format - I manually convert them one point at a time from the Irrlicht Mesh structure into btVector3s and adding the points to the btConvexHull. So the data (originally floats) is typecast to btScalars, defined as double, one point at a time.

The debug drawing lines show all the collision shapes in the correct locations (everything looks identical to debug drawing under floating point), so the data is there. It just seems to be failing to detect the collision for some reason.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision detection in double precision mode

Post by Erwin Coumans »

Where do you define BT_USE_DOUBLE_PRECISION ?

The least error-prone method is to simply hardcode it at the top of Bullet/LinearMath/btScalar.h and make sure to clean/recompile all files/libraries.
I created a patch earlier which is posted here, maybe it could help you out (it's not been applied to the SVN trunk version of Bullet yet). You can find it at the issue tracker:
Ok, it is now applied. Thanks for that patch!
Erwin
mspong
Posts: 6
Joined: Tue May 05, 2009 11:25 pm

Re: Collision detection in double precision mode

Post by mspong »

Erwin Coumans wrote:Where do you define BT_USE_DOUBLE_PRECISION ?

The least error-prone method is to simply hardcode it at the top of Bullet/LinearMath/btScalar.h and make sure to clean/recompile all files/libraries.
Yup, that's exactly what I did.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision detection in double precision mode

Post by Erwin Coumans »

Several projects use double precision without a problem, so it is likely a build or initialization issue.

Is it just the collision detection with triangle meshes that fails?

Can you share the entire project, or at least the entire setup of btBvhTriangleMeshShape? Or attach a zipped COLLADA snapshot?
Thanks,
Erwin
mspong
Posts: 6
Joined: Tue May 05, 2009 11:25 pm

Re: Collision detection in double precision mode

Post by mspong »

Huh. I just tried again, and it seems to be working this time. Not sure what happened last time (I made sure to build everything clean then too). Sorry for the misunderstanding!