mesh shape offset (or width)

User avatar
orange
Posts: 6
Joined: Wed Aug 05, 2009 2:21 am
Location: Montreal

mesh shape offset (or width)

Post by orange »

I'm trying to reuse assets and code from a different Physics library, in which the triangle mesh shapes used for the environment have a "width", in fact all convex shapes in Havok have an extra radius (I used 0.05m).

Is there any way in Bullet to give my btBvhTriangleMeshShape/btRigidBody this extra width ?

For the other convex shape (capsule, etc), I can hack it buy simply increasing the radius at creation, but it's more complicated for triangle meshes.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: mesh shape offset (or width)

Post by Erwin Coumans »

This extra radius is called margin in Bullet. Its default value is 0.04 (4 centimeter if we assume meter units and default gravity). Note that some collision shapes embed the margins internally (box, sphere) so they don't increase in size. Other collision shape types apply this margin externally (convex hull, trimesh) so they grow a bit bigger.

This margin can be set for convex but also concave shapes. Have you tried triangleMesh->setMargin(newMargin) ?

For example, check out Bullet/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp

Code: Select all

//comment out the next line to read the BVH from disk (first run the demo once to create the BVH)
#define SERIALIZE_TO_DISK 1
#ifdef SERIALIZE_TO_DISK
        btVector3 aabbMin(-1000,-1000,-1000),aabbMax(1000,1000,1000);

        trimeshShape  = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,aabbMin,aabbMax);
///add an extra collision radius/margin to the trimesh
        trimeshShape->setMargin(0.05);
Hope this helps,
Erwin
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: mesh shape offset (or width)

Post by sparkprime »

Does a triangle after margin is applied have rounded edges and blunt points? Or does it extrude the triangle in the direction of the normals, maintaining the points and edges of the triangle.