Sign in to follow this  
bmarci

Physics and huge game worlds

Recommended Posts

bmarci    786

Hi,

 

Did any of you used Bullet in huge game maps?

 

I'd say loading all the 100.000 objects and feeding them into the physics engine is not an option.

First I'd go for dynamicaly load/add collision shapes within a certain radius of the player and remove them when they are out of "interest".

So the question is;

How rapid modification (add/remove) of the physics world affects the performance, and what about memory fragmentation?

Is it advised to implement some self made memory manager for this, or does the bullet handle it fine?

Also btBvhTriangleMeshShape takes some time to build the hierarchy, so  serialize or not to serialize??

 

thanks for any help smile.png

Edited by bmarci

Share this post


Link to post
Share on other sites
xexuxjy    1477

Adding / removing objects to bullet should be pretty quick, and the bullet broadphase would minimise any unnecessary collision tests, especially if most of the objects in the sim are static. Having said that, having all that collision data around in memory may not be that useful if the only things you ever test are near to the player.

You might also want to consider keeping a portion of the collision shapes/ rigid bodies available in memory even if they're not part of the simulation world , maybe creating the serialised versions of the collision shapes as part of a build rather than run-time step.

In terms of memory usage , it will depend a bit on which broadphase you use, AxisSweep will allocate a large block of memory base on what you set it up (maxHandles) , Dbvt has a freelist for nodes it creates so neither should thrash / fragment memory particularly.

Share this post


Link to post
Share on other sites
Krohm    5030

As an aside, Havok deals with that kind of problem with their concept of Islands.  I'm guessing Bullet doesn't have a similar built in structure? 

It does, but sadly, it doesn't expose them at library level.

 


Also btBvhTriangleMeshShape takes some time to build the hierarchy, so  serialize or not to serialize??
Do not serialize, do not use. Performance is terrible to start with and I cannot understand why so many people go for it.

Share this post


Link to post
Share on other sites
Dawoodoz    461

 

As an aside, Havok deals with that kind of problem with their concept of Islands.  I'm guessing Bullet doesn't have a similar built in structure? 

It does, but sadly, it doesn't expose them at library level.

 

 

 


Also btBvhTriangleMeshShape takes some time to build the hierarchy, so  serialize or not to serialize??
Do not serialize, do not use. Performance is terrible to start with and I cannot understand why so many people go for it.

 

 

The main problem is that small items will get stuck if the collision shape has no volume. I only use triangles in heightmaps and then I can't have small items in the game. Most shapes are easy to make a convex decomposition of manually.

Edited by Dawoodoz

Share this post


Link to post
Share on other sites
Krohm    5030

Performance is bad because the algorithm cannot make any assumption about the collision data. This is not the case for other collision shapes, which also have a fully parametric representation.

I am currently using proxy hulls for everything (hand made). This is standard about now albeit we could discuss on the amount of automation.

Share this post


Link to post
Share on other sites
bmarci    786

Do not serialize, do not use. Performance is terrible to start with and I cannot understand why so many people go for it.

 

I agree with the first part, I always have the creeps saving 3rd party library's binary data into the content.

Again, I made some timing with the BVH mesh and I'm not convinced not to use it.

I loaded a test scene consisting of ~40.000 polys, as a single collision shape.

The bvh generation took about 60-70 ms. And dropping  150-200 convex hull bodies and some basic primitives (all of them using CCD) was running with acceptable speed (over 60fps).

So, at first I'd say: "Vincent, we happy" :D

 

Here is a test of 520 convex hull bodies:

https://www.youtube.com/watch?v=dDL5oHoHzzY

It slows a bit down at the end, maybe because of the 600.000 polys on my IntelHD someting smile.png

 

 

Is there any (good) algorithm to generate low poly concave hull? (not mesh simplification)

Edited by bmarci

Share this post


Link to post
Share on other sites
Krohm    5030


acceptable speed (over 60fps).
This conveys no information at all. What processor are you running and how high is it clocking while running?

I did my tests on low-end hardware, where you can measure the difference in the first place and I can tell the difference in my case. With 10 spherical sweeps per frame, the performance hits about 15fps with the trimesh while it was in the realm of playability (not smoothness) with the basic hulls.

But don't take my word for granted, check out how AAA games do it in UDK (scroll to end of page).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this