From b80383bdd92601d8452fb592608a7fa8184f11b1 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Thu, 5 Sep 2024 20:16:33 -0400 Subject: [PATCH] Fix sub mesh generating having incorrect offsets --- .../Bfres/Editing/ModelConversion/BfresModelImporter.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs b/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs index 958a0bf..d90b9e3 100644 --- a/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs +++ b/Plugins/CafeLibrary/Bfres/Editing/ModelConversion/BfresModelImporter.cs @@ -524,9 +524,8 @@ static void CalculateMeshDivision(List vertices, Shape fshp, Mesh mesh fshp.SubMeshBoundingNodes.Clear(); fshp.SubMeshBoundings.Clear(); - int offset = 0; foreach (var root in divided) - AddSubMesh(root, ref fshp, ref mesh, ref offset, ref indexList); + AddSubMesh(root, ref fshp, ref mesh, ref indexList); Console.WriteLine($"fshp {fshp.Name} submeshes {mesh.SubMeshes.Count}"); @@ -603,9 +602,9 @@ private static void NormalizeByteType(IEnumerable weights) } } - static void AddSubMesh(DivSubMesh subMesh, ref Shape shape, ref Mesh mesh, ref int offset, ref List indexList) + static void AddSubMesh(DivSubMesh subMesh, ref Shape shape, ref Mesh mesh, ref List indexList) { - offset += indexList.Count; + var offset = indexList.Count; indexList.AddRange(subMesh.Faces.Select(x => (uint)x).ToList()); int index = mesh.SubMeshes.Count;