Scripting and API reference

Collider Painter can be driven from C++, Blueprint, Python and the console. The public API uses mesh-local centimetres. Core calculations take detached arrays; reading UObjects and changing collision happen on the game thread. Exact declarations are in each module’s Public folder.

Which module to depend on

  • ColliderPainterCore: geometry, fitters, decomposition, QA metrics. No editor dependency.
  • ColliderPainterRuntime: gameplay generation (Runtime module).
  • ColliderPainterEditor: authoring data, bake, recipes, skeletal and Geometry Collection tools, editor scripting. Editor modules only.

ColliderPainterGPU is an optional editor loader for the separately built CuACD library: no CUDA headers or static link reach gameplay code. CPCompat.h hides engine API differences between versions.

Core types

TypePurpose
FCPMeshData (CPTypes.h)Plain mesh snapshot: vertices, triangles, material, group and UV-island IDs, and persistent source mappings. Validates, extracts subsets and builds adjacency without UObjects, so it can be used on workers.
FCPShapeA box, sphere, capsule, cylinder or convex with transform, collision flags (CollisionEnabled, bContributeToMass) and owning hull ID. Box dimensions are full side lengths; capsule Length excludes the end caps; convex vertices are mesh-local with an identity transform.
FCPCollisionResultShapes, Error, Warnings, Notes, SolveSeconds, BackendUsed, bCancelled. IsSuccess() needs no error, not cancelled and at least one shape.
FCPFitSettings, FCPDecompositionSettingsFit and decomposition options (see settings).
FCPMeshAdapterGame-thread snapshot of Static Mesh or Dynamic Mesh geometry. A packaged Static Mesh needs retained CPU render data.
FCPFit::Fit, FitPointsFit a primitive or convex to selected vertices. A cylinder becomes a convex shape.
FCPDecomposition::GenerateClean a region, run the chosen backend and post-process the shapes. An empty region means all triangles.
FCPMeshPreprocessor::ProcessFinite and index checks, limited repair and a detailed report. Not volumetric remeshing.
FCPQuality::EvaluateSampled directional and symmetric surface error, overlap pairs, shape volumes and costs, walkable samples.

FCPCollisionResult separates Warnings (the result is usable but may not be what was asked for) from Notes (how it was produced: separate shells decomposed independently, the hull budget taking precedence over the concavity threshold, the backend chosen for navigation space, primitive counts). Notes never make a batch row a warning.

Decompose in C++

C++
#include "Decomposition/CPDecomposition.h"
#include "Geometry/CPMeshAdapter.h"

// Game thread: snapshot once; Mesh can then be moved to a worker.
FCPMeshData Mesh;
FString Error;
if (!FCPMeshAdapter::FromStaticMesh(Asset, Mesh, Error)) { /* report Error */ }

FCPDecompositionSettings Settings = FCPDecomposition::Preset(ECPQualityPreset::Balanced);
Settings.BackendName = TEXT("CoACD");
Settings.MaxHulls = 24;
Settings.MaxVertices = 64;

FCPCancelToken Cancellation;
Cancellation.SetTimeBudget(10.0);
FCPCollisionResult Result = FCPDecomposition::Generate(Mesh, {}, Settings, Cancellation);
// Check Result.IsSuccess(), Error, Warnings and BackendUsed before using Shapes.
  • Copies of a cancel token share its atomic cancel flag. Set a deadline before dispatching work.
  • Solver progress runs on the calling thread and is a coarse stage fraction, not a finish-time estimate. Do not touch UObjects from worker callbacks.
  • Cancellation returns no partial result. Third-party code and running CUDA kernels can delay the next checkpoint; PrepareSource and FCPMeshQuery::Build do not observe cancellation.

Backends

FCPBackendRegistry::Get().GetBackendIds(true) lists available runtime-safe backends. A backend reports its actual availability and runtime safety. Register your own ICPDecompositionBackend implementations, and unregister them before their owning module unloads. Inspect BackendUsed: do not infer what ran from the requested name.

CuACD is editor-only. It can retry CoACD on execution failure or a hull-budget mismatch, and meshes with disconnected source components use that CPU retry before CUDA runs, because the GPU search can omit separate solids. With CPU fallback disabled, those meshes return an explicit unsupported-input error.

Decomposition helpers

  • PrepareSource performs the region extraction and cleanup that Generate applies before any backend runs.
  • BuildNavigationClearance builds the walkable-clearance guard on the same cleaned source; FCPNavigationClearance::CountIntrusions and Validate check shapes against the sampled points.
  • OrientComponentsOutward reverses only closed, non-negligible parts whose volume is negative (a sealed cavity stays a cavity) and can return an FCPMeshComponents classification.
  • SetHullCountWarningThreshold / GetHullCountWarningThreshold: an advisory element count above which post-processing adds a warning (0 disables it; it never rejects a result). The editor setting feeds it.

Bake and authoring data (editor)

  • FCPBakeService::Bake(Asset, Result, bReplaceAll, Error) changes Static Mesh collision on the game thread. false keeps unrelated elements and replaces tracked ones; true replaces all simple collision. FCPBakeService::OnCollisionBaked reports completion. Save the asset through the normal editor workflow.
  • UCPAuthoringData::FindOrAdd attaches the editable definitions. Callers own transactions and Modify() when changing hulls. RefreshSource remaps source triangles and keeps stale samples; do not treat unmapped data as confirmed geometry.
  • UCPAuthoringData::CurrentSchemaVersion is 3. FCPHullDef::GetGeometrySource() returns Triangles when a hull has paint and ImportedShapes otherwise; Fit, Bake, Stats, QA, Merge, Split and Mirror all follow it. Loading older data splits hulls that held both, without deleting anything.

Skeletal and Geometry Collection libraries (editor)

FunctionPurpose
UCPSkeletalCollisionLibrary::CreatePhysicsAsset(Mesh, PackagePath, OutError)Creates an unsaved Physics Asset; never overwrites an existing object.
GenerateCharacterCollision(Mesh, Asset, Settings, OutError, OutWarnings)Generate Character from script, with FCPCharacterCollisionSettings (including BoneRules, BodySet, bLimitJointsByType, AngularDamping, bSeparateTwistBones).
FitBoneCollision(Mesh, Asset, BoneName, SourceTriangleIDs, Type, Settings, OutError, LOD)Fit one bone. Empty triangle IDs means all triangles the bone owns.
GetPhysicsAssetJoints(Asset)Every joint: child and parent bone, role, Swing 1, Swing 2, Twist (0 locked, −1 free) and Slide (cm).
UCPCollectionCollisionLibrary::GenerateCollectionCollision(Asset, Settings, OutError, OutWarnings)Per-piece collision for a Geometry Collection.
ApplyCollectionRecipe(Asset, Recipe, OutError, OutWarnings)Apply a collection recipe with per-piece overrides.

These calls keep synchronous return values, but their numerical work runs on detached worker data; interactive calls show cancellable progress while waiting. Before applying, the service re-reads source fingerprints, transforms and ownership and checks the target’s revision; a changed source or a missing target discards the pending result. FCPSkeletalCollisionService::BakeBodies takes optional bReplaceUntracked and OutRemovedElements; FCPCollectionCollisionService::BakePieces takes bReplaceExisting.

Recipes and batches (editor)

  • UCPEditorScriptingLibrary::ApplyRecipe and FCPRecipeRunner::Run block behind a cancellable progress dialog (none in a commandlet). Scripts, Blueprint and CPApplyRecipe use them.
  • Both they and the Content Browser’s background batch drive FCPRecipeBatch: a rolling pool of workers with each mesh’s snapshot, source check and bake on the game thread. Drive it with Tick() until it returns false; Cancel() reports meshes not started as not run; GetResults() returns one FCPBatchAssetResult per input mesh, in input order.
  • FCPRecipeRunner::Generate(MeshSnapshot, Steps) previews a list of steps without baking (example on Recipes).
  • UCPUCXLibrary imports UCX_/UBX_/USP_/UCP_ definitions and exports render and simple-collision geometry.

Driving the editors from Python

UCPEditorUILibrary (editor module) opens and drives the Collider Painter editors and the Level Editor mode from Python, Editor Utility Blueprints and the console. Every call runs the handler of the matching menu entry, toolbar button or hotkey, so a command that is disabled in the UI (a job or stroke running) is refused the same way, and every change is the same undoable transaction a click makes. Calls are game-thread only. Without an open editor, in a commandlet or with invalid arguments they log a warning to LogColliderPainterScripting and return false or an empty state.

Python
import unreal

lib = unreal.CPEditorUILibrary
mesh = unreal.load_asset("/Game/Props/SM_Rock")
lib.open_collider_painter_editor(mesh)
lib.run_static_mesh_editor_action(mesh, unreal.CPStaticEditorAction.ADD_HULL)
lib.run_static_mesh_editor_action(mesh, unreal.CPStaticEditorAction.SELECT_ALL)
lib.auto_decompose_active_hull(mesh, unreal.CPQualityPreset.BALANCED)
lib.wait_for_static_mesh_editor(mesh, 120.0)
state = lib.get_static_mesh_editor_state(mesh)
print(state.preview_element_count, state.status)
lib.run_static_mesh_editor_action(mesh, unreal.CPStaticEditorAction.BAKE)
Python (unreal.CPEditorUILibrary.…)Purpose
open_collider_painter_editor(asset), close_collider_painter_editor(asset), is_collider_painter_editor_open(asset), get_assets_with_open_editor(), can_close_editor_windows()Open or close the Static Mesh, Skeletal Mesh or Geometry Collection editor. Opening one that is already open brings it to the front.
set_collider_painter_mode_active(active), is_collider_painter_mode_active(), start_mode_tool(name), get_active_mode_tool()Level Editor mode and its tools (Paint, Select, Fit, Auto, Bake, QA). A tool starts on the editor’s next tick.
run_static_mesh_editor_action(mesh, action)CPStaticEditorAction: ADD_HULL, DELETE_HULL, DUPLICATE_HULL, SELECT_ALL, CLEAR_PAINTED_TRIANGLES, INVERT, GROW, SHRINK, FIT, FIT_ALL, AUTO, BAKE, QA, ACCEPT, CANCEL. Returns False when the handler had no effect.
set_active_hull(mesh, index), set_active_hull_type(mesh, type), auto_decompose_active_hull(mesh, preset)Hull List selection, type and preset.
set_selection_interaction(mesh, interaction), set_paint_enabled(mesh, on), set_brush_radius(mesh, cm)Paint and select modes (CPSelectionInteraction: BRUSH, TRIANGLE, CONNECTED, MATERIAL_SLOT, UV_ISLAND, POLYGROUP, BOX, LASSO).
set_static_mesh_editor_preview(mesh, preview, visible)CPEditorPreview: COLLISION, SOLID_COLLISION, PAINT_OVERLAY, DISTANCE_HEATMAP, WALKABLE_FACES, OVERLAP_PAIRS, HIDDEN_COLLISION.
paint_stroke_in_viewport(mesh, points, radius=0, ticks=0, erase=False), paint_stroke_in_viewport_over_time(...), paint_stroke_along_rays(...), get_last_paint_stroke_stats(mesh)Synthetic strokes through the viewport’s own path (points are normalised viewport coordinates), or along world-space rays (works headless), and their frame-time statistics.
is_static_mesh_editor_busy(mesh), wait_for_static_mesh_editor(mesh, timeout), get_static_mesh_editor_state(mesh)Wait for fits, QA and strokes; read the editor state.
run_context_editor_action(asset, action), select_context_region_by_name, select_context_region_by_index, set_context_editor_preview, is_context_editor_busy, wait_for_context_editor, get_context_editor_stateSkeletal and Geometry Collection editors (CPContextEditorAction: FIT, BAKE, GENERATE_ALL, SELECT_ALL, CLEAR_PAINT, RESET_PAINT, INVERT, GROW, SHRINK, CANCEL).
frame_static_mesh_editor_view, set_static_mesh_editor_camera, frame_context_editor_view, set_context_editor_camera, take_editor_screenshot(asset, filename, whole_window=True)Cameras and PNG screenshots of an editor window (not available without a renderer).

Console commands

CommandPurpose
cp.OpenEditor <ObjectPath>, cp.CloseEditor [ObjectPath]Open or close an editor.
cp.Mode on, cp.Mode off, cp.Tool <name>Level Editor mode and its tools (Paint, Select, Fit, Auto, Bake, QA).
cp.Editor [ObjectPath] <verb> [args]Drive the given editor, or the most recently opened one. cp.Editor help lists the verbs, for example add-hull, select-all, fit, auto [preset], bake, qa, radius <cm>, preview <name> on/off, wait [s], state, stats; and generate, select <name or index> for skeletal and fracture editors.
cp.Screenshot <File.png> [ObjectPath] [frames=N] [tab]Screenshot after N frames (default 2).
cp.PaintReplay x0 y0 x1 y1 seconds, cp.PaintProfile 1Developer diagnostics for brushing performance.

The CPApplyRecipe commandlet is described on Recipes.

Applies to Collider Painter 1.0.0. Report a problem with this page.

Esc

Type to search the documentation.

↑ ↓ moveEnter openEsc close