Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Supporting 100000 objects in box2d


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 driuha   Members   -  Reputation: 126

Like
0Likes
Like

Posted 19 June 2012 - 06:14 AM

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!

Sponsor:

#2 AzureBlaze   Members   -  Reputation: 1402

Like
3Likes
Like

Posted 19 June 2012 - 07:00 AM

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?

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?

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.

#3 driuha   Members   -  Reputation: 126

Like
0Likes
Like

Posted 19 June 2012 - 08:03 AM

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.

#4 SimonForsman   Crossbones+   -  Reputation: 6318

Like
1Likes
Like

Posted 19 June 2012 - 08:53 AM


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.


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)
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!

#5 driuha   Members   -  Reputation: 126

Like
0Likes
Like

Posted 19 June 2012 - 01:20 PM

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.

#6 SimonForsman   Crossbones+   -  Reputation: 6318

Like
1Likes
Like

Posted 19 June 2012 - 02:25 PM

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)
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!

#7 saejox   Members   -  Reputation: 714

Like
1Likes
Like

Posted 19 June 2012 - 02:31 PM

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 :)

#8 M6dEEp   Members   -  Reputation: 897

Like
1Likes
Like

Posted 20 June 2012 - 12:31 AM

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

Edited by M6dEEp, 20 June 2012 - 12:59 AM.


#9 wolfscaptain   Members   -  Reputation: 200

Like
1Likes
Like

Posted 20 June 2012 - 10:55 AM

Box2D doesn't implement a quad tree, or some other grouping technique?

#10 BeerNutts   Crossbones+   -  Reputation: 3017

Like
1Likes
Like

Posted 20 June 2012 - 11:05 AM

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)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS