Jump to content
  • Advertisement
Sign in to follow this  
celloe

Continuous collision time subdivision

This topic is 2486 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

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?

Share this post


Link to post
Share on other sites
Advertisement
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.co.uk/blog/2011/03/25/speculative-contacts-an-continuous-collision-engine-approach-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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

[quote name='wildbunny' timestamp='1329563970' post='4914162']http://www.wildbunny...pproach-part-1/


Looks like the blog is down ("[color=#000000][font=monospace][size=1]403 Forbidden[/font]"). I hope it is only temporary, the articles that show up on Google sound extremely interesting...
[/quote]

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 :)

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!