Jump to content



Continuous collision time subdivision

  • You cannot reply to this topic
4 replies to this topic

#1 celloe   Members   -  Reputation: 100

Like
0Likes
Like

Posted 13 February 2012 - 01:01 PM

Hey guys, been working on something all day and haven't been able to make any progress whatsoever.. I've been trying out continuous collision detection through an approach of "find time of impact, if it's within the next frame integrate positions to that time, solve, then resume simulating" which should work fine. I've been looking at a few implementations, namely Andre Michelle's PopShapes physics engine (and his other one, Revive, but I think his site's down just now). I understand the method and the theory behind it but when it comes to implementation I can never seem to get it quite right, it'll detect first collisions and attempt to solve them but it can easily.. go wrong.

Here's an example of the sort of thing I'm doing:
var dt = 1.;

var pair = new CirclePair(cs[0], cs[1]);

while (pair.willCollide(dt)) {
    pair.c1.integrate(pair.toi);
    pair.c2.integrate(pair.toi);
    
    dt -= pair.toi;
    
    pair.resolve();
}

for (c in cs) {
    c.integrate(dt);
    
    // Reset forces etc
    c.fx = 0;
    c.fy = c.mass*gravity;
}

This works in certains situations, though in others will just completely lock up. If I add a breaking term, for instance incrementing a variable each step and terminating the while loop if it exceeds a certain value, then it never crashes but penetration occurs. What could be the cause of this?

Ad:

#2 wildbunny   Members   -  Reputation: 180

Like
0Likes
Like

Posted 18 February 2012 - 05:19 AM

Its a big can of worms this problem, and very, very difficult to get right.

Take a look at box2d, which features a solid implementation of this technique.

There is another way of approaching this problem as well, if you don't mind a few compromises. I wrote this article on the subject:

http://www.wildbunny...pproach-part-1/

As a side note - I would steer clear of physics engines which attempt to model rigid bodies as a series of length constraints - they're easy to understand but they quickly come unstuck with fast collisions which can flip objects inside out. And getting stability requires a lot of iterations :)

Cheers, Paul.

#3 celloe   Members   -  Reputation: 100

Like
0Likes
Like

Posted 20 February 2012 - 02:49 AM

Hi Paul, I've tried working with speculative contacts before (consider me a fan.. I've even commented on the article!) but the inability to model elastic collisions is a bit too much of a downside to me. As a side note, can you implement friction with speculative contacts? I imagine it's possible but don't know how you could circumvent the same problems that prevent elasticity.

I'll take a look at Box2D's source, it's a little.. overwhelming at this point, but I'll keep at it. And I agree regarding deformable bodies, I was more just taking a look to see how he handled the TOI ordering. Turns out it breaks pretty easily with more than a few bodies anyway!

#4 kloffy   Members   -  Reputation: 273

Like
0Likes
Like

Posted 20 February 2012 - 02:34 PM

View Postwildbunny, on 18 February 2012 - 05:19 AM, said:


Looks like the blog is down ("403 Forbidden"). I hope it is only temporary, the articles that show up on Google sound extremely interesting...

#5 wildbunny   Members   -  Reputation: 180

Like
0Likes
Like

Posted 20 February 2012 - 05:11 PM

View Postkloffy, on 20 February 2012 - 02:34 PM, said:

View Postwildbunny, on 18 February 2012 - 05:19 AM, said:


Looks like the blog is down ("403 Forbidden"). I hope it is only temporary, the articles that show up on Google sound extremely interesting...

Sorry, was having yet more problems with my webhost - its back again now...

Yes, you can implement friction no problem - look for my angry birds pt2 article for a live demo :)






We are working on generating results for this topic
PARTNERS