How to approach implementing voxel-based physics objects?

I’m attempting to build a simple game prototype where you can build vehicles and other contraptions out of blocks in a 3D grid (voxels, but really big ones) - if you know Avorion or Stormworks - exactly something like that.

The main challenge that I’m struggling with when trying to execute this in UE4 is physics. There are so many approaches to this, and every time I seem to hit a major obstacle. So here’s what I tried:

  1. Just using an Instanced Mesh is impossible because Simulate Physics is not available on it
  2. Putting an Instanced Mesh as a child of a Static Mesh (to be able to enable Simulate Physics)
  3. The Static Mesh must be set to something, which is not very optimal (maybe there’s a better “root” component for a case like this?)
  4. Only the Static Mesh collider seems to react to Impulses (shooting with a projectile from the FPS template). Instanced Mesh colliders don’t react when acted upon.
  5. Center of Mass seems to be miscalculated
  6. Putting an Instanced Mesh without collisions enabled (just for rendering) and creating a Static Mesh with collisions set up for each cell and a root Static Mesh with Simulate Physics enabled
  7. Actually works fine frame-to-frame, but when I try to build this thing I get an O(n^2) situation where each additional cell increases the build lag by an increasing amount of time
  8. I’ve managed to narrow this down to an issue with “Welding” (see Imgur: The magic of the Internet ). At 1000-th Static Mesh component (with 999 existing already) I get a 500ms frame time (FilterUpdate in Physics is the culprit apparently). After it’s constructed the game works just fine at regular ~100 FPS.
  9. Tried to add a single Mesh per cell per tick. This revealed that the lag issue is actually minor when a few meshes are added initially, but with each instance existing it gets worse and worse (hence O(n^2)).
  10. Tried to replace Static Meshes of the cells with Box Collision components, but that had issues with Impulses too
  11. The issue does not happen if Simulate Physics is disabled on the root. The object is created very quickly, even at 1000 voxels.

Some more details on how it works in runtime:

  1. A “description” of a contraption is set on the component - an array of vectors defining where a cube should be put in a grid
  2. On the first tick the Instanced Mesh creates it’s instances, this is super fast
  3. Create and attach a Static Mesh component for each instance, set visibility to hidden (later changed to: create an array of static meshes to create and on each Tick create one of the meshes)
  4. When running the game there’s a few seconds of a lag while the object is built. After exiting the game there’s a few seconds of a lag too.

The goal is basically to be able to build a physics object out of voxels and to be able to properly interact with it in terms of Physics and collisions. I’d go with my current solution, but the n^2 issue when building the thing one voxel at a time per tick is a huge no-go.

Any ideas on how to approach this?