Getting impulses applied with Havok 2011.3.0.1

Getting impulses applied with Havok 2011.3.0.1

Hi all,

I have just updated my code from Havok 6.6.0 to the last release. Reading the documentation, I have been pleased to see that the collision callback system have been improved. in particular, I was interested in the newTYPE_MANIFOLD_AT_END_OF_STEP contact type that makes getting contact information after the solving step much easier. However, even with this new contct type, I can not get the impulse applied by the solver for most contacts !

I have set theregisterForEndOfStepContactPointCallbacks(event) andinfo.m_fireCollisionCallbacks = true; properly, I set therigidBody->setContactPointCallbackDelay(0); to 0 just in case... All the callback system works well... Except the getImpulseApplied value that is stuck to 0, unless the contact point lasts several frames.

For example, I set up a ball to hit and bounce against a wall with a certain velocity. This generates a brief contact that generates 2 or 3 callback calls, but none of them has an appliedImpulse greater than zero. Does anybody know how to get the impulse applied ? By the way, in my case it is important to get the actual impulse applied at each contact point, not an approximation based on the change of velocity.

Thanks in advance,

Loeiz.

publicaciones de 8 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.

Hi Loeiz,

Unfortunately, there is no way to get the applied impulse value from the callback (even the end of step) since it calculates that information afterwards. The usual workaround is, like you suggested, to use the velocities to approximate the impulse, but since you want the exact impulse I'm afraid there's no way to do that--at least not without source level access to the SDK. :/

Best regards,

--Joel

Hi Joel,

Thank you for the answer. This is indeed curious that this informmation is not available, as it is a relevant information for the different events of the game (e.g. setting the volume of the contact sound w.r.t. the impulse applied).

However, I found a member called m_internalSolverData in the contact properties, that seems to be completely related to the impulse applied. According to my measures on a sphere-plane contact, this value is proportionnal to the velocity of approach, and proportionnal to the time step used. this may be the coefficient applied for the contact point in the linear system being solved ? In that case, the impulse applied could be deduced... Could you tell more about this value ?

Thanks,

Loeiz.

Hi Joel,

I'm interested in aproximate calculation of impulse from separating velocity, how can it be achieved?

Hi Andy,

The separating velocity at a contact point refers to the relative speed with which the points on each body are moving away from each other.  If this value is negative, it means the points are moving toward each other and are likely to collide.  Generally speaking, this means that the total impulse applied by the collision will be equal to this velocity.  In addition to this, restitution can be applied, which will scale the total impulse by 1 + (resA  * resB), where resA and resB are the individual restitutions of each body.  If one of the objects is fixed or keyframed, then its velocity will not be influenced by the collision and the total impulse will be applied to the other object.  If both objects are dynamic, then the total impulse applied will be divided between them according to each's mass.  If the masses of bodies A and B are massA and massB, then the impulse applied to body A will be the total impulse * massB / (massA + massB).  Together this can be expressed as

impulseAppliedToBodyA = separatingVelocity * (1 + (resA * resB)) * massB / (massA + massB)

if B is dynamic, or

impulseAppliedToBodyA = separatingVelocity * (1 + (resA * resB))

if B is fixed or keyframed.  For simple collisions, thich should give you a good approximation of the impulse applied to each body.

cheers,

Josh

Josh S. Havok Developer Support Engineer www.havok.com

Thank you!

That's what I need.

Hmm, I'm missing one thing, doesn't mass of both objects matter?

When two 1kg objects have separating velocity 1 m/s, applied impulse is apparently lower than two 1000 kg bodies with separating velocity 1 m/s.
(in above equations mass only splits impulse between bodies)

I guess I should add
* (massA + massB), right?

Hi Andy,

It sounds like you may be thinking of force, which is relative to mass.  Impulse refers to an instantaneous change in velocity, and this is not proportional to mass.  Think of it this way: say you have two 1 kg balls that both have zero restitution, one at (-1,0,0) with velocity (1,0,0) and the other at (1,0,0) with velocity (-1,0,0).  They should collide at (0,0,0) with separating velocity 2 m/s.  They are the same mass travelling at the same speed, so after they collide, they should both end up with velocity of (0,0,0), meaning they experienced an impulse of (-1,0,0) and (1,0,0) respectively.  Now imagine that each of those balls is actually 1000 kg.  They should still come to a stop after colliding with each other, meaning their impulses are still (-1,0,0) and (1,0,0).  That is to say, you can't tell by watching two bodies collide how massive the bodies are, only how massive they are relative to each other.  This is because you only observe the impulses.

If you want to estimate the force of the collision using the impulse, then you need to take the mass into account.  You can estimate the force applied to each body using f = ma.  The mass of each body is known, and you can estimate the acceleration using the impulse * frame rate.  So you can estimate the forces applied to each body as forceA = massA * impulseA * frameRate and forceB = massB * impulseB * frameRate.  It should work out that forceA = -forceB.

It can be counterintuitive that we're working with impulses rather than forces.  This is due to the fact that Havok physics is processed in discrete time steps rather than continuously.  This means that impulses can be computed exactly, but forces cannot; which is the opposite of how we learned physics in school. Keep in mind that the force estimate above is highly dependent on the physics frame rate, and is only accurate relative to other forces calculated this way.

Josh S. Havok Developer Support Engineer www.havok.com

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya