🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

sweep test with two moving bodies

Started by
1 comment, last by coderchris 6 years, 1 month ago

Hello,

I have a circumstance where I have two very thin cylinders, and I want to determine the (reasonably) precise moment that they collide as they move toward each other. They will not be moving or rotating extremely fast, but it may be enough that they will pass through each other in a single time step, because they are so thin.

I am using the Bullet physics library (Is anyone else still using Bullet, btw?) and it has a fancy function that lets you perform a sweep test of a convex object as it moves from transformation A1 to transformation A2. The return value includes the proportion of how far it had to move from A1 to A2 to reach the point of contact, which is all I need. Cool! I could use this instead of discrete, once per frame collision checking.

My issue is that BOTH objects are moving. Object A is moving from transform A1 to A2, and object B is moving from transform B1 to B2.

Would it be reasonable to check for this collision by computing only the relative motion of object B from A (in other words, let A be our reference frame), and then do a sweep test of B, observing that relative motion?

More precisely, the initial position of object B relative to object A would be D1 = A1^(-1)B1, and the final position would be D2 = A2^(-1) B2.

I could then fix the position of object A at the origin, and perform a sweep test of B moving from D1 to D2. 

Does this seam like a reasonable approach, or how else should I do this?

Any advice would be appreciated.

Thanks!

 

Advertisement
Quote

I could then fix the position of object A at the origin, and perform a sweep test of B moving from D1 to D2. 

Does this seam like a reasonable approach, or how else should I do this?

Spot on. That's typically how you would handle the case of two moving rigid objects. Fix object A and subtract object A's transform from object B.

 I'm not sure how bullet's swept function works internally, but if you want to implement it yourself, you could look into conservative advancement. 

This topic is closed to new replies.

Advertisement