Collision detection is eratic / not working :(

kazade
Posts: 3
Joined: Tue Dec 31, 2013 10:35 am

Collision detection is eratic / not working :(

Post by kazade »

Hi all,

I'm new to Bullet and I'm trying to convert my physics code from ODE, but I'm having some trouble getting rigid bodies colliding.

I have a test app, which creates a plane, and every second spawns a box above it. What should happen is the boxes should hit the plane, and pile up on one another. What actually happens is random. The boxes never collide with each other, but sometimes they collide with the plane, sometimes they don't. Sometimes they collide with the plane but rather than stopping, their descent slows down. My set up code is basically the same as the Hello World tutorial (http://www.bulletphysics.org/mediawiki- ... ello_World) except instead of creating a btSphereShape, I'm creating a btCompoundShape with a single child btBoxShape.

Does anyone have any idea what could be going wrong?

Thanks!
User avatar
emersonmx
Posts: 9
Joined: Mon Sep 09, 2013 2:06 pm

Re: Collision detection is eratic / not working :(

Post by emersonmx »

Why use a btCompoundShape with a btBoxShape rather than a simple btBoxShape?
kazade
Posts: 3
Joined: Tue Dec 31, 2013 10:35 am

Re: Collision detection is eratic / not working :(

Post by kazade »

It's to do with fitting it to the structure of the existing ODE backend in my game engine. I might be able to drop that, but I'd rather figure out why btCompoundShape isn't working than restructure my API :)
User avatar
emersonmx
Posts: 9
Joined: Mon Sep 09, 2013 2:06 pm

Re: Collision detection is eratic / not working :(

Post by emersonmx »

It's good to look ConcaveDemo to see what is wrong.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision detection is eratic / not working :(

Post by Erwin Coumans »

There should be no issue with btCompoundShape/btBoxShape versus btPlaneShape.

Can you please modify the existing BasicDemo with those shape and see if you can reproduce the problem,
and then share the modified demo so others can look at it?
Thanks!
Erwin
kazade
Posts: 3
Joined: Tue Dec 31, 2013 10:35 am

Re: Collision detection is eratic / not working :(

Post by kazade »

Hmm, I've just had a thought what it could be...

Do have to construct the rigid body *after* I've added all my child shapes to the btCompoundShape? At the moment I'm doing it the other way, e.g. passing a new btCompoundShape in the rigid body construction info, and then later adding child shapes.

Does the order matter?
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: Collision detection is eratic / not working :(

Post by xexuxjy »

Sorry ignore original post - setupRigidBody relies on the localInertia values in it's ctor so you would need to add all your children to the compound shape before calculating localInertia and creating the rigidBody.