From 8fbcb5c6a719a3ac3e9a8118f7fb5e8a781f3de8 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 22 Dec 2021 16:01:44 +0900 Subject: [PATCH] =?UTF-8?q?bufferView.stride=20=E3=81=8C=E7=84=A1=E3=81=84?= =?UTF-8?q?=E3=81=A8=E3=81=8D=E3=81=AE=E5=87=A6=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/schema/bufferView.schema.json#L24 --- Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs index f37401fb5..614dc3ad2 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; namespace UniGLTF { @@ -156,7 +157,7 @@ namespace UniGLTF { var segment = GetBytesFromBuffer(view.buffer); var attrib = new T[count]; - var bytes = new ArraySegment(segment.Array, segment.Offset + view.byteOffset + byteOffset, count * view.byteStride); + var bytes = new ArraySegment(segment.Array, segment.Offset + view.byteOffset + byteOffset, count * Marshal.SizeOf()); SafeMarshalCopy.CopyBytesToArray(bytes, attrib); return attrib; } @@ -288,7 +289,7 @@ namespace UniGLTF var attrib = new float[vertexAccessor.count * vertexAccessor.TypeCount]; var view = GLTF.bufferViews[vertexAccessor.bufferView]; var segment = GetBytesFromBuffer(view.buffer); - var bytes = new ArraySegment(segment.Array, segment.Offset + view.byteOffset + vertexAccessor.byteOffset, vertexAccessor.count * view.byteStride); + var bytes = new ArraySegment(segment.Array, segment.Offset + view.byteOffset + vertexAccessor.byteOffset, vertexAccessor.count * 4 * vertexAccessor.TypeCount); SafeMarshalCopy.CopyBytesToArray(bytes, attrib); result = attrib; }