Verlet collision detection and response

Started by
11 comments, last by haphazardlynamed 19 years, 6 months ago
Hi, I've been messing around with the Jackobsen verlet paper and I have a problem. My world is a 2D set of line segments, to begin with as a quick hack I was just adding the response vector to the current position of the particle, which works very well but looks nasty if falling a long enough distance to make the gap between the particle path and the actual collision point noticable, causing a visible jolt. So next I tried projecting the particle onto the collision point and modifying the old position to cause the bounce, the problem with this is if the bounce is very small the particle could fall through the geometry or never be resolved and crash. I need suggestions and help. :)
Advertisement
In your first scenario, were you scaling the response vector by the appropriate time step? For example, if the collision occurs somewhere between t and t+dt (dt being the time step of your sim), you do not need to apply all of dt to the after-collision motion. If the collision occurs at t + ht (ht being between zero and dt), then you'd only need to apply (dt - ht) to the after-collision motion.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Quote:Original post by grhodes_at_work
In your first scenario, were you scaling the response vector by the appropriate time step? For example, if the collision occurs somewhere between t and t+dt (dt being the time step of your sim), you do not need to apply all of dt to the after-collision motion. If the collision occurs at t + ht (ht being between zero and dt), then you'd only need to apply (dt - ht) to the after-collision motion.


No I wasn't, that sounds very much like it will fix the problem, wouldn't this cause a lot of unwanted energy loss though? The last step would only be very small.
...Unless I move the old position proportionally back the other way, which sounds a like it could cause the same problems as in my second solution...

I'll try it and see what happens.
Quote:Original post by xobliam
Quote:Original post by grhodes_at_work
In your first scenario, were you scaling the response vector by the appropriate time step? For example, if the collision occurs somewhere between t and t+dt (dt being the time step of your sim), you do not need to apply all of dt to the after-collision motion. If the collision occurs at t + ht (ht being between zero and dt), then you'd only need to apply (dt - ht) to the after-collision motion.


No I wasn't, that sounds very much like it will fix the problem, wouldn't this cause a lot of unwanted energy loss though? The last step would only be very small.


If you do what I meant to be communicating, you wouldn't be losing energy. If you were doing what I though you were doing, you're really sort of fast-forwarding in time, e.g., moving further in one time step than you should. You weren't adding energy either since your velocity would have dropped back to normal in the following time step. But, its possible that I've both misunderstood what you are doing and miscommunicated what I want you to do! A small code sample might help, if you wanted to post one.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Think I had better make some diagrams too. ;)
I've googled for a while and found the problem described in greater depth here:

http://www.idevgames.com/forum/showthread.php?t=2189

Here if there is no energy loss (coeff=1) everything goes ok, but if coming to rest (coeff=0) with neither end touching there will be a jolt before the simulation corrects itself.



Here's the problem I'm thinking of when using a variable timestep, unless compensated for:

you have to remember that the velocity in a verlet integrator is implicit. meaning, it's calculated from the previous position to the next position. Imagine a particle bouncing straight up on a plane. the next position coinciding with the start position after the bounce. the implicit velocity will then be 0, instead it should be on the positive Y (the particle moving straight up).

I think you'd have to move the prev position to say, under the plane, or something like that, so the velocity of the particle is concerved.

That's my understanding of it. Anyone agrees?

Verlet is not meant for single particles, but an assembly of particles. The enengy is very hard to control in a particle system like this. In the Jakobsen paper, there is no such thing as collision response, only constraining the position of particles within the empty regions of the world. That in turn create some pseudo friction and low elasticity.

Everything is better with Metal.

In my physics model (which is based on Jakobsen's)
when I find that the new position is below the plane and the previous one was above
(thus it crossed the plane and collided at some unknown inbetween time)
I reflect Both the new and previous positions across it

so the new position is goes above, the previous one goes below
this conserves the velocity magnitude and flips its direction
and also puts the particle at the position it theoreticaly should end up assuming a perfectly elastic collision
-the amount of distance travelled past the plane between time steps is the same amount of distance it would have bounced if we had known the exact collision time


this also keeps the particle from falling through the floor, since it always gets repositioned above it whenever it sinks below
one thing to worry about though, is when you have a multi-particle object, that the constraint springs dont push a particle under the floor, this kind of 'artificial' repositioning can mess it up so that the reflection doesnt work right
Quote:Original post by oliii
I think you'd have to move the prev position to say, under the plane, or something like that, so the velocity of the particle is concerved.


Yes, that's what I was doing but it caused errors too often. While nobody has any solution I have some hack ideas I'll try out and report back.

This topic is closed to new replies.

Advertisement