Generating accurate CollisionComponent

Currently in an app I am working on, we are adding collision shapes/components to objects by using the ShapeResource.generateConvex method to generate the shape from the mesh of our ModelEntity. Unfortunately, this does not result in a totally accurate collision shape. The following example is how the collision component looks currently.

Is there anyway to generate a collision shape that fits the exact bounds of the ModelEntity?

In sceneKit, you can just build your physics shapes from other shapes when all else fails. So the couch collision shape could be explained with a few boxes using SCNPhysicsShape(shapes:. I don't think RealityKit has that yet. But I could be wrong.

The standard way to use a concave collision shape in RealityKit would be to use ShapeResource.generateStaticMesh. New in 2024, it's easier than ever to use generateStaticMesh by converting a MeshResource to a ShapeResource.

Another option is to define your Entity as a collection of simpler collision shapes. You can use multiple ShapeResource objects in a single CollisionComponent with CollisionComponent.shapes. Use ShapeResource.offsetBy to manipulate the pose of a ShapeResource.

Generating accurate CollisionComponent
 
 
Q