From 4c043c0eb6bd2549e9f0e32c2b665e53266ee39f Mon Sep 17 00:00:00 2001 From: pharan Date: Sun, 30 Apr 2017 21:33:44 +0800 Subject: [PATCH] [csharp] Minor formatting changes. --- spine-csharp/src/SkeletonClipping.cs | 39 +++++++++++++--------------- spine-csharp/src/Triangulator.cs | 10 +++---- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/spine-csharp/src/SkeletonClipping.cs b/spine-csharp/src/SkeletonClipping.cs index c5dfb3865..c55db5f6b 100644 --- a/spine-csharp/src/SkeletonClipping.cs +++ b/spine-csharp/src/SkeletonClipping.cs @@ -32,22 +32,24 @@ using System; namespace Spine { public class SkeletonClipping { - private readonly Triangulator triangulator = new Triangulator(); - private readonly ExposedList clippingPolygon = new ExposedList(); - private readonly ExposedList clipOutput = new ExposedList(128); - private readonly ExposedList clippedVertices = new ExposedList(128); - private readonly ExposedList clippedTriangles = new ExposedList(128); - private readonly ExposedList clippedUVs = new ExposedList(128); - private readonly ExposedList scratch = new ExposedList(); + internal readonly Triangulator triangulator = new Triangulator(); + internal readonly ExposedList clippingPolygon = new ExposedList(); + internal readonly ExposedList clipOutput = new ExposedList(128); + internal readonly ExposedList clippedVertices = new ExposedList(128); + internal readonly ExposedList clippedTriangles = new ExposedList(128); + internal readonly ExposedList clippedUVs = new ExposedList(128); + internal readonly ExposedList scratch = new ExposedList(); - private ClippingAttachment clipAttachment; - private ExposedList> clippingPolygons; + internal ClippingAttachment clipAttachment; + internal ExposedList> clippingPolygons; public ExposedList ClippedVertices { get { return clippedVertices; } } public ExposedList ClippedTriangles { get { return clippedTriangles; } } public ExposedList ClippedUVs { get { return clippedUVs; } } - public int ClipStart(Slot slot, ClippingAttachment clip) { + public bool IsClipping () { return clipAttachment != null; } + + public int ClipStart (Slot slot, ClippingAttachment clip) { if (clipAttachment != null) return 0; clipAttachment = clip; @@ -64,11 +66,11 @@ namespace Spine { return clippingPolygons.Count; } - public void ClipEnd(Slot slot) { + public void ClipEnd (Slot slot) { if (clipAttachment != null && clipAttachment.endSlot == slot.data) ClipEnd(); } - public void ClipEnd() { + public void ClipEnd () { if (clipAttachment == null) return; clipAttachment = null; clippingPolygons = null; @@ -76,13 +78,8 @@ namespace Spine { clippedTriangles.Clear(); clippingPolygon.Clear(); } - - public bool IsClipping() { - return clipAttachment != null; - } - - public void ClipTriangles(float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs) { - + + public void ClipTriangles (float[] vertices, int verticesLength, int[] triangles, int trianglesLength, float[] uvs) { ExposedList clipOutput = this.clipOutput, clippedVertices = this.clippedVertices; var clippedTriangles = this.clippedTriangles; var polygons = clippingPolygons.Items; @@ -174,7 +171,7 @@ namespace Spine { /** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping * area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */ - internal bool Clip(float x1, float y1, float x2, float y2, float x3, float y3, ExposedList clippingArea, ExposedList output) { + internal bool Clip (float x1, float y1, float x2, float y2, float x3, float y3, ExposedList clippingArea, ExposedList output) { var originalOutput = output; var clipped = false; @@ -261,7 +258,7 @@ namespace Spine { return clipped; } - static void MakeClockwise(ExposedList polygon) { + static void MakeClockwise (ExposedList polygon) { float[] vertices = polygon.Items; int verticeslength = polygon.Count; diff --git a/spine-csharp/src/Triangulator.cs b/spine-csharp/src/Triangulator.cs index 99b58e9cc..0fadcf15a 100644 --- a/spine-csharp/src/Triangulator.cs +++ b/spine-csharp/src/Triangulator.cs @@ -42,7 +42,7 @@ namespace Spine { private readonly Pool> polygonPool = new Pool>(); private readonly Pool> polygonIndicesPool = new Pool>(); - public ExposedList Triangulate(ExposedList verticesArray) { + public ExposedList Triangulate (ExposedList verticesArray) { var vertices = verticesArray.Items; int vertexCount = verticesArray.Count >> 1; @@ -120,7 +120,7 @@ namespace Spine { return triangles; } - public ExposedList> Decompose(ExposedList verticesArray, ExposedList triangles) { + public ExposedList> Decompose (ExposedList verticesArray, ExposedList triangles) { var vertices = verticesArray.Items; var convexPolygons = this.convexPolygons; for (int i = 0, n = convexPolygons.Count; i < n; i++) { @@ -250,7 +250,7 @@ namespace Spine { return convexPolygons; } - static private bool IsConcave(int index, int vertexCount, float[] vertices, int[] indices) { + static private bool IsConcave (int index, int vertexCount, float[] vertices, int[] indices) { int previous = indices[(vertexCount + index - 1) % vertexCount] << 1; int current = indices[index] << 1; int next = indices[(index + 1) % vertexCount] << 1; @@ -258,11 +258,11 @@ namespace Spine { vertices[next + 1]); } - static private bool PositiveArea(float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) { + static private bool PositiveArea (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) { return p1x * (p3y - p2y) + p2x * (p1y - p3y) + p3x * (p2y - p1y) >= 0; } - static private int Winding(float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) { + static private int Winding (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) { float px = p2x - p1x, py = p2y - p1y; return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; }