# Physics: calculating forces.

## Physics: calculating forces.

Hi everyone,

I'm trying to simulate a penetration. Here are the simplified conditions:

I have a compound body consisting of triangles(flat ones), joined by their vertices, and a separate sphere. The sphere is launched at a body. The idea is, if it hits(or presses) the surface of any tringle hard enough, this triangle is destroyed and removed from the world. Thus, sphere creates a hole in the body.

I would like to know if there is a way to calculate how hard sphere and triangle press each other using havok. Thanks in advance.

3 posts / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Olex,
The Havok solver, like most iterative solvers, is based on application of impulses iteratively (impulse = instantaneous change of momentum) and the concept of "force" is not really available anywhere in the physics pipeline.
An impulse represents a force applied over the course of a Physics timestep, so basically the problem becomes obtaining the impulse the solver applied during the timestep.

This task is not as trivial as one may think, if you look at the docs, in the section about Havok Physics 2012 -> Interacting with a Simulation -> Collision Listeners, you'll see that the physics pipeline has the following order:

1) Solve constraints (including contacts)
2) Collision detection (including TOIs and TOI solving)

Meaning that basically when the contact gets solved and we apply impulses to the bodies we are solving the collision that we detected the frame before, shortly after in the same step we'll do another collision detection for the frame coming after this.

So basically to figure out how much impulse has been applied or is going to be applied to those bodies, you have 2 options:

a) You can look inside your hkpContactPointEvent in your contact point callback and retrieve m_contactPointProperties.getImpulseApplied(). This will be an approximation the impulse applied by the solver just before and it will correspond to the solving that happened for the same contact but the frame _before_. Also, if the contact is deleted, the results applied last frame will be lost.
b) You can try to figure out what impulse is going to be applied and how strong of an impact you're looking at by asking for hkpContactPointEvent::getSeparatingVelocity(). This will return you the relative velocity of the two objects at the point of contact projected on the separating normal and this should be enough for you to figure out how strong of an impact is probably going to be. For the sake of completeness, the approximation that you're going to get here could be inaccurate because of TOIs and other constraints acting on the bodies, but most of the time this will be good enough.

Let me know if that makes sense!

Cheers,
Daniele

Try not to become a man of success, but rather try to become a man of value.

Thanks a lot for such a substantial reply! Things have become much clearer for me now. I don’t need much precision, so the second option you suggested should be ideal.