From 4b93db20fd2295fd8a2171f741686af93ff93b37 Mon Sep 17 00:00:00 2001 From: badlogic Date: Fri, 21 Jul 2017 15:59:43 +0200 Subject: [PATCH] [xna] Also draw decomposed convex clipping polygons --- spine-xna/example/src/ExampleGame.cs | 1 + spine-xna/src/SkeletonDebugRenderer.cs | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/spine-xna/example/src/ExampleGame.cs b/spine-xna/example/src/ExampleGame.cs index 43bb2b5c5..842d3e980 100644 --- a/spine-xna/example/src/ExampleGame.cs +++ b/spine-xna/example/src/ExampleGame.cs @@ -83,6 +83,7 @@ namespace Spine { skeletonDebugRenderer = new SkeletonDebugRenderer(GraphicsDevice); skeletonDebugRenderer.DisableAll(); skeletonDebugRenderer.DrawClipping = true; + skeletonDebugRenderer.DrawClippingDecomposed = true; // String name = "spineboy-ess"; // String name = "goblins-pro"; diff --git a/spine-xna/src/SkeletonDebugRenderer.cs b/spine-xna/src/SkeletonDebugRenderer.cs index 0c937eeb0..05a9e1238 100644 --- a/spine-xna/src/SkeletonDebugRenderer.cs +++ b/spine-xna/src/SkeletonDebugRenderer.cs @@ -46,6 +46,7 @@ namespace Spine { private static Color triangleLineColor = new Color(1f, 0.64f, 0f, 0.5f); private static Color pathColor = new Color(1f, 0.5f, 0f, 1f); private static Color clipColor = new Color(0.8f, 0f, 0f, 1f); + private static Color clipDecomposedColor = new Color(0.8f, 0.8f, 0f, 1f); private static Color aabbColor = new Color(0f, 1f, 0f, 0.5f); public BasicEffect Effect { get { return renderer.Effect; } set { renderer.Effect = value; } } @@ -56,6 +57,7 @@ namespace Spine { public bool DrawMeshTriangles { get; set; } public bool DrawPaths { get; set; } public bool DrawClipping { get; set; } + public bool DrawClippingDecomposed { get; set; } public bool DrawSkeletonXY { get; set; } public void DisableAll() { DrawBones = false; @@ -204,14 +206,17 @@ namespace Spine { clippingPolygon.Add(x); clippingPolygon.Add(y); } - - if (!skeleton.FlipY) SkeletonClipping.MakeClockwise(clippingPolygon); - var clippingPolygons = triangulator.Decompose(clippingPolygon, triangulator.Triangulate(clippingPolygon)); - foreach (var polygon in clippingPolygons) { - if (!skeleton.FlipY) SkeletonClipping.MakeClockwise(polygon); - polygon.Add(polygon.Items[0]); - polygon.Add(polygon.Items[1]); - renderer.Polygon(polygon.Items, 0, polygon.Count >> 1); + + if (DrawClippingDecomposed) { + if (!skeleton.FlipY) SkeletonClipping.MakeClockwise(clippingPolygon); + var clippingPolygons = triangulator.Decompose(clippingPolygon, triangulator.Triangulate(clippingPolygon)); + renderer.SetColor(clipDecomposedColor); + foreach (var polygon in clippingPolygons) { + if (!skeleton.FlipY) SkeletonClipping.MakeClockwise(polygon); + polygon.Add(polygon.Items[0]); + polygon.Add(polygon.Items[1]); + renderer.Polygon(polygon.Items, 0, polygon.Count >> 1); + } } } }