A different way to look at collision margins and understanding collision shapes, for everyone using Bullet physics engine (in any form on any platform)...
Hopefully this is also a useful tutorial and visual explanation of Bullet's collision margins. I also cover compound rigid bodies in this video and consider ways to really exploit collision margins.
YouTube: Bullet Physics Collision Margins and Shapes
UPDATE: I've posted some code below that contains a utility function to generate convex hull meshes extruded by a specified collision margin (and specified margin curve resolution).
Bullet Physics Collision Margins and Shapes
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Bullet Physics Collision Margins and Shapes
Last edited by RBD on Thu Jul 04, 2013 2:28 pm, edited 1 time in total.
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Bullet Physics Collision Margins and Shapes
Really amazing video
Thanks for sharing it
I'm not an expert Blender user at all, and it took me a while to understand that the .blend file works (and with runtime rendering!) on a plain Blender 2.66 version (and the performance is not at all bad even of my old graphic card!).
About the topic: it is really interesting (and it's impressive how quickly you can create meshes that match each Bullet collision shapes with arbitrary margin...).
I remember that by using the btMultiSphereShape, some time ago I was able to produce similiar results (I don't know if this shape is available in Blender, but it's basically a convex hull shape with a radius associated to each vertex: it's an underestimated collision shape IMO, but it's very powerful and can be further scaled in each direction).
However many things like rounded cylinders, cones and compund shapes can't be built using a btMultiSphereShape and the "collision margin tuning technique" you propose is extremely interesting indeed .
Thanks for sharing it
I'm not an expert Blender user at all, and it took me a while to understand that the .blend file works (and with runtime rendering!) on a plain Blender 2.66 version (and the performance is not at all bad even of my old graphic card!).
About the topic: it is really interesting (and it's impressive how quickly you can create meshes that match each Bullet collision shapes with arbitrary margin...).
I remember that by using the btMultiSphereShape, some time ago I was able to produce similiar results (I don't know if this shape is available in Blender, but it's basically a convex hull shape with a radius associated to each vertex: it's an underestimated collision shape IMO, but it's very powerful and can be further scaled in each direction).
However many things like rounded cylinders, cones and compund shapes can't be built using a btMultiSphereShape and the "collision margin tuning technique" you propose is extremely interesting indeed .
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Bullet Physics Collision Margins and Shapes
Thank you Flix.
Yes btMultiSphereShape does indeed seem to have a lot of potential uses (not exposed in Blender at this time).
I've had this feeling there might be a way to exploit (compound) btMultiSphereShape to do automated convex decomposition of high resolution subdivision surface / rounded / bevelled objects using a sphere packing algorithm (only using the outer spheres of convex spaces). Haven't tried attacking this problem.
Yes btMultiSphereShape does indeed seem to have a lot of potential uses (not exposed in Blender at this time).
I've had this feeling there might be a way to exploit (compound) btMultiSphereShape to do automated convex decomposition of high resolution subdivision surface / rounded / bevelled objects using a sphere packing algorithm (only using the outer spheres of convex spaces). Haven't tried attacking this problem.
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Bullet Physics Collision Margins and Shapes
Intersesting...
I hope Blender developers will add that shape in the future (even if they should probably find some spot to add the "radii" of the vertices).
And I hope that in the future they will add some way (or some addon) to create meshes that match the Bullet collision shapes (with arbitrary margins) automatically too.
Blender seems to be a great tool for Bullet users.
I hope Blender developers will add that shape in the future (even if they should probably find some spot to add the "radii" of the vertices).
And I hope that in the future they will add some way (or some addon) to create meshes that match the Bullet collision shapes (with arbitrary margins) automatically too.
Blender seems to be a great tool for Bullet users.
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Bullet Physics Collision Margins and Shapes
I guess I could do that at some point in the future... (with spring here, this indoor hobby will probably take a back seat. )Flix wrote:And I hope that in the future they will add some way (or some addon) to create meshes that match the Bullet collision shapes (with arbitrary margins) automatically too.
But yes, just needs a few more exposed tools... e.g.: Blender already has a convex hull mesh operator, and it actually calls Bullet's btConvexHullComputer, but unfortunately the margin shrink parameter was simply ignored. All that's needed is a simple call to Ole's btConvexHullComputer possibly followed by Erwin's GrahamScanConvexHull2D to consolidate left over co-planar faces (for Bmesh); these little things would be fairly straightforward to implement, but it still takes time and effort; I'll leave it to people making an income related to this to work it out.
-
- Posts: 456
- Joined: Tue Dec 25, 2007 1:06 pm
Re: Bullet Physics Collision Margins and Shapes
(computer activity in the open air might help, but it's definitely not the ideal outdoor hobby one can have ).RBD wrote: I guess I could do that at some point in the future... (with spring here, this indoor hobby will probably take a back seat. )
I agree with you about the rest of your post (I was simply making some general considerations in my previous post, I was obviously not expecting anything by your side: you're already doing a lot ).
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Bullet Physics Collision Margins and Shapes
I've received some inquiries about how I produced the extruded collision margin meshes for this video. So I'm posting some example code to produce these here.
The function I'm providing takes mesh vertices as input and will generate a convex hull mesh extruded by the specified collision margin (with specified margin curve resolution).
You can supply any convex hull vertices to this function, and just like in the video: if you supply one vertex you will get a sphere, if you supply two vertices you will get a capsule, etc..
For a cone primitive, of course, you would supply a circle of vertices at the base and one vertex at the tip; two circles for a cylinder, etc..
If you want a single compound non-convex mesh, you'll need to resort to your favourite CSG mesh tool to create a union of these.
See convexMarginMesh.h for instructions.
The function I'm providing takes mesh vertices as input and will generate a convex hull mesh extruded by the specified collision margin (with specified margin curve resolution).
You can supply any convex hull vertices to this function, and just like in the video: if you supply one vertex you will get a sphere, if you supply two vertices you will get a capsule, etc..
For a cone primitive, of course, you would supply a circle of vertices at the base and one vertex at the tip; two circles for a cylinder, etc..
If you want a single compound non-convex mesh, you'll need to resort to your favourite CSG mesh tool to create a union of these.
See convexMarginMesh.h for instructions.
You do not have the required permissions to view the files attached to this post.
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Bullet Physics Collision Margins and Shapes
Convex Hull Margin Blender add-on posted on Blender Artists forum in this thread: Round Cube: real Quadsphere, Capsule, Rounded Cuboid, 3D Grid + Convex Hull Margin
-
- Posts: 141
- Joined: Tue Sep 16, 2008 11:31 am
Re: Bullet Physics Collision Margins and Shapes
Convex Hull Margin Blender add-on updated for the latest Blender version (2.74) and attached here (for now).
This Blender add-on allows users to create an approximate convex hull mesh from any Blender object with an optional margin value used to shrink or expand the convex hull.
- Use a margin of 0 to get an approximate convex hull
- Use a negative margin to generate an approximate convex hull of the object less this collision margin: this convex hull can be used with the specified collision margin as a proxy for physics of the object.
- Use a positive margin to generate an approximate convex hull of the object plus a collision margin: this convex hull is an approximate visual representation the object plus a collision margin.
This Blender add-on allows users to create an approximate convex hull mesh from any Blender object with an optional margin value used to shrink or expand the convex hull.
- Use a margin of 0 to get an approximate convex hull
- Use a negative margin to generate an approximate convex hull of the object less this collision margin: this convex hull can be used with the specified collision margin as a proxy for physics of the object.
- Use a positive margin to generate an approximate convex hull of the object plus a collision margin: this convex hull is an approximate visual representation the object plus a collision margin.
You do not have the required permissions to view the files attached to this post.