Vixen
02b45cc4
csharp
public sealed class MeshElements

The vertices, edges and faces of a mesh, as things that can be pointed at.

Read the guide page for this →

Remarks

Derived, not authored, and that distinction is the whole of what this type is. MeshData is a drawing structure: its vertices are corners, split wherever a normal or a texture coordinate had to be, so a cube's eight corners are twenty-four entries and its twelve edges do not exist at all. Sub-object selection asks about the other graph — doc 24's D2 calls it the position graph — where a cube corner is one thing you can drag and an edge is one thing you can bevel.

⚠ This is not EditMesh and must not grow into it. Doc 24's P1 builds the authored structure in Core/Vixen.Geometry: n-gon faces, an edge table that names up to two faces and reports more, attribute layers, face groups. What is here is the smallest thing that lets a pointer name an element of the geometry the editor already draws, so that B4's question is answerable before P1 exists. When it does, an EditMesh's triangulation is what this is built from — or replaces it outright — and nothing above changes, because SubObjectPicker only ever reads positions, triangles and edges.

⚠ Positions are welded within a tolerance rather than by exact equality. A cube's corner really is the same three floats three times over, but a sphere's seam is cos 0 against cos 2π and differs in the last bits — so exact welding leaves a line of doubled vertices down every curved primitive, invisible until somebody drags one half of it. The tolerance is relative to the mesh's own size, because a tolerance in metres is one that is wrong for anything not built at the scale it was chosen for.

Fields and properties (8)

  • public const float DefaultWeldTolerance

    How far apart two positions may be and still be one, as a fraction of the bounds.

  • public ReadOnlySpan<Vector3> Positions

    The shared positions, each one exactly once.

  • public ReadOnlySpan<int> Triangles

    Three Positions indices per face, in the mesh's winding order.

  • public ReadOnlySpan<MeshEdge> Edges

    Every edge of every face, each one exactly once.

  • public int TriangleCount

    How many triangles there are.

  • public int FaceCount

    How many faces there are — n-gons where these came from a mesh that has them.

  • public int EdgeCount

    How many edges there are.

  • public int PositionCount

    How many shared positions there are.

Methods (4)

  • public int FaceOf(int triangle)

    Which face a triangle belongs to.

  • public void TrianglesOf(int face, List<int> into)

    Which triangles a face is drawn as.

  • public static MeshElements From(MeshData mesh, float tolerance = 0.0001)

    Derives the elements of a mesh.

  • public static MeshElements From(EditMesh mesh)

    The elements of an editable mesh, which already has them.

Used by (6)

  • ISubObjectPickerVixen.Editor.SceneView
  • PickingTestsVixen.Editor.SceneView.Tests
  • ScenePickerVixen.Editor.SceneView
  • SceneProbeVixen.Editor.SceneView
  • SubObjectPickerVixen.Editor.SceneView
  • SubObjectTestsVixen.Editor.SceneView.Tests