Browse Source

code cleanup
warnings--

vpenades 2 years ago
parent
commit
af4cc540e9

+ 8 - 8
src/SharpGLTF.Core/Memory/MemoryAccessor.cs

@@ -18,7 +18,7 @@ namespace SharpGLTF.Memory
     {
         #region debug
 
-        internal string _GetDebuggerDisplay()
+        internal readonly string _GetDebuggerDisplay()
         {
             return Diagnostics.DebuggerDisplay.ToReport(this);
         }
@@ -84,7 +84,7 @@ namespace SharpGLTF.Memory
             this.Normalized = normalized;
         }
 
-        public MemoryAccessInfo Slice(int itemStart, int itemCount)
+        public readonly MemoryAccessInfo Slice(int itemStart, int itemCount)
         {
             var stride = _GetRowByteLength();
 
@@ -141,11 +141,11 @@ namespace SharpGLTF.Memory
         /// <summary>
         /// number of bytes to advance to the next item.
         /// </summary>
-        public int StepByteLength => _GetRowByteLength();
+        public readonly int StepByteLength => _GetRowByteLength();
 
-        public int ItemByteLength => _GetItemByteLength();
+        public readonly int ItemByteLength => _GetItemByteLength();
 
-        public Boolean IsValidVertexAttribute
+        public readonly Boolean IsValidVertexAttribute
         {
             get
             {
@@ -166,7 +166,7 @@ namespace SharpGLTF.Memory
         /// <summary>
         /// returns true if this type can be used as a joint index.
         /// </summary>
-        public Boolean IsValidIndexer
+        public readonly Boolean IsValidIndexer
         {
             get
             {
@@ -187,7 +187,7 @@ namespace SharpGLTF.Memory
 
         #region API
 
-        private int _GetItemByteLength()
+        private readonly int _GetItemByteLength()
         {
             var xlen = Encoding.ByteLength();
 
@@ -200,7 +200,7 @@ namespace SharpGLTF.Memory
             return xlen;
         }
 
-        private int _GetRowByteLength()
+        private readonly int _GetRowByteLength()
         {
             return Math.Max(ByteStride, _GetItemByteLength());
         }

+ 4 - 4
src/SharpGLTF.Core/Schema2/gltf.ExtraProperties.cs

@@ -214,13 +214,13 @@ namespace SharpGLTF.Schema2
         /// <summary>
         /// Reads the properties of the current instance from a <see cref="Utf8JsonReader"/>.
         /// </summary>
-        /// <param name="property">The name of the property.</param>
+        /// <param name="jsonPropertyName">The name of the property.</param>
         /// <param name="reader">The source reader.</param>
-        protected override void DeserializeProperty(string property, ref Utf8JsonReader reader)
+        protected override void DeserializeProperty(string jsonPropertyName, ref Utf8JsonReader reader)
         {
-            Guard.NotNullOrEmpty(property, nameof(property));
+            Guard.NotNullOrEmpty(jsonPropertyName, nameof(jsonPropertyName));
 
-            switch (property)
+            switch (jsonPropertyName)
             {
                 case "extensions": _DeserializeExtensions(this, ref reader, _extensions); break;
 

+ 3 - 3
src/SharpGLTF.Core/Schema2/gltf.MaterialsFactory.cs

@@ -28,7 +28,7 @@ namespace SharpGLTF.Schema2
         /// </summary>
         public void InitializeUnlit()
         {
-            if (this._pbrMetallicRoughness == null) this._pbrMetallicRoughness = new MaterialPBRMetallicRoughness();
+            this._pbrMetallicRoughness ??= new MaterialPBRMetallicRoughness();
 
             ClearExtensions();
             this.UseExtension<MaterialUnlit>();
@@ -45,7 +45,7 @@ namespace SharpGLTF.Schema2
         {
             Guard.NotNull(extensionNames, nameof(extensionNames));
 
-            if (this._pbrMetallicRoughness == null) this._pbrMetallicRoughness = new MaterialPBRMetallicRoughness();
+            this._pbrMetallicRoughness ??= new MaterialPBRMetallicRoughness();
 
             ClearExtensions();
 
@@ -67,7 +67,7 @@ namespace SharpGLTF.Schema2
         {
             if (useFallback)
             {
-                if (this._pbrMetallicRoughness == null) this._pbrMetallicRoughness = new MaterialPBRMetallicRoughness();
+                this._pbrMetallicRoughness ??= new MaterialPBRMetallicRoughness();
             }
             else
             {

+ 2 - 2
src/SharpGLTF.Core/Schema2/gltf.Node.cs

@@ -290,7 +290,7 @@ namespace SharpGLTF.Schema2
 
                 // check if it's affected by any animation channel.
 
-                bool _isTransformPath(PropertyPath path)
+                static bool _isTransformPath(PropertyPath path)
                 {
                     if (path == PropertyPath.scale) return true;
                     if (path == PropertyPath.rotation) return true;
@@ -705,7 +705,7 @@ namespace SharpGLTF.Schema2
                 .ToList();
 
             // find all the nodes that cannot be modified
-            bool isSensible(Node node)
+            static bool isSensible(Node node)
             {
                 if (node.IsTransformAnimated) return true;
                 if (node.IsTransformDecomposed) return true;

+ 3 - 3
src/SharpGLTF.Toolkit/Geometry/MeshBuilder.cs

@@ -212,8 +212,8 @@ namespace SharpGLTF.Geometry
         {
             if (mesh == null) return;
 
-            if (materialTransform == null) materialTransform = m => m;
-            if (vertexTransform == null) vertexTransform = v => VertexBuilder<TvG, TvM, TvS>.CreateFrom(v);
+            materialTransform ??= m => m;
+            vertexTransform ??= v => VertexBuilder<TvG, TvM, TvS>.CreateFrom(v);
 
             AddMesh<TMaterial>(mesh, materialTransform, vertexTransform);
         }
@@ -223,7 +223,7 @@ namespace SharpGLTF.Geometry
             if (mesh == null) return;
 
             Guard.NotNull(materialTransform, nameof(materialTransform));
-            if (vertexTransform == null) vertexTransform = v => VertexBuilder<TvG, TvM, TvS>.CreateFrom(v);
+            vertexTransform ??= v => VertexBuilder<TvG, TvM, TvS>.CreateFrom(v);
 
             foreach (var p in mesh.Primitives)
             {

+ 41 - 36
src/SharpGLTF.Toolkit/Geometry/Packed/PackedMeshBuilder.cs

@@ -48,60 +48,65 @@ namespace SharpGLTF.Geometry
 
             foreach (var srcMesh in meshBuilders)
             {
-                // Gather all the primitives of the mesh
+                yield return Create(srcMesh, vertexEncodings, indexEncoding, settings);
+            }
+        }
+
+        private static PackedMeshBuilder<TMaterial> Create(IMeshBuilder<TMaterial> srcMesh, PackedEncoding vertexEncodings, EncodingType indexEncoding, Scenes.SceneBuilderSchema2Settings settings)
+        {
+            // Gather all the primitives of the mesh
 
-                var srcPrims = srcMesh
+            var srcPrims = srcMesh
                     .Primitives
                     .Where(item => item.Vertices.Count > 0)
-                    .ToList();                
-
-                // identify morph target attributes in use                
+                    .ToList();
 
-                var morphTargetsAttributes = new HashSet<string>();
+            // identify morph target attributes in use                
 
-                foreach (var srcPrim in srcPrims)
-                {
-                    srcPrim._GatherMorphTargetAttributes(morphTargetsAttributes);                    
-                }
+            var morphTargetsAttributes = new HashSet<string>();
 
-                // adjust vertex encoding
+            foreach (var srcPrim in srcPrims)
+            {
+                srcPrim._GatherMorphTargetAttributes(morphTargetsAttributes);
+            }
 
-                if (morphTargetsAttributes.Count > 0)
-                {
-                    // if any primitive has morph targets, it is better not to use strided vertex buffers.
-                    settings.UseStridedBuffers = false;
-                }
+            // adjust vertex encoding
 
-                bool hasColorMorph = morphTargetsAttributes.Contains("COLOR_0DELTA")
-                    || morphTargetsAttributes.Contains("COLOR_1DELTA")
-                    || morphTargetsAttributes.Contains("COLOR_2DELTA")
-                    || morphTargetsAttributes.Contains("COLOR_3DELTA");
+            if (morphTargetsAttributes.Count > 0)
+            {
+                // if any primitive has morph targets, it is better not to use strided vertex buffers.
+                settings.UseStridedBuffers = false;
+            }
 
-                // if any primitive has color morphing, we need to ensure the vertex
-                // color attribute encoding is FLOAT to allow negative delta values.
+            bool hasColorMorph = morphTargetsAttributes.Contains("COLOR_0DELTA")
+                || morphTargetsAttributes.Contains("COLOR_1DELTA")
+                || morphTargetsAttributes.Contains("COLOR_2DELTA")
+                || morphTargetsAttributes.Contains("COLOR_3DELTA");
 
-                vertexEncodings.ColorEncoding = hasColorMorph
-                    ? EncodingType.FLOAT
-                    : (EncodingType?)null;
+            // if any primitive has color morphing, we need to ensure the vertex
+            // color attribute encoding is FLOAT to allow negative delta values.
 
-                // Create a packed mesh
+            vertexEncodings.ColorEncoding = hasColorMorph
+                ? EncodingType.FLOAT
+                : (EncodingType?)null;
 
-                var dstMesh = new PackedMeshBuilder<TMaterial>(srcMesh.Name, srcMesh.Extras);
+            // Create a packed mesh
 
-                foreach (var srcPrim in srcPrims)
-                {
-                    var dstPrim = dstMesh.AddPrimitive(srcPrim.Material, srcPrim.VerticesPerPrimitive);
+            var dstMesh = new PackedMeshBuilder<TMaterial>(srcMesh.Name, srcMesh.Extras);
 
-                    if (settings.UseStridedBuffers) dstPrim.SetStridedVertices(srcPrim, vertexEncodings);
-                    else dstPrim.SetStreamedVertices(srcPrim, vertexEncodings);
+            foreach (var srcPrim in srcPrims)
+            {
+                var dstPrim = dstMesh.AddPrimitive(srcPrim.Material, srcPrim.VerticesPerPrimitive);
 
-                    dstPrim.SetIndices(srcPrim, indexEncoding);
+                if (settings.UseStridedBuffers) dstPrim.SetStridedVertices(srcPrim, vertexEncodings);
+                else dstPrim.SetStreamedVertices(srcPrim, vertexEncodings);
 
-                    if (morphTargetsAttributes.Count > 0) dstPrim.SetMorphTargets(srcPrim, vertexEncodings, morphTargetsAttributes);
-                }
+                dstPrim.SetIndices(srcPrim, indexEncoding);
 
-                yield return dstMesh;
+                if (morphTargetsAttributes.Count > 0) dstPrim.SetMorphTargets(srcPrim, vertexEncodings, morphTargetsAttributes);
             }
+
+            return dstMesh;
         }
 
         private PackedMeshBuilder(string name, JSONEXTRAS extras)

+ 5 - 3
src/SharpGLTF.Toolkit/Geometry/Packed/PackedPrimitiveBuilder.cs

@@ -106,7 +106,9 @@ namespace SharpGLTF.Geometry
 
             for (int i = 0; i < srcPrim.MorphTargets.Count; ++i)
             {
-                var (pAccessor,nAccessor,tAccessor,c0Accessor, c1Accessor, uv0Accessor, uv1Accessor, uv2Accessor, uv3Accessor) = srcPrim._GetMorphTargetAccessors(i, vertexEncodings, morphTargetAttributes);
+                var (pAccessor, nAccessor, tAccessor,
+                    c0Accessor, c1Accessor,
+                    uv0Accessor, uv1Accessor, uv2Accessor, uv3Accessor) = srcPrim._GetMorphTargetAccessors(i, vertexEncodings, morphTargetAttributes);
 
                 if (!hasPositions) pAccessor = null;
                 if (!hasNormals) nAccessor = null;
@@ -124,7 +126,7 @@ namespace SharpGLTF.Geometry
 
         private void AddMorphTarget(params MACCESSOR[] morphTarget)
         {
-            MACCESSOR _removeDeltaSuffix(MACCESSOR accessor)
+            static MACCESSOR _removeDeltaSuffix(MACCESSOR accessor)
             {
                 var name = accessor.Attribute.Name;
                 if (!name.EndsWith("DELTA", StringComparison.Ordinal)) throw new InvalidOperationException();
@@ -134,7 +136,7 @@ namespace SharpGLTF.Geometry
                 var attr = accessor.Attribute;
                 attr.Name = name;
 
-                return new Memory.MemoryAccessor(accessor.Data, attr);
+                return new MACCESSOR(accessor.Data, attr);
             }
 
             morphTarget = morphTarget

+ 6 - 8
src/SharpGLTF.Toolkit/Geometry/PrimitiveBuilder.cs

@@ -272,7 +272,7 @@ namespace SharpGLTF.Geometry
         {
             if (primitive == null) return;
 
-            if (vertexTransformFunc == null) vertexTransformFunc = v => v;
+            vertexTransformFunc ??= v => v;
 
             AddPrimitive<TMaterial>(primitive, v => vertexTransformFunc((VertexBuilder<TvG, TvM, TvS>)v));
         }
@@ -440,9 +440,7 @@ namespace SharpGLTF.Geometry
 
         private sealed class VertexListWrapper : ValueListSet<VertexBuilder<TvG, TvM, TvS>>, IReadOnlyList<IVertexBuilder>
         {
-            #pragma warning disable SA1100 // Do not prefix calls with base unless local implementation exists
             IVertexBuilder IReadOnlyList<IVertexBuilder>.this[int index] => base[index];
-            #pragma warning restore SA1100 // Do not prefix calls with base unless local implementation exists
 
             IEnumerator<IVertexBuilder> IEnumerable<IVertexBuilder>.GetEnumerator()
             {
@@ -509,7 +507,7 @@ namespace SharpGLTF.Geometry
 
         #region types
 
-        struct PointListWrapper<T> : IReadOnlyList<int>
+        readonly struct PointListWrapper<T> : IReadOnlyList<int>
         {
             public PointListWrapper(IReadOnlyList<T> vertices)
             {
@@ -765,7 +763,7 @@ namespace SharpGLTF.Geometry
 
         #region Types
 
-        private struct TriangleList : IReadOnlyList<(int A, int B, int C)>
+        private readonly struct TriangleList : IReadOnlyList<(int A, int B, int C)>
         {
             public TriangleList(IReadOnlyList<(int, int, int)> tris, IReadOnlyList<(int, int, int, int)> quads)
             {
@@ -809,7 +807,7 @@ namespace SharpGLTF.Geometry
             }
         }
 
-        private struct SurfaceList : IReadOnlyList<(int A, int B, int C, int? D)>
+        private readonly struct SurfaceList : IReadOnlyList<(int A, int B, int C, int? D)>
         {
             public SurfaceList(IReadOnlyList<(int, int, int)> tris, IReadOnlyList<(int, int, int, int)> quads)
             {
@@ -932,13 +930,13 @@ namespace SharpGLTF.Geometry
 
         public void SetVertexNormal(int idx, Vector3 normal)
         {
-            if (_Normals == null) _Normals = new Vector3[VertexCount];
+            _Normals ??= new Vector3[VertexCount];
             _Normals[idx] = normal;
         }
 
         public void SetVertexTangent(int idx, Vector4 tangent)
         {
-            if (_Tangents == null) _Tangents = new Vector4[VertexCount];
+            _Tangents ??= new Vector4[VertexCount];
             _Tangents[idx] = tangent;
         }
 

+ 4 - 8
src/SharpGLTF.Toolkit/Geometry/VertexBufferColumns.cs

@@ -82,7 +82,7 @@ namespace SharpGLTF.Geometry
 
         #region properties
 
-        public IReadOnlyList<VertexBufferColumns> MorphTargets => _MorphTargets != null ? _MorphTargets : (IReadOnlyList<VertexBufferColumns>)Array.Empty<VertexBufferColumns>();
+        public IReadOnlyList<VertexBufferColumns> MorphTargets => _MorphTargets ?? (IReadOnlyList<VertexBufferColumns>)Array.Empty<VertexBufferColumns>();
 
         #endregion
 
@@ -178,8 +178,6 @@ namespace SharpGLTF.Geometry
 
             var skinning = default(Transforms.SparseWeight8);
 
-            Transforms.IMaterialTransform morphMaterial = transform as Transforms.IMaterialTransform;
-
             Vector3[] morphPositions = null;
             Vector3[] morphNormals = null;
             Vector3[] morphTangents = null;
@@ -229,7 +227,7 @@ namespace SharpGLTF.Geometry
                     Tangents[i] = transform.TransformTangent(Tangents[i], morphTangents, skinning);
                 }
 
-                if (morphMaterial != null)
+                if (transform is Transforms.IMaterialTransform morphMaterial)
                 {
                     if (this.Colors0 != null)
                     {
@@ -488,15 +486,13 @@ namespace SharpGLTF.Geometry
 
             public void SetVertexNormal(int idx, Vector3 normal)
             {
-                if (_Vertices.Normals == null) _Vertices.Normals = new Vector3[_Vertices.Positions.Count];
-
+                _Vertices.Normals ??= new Vector3[_Vertices.Positions.Count];
                 _Vertices.Normals[idx] = normal;
             }
 
             public void SetVertexTangent(int idx, Vector4 tangent)
             {
-                if (_Vertices.Tangents == null) _Vertices.Tangents = new Vector4[_Vertices.Positions.Count];
-
+                _Vertices.Tangents ??= new Vector4[_Vertices.Positions.Count];
                 _Vertices.Tangents[idx] = tangent;
             }
         }

+ 4 - 4
src/SharpGLTF.Toolkit/Geometry/VertexBuilder.cs

@@ -104,7 +104,7 @@ namespace SharpGLTF.Geometry
             return method.Invoke(o, Array.Empty<Object>()) as string;
         }
 
-        private String _GetDebugWarnings()
+        private readonly String _GetDebugWarnings()
         {
             var sb = new StringBuilder();
 
@@ -284,10 +284,10 @@ namespace SharpGLTF.Geometry
         public readonly override int GetHashCode() { return Geometry.GetHashCode(); }
 
         /// <inheritdoc/>
-        public override bool Equals(object obj) { return obj is VertexBuilder<TvG, TvM, TvS> other && AreEqual(this, other); }
+        public readonly override bool Equals(object obj) { return obj is VertexBuilder<TvG, TvM, TvS> other && AreEqual(this, other); }
 
         /// <inheritdoc/>
-        public bool Equals(VertexBuilder<TvG, TvM, TvS> other) { return AreEqual(this, other); }
+        public readonly bool Equals(VertexBuilder<TvG, TvM, TvS> other) { return AreEqual(this, other); }
 
         public static bool operator ==(in VertexBuilder<TvG, TvM, TvS> a, in VertexBuilder<TvG, TvM, TvS> b) { return AreEqual(a, b); }
 
@@ -480,7 +480,7 @@ namespace SharpGLTF.Geometry
         public IVertexMaterial Material;
         public IVertexSkinning Skinning;
 
-        public override int GetHashCode() { return Geometry.GetHashCode(); }
+        public readonly override int GetHashCode() { return Geometry.GetHashCode(); }
 
         #endregion
 

+ 9 - 9
src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexGeometry.cs

@@ -91,7 +91,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -146,12 +146,12 @@ namespace SharpGLTF.Geometry.VertexTypes
 
         void IVertexGeometry.SetPosition(in Vector3 position) { this.Position = position; }
 
-        void IVertexGeometry.SetNormal(in Vector3 normal) { }
+        readonly void IVertexGeometry.SetNormal(in Vector3 normal) { }
 
-        void IVertexGeometry.SetTangent(in Vector4 tangent) { }
+        readonly void IVertexGeometry.SetTangent(in Vector4 tangent) { }
 
         /// <inheritdoc/>
-        public VertexGeometryDelta Subtract(IVertexGeometry baseValue)
+        public readonly VertexGeometryDelta Subtract(IVertexGeometry baseValue)
         {
             return new VertexGeometryDelta((VertexPosition)baseValue, this);
         }
@@ -188,7 +188,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -252,10 +252,10 @@ namespace SharpGLTF.Geometry.VertexTypes
 
         void IVertexGeometry.SetNormal(in Vector3 normal) { this.Normal = normal; }
 
-        void IVertexGeometry.SetTangent(in Vector4 tangent) { }
+        readonly void IVertexGeometry.SetTangent(in Vector4 tangent) { }
 
         /// <inheritdoc/>
-        public VertexGeometryDelta Subtract(IVertexGeometry baseValue)
+        public readonly VertexGeometryDelta Subtract(IVertexGeometry baseValue)
         {
             return new VertexGeometryDelta((VertexPositionNormal)baseValue, this);
         }
@@ -404,7 +404,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => $"Δ𝐏:{PositionDelta} Δ𝚴:{NormalDelta} Δ𝚻:{TangentDelta}";
+        private readonly string _GetDebuggerDisplay() => $"Δ𝐏:{PositionDelta} Δ𝚴:{NormalDelta} Δ𝚻:{TangentDelta}";
 
         #endregion
 
@@ -524,7 +524,7 @@ namespace SharpGLTF.Geometry.VertexTypes
         public void ApplyTransform(in Matrix4x4 xform) { throw new NotSupportedException(); }
 
         /// <inheritdoc/>
-        public VertexGeometryDelta Subtract(IVertexGeometry baseValue)
+        public readonly VertexGeometryDelta Subtract(IVertexGeometry baseValue)
         {
             return new VertexGeometryDelta((VertexGeometryDelta)baseValue, this);
         }

+ 16 - 16
src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexMaterial.cs

@@ -90,7 +90,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -147,7 +147,7 @@ namespace SharpGLTF.Geometry.VertexTypes
         #region API
 
         /// <inheritdoc/>
-        public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
+        public readonly VertexMaterialDelta Subtract(IVertexMaterial baseValue)
         {
             return new VertexMaterialDelta((VertexColor1)baseValue, this);
         }
@@ -160,7 +160,7 @@ namespace SharpGLTF.Geometry.VertexTypes
 
         void IVertexMaterial.SetColor(int setIndex, Vector4 color) { if (setIndex == 0) this.Color = color; }
 
-        void IVertexMaterial.SetTexCoord(int setIndex, Vector2 coord) { }
+        readonly void IVertexMaterial.SetTexCoord(int setIndex, Vector2 coord) { }
 
         /// <inheritdoc/>
         public readonly Vector4 GetColor(int index)
@@ -186,7 +186,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -247,7 +247,7 @@ namespace SharpGLTF.Geometry.VertexTypes
         #region API
 
         /// <inheritdoc/>
-        public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
+        public readonly VertexMaterialDelta Subtract(IVertexMaterial baseValue)
         {
             return new VertexMaterialDelta((VertexColor2)baseValue, this);
         }
@@ -265,7 +265,7 @@ namespace SharpGLTF.Geometry.VertexTypes
             if (setIndex == 1) this.Color1 = color;
         }
 
-        void IVertexMaterial.SetTexCoord(int setIndex, Vector2 coord) { }
+        readonly void IVertexMaterial.SetTexCoord(int setIndex, Vector2 coord) { }
 
         /// <inheritdoc/>
         public readonly Vector4 GetColor(int index)
@@ -289,7 +289,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -345,7 +345,7 @@ namespace SharpGLTF.Geometry.VertexTypes
         #region API
 
         /// <inheritdoc/>
-        public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
+        public readonly VertexMaterialDelta Subtract(IVertexMaterial baseValue)
         {
             return new VertexMaterialDelta((VertexTexture1)baseValue, this);
         }
@@ -356,7 +356,7 @@ namespace SharpGLTF.Geometry.VertexTypes
             this.TexCoord += delta.TexCoord0Delta;
         }
 
-        void IVertexMaterial.SetColor(int setIndex, Vector4 color) { }
+        readonly void IVertexMaterial.SetColor(int setIndex, Vector4 color) { }
 
         void IVertexMaterial.SetTexCoord(int setIndex, Vector2 coord) { if (setIndex == 0) this.TexCoord = coord; }
 
@@ -384,7 +384,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -445,7 +445,7 @@ namespace SharpGLTF.Geometry.VertexTypes
         #region API
 
         /// <inheritdoc/>
-        public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
+        public readonly VertexMaterialDelta Subtract(IVertexMaterial baseValue)
         {
             return new VertexMaterialDelta((VertexTexture2)baseValue, this);
         }
@@ -457,7 +457,7 @@ namespace SharpGLTF.Geometry.VertexTypes
             this.TexCoord1 += delta.TexCoord1Delta;
         }
 
-        void IVertexMaterial.SetColor(int setIndex, Vector4 color) { }
+        readonly void IVertexMaterial.SetColor(int setIndex, Vector4 color) { }
 
         void IVertexMaterial.SetTexCoord(int setIndex, Vector2 coord)
         {
@@ -490,7 +490,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -551,7 +551,7 @@ namespace SharpGLTF.Geometry.VertexTypes
         #region API
 
         /// <inheritdoc/>
-        public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
+        public readonly VertexMaterialDelta Subtract(IVertexMaterial baseValue)
         {
             return new VertexMaterialDelta((VertexColor1Texture1)baseValue, this);
         }
@@ -592,7 +592,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -658,7 +658,7 @@ namespace SharpGLTF.Geometry.VertexTypes
         #region API
 
         /// <inheritdoc/>
-        public VertexMaterialDelta Subtract(IVertexMaterial baseValue)
+        public readonly VertexMaterialDelta Subtract(IVertexMaterial baseValue)
         {
             return new VertexMaterialDelta((VertexColor1Texture2)baseValue, this);
         }

+ 5 - 5
src/SharpGLTF.Toolkit/Geometry/VertexTypes/VertexSkinning.cs

@@ -82,7 +82,7 @@ namespace SharpGLTF.Geometry.VertexTypes
     {
         #region debug
 
-        private string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
+        private readonly string _GetDebuggerDisplay() => VertexUtils._GetDebuggerDisplay(this);
 
         #endregion
 
@@ -165,13 +165,13 @@ namespace SharpGLTF.Geometry.VertexTypes
         #region properties
 
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
-        Vector4 IVertexSkinning.JointsLow => this.Joints;
+        readonly Vector4 IVertexSkinning.JointsLow => this.Joints;
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
-        Vector4 IVertexSkinning.JointsHigh => Vector4.Zero;
+        readonly Vector4 IVertexSkinning.JointsHigh => Vector4.Zero;
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
-        Vector4 IVertexSkinning.WeightsLow => this.Weights;
+        readonly Vector4 IVertexSkinning.WeightsLow => this.Weights;
         [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
-        Vector4 IVertexSkinning.WeightsHigh => Vector4.Zero;
+        readonly Vector4 IVertexSkinning.WeightsHigh => Vector4.Zero;
 
         #endregion