Skip to content

Commit

Permalink
Merge ignore-hull
Browse files Browse the repository at this point in the history
  • Loading branch information
discosultan committed Feb 12, 2017
2 parents 64c818a + 84ed5ef commit 1115be3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
9 changes: 7 additions & 2 deletions Source/Graphics/Renderers/ShadowRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,15 @@ public void Dispose()
for (int i = 0; i < hullCount; i++)
{
Hull hull = _engine.Hulls[i];
if (!hull.Enabled || !hull.Valid || !light.Intersects(hull))
if (!hull.Enabled ||
!hull.Valid ||
light.IgnoredHulls.Contains(hull) ||
!light.Intersects(hull))
{
continue;
}

Polygon points = hull.WorldPoints;
Polygon points = hull.WorldPoints;

Vector2 prevPoint = points[points.Count - 1];

Expand Down
8 changes: 6 additions & 2 deletions Source/Hull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,14 @@ public bool Contains(Light light)
for (int i = 0; i < hullCount; i++)
{
Hull hull = this[i];
// If hull is valid and enabled:
// If hull is not ignored by light, valid and enabled:
// 1. test AABB intersection
// 2. test point is contained in polygon
if (hull.Enabled && hull.Valid && light.Bounds.Intersects(ref hull.Bounds) && hull.WorldPoints.Contains(ref light._position))
if (!light.IgnoredHulls.Contains(hull) &&
hull.Enabled &&
hull.Valid &&
light.Bounds.Intersects(ref hull.Bounds) &&
hull.WorldPoints.Contains(ref light._position))
return true;
}
return false;
Expand Down
8 changes: 7 additions & 1 deletion Source/Light.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Penumbra.Geometry;
Expand Down Expand Up @@ -185,7 +186,12 @@ public float Radius
/// Gets or sets how the shadow <see cref="Hull"/>s are shadowed. See
/// <see cref="ShadowType"/> for more information.
/// </summary>
public ShadowType ShadowType { get; set; } = ShadowType.Illuminated;
public ShadowType ShadowType { get; set; } = ShadowType.Illuminated;

/// <summary>
/// Gets a list of hulls not participating in the light's shadow casting process.
/// </summary>
public List<Hull> IgnoredHulls { get; } = new List<Hull>();

// Cleared by the engine. Used by other systems to know if the light's world transform has changed.
internal bool Dirty;
Expand Down

0 comments on commit 1115be3

Please sign in to comment.