Hi, I'm relatively new to bullet and need help on how to get information from collisions
I have a room full of rigid body boxes, how could I determine the impulse force from collisions on these boxes ?
How could I determine the normal vector from a collision these boxes?
thanks in advance
collision impulse and normal
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: collision impulse and normal
Easiest and best way is to iterate over all btPersistentManifold, each holds up to 4 contact points (but it can be empty).
Each contact point (btManifoldPoint) has the applied impulse (m_appliedImpulse), contact normal (m_normalWorldOnB) etc.
See CollisionInterfaceDemo how to access the contact points (Bullet\Demos\CollisionInterfaceDemo\CollisionInterfaceDemo.cpp)
Hope this helps,
Erwin
Each contact point (btManifoldPoint) has the applied impulse (m_appliedImpulse), contact normal (m_normalWorldOnB) etc.
See CollisionInterfaceDemo how to access the contact points (Bullet\Demos\CollisionInterfaceDemo\CollisionInterfaceDemo.cpp)
Hope this helps,
Erwin
-
- Posts: 13
- Joined: Fri May 23, 2008 4:30 pm
Re: collision impulse and normal
Thanks for your help, I got it working
-
- Posts: 229
- Joined: Sun Sep 30, 2007 7:58 am
Re: collision impulse and normal
Hi,
what is "m_appliedImpulse" exactly? The impulse that is needed to seperate two bodies after collision?
Especially when one object crashes into another then "m_appliedImpulse" is often zero for me. Is this
the normal behaviour? The collision normal acts as expected, also in this case.
what is "m_appliedImpulse" exactly? The impulse that is needed to seperate two bodies after collision?
Especially when one object crashes into another then "m_appliedImpulse" is often zero for me. Is this
the normal behaviour? The collision normal acts as expected, also in this case.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: collision impulse and normal
It is the total accumulated impulse applied by the constraint solver during the last internal substep.what is "m_appliedImpulse" exactly?
Bullet might perform multiple internal substeps, and a later substep might clear out the applied impulse. So if the m_appliedImpulse is access outside of the stepSimulation, it might be zero.
Try to access the m_appliedImpulse during a contact callback (see ContactProcessedCallback) or during an internal tick callback (see setInternalTickCallback in the dynamics world).
Hope this helps,
Erwin
-
- Posts: 229
- Joined: Sun Sep 30, 2007 7:58 am
Re: collision impulse and normal
This makes sense, because we let Bullet perform 4 substeps for each frame as otherwise small collisions go through small walls:
simulationStepsNum=4;
bltWorld->stepSimulation(1.0/frameRate,simulationStepsNum,(1.0/frameRate)/(float)simulationStepsNum);
If we now catch "ContactProcessedCallback", as you describe, wouldn't we then get more then one callback for our single frame because we have 4 subframes?
How is this problem solved generally?
Currently we just iterate over all btPersistentManifold and send callbacks to when "contactManifold->getNumContacts()>0".
thanks
simulationStepsNum=4;
bltWorld->stepSimulation(1.0/frameRate,simulationStepsNum,(1.0/frameRate)/(float)simulationStepsNum);
If we now catch "ContactProcessedCallback", as you describe, wouldn't we then get more then one callback for our single frame because we have 4 subframes?
How is this problem solved generally?
Currently we just iterate over all btPersistentManifold and send callbacks to when "contactManifold->getNumContacts()>0".
thanks