Skip to content

Commit

Permalink
[Penumbra] Remove trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
discosultan committed Jun 10, 2017
1 parent b81384e commit 5fe346f
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 86 deletions.
22 changes: 11 additions & 11 deletions Source/Graphics/DynamicVao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ internal sealed class DynamicVao : Vao
{
private const int DefaultVertexCount = 32;

private readonly GraphicsDevice _graphicsDevice;
private readonly GraphicsDevice _graphicsDevice;

private int _currentVertexCount;
private int _currentIndexCount;
private int _vertexCountInUse;
private int _indexCountInUse;

private DynamicVao(
GraphicsDevice graphicsDevice,
GraphicsDevice graphicsDevice,
VertexDeclaration vertexDecl,
PrimitiveType primitiveTopology,
int initialVertexCount,
int initialIndexCount,
int initialIndexCount,
bool useIndices) : base(vertexDecl, primitiveTopology)
{
_graphicsDevice = graphicsDevice;
_graphicsDevice = graphicsDevice;

_currentVertexCount = initialVertexCount;
_currentIndexCount = initialIndexCount;
Expand All @@ -34,7 +34,7 @@ private DynamicVao(

public override int VertexCount => _vertexCountInUse;

public override int IndexCount => _indexCountInUse;
public override int IndexCount => _indexCountInUse;

public void SetVertices<T>(T[] fromData) where T : struct
{
Expand Down Expand Up @@ -79,15 +79,15 @@ public void SetIndices(int[] fromData, int count)
}

private void CreateVertexBuffer()
{
VertexBuffer = new DynamicVertexBuffer(_graphicsDevice, VertexDeclaration, _currentVertexCount, BufferUsage.WriteOnly);
{
VertexBuffer = new DynamicVertexBuffer(_graphicsDevice, VertexDeclaration, _currentVertexCount, BufferUsage.WriteOnly);
Logger.Write($"Created dynamic vao vertex buffer with size {_currentVertexCount}");
}

private void CreateIndexBuffer()
{
{
IndexBuffer = new DynamicIndexBuffer(_graphicsDevice, IndexElementSize.ThirtyTwoBits, _currentIndexCount,
BufferUsage.WriteOnly);
BufferUsage.WriteOnly);
Logger.Write($"Created dynamic vao index buffer with size {_currentIndexCount}");
}

Expand All @@ -112,6 +112,6 @@ public static DynamicVao New(
bool useIndices = false)
{
return new DynamicVao(graphicsDevice, vertexDecl, primitiveTopology, vertexCount, indexCount, useIndices);
}
}
}
}
8 changes: 4 additions & 4 deletions Source/Graphics/StaticVao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Penumbra.Graphics
{
internal sealed class StaticVao : Vao
{
private StaticVao(VertexBuffer vertexBuffer, IndexBuffer indexBuffer, VertexDeclaration vertexDeclaration, PrimitiveType primitiveTopology)
{
private StaticVao(VertexBuffer vertexBuffer, IndexBuffer indexBuffer, VertexDeclaration vertexDeclaration, PrimitiveType primitiveTopology)
: base(vertexDeclaration, primitiveTopology)
{
IndexBuffer = indexBuffer;
Expand Down Expand Up @@ -37,6 +37,6 @@ public static StaticVao New<T>(
result = new StaticVao(vb, ib, vertexDeclaration, primitiveTopology);
}
return result;
}
}
}
}
}
6 changes: 3 additions & 3 deletions Source/Graphics/Vao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Penumbra.Graphics
{
internal abstract class Vao : IDisposable
{
{
protected Vao(VertexDeclaration vertexDeclaration, PrimitiveType primitiveTopology)
{
VertexDeclaration = vertexDeclaration;
Expand All @@ -15,10 +15,10 @@ protected Vao(VertexDeclaration vertexDeclaration, PrimitiveType primitiveTopolo
public IndexBuffer IndexBuffer { get; protected set; }
public int PrimitiveCount { get; private set; }
public VertexDeclaration VertexDeclaration { get; }
public PrimitiveType PrimitiveTopology { get; }
public PrimitiveType PrimitiveTopology { get; }
public bool HasIndices => IndexBuffer != null;
public virtual int VertexCount => VertexBuffer.VertexCount;
public virtual int IndexCount => IndexBuffer.IndexCount;
public virtual int IndexCount => IndexBuffer.IndexCount;

public void Dispose()
{
Expand Down
12 changes: 6 additions & 6 deletions Source/Graphics/VertexTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ internal struct VertexPosition2Texture
public Vector2 TexCoord;

public VertexPosition2Texture(Vector2 position, Vector2 texCoord)
{
{
Position = position;
TexCoord = texCoord;
}
TexCoord = texCoord;
}

public override string ToString() =>
$"{nameof(Position)}:{Position} {nameof(TexCoord)}:{TexCoord}";
}

[StructLayout(LayoutKind.Sequential)]
internal struct VertexShadow
{
Expand All @@ -45,7 +45,7 @@ internal struct VertexShadow
new VertexElement(0, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
new VertexElement(8, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 1),
new VertexElement(16, VertexElementFormat.Vector2, VertexElementUsage.Position, 0));

public Vector2 SegmentA;
public Vector2 SegmentB;
public Vector2 Stencil;
Expand All @@ -54,7 +54,7 @@ public VertexShadow(Vector2 segA, Vector2 segB, Vector2 stencil)
{
SegmentA = segA;
SegmentB = segB;
Stencil = stencil;
Stencil = stencil;
}

public override string ToString() =>
Expand Down
70 changes: 35 additions & 35 deletions Source/Hull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
namespace Penumbra
{
/// <summary>
/// A hull is an object from which shadows are cast.
/// A hull is an object from which shadows are cast.
/// It is a simple convex or concave polygon impassable by light rays.
/// </summary>
public class Hull
{
private readonly ExtendedObservableCollection<Vector2> _rawLocalPoints =
new ExtendedObservableCollection<Vector2>();
{
private readonly ExtendedObservableCollection<Vector2> _rawLocalPoints =
new ExtendedObservableCollection<Vector2>();

private bool _worldDirty = true;
private bool _pointsDirty = true;
Expand All @@ -30,7 +30,7 @@ public class Hull
/// <list type="number">
/// <item><description>A polygon with at least 3 points.</description></item>
/// <item><description>A simple polygon (no two edges intersect with each other).</description></item>
/// </list>
/// </list>
/// </param>
public Hull(params Vector2[] points) : this((IEnumerable<Vector2>)points)
{ }
Expand All @@ -43,9 +43,9 @@ public Hull(params Vector2[] points) : this((IEnumerable<Vector2>)points)
/// <list type="number">
/// <item><description>A polygon with at least 3 points.</description></item>
/// <item><description>A simple polygon (no two edges intersect with each other).</description></item>
/// </list>
/// </param>
public Hull(IEnumerable<Vector2> points = null)
/// </list>
/// </param>
public Hull(IEnumerable<Vector2> points = null)
{
if (points != null)
{
Expand All @@ -63,11 +63,11 @@ public Hull(IEnumerable<Vector2> points = null)
ConvertRawLocalPointsToLocalPoints();
if (e.Action == NotifyCollectionChangedAction.Add)
foreach (Vector2 point in e.NewItems)
Logger.Write($"New point at {point}.");
Logger.Write($"New point at {point}.");
_worldDirty = true;
_pointsDirty = true;
}
};
}
};
}

/// <summary>
Expand All @@ -81,7 +81,7 @@ public Hull(IEnumerable<Vector2> points = null)
public IList<Vector2> Points => _rawLocalPoints;

/// <summary>
/// Gets or sets if the hull is enabled and participates in shadow casting.
/// Gets or sets if the hull is enabled and participates in shadow casting.
/// Shadows are only cast from enabled hulls.
/// </summary>
public bool Enabled { get; set; } = true;
Expand All @@ -90,7 +90,7 @@ public Hull(IEnumerable<Vector2> points = null)
/// Gets if the hull forms a valid polygon and participates in shadow casting. See
/// Points property for rules of a valid polygon.
/// </summary>
public bool Valid { get; private set; }
public bool Valid { get; private set; }

private Vector2 _position;
/// <summary>
Expand All @@ -102,13 +102,13 @@ public Vector2 Position
set
{
if (_position != value)
{
{
_position = value;
_worldDirty = true;
}
}
}

private Vector2 _origin;
/// <summary>
/// Gets or sets the origin ((0, 0) point) of the hull's local space.
Expand All @@ -119,13 +119,13 @@ public Vector2 Origin
set
{
if (_origin != value)
{
{
_origin = value;
_worldDirty = true;
}
}
}

private float _rotation;
/// <summary>
/// Gets or sets the rotation of the hull in radians.
Expand All @@ -136,13 +136,13 @@ public float Rotation
set
{
if (_rotation != value)
{
{
_rotation = value;
_worldDirty = true;
}
}
}

private Vector2 _scale = Vector2.One;
/// <summary>
/// Gets or sets the scale (width and height) along X and Y axes.
Expand All @@ -153,12 +153,12 @@ public Vector2 Scale
set
{
if (_scale != value)
{
{
_scale = value;
_worldDirty = true;
}
}
}
}

internal bool Dirty;

Expand All @@ -172,25 +172,25 @@ public Vector2 Scale

internal Indices Indices { get; } = new Indices();

internal bool IsConvex;
internal bool IsConvex;

internal void Update()
{
if (_worldDirty)
{
UpdatePoints();

// Calculate local to world transform.
// Calculate local to world transform.
Calculate.Transform(ref _position, ref _origin, ref _scale, _rotation, out LocalToWorld);

// Calculate points in world space.
WorldPoints.Clear();
WorldPoints.Clear();
int pointCount = LocalPoints.Count;
for (int i = 0; i < pointCount; i++)
{
Vector2 originalPos = LocalPoints[i];
Vector2 transformedPos;
Vector2.Transform(ref originalPos, ref LocalToWorld, out transformedPos);
Vector2.Transform(ref originalPos, ref LocalToWorld, out transformedPos);
WorldPoints.Add(transformedPos);
}

Expand All @@ -207,7 +207,7 @@ private void UpdatePoints()
if (_pointsDirty)
{
IsConvex = LocalPoints.IsConvex();
Indices.Clear();
Indices.Clear();

if (IsConvex)
{
Expand All @@ -224,7 +224,7 @@ private void UpdatePoints()
Triangulator.Process(LocalPoints, Indices);
}

_pointsDirty = false;
_pointsDirty = false;
}
}

Expand All @@ -234,7 +234,7 @@ private void ConvertRawLocalPointsToLocalPoints()
LocalPoints.Clear();
LocalPoints.AddRange(_rawLocalPoints);
if (!LocalPoints.IsCounterClockWise())
LocalPoints.ReverseWindingOrder();
LocalPoints.ReverseWindingOrder();
}

private void ValidateRawLocalPoints()
Expand All @@ -257,18 +257,18 @@ private void ValidateRawLocalPoints()
}

/// <summary>
/// Factory method for creating a rectangular <see cref="Hull"/> with points defined so that
/// Factory method for creating a rectangular <see cref="Hull"/> with points defined so that
/// min vertex is at (0.0, 0.0) and max vertex is at (1.0, 1.0).
/// </summary>
/// <param name="position">Optional initial position. Default is (0.0, 0.0).</param>
/// <param name="scale">Optional initial scale. Default is (1.0, 1.0).</param>
/// <param name="rotation">Optional initial rotation in radians. Default is 0.0.</param>
/// <param name="origin">Optional initial origin. Default is (0.5, 0.5).</param>
/// <returns>A rectangular <see cref="Hull"/>.</returns>
public static Hull CreateRectangle(Vector2? position = null, Vector2? scale = null, float rotation = 0.0f, Vector2? origin = null) =>
public static Hull CreateRectangle(Vector2? position = null, Vector2? scale = null, float rotation = 0.0f, Vector2? origin = null) =>
new Hull(new Vector2(1.0f), new Vector2(0.0f, 1.0f), new Vector2(0.0f), new Vector2(1.0f, 0.0f))
{
Position = position ?? Vector2.Zero,
Position = position ?? Vector2.Zero,
Origin = origin ?? new Vector2(0.5f),
Scale = scale ?? new Vector2(1.0f),
Rotation = rotation
Expand All @@ -286,7 +286,7 @@ public void Update()
{
Hull hull = this[i];

hull.Update();
hull.Update();
Dirty = Dirty || hull.Dirty;
hull.Dirty = false;
}
Expand All @@ -302,9 +302,9 @@ public bool Contains(Light light)
// 1. test AABB intersection
// 2. test point is contained in polygon
if (!light.IgnoredHulls.Contains(hull) &&
hull.Enabled &&
hull.Valid &&
light.Bounds.Intersects(ref hull.Bounds) &&
hull.Enabled &&
hull.Valid &&
light.Bounds.Intersects(ref hull.Bounds) &&
hull.WorldPoints.Contains(ref light._position))
return true;
}
Expand Down
Loading

0 comments on commit 5fe346f

Please sign in to comment.