class MAGES::MeshDeformations::Editor::CutActionVolumeSelectionMath

Overview

Pure, side-effect-free helpers for the Cut Action volume selection tool. Extracted from CutActionVolumeSelectionTool so the geometry/selection logic can be unit-tested without a live scene, camera, or simulation mesh. More…

class CutActionVolumeSelectionMath
{
public:
    // methods

    static float3 TetrahedronCentroid(float3 a, float3 b, float3 c, float3 d);

    static void SelectNearest(
        IReadOnlyList centroids,
        float3 cameraPosition,
        int count,
        List result
    );

    static void BuildInteractionSet(
        IEnumerable nearest,
        IEnumerable selected,
        HashSet result
    );

    static HashSet LoadSelection(int[] volumeConstraints, int tetrahedronCount);
    static int[] ApplySelection(HashSet selection);
    static bool Toggle(HashSet selection, int index);
};

Detailed Documentation

Pure, side-effect-free helpers for the Cut Action volume selection tool. Extracted from CutActionVolumeSelectionTool so the geometry/selection logic can be unit-tested without a live scene, camera, or simulation mesh.

Methods

static float3 TetrahedronCentroid(float3 a, float3 b, float3 c, float3 d)

Returns the centroid of a tetrahedron given its four corner positions.

static void SelectNearest(
    IReadOnlyList centroids,
    float3 cameraPosition,
    int count,
    List result
)

Fills result with the indices of the count centroids closest to cameraPosition, nearest first.

count <= 0 yields an empty set; count>= the centroid count yields every index (ascending). Ties are broken by ascending index so the result is deterministic regardless of input order.

static void BuildInteractionSet(
    IEnumerable nearest,
    IEnumerable selected,
    HashSet result
)

Fills result with the interaction set: the union of the in-range (nearest) indices and the currently selected indices. This is the set of volumes that can be hovered or clicked.

static HashSet LoadSelection(int[] volumeConstraints, int tetrahedronCount)

Builds a selection set from a serialized VolumeConstraints index array, discarding any index outside [0, tetrahedronCount).

static int[] ApplySelection(HashSet selection)

Converts a selection set back into a serialized VolumeConstraints array, sorted ascending.

static bool Toggle(HashSet selection, int index)

Toggles index in selection : adds it when absent (returning true), removes it when present (returning false).