Parts as static meshes
Everything else on these pages draws a document as one primitive: one component, however many parts, merged into a handful of draws. The Cadaclysm Static Mesh Actor does the opposite. It reads the same file and hands every part to the engine as an ordinary UStaticMeshComponent, the kind of actor everything in Unreal already understands. This page is about what that buys, what it costs, and how to tell which you want.
The same file, a component a part
Place a Cadaclysm Static Mesh Actor and call Load CAD File on it, or Load CAD File Async, exactly as on the Cadaclysm Actor. In C++:
#include "CadaclysmStaticMeshActor.h"
#include "CadaclysmLog.h"
ACadaclysmStaticMeshActor* Parts = GetWorld()->SpawnActor<ACadaclysmStaticMeshActor>();
Parts->bGenerateCollision = true; // a fitted body per part
Parts->bSimulatePhysics = false; // true lets every part fall
FString Error;
if (!Parts->Load("D:/models/platform.step", Error))
{
UE_LOG(LogCadaclysm, Error, TEXT("%s"), *Error);
}
Each distinct geometry becomes one UStaticMesh, and each placement of it one component pointing at that mesh: a bolt placed seventy-four times is built once and drawn by seventy-four components. The file’s colours are baked into the vertex colours and shown by the plugin’s material; set Material to draw every part with your own instead.
Get Part Components hands the components back, in the order the document draws its parts. From there they are yours, like any other component:
// One ordinary component per part, in the order the document draws them.
const TArray<UStaticMeshComponent*>& Components = Parts->GetParts();
for (UStaticMeshComponent* Part : Components)
{
Part->SetCustomDepthStencilValue(1);
Part->SetRenderCustomDepth(true);
}
UE_LOG(LogCadaclysm, Display, TEXT("%d parts share %d meshes"),
Components.Num(), Parts->GetSharedMeshCount());
Everything Unreal does with a component
A rigid body per part. With Generate Collision on, every part gets a fitted collision shape — a box, a sphere, a capsule or a convex hull, whichever fits best within Hull Triangle Budget — and Simulate Physics lets go of them. Without joints between them an assembly let go of this way falls into a heap, which is what a pile of unconnected parts does.
Ordinary components. A trace returns the component it hit. Each part can be moved, hidden, given a material, attached to something else or animated by anything that drives a component: Sequencer, physics constraints, your own code. In the editor every part is a row in the Details panel.
Culling and occlusion per part, by the engine, as for every other static mesh.
Nanite, optionally. Build Nanite encodes each part in the background and switches it to Nanite when its encode lands; nothing waits for it. It is there to put CAD parts inside a Nanite scene, with its virtual shadow maps, rather than to be faster, and it is still experimental: on some assemblies the Nanite geometry does not yet match the ordinary mesh exactly.
Everything the single primitive was for
Draw calls. A component is a draw, at least, so the merging that makes the Cadaclysm component fast is gone. Measured on an assembly of 7,867 parts and 35.4 million triangles, at 1280x720:
| Draws | Frame | |
|---|---|---|
| Cadaclysm component | 210 | 4.8 to 6.7 ms |
| Static Mesh Actor | 10,528 to 18,780 | 18 to 197 ms |
| Static Mesh Actor, Nanite | 224 | 10.5 to 11.2 ms |
The ranges span the camera from close up to eight framing distances away. Nanite turns the static meshes from unusable into reasonable here, but the single primitive is still about twice as fast.
Load time. Building a UStaticMesh is game-thread work. The same assembly took about 14 seconds as one component and about 128 as static meshes. r.Cadaclysm.NaniteOnlyMesh 1 builds the meshes straight into their render buffers and brings it down to 17 seconds, at the price of collision. Load CAD File Async reads and meshes on a worker and spreads the component building over frames (Milliseconds Per Frame), so a long load does not freeze the game, but it still takes as long.
Triangles fixed at load. Every part is drawn from the mesh made when the file was read, with one level of detail. There is no surface drawing, so a close-up shows facets the surface component would not, and no levels of detail sized for the view.
No edges or isocurves. The line renderer belongs to the Cadaclysm component. A static mesh has nothing to draw an outline with.
No document afterwards. The file is closed once the parts are built: no tree, no part names, no attributes, no queries and no Get Node Bounds. A component is identified by its place in Get Part Components, and nothing else.
No distance fields. A mesh built at run time has none, so Lumen’s software tracing and distance-field shadows and occlusion do not see these parts. Hardware ray tracing does. The Cadaclysm component builds a distance field of its own for the whole document.
Nothing is saved. The meshes are made at run time and live as long as the actor; the level stores the actor and the path, not the geometry. That is the same as the Cadaclysm component, and the opposite of importing.
Decide by what moves
| Your scene | Use |
|---|---|
| A model to look at, explore, colour, cut and pick from | Cadaclysm Actor, or the Surface Actor for close-ups. Fastest by far. |
| Mostly still, with some parts that fall or collide | Cadaclysm Part Bodies Actor: one drawn primitive, a rigid body per part. |
| Every part moving on its own, or parts handed to systems that expect static mesh components | Cadaclysm Static Mesh Actor. |
| Tens of thousands of parts | Not the Static Mesh Actor. Neither its load nor its draw calls scale that far. |
A part with its own transform cannot be merged anyway. Once every part of a document moves independently, the Cadaclysm component has lost the merging it exists for, and the static meshes give up nothing more. That is where this actor stops being the expensive option. Until then, start with the Cadaclysm Actor and move parts with Set Node Transform; see working with parts.