From 2ba339035c5465ba869c81fe0e32fbaa9bf95754 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Fri, 12 Jan 2018 16:17:02 +0200 Subject: [PATCH] Fixed LOS lightsource keeping references to already unloaded convex hulls and subs, causing the los effects of the previously loaded subs to be always rendered. --- .../Source/Map/Lights/LightManager.cs | 1 + .../Source/Map/Lights/LightSource.cs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs index 0cd602cac..9d2ed314f 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs @@ -370,6 +370,7 @@ namespace Barotrauma.Lights public void ClearLights() { lights.Clear(); + losSource.Reset(); } } diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs index 07bd5dd0a..3bf19416c 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightSource.cs @@ -641,6 +641,28 @@ namespace Barotrauma.Lights ); } + public void Reset() + { + hullsInRange.Clear(); + diffToSub.Clear(); + NeedsHullCheck = true; + NeedsRecalculation = true; + + vertexCount = 0; + if (lightVolumeBuffer != null) + { + lightVolumeBuffer.Dispose(); + lightVolumeBuffer = null; + } + + indexCount = 0; + if (lightVolumeIndexBuffer != null) + { + lightVolumeIndexBuffer.Dispose(); + lightVolumeIndexBuffer = null; + } + } + public void Remove() { if (LightSprite != null) LightSprite.Remove();