diff --git a/Source/Core/Editing/NullThingsFilter.cs b/Source/Core/Editing/NullThingsFilter.cs index e9cc7d2b73d52132c1f1447dea4e56f53e1a8a24..3a9f7972a35f54b5f93b3fcfec3fd5314e0ec129 100644 --- a/Source/Core/Editing/NullThingsFilter.cs +++ b/Source/Core/Editing/NullThingsFilter.cs @@ -63,6 +63,8 @@ namespace CodeImp.DoomBuilder.Editing // Make lists visiblethings = new List<Thing>(General.Map.Map.Things); hiddenthings = new List<Thing>(0); + thingsvisiblestate = new Dictionary<Thing, bool>(General.Map.Map.Things.Count); + foreach(Thing t in visiblethings) thingsvisiblestate.Add(t, true); } #endregion diff --git a/Source/Core/Editing/ThingsFilter.cs b/Source/Core/Editing/ThingsFilter.cs index 6fea498dcea5d5af073ef1cf375c6cc3aebbb8eb..97a254821558309fa3fa3e641ac8569e51ede0aa 100644 --- a/Source/Core/Editing/ThingsFilter.cs +++ b/Source/Core/Editing/ThingsFilter.cs @@ -56,6 +56,7 @@ namespace CodeImp.DoomBuilder.Editing // List of things protected List<Thing> visiblethings; protected List<Thing> hiddenthings; + protected Dictionary<Thing, bool> thingsvisiblestate; // Disposing protected bool isdisposed = false; @@ -142,6 +143,7 @@ namespace CodeImp.DoomBuilder.Editing // Clean up visiblethings = null; hiddenthings = null; + thingsvisiblestate = null; // Done isdisposed = true; @@ -152,6 +154,14 @@ namespace CodeImp.DoomBuilder.Editing #region ================== Methods + /// <summary> + /// This checks if a thing is visible. Throws an exception when the specified Thing does not exist in the map (filter not updated?). + /// </summary> + public bool IsThingVisible(Thing t) + { + return thingsvisiblestate[t]; + } + // This writes the filter to configuration internal void WriteSettings(Configuration cfg, string path) { @@ -182,14 +192,18 @@ namespace CodeImp.DoomBuilder.Editing // Clear lists visiblethings = null; hiddenthings = null; + thingsvisiblestate = null; } - // This updates the list of things + /// <summary> + /// This updates the list of things. + /// </summary> public virtual void Update() { // Make new list visiblethings = new List<Thing>(General.Map.Map.Things.Count); hiddenthings = new List<Thing>(General.Map.Map.Things.Count); + thingsvisiblestate = new Dictionary<Thing, bool>(General.Map.Map.Things.Count); foreach(Thing t in General.Map.Map.Things) { bool qualifies; @@ -243,8 +257,9 @@ namespace CodeImp.DoomBuilder.Editing } } - // Put the thing in the correct list + // Put the thing in the lists if(qualifies) visiblethings.Add(t); else hiddenthings.Add(t); + thingsvisiblestate.Add(t, qualifies); } } diff --git a/Source/Core/VisualModes/VisualMode.cs b/Source/Core/VisualModes/VisualMode.cs index 23c2f35da2c3d4508184b46a53c852a6c3a3069e..ba9b2d1b3b9b8f55f894a432f01609004f315deb 100644 --- a/Source/Core/VisualModes/VisualMode.cs +++ b/Source/Core/VisualModes/VisualMode.cs @@ -341,20 +341,24 @@ namespace CodeImp.DoomBuilder.VisualModes { VisualThing vt; - if(allthings.ContainsKey(t)) + // Not filtered out? + if(General.Map.ThingsFilter.IsThingVisible(t)) { - vt = allthings[t]; - } - else - { - // Create new visual thing - vt = CreateVisualThing(t); - if(vt != null) allthings.Add(t, vt); - } + if(allthings.ContainsKey(t)) + { + vt = allthings[t]; + } + else + { + // Create new visual thing + vt = CreateVisualThing(t); + if(vt != null) allthings.Add(t, vt); + } - if(vt != null) - { - visiblethings.Add(vt); + if(vt != null) + { + visiblethings.Add(vt); + } } } }