Bullet for really large amounts of simple objects

CIB
Posts: 3
Joined: Fri Dec 04, 2009 10:38 pm

Bullet for really large amounts of simple objects

Post by CIB »

I'm designing a game that I want to add physics simulations to. This game will be based on completely dynamic, tile-based maps, that is a building may consist of tens of thousands of distinct wall objects that may be modified at any time. These walls don't need to be moved by the physics engine, but they need to serve as colliders.

Furthermore, there will likely be hundreds to thousands of objects that can potentially be moved by the physics engine.

Obviously, at least with my requirements(I want the game to run on my 2ghz dualcore CPU), it won't be possible to simulate the entire building at once. That's fine. I can disable physics simulations for parts of the building and use less accurate approximations instead. The problem I have is that I don't know how fast it would be to remove objects from the physics simulation and add them again. Would it be viable for the engine to add a few hundred objects in less than half a second? Or is there a way to have the physics engine contain all objects at once, putting most of them to sleep, efficiently?

A compromise might also be to summarize the walls to larger objects, and have only these in the engine all the time, while loading and unloading only the movable objects.

Since I've never used a physics engine, this decision is not easy for me, so if some of you could share your experiences, that would be greatly appreciated.
User avatar
gennoevus
Posts: 39
Joined: Sun Oct 10, 2010 4:39 am

Re: Bullet for really large amounts of simple objects

Post by gennoevus »

Planning on making something like minecraft eh? lol

I have a machine with similar specs to yours. Even without any sort of optimization, I was able to generate a absolutely insane amount of dynamic objects, all of which were colliding not only with each other, but with a high poly static triangle mesh environment.

I bound the spawning of the objects to a button on my keyboard. The object I was spawning was a compound shape made of three rectangular prisms and a sphere (it was a weird tripod thing). I wasted a lot of time just playing around spawning ga-zillions of these compound objects and the frame rate never dropped enough to affect gameplay.

If you are just using geometric primitives (cubes, spheres, etc.) I can imagine that what you are trying to do will not be a problem.

I have found that it will slow down considerably if many objects are spawned at once AND they are colliding/intersecting with each other, but I'm sure that most of the time you wont be spawning objects inside each other!
CIB
Posts: 3
Joined: Fri Dec 04, 2009 10:38 pm

Re: Bullet for really large amounts of simple objects

Post by CIB »

That's interesting. Hm, it seems I might want to do a bit of experimenting of my own. Just to give you an impression, I figured I'd want to support around 100000(100x100x10) wall objects at a time. They'd just be immovable colliders, so I'm really not sure. Memory consumption might be a concern, I'm currently using very simplistic structs to represent all my objects.
User avatar
gennoevus
Posts: 39
Joined: Sun Oct 10, 2010 4:39 am

Re: Bullet for really large amounts of simple objects

Post by gennoevus »

If they are static, I can't imagine that it would be a problem ... probably! Try it!! :twisted: