public sealed class MeshSelectionWhat is selected in one mesh: a kind, and the indices of that kind.
Remarks
Doc 24's P2, and it is in the kernel rather than in the editor for the reason the queries are. Converting a face selection to the vertices it covers is a walk over the corner table; growing an edge selection is a walk over the incidence tables. Both are arithmetic with a right answer, both are what a test can assert against a cube, and neither needs a viewport.
⚠ One set and a kind, not three sets. A designer in vertex mode has vertices selected; switching to face mode converts, and what they had before is gone — which is exactly what Blender, ProBuilder and Unreal's PolyGroup editing all do. Three sets kept in parallel would mean the mode you are not in holds a selection that drifts out of agreement with the one you are, and the first operation to read the wrong one is a bug nobody can reproduce.
⚠ Coarser-to-finer takes everything and finer-to-coarser takes only what is fully covered. Three faces converted to vertices is every corner of them; those vertices converted back is the three faces again, because each has all its corners. A rule that took partially covered faces would make the round trip grow the selection every time it was made, and switching modes twice is something people do without meaning anything by it.
The version is what drawing caches from. A highlight is rebuilt when the selection changes and not once a frame, and an event per change would be a subscription the frame loop already has in the form of "it is redrawn anyway".
Fields and properties (6)
public MeshElementKind KindWhich table Indices indexes.
public IReadOnlyList<int> IndicesWhat is selected, in the order it was selected in.
public int CountHow many elements are selected.
public bool IsEmptyWhether nothing is.
public int ActiveThe most recently added element, or -1.
public int VersionHow many times this has changed.
Methods (19)
public bool Contains(int index)Whether an element is selected.
public bool Add(int index)Selects one more element.
public bool Remove(int index)Takes one out.
public bool Toggle(int index)Selects an element if it is not, and deselects it if it is.
public void Set(int index)Replaces everything with one element.
public void Set(IEnumerable<int> values)Replaces everything with a set.
public void Union(IEnumerable<int> values)Adds a set to what is selected.
public void Clear()Deselects everything.
public void All(EditMesh mesh)Selects every element of the current kind.
public void Invert(EditMesh mesh)Selects what is not selected, and deselects what is.
public void Convert(EditMesh mesh, MeshElementKind kind)Changes which kind of element is selected, converting what is selected to it.
public void Grow(EditMesh mesh)Takes in everything touching what is already selected.
public void Shrink(EditMesh mesh)Gives back everything on the edge of what is selected.
public void SetKind(MeshElementKind kind)Changes which kind is selected, without a mesh to convert through.
public bool Validate(EditMesh mesh)Drops anything naming an element the mesh no longer has.
public void Positions(EditMesh mesh, List<int> into)Which shared positions the selection covers, whatever kind it is of.
public Vector3? Centre(EditMesh mesh)Where the selection is, as the average of the positions it covers.
public static int Total(EditMesh mesh, MeshElementKind kind)How many elements of a kind a mesh has.
public IReadOnlyList<int> Converted(EditMesh mesh, MeshElementKind kind)What this selection would be as another kind, without changing it.
Used by (17)
- MeshSelectionTestsVixen.Geometry.Tests
- BlockoutBooleanTestsVixen.Editor.Blockout.Tests
- BlockoutCreateTestsVixen.Editor.Blockout.Tests
- BlockoutCubeGridVixen.Editor.Blockout
- BlockoutGeometryVixen.Editor.Blockout
- BlockoutGeometryTestsVixen.Editor.Blockout.Tests
- BlockoutHistoryTestsVixen.Editor.Blockout.Tests
- BlockoutModeVixen.Editor.Blockout
- BlockoutSelectionVixen.Editor.Blockout
- BlockoutSelectionTestsVixen.Editor.Blockout.Tests
- BlockoutSurfaceTestsVixen.Editor.Blockout.Tests
- BlockoutSurfacesVixen.Editor.Blockout
- EditorApplicationVixen.Editor.App
- MeshEditVixen.Editor.SceneView
- MeshEditTestsVixen.Editor.SceneView.Tests
- SceneLinesVixen.Editor.SceneView
- SceneViewportVixen.Editor.SceneView