v1.6.17.0 (Unto the Breach update)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Barotrauma.Items.Components;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,6 +12,7 @@ namespace Barotrauma.Lights
|
||||
|
||||
public readonly Submarine Submarine;
|
||||
public HashSet<ConvexHull> IsHidden = new HashSet<ConvexHull>();
|
||||
public HashSet<ConvexHull> HasBeenVisible = new HashSet<ConvexHull>();
|
||||
public readonly List<ConvexHull> List = new List<ConvexHull>();
|
||||
|
||||
public ConvexHullList(Submarine submarine)
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
private readonly List<LightSource> activeLights = new List<LightSource>(capacity: 100);
|
||||
private readonly List<LightSource> activeLightsWithLightVolume = new List<LightSource>(capacity: 100);
|
||||
private readonly List<LightSource> activeShadowCastingLights = new List<LightSource>(capacity: 100);
|
||||
|
||||
public static int ActiveLightCount { get; private set; }
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
//above the top boundary of the level (in an inactive respawn shuttle?)
|
||||
if (Level.Loaded != null && light.WorldPosition.Y > Level.Loaded.Size.Y) { continue; }
|
||||
if (Level.IsPositionAboveLevel(light.WorldPosition)) { continue; }
|
||||
|
||||
float range = light.LightSourceParams.TextureRange;
|
||||
if (light.LightSprite != null)
|
||||
@@ -315,19 +315,20 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
//find the lights with an active light volume
|
||||
activeLightsWithLightVolume.Clear();
|
||||
activeShadowCastingLights.Clear();
|
||||
foreach (var activeLight in activeLights)
|
||||
{
|
||||
if (!activeLight.CastShadows) { continue; }
|
||||
if (activeLight.Range < 1.0f || activeLight.Color.A < 1 || activeLight.CurrentBrightness <= 0.0f) { continue; }
|
||||
activeLightsWithLightVolume.Add(activeLight);
|
||||
activeShadowCastingLights.Add(activeLight);
|
||||
}
|
||||
|
||||
//remove some lights with a light volume if there's too many of them
|
||||
if (activeLightsWithLightVolume.Count > GameSettings.CurrentConfig.Graphics.VisibleLightLimit && Screen.Selected is { IsEditor: false })
|
||||
if (activeShadowCastingLights.Count > GameSettings.CurrentConfig.Graphics.VisibleLightLimit && Screen.Selected is { IsEditor: false })
|
||||
{
|
||||
for (int i = GameSettings.CurrentConfig.Graphics.VisibleLightLimit; i < activeLightsWithLightVolume.Count; i++)
|
||||
for (int i = GameSettings.CurrentConfig.Graphics.VisibleLightLimit; i < activeShadowCastingLights.Count; i++)
|
||||
{
|
||||
activeLights.Remove(activeLightsWithLightVolume[i]);
|
||||
activeLights.Remove(activeShadowCastingLights[i]);
|
||||
}
|
||||
}
|
||||
activeLights.Sort((l1, l2) => l1.LastRecalculationTime.CompareTo(l2.LastRecalculationTime));
|
||||
@@ -827,7 +828,7 @@ namespace Barotrauma.Lights
|
||||
public void ClearLights()
|
||||
{
|
||||
activeLights.Clear();
|
||||
activeLightsWithLightVolume.Clear();
|
||||
activeShadowCastingLights.Clear();
|
||||
lights.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Extensions;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -245,7 +245,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!needsRecalculation && value)
|
||||
if (value)
|
||||
{
|
||||
foreach (ConvexHullList chList in convexHullsInRange)
|
||||
{
|
||||
@@ -550,7 +550,6 @@ namespace Barotrauma.Lights
|
||||
chList.List.Clear();
|
||||
foreach (var convexHull in fullChList.List)
|
||||
{
|
||||
if (!convexHull.Enabled) { continue; }
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, TextureRange, convexHull.BoundingBox)) { continue; }
|
||||
if (lightSourceParams.Directional)
|
||||
{
|
||||
@@ -572,6 +571,7 @@ namespace Barotrauma.Lights
|
||||
chList.List.Add(convexHull);
|
||||
}
|
||||
chList.IsHidden.RemoveWhere(ch => !chList.List.Contains(ch));
|
||||
chList.HasBeenVisible.RemoveWhere(ch => !chList.List.Contains(ch));
|
||||
HullsUpToDate.Add(sub);
|
||||
}
|
||||
|
||||
@@ -604,7 +604,8 @@ namespace Barotrauma.Lights
|
||||
|
||||
foreach (var ch in chList.List)
|
||||
{
|
||||
if (ch.LastVertexChangeTime > LastRecalculationTime && !chList.IsHidden.Contains(ch))
|
||||
if (ch.LastVertexChangeTime > LastRecalculationTime &&
|
||||
(!chList.IsHidden.Contains(ch) || chList.HasBeenVisible.Contains(ch)))
|
||||
{
|
||||
NeedsRecalculation = true;
|
||||
break;
|
||||
@@ -712,8 +713,8 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
foreach (ConvexHull hull in chList.List)
|
||||
{
|
||||
if (hull.IsInvalid) { continue; }
|
||||
if (!chList.IsHidden.Contains(hull))
|
||||
if (hull.IsInvalid || !hull.Enabled) { continue; }
|
||||
if (!chList.IsHidden.Contains(hull) || chList.HasBeenVisible.Contains(hull))
|
||||
{
|
||||
//find convexhull segments that are close enough and facing towards the light source
|
||||
lock (mutex)
|
||||
@@ -732,7 +733,17 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
foreach (ConvexHull hull in chList.List)
|
||||
{
|
||||
chList.IsHidden.Add(hull);
|
||||
if (!hull.Enabled)
|
||||
{
|
||||
//if the hull is not enabled, we cannot determine if it's visible or hidden from the point of view of the light source
|
||||
//so let's not mark it as hidden, but instead consider it as something that has been visible, so we know to recalculate if/when it becomes enabled again
|
||||
chList.IsHidden.Remove(hull);
|
||||
chList.HasBeenVisible.Add(hull);
|
||||
continue;
|
||||
}
|
||||
|
||||
//mark convex hulls as hidden at this point, they're removed if we find any of the segments to be visible
|
||||
chList.IsHidden.Add(hull);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1411,14 +1422,7 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (conditionals.None()) { return; }
|
||||
if (conditionalTarget == null) { return; }
|
||||
if (logicalOperator == PropertyConditional.LogicalOperatorType.And)
|
||||
{
|
||||
Enabled = conditionals.All(c => c.Matches(conditionalTarget));
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = conditionals.Any(c => c.Matches(conditionalTarget));
|
||||
}
|
||||
Enabled = PropertyConditional.CheckConditionals(conditionalTarget, conditionals, logicalOperator);
|
||||
}
|
||||
|
||||
public void DebugDrawVertices(SpriteBatch spriteBatch)
|
||||
@@ -1501,6 +1505,7 @@ namespace Barotrauma.Lights
|
||||
foreach (var convexHullList in convexHullsInRange)
|
||||
{
|
||||
convexHullList.IsHidden.Remove(visibleConvexHull);
|
||||
convexHullList.HasBeenVisible.Add(visibleConvexHull);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user