Jump to content
  • Advertisement
Sign in to follow this  
Bow_vernon

Sweep test and physics

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

Ok, Im worried about tunneling now, and I guess the best thing to do is a sweep test. now how to do it. with many objects there are many TOI. what do I do with them? and what is this "it may stuck, Bow!" my friend said on the phone? sadly he isnt able to explain more(on vacation). any suggestion?

Share this post


Link to post
Share on other sites
Advertisement

Ok, Im worried about tunneling now, and I guess the best thing to do is a sweep test. now how to do it. with many objects there are many TOI. what do I do with them? and what is this "it may stuck, Bow!" my friend said on the phone? sadly he isnt able to explain more(on vacation). any suggestion?


Ok, first let me say this: there is no way to avoid penetration in all cases. You *will* have to deal with it at some point, so all your collision detection/response routines will have to be able to detect and recover from it.

Secondly, dealing with lots of TOI events from multiple simultaneous collisions is *hard* and can be *very* slow. I faced this problem when writing the physics engine on little big planet psp...

The solution (and i can't take credit for it, unfortunately) is not to do it. Instead you need to use what i'm going to call 'predictive contacts'. These are detected by your usual time stepping collision detection code - there are several ways to do this, the most simple is to just use a closest points between objects routine.

These predictive contacts should do *no work* in the solver until the collision is due to happen, and when they do act, they don't remove all the relative normal velocity, they only remove exactly the right amount to bring the object to exactly touch the surface.

Thats the basic gist of it anyway, really this needs its own article and demo - if you'd like to see one please register your interest in this thread :)

Cheers, Paul.

Share this post


Link to post
Share on other sites
Eh? of course Im all interested. I know it's unvoidable, Im just trying to avoid tunnelling with a minimum of fuss. Im not used to CCD, what do I do with TOI? what should I add to the integration scheme (with the TOI)? Anyway, I dont need accurate TOI. Just a 'safe' value is enough. Thanks...

Share this post


Link to post
Share on other sites

Eh? of course Im all interested. I know it's unvoidable, Im just trying to avoid tunnelling with a minimum of fuss. Im not used to CCD, what do I do with TOI? what should I add to the integration scheme (with the TOI)? Anyway, I dont need accurate TOI. Just a 'safe' value is enough. Thanks...


I'm saying you might want to consider forgetting about TOI completely, use predictive contacts and let your contact solver do the hard work for you...

If you really must use TOI events then i would sit down on paper and draw out a bunch of different scenarios with several objects colliding in the next time-step each with different TOIs and note what happens when you solve each scenario in a certain order. Then switch the order around and try again - you'll notice it leads to a different outcome each time. The TOI events must be processed from earliest to latest...

If enough people chime in on this thread then i will consider writing the predictive contacts thing up formally with a demo :)

Cheers, Paul.


Share this post


Link to post
Share on other sites
Ok, Im very scared of tunnelling, ya know especially with small sized objects. I'll forget the TOI altogether, ok. Oh man if we wait for enough people in this thread, Im affraid it will take a long time...
I'll wait though, oops Im too happy and cant wait to see it >.<

Share this post


Link to post
Share on other sites

Ok, Im very scared of tunnelling, ya know especially with small sized objects. I'll forget the TOI altogether, ok. Oh man if we wait for enough people in this thread, Im affraid it will take a long time...
I'll wait though, oops Im too happy and cant wait to see it >.<


Maybe i can explain using a simple example :)

  • Ok, take a small sized sphere object, travelling very quickly towards the ground.
  • Around the sphere, form a bounding box which encompasses the sphere on the current frame AND where the sphere will travel to on the next frame. Lets call this the swept bounding box.
  • If this swept bounding box intersects the ground on the current frame, there will possibly be a collision on the next frame.
  • So, we generate a predictive contact for the sphere and the ground. The simplest way to do this, is just to pick the closest points between the two objects as the collision points, and the normal is the unit length vector between these two points.
  • At contact solve time, the predictive contact will remove *only* the portion of the relative normal velocity that would cause the sphere to just touch the ground on the following frame.

    Thats the gist of it - I've over simplified here for example purposes but that should get you started :)

    Cheers, Paul.

Share this post


Link to post
Share on other sites
Im confused +.+a suppose I get the predictive CP, but at the current frame and the objects havent collided yet. Should I solve the predictive contact? that's weird. The objectsarent intersecting but we've solved CP. Or Im missing something??
*.*

Share this post


Link to post
Share on other sites

Me needs more explanation, puh lease +.+a


Because you know the objects will have collided somewhere between the current frame and next frame, its ok to solve the predictive contact on the current frame, because after you've solved it and the next frame rolls around, the objects will be just touching :)

Basically, you're throwing away some of the time involved in the collision by doing this, but in practice it looks totally unnoticeable :)

Cheers, Paul.

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!