Vixen
dd8b0a81
csharp
public record class MeshData

The geometry of one mesh, as it came out of an authoring tool.

Read the guide page for this →

Remarks

The CPU side of MeshDraw. That struct holds buffer handles and a range, because it is read once per object in a frame; this holds arrays, because it is read once per build by something deciding what those buffers should contain.

Parallel arrays, and typed ones. A vertex is not a struct here, because the layout is a compile-time decision — which attributes are present, in what order, at what precision, interleaved or not — and doc 08 puts that in ModelCompiler where the whole model is in hand. Separate arrays let a compiler drop an attribute nothing samples without rewriting the ones it keeps.

An attribute the file did not have is an empty array rather than a null or a defaulted one. Empty says "this mesh has no tangents"; an array of zeros says "this mesh has tangents and they are all degenerate", and a compiler cannot tell the second from a bug in the first.

⚠ There is no vertex-colour channel and no second texture coordinate set, and that is a decision rather than an omission. Both were here — read from Assimp, serialized, round-trip tested — and both were dropped by Pack on the way to the only vertex layout the engine draws through, for the whole time they existed. An importer that carries a channel nothing draws is the worst of the three available states: it costs bytes in every mesh chunk, it reads as support in the type's own signature, and it fails silently, because a colour that never arrives looks exactly like a mesh nobody painted.

The objection that kept them undrawn was wrong, and correcting it did not make the change small. Widening SurfaceVertex was recorded as costing sixteen bytes a vertex; UNorm8X4 is four, is documented for exactly this, and translates on all three backends. What the arithmetic does not reach is the shape of the change: the interleaved stream is one of three ways a vertex attribute gets to a shader, and the other two — ModelCompiler.PageAttributes for the cluster pages, and VisibilityResolve's fetch out of them — pack their own records. A colour added to the interleaved stream alone is a mesh that is tinted until it clusters and untinted after, which is worse than not having one. Nor is the free version available: VertexChannel carries no binding index and a VertexSchema has one stride, so VertexSchema.Layout returns a single buffer by construction, and the two renderers that do bind a second stream build their VertexBufferLayout[] by hand rather than through a schema.

So the channels land with the change that needs them, and not before. Doc 31 § B3 already says which one — the per-instance record change, which is the same class of edit to the same three paths — and doc 24 § P5 records the blockout painting that wants it. Re-adding the importer half is ten lines of ModelReader; that is the cheap half, and holding it open for two phases that closed without it bought nothing. The second coordinate set does not come back with them: its headline consumer was a lightmap, and the engine's global illumination is dynamic by decision — no unwrap, no chart packing, no atlas — so a detail map or a trim sheet addressing off the first set is what is actually on offer.

Fields and properties (18)

  • public string Name

    What the mesh is called. Its sub-asset name, and part of its address.

  • public Vector3[] Positions

    One position per vertex.

  • public Vector3[] Normals

    One normal per vertex, or empty.

  • public Vector4[] Tangents

    One tangent per vertex, or empty. W is the bitangent's sign.

  • public Vector2[] TexCoords

    One texture coordinate per vertex, or empty.

  • public int[] Indices

    Three indices per triangle.

  • public int[] BoneIndices

    Four joint indices per vertex, or empty if the mesh is not skinned.

  • public float[] BoneWeights

    Four weights per vertex, summing to one, or empty.

  • public int MaterialIndex

    Which of the model's materials this is drawn with.

  • public BoundingBox Bounds

    Everything the mesh occupies, in the model's space.

  • public AssetReference Clusters

    This mesh's cluster hierarchy and page records, or null if it has none.

  • public AssetReference ClusterPages

    Where this mesh's page blob is, or null if it has no clusters.

  • public MorphTargetData[] MorphTargets

    The blend shapes this mesh carries, or empty.

  • public bool IsClustered

    Whether it was built with a cluster hierarchy.

  • public bool IsMorphed

    Whether it carries blend shapes.

  • public int VertexCount

    How many vertices it has.

  • public int TriangleCount

    How many triangles it has.

  • public bool IsSkinned

    Whether it carries skinning weights.

Used by (86, showing 40)

  • AssetMeshSourceVixen.Engine.Renderer
  • AssetVirtualGeometrySourceVixen.Engine.Renderer
  • BuilderVixen.Rendering
  • CompositorImageTestsVixen.Graphics.Golden.Tests
  • DeferredMeshSourceVixen.Engine.Renderer.Tests
  • DeferredQuadVixen.Rendering.Tests
  • EditorGizmoFacingDeviceTestsVixen.Graphics.Golden.Tests
  • EntryVixen.Engine.Renderer
  • EveryMeshVixen.Rendering.Tests
  • GeometryVixen.Rendering.Tests
  • GeometryResidencyVixen.Rendering
  • IMeshSourceVixen.Rendering
  • MeshExtractionSystemVixen.Rendering
  • MeshExtractionTestsVixen.Rendering.Tests
  • MeshInstanceRendererVixen.Rendering
  • MeshInstanceRendererTestsVixen.Rendering.Tests
  • MeshPrimitivesVixen.Rendering
  • MeshPrimitivesTestsVixen.Rendering.Tests
  • MeshRenderableVixen.Rendering
  • ModelDataTestsVixen.Rendering.Tests
  • MorphRenderFeatureVixen.Rendering
  • MorphRenderFeatureTestsVixen.Rendering.Tests
  • MorphScatterDeviceTestsVixen.Graphics.Golden.Tests
  • MorphedClusterTestsVixen.Rendering.Tests
  • OneMeshVixen.Rendering.Tests
  • OneMeshVixen.Rendering.Tests
  • OneMeshVixen.Graphics.Golden.Tests
  • OneMeshVixen.Rendering.Tests
  • OneTriangleVixen.Rendering.Tests
  • OneTriangleVixen.Rendering.Terrain.Tests
  • QuadVixen.Rendering.Tests
  • SurfaceGeometryVixen.Rendering
  • SurfaceGeometryTestsVixen.Rendering.Tests
  • TerrainSceneRendererVixen.Rendering.Terrain
  • TextureDemandTestsVixen.Engine.Renderer.Tests
  • TypeRegistrationVixen.Rendering
  • VfxEmitterVixen.Rendering
  • VfxExtractionSystemVixen.Rendering
  • VirtualGeometryCasterTestsVixen.Rendering.Tests
  • Vixen_Rendering_MeshDataSerializerVixen.Rendering