For the longest time I've been using my own hacked together 3D physics engine, but I've decided to let it go and finally move off to the Bullet API. I would like to convert a project over that I have working with my own engine to Bullet, but don't know what method would be best.
I have a large 3D tile based world, the geometry is non movable but it does dynamically change. The tiles can be solid, empty, or even have half spaces for slopes and such. Since the world is dynamic and because of angled tiles I am thinking that the best method inside of Bullet would be something like this...
Break the world into a grid of gtBvhTriangleMeshShapes that represent a cluster of tiles. The broad phase should be able to efficiently cull out these clusters, and most actual collisions would really only need to test one or two meshes at a time. Since the meshes are small, I would hope the speed of updating them dynamically would be fast enough. It would also be simple on my part, as I already have methods for generating the mesh which culls out any triangles being obscured by other tiles.
I feel bad about using triangle meshes, since at the base level all of my geometry is convex, but I have two concerns. First, I'm not sure if there is a better method to handle the angled tiles. Second, I'm also not sure if the Bullet API would be able to easily handle the "very" large number of static objects in the scene if I added them individually.
I appreciate any advice on this!
- Chase
New to Bullet, correct use of the API
-
- Posts: 43
- Joined: Mon Jan 03, 2011 4:26 pm
Re: New to Bullet, correct use of the API
If all your geometry is convex, I would look into Bullet's convex hull classes. They can't be any worse than triangle meshes.
Not sure how it handles large amounts of static objects, but since they are not moving, the broadphase might simplify it.
Not sure how it handles large amounts of static objects, but since they are not moving, the broadphase might simplify it.
-
- Posts: 8
- Joined: Tue Jan 18, 2011 7:14 pm
Re: New to Bullet, correct use of the API
http://bulletphysics.org/mediawiki-1.5. ... ion_Shapeslulzfish wrote:If all your geometry is convex, I would look into Bullet's convex hull classes. They can't be any worse than triangle meshes.
Not sure how it handles large amounts of static objects, but since they are not moving, the broadphase might simplify it.
In the wiki, it does say that using convex hulls are more efficient then triangle meshes which I would expect. Unless I'm mistaken, I believe that convex hulls are generalization of a point cloud... so I guess the question would be is that if I specified a 6 vert wedge, if it would correctly interpret the edges. I feel I may just need to experiment with it in code to find out.
If the convex hulls work, I guess the broad phase implementation would be the determining factor for using that method. In a 3d system the number of tiles could get to be unreasonable for both memory as well as computation, which is why I somewhat was leaning towards the sub-meshes of the world.
I appreciate your advice on this!
-
- Posts: 8
- Joined: Tue Jan 18, 2011 7:14 pm
Re: New to Bullet, correct use of the API
So after a day or two of fiddling I was able to find a method that will do what I want. Below are the methods I tried and why they did or didn't work.
A: Using convex shapes to build the world
This method is simple to understand, for each tile in the world I would use a collision block. Unfortunately the number of objects I needed support was to big for this method. With stress testing I was eating up insanely large amounts of memory just creating these objects. Also, as suspected the actual collision ran very slow due to the broadphase not really wanting to support 500,000 static objects in real time.
B: Creating chunked meshes
This method worked better then the first as expected, but it still wasn't good enough. If I started with a large scene it too way too long to optimize each BVH triangle mesh. The memory requirement was also an issue as I was eating up just below 2 gigs of memory.
C: Custom btConcaveShape to dynamically create triangles
Interestingly enough, this method was almost identical to how I handled it in my own engine. Instead of creating all of the geometry beforehand, I instead created a custom btConcaveShape which looked at the tile grid and generated the collideable triangles as needed. The method take zero pre-compute time, no extra memory and supports dynamic changes like a charm. This is the method I think I'm going to be sticking with for my situation.
Below is a forum post I found helpful in this search.
http://bulletphysics.org/Bullet/phpBB3/ ... 4954#18194
Screenshot of code in action!

A: Using convex shapes to build the world
This method is simple to understand, for each tile in the world I would use a collision block. Unfortunately the number of objects I needed support was to big for this method. With stress testing I was eating up insanely large amounts of memory just creating these objects. Also, as suspected the actual collision ran very slow due to the broadphase not really wanting to support 500,000 static objects in real time.
B: Creating chunked meshes
This method worked better then the first as expected, but it still wasn't good enough. If I started with a large scene it too way too long to optimize each BVH triangle mesh. The memory requirement was also an issue as I was eating up just below 2 gigs of memory.
C: Custom btConcaveShape to dynamically create triangles
Interestingly enough, this method was almost identical to how I handled it in my own engine. Instead of creating all of the geometry beforehand, I instead created a custom btConcaveShape which looked at the tile grid and generated the collideable triangles as needed. The method take zero pre-compute time, no extra memory and supports dynamic changes like a charm. This is the method I think I'm going to be sticking with for my situation.
Below is a forum post I found helpful in this search.
http://bulletphysics.org/Bullet/phpBB3/ ... 4954#18194
Screenshot of code in action!
