From 7f5c3d8b18c98b466f22e413ebecf1a3f2b0cf72 Mon Sep 17 00:00:00 2001 From: Kirill <95088806+kirill-mapper@users.noreply.github.com> Date: Thu, 16 Jan 2025 00:08:49 +0300 Subject: [PATCH 1/2] Fix Render GtaV Map & Project Items in ProjectForm.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Render of hiding map and project items became public Logic ymap.HasСhange is now clear to the logic that this is a map in the project Disabled deleting a map, which broke the LOD hierarchy of objects in the project, after enabling --- CodeWalker/Project/ProjectForm.cs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/CodeWalker/Project/ProjectForm.cs b/CodeWalker/Project/ProjectForm.cs index 367ff83c9..2981859f6 100644 --- a/CodeWalker/Project/ProjectForm.cs +++ b/CodeWalker/Project/ProjectForm.cs @@ -92,8 +92,8 @@ public bool IsProjectLoaded - private bool renderitems = true; - private bool hidegtavmap = false; + public static bool renderitems = true; + public static bool hidegtavmap = false; private bool autoymapflags = true; private bool autoymapextents = true; public bool displayentityindexes = false; @@ -1393,6 +1393,7 @@ public void CloseProject() CurrentYmapFile = ymap; SaveYmap(); } + ymap.HasChanged = false; } } @@ -1519,6 +1520,15 @@ public void CloseProject() } + if (!renderitems) + { + renderitems = true; + } + + if (hidegtavmap) + { + hidegtavmap = false; + } if (WorldForm != null) { @@ -1614,7 +1624,11 @@ public void OpenFiles(string[] files = null) { case ".ymap": var ymap = CurrentProjectFile.AddYmapFile(file); - if (ymap != null) LoadYmapFromFile(ymap, file); + if (ymap != null) + { + LoadYmapFromFile(ymap, file); + ymap.HasChanged = true; + } break; case ".ytyp": var ytyp = CurrentProjectFile.AddYtypFile(file); @@ -1996,7 +2010,7 @@ public void SaveYmap(bool saveas = false) File.WriteAllBytes(filepath, data); } - SetYmapHasChanged(false); + SetYmapHasChanged(true); if (saveas) { @@ -2061,6 +2075,7 @@ public void RemoveYmapFromProject() { if (CurrentYmapFile == null) return; if (CurrentProjectFile == null) return; + CurrentYmapFile.HasChanged = false; CurrentProjectFile.RemoveYmapFile(CurrentYmapFile); CurrentYmapFile = null; LoadProjectTree(); @@ -7214,10 +7229,10 @@ public bool YtdExistsInProject(YtdFile ytd) public void GetVisibleYmaps(Camera camera, Dictionary ymaps) { - if (hidegtavmap) - { - ymaps.Clear(); //remove all the gtav ymaps. - } + //if (hidegtavmap) + //{ + // ymaps.Clear(); //remove all the gtav ymaps. + //} lock (projectsyncroot) { From 1a8bdb6fc57b95ab8ef64b0e870727bc5bbe2a07 Mon Sep 17 00:00:00 2001 From: Kirill <95088806+kirill-mapper@users.noreply.github.com> Date: Thu, 16 Jan 2025 00:23:21 +0300 Subject: [PATCH 2/2] Fix Render GtaV Map & Project Items in Renderer.cs Hiding Map and Project Items Metod: HideGtavMap: When enabled, only modified project objects are shown When disabled, all objects are displayed in standard mode RenderItems: When disabled, all objects modified in the project are hidden When enabled, modified objects are displayed Working Principle: Objects are filtered during the update method based on these flags Modified objects are excluded from the list of visible objects Implemented through recursive visibility checking Main Purpose: Provide the ability to isolate the original GTA V map from project modifications and vice versa Key Features: Preserves LOD (Level of Detail) hierarchy Maintains original distance-based rendering logic Keeps the existing spatial relationships between objects --- CodeWalker/Rendering/Renderer.cs | 67 +++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/CodeWalker/Rendering/Renderer.cs b/CodeWalker/Rendering/Renderer.cs index afe3d1eda..20fa9c8b5 100644 --- a/CodeWalker/Rendering/Renderer.cs +++ b/CodeWalker/Rendering/Renderer.cs @@ -1,4 +1,5 @@ using CodeWalker.GameFiles; +using CodeWalker.Project; using CodeWalker.Properties; using CodeWalker.World; using SharpDX; @@ -4022,6 +4023,8 @@ public class RenderLodManager public bool ShowScriptedYmaps = true; public bool HDLightsEnabled = true; public bool LODLightsEnabled = true; + public bool RenderItems => ProjectForm.renderitems; + public bool HideGtavMap => ProjectForm.hidegtavmap; public Camera Camera = null; public Vector3 Position = Vector3.Zero; @@ -4061,10 +4064,10 @@ public void Update(Dictionary ymaps, Camera camera, float el { YmapFile ymap = null; if (!ymaps.TryGetValue(kvp.Key, out ymap) || (ymap != kvp.Value) || (ymap.IsScripted && !ShowScriptedYmaps) || (ymap.LodManagerUpdate)) - { - RemoveYmaps.Add(kvp.Key); + { + RemoveYmaps.Add(kvp.Key); + } } - } foreach (var remYmap in RemoveYmaps) { var ymap = CurrentYmaps[remYmap]; @@ -4075,16 +4078,16 @@ public void Update(Dictionary ymaps, Camera camera, float el for (int i = 0; i < remEnts.Length; i++) { var ent = remEnts[i]; - RootEntities.Remove(ent); - ent.LodManagerChildren?.Clear(); - ent.LodManagerChildren = null; - ent.LodManagerRenderable = null; - if ((ent.Parent != null) && (ent.Parent.Ymap != ymap)) - { - ent.Parent.LodManagerRemoveChild(ent); + RootEntities.Remove(ent); + ent.LodManagerChildren?.Clear(); + ent.LodManagerChildren = null; + ent.LodManagerRenderable = null; + if ((ent.Parent != null) && (ent.Parent.Ymap != ymap)) + { + ent.Parent.LodManagerRemoveChild(ent); + } } } - } var remLodLights = ymap.LODLights?.LodLights; if (remLodLights != null) { @@ -4136,18 +4139,33 @@ public void Update(Dictionary ymaps, Camera camera, float el VisibleLeaves.Clear(); VisibleLights.Clear(); - foreach (var kvp in RootEntities) + + if (HideGtavMap) { - var ent = kvp.Key; - if (EntityVisibleAtMaxLodLevel(ent)) + foreach (var kvp in CurrentYmaps) { - ent.Distance = MapViewEnabled ? MapViewDist : (ent.Position - Position).Length(); - if (ent.Distance <= (ent.LodDist * LodDistMult)) + var ymap = kvp.Value; + if (ymap.HasChanged && ymap.AllEntities != null) { - RecurseAddVisibleLeaves(ent); + if (!RenderItems) continue; + foreach (var ent in ymap.AllEntities) + { + ProcessEntitiesForVisibility(ent); + } } } } + else + { + foreach (var kvp in RootEntities) + { + var ent = kvp.Key; + if (ent.Ymap.HasChanged && !RenderItems) + continue; + + ProcessEntitiesForVisibility(ent); + } + } UpdateLodLights.Clear(); foreach (var light in VisibleLights) @@ -4178,7 +4196,17 @@ public void Update(Dictionary ymaps, Camera camera, float el VisibleLights = VisibleLightsPrev; VisibleLightsPrev = vl; } - + private void ProcessEntitiesForVisibility(YmapEntityDef ent) + { + if (EntityVisibleAtMaxLodLevel(ent)) + { + ent.Distance = MapViewEnabled ? MapViewDist : (ent.Position - Position).Length(); + if (ent.Distance <= (ent.LodDist * LodDistMult)) + { + RecurseAddVisibleLeaves(ent); + } + } + } private void RecurseAddVisibleLeaves(YmapEntityDef ent) { var clist = GetEntityChildren(ent); @@ -4195,6 +4223,9 @@ private void RecurseAddVisibleLeaves(YmapEntityDef ent) { if (EntityVisible(ent)) { + if (!RenderItems && ent.Ymap.HasChanged) + return; + VisibleLeaves.Add(ent); if (HDLightsEnabled && (ent.Lights != null))