class MAGES::MeshDeformations::SimulationMeshSurface

Overview

Offline reconstruction of a SimulationMesh’s rendered boundary surface at rest pose. More…

class SimulationMeshSurface
{
public:
    // structs

    struct BoundarySurface;

    // methods

    static BoundarySurface BuildBoundarySurface(SimulationMesh simulationMesh);

    static float2[] GenerateWedgeUVs(
        SimulationMesh simulationMesh,
        float padding,
        out BoundarySurface surface,
        UvMappingMode mode = UvMappingMode.BoxProjection,
        float minCellUv = 0f,
        bool assumeHull = true,
        float chartAngleDegrees = AutoUV.DefaultChartAngleDegrees
    );
};

Detailed Documentation

Offline reconstruction of a SimulationMesh’s rendered boundary surface at rest pose.

This mirrors, on the CPU and without a PhysicsWorld /actor, the hull extraction performed at runtime by DynamicSoftbodyActor.RecreateFlatMeshJob.Execute. It flattens the volume constraints into a tetrahedron index array, welds coincident particles via MeshUtilities.FindTetrahedronNeighbors(in int[], Vector3[], float), and walks the four faces of every tet emitting a fully split triangle (three unique vertices) wherever the face has no neighbor (< 0) — the exact shape AutoUV consumes.

Lockstep contract: the per-face corner triples and wedge keys below must stay identical to RecreateFlatMeshJob.Execute (see DynamicSoftbodyActor.cs) and to WedgeUvLayout. A .tetuv sidecar written in the per-face-corner order (vc*12 + faceSlot*3 + cornerInFace, see WedgeUvLayout) drops straight into DynamicSoftbodyActor.tetCornerUVs only while the orderings match. If you change one, change the others.

At design time nothing is cut, so every volume constraint is treated as enabled and a face is a boundary face iff its neighbor slot is < 0 (the runtime job additionally drops faces whose neighbor tet has been disabled by a cut — irrelevant here).

Methods

static BoundarySurface BuildBoundarySurface(SimulationMesh simulationMesh)

Builds the rest-pose boundary surface of a SimulationMesh.

Parameters:

simulationMesh

The simulation mesh whose hull to reconstruct.

Returns:

The fully split boundary surface (see BoundarySurface).

static float2[] GenerateWedgeUVs(
    SimulationMesh simulationMesh,
    float padding,
    out BoundarySurface surface,
    UvMappingMode mode = UvMappingMode.BoxProjection,
    float minCellUv = 0f,
    bool assumeHull = true,
    float chartAngleDegrees = AutoUV.DefaultChartAngleDegrees
)

Generates a per-wedge UV atlas for a simulation mesh and scatters it into a tetCornerCount -length array ready to serialize as a .tetuv payload or load into DynamicSoftbodyActor.tetCornerUVs.

Parameters:

simulationMesh

The simulation mesh to unwrap.

padding

The inter-island/inter-cell gutter, in UV units (both modes).

surface

The reconstructed boundary surface used for the unwrap.

mode

Which generator to use. UvMappingMode.BoxProjection runs AutoUV; UvMappingMode.PerTriangleAtlas runs PerTriangleAtlas.

minCellUv

The PerTriangleAtlas minimum cell edge in UV units (ignored in box mode). The caller computes minCellTexels / resolution.

assumeHull

When true (default) every non-degenerate boundary triangle is unwrapped — the boundary surface is trusted as topological. When false an outward ray-cast culls faces judged buried (interior), which removes spurious internal faces a tetrahedralizer may leave behind but can drop real faces deep in concave pockets.

chartAngleDegrees

The UvMappingMode.BoxProjection chart cone half-angle in degrees (ignored in per-triangle mode). Larger grows bigger charts (fewer seams) at more stretch. See AutoUV.DefaultChartAngleDegrees.

Returns:

The per-corner UVs (see ScatterWedgeUVs).