There are so many collision shape classes, I've read about all of them and looked at some code but I'm still clueless about which ones to use. I thought if I write down what I've currently guessed then people can correct it where it's wrong and also fill in the gaps.
The following is a list of classes that can be used. There are other classes but they are abstract classes used to factor out common functionality and interfaces.
Primitives
(*) means there are additional specialisations to allow the vertical axis to be other than Y in model space.
Box: Specified by halfwidth/halfheight/halfdepth.
Sphere: Specified by radius.
Capsule: Specified by radius and height, useful for actor collisions. (*)
Cylinder: Very similar to above.
Cone: Specified by radius and height. (*)
EmptyShape: What is this for? Placeholder?
StaticPlane: Specified by normal and "constant". Don't use a "constant" of zero. Useful for ground. Does the plane have thickness?
Triangle: Specified by 3 points. Not sure this is very useful. Is it actually better than a singleton convex hull?
BU_Simplex1to4 (convex): Can create points, lines, triangles, and tetrahedrons. Probably the best option for a tetrahedron primitive. How do points/lines collide? Is there any reason for using the Triangle shape if you can make a triangle with this?
User-defined (static)
BvhTriangleMesh (concave): The most general shape, and the only one that allows arbitrary triangles. What happens if there are gaps?
HeightFieldTerrain (concave): Exactly what it says on the tin.
User-defined (dynamic)
MultiSphere (convex): Can create a capsule, a bevelled box, or maybe some vague egg shape. A single sphere is useful because it can have local scaling applied whereas btSphereShape cannot.
ConvexHull (convex): Specified by a cloud of points.
ConvexTriangleMesh (convex): Like ConvexHull but you give the triangles instead of the points. What's the point? What happens if there are gaps?
SoftBody (concave): I haven't bothered looking at this one but I thought I'd list it for completeness.
Compound/Derived
CompoundShape: Stick any other shapes together to form a concave shape. Is it best (for performance) to use a tree of compound shapes with primitives/meshes at the leaves, or one compound shape with everything at the first level?
UniformScaling: Take any other shape and apply a uniform scaling factor. Allows reuse of shapes, saving memory.
MinkowskiSum: I took a look at http://en.wikipedia.org/wiki/Minkowski_addition, this seems to allow you to make a new shape out of lots of clones (like a rubber stamp) of a single other shape. Maybe this is useful for fences/gates that are made out of "slats" of woods with gaps in them?
When to use what collision shapes?
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
When to use what collision shapes?
Last edited by sparkprime on Sun Jun 29, 2008 11:22 am, edited 1 time in total.
-
- Posts: 56
- Joined: Thu Jun 19, 2008 7:54 am
Re: When to use what collision shapes?
use for what?...but I'm still clueless about which ones to use.
i don't quite see a question there, if you said:
im doing pinball simulator, but I'm still clueless about which shape to use ...for the ball
- the answer would be: sphere
or
...but I'm still clueless about which shape to use ...for chair
- then answer could be: sphere, box, compound of 2 or 6 boxes... but if chair is not planned to move than its the best to include it as a part of static mesh - btBvhTriangleMeshShape, and even then you could use slightly different, more simple shape to approximate that object
- some things are better for some things while other things are better for some other things, but what is the thing you want to use this for?Triangle: Specified by 3 points. Not sure this is very useful. Is it actually better than a singleton convex hull?
- i believe the reasons for using any shape over any other shape is speed, so as long as you can get visually satisfactory results you want to go for the simplest/fastest solution possible...Is there any reason for using the Triangle shape if you can make a triangle with this?
- surely you see the point of a sphere shape to represent a ball in a pinball simulator, then what kind of shape to use for the flippers? ...gaps? best i can say is obvious:- wherever collision is "not defined" there will be no collisionConvexTriangleMesh (convex): Like ConvexHull but you give the triangles instead of the points. What's the point? What happens if there are gaps?
btw, i think you should listed proper and full names, eg. btConvexHullShape, btBvhTriangleMeshShape...
- thats right, and you want to put ALL of you static geometry in one big btBvhTriangleMeshShape... gaps, it will happen whatever you want it to happen, but the answer you were probably looking for is - your 'character' will "fall" through the "gaps"BvhTriangleMesh (concave): The most general shape, and the only one that allows arbitrary triangles. What happens if there are gaps? Apparently best suited for static geometry?
- possibly, to get more precise answers ask more concrete questions, eg. exactly what shape you are talking about and what are the other kind of shapes that will interact with it and how all they compare in size... and so onCompoundShape: Stick any other shapes together to form a concave shape. Apparently composing convex shapes with this is better than BvhTriangleMesh for dynamic objects. Is it best (for performance) to use a tree of compound shapes with primitives/meshes at the leaves?
beside, btBvhTriangleMeshShape can not be used as moving object, it can only be static, ie. have mass=0 to function properly
in short,
- for static background use btBvhTriangleMeshShape or btHeightfieldTerrainShape
- for dynamic/kinetic objects use spheres, boxes.. or some combination of basic shapes, the simpler the faster
does this answer?
cheers
Last edited by abaraba on Mon Jun 30, 2008 1:14 am, edited 20 times in total.
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: When to use what collision shapes?
To use in general...
I'm creating lots of things, I want a general idea of what's going on.
Well... I think I have a general idea but I want someone else to say "yes that is correct" before I waste a lot of time.
You have clarified one thing, for which I am grateful: Except for the CompoundShape, all the concave shapes are for static geometry only. Dynamic geometry must use CompoundShape if it is to be concave. I don't understand why but I can code around it.
The triangle thing - I may use it in various circumstances, what is the actual difference between them? When should I use either?
As for "I don't quite see a question there" -- there are lots of unanswered questions in the post, just search for the question marks!
I never intended to ask a specific question, I'm trying to answer more general questions, like why is there so much overlap within the different shapes and which class is preferred in the case of those overlaps.
I'm creating lots of things, I want a general idea of what's going on.
Well... I think I have a general idea but I want someone else to say "yes that is correct" before I waste a lot of time.
You have clarified one thing, for which I am grateful: Except for the CompoundShape, all the concave shapes are for static geometry only. Dynamic geometry must use CompoundShape if it is to be concave. I don't understand why but I can code around it.
The triangle thing - I may use it in various circumstances, what is the actual difference between them? When should I use either?
As for "I don't quite see a question there" -- there are lots of unanswered questions in the post, just search for the question marks!
I never intended to ask a specific question, I'm trying to answer more general questions, like why is there so much overlap within the different shapes and which class is preferred in the case of those overlaps.
-
- Posts: 56
- Joined: Thu Jun 19, 2008 7:54 am
Re: When to use what collision shapes?
that is correct, and if you are doing game-like simulation you would want to simplify as many of your concave moving objects by composing them from simpler convex geometry, or better yet approximate them with single convex shape, alternatively GIMPACT is the answer:You have clarified one thing, for which I am grateful: Except for the CompoundShape, all the concave shapes are for static geometry only. Dynamic geometry must use CompoundShape if it is to be concave. I don't understand why but I can code around it.
"but I want to use a dynamic concave trimesh"
http://www.bulletphysics.com/Bullet/php ... cave#p8374
cheers
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: When to use what collision shapes?
Heh, I didn't even know that GIMPACT existed, that's another option. I'll first look into that automatic algorithm for splitting the concave into convex, if that doesn't work out I'll try GIMPACT. Performance is the main consideration though so my guess would be btCompoundObject is better.
I assume it would not be hard to extend btCollisionWorld to have some kind of "compoundSweepTest" that just recursed over the compound structure calling convexSweetTest at the leaves. I need that to test if a spawned object intersects any existing objects.
I assume it would not be hard to extend btCollisionWorld to have some kind of "compoundSweepTest" that just recursed over the compound structure calling convexSweetTest at the leaves. I need that to test if a spawned object intersects any existing objects.
-
- Posts: 508
- Joined: Fri May 30, 2008 2:51 am
- Location: Ossining, New York
Re: When to use what collision shapes?
I've just noticed that MinkowskiSumShape and UnformScalingShape are both convex. This means I was completely wrong about it, and I can't imagine where MinkowskiSumShape is useful anymore. Also does UniformScalingShape have to wrap a convex object too then? Or does it convert from concave to convex. I don't see why it needs to be restricted to convex, surely it can just translate/etc whatever ray/shape is being tested for collision and invoke the wrapped shape's test? I would have thought it should be beside CompoundShape in the hierarchy.