[ts, csharp] Revert RegionAttachment#UpdateOffset from csharp to ts, instead use ts code.

#1889
This commit is contained in:
Nathan Sweet 2021-06-10 00:04:28 -04:00
parent aa752c49d4
commit 0347c262e0
2 changed files with 12 additions and 20 deletions

View File

@ -76,16 +76,12 @@ namespace Spine {
}
public void UpdateOffset () {
float width = this.width, height = this.height;
float scaleX = this.scaleX, scaleY = this.scaleY;
float localX2 = width * 0.5f;
float localY2 = height * 0.5f;
float localX = (-localX2 + regionOffsetX / regionOriginalWidth * width) * scaleX;
float localY = (-localY2 + regionOffsetY / regionOriginalHeight * height) * scaleY;
localX2 -= (regionOriginalWidth - regionOffsetX - regionWidth) / regionOriginalWidth * width;
localY2 -= (regionOriginalHeight - regionOffsetY - regionHeight) / regionOriginalHeight * height;
localX2 *= scaleX;
localY2 *= scaleY;
float regionScaleX = width / regionOriginalWidth * scaleX;
float regionScaleY = height / regionOriginalHeight * scaleY;
float localX = -width / 2 * scaleX + regionOffsetX * regionScaleX;
float localY = -height / 2 * scaleY + regionOffsetY * regionScaleY;
float localX2 = localX + regionWidth * regionScaleX;
float localY2 = localY + regionHeight * regionScaleY;
float cos = MathUtils.CosDeg(this.rotation);
float sin = MathUtils.SinDeg(this.rotation);
float x = this.x, y = this.y;

View File

@ -79,16 +79,12 @@ module spine {
/** Calculates the {@link #offset} using the region settings. Must be called after changing region settings. */
updateOffset () : void {
let region = this.region;
let width = this.width, height = this.height;
let scaleX = this.scaleX, scaleY = this.scaleY;
let localX2 = width * 0.5;
let localY2 = height * 0.5;
let localX = (-localX2 + region.offsetX / region.originalWidth * width) * scaleX;
let localY = (-localY2 + region.offsetY / region.originalHeight * height) * scaleY;
localX2 -= (region.originalWidth - region.offsetX - region.width) / region.originalWidth * width;
localY2 -= (region.originalHeight - region.offsetY - region.height) / region.originalHeight * height;
localX2 *= scaleX;
localY2 *= scaleY;
let regionScaleX = this.width / this.region.originalWidth * this.scaleX;
let regionScaleY = this.height / this.region.originalHeight * this.scaleY;
let localX = -this.width / 2 * this.scaleX + this.region.offsetX * regionScaleX;
let localY = -this.height / 2 * this.scaleY + this.region.offsetY * regionScaleY;
let localX2 = localX + this.region.width * regionScaleX;
let localY2 = localY + this.region.height * regionScaleY;
let radians = this.rotation * Math.PI / 180;
let cos = Math.cos(radians);
let sin = Math.sin(radians);