Эх сурвалжийг харах

Changed how scale is applied.

Scale is now multiplicative, as it was intended to be.
http://esotericsoftware.com/forum/viewtopic.php?p=16259#p16259
This change means skeletons need to be exported again using Spine 2.0.00+.
NathanSweet 11 жил өмнө
parent
commit
3ed7fb6865

+ 4 - 4
spine-as3/spine-as3/src/spine/animation/ScaleTimeline.as

@@ -44,8 +44,8 @@ public class ScaleTimeline extends TranslateTimeline {
 
 		var bone:Bone = skeleton.bones[boneIndex];
 		if (time >= frames[int(frames.length - 3)]) { // Time is after last frame.
-			bone.scaleX += (bone.data.scaleX - 1 + frames[int(frames.length - 2)] - bone.scaleX) * alpha;
-			bone.scaleY += (bone.data.scaleY - 1 + frames[int(frames.length - 1)] - bone.scaleY) * alpha;
+			bone.scaleX += (bone.data.scaleX * frames[int(frames.length - 2)] - bone.scaleX) * alpha;
+			bone.scaleY += (bone.data.scaleY * frames[int(frames.length - 1)] - bone.scaleY) * alpha;
 			return;
 		}
 
@@ -57,8 +57,8 @@ public class ScaleTimeline extends TranslateTimeline {
 		var percent:Number = 1 - (time - frameTime) / (frames[int(frameIndex + PREV_FRAME_TIME)] - frameTime);
 		percent = getCurvePercent(frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
 
-		bone.scaleX += (bone.data.scaleX - 1 + prevFrameX + (frames[int(frameIndex + FRAME_X)] - prevFrameX) * percent - bone.scaleX) * alpha;
-		bone.scaleY += (bone.data.scaleY - 1 + prevFrameY + (frames[int(frameIndex + FRAME_Y)] - prevFrameY) * percent - bone.scaleY) * alpha;
+		bone.scaleX += (bone.data.scaleX * (prevFrameX + (frames[int(frameIndex + FRAME_X)] - prevFrameX) * percent) - bone.scaleX) * alpha;
+		bone.scaleY += (bone.data.scaleY * (prevFrameY + (frames[int(frameIndex + FRAME_Y)] - prevFrameY) * percent) - bone.scaleY) * alpha;
 	}
 }
 

+ 4 - 4
spine-c/src/spine/Animation.c

@@ -368,8 +368,8 @@ void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
 
 	bone = skeleton->bones[self->boneIndex];
 	if (time >= self->frames[self->framesCount - 3]) { /* Time is after last frame. */
-		bone->scaleX += (bone->data->scaleX - 1 + self->frames[self->framesCount - 2] - bone->scaleX) * alpha;
-		bone->scaleY += (bone->data->scaleY - 1 + self->frames[self->framesCount - 1] - bone->scaleY) * alpha;
+		bone->scaleX += (bone->data->scaleX * self->frames[self->framesCount - 2] - bone->scaleX) * alpha;
+		bone->scaleY += (bone->data->scaleY * self->frames[self->framesCount - 1] - bone->scaleY) * alpha;
 		return;
 	}
 
@@ -381,9 +381,9 @@ void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
 	percent = 1 - (time - frameTime) / (self->frames[frameIndex + TRANSLATE_PREV_FRAME_TIME] - frameTime);
 	percent = spCurveTimeline_getCurvePercent(SUPER(self), frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
 
-	bone->scaleX += (bone->data->scaleX - 1 + prevFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - prevFrameX) * percent
+	bone->scaleX += (bone->data->scaleX * (prevFrameX + (self->frames[frameIndex + TRANSLATE_FRAME_X] - prevFrameX) * percent)
 			- bone->scaleX) * alpha;
-	bone->scaleY += (bone->data->scaleY - 1 + prevFrameY + (self->frames[frameIndex + TRANSLATE_FRAME_Y] - prevFrameY) * percent
+	bone->scaleY += (bone->data->scaleY * (prevFrameY + (self->frames[frameIndex + TRANSLATE_FRAME_Y] - prevFrameY) * percent)
 			- bone->scaleY) * alpha;
 }
 

+ 4 - 4
spine-csharp/src/Animation.cs

@@ -325,8 +325,8 @@ namespace Spine {
 
 			Bone bone = skeleton.bones[boneIndex];
 			if (time >= frames[frames.Length - 3]) { // Time is after last frame.
-				bone.scaleX += (bone.data.scaleX - 1 + frames[frames.Length - 2] - bone.scaleX) * alpha;
-				bone.scaleY += (bone.data.scaleY - 1 + frames[frames.Length - 1] - bone.scaleY) * alpha;
+				bone.scaleX += (bone.data.scaleX * frames[frames.Length - 2] - bone.scaleX) * alpha;
+				bone.scaleY += (bone.data.scaleY * frames[frames.Length - 1] - bone.scaleY) * alpha;
 				return;
 			}
 
@@ -338,8 +338,8 @@ namespace Spine {
 			float percent = 1 - (time - frameTime) / (frames[frameIndex + LAST_FRAME_TIME] - frameTime);
 			percent = GetCurvePercent(frameIndex / 3 - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
 
-			bone.scaleX += (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + FRAME_X] - lastFrameX) * percent - bone.scaleX) * alpha;
-			bone.scaleY += (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + FRAME_Y] - lastFrameY) * percent - bone.scaleY) * alpha;
+			bone.scaleX += (bone.data.scaleX * (lastFrameX + (frames[frameIndex + FRAME_X] - lastFrameX) * percent) - bone.scaleX) * alpha;
+			bone.scaleY += (bone.data.scaleY * (lastFrameY + (frames[frameIndex + FRAME_Y] - lastFrameY) * percent) - bone.scaleY) * alpha;
 		}
 	}
 

+ 4 - 4
spine-js/spine.js

@@ -407,8 +407,8 @@ spine.ScaleTimeline.prototype = {
 		var bone = skeleton.bones[this.boneIndex];
 
 		if (time >= frames[frames.length - 3]) { // Time is after last frame.
-			bone.scaleX += (bone.data.scaleX - 1 + frames[frames.length - 2] - bone.scaleX) * alpha;
-			bone.scaleY += (bone.data.scaleY - 1 + frames[frames.length - 1] - bone.scaleY) * alpha;
+			bone.scaleX += (bone.data.scaleX * frames[frames.length - 2] - bone.scaleX) * alpha;
+			bone.scaleY += (bone.data.scaleY * frames[frames.length - 1] - bone.scaleY) * alpha;
 			return;
 		}
 
@@ -420,8 +420,8 @@ spine.ScaleTimeline.prototype = {
 		var percent = 1 - (time - frameTime) / (frames[frameIndex + -3/*LAST_FRAME_TIME*/] - frameTime);
 		percent = this.curves.getCurvePercent(frameIndex / 3 - 1, percent);
 
-		bone.scaleX += (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent - bone.scaleX) * alpha;
-		bone.scaleY += (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent - bone.scaleY) * alpha;
+		bone.scaleX += (bone.data.scaleX * (lastFrameX + (frames[frameIndex + 1/*FRAME_X*/] - lastFrameX) * percent) - bone.scaleX) * alpha;
+		bone.scaleY += (bone.data.scaleY * (lastFrameY + (frames[frameIndex + 2/*FRAME_Y*/] - lastFrameY) * percent) - bone.scaleY) * alpha;
 	}
 };
 

+ 4 - 4
spine-lua/Animation.lua

@@ -302,8 +302,8 @@ function Animation.ScaleTimeline.new ()
 		local bone = skeleton.bones[self.boneIndex]
 
 		if time >= frames[#frames - 2] then -- Time is after last frame.
-			bone.scaleX = bone.scaleX + (bone.data.scaleX - 1 + frames[#frames - 1] - bone.scaleX) * alpha
-			bone.scaleY = bone.scaleY + (bone.data.scaleY - 1 + frames[#frames] - bone.scaleY) * alpha
+			bone.scaleX = bone.scaleX + (bone.data.scaleX * frames[#frames - 1] - bone.scaleX) * alpha
+			bone.scaleY = bone.scaleY + (bone.data.scaleY * frames[#frames] - bone.scaleY) * alpha
 			return
 		end
 
@@ -316,8 +316,8 @@ function Animation.ScaleTimeline.new ()
 		if percent < 0 then percent = 0 elseif percent > 1 then percent = 1 end
 		percent = self:getCurvePercent(frameIndex / 3 - 1, percent)
 
-		bone.scaleX = bone.scaleX + (bone.data.scaleX - 1 + lastFrameX + (frames[frameIndex + FRAME_X] - lastFrameX) * percent - bone.scaleX) * alpha
-		bone.scaleY = bone.scaleY + (bone.data.scaleY - 1 + lastFrameY + (frames[frameIndex + FRAME_Y] - lastFrameY) * percent - bone.scaleY) * alpha
+		bone.scaleX = bone.scaleX + (bone.data.scaleX * (lastFrameX + (frames[frameIndex + FRAME_X] - lastFrameX) * percent) - bone.scaleX) * alpha
+		bone.scaleY = bone.scaleY + (bone.data.scaleY * (lastFrameY + (frames[frameIndex + FRAME_Y] - lastFrameY) * percent) - bone.scaleY) * alpha
 	end
 
 	return self