From 011969753374e3b8bfa3d69f87b7841954ab11f5 Mon Sep 17 00:00:00 2001 From: Campbell Suter Date: Fri, 15 Jul 2022 12:55:33 +1200 Subject: [PATCH] gltf-export: Set the material group of overwritten models Without this, any RenderAtoms would have material IDs corresponding to the created-but-not-installed-to-model MaterialGroup's materials, rather than those already in the model. This could be seen with players, where their head would disappear since it became the 'mtl_hair' material instead of 'mtl_head'. --- PD2ModelParser/Importers/GltfImporter.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PD2ModelParser/Importers/GltfImporter.cs b/PD2ModelParser/Importers/GltfImporter.cs index 7c9e8af..003ca94 100644 --- a/PD2ModelParser/Importers/GltfImporter.cs +++ b/PD2ModelParser/Importers/GltfImporter.cs @@ -212,9 +212,9 @@ void OverwriteModel(GLTF.Mesh gmesh, DM.Model model) var matGroup = new DM.MaterialGroup(mats); data.AddSection(matGroup); + model.MaterialGroup = matGroup; var ms = new MeshSections(); - ms.matg = matGroup; ms.topoip = model.TopologyIP; ms.passgp = model.PassthroughGP; ms.geom = ms.passgp.Geometry; @@ -286,7 +286,6 @@ DM.Model CreateNewModel(GLTF.Mesh gmesh, string name) data.AddSection(matGroup); var ms = new MeshSections(); - ms.matg = matGroup; ms.geom = new DM.Geometry(); data.AddSection(ms.geom); @@ -306,7 +305,7 @@ DM.Model CreateNewModel(GLTF.Mesh gmesh, string name) ms.PopulateFromMeshData(md); ms.Scale(this.scaleFactor); - var model = new DM.Model(name, (uint)ms.geom.verts.Count, (uint)ms.topo.facelist.Count, ms.passgp, ms.topoip, ms.matg, null); + var model = new DM.Model(name, (uint)ms.geom.verts.Count, (uint)ms.topo.facelist.Count, ms.passgp, ms.topoip, matGroup, null); model.RenderAtoms = md.renderAtoms; return model; @@ -484,7 +483,6 @@ public class MeshSections public DM.Topology topo; public DM.TopologyIP topoip; public DM.PassthroughGP passgp; - public DM.MaterialGroup matg; public List atoms = new List(); public void PopulateFromMeshData(MeshData md)