Using Bullet for swept collision detection _only_.

Post Reply
Ameise
Posts: 11
Joined: Sun Oct 18, 2009 1:18 am

Using Bullet for swept collision detection _only_.

Post by Ameise »

I'm writing an orbital simulator for solar systems. I can trivially write the n-body simulator to handle everything (and would much rather do that myself). However, handling the potential (but rare) swept collisions between spheres, ellipsoids, and irregular objects in space is frustrating and rather a waste of time.

From what I've read, Bullet can handle this. I'd much rather not use Bullet to handle all movement (and just use the n-body simulation as an impulse generator) as that could introduce more error, and I don't fully trust Bullet's double precision build (many, many truncations of double precision to single precision).

I've noticed that Bullet has btCollisionWorld, which looks to be designed so that one can use Bullet for collisions alone. Is it suitable/can it be used to perform swept collisions between the previous tick and the current tick, after I've updated every object's position, velocity, etc? I want to detect them, not resolve them.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Using Bullet for swept collision detection _only_.

Post by Erwin Coumans »

Hi,

You can indeed use btCollisionWorld, just using the collision detection and not even using/linking against BulletDynamics.

Just add all btCollisionObject to the world and perform a query.
The easiest is to perform a single query for each moving object, assuming all other objects don't move during each query.
btCollisionWorld::convexSweepTest . See also the Bullet/Demos/ConcaveConvexcastDemo for an example use of convexSweepTest.

It would be possible to create a new query that performs a convex sweep test between pairs of (potential) overlapping objects,
assuming both objects are moving during this query. Is that what you need, or is the previous query sufficient?
Thanks!
Erwin
Ameise
Posts: 11
Joined: Sun Oct 18, 2009 1:18 am

Re: Using Bullet for swept collision detection _only_.

Post by Ameise »

In this case, every tick all the objects are moved, and new positions/velocities are calculated. The only data available to me would be the previous tick's data and the current tick's data, and basically need Bullet to tell me, using swept collisions, whether any interactions happened between the previous tick and the current one.

It needs to be swept since the objects can potentially move fast enough over a tick to simply pass through other objects entirely.

All objects move every tick. Collisions are expected to be extremely rare.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Using Bullet for swept collision detection _only_.

Post by Basroil »

Ameise wrote:In this case, every tick all the objects are moved, and new positions/velocities are calculated. The only data available to me would be the previous tick's data and the current tick's data, and basically need Bullet to tell me, using swept collisions, whether any interactions happened between the previous tick and the current one.

It needs to be swept since the objects can potentially move fast enough over a tick to simply pass through other objects entirely.

All objects move every tick. Collisions are expected to be extremely rare.
Sounds like you might want to write your own broadphase and then "rewind" to the place where the collision might have happened (where you can use bullet's collision detection). Non-linear motion (assuming you are using proper gravity calculations) is probably easier to do as an optimization problem if you have both equations of motion for the paths between two steps (just minimize the distance D subject to time T terminating when D is < diameter of the larger object), and probably easier to vectorize if you are planning to go multi-threaded/GPU. If everything is linear though, have you tried the CCD demo to see if it helps?
Post Reply