FMeshCollisionGenerator
Turns render geometry into the authored primitives a mesh's collision setup stores. Everything here runs at AUTHOR time (the mesh editor's Generate buttons), never at body creation — the cook path consumes the result.
- Module
- Physics
- Header
#include "Physics/MeshCollisionBuild.h"- Namespace
Mowo
It lives in Physics because the hull reduction is Jolt's ConvexHullBuilder, and Jolt is private to the Physics image: its allocator globals exist once.
Public functions
| Returns | Name | Description |
|---|---|---|
FMeshCollisionPrimitive | FitBox | Tightest axis-aligned box / bounding sphere / capsule around the cloud. |
FMeshCollisionPrimitive | FitSphere | |
FMeshCollisionPrimitive | FitCapsule | |
FMeshCollisionPrimitive | BuildKDop | K-DOP: the cloud clipped by 10, 18 or 26 fixed direction pairs and returned as the resulting polytope's corners. |
bool | BuildConvexHull | One hull over the whole cloud, reduced to at most maxVertices. |
bool | Decompose | Approximate convex decomposition. |
float | MeasureConcavity | How far the mesh's own convex hull strays from the mesh, as a fraction of the hull radius: 0 for a convex mesh, and the size of the gap the hull would have filled in for a concave one. |
Function details
FitBox
static FMeshCollisionPrimitive FitBox(const std::vector<Vec3>& points)Tightest axis-aligned box / bounding sphere / capsule around the cloud. The capsule picks its axis from the cloud's longest extent and rotates onto it, because Jolt capsules are Y-major and a Z-major prop wrapped in an unrotated capsule is a sphere with the prop poking out of both ends.
FitSphere
static FMeshCollisionPrimitive FitSphere(const std::vector<Vec3>& points)FitCapsule
static FMeshCollisionPrimitive FitCapsule(const std::vector<Vec3>& points)BuildKDop
static FMeshCollisionPrimitive BuildKDop(const std::vector<Vec3>& points, int32_t dopDirections)K-DOP: the cloud clipped by 10, 18 or 26 fixed direction pairs and returned as the resulting polytope's corners. Circumscribed, so the result always contains the mesh — which is what a simple collider has to be, or a character walks through the wall it is standing against. Any other direction count is read as 26.
BuildConvexHull
static bool BuildConvexHull(const std::vector<Vec3>& points, int32_t maxVertices, FMeshCollisionPrimitive& out)One hull over the whole cloud, reduced to at most maxVertices.
Decompose
static bool Decompose(const std::vector<Vec3>& points, const std::vector<uint32_t>& indices, const FMeshDecompositionSettings& settings, std::vector<FMeshCollisionPrimitive>& out)Approximate convex decomposition. Splits the piece with the worst concavity first and stops on the settings' budget, so a shape that needs three hulls gets three rather than the ceiling.
MeasureConcavity
static float MeasureConcavity(const std::vector<Vec3>& points, const std::vector<uint32_t>& indices)How far the mesh's own convex hull strays from the mesh, as a fraction of the hull radius: 0 for a convex mesh, and the size of the gap the hull would have filled in for a concave one. It needs the triangles, not just the cloud — the inner corner of a flat L-prism is a hull vertex like any other, so nothing about the vertex set alone says the hull invented a face there.