From 8aa1c7c4bce36deec7a3f8b7f62da8f6d3608b5b Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sun, 25 Aug 2024 13:21:55 +0100 Subject: [PATCH] Don't render objects marked not rendered --- project/code/TMV/Mission.cs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/project/code/TMV/Mission.cs b/project/code/TMV/Mission.cs index 0d081a6..cd83eb4 100644 --- a/project/code/TMV/Mission.cs +++ b/project/code/TMV/Mission.cs @@ -97,7 +97,6 @@ public partial class Mission : Node3D { ClearMap(); - // TODO: This shouldn't be set for things that aren't actually FMs _textureLoader = new TextureLoader(_campaignName); _file = new(FileName); UseChunk("TXLIST", LoadTextures); @@ -106,6 +105,7 @@ public partial class Mission : Node3D _file.Chunks.TryGetValue("BRLIST", out var brListRaw) && _file.Chunks.TryGetValue("P$ModelName", out var modelNamesRaw) && _file.Chunks.TryGetValue("P$Scale", out var scalesRaw) && + _file.Chunks.TryGetValue("P$RenderTyp", out var renderTypesRaw) && _file.Chunks.TryGetValue("L$MetaProp", out var metaPropLinksRaw) && _file.Chunks.TryGetValue("LD$MetaProp", out var metaPropLinkDataRaw) ) @@ -113,6 +113,7 @@ public partial class Mission : Node3D var brList = (BrList)brListRaw; var modelNames = (PropertyChunk)modelNamesRaw; var scales = (PropertyChunk)scalesRaw; + var renderTypes = (PropertyChunk)renderTypesRaw; var metaPropLinks = (LinkChunk)metaPropLinksRaw; var metaPropLinkData = (LinkDataMetaProp)metaPropLinkDataRaw; @@ -133,19 +134,21 @@ public partial class Mission : Node3D if (gamFile.Chunks.TryGetValue("P$ModelName", out var gamChunk1) && gamFile.Chunks.TryGetValue("L$MetaProp", out var gamChunk2) && gamFile.Chunks.TryGetValue("LD$MetaProp", out var gamChunk3) && - gamFile.Chunks.TryGetValue("P$Scale", out var gamChunk4)) + gamFile.Chunks.TryGetValue("P$Scale", out var gamChunk4) && + gamFile.Chunks.TryGetValue("P$RenderTyp", out var gamChunk5)) { GD.Print($"Pre-Merged chunks: {modelNames.properties.Count} {metaPropLinks.links.Count} {metaPropLinkData.linkData.Count}"); modelNames.properties.AddRange(((PropertyChunk)gamChunk1).properties); metaPropLinks.links.AddRange(((LinkChunk)gamChunk2).links); metaPropLinkData.linkData.AddRange(((LinkDataMetaProp)gamChunk3).linkData); scales.properties.AddRange(((PropertyChunk)gamChunk4).properties); + renderTypes.properties.AddRange(((PropertyChunk)gamChunk5).properties); GD.Print($"Post-Merged chunks: {modelNames.properties.Count} {metaPropLinks.links.Count} {metaPropLinkData.linkData.Count}"); } } } - PlaceObjects(brList, modelNames, scales, metaPropLinks, metaPropLinkData); + PlaceObjects(brList, modelNames, scales, renderTypes, metaPropLinks, metaPropLinkData); } } @@ -165,6 +168,7 @@ public partial class Mission : Node3D BrList brList, PropertyChunk modelNames, PropertyChunk scales, + PropertyChunk renderTypes, LinkChunk metapropLink, LinkDataMetaProp metaPropLinkData) { @@ -182,6 +186,8 @@ public partial class Mission : Node3D var modelName = ""; var scale = Vector3.One; var scaleFound = false; + var renderType = PropRenderType.Mode.Normal; + var renderTypeFound = false; while (true) { // See if there's a modelname property @@ -210,7 +216,20 @@ public partial class Mission : Node3D } } - if (modelName != "" && scaleFound) + if (!renderTypeFound) + { + foreach (var prop in renderTypes.properties) + { + if (prop.objectId == id) + { + renderType = prop.mode; + renderTypeFound = true; + break; + } + } + } + + if (modelName != "" && scaleFound && renderTypeFound) { break; } @@ -234,7 +253,7 @@ public partial class Mission : Node3D break; } } - if (modelName == "") + if (modelName == "" || renderType == PropRenderType.Mode.NotRendered) { continue; }