Newbie question - Manual management of islands?

Chaster
Posts: 19
Joined: Mon Oct 01, 2007 7:24 pm

Newbie question - Manual management of islands?

Post by Chaster »

Hello,

I recently started using Bullet in my game application (actually, since I'm using Ogre3D rendering engine, I use OgreBullet, which is a wrapper for Bullet to use with Ogre). So far, all is going well. However, I have some questions which I am hoping people can answer:

First, my scene is already divided into "zones" which are connected by portals (if you are familiar with Portal style graphics engines, this is the same). Since I am already paritioning the world objects into these zones, I was hoping that I would be able to use this information to separate my simulation into zones (to increase performance). Basically, since I know what zones an object is intersecting, I can cut down the collision checks by a huge amount. So, I am wondering if Bullet allows me to create simulation islands and add/remove objects to the islands manually. Also, can objects exist in two different islands simultaneously (for objects which are touching a portal and therefore touching 2 (or more) zones at once)..?

I know that Bullet has a simulation island manager, but it seems that it is automatically populated during the broadphase collision sweep. Should I make multiple dynamics worlds (one for each "zone" in my game engine)? Can objects exist in multiple dynamics world simultaneously?

I know this isn't a very good description of what I am trying to do, but if someone understands, any pointers would be greatly appreciated.

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

Re: Newbie question - Manual management of islands?

Post by Erwin Coumans »

Chaster wrote: First, my scene is already divided into "zones" which are connected by portals (if you are familiar with Portal style graphics engines, this is the same). Since I am already paritioning the world objects into these zones, I was hoping that I would be able to use this information to separate my simulation into zones (to increase performance). Basically, since I know what zones an object is intersecting, I can cut down the collision checks by a huge amount. So, I am wondering if Bullet allows me to create simulation islands and add/remove objects to the islands manually. Also, can objects exist in two different islands simultaneously (for objects which are touching a portal and therefore touching 2 (or more) zones at once)..?
The simulation islands are only used for the physics simulation and object activation/deactivation. It is not used in the collision detection (yet). Objects are in the same simulation island if they are 'close' or if they share a physics constraint. 'Close' could be sharing a contact constraint, but we use AABB bounding box overlap to determine 'close'. I doubt that the actual island management is a bottleneck. Usually the collision detection narrowphase (contact generation) and constraint solver are the bottlenecks.

How many objects are in each zone?

There is one optimization for the broadphase collision detection, but usually this only helps when you have an extreme large amount of objects in the broadphase. Currently the new Multi SAP broadphase is work in progress (unfinished). This would allow to add each 'zone' in its own broadphase. It is allowed for an object to be in multiple broadphase in the Multi SAP. But as I mentioned, it doesn't work yet, but if you are interested and you have many objects, this could be an area to look into.

Is the Bullet performance a bottleneck at the moment? If it is slow, could you try profiling it, and see which parts are slow? Some general performance tip: merge small static triangle meshes into a one bigger one. And make sure to use the btBvhTriangleMeshShape, with compression enabled.

Do you use the latest Bullet 2.62?

Thanks a lot,
Erwin
Chaster
Posts: 19
Joined: Mon Oct 01, 2007 7:24 pm

Re: Newbie question - Manual management of islands?

Post by Chaster »

Hello Erwin,

Thanks for the quick response. To answer your questions:

1) This is early phase development, but our world could have on the order of high hundreds to low thousands of simulated objects. This seems to me to be a fairly heavy number of objects to be collision checking..

2) Each zone would have much less objects - anywhere from a handful to dozens to low hundreds.

3) right now, bullet performance is great! But since we're quite early in the development, we haven't stressed it at all. Just a few dozen objects, and the scene complexity is very low (compared to what it will be in the final product). We plan to have many agents running around on complex terrain, inside buildings, and inside of large kinematic interior settings (moving ships!), all happening simultaneously with hundreds (maybe even over a thousand) rigid bodies.... So while I can't say that Bullet is the bottleneck now, I am anticipating that it WILL become one if I just use naive implementation with the number of bodies we are simulating... Of course, this is the plan... reality may take us on a different course..

The Multi-SAP sounds like it is intended to do what I am wanting to do. I guess I could take a look into it, but I am pessimistic about my ability to add anything of significance - I am a physics neophyte and it would be like asking a first year medical student to perform brain surgery... heh.

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

Re: Newbie question - Manual management of islands?

Post by Erwin Coumans »

Chaster wrote: 1) This is early phase development, but our world could have on the order of high hundreds to low thousands of simulated objects. This seems to me to be a fairly heavy number of objects to be collision checking..
2) Each zone would have much less objects - anywhere from a handful to dozens to low hundreds.
3) right now, bullet performance is great! But since we're quite early in the development, we haven't stressed it at all.
I wouldn't worry too early. Bullet has a very advanced 3D broadphase to efficiently find the limited set of potential overlapping pairs. The btAxisSweep3 broadphase is almost on par with Havok and Ageia for this, so it can handle ten thousands of objects with no problem. It is still better to reduce the amount of objects in the broadphase. The best way of doing this is to make sure to merge lots of static (never moving) triangle mesh objects into fewer btBvhTriangleMeshShape. A single static btBvhTriangleMeshShape can easily contain from 1000 triangles to a million triangles...

Sooner or later it can happen that Bullet doesn't perform as well as you want or expect. In that case please report it in the forum, with some profiling if possible.

Hope this helps,
Erwin
Chaster
Posts: 19
Joined: Mon Oct 01, 2007 7:24 pm

Re: Newbie question - Manual management of islands?

Post by Chaster »

Okay, I will just keep going "as is" until I run into a problem. Thanks Erwin. Naturally, if I run into a problem, I will do my best to provide all the info needed to make improvements. =)

Cheers!