How to combine intersecting static meshes into a single mesh using c++?

I’m developing a spider locomotion system in Unreal Engine that functions similar to Navmesh but allows movement on all surfaces (walls, ceilings, etc.). The player actor’s rotation and gravity align with the surface it’s on. To achieve this, I’m creating an actor that:

  1. Scans all non-player static meshes in a level.
  2. Detects intersections and creates connections between the vertices of intersecting meshes.
  3. Combines these intersecting static meshes into a single mesh.

I’m stuck on step 3. How can I programmatically combine static meshes in C++? Are there specific APIs or workflows I should follow? Additionally, here’s my code for drawing debug lines between vertices of different meshes. How can I turn these connections into faces and merge the meshes?