11. Shapes

Video tutorial about Rigid Bodies and Shapes.

Try out the BodiesAndShapes level, included in the Tutorial Hallways Demo Project

The Bodies And Shapes level of the Tutorial Hallways demo project.

The Bodies And Shapes level of the Tutorial Hallways demo project.

11.1. Primitive Shapes

Primitive Shapes.

Primitive Shapes.

The primitive shapes: Box, Sphere, Cylinder and Capsule are Shapes that offer good simulation performance, making them a good choice as collision shapes.

11.2. Trimesh Shape

A Trimesh Shape is a collision Shape represented by a collection of triangles. The triangles are read from an Unreal Engine Static Mesh, either via a Static Mesh Component or by referencing a Static Mesh asset.

On Linux it is currently required to enable General Settings > Advanced > Allow CPU Access on the Static Mesh asset for it to be usable with a Trimesh Shape in cooked builds.

11.3. Collision Groups

Collision Groups can be used to disable collision between specific Shapes. Doing this can increase the performance of the physics engine since no collision detection needs to be done for those Shapes.

Collision Groups are assigned to Shapes and disabling collisions between specific groups are done using the Collision Group Disabler Component.

A common usage is using Collision Groups to disable self-collision between Shapes belonging to the same model that are known to never collide with each other.

Below is an example of using Collision Groups to disable collision between the tire Shapes and the rear body Shape of a wheel loader model. By doing this, no broad phase collision detection needs to be done by the physics engine for those Shapes.

First, we add a Collision Group “Tire” to the tire Shape.

Adding a Collision Group to the tire Shape.

Adding a Collision Group to the tire Shape.

Notice that a Collision Group can be added to multiple Shapes, here we would likely want to add the “Tire” group to all tire Shapes. Next, we add a Collision Group “RearBody” to the rear body Shape.

Adding a Collision Group to the rear body Shape.

Adding a Collision Group to the rear body Shape.

At this point, we have added Collision Groups to both the tire and rear body Shapes, but they will still be able to collide with each other. We need to tell AGX Dynamics that we want to disable collision between these Collision Groups. This is done using the Collision Group Disabler:

Disabling collision between the Tire and RearBody Collision Groups.

Disabling collision between the Tire and RearBody Collision Groups.

First, we select the group pairs we want to disable collision for (1). Next, we press the Disable Collision button (2). And finally, we can see that the two groups show up in the list of disabled Collision Groups.

As long as the Collision Group Disabler Component is in the Level once we press Play, the Collision Group Disabler will automatically register their disabled Collision Groups with AGX Dynamics. Having multiple Collision Group Disabler Components in a level is supported, but disabling the same Collision Group pars in multiple Collision Group Disabler Components should be avoided.

11.4. Auto-fit

Auto-fit is a feature that automatically positions and resizes a Shape to fit an Unreal Static Mesh as closely as possible. This is useful for example when adding primitive collision Shapes to Unreal meshes. The figure below shows a typical work-flow.

  1. Add a primitive Shape as a child or parent to an Unreal Static Mesh.

  2. In the Details panel, set Mesh Location under the AGX Shape Auto-fit category according to where the Static Mesh is relative to the Shape.

  3. Press the “Auto-fit” button. The Shape will change its size and transform to fit the Mesh.

  4. In the Rendering category in the Details panel of the Shape, make the Shape invisible.

Auto fit.

Auto-fit a Cylinder Shape to a tire Mesh.

Auto-fit can also be done to several Static Meshes by having them as children to the Shape and selecting All Children as the Mesh Location.

Auto-fit is currently supported for Box, Cylinder and Capsule.

11.5. Additional Unreal Collisions

Note

This feature makes primitive AGX Shapes “visible” to the Unreal physics engine, but not the other way around, i.e. AGX Dynamics is not affected by Unreals’ physics. No guarantee is given regarding the dynamic bahavior between AGX Shapes and Unreal physics objects. It is recommended to match the Unreal framerate and the AGX Dynamics time step when utilizing this, see Frame Jittering for instructions.

Unreal Cube falling on an AGX Sphere.

Each primitive AGX Shape can be configured to carry additional collision information, so that Unreals’ built in physics engine “sees” them. This can be useful to enable e.g. LineTrace against primitive AGX Shapes (enabled by default), or let an Unreal body collide with AGX Shapes, for example to use as a blocking volume.

This can be controlled for all AGX Shapes in Plugin Settings, or on individual AGX Shapes from the Details Panel.

Enabling additional Unreal collision for all AGX Shapes.

Enabling additional Unreal collision for all AGX Shapes in plugin settings.

Enabling additional Unreal collision for an individual AGX Shape.

Enabling additional Unreal collision for an individual AGX Shape.