- Fixed shadows not being cast if the lightsource is outside the sub and the convexhull is not

- Option to change the texture of the "light sphere"
- Added "headlights" to the scooters
This commit is contained in:
Regalis
2016-05-03 00:27:48 +03:00
parent 26608d3f82
commit 03626c997b
9 changed files with 122 additions and 47 deletions
+4 -7
View File
@@ -2,6 +2,7 @@
using Microsoft.Xna.Framework.Graphics;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Barotrauma.Lights
{
@@ -122,7 +123,7 @@ namespace Barotrauma.Lights
foreach (LightSource light in lights)
{
if (light.hullsInRange.Count == 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue;
if (!light.hullsInRange.Any() || light.Color.A < 0.01f || light.Range < 1.0f) continue;
if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
//clear alpha to 1
@@ -135,7 +136,7 @@ namespace Barotrauma.Lights
foreach (ConvexHull ch in light.hullsInRange)
{
if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue;
//if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue;
//draw shadow
ch.DrawShadows(graphics, cam, light, shadowTransform, false);
}
@@ -152,7 +153,7 @@ namespace Barotrauma.Lights
foreach (LightSource light in lights)
{
if (light.hullsInRange.Count > 0 || light.Color.A < 0.01f) continue;
if (light.hullsInRange.Any() || light.Color.A < 0.01f) continue;
//if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
light.Draw(spriteBatch);
@@ -163,10 +164,6 @@ namespace Barotrauma.Lights
//clear alpha, to avoid messing stuff up later
ClearAlphaToOne(graphics, spriteBatch);
graphics.SetRenderTarget(null);
if (!ObstructVision) return;
}
public void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 lookAtPosition)