Supporting 100000 objects in box2d

Started by
8 comments, last by BeerNutts 11 years, 10 months ago
Hello everybody, our team is developing a game and now we're in search of an engine that can simplify our project.

1) Can box2d be scaled to use more than 100000 bodies?
2) Can box2d be scaled to do collision detection of more that 100000 shapes?
3) what is the order of the raycast algorithm used in box2d for checking if 2 bodies are in line of sight of each other?
4) What 2d engine can be used for rendering more than 100000 characters?

Thanks!
Advertisement
1) Can box2d be scaled to use more than 100000 bodies?
2) Can box2d be scaled to do collision detection of more that 100000 shapes?[/quote]
If you mean at a reasonable frame rate, No. My Core 2 Duo 2.4GHz can't deal with more than a few hundred active bodies. I don't think there are any general purpose physics engine that can deal with 100k.

4) What 2d engine can be used for rendering more than 100000 characters?[/quote]
This is more a hardware problem. My on-broad Intel HD Graphics 3000 can render around 8K 32*32 sprites with same texture at 60fps, while doing game logic and rendering simple background. With some decent graphic card you could do maybe like 50K simple sprites or particles, but 100K "characters" don't sound promising.

It could be possible if you came up with some clever optimization for your game, but I'll suggest you consider that do you really need 100K.

This is more a hardware problem. My on-broad Intel HD Graphics 3000 can render around 8K 32*32 sprites with same texture at 60fps, while doing game logic and rendering simple background. With some decent graphic card you could do maybe like 50K simple sprites or particles, but 100K "characters" don't sound promising.

This is meant to be run on server, while showing only small part to frontend.

[quote name='AzureBlaze' timestamp='1340110844' post='4950561']
This is more a hardware problem. My on-broad Intel HD Graphics 3000 can render around 8K 32*32 sprites with same texture at 60fps, while doing game logic and rendering simple background. With some decent graphic card you could do maybe like 50K simple sprites or particles, but 100K "characters" don't sound promising.

This is meant to be run on server, while showing only small part to frontend.
[/quote]

Then you don't have to render anything, to simulate 100k users on your server you need to either keep the simulation really simple or distribute the simulation across multiple physical machines. (Looking into distributed simulations is almost essential for any proper MMO project and is one of the biggest technical challenges that separate them from normal multiplayer games)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Is box2d scalable to 100000 characters? The problem with the engines out there including box2d is that they run a loop and in each loop check for collisions between objects. but if instead of checking for collision on each object in each loop if we calculate when the next collision for an object occurs using equations of motion then i think it will be the most efficient.

Is box2d scalable to 100000 characters? The problem with the engines out there including box2d is that they run a loop and in each loop check for collisions between objects. but if instead of checking for collision on each object in each loop if we calculate when the next collision for an object occurs using equations of motion then i think it will be the most efficient.


it really depends on what a character is, if it is just a box that you do collision detection on and nothing else then yes, Box2D should handle 100k of those unless you keep them all very close to eachother (But in that case you really don't need Box2D since detecting collisions between boxes is trivial), if you start adding in forces and actually use Box2D for what its meant for then it will most likely be far too slow for a game and there is no way around this, proper physics for 100k entities isn't really reasonable on todays hardware (Today this is solved by not doing any physic simulation at all for resting objects (objects tend to be put in a resting state if they havn't moved noticably for a few updates and are woken up again if a new force is applied to them or if the object they're resting against moves, this however doesn't work with characters as they tend to be constantly moving)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
physics engines use sleeping for dynamic objects. if most of them are sleeping it is not a problem.

on the other hand 100000 bodies means 100000 entities.
this means 100000 batches to renders all of them. i dont thing any cpu can handle that many render calls.
You need some awesome instancing method to keep batch count low.
even if you do so, say each character is 100 tris (low because of LOD), that is 10 million polygons, and you want 60fps?

i say: give up :)
You could easily do thousands of colliding instances if you implement some clever spatial partitioning. I've seen some grid based solutions used in physics engines that allowed for a lot of colliding objects . Also having hundreds of thousands of objects in a scene does not mean you have to render all of them. The trick is determining the potentially visible set, which you can do with a quad tree, bsp or whatever spatial partitioning technique best fits the job. You might want to look up some stuff on spatial partitioning too while you're at it.

EDIT: That quadtree collision video, top left corner says ~10,000 objects:



After watching this, I think you should re evaluate your need for that many entities... lol
Box2D doesn't implement a quad tree, or some other grouping technique?
Yes, Box2D does Spatial Hashing, I'm sure (chipmunk-physics does for sure, and you define the grid size). And, I'm sure Box2D handles sleeping objects (again, I know chipmunk-physics does).

So, it really depends on how you're setting up your environment, and how many objects are truly active, and how close the objects are to each other.

BTW, this question should really go onto the Box2D forums. They would be able to give you more detailed answers.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

This topic is closed to new replies.

Advertisement