Olee wrote:While I was testing my world and shooting around some projectiles I found a lot of areas where with one hit of the projectil on the ground many sounds were played at once.
After some debugging I found out that Newton calls the NewtonContactsProcess-callback numerous times with the SAME CollisionJoint parameter and the same data for position, normal, ... of for the contacts (of NewtonContactJointGetFirstContact).
This happens often when I shoot on the ground with a small angle and when there are more polygons forming a simple floor.
EDIT:
I just found out that this also happens at low speed, but ONLY WITH CONTINIOUS-COLLISION-MODE SWITCHED ON.
Björn Zeutzheim
this is normal, when continue collision is on, and you have a body that move at hight speed,
or at a peed that in one timestep will generate a large penetration on teh colliding bodies, the engine do no integrate the body and the normal time step,
because that leads to contacts generation outside the sphere of the body, which also lead to very bad contact resolution.
say for example you have a small box with Continue collision on, and you move at speed that will make the body of the Box travel more than half the smallest with of the Box.
Say the Box will hit a wall on and edge.
the continue collision code determine that the contact point will be on the edge, but the edge is way outside the Box Shape.
If a contact pair like that is sent to the solve, the contact will generate unrealistic implsive torques that will make the Box move in strange ways,
some time even explosion. This is how 1.53 worked.
In 2.0 the engine save the state on the bodies and all the bodies that are in contact,
and the one in cont wit with other (the island), then is find the bodies with the world Time/space displacement and calculate the conservative time step.
until teh body react teh closest contact. Then is determine how many steps it need to execute to complete the time application step.
then is discard the contacts, and in a loop it advance the island by this smaler conservative time step,
each time calculating continue collision at the end of the smaller time step, solving the contacts and integrating the island.
the calculation is very efficient because the call to collision is seeded with the contacts that are already calculated,
and in the calculation determine that no there there are not more contact in the path of the body then is does the rest for the time in one iteration.
in the Box example in the box CC determine that it needs 10 steps then, in a loop is does this.
-abcance by convervatibe step, and recalculate contacts, this now make the contacts closer to the collision shape.
-the contacts are the same at before but the time is lot smaller, so the teh solver will calculate more accurate impulse,
-the contct are solve and the imuplse are applyed to each body,
-in the next step, continue collision is called again to get new contacts,
-if the Box collide again, the the loop repeacts until no more time is left
but if the box do not see a contacts the teh loop is terminated, and teh bodies are advanced by the time leftover.
this is why you see more than one call to contact call back when CC is on.
notice that this does not slow the entire when a body move at hight speed since only
that body and the bodies invlve in the collition are subsample in the calculation.
you can solve the problem of playing duplicate sounds by instead of playing the sound from the callback, you queue the sound, and the you play then the after the call to NewtonUpdate.
This is better anyway, because if you enable multithread, you may run in thread synchronization problem the may require critical section that may slow down the engine or worse race generate condition.