diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs index 0c316d4da..3f3c40ff5 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/BufferAccessor.cs @@ -80,13 +80,13 @@ namespace UniGLTF public NativeArray Bytes { get; private set; } - public AccessorValueType ComponentType; + public AccessorValueType ComponentType { get; private set; } - public AccessorVectorType AccessorType; + public AccessorVectorType AccessorType { get; private set; } public int Stride => ComponentType.ByteSize() * AccessorType.TypeCount(); - public int Count; + public int Count { get; private set; } public int ByteLength => Stride * Count; diff --git a/Assets/VRM10/vrmlib/Runtime/Mesh.cs b/Assets/VRM10/vrmlib/Runtime/Mesh.cs index 0751bc610..8f6169aa2 100644 --- a/Assets/VRM10/vrmlib/Runtime/Mesh.cs +++ b/Assets/VRM10/vrmlib/Runtime/Mesh.cs @@ -62,139 +62,10 @@ namespace VrmLib public BufferAccessor IndexBuffer; - /// - /// indicesの最大値が65535未満(-1を避ける)ならばushort 型で、 - /// そうでなければ int型で IndexBufferを代入する - /// - public void AssignIndexBuffer(NativeArray indices) - { - bool isInt = false; - foreach (var i in indices) - { - if (i >= short.MaxValue) - { - isInt = true; - break; - } - } - - if (isInt) - { - if (IndexBuffer.Stride != 4) - { - IndexBuffer.ComponentType = AccessorValueType.UNSIGNED_INT; - if (IndexBuffer.AccessorType != AccessorVectorType.SCALAR) - { - throw new Exception(); - } - } - // 変換なし - IndexBuffer.Assign(indices); - } - else - { - // int to ushort - IndexBuffer.AssignAsShort(indices); - } - } - public TopologyType Topology = TopologyType.Triangles; public List Submeshes { private set; get; } = new List(); - public int SubmeshTotalDrawCount => Submeshes.Sum(x => x.DrawCount); - - public IEnumerable GetTriangles(int i) - { - var indices = IndexBuffer.GetAsIntArray(); - - var submesh = Submeshes[i]; - var submeshEnd = submesh.Offset + submesh.DrawCount; - for (int j = submesh.Offset; j < submeshEnd; j += 3) - { - var triangle = new Triangle( - indices[j], - indices[j + 1], - indices[j + 2] - ); - yield return triangle; - } - } - - public IEnumerable> Triangles - { - get - { - if (Topology != TopologyType.Triangles) - { - throw new InvalidOperationException(); - } - - var indices = IndexBuffer.GetAsIntArray(); - - for (int i = 0; i < Submeshes.Count; ++i) - { - var submesh = Submeshes[i]; - var submeshEnd = submesh.Offset + submesh.DrawCount; - for (int j = submesh.Offset; j < submeshEnd; j += 3) - { - var triangle = new Triangle( - indices[j], - indices[j + 1], - indices[j + 2] - ); - yield return (i, triangle); - } - } - } - } - - bool GetSubmeshOverlapped() where T : struct - { - var indices = IndexBuffer.GetSpan(); - var offset = 0; - var max = 0; - foreach (var x in Submeshes) - { - var submeshIndices = indices.Slice(offset, x.DrawCount); - var currentMax = 0; - foreach (var y in submeshIndices) - { - if (y < max) - { - return true; - } - currentMax = Math.Max(y, currentMax); - } - offset += x.DrawCount; - max = currentMax; - } - return false; - } - - public bool IsSubmeshOverlapped - { - get - { - if (Submeshes.Count <= 1) - { - return false; - } - - switch (IndexBuffer.ComponentType) - { - case AccessorValueType.UNSIGNED_SHORT: - return GetSubmeshOverlapped(); - - case AccessorValueType.UNSIGNED_INT: - return GetSubmeshOverlapped(); - - default: - throw new NotImplementedException(); - } - } - } - public List MorphTargets = new List(); public override string ToString() @@ -238,11 +109,6 @@ namespace VrmLib Topology = topology; } - public void RemoveUnusedSubmesh() - { - Submeshes = Submeshes.Where(x => x.DrawCount != 0).ToList(); - } - // Skin.Normalize public void ApplyRotationAndScaling(Matrix4x4 m) {