Lighting bugfixes, setting camera position to character on shift start

This commit is contained in:
Regalis
2015-12-26 22:35:28 +02:00
parent 064e2eadd0
commit 8c032d8368
10 changed files with 49 additions and 26 deletions

View File

@@ -148,6 +148,8 @@ namespace Barotrauma.Lights
cachedShadows.Clear();
vertices = points;
CalculateDimensions();
}
public bool Intersects(Rectangle rect)
@@ -307,6 +309,7 @@ namespace Barotrauma.Lights
else
{
cachedShadow = new CachedShadow(shadowVertices, penumbraVertices, light.Position, shadowVertexCount, 0);
cachedShadows.Remove(light);
cachedShadows.Add(light, cachedShadow);
}
}
@@ -350,7 +353,7 @@ namespace Barotrauma.Lights
else
{
shadowEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, shadowVertexCount);
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, shadowVertexCount*2 - 2);
}
}

View File

@@ -21,6 +21,9 @@ namespace Barotrauma.Lights
public Entity Submarine;
//what was the range of the light when HullsInRange were last updated
private float prevHullUpdateRange;
private Vector2 position;
public Vector2 Position
{
@@ -64,11 +67,11 @@ namespace Barotrauma.Lights
set
{
float prevRange = range;
range = MathHelper.Clamp(value, 0.0f, 2048.0f);
if (Math.Abs(prevRange - range)<5.0f) return;
if (Math.Abs(prevHullUpdateRange - range)>5.0f) return;
UpdateHullsInRange();
prevHullUpdateRange = range;
}
}