Class GeometryGroupUtils
Provides helper methods used by geometry groups during mesh construction, including bone-weight normalization/limiting and blend-shape processing.
Namespace: TriLibCore.Geometries
Assembly: TriLibCore.Source.dll
Syntax
public static class GeometryGroupUtils
Methods
LimitBoneWeights(List<BoneWeight1>)
Limits the given bone weight list to at most 4 influences and normalizes the weights, returning a Unity BoneWeight structure.
Declaration
public static BoneWeight LimitBoneWeights(List<BoneWeight1> boneWeights1)
Parameters
| Type | Name | Description |
|---|---|---|
| List<BoneWeight1> | boneWeights1 | The list of raw bone weight entries for a vertex. |
Returns
| Type | Description |
|---|---|
| BoneWeight | A normalized BoneWeight with up to 4 influences. |
Remarks
The input list is sorted in-place (descending by weight). The top four influences are used. The selected weights are normalized so that their sum equals 1.
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown when the sum of weights is zero. |
LimitBoneWeights(BoneWeight1[], int, int)
Declaration
public static BoneWeight LimitBoneWeights(BoneWeight1[] boneWeights1, int start, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| BoneWeight1[] | boneWeights1 | |
| int | start | |
| int | count |
Returns
| Type | Description |
|---|---|
| BoneWeight |
LimitMaxBoneWeights(List<BoneWeight1>, List<BoneWeight1>)
Normalizes and appends all weights from weightsList into allWeightsList,
returning the number of weights appended as a Byte.
Declaration
public static byte LimitMaxBoneWeights(List<BoneWeight1> allWeightsList, List<BoneWeight1> weightsList)
Parameters
| Type | Name | Description |
|---|---|---|
| List<BoneWeight1> | allWeightsList | The output list receiving normalized weights. |
| List<BoneWeight1> | weightsList | The source list of weights for a vertex. |
Returns
| Type | Description |
|---|---|
| byte | The number of weights appended; returns 0 if the sum of weights is zero. |
Remarks
The input list is sorted in-place (descending by weight). All influences in weightsList
are normalized to sum to 1 and appended to allWeightsList.
LimitMaxBoneWeights(List<BoneWeight1>, BoneWeight1[], int, int)
Declaration
public static byte LimitMaxBoneWeights(List<BoneWeight1> allWeightsList, BoneWeight1[] weights, int start, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| List<BoneWeight1> | allWeightsList | |
| BoneWeight1[] | weights | |
| int | start | |
| int | count |
Returns
| Type | Description |
|---|---|
| byte |
ProcessBlendShapeKeys(AssetLoaderContext, CommonGeometryGroup, List<IBlendShapeKey>)
Adds blend shape frames to the target mesh using the provided blend shape keys.
Declaration
public static IEnumerable ProcessBlendShapeKeys(AssetLoaderContext assetLoaderContext, CommonGeometryGroup geometryGroup, List<IBlendShapeKey> blendShapeKeys)
Parameters
| Type | Name | Description |
|---|---|---|
| AssetLoaderContext | assetLoaderContext | The asset loader context and options. |
| CommonGeometryGroup | geometryGroup | The geometry group containing the base mesh data and the target mesh. |
| List<IBlendShapeKey> | blendShapeKeys | The blend shape keys to process. |
Returns
| Type | Description |
|---|---|
| IEnumerable | An enumerator used by the importer pipeline to schedule work across frames. |
Remarks
For each key, this method builds delta arrays for vertices (and optionally normals/tangents) and calls AddBlendShapeFrame(string, float, Vector3[], Vector3[], Vector3[]). This method is implemented as an iterator to allow yielding back to the main thread between frames.
TransferToBlendShape(IGeometryGroup, IGeometryGroup, IBlendShapeKey, IList<int>)
Transfers vertex deltas from geometryGroup into a blend shape key,
using baseGeometryGroup as the reference.
Declaration
public static void TransferToBlendShape(IGeometryGroup baseGeometryGroup, IGeometryGroup geometryGroup, IBlendShapeKey blendShapeKey, IList<int> originalVertexIndices)
Parameters
| Type | Name | Description |
|---|---|---|
| IGeometryGroup | baseGeometryGroup | The reference geometry group used as the base shape. |
| IGeometryGroup | geometryGroup | The geometry group containing the target (morphed) positions. |
| IBlendShapeKey | blendShapeKey | The blend shape key to populate. |
| IList<int> | originalVertexIndices | The original vertex index mapping for the base geometry. |
Remarks
This method populates Vertices with delta positions (blend shape position - base position) and creates an index map from original vertex indices to blend shape vertex indices. Existing blend shape buffers are disposed when supported.