From 1b632251a8a096ae7b7d86cb8cbd034035c46a1f Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Fri, 15 Oct 2021 15:51:51 +0200 Subject: [PATCH] refactor: Removed redundant code --- ChangeLog.md | 1 + Runtime/Scripts/Schema/Accessor.cs | 27 +++------------------------ Runtime/Scripts/Schema/Root.cs | 2 +- 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 96fb03e8..d8451919 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Corrected mesh bounds (calculated from accessor's min/max) - No errors when importing empty scenes +- Removed redundant code ## [4.3.2] - 2021-10-13 ### Added diff --git a/Runtime/Scripts/Schema/Accessor.cs b/Runtime/Scripts/Schema/Accessor.cs index 6cb7335d..0f6a8a33 100644 --- a/Runtime/Scripts/Schema/Accessor.cs +++ b/Runtime/Scripts/Schema/Accessor.cs @@ -148,9 +148,8 @@ public GLTFAccessorAttributeType typeEnum { /// public AccessorSparse sparse; - public static int GetAccessorComponentTypeLength( GLTFComponentType componentType ) { - switch (componentType) - { + public static int GetComponentTypeSize( GLTFComponentType componentType ) { + switch (componentType) { case GLTFComponentType.Byte: case GLTFComponentType.UnsignedByte: return 1; @@ -161,27 +160,7 @@ public static int GetAccessorComponentTypeLength( GLTFComponentType componentTyp case GLTFComponentType.UnsignedInt: return 4; default: - Debug.LogError("Unknown GLTFComponentType"); - return 0; - } - } - - public static int GetComponentTypeSize(GLTFComponentType type) { - switch (type) { - case GLTFComponentType.Byte: - return 1; - case GLTFComponentType.UnsignedByte: - return 1; - case GLTFComponentType.Short: - return 2; - case GLTFComponentType.UnsignedShort: - return 2; - case GLTFComponentType.UnsignedInt: - return 4; - case GLTFComponentType.Float: - return 4; - default: - throw new ArgumentOutOfRangeException(nameof(type), type, null); + throw new ArgumentOutOfRangeException(nameof(type), componentType, null); } } diff --git a/Runtime/Scripts/Schema/Root.cs b/Runtime/Scripts/Schema/Root.cs index 226d3f2b..3c47b798 100644 --- a/Runtime/Scripts/Schema/Root.cs +++ b/Runtime/Scripts/Schema/Root.cs @@ -118,7 +118,7 @@ public bool IsAccessorInterleaved( int accessorIndex ) { var accessor = accessors[accessorIndex]; var bufferView = bufferViews[accessor.bufferView]; if (bufferView.byteStride < 0) return false; - int elementSize = Accessor.GetAccessorAttributeTypeLength(accessor.typeEnum) * Accessor.GetAccessorComponentTypeLength(accessor.componentType); + var elementSize = Accessor.GetAccessorAttributeTypeLength(accessor.typeEnum) * Accessor.GetComponentTypeSize(accessor.componentType); return bufferView.byteStride > elementSize; } }