From ead65ebd939e9f38d30305022247a20fef828da5 Mon Sep 17 00:00:00 2001 From: spherallic Date: Fri, 6 Jan 2023 12:01:43 +0100 Subject: [PATCH] hashset effectsectors --- .../VisualModes/BaseVisualMode.cs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 59d51d1..57acca5 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -791,20 +791,17 @@ namespace CodeImp.DoomBuilder.BuilderModes internal void RebuildElementData() { //mxd - Sector[] sectorsWithEffects = null; + HashSet effectsectors = null; bsp.Build(); useblockmap = bsp.IsDeactivated; if (!General.Settings.GZDoomRenderingEffects) { - //store all sectors with effects + //Store all sectors with effects if(sectordata != null && sectordata.Count > 0) - { - sectorsWithEffects = new Sector[sectordata.Count]; - sectordata.Keys.CopyTo(sectorsWithEffects, 0); - } + effectsectors = new HashSet(sectordata.Keys); - //remove all vertex handles from selection + //Remove all vertex handles from selection if(vertices != null && vertices.Count > 0) { foreach(IVisualEventReceiver i in selectedobjects) @@ -823,17 +820,16 @@ namespace CodeImp.DoomBuilder.BuilderModes MessageBox.Show("Could not load the map's nodes: " + bsp.ErrorMessage + " Defaulting to blockmap.", "Error loading nodes!", MessageBoxButtons.OK, MessageBoxIcon.Error); - //mxd. rebuild all sectors with effects - if (sectorsWithEffects != null) + //mxd. Rebuild all sectors with effects + if (effectsectors != null) { - for(int i = 0; i < sectorsWithEffects.Length; i++) + foreach (Sector s in effectsectors) { + if (!VisualSectorExists(s)) continue; + // The visual sector associated is now outdated - if(VisualSectorExists(sectorsWithEffects[i])) - { - BaseVisualSector vs = (BaseVisualSector)GetVisualSector(sectorsWithEffects[i]); - vs.UpdateSectorGeometry(true); - } + BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s); + vs.UpdateSectorGeometry(true); } }