Merge remote-tracking branch 'origin/3.6-beta' into 3.6-beta

This commit is contained in:
Nathan Sweet 2017-03-31 19:52:28 +09:00
commit 2bf79e8519
36 changed files with 641 additions and 194 deletions

View File

@ -69,6 +69,25 @@
* `AtasRegionAttacher` and `SpriteAttacher` are now part of `Example Modules`, to reflect that they are meant to be used as sample code rather than production.
* In the unitypackage, the "spine-csharp" and "spine-unity" folders are now inside a "Spine" folder. This change will only affect fresh imports. Importing the unitypackage to update Spine-Unity in your project will update the appropriate files wherever you have moved them.
## Java
* **Breaking changes**
* `Skeleton.getBounds` takes a scratch array as input so it doesn't have to allocate a new array on each invocation itself. Reduces GC activity.
* Removed `Bone.worldToLocalRotationX` and `Bone.worldToLocalRotationY`. Replaced by `Bone.worldToLocalRotation` (rotation given relative to x-axis, counter-clockwise, in degrees).
* Added `stride` parameter to `VertexAttachment.computeWorldVertices`.
* Removed `RegionAttachment.vertices` field. The vertices array is provided to `RegionAttachment.computeWorldVertices` by the API user now.
* Removed `RegionAttachment.updateWorldVertices`, added `RegionAttachment.computeWorldVertices`. The new method now computes the x/y positions of the 4 vertices of the corner and places them in the provided `worldVertices` array, starting at `offset`, then moving by `stride` array elements when advancing to the next vertex. This allows to directly compose the vertex buffer and avoids a copy. The computation of the full vertices, including vertex colors and texture coordinates, is now done by the backend's respective renderer.
* **Additions**
* Added support for local and relative transform constraint calculation, including additional fields in `TransformConstraintData`
* Added `Bone.localToWorldRotation`(rotation given relative to x-axis, counter-clockwise, in degrees).
* Added two color tinting support, including `TwoColorTimeline` and additional fields on `Slot` and `SlotData`.
* Added `PointAttachment`, additional method `newPointAttachment` in `AttachmentLoader` interface.
* Added `ClippingAttachment`, additional method `newClippingAttachment` in `AttachmentLoader` interface.
### libGDX
* Fixed renderer to work with 3.6 changes
* Added support for two color tinting. Use the new `TwoColorPolygonBatch` together with `SkeletonRenderer`
* Added support for clipping. See `SkeletonClipper`. Used automatically by `SkeletonRenderer`. Does not work when using a `SpriteBatch` with `SkeletonRenderer`. Use `PolygonSpriteBatch` or `TwoColorPolygonBatch` instead.
## Lua
* **Breaking changes**
* Removed `Bone:worldToLocalRotationX` and `Bone:worldToLocalRotationY`. Replaced by `Bone:worldToLocalRotation` (rotation given relative to x-axis, counter-clockwise, in degrees).

View File

@ -27,7 +27,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
package spine.animation {
import spine.MathUtils;
import spine.Bone;
@ -52,6 +51,7 @@ package spine.animation {
internal var queue : EventQueue;
internal var propertyIDs : Dictionary = new Dictionary();
internal var animationsChanged : Boolean;
public var multipleMixing : Boolean = false;
public var timeScale : Number = 1;
internal var trackEntryPool : Pool;
@ -198,7 +198,9 @@ package spine.animation {
var timelineCount : int = from.animation.timelines.length;
var timelines : Vector.<Timeline> = from.animation.timelines;
var timelinesFirst : Vector.<Boolean> = from.timelinesFirst;
var alpha : Number = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast : Vector.<Boolean> = multipleMixing ? null : from.timelinesLast;
var alphaBase : Number = from.alpha * entry.mixAlpha;
var alphaMix : Number = alphaBase * (1 - mix);
var firstFrame : Boolean = from.timelinesRotation.length == 0;
if (firstFrame) from.timelinesRotation.length = timelineCount << 1;
@ -207,6 +209,7 @@ package spine.animation {
for (var i : int = 0; i < timelineCount; i++) {
var timeline : Timeline = timelines[i];
var setupPose : Boolean = timelinesFirst[i];
var alpha : Number = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline is RotateTimeline)
applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -360,10 +363,30 @@ package spine.animation {
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
var mixingFrom : TrackEntry = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
// A mix was interrupted, mix from the closest animation.
if (!multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
// If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero.
if (from.mixingFrom != null && from.mixDuration > 0) current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
// The interrupted mix will mix out from its current percentage to zero.
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
// End the other animation after it is applied one last time.
if (!multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
queue.start(current);
@ -524,6 +547,36 @@ package spine.animation {
entry = tracks[i];
if (entry != null) checkTimelinesFirst(entry);
}
if (multipleMixing) return;
// Set timelinesLast for mixingFrom entries, from highest track to lowest that has mixingFrom.
for (var key2 : String in propertyIDs) {
delete propertyIDs[key2];
}
var lowestMixingFrom : int = n;
for (i = 0; i < n; i++) { // Find lowest track with a mixingFrom entry.
entry = tracks[i];
if (entry == null || entry.mixingFrom == null) continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) { // Find first non-null entry.
entry = tracks[i];
if (entry == null) continue;
// Store properties for non-mixingFrom entry but don't set timelinesLast, which is only used for mixingFrom entries.
var timelines : Vector.<Timeline> = entry.animation.timelines;
for (var ii : int = 0, nn : int = entry.animation.timelines.length; ii < nn; ii++)
var id : String = timelines[ii].getPropertyId().toString();
propertyIDs[id] = id;
entry = entry.mixingFrom;
while (entry != null) {
checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
}
private function setTimelinesFirst(entry : TrackEntry) : void {

View File

@ -47,6 +47,7 @@ package spine.animation {
public var delay : Number, trackTime : Number, trackLast : Number, nextTrackLast : Number, trackEnd : Number, timeScale : Number;
public var alpha : Number, mixTime : Number, mixDuration : Number, mixAlpha : Number;
public var timelinesFirst : Vector.<Boolean> = new Vector.<Boolean>();
public var timelinesLast : Vector.<Boolean> = new Vector.<Boolean>();
public var timelinesRotation : Vector.<Number> = new Vector.<Number>();
public function TrackEntry() {
@ -72,6 +73,7 @@ package spine.animation {
onComplete.listeners.length = 0;
onEvent.listeners.length = 0;
timelinesFirst.length = 0;
timelinesLast.length = 0;
timelinesRotation.length = 0;
}

View File

@ -45,7 +45,7 @@ package spine.examples {
// example = TankExample;
// example = VineExample;
// example = StretchymanExample;
example = TwoColorExample;
// example = TwoColorExample;
_starling = new Starling(example, stage);
_starling.enableErrorChecking = true;

View File

@ -328,6 +328,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -385,6 +386,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1461,6 +1461,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1588,7 +1589,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1596,6 +1599,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1736,9 +1740,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1884,6 +1903,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1941,6 +1984,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1949,6 +1993,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -328,6 +328,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -385,6 +386,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1461,6 +1461,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1588,7 +1589,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1596,6 +1599,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1736,9 +1740,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1884,6 +1903,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1941,6 +1984,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1949,6 +1993,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -235,6 +235,7 @@ declare module spine {
queue: EventQueue;
propertyIDs: IntSet;
animationsChanged: boolean;
multipleMixing: boolean;
timeScale: number;
trackEntryPool: Pool<TrackEntry>;
constructor(data: AnimationStateData);
@ -292,6 +293,7 @@ declare module spine {
mixDuration: number;
mixAlpha: number;
timelinesFirst: boolean[];
timelinesLast: boolean[];
timelinesRotation: number[];
reset(): void;
getAnimationTime(): number;

View File

@ -1043,6 +1043,7 @@ var spine;
this.queue = new EventQueue(this);
this.propertyIDs = new spine.IntSet();
this.animationsChanged = false;
this.multipleMixing = false;
this.timeScale = 1;
this.trackEntryPool = new spine.Pool(function () { return new TrackEntry(); });
this.data = data;
@ -1170,7 +1171,9 @@ var spine;
var timelineCount = from.animation.timelines.length;
var timelines = from.animation.timelines;
var timelinesFirst = from.timelinesFirst;
var alpha = from.alpha * entry.mixAlpha * (1 - mix);
var timelinesLast = this.multipleMixing ? null : from.timelinesLast;
var alphaBase = from.alpha * entry.mixAlpha;
var alphaMix = alphaBase * (1 - mix);
var firstFrame = from.timelinesRotation.length == 0;
if (firstFrame)
spine.Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -1178,6 +1181,7 @@ var spine;
for (var i = 0; i < timelineCount; i++) {
var timeline = timelines[i];
var setupPose = timelinesFirst[i];
var alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof spine.RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -1318,9 +1322,24 @@ var spine;
this.queue.interrupt(from);
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
if (from.mixingFrom != null && from.mixDuration > 0)
var mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
};
@ -1466,6 +1485,30 @@ var spine;
if (entry != null)
this.checkTimelinesFirst(entry);
}
if (this.multipleMixing)
return;
propertyIDs.clear();
var lowestMixingFrom = n;
for (i = 0; i < n; i++) {
var entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null)
continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) {
var entry = this.tracks[i];
if (entry == null)
continue;
var timelines = entry.animation.timelines;
for (var ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
};
AnimationState.prototype.setTimelinesFirst = function (entry) {
if (entry.mixingFrom != null) {
@ -1523,6 +1566,7 @@ var spine;
var TrackEntry = (function () {
function TrackEntry() {
this.timelinesFirst = new Array();
this.timelinesLast = new Array();
this.timelinesRotation = new Array();
}
TrackEntry.prototype.reset = function () {
@ -1531,6 +1575,7 @@ var spine;
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
};
TrackEntry.prototype.getAnimationTime = function () {

File diff suppressed because one or more lines are too long

View File

@ -39,6 +39,7 @@ module spine {
queue = new EventQueue(this);
propertyIDs = new IntSet();
animationsChanged = false;
multipleMixing = false;
timeScale = 1;
trackEntryPool = new Pool<TrackEntry>(() => new TrackEntry());
@ -183,7 +184,9 @@ module spine {
let timelineCount = from.animation.timelines.length;
let timelines = from.animation.timelines;
let timelinesFirst = from.timelinesFirst;
let alpha = from.alpha * entry.mixAlpha * (1 - mix);
let timelinesLast = this.multipleMixing ? null : from.timelinesLast;
let alphaBase = from.alpha * entry.mixAlpha;
let alphaMix = alphaBase * (1 - mix);
let firstFrame = from.timelinesRotation.length == 0;
if (firstFrame) Utils.setArraySize(from.timelinesRotation, timelineCount << 1, null);
@ -192,6 +195,7 @@ module spine {
for (let i = 0; i < timelineCount; i++) {
let timeline = timelines[i];
let setupPose = timelinesFirst[i];
let alpha = timelinesLast != null && setupPose && !timelinesLast[i] ? alphaBase : alphaMix;
if (timeline instanceof RotateTimeline)
this.applyRotateTimeline(timeline, skeleton, animationTime, alpha, setupPose, timelinesRotation, i << 1, firstFrame);
else {
@ -348,10 +352,30 @@ module spine {
current.mixingFrom = from;
current.mixTime = 0;
from.timelinesRotation.length = 0;
let mixingFrom = from.mixingFrom;
if (mixingFrom != null && from.mixDuration > 0) {
// A mix was interrupted, mix from the closest animation.
if (!this.multipleMixing && from.mixTime / from.mixDuration < 0.5 && mixingFrom.animation != AnimationState.emptyAnimation) {
current.mixingFrom = mixingFrom;
mixingFrom.mixingFrom = from;
mixingFrom.mixTime = from.mixDuration - from.mixTime;
mixingFrom.mixDuration = from.mixDuration;
from.mixingFrom = null;
from = mixingFrom;
}
// If not completely mixed in, set mixAlpha so mixing out happens from current mix to zero.
if (from.mixingFrom != null && from.mixDuration > 0) current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
// The interrupted mix will mix out from its current percentage to zero.
current.mixAlpha *= Math.min(from.mixTime / from.mixDuration, 1);
// End the other animation after it is applied one last time.
if (!this.multipleMixing) {
from.mixAlpha = 0;
from.mixTime = 0;
from.mixDuration = 0;
}
}
from.timelinesRotation.length = 0;
}
this.queue.start(current);
@ -510,6 +534,33 @@ module spine {
let entry = this.tracks[i];
if (entry != null) this.checkTimelinesFirst(entry);
}
if (this.multipleMixing) return;
// Set timelinesLast for mixingFrom entries, from highest track to lowest that has mixingFrom.
propertyIDs.clear();
let lowestMixingFrom = n;
for (i = 0; i < n; i++) { // Find lowest track with a mixingFrom entry.
let entry = this.tracks[i];
if (entry == null || entry.mixingFrom == null) continue;
lowestMixingFrom = i;
break;
}
for (i = n - 1; i >= lowestMixingFrom; i--) { // Find first non-null entry.
let entry = this.tracks[i];
if (entry == null) continue;
// Store properties for non-mixingFrom entry but don't set timelinesLast, which is only used for mixingFrom entries.
let timelines = entry.animation.timelines;
for (let ii = 0, nn = entry.animation.timelines.length; ii < nn; ii++)
propertyIDs.add(timelines[ii].getPropertyId());
entry = entry.mixingFrom;
while (entry != null) {
this.checkTimelinesUsage(entry, entry.timelinesLast);
entry = entry.mixingFrom;
}
}
}
setTimelinesFirst (entry: TrackEntry) {
@ -578,6 +629,7 @@ module spine {
delay: number; trackTime: number; trackLast: number; nextTrackLast: number; trackEnd: number; timeScale: number;
alpha: number; mixTime: number; mixDuration: number; mixAlpha: number;
timelinesFirst = new Array<boolean>();
timelinesLast = new Array<boolean>();
timelinesRotation = new Array<number>();
reset () {
@ -586,6 +638,7 @@ module spine {
this.animation = null;
this.listener = null;
this.timelinesFirst.length = 0;
this.timelinesLast.length = 0;
this.timelinesRotation.length = 0;
}

View File

@ -50,7 +50,7 @@ var hoverboardDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
var offset = new spine.Vector2();
bounds = new spine.Vector2();
skeleton.getBounds(offset, bounds);
skeleton.getBounds(offset, bounds, []);
for (var i = 0; i < controlBones.length; i++) hoverTargets.push(null);
renderer.camera.position.x = offset.x + bounds.x / 2;
@ -139,15 +139,8 @@ var hoverboardDemo = function(loadingComplete, bgColor) {
renderer.begin();
renderer.drawSkeleton(skeleton, true);
renderer.drawSkeletonDebug(skeleton, false, ["root"]);
gl.lineWidth(2);
for (var i = 0; i < controlBones.length; i++) {
var bone = skeleton.findBone(controlBones[i]);
var colorInner = hoverTargets[i] !== null ? spineDemos.HOVER_COLOR_INNER : spineDemos.NON_HOVER_COLOR_INNER;
var colorOuter = hoverTargets[i] !== null ? spineDemos.HOVER_COLOR_OUTER : spineDemos.NON_HOVER_COLOR_OUTER;
renderer.circle(true, bone.worldX, bone.worldY, 20, colorInner);
renderer.circle(false, bone.worldX, bone.worldY, 20, colorOuter);
}
// renderer.drawSkeletonDebug(skeleton, false, ["root"]);
renderer.end();
gl.lineWidth(1);

View File

@ -102,7 +102,7 @@ var imageChangesDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
var offset = new spine.Vector2();
var size = new spine.Vector2();
skeleton.getBounds(offset, size);
skeleton.getBounds(offset, size, []);
if (name === "alien") {
state.update(-anim.duration / 2.5);
}

View File

@ -110,7 +110,7 @@ var meshesDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
var offset = new spine.Vector2();
var size = new spine.Vector2();
skeleton.getBounds(offset, size);
skeleton.getBounds(offset, size, []);
return {
atlas: atlas,

View File

@ -47,7 +47,7 @@ var skinsDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
offset = new spine.Vector2();
bounds = new spine.Vector2();
skeleton.getBounds(offset, bounds);
skeleton.getBounds(offset, bounds, []);
setupUI();
setupInput();
loadingComplete(canvas, render);

View File

@ -50,7 +50,7 @@ var spritesheetsDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
offset = new spine.Vector2();
bounds = new spine.Vector2();
skeleton.getBounds(offset, bounds);
skeleton.getBounds(offset, bounds, []);
skeleton.x -= 60;
skeletonSeq = new spine.Skeleton(skeletonData);

View File

@ -56,7 +56,7 @@ var stretchymanDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
var offset = new spine.Vector2();
bounds = new spine.Vector2();
skeleton.getBounds(offset, bounds);
skeleton.getBounds(offset, bounds, []);
for (var i = 0; i < controlBones.length; i++) hoverTargets.push(null);
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
state.setAnimation(0, "idle", true);

View File

@ -50,7 +50,7 @@ var transformsDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
var offset = new spine.Vector2();
bounds = new spine.Vector2();
skeleton.getBounds(offset, bounds);
skeleton.getBounds(offset, bounds, []);
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
skeleton.setToSetupPose();
skeleton.updateWorldTransform();

View File

@ -40,6 +40,7 @@ var transitionsDemo = function(loadingComplete, bgColor) {
skeleton = loadSkeleton("spineboy");
skeletonNoMix = new spine.Skeleton(skeleton.data);
state = createState(0.25);
state.multipleMixing = true;
setAnimations(state, 0);
stateNoMix = createState(0);
setAnimations(stateNoMix, -0.25);
@ -47,7 +48,7 @@ var transitionsDemo = function(loadingComplete, bgColor) {
state.apply(skeleton);
skeleton.updateWorldTransform();
bounds = { offset: new spine.Vector2(), size: new spine.Vector2() };
skeleton.getBounds(bounds.offset, bounds.size);
skeleton.getBounds(bounds.offset, bounds.size, []);
setupInput();
$("#transitions-overlay").removeClass("overlay-hide");
$("#transitions-overlay").addClass("overlay");

View File

@ -48,7 +48,7 @@ var vineDemo = function(loadingComplete, bgColor) {
skeleton.updateWorldTransform();
var offset = new spine.Vector2();
bounds = new spine.Vector2();
skeleton.getBounds(offset, bounds);
skeleton.getBounds(offset, bounds, []);
state = new spine.AnimationState(new spine.AnimationStateData(skeleton.data));
state.setAnimation(0, "animation", true);
state.apply(skeleton);

View File

@ -29,11 +29,13 @@
*****************************************************************************/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Spine;
using Spine.Unity.Modules.AttachmentTools;
namespace Spine.Unity.Modules {
/// <summary>
/// Example code for a component that replaces the default attachment of a slot with an image from a Spine atlas.</summary>
public class AtlasRegionAttacher : MonoBehaviour {
[System.Serializable]
@ -45,8 +47,9 @@ namespace Spine.Unity.Modules {
public string region;
}
public AtlasAsset atlasAsset;
public SlotRegionPair[] attachments;
[SerializeField] protected AtlasAsset atlasAsset;
[SerializeField] protected bool inheritProperties = true;
[SerializeField] protected List<SlotRegionPair> attachments = new List<SlotRegionPair>();
Atlas atlas;
@ -58,15 +61,56 @@ namespace Spine.Unity.Modules {
atlas = atlasAsset.GetAtlas();
float scale = skeletonRenderer.skeletonDataAsset.scale;
var enumerator = attachments.GetEnumerator();
while (enumerator.MoveNext()) {
var entry = (SlotRegionPair)enumerator.Current;
var slot = skeletonRenderer.skeleton.FindSlot(entry.slot);
foreach (var entry in attachments) {
var slot = skeletonRenderer.Skeleton.FindSlot(entry.slot);
var region = atlas.FindRegion(entry.region);
slot.Attachment = region.ToRegionAttachment(entry.region, scale);
ReplaceAttachment(slot, region, scale, inheritProperties);
}
}
static void ReplaceAttachment (Slot slot, AtlasRegion region, float scale, bool inheritProperties) {
var originalAttachment = slot.Attachment;
// Altas was empty
if (region == null) {
slot.Attachment = null;
return;
}
// Original was MeshAttachment
if (inheritProperties) {
var originalMeshAttachment = originalAttachment as MeshAttachment;
if (originalMeshAttachment != null) {
var newMeshAttachment = originalMeshAttachment.GetLinkedClone(); // Attach the region as a linked mesh to the original mesh.
newMeshAttachment.SetRegion(region);
slot.Attachment = newMeshAttachment;
return;
}
}
// Original was RegionAttachment or empty
{
var originalRegionAttachment = originalAttachment as RegionAttachment;
var newRegionAttachment = region.ToRegionAttachment(region.name, scale);
if (originalRegionAttachment != null && inheritProperties) {
newRegionAttachment.X = originalRegionAttachment.X;
newRegionAttachment.Y = originalRegionAttachment.Y;
newRegionAttachment.Rotation = originalRegionAttachment.Rotation;
newRegionAttachment.ScaleX = originalRegionAttachment.ScaleX;
newRegionAttachment.ScaleY = originalRegionAttachment.ScaleY;
newRegionAttachment.UpdateOffset();
newRegionAttachment.R = originalRegionAttachment.R;
newRegionAttachment.G = originalRegionAttachment.G;
newRegionAttachment.B = originalRegionAttachment.B;
newRegionAttachment.A = originalRegionAttachment.A;
}
slot.Attachment = newRegionAttachment;
return;
}
}
}
}