Need help conceptualizing Bullet usage

figgles
Posts: 3
Joined: Wed Dec 09, 2009 7:31 am

Need help conceptualizing Bullet usage

Post by figgles »

Hello all,

I'm developing a 3D MMORPG that is a similar to one of my favorites and I need some advice as to how to integrate Bullet into the server-side code. I need to implement collision detection between players (boxes), monsters (boxes), terrain (heightfield) terrain objects (e.g. rocks, simple convex hull), and later dungeons (BSPs). For now, I am concerned only with Player<->Player/Monster collision. The problem I am facing is that to simple dump all active objects in the world into a single "world" would likely not scale well given the size of the world (at largest, say 15x15 miles). Since things are likely to be geographically isolated by many miles (!) from each other, I was wondering if it made sense to create/destroy btDiscreteDynamicsWorld and add/remove objects from them. It likely that many objects will enter/leave the simulation as they are created/destroyed (e.g. arrows). For example, would it make sense to start each frame with an empty world and add the objects each frame, then clear the world and reset (might destroy caching?)

The number of sets of isolated blocks will increase as groups of players/monsters diverge from each other. You can picture an amoeba splitting in two, where each blob represents some active group of objects that could potentially interact with each other.

My world is divided into blocks of land, which are height fields about 100x100 yards in size, and objects are "on top of" it. This is the unit of granularity that I intend on using. I figure each isolated set of blocks can be simulated in parallel by the server's worker threads.

Is there any reason that using separate instances of btDiscreteDynamicsWorld each on a different thread would cause data corruption? It may sound like a silly questions, but in ODE, the answer is YES -- they share a lot of global state and multithreading even entirely separate worlds causes crashes.

The short list of questions:
a) Does my approach make sense? Does anyone have a better idea?
b) Is creating/destroying worlds expensive? Is this something you would want to do per-frame or would you want to cache instances?
c) Is adding/removing objects from worlds expensive? Is this something that can be done many times per frame (before simulation)?
d) Any multiple-instance caveat with respect to running multiple simulations on different CPUs?

Thanks for any help! Please let me know if I can clarify anything.

Patrick Baggett
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Need help conceptualizing Bullet usage

Post by Erwin Coumans »

a) Does my approach make sense? Does anyone have a better idea?
b) Is creating/destroying worlds expensive? Is this something you would want to do per-frame or would you want to cache instances?
c) Is adding/removing objects from worlds expensive? Is this something that can be done many times per frame (before simulation)?
Adding and removing many objects to the world is not recommended, there are caching and other optimizations. Try to avoid creating a world each frame. Just add all objects to the world and rely on the btDbvtBroadphase.
d) Any multiple-instance caveat with respect to running multiple simulations on different CPUs?
You should be able to simulate different worlds in parallel, if you run into issue just report them here.
Thanks,
Erwin