Jump to content
  • Advertisement
Sign in to follow this  

Sliding a ball on a surface

This topic is 2921 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been working on my physics solution and I know how to calculate resting contact, but my definition of this might be off. I calculate resting contact as

distance = (plane.Normal dot sphere.origin) - plane.d
then if (plane.normal dot sphere.velocity) * distance == 0.0f, there is resting contact

This will be true that there is restinng contact when my simulation first starts, as the
plane.location = (0, 0, 0)
plane.normal = (0, 1, 0)
sphere.origin = (0, 1, 0)
sphere.radius = 1
sphere.velocity = (2, 0, 0)

My first question, is it still "resting contact" in my simulation scenario? My sphere is sitting on the plane, although it is not exactly still as the ball is still moving 2 on the x direction. Also, the sphere radius is not taken into account in this exact scenario(I first check to see if there is static collision with the radius though).

My second question is, if there is resting contact, should the update for the object be modified? My physics update first checks collision, then does an update (should it be the other way around?). How ever, my update makes no notice of the collision state (which in this case, is resting state) and will apply gravity. Should my object update check to see if it is in resting contact, and then not update the velocity?

EDIT: I understand that friction will also need to play a part of this, which I have added but I need to get the resting state and update part correctly because I can add that.

Share this post

Link to post
Share on other sites
Each contact between objects is unique and should be persistent. In other words, the next frame, you need to know if this contact was there the previous frame.
Contacts that have been around for a while are resting contacts.

Typically the bodies are solved in one of two ways, depending on if it has resting contacts or newly created colliding contacts.
Newly created contacts are handled sequentially and change the velocity of the contact pt to prevent or to reduce penetration.

Contacts that have been around for a while are harder to solve and must find a solution that also keeps all of the other contact pts satisfied.

In the simplest case, a sphere on a plane. The force for the resting contact will need to be compute to be exactly the opposite of the force of gravity. That way when you add the two together, the object does not accelerate. You first accumulate world forces, such as gravity, and then you compute contact forces to keep the penetration constraints satisfied.

If another sphere were to come to rest on top of this sphere, the contact pt between the first sphere and the plane would have to supply twice the force. It becomes more complicated as more contact pts are involved because adding a force to one pt may change the force requirement of another pt. Often a large system of equations is constructed and iteratively solved until a "close enough" solution is found. The result is a list of force, one per contact pt that if applied over the next frame will prevent all contact pts from going into penetration.

See the last section here: http://graphics.cs.cmu.edu/courses/15-869-F08/lec/14/notesg.pdf

That would be the proper way to solve it. a hack way to solve i is to just treat all the contacts as collisions and iterate them a few times each frame. the results can be very plausible.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!