From 6ac30f758f6271e823e738d273e127da636ba2c4 Mon Sep 17 00:00:00 2001 From: Chris Dill Date: Mon, 20 Jul 2026 21:52:59 +0100 Subject: [PATCH] Update Model span utils * Order based on field position * Fix length bug with MeshMaterialAsSpan * Add MaterialsAsSpan --- Raylib-cs/types/Model.cs | 59 ++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/Raylib-cs/types/Model.cs b/Raylib-cs/types/Model.cs index edde296..74da3f8 100644 --- a/Raylib-cs/types/Model.cs +++ b/Raylib-cs/types/Model.cs @@ -130,16 +130,42 @@ public unsafe struct Model public Matrix4x4* BoneMatrices; /// - /// Bones animated transformation matrices as span. Based on Skeleton.BoneCount length + /// Meshes as span. Based on MeshCount length /// - public Span BoneMatricesAsSpan() + public Span MeshesAsSpan() { - if (BoneMatrices == null || Skeleton.BoneCount <= 0) + if (Meshes == null || MeshCount <= 0) { - return Span.Empty; + return Span.Empty; } - return new Span(BoneMatrices, Skeleton.BoneCount); + return new Span(Meshes, MeshCount); + } + + /// + /// Materials as span. Based on MaterialCount length + /// + public Span MaterialsAsSpan() + { + if (Materials == null || MaterialCount <= 0) + { + return Span.Empty; + } + + return new Span(Materials, MaterialCount); + } + + /// + /// Mesh material number as span. Based on MeshCount length + /// + public Span MeshMaterialAsSpan() + { + if (MeshMaterial == null || MeshCount <= 0) + { + return Span.Empty; + } + + return new Span(MeshMaterial, MeshCount); } /// @@ -156,29 +182,16 @@ public unsafe struct Model } /// - /// Mesh material number as span. Based on MaterialCount length + /// Bones animated transformation matrices as span. Based on Skeleton.BoneCount length /// - public Span MeshMaterialAsSpan() + public Span BoneMatricesAsSpan() { - if (MeshMaterial == null || MaterialCount <= 0) + if (BoneMatrices == null || Skeleton.BoneCount <= 0) { - return Span.Empty; + return Span.Empty; } - return new Span(MeshMaterial, MaterialCount); - } - - /// - /// Meshes as span. Based on MeshCount length - /// - public Span MeshesAsSpan() - { - if (Meshes == null || MeshCount <= 0) - { - return Span.Empty; - } - - return new Span(Meshes, MeshCount); + return new Span(BoneMatrices, Skeleton.BoneCount); } }