From ff67c6c039cb2cc6ea9d918dd149a0f90eca4f60 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Sun, 23 Dec 2018 17:42:07 +0100 Subject: [PATCH] [csharp] Port of mesh whitespaces stripping. See #1232. --- spine-csharp/src/Attachments/MeshAttachment.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spine-csharp/src/Attachments/MeshAttachment.cs b/spine-csharp/src/Attachments/MeshAttachment.cs index 66ecf8ca7..2f66b41e6 100644 --- a/spine-csharp/src/Attachments/MeshAttachment.cs +++ b/spine-csharp/src/Attachments/MeshAttachment.cs @@ -96,16 +96,30 @@ namespace Spine { } public void UpdateUVs () { - float u = RegionU, v = RegionV, width = RegionU2 - RegionU, height = RegionV2 - RegionV; float[] regionUVs = this.regionUVs; if (this.uvs == null || this.uvs.Length != regionUVs.Length) this.uvs = new float[regionUVs.Length]; float[] uvs = this.uvs; + if (RegionRotate) { + float textureHeight = this.regionWidth / (RegionV2 - RegionV); + float textureWidth = this.regionHeight / (RegionU2 - RegionU); + float u = RegionU - (RegionOriginalHeight - RegionOffsetY - RegionHeight) / textureWidth; + float v = RegionV - (RegionOriginalWidth - RegionOffsetX - RegionWidth) / textureHeight; + float width = RegionOriginalHeight / textureWidth; + float height = RegionOriginalWidth / textureHeight; + for (int i = 0, n = uvs.Length; i < n; i += 2) { uvs[i] = u + regionUVs[i + 1] * width; uvs[i + 1] = v + height - regionUVs[i] * height; } } else { + float textureWidth = this.regionWidth / (RegionU2 - RegionU); + float textureHeight = this.regionHeight / (RegionV2 - RegionV); + float u = RegionU - RegionOffsetX / textureWidth; + float v = RegionV - (RegionOriginalHeight - RegionOffsetY - RegionHeight) / textureHeight; + float width = RegionOriginalWidth / textureWidth; + float height = RegionOriginalHeight / textureHeight; + for (int i = 0, n = uvs.Length; i < n; i += 2) { uvs[i] = u + regionUVs[i] * width; uvs[i + 1] = v + regionUVs[i + 1] * height;