Merge pull request #1374 from ousttrue/fix10/fix_indexFormat

[1.0] indices が 65535 を超える場合に indexFormat をセットする
This commit is contained in:
ousttrue
2021-11-11 18:48:33 +09:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -16,6 +16,10 @@ namespace UniVRM10
{
// submesh 方式
var mesh = new UnityEngine.Mesh();
if (src.IndexBuffer.Count > UInt16.MaxValue)
{
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
}
mesh.vertices = src.VertexBuffer.Positions.GetSpan<Vector3>().ToArray();
mesh.normals = src.VertexBuffer.Normals?.GetSpan<Vector3>().ToArray();

View File

@@ -10,6 +10,10 @@ namespace UniVRM10
public static UnityEngine.Mesh LoadDivided(VrmLib.MeshGroup src)
{
var dst = new UnityEngine.Mesh();
if (src.Meshes.Sum(x => x.IndexBuffer.Count) > ushort.MaxValue)
{
dst.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
}
//
// vertices