CSG operations on static meshes

Hi everyone,

We are currently developing a volumetric soft-body physics engine and one of the things we want to implement is to use a volume to select a portion of a static mesh, remove the overlapping volume, and replace it with our soft actor.
Brushes offer the functionality that we need (subtraction to be specific), but this does not work with static meshes since they are, as they are called, static. For normal assets, one would use an external modeling tool to edit the static mesh as needed, but we want to do this in the editor (not necessarily at run-time).

As we see it, there are two ways to do this:

  • Visually - use the geometry shader to hide the polygons that overlap with the volume. This should be doable if the volume is simple like a box, but it would be hard if the volume itself is also a static mesh.
  • Modify the mesh - reuse/modify the existing BSP/CSG code or implement it as a plugin.

What would be the easiest way to achieve this? Has someone done this before?

You could convert the static meshes to BSP and do CSG on them there. However, that won’t necessarily be robust because BSP is required to be “airtight” (a seamless solid manifold) and static meshes aren’t so constrained.

There is some research on implementing CSG purely at render-time, for example: However, this doesn’t provide a solution for collision-detection and other expected features of a CSG system.

In general, this is very tricky, leading-edge stuff.