Color legend method
How folded the sheet is, against how folded it rests: cloth held bent by something pressing on it rests flat, while creased cloth rests bent, because the plasticity model has set its folds.
A static class, in the namespace BorrowedTorch.FabricSimulator.Diagnostics. It measures every fold with the solver’s own fold arithmetic, from the array of FabricEffect.ReadBack alone: the live angle from the positions, the rest angle from RestAngles. A fold of 0° is flat and one of 180° folded back onto itself. It allocates: a debugging tool, not frame work. The diagnostics page shows it in context, with code.
Names are colored by what they are: a method; values and fields keep the plain color.
Fields
SharpFoldDegrees →
float · Constant, 25. How far from flat a fold must rest, in degrees, to count as a crease in Result.CreasedEdges.
Methods
Run() →
Run(FabricParticle[] particles, int width, int height, uint[] tearState = null) · Static. Returns CreaseCheck.Result: the live and rest folds over every fold of the sheet, three per point where the grid has room for them, across, down and diagonal. Folds a rip has killed span its gap and are skipped, as the solver skips them, and so are folds with a corner that isn’t finite. Returns all zeros for an empty array or a sheet with no folds. Throws ArgumentNullException for a null array, and ArgumentException when width × height isn’t the array’s length, or when the tear state’s length isn’t.
| Parameter | Type | Description |
|---|---|---|
particles |
FabricParticle[] |
The array from FabricEffect.ReadBack: fetch it once for every check you run. |
width |
int |
The grid width the sheet was built with, Fabric.WidthInParticles. |
height |
int |
The grid height it was built with, Fabric.HeightInParticles. |
tearState |
uint[] |
Fabric.CopyTearState on a torn sheet, so the dead folds are left out; null, the default, for a sheet never torn. |