Objects with a mass of zero don't collide

Post Reply
Krumelur
Posts: 3
Joined: Sun Mar 19, 2017 7:51 pm

Objects with a mass of zero don't collide

Post by Krumelur »

I'm using Urho3D and have some box shaped objects. All of them have a rigid body and a collision shape (also a box).
As long as the masses of my objects is set to zero, the objects don't collide.
I'm not sure if what I'm trying to do is possible with the Bullets library, but my intention was to use it purely for collision detection and not for any kind of physics simulation.

What's the right way of solving this?
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Objects with a mass of zero don't collide

Post by ktfh »

try btCollisionWorld::contactPairTest ? or you can perform a convexSweepTest. More details about what you want collision but not physics for could help.
Last edited by ktfh on Sun Mar 19, 2017 8:10 pm, edited 1 time in total.
Krumelur
Posts: 3
Joined: Sun Mar 19, 2017 7:51 pm

Re: Objects with a mass of zero don't collide

Post by Krumelur »

Are you proposing that I should manually try to detect collision wit all potential bodies? That sounds wrong.

Meanwhile I found that my bodies should be kinematic and not dynamic. So I changed them. Still I don't get any collision callbacks.
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Objects with a mass of zero don't collide

Post by ktfh »

Krumelur wrote:Are you proposing that I should manually try to detect collision wit all potential bodies? That sounds wrong.

Meanwhile I found that my bodies should be kinematic and not dynamic. So I changed them. Still I don't get any collision callbacks.
static and kinematic objects cant collide with each other. Could you provide more details about what your trying to achieve ?
Krumelur
Posts: 3
Joined: Sun Mar 19, 2017 7:51 pm

Re: Objects with a mass of zero don't collide

Post by Krumelur »

Sure, let me try.

I have a simple scene in Urho3D without any physics going on. The player can move an object around (a cube) and is supposed to "collect" items which are not moved by physics but change their positions randomly.

Urho3D is using Bullet to simulate physics. If I know add a rigid body and a collision shape (box) to the player and the collectible objects, everything starts dropping down, thanks to gravity and the mass of the objects. Also, the objects influence each other by colliding and change positions due to the forces applied to them. Nothing of this behaviour is what I want for this simple demo game, except the fact the collisions are detected: Urho3D reports all collisions detected by Bullet back to me in a callback.

So I set the mass of my objects to 0 to prevent them from falling. But this disabled collision detection (and I presume that's a feature/behaviour of Bullet and not Urho3D; please correct me if I'm wrong).

Next thing I found: Bullet supports kinematic bodies. I read about tose and figured that's what I want. My player object and the collectibles should be of this type but still, if the collision shapes clearly overlap, I'm not informed about the collision.

Does that help to make it clearer?

EDIT: I noticed that the collision shapes seem to be inactive (the debug renderer changes their color from white to green). So I tried and made the player a dynamic object with mass and disabled gravity on the scene. Now if the player is moving, it will collide with the other kinematic objects but with all the effects described above, meaning physical force will be applied to it and it will bounce off the other objects.
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Objects with a mass of zero don't collide

Post by ktfh »

You could implement this with a btGhostObject, they maintain an array of overlapping objects, I think you would still have to perform a contactPairTest for each overlapping object to get btManifoldPoint where they touch.

You might also find the btKinematicCharacterController useful too
http://bulletphysics.org/Bullet/BulletF ... oller.html
Post Reply