Page MenuHome

Add compound shape for rigid body simulation
Needs ReviewPublic

Authored by David Vogel (Dadido3) on Sep 14 2019, 7:43 PM.

Details

Summary

This patch adds a new entry to the shape selection dropdown. It also corrects wrong inertia calculation for convex hulls, that resulted in strange behavior for small objects.

Compound shape

With the help of this new shape it's possible to build concave shapes out of other primitive shapes. Because most primitive shapes are much more stable than the "Mesh" shape (Which was the only option to create concave collision shapes for now), it's possible to create create more complex simulations. Furthermore, it's possible to exploit the margin, and simplify collision meshes to speed up simulations.

To use this feature a rigid body object's shape has to be set to "Compound Parent". When this shape is used, all direct children shapes will be added to the compound shape of the parent automatically.

The weight and other settings will be ignored, only the shape and margin settings of children are used. Mass, center of mass and other physical properties are determined by the parent object.

The inertia of the compound will be approximated with the bounding box that encloses all child bounding boxes. By default, bullet adds the margin of the parent to that bounding box, best is to enable "Collision Margin" and set it to 0. (That's something that needs to be improved, similar to the other shapes, where it's not clear to the user, if the margin is embedded into the shape or added)

Compound example #1

About 700 concave objects with a length of 3cm each.

Compound example #2

Chains with compound shapes made out of several single edge convex hulls. Each of the 42 chain elements has a length of about 11cm. The simulation runs in realtime. (Remove the baked data, if you want to test the simulation speed)

Inertia fix for convex hulls

Depending on the settings, and if the margin was embedded into the convex hull, it was calculated wrongly.

In the worst case the margin was added to each side of the bounding box. And later when approximating inertia from the bounding box it was added again. Now the bounding box dimensions and inertia of a cube is equal, no matter if the "Cube" or "Convex Hull" is used as shape.

Diff Detail

Repository
rB Blender