From d57102271dd742fea7b98ba7d33782187306244a Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 5 Mar 2018 18:16:51 +0200 Subject: [PATCH] Fixed exceptions when trying to render LOS with no convex hulls within the view --- .../Source/Map/Lights/LightManager.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs index 017d7755b..d8405163e 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Lights/LightManager.cs @@ -309,14 +309,19 @@ namespace Barotrauma.Lights penumbraVerts.AddRange(convexHull.PenumbraVertices); } - ConvexHull.shadowEffect.World = shadowTransform; - ConvexHull.shadowEffect.CurrentTechnique.Passes[0].Apply(); - graphics.DrawUserPrimitives(PrimitiveType.TriangleList, shadowVerts.ToArray(), 0, shadowVerts.Count / 3, VertexPositionColor.VertexDeclaration); - - ConvexHull.penumbraEffect.World = shadowTransform; - ConvexHull.penumbraEffect.CurrentTechnique.Passes[0].Apply(); - graphics.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVerts.ToArray(), 0, penumbraVerts.Count / 3, VertexPositionTexture.VertexDeclaration); + if (shadowVerts.Count > 0) + { + ConvexHull.shadowEffect.World = shadowTransform; + ConvexHull.shadowEffect.CurrentTechnique.Passes[0].Apply(); + graphics.DrawUserPrimitives(PrimitiveType.TriangleList, shadowVerts.ToArray(), 0, shadowVerts.Count / 3, VertexPositionColor.VertexDeclaration); + if (penumbraVerts.Count > 0) + { + ConvexHull.penumbraEffect.World = shadowTransform; + ConvexHull.penumbraEffect.CurrentTechnique.Passes[0].Apply(); + graphics.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVerts.ToArray(), 0, penumbraVerts.Count / 3, VertexPositionTexture.VertexDeclaration); + } + } } } graphics.SetRenderTarget(null);