Compound Shapes Questions

Post Reply
Jonathan
Posts: 36
Joined: Sun Feb 10, 2013 6:52 pm

Compound Shapes Questions

Post by Jonathan »

1) Do compound shapes have as much overhead as if each collider were a separate rigidbody? (I'm about to use Unity3D's implementation of PhysX as an example, but I am asking about how the Bullet physics engine handles this situation particularly.) A few weeks ago I was doing physics experiments in Unity3D (it uses the PhysX engine), and I noticed that my CPU was starting to choke on ~8,000 rigidbody cubes (just plain simple, primitive, cubes). Now that is an excessive amount of rigidbodies, understandably, but what is concerning is I then turned those 8,000 cubes into 80, but gave each of those 80 rigidbodies about 100 compound colliders (as cube shapes as well). When I ran the scene again, I was expecting to have ultra smooth performance as I thought I was mainly simulated 80 rigidbodies, but it crawled just as slow as when I had 8,000 individual rigidbody cubes. Maybe someone can explain if this is how all physics engines work or if there is just something odd about how Unity3D has implemented the PhysX engine? Also, I had run tests on the 80 rigidbody setup (with the 100 compound shapes) where they were all significantly separated as not to collide with each other, and it was STILL maxing the CPU. They were not asleep because they were falling under the influence of gravity, I'm just trying to simulate a lot of motion for my game. Would this situation run much faster if I were to use the Bullet physics engine?

2) Is there a visual method for piecing together compound shapes? Like in the situation of my previous example where you have maybe 100 compound colliders on a single rigidbody. Is there a known way to use a program like blender or something to visually encapsulate your object with many colliders and import that into bullet?

Thanks!
CireNeikual
Posts: 19
Joined: Thu Jun 28, 2012 5:06 pm

Re: Compound Shapes Questions

Post by CireNeikual »

I am no expert, so this may be completely wrong:

1) I don't think Bullet will be much faster. You still have the same number of bodies, and I do not believe it gets any cheaper to simulate them when constraints are added. If these bodies were combined into a single body without constraints (e.g. with a convex collision shape), then it might be faster.

2) Yes, you can use HACD to decompose meshes. For my game, I wrote a .obj loader, and fed that information to HACD and stored it in a custom file type ".phy". Once pre-generated, I can quickly load these shapes for use in the game. I used Blender to export the .obj files. I uploaded the program I made here: https://sourceforge.net/projects/objtoc ... rce=navbar. It isn't visual, but it doesn't need to be.
Post Reply