[csharp] Port RegionAttachment.java checking for compatible region values.

This commit is contained in:
pharan 2018-03-08 22:40:00 +08:00
parent 0b01953690
commit 2345764fbf

View File

@ -79,14 +79,22 @@ namespace Spine {
public void UpdateOffset () { public void UpdateOffset () {
float width = this.width; float width = this.width;
float height = this.height; float height = this.height;
float localX2 = width * 0.5f;
float localY2 = height * 0.5f;
float localX = -localX2;
float localY = -localY2;
if (regionOriginalWidth != 0) { // if (region != null)
localX += regionOffsetX / regionOriginalWidth * width;
localY += regionOffsetY / regionOriginalHeight * height;
localX2 -= (regionOriginalWidth - regionOffsetX - regionWidth) / regionOriginalWidth * width;
localY2 -= (regionOriginalHeight - regionOffsetY - regionHeight) / regionOriginalHeight * height;
}
float scaleX = this.scaleX; float scaleX = this.scaleX;
float scaleY = this.scaleY; float scaleY = this.scaleY;
float regionScaleX = width / regionOriginalWidth * scaleX; localX *= scaleX;
float regionScaleY = height / regionOriginalHeight * scaleY; localY *= scaleY;
float localX = -width / 2 * scaleX + regionOffsetX * regionScaleX; localX2 *= scaleX;
float localY = -height / 2 * scaleY + regionOffsetY * regionScaleY; localY2 *= scaleY;
float localX2 = localX + regionWidth * regionScaleX;
float localY2 = localY + regionHeight * regionScaleY;
float rotation = this.rotation; float rotation = this.rotation;
float cos = MathUtils.CosDeg(rotation); float cos = MathUtils.CosDeg(rotation);
float sin = MathUtils.SinDeg(rotation); float sin = MathUtils.SinDeg(rotation);