1
\$\begingroup\$

I have been working on a physics simulation module. Almost everything works properly, but I am having an issue, which I have demonstrated in the following video.

http://youtu.be/2L17y9Lme0Q

As you can see in the video, if an object doesn't have an angular velocity, everything is OK. But once an angular velocity (even just a little) is applied to the object and it collides with the ground, it begins to shake.

I check for collision and get the normal and MTD (Minimum Translation Distance) using SAT (Separating Axis Theorem).

To get the contact point, I check for intersections between the two polygons. If there is more than one point of intersection, I then find the point in between the two intersection points.

Then I resolve overlapping objects by using the normal, MTD, and mass factor. To solve the collision, I use the Impulse theory.

Do you have any idea what might be causing this shaking effect? Could it be caused by a wrong choice of contact points?

\$\endgroup\$
  • \$\begingroup\$ I have had shaking glitches like this before (it was with much simpler physics though). Basically when something would land it would shake because I was using floats so it would round down the Y because of the gravity and offsets or whatever the cause was. When I would print it go between something like 36.99999996 and 37.000000001. The solution was to round the Y when drawing. \$\endgroup\$ – Lysol Jan 10 '14 at 23:35
  • \$\begingroup\$ I'm not really sure is it the problem, because shaking object is very unstable - if I put another body (B) on body that shakes (A) then body B can't become stabilized \$\endgroup\$ – l00k Jan 11 '14 at 0:02
  • \$\begingroup\$ Floating point issues can exist in the simulation, no just the drawing of it. Your algorithm might be oscillating around some very small target value and over-compensating for it. Try adding a margin-of-error anywhere you compare floating point numbers. \$\endgroup\$ – user39686 Jan 11 '14 at 20:24
1
\$\begingroup\$

This is because you only have a single point of contact. During the first solve you apply a huge torque, which forces the other side of the object downward -repeating the cycle.

One way is to keep both points of contact. You can solve this issue by solving two different resolution contacts, one for each point, and spread out the impulse scalar over each point of contact based upon depth.

for each scalar impulse j and associated contact depth
{
  ApplyImpulse( objectA, j, depth );
  ApplyImpulse( objectB, -j, depth );
}

This will provide multiple angular responses, of which will cancel each other out leaving only the upward linear impulses.

Please also be sure to allow objects to penetrate slightly with a slop factor, and do not resolve collision with separating velocity.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.