What does setWeldingDistance do in BulletTriangleMesh?

I thought this method had something to do with the borders between triangles, but comments on the Bullet forums seem to indicate it has to do with contact between the mesh and another body. Any ideas? enn0x, if you see this, my apologies for the barrage of questions. :slight_smile:

EDIT:
The source contains this comment:
“Welding threshold: distance between nearby vertices to be considered equal => set to 0.0 to disable welding test and speed up scene loading (ok if the mesh has no duplicates)”.

Apparently vertex welding is a kind of mesh simplification in which vertices closer than a certain threshold are combined by edge collapsing. I guess this is there to reduce the amount of collision geometry at the expense of scene loading time.

Right. It’s a common situation that modelling tools “duplicate” vertices. Both vertices are nearly at the same position, one one is used in the “left” triangle, the other in the “right” triangle (left and right are just to distinguish two adjacent triangles).

It’s not a problem with rendering. If the vertices are so close to each other that the distance is less than one pixel you won’t ever see it.

For physics this is a huge problem. Objects might pass through a mesh or you get “bumpy” behaviour if sliding over such a crack. So it is a good idea to “weld” such vertices together before creating the collision meshes. Most physics engines have this feature built-in.

By the way: modelling tool often provide this feature too, often called “welding”.