Merge branch '3.6' into 3.7-beta

This commit is contained in:
badlogic 2017-08-28 10:54:18 +02:00
commit f26cb43a81
36 changed files with 230 additions and 45 deletions

View File

@ -132,7 +132,8 @@ package spine.animation {
// Require mixTime > 0 to ensure the mixing from entry was applied at least once. // Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
queue.end(from); queue.end(from);

View File

@ -312,7 +312,8 @@ int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTr
/* Require mixTime > 0 to ensure the mixing from entry was applied at least once. */ /* Require mixTime > 0 to ensure the mixing from entry was applied at least once. */
if (to->mixTime > 0 && (to->mixTime >= to->mixDuration || to->timeScale == 0)) { if (to->mixTime > 0 && (to->mixTime >= to->mixDuration || to->timeScale == 0)) {
if (from->totalAlpha == 0) { /* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */
if (from->totalAlpha == 0 || to->mixDuration == 0) {
to->mixingFrom = from->mixingFrom; to->mixingFrom = from->mixingFrom;
to->interruptAlpha = from->interruptAlpha; to->interruptAlpha = from->interruptAlpha;
_spEventQueue_end(internal->queue, from); _spEventQueue_end(internal->queue, from);

View File

@ -139,8 +139,9 @@ namespace Spine {
bool finished = UpdateMixingFrom(from, delta); bool finished = UpdateMixingFrom(from, delta);
// Require mixTime > 0 to ensure the mixing from entry was applied at least once. // Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
queue.End(from); queue.End(from);
@ -707,10 +708,13 @@ namespace Spine {
} else { } else {
for (int ii = mixingToLast; ii >= 0; ii--) { for (int ii = mixingToLast; ii >= 0; ii--) {
var entry = mixingTo[ii]; var entry = mixingTo[ii];
if (entry.mixDuration > 0 && !entry.HasTimeline(id)) { if (!entry.HasTimeline(id)) {
timelineDataItems[i] = AnimationState.DipMix; if (entry.mixDuration > 0) {
timelineDipMixItems[i] = entry; timelineDataItems[i] = AnimationState.DipMix;
goto outer; // continue outer; timelineDipMixItems[i] = entry;
goto outer; // continue outer;
}
break;
} }
} }
timelineDataItems[i] = AnimationState.Dip; timelineDataItems[i] = AnimationState.Dip;

View File

@ -258,7 +258,7 @@ namespace Spine {
return clipped; return clipped;
} }
public static void MakeClockwise (ExposedList<float> polygon) { static void MakeClockwise (ExposedList<float> polygon) {
float[] vertices = polygon.Items; float[] vertices = polygon.Items;
int verticeslength = polygon.Count; int verticeslength = polygon.Count;

View File

@ -31,7 +31,7 @@
using System; using System;
namespace Spine { namespace Spine {
public class Triangulator { internal class Triangulator {
private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>(); private readonly ExposedList<ExposedList<float>> convexPolygons = new ExposedList<ExposedList<float>>();
private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>(); private readonly ExposedList<ExposedList<int>> convexPolygonsIndices = new ExposedList<ExposedList<int>>();

View File

@ -144,7 +144,8 @@ public class AnimationState {
// Require mixTime > 0 to ensure the mixing from entry was applied at least once. // Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
queue.end(from); queue.end(from);

View File

@ -128,6 +128,7 @@ public class SkeletonViewer extends ApplicationAdapter {
Gdx.files.internal(Gdx.app.getPreferences("spine-skeletonviewer").getString("lastFile", "spineboy/spineboy.json"))); Gdx.files.internal(Gdx.app.getPreferences("spine-skeletonviewer").getString("lastFile", "spineboy/spineboy.json")));
ui.loadPrefs(); ui.loadPrefs();
ui.prefsLoaded = true;
} }
void loadSkeleton (final FileHandle skeletonFile) { void loadSkeleton (final FileHandle skeletonFile) {
@ -142,7 +143,8 @@ public class SkeletonViewer extends ApplicationAdapter {
pixmap.dispose(); pixmap.dispose();
String atlasFileName = skeletonFile.nameWithoutExtension(); String atlasFileName = skeletonFile.nameWithoutExtension();
if (atlasFileName.endsWith(".json")) atlasFileName = new FileHandle(atlasFileName).nameWithoutExtension(); if (atlasFileName.endsWith(".json") || atlasFileName.endsWith(".skel"))
atlasFileName = atlasFileName.substring(0, atlasFileName.length() - 5);
FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas"); FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas");
if (!atlasFile.exists()) { if (!atlasFile.exists()) {
if (atlasFileName.endsWith("-pro") || atlasFileName.endsWith("-ess")) if (atlasFileName.endsWith("-pro") || atlasFileName.endsWith("-ess"))
@ -380,6 +382,8 @@ public class SkeletonViewer extends ApplicationAdapter {
} }
class UI { class UI {
boolean prefsLoaded;
Stage stage = new Stage(new ScreenViewport()); Stage stage = new Stage(new ScreenViewport());
com.badlogic.gdx.scenes.scene2d.ui.Skin skin = new com.badlogic.gdx.scenes.scene2d.ui.Skin( com.badlogic.gdx.scenes.scene2d.ui.Skin skin = new com.badlogic.gdx.scenes.scene2d.ui.Skin(
Gdx.files.internal("skin/skin.json")); Gdx.files.internal("skin/skin.json"));
@ -436,7 +440,6 @@ public class SkeletonViewer extends ApplicationAdapter {
Label statusLabel = new Label("", skin); Label statusLabel = new Label("", skin);
WidgetGroup toasts = new WidgetGroup(); WidgetGroup toasts = new WidgetGroup();
boolean prefsLoaded;
UI () { UI () {
initialize(); initialize();
@ -706,6 +709,16 @@ public class SkeletonViewer extends ApplicationAdapter {
} }
}); });
InputListener scrollFocusListener = new InputListener() {
public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) {
if (pointer == -1) stage.setScrollFocus(event.getListenerActor());
}
public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) {
if (pointer == -1 && stage.getScrollFocus() == event.getListenerActor()) stage.setScrollFocus(null);
}
};
animationList.addListener(new ChangeListener() { animationList.addListener(new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) { public void changed (ChangeEvent event, Actor actor) {
if (state != null) { if (state != null) {
@ -717,6 +730,7 @@ public class SkeletonViewer extends ApplicationAdapter {
} }
} }
}); });
animationScroll.addListener(scrollFocusListener);
loopCheckbox.addListener(new ChangeListener() { loopCheckbox.addListener(new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) { public void changed (ChangeEvent event, Actor actor) {
@ -736,6 +750,7 @@ public class SkeletonViewer extends ApplicationAdapter {
} }
} }
}); });
skinScroll.addListener(scrollFocusListener);
ChangeListener trackButtonListener = new ChangeListener() { ChangeListener trackButtonListener = new ChangeListener() {
public void changed (ChangeEvent event, Actor actor) { public void changed (ChangeEvent event, Actor actor) {
@ -909,7 +924,6 @@ public class SkeletonViewer extends ApplicationAdapter {
scaleSlider.setValue(prefs.getFloat("scale", 1)); scaleSlider.setValue(prefs.getFloat("scale", 1));
animationList.setSelected(prefs.getString("animationName", null)); animationList.setSelected(prefs.getString("animationName", null));
skinList.setSelected(prefs.getString("skinName", null)); skinList.setSelected(prefs.getString("skinName", null));
prefsLoaded = true;
} }
} }

View File

@ -346,7 +346,8 @@ function AnimationState:updateMixingFrom (to, delta)
-- Require mixTime > 0 to ensure the mixing from entry was applied at least once. -- Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 and (to.mixTime >= to.mixDuration or to.timeScale == 0)) then if (to.mixTime > 0 and (to.mixTime >= to.mixDuration or to.timeScale == 0)) then
if (from.totalAlpha == 0) then -- Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
if (from.totalAlpha == 0 or to.mixDuration == 0) then
to.mixingFrom = from.mixingFrom to.mixingFrom = from.mixingFrom
to.interruptAlpha = from.interruptAlpha to.interruptAlpha = from.interruptAlpha
self.queue:_end(from) self.queue:_end(from)

View File

@ -585,6 +585,9 @@ declare module spine {
ChainScale = 2, ChainScale = 2,
} }
} }
interface Math {
fround(n: number): number;
}
declare module spine { declare module spine {
class SharedAssetManager implements Disposable { class SharedAssetManager implements Disposable {
private pathPrefix; private pathPrefix;
@ -987,6 +990,7 @@ declare module spine {
static newFloatArray(size: number): ArrayLike<number>; static newFloatArray(size: number): ArrayLike<number>;
static newShortArray(size: number): ArrayLike<number>; static newShortArray(size: number): ArrayLike<number>;
static toFloatArray(array: Array<number>): number[] | Float32Array; static toFloatArray(array: Array<number>): number[] | Float32Array;
static toSinglePrecision(value: number): number;
} }
class DebugUtils { class DebugUtils {
static logBones(skeleton: Skeleton): void; static logBones(skeleton: Skeleton): void;

View File

@ -1216,7 +1216,7 @@ var spine;
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
this.queue.end(from); this.queue.end(from);
@ -2974,6 +2974,15 @@ var spine;
RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
})(RotateMode = spine.RotateMode || (spine.RotateMode = {})); })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
})(spine || (spine = {})); })(spine || (spine = {}));
(function () {
if (!Math.fround) {
Math.fround = (function (array) {
return function (x) {
return array[0] = x, array[0];
};
})(new Float32Array(1));
}
})();
var spine; var spine;
(function (spine) { (function (spine) {
var Assets = (function () { var Assets = (function () {
@ -4745,7 +4754,7 @@ var spine;
var eventData = skeletonData.findEvent(eventMap.name); var eventData = skeletonData.findEvent(eventMap.name);
if (eventData == null) if (eventData == null)
throw new Error("Event not found: " + eventMap.name); throw new Error("Event not found: " + eventMap.name);
var event_5 = new spine.Event(eventMap.time, eventData); var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
@ -5879,6 +5888,9 @@ var spine;
Utils.toFloatArray = function (array) { Utils.toFloatArray = function (array) {
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
}; };
Utils.toSinglePrecision = function (value) {
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
};
return Utils; return Utils;
}()); }());
Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";

File diff suppressed because one or more lines are too long

View File

@ -585,6 +585,9 @@ declare module spine {
ChainScale = 2, ChainScale = 2,
} }
} }
interface Math {
fround(n: number): number;
}
declare module spine { declare module spine {
class SharedAssetManager implements Disposable { class SharedAssetManager implements Disposable {
private pathPrefix; private pathPrefix;
@ -987,6 +990,7 @@ declare module spine {
static newFloatArray(size: number): ArrayLike<number>; static newFloatArray(size: number): ArrayLike<number>;
static newShortArray(size: number): ArrayLike<number>; static newShortArray(size: number): ArrayLike<number>;
static toFloatArray(array: Array<number>): number[] | Float32Array; static toFloatArray(array: Array<number>): number[] | Float32Array;
static toSinglePrecision(value: number): number;
} }
class DebugUtils { class DebugUtils {
static logBones(skeleton: Skeleton): void; static logBones(skeleton: Skeleton): void;

View File

@ -1216,7 +1216,7 @@ var spine;
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
this.queue.end(from); this.queue.end(from);
@ -2974,6 +2974,15 @@ var spine;
RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
})(RotateMode = spine.RotateMode || (spine.RotateMode = {})); })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
})(spine || (spine = {})); })(spine || (spine = {}));
(function () {
if (!Math.fround) {
Math.fround = (function (array) {
return function (x) {
return array[0] = x, array[0];
};
})(new Float32Array(1));
}
})();
var spine; var spine;
(function (spine) { (function (spine) {
var Assets = (function () { var Assets = (function () {
@ -4745,7 +4754,7 @@ var spine;
var eventData = skeletonData.findEvent(eventMap.name); var eventData = skeletonData.findEvent(eventMap.name);
if (eventData == null) if (eventData == null)
throw new Error("Event not found: " + eventMap.name); throw new Error("Event not found: " + eventMap.name);
var event_5 = new spine.Event(eventMap.time, eventData); var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
@ -5879,6 +5888,9 @@ var spine;
Utils.toFloatArray = function (array) { Utils.toFloatArray = function (array) {
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
}; };
Utils.toSinglePrecision = function (value) {
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
};
return Utils; return Utils;
}()); }());
Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";

File diff suppressed because one or more lines are too long

View File

@ -585,6 +585,9 @@ declare module spine {
ChainScale = 2, ChainScale = 2,
} }
} }
interface Math {
fround(n: number): number;
}
declare module spine { declare module spine {
class SharedAssetManager implements Disposable { class SharedAssetManager implements Disposable {
private pathPrefix; private pathPrefix;
@ -987,6 +990,7 @@ declare module spine {
static newFloatArray(size: number): ArrayLike<number>; static newFloatArray(size: number): ArrayLike<number>;
static newShortArray(size: number): ArrayLike<number>; static newShortArray(size: number): ArrayLike<number>;
static toFloatArray(array: Array<number>): number[] | Float32Array; static toFloatArray(array: Array<number>): number[] | Float32Array;
static toSinglePrecision(value: number): number;
} }
class DebugUtils { class DebugUtils {
static logBones(skeleton: Skeleton): void; static logBones(skeleton: Skeleton): void;

View File

@ -1216,7 +1216,7 @@ var spine;
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
this.queue.end(from); this.queue.end(from);
@ -2974,6 +2974,15 @@ var spine;
RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
})(RotateMode = spine.RotateMode || (spine.RotateMode = {})); })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
})(spine || (spine = {})); })(spine || (spine = {}));
(function () {
if (!Math.fround) {
Math.fround = (function (array) {
return function (x) {
return array[0] = x, array[0];
};
})(new Float32Array(1));
}
})();
var spine; var spine;
(function (spine) { (function (spine) {
var Assets = (function () { var Assets = (function () {
@ -4745,7 +4754,7 @@ var spine;
var eventData = skeletonData.findEvent(eventMap.name); var eventData = skeletonData.findEvent(eventMap.name);
if (eventData == null) if (eventData == null)
throw new Error("Event not found: " + eventMap.name); throw new Error("Event not found: " + eventMap.name);
var event_5 = new spine.Event(eventMap.time, eventData); var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
@ -5879,6 +5888,9 @@ var spine;
Utils.toFloatArray = function (array) { Utils.toFloatArray = function (array) {
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
}; };
Utils.toSinglePrecision = function (value) {
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
};
return Utils; return Utils;
}()); }());
Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";

File diff suppressed because one or more lines are too long

View File

@ -585,6 +585,9 @@ declare module spine {
ChainScale = 2, ChainScale = 2,
} }
} }
interface Math {
fround(n: number): number;
}
declare module spine { declare module spine {
class SharedAssetManager implements Disposable { class SharedAssetManager implements Disposable {
private pathPrefix; private pathPrefix;
@ -987,6 +990,7 @@ declare module spine {
static newFloatArray(size: number): ArrayLike<number>; static newFloatArray(size: number): ArrayLike<number>;
static newShortArray(size: number): ArrayLike<number>; static newShortArray(size: number): ArrayLike<number>;
static toFloatArray(array: Array<number>): number[] | Float32Array; static toFloatArray(array: Array<number>): number[] | Float32Array;
static toSinglePrecision(value: number): number;
} }
class DebugUtils { class DebugUtils {
static logBones(skeleton: Skeleton): void; static logBones(skeleton: Skeleton): void;

View File

@ -1216,7 +1216,7 @@ var spine;
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
this.queue.end(from); this.queue.end(from);
@ -2974,6 +2974,15 @@ var spine;
RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
})(RotateMode = spine.RotateMode || (spine.RotateMode = {})); })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
})(spine || (spine = {})); })(spine || (spine = {}));
(function () {
if (!Math.fround) {
Math.fround = (function (array) {
return function (x) {
return array[0] = x, array[0];
};
})(new Float32Array(1));
}
})();
var spine; var spine;
(function (spine) { (function (spine) {
var Assets = (function () { var Assets = (function () {
@ -4745,7 +4754,7 @@ var spine;
var eventData = skeletonData.findEvent(eventMap.name); var eventData = skeletonData.findEvent(eventMap.name);
if (eventData == null) if (eventData == null)
throw new Error("Event not found: " + eventMap.name); throw new Error("Event not found: " + eventMap.name);
var event_5 = new spine.Event(eventMap.time, eventData); var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
@ -5879,6 +5888,9 @@ var spine;
Utils.toFloatArray = function (array) { Utils.toFloatArray = function (array) {
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
}; };
Utils.toSinglePrecision = function (value) {
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
};
return Utils; return Utils;
}()); }());
Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";

File diff suppressed because one or more lines are too long

View File

@ -585,6 +585,9 @@ declare module spine {
ChainScale = 2, ChainScale = 2,
} }
} }
interface Math {
fround(n: number): number;
}
declare module spine { declare module spine {
class SharedAssetManager implements Disposable { class SharedAssetManager implements Disposable {
private pathPrefix; private pathPrefix;
@ -987,6 +990,7 @@ declare module spine {
static newFloatArray(size: number): ArrayLike<number>; static newFloatArray(size: number): ArrayLike<number>;
static newShortArray(size: number): ArrayLike<number>; static newShortArray(size: number): ArrayLike<number>;
static toFloatArray(array: Array<number>): number[] | Float32Array; static toFloatArray(array: Array<number>): number[] | Float32Array;
static toSinglePrecision(value: number): number;
} }
class DebugUtils { class DebugUtils {
static logBones(skeleton: Skeleton): void; static logBones(skeleton: Skeleton): void;

View File

@ -1216,7 +1216,7 @@ var spine;
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
this.queue.end(from); this.queue.end(from);
@ -2974,6 +2974,15 @@ var spine;
RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
})(RotateMode = spine.RotateMode || (spine.RotateMode = {})); })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
})(spine || (spine = {})); })(spine || (spine = {}));
(function () {
if (!Math.fround) {
Math.fround = (function (array) {
return function (x) {
return array[0] = x, array[0];
};
})(new Float32Array(1));
}
})();
var spine; var spine;
(function (spine) { (function (spine) {
var Assets = (function () { var Assets = (function () {
@ -4745,7 +4754,7 @@ var spine;
var eventData = skeletonData.findEvent(eventMap.name); var eventData = skeletonData.findEvent(eventMap.name);
if (eventData == null) if (eventData == null)
throw new Error("Event not found: " + eventMap.name); throw new Error("Event not found: " + eventMap.name);
var event_5 = new spine.Event(eventMap.time, eventData); var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
@ -5879,6 +5888,9 @@ var spine;
Utils.toFloatArray = function (array) { Utils.toFloatArray = function (array) {
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
}; };
Utils.toSinglePrecision = function (value) {
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
};
return Utils; return Utils;
}()); }());
Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";

File diff suppressed because one or more lines are too long

View File

@ -585,6 +585,9 @@ declare module spine {
ChainScale = 2, ChainScale = 2,
} }
} }
interface Math {
fround(n: number): number;
}
declare module spine { declare module spine {
class SharedAssetManager implements Disposable { class SharedAssetManager implements Disposable {
private pathPrefix; private pathPrefix;
@ -987,6 +990,7 @@ declare module spine {
static newFloatArray(size: number): ArrayLike<number>; static newFloatArray(size: number): ArrayLike<number>;
static newShortArray(size: number): ArrayLike<number>; static newShortArray(size: number): ArrayLike<number>;
static toFloatArray(array: Array<number>): number[] | Float32Array; static toFloatArray(array: Array<number>): number[] | Float32Array;
static toSinglePrecision(value: number): number;
} }
class DebugUtils { class DebugUtils {
static logBones(skeleton: Skeleton): void; static logBones(skeleton: Skeleton): void;

View File

@ -1216,7 +1216,7 @@ var spine;
return true; return true;
var finished = this.updateMixingFrom(from, delta); var finished = this.updateMixingFrom(from, delta);
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
this.queue.end(from); this.queue.end(from);
@ -2974,6 +2974,15 @@ var spine;
RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale"; RotateMode[RotateMode["ChainScale"] = 2] = "ChainScale";
})(RotateMode = spine.RotateMode || (spine.RotateMode = {})); })(RotateMode = spine.RotateMode || (spine.RotateMode = {}));
})(spine || (spine = {})); })(spine || (spine = {}));
(function () {
if (!Math.fround) {
Math.fround = (function (array) {
return function (x) {
return array[0] = x, array[0];
};
})(new Float32Array(1));
}
})();
var spine; var spine;
(function (spine) { (function (spine) {
var Assets = (function () { var Assets = (function () {
@ -4745,7 +4754,7 @@ var spine;
var eventData = skeletonData.findEvent(eventMap.name); var eventData = skeletonData.findEvent(eventMap.name);
if (eventData == null) if (eventData == null)
throw new Error("Event not found: " + eventMap.name); throw new Error("Event not found: " + eventMap.name);
var event_5 = new spine.Event(eventMap.time, eventData); var event_5 = new spine.Event(spine.Utils.toSinglePrecision(eventMap.time), eventData);
event_5.intValue = this.getValue(eventMap, "int", eventData.intValue); event_5.intValue = this.getValue(eventMap, "int", eventData.intValue);
event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue); event_5.floatValue = this.getValue(eventMap, "float", eventData.floatValue);
event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue); event_5.stringValue = this.getValue(eventMap, "string", eventData.stringValue);
@ -5879,6 +5888,9 @@ var spine;
Utils.toFloatArray = function (array) { Utils.toFloatArray = function (array) {
return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array; return Utils.SUPPORTS_TYPED_ARRAYS ? new Float32Array(array) : array;
}; };
Utils.toSinglePrecision = function (value) {
return Utils.SUPPORTS_TYPED_ARRAYS ? Math.fround(value) : value;
};
return Utils; return Utils;
}()); }());
Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined"; Utils.SUPPORTS_TYPED_ARRAYS = typeof (Float32Array) !== "undefined";

File diff suppressed because one or more lines are too long

View File

@ -116,7 +116,8 @@ module spine {
// Require mixTime > 0 to ensure the mixing from entry was applied at least once. // Require mixTime > 0 to ensure the mixing from entry was applied at least once.
if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) { if (to.mixTime > 0 && (to.mixTime >= to.mixDuration || to.timeScale == 0)) {
if (from.totalAlpha == 0) { // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame).
if (from.totalAlpha == 0 || to.mixDuration == 0) {
to.mixingFrom = from.mixingFrom; to.mixingFrom = from.mixingFrom;
to.interruptAlpha = from.interruptAlpha; to.interruptAlpha = from.interruptAlpha;
this.queue.end(from); this.queue.end(from);

View File

@ -170,7 +170,7 @@ namespace Spine.Unity.Editor {
#if NO_PREFAB_MESH #if NO_PREFAB_MESH
if (isInspectingPrefab) { if (isInspectingPrefab) {
MeshFilter meshFilter = component.GetComponent<MeshFilter>(); MeshFilter meshFilter = component.GetComponent<MeshFilter>();
if (meshFilter != null) if (meshFilter != null && meshFilter.sharedMesh != null)
meshFilter.sharedMesh = null; meshFilter.sharedMesh = null;
} }
#endif #endif
@ -211,7 +211,7 @@ namespace Spine.Unity.Editor {
#if NO_PREFAB_MESH #if NO_PREFAB_MESH
if (isInspectingPrefab) { if (isInspectingPrefab) {
MeshFilter meshFilter = component.GetComponent<MeshFilter>(); MeshFilter meshFilter = component.GetComponent<MeshFilter>();
if (meshFilter != null) if (meshFilter != null && meshFilter.sharedMesh != null)
meshFilter.sharedMesh = null; meshFilter.sharedMesh = null;
} }
#endif #endif

View File

@ -1020,13 +1020,18 @@ namespace Spine.Unity.Editor {
pageFiles.Add(atlasLines[i + 1].Trim()); pageFiles.Add(atlasLines[i + 1].Trim());
} }
atlasAsset.materials = new Material[pageFiles.Count]; var populatingMaterials = new List<Material>(pageFiles.Count);//atlasAsset.materials = new Material[pageFiles.Count];
for (int i = 0; i < pageFiles.Count; i++) { for (int i = 0; i < pageFiles.Count; i++) {
string texturePath = assetPath + "/" + pageFiles[i]; string texturePath = assetPath + "/" + pageFiles[i];
Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)); Texture2D texture = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D));
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath); TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
if (texImporter == null) {
Debug.LogWarning(string.Format("{0} ::: Texture asset \"{1}\" not found. Skipping. Please check your atlas file for renamed files.", atlasAsset.name, texturePath));
continue;
}
#if UNITY_5_5_OR_NEWER #if UNITY_5_5_OR_NEWER
texImporter.textureCompression = TextureImporterCompression.Uncompressed; texImporter.textureCompression = TextureImporterCompression.Uncompressed;
texImporter.alphaSource = TextureImporterAlphaSource.FromInput; texImporter.alphaSource = TextureImporterAlphaSource.FromInput;
@ -1039,7 +1044,6 @@ namespace Spine.Unity.Editor {
texImporter.spriteImportMode = SpriteImportMode.None; texImporter.spriteImportMode = SpriteImportMode.None;
texImporter.maxTextureSize = 2048; texImporter.maxTextureSize = 2048;
EditorUtility.SetDirty(texImporter); EditorUtility.SetDirty(texImporter);
AssetDatabase.ImportAsset(texturePath); AssetDatabase.ImportAsset(texturePath);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
@ -1064,9 +1068,11 @@ namespace Spine.Unity.Editor {
EditorUtility.SetDirty(mat); EditorUtility.SetDirty(mat);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
atlasAsset.materials[i] = mat; populatingMaterials.Add(mat); //atlasAsset.materials[i] = mat;
} }
atlasAsset.materials = populatingMaterials.ToArray();
for (int i = 0; i < vestigialMaterials.Count; i++) for (int i = 0; i < vestigialMaterials.Count; i++)
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i])); AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(vestigialMaterials[i]));
@ -1078,6 +1084,11 @@ namespace Spine.Unity.Editor {
EditorUtility.SetDirty(atlasAsset); EditorUtility.SetDirty(atlasAsset);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
if (pageFiles.Count != atlasAsset.materials.Length)
Debug.LogWarning(string.Format("{0} ::: Not all atlas pages were imported. If you rename your image files, please make sure you also edit the filenames specified in the atlas file.", atlasAsset.name));
else
Debug.Log(string.Format("{0} ::: Imported with {1} material", atlasAsset.name, atlasAsset.materials.Length));
// Iterate regions and bake marked. // Iterate regions and bake marked.
Atlas atlas = atlasAsset.GetAtlas(); Atlas atlas = atlasAsset.GetAtlas();
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic); FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);

View File

@ -72,6 +72,14 @@ namespace Spine.Unity.Modules {
#endregion #endregion
#region Runtime Instantiation #region Runtime Instantiation
/// <summary>Adds a SkeletonRenderSeparator and child SkeletonPartsRenderer GameObjects to a given SkeletonRenderer.</summary>
/// <returns>The to skeleton renderer.</returns>
/// <param name="skeletonRenderer">The target SkeletonRenderer or SkeletonAnimation.</param>
/// <param name="sortingLayerID">Sorting layer to be used for the parts renderers.</param>
/// <param name="extraPartsRenderers">Number of additional SkeletonPartsRenderers on top of the ones determined by counting the number of separator slots.</param>
/// <param name="sortingOrderIncrement">The integer to increment the sorting order per SkeletonPartsRenderer to separate them.</param>
/// <param name="baseSortingOrder">The sorting order value of the first SkeletonPartsRenderer.</param>
/// <param name="addMinimumPartsRenderers">If set to <c>true</c>, a minimum number of SkeletonPartsRenderer GameObjects (determined by separatorSlots.Count + 1) will be added.</param>
public static SkeletonRenderSeparator AddToSkeletonRenderer (SkeletonRenderer skeletonRenderer, int sortingLayerID = 0, int extraPartsRenderers = 0, int sortingOrderIncrement = DefaultSortingOrderIncrement, int baseSortingOrder = 0, bool addMinimumPartsRenderers = true) { public static SkeletonRenderSeparator AddToSkeletonRenderer (SkeletonRenderer skeletonRenderer, int sortingLayerID = 0, int extraPartsRenderers = 0, int sortingOrderIncrement = DefaultSortingOrderIncrement, int baseSortingOrder = 0, bool addMinimumPartsRenderers = true) {
if (skeletonRenderer == null) { if (skeletonRenderer == null) {
Debug.Log("Tried to add SkeletonRenderSeparator to a null SkeletonRenderer reference."); Debug.Log("Tried to add SkeletonRenderSeparator to a null SkeletonRenderer reference.");
@ -90,15 +98,34 @@ namespace Spine.Unity.Modules {
var componentRenderers = srs.partsRenderers; var componentRenderers = srs.partsRenderers;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
var smr = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRendererTransform, i.ToString()); var spr = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRendererTransform, i.ToString());
var mr = smr.MeshRenderer; var mr = spr.MeshRenderer;
mr.sortingLayerID = sortingLayerID; mr.sortingLayerID = sortingLayerID;
mr.sortingOrder = baseSortingOrder + (i * sortingOrderIncrement); mr.sortingOrder = baseSortingOrder + (i * sortingOrderIncrement);
componentRenderers.Add(smr); componentRenderers.Add(spr);
} }
return srs; return srs;
} }
/// <summary>Add a child SkeletonPartsRenderer GameObject to this SkeletonRenderSeparator.</summary>
public void AddPartsRenderer (int sortingOrderIncrement = DefaultSortingOrderIncrement) {
int sortingLayerID = 0;
int sortingOrder = 0;
if (partsRenderers.Count > 0) {
var previous = partsRenderers[partsRenderers.Count - 1];
var previousMeshRenderer = previous.MeshRenderer;
sortingLayerID = previousMeshRenderer.sortingLayerID;
sortingOrder = previousMeshRenderer.sortingOrder + sortingOrderIncrement;
}
var spr = SkeletonPartsRenderer.NewPartsRendererGameObject(skeletonRenderer.transform, partsRenderers.Count.ToString());
partsRenderers.Add(spr);
var mr = spr.MeshRenderer;
mr.sortingLayerID = sortingLayerID;
mr.sortingOrder = sortingOrder;
}
#endregion #endregion
void OnEnable () { void OnEnable () {

View File

@ -133,7 +133,7 @@ namespace Spine.Unity.Modules {
} }
Applied = false; Applied = false;
skeletonRenderer.LateUpdate(); if (skeletonRenderer.valid) skeletonRenderer.LateUpdate();
} }
public void GetTexture () { public void GetTexture () {

View File

@ -185,6 +185,20 @@ namespace Spine.Unity {
bone.WorldToLocal(worldPosition.x, worldPosition.y, out o.x, out o.y); bone.WorldToLocal(worldPosition.x, worldPosition.y, out o.x, out o.y);
return o; return o;
} }
/// <summary>Sets the skeleton-space position of a bone.</summary>
/// <returns>The local position in its parent bone space, or in skeleton space if it is the root bone.</returns>
public static Vector2 SetPositionSkeletonSpace (this Bone bone, Vector2 skeletonSpacePosition) {
if (bone.parent == null) { // root bone
bone.SetPosition(skeletonSpacePosition);
return skeletonSpacePosition;
} else {
var parent = bone.parent;
Vector2 parentLocal = parent.WorldToLocal(skeletonSpacePosition);
bone.SetPosition(parentLocal);
return parentLocal;
}
}
#endregion #endregion
#region Attachments #region Attachments

View File

@ -61,13 +61,14 @@ namespace Spine.Unity {
public bool useClipping = true; public bool useClipping = true;
public bool immutableTriangles = false; public bool immutableTriangles = false;
public bool pmaVertexColors = true; public bool pmaVertexColors = true;
/// <summary>Clears the state when this component or its GameObject is disabled. This prevents previous state from being retained when it is enabled again. When pooling your skeleton, setting this to true can be helpful.</summary>
public bool clearStateOnDisable = false; public bool clearStateOnDisable = false;
public bool tintBlack = false; public bool tintBlack = false;
public bool singleSubmesh = false; public bool singleSubmesh = false;
[UnityEngine.Serialization.FormerlySerializedAs("calculateNormals")] [UnityEngine.Serialization.FormerlySerializedAs("calculateNormals")]
public bool addNormals; public bool addNormals = false;
public bool calculateTangents; public bool calculateTangents = false;
public bool logErrors = false; public bool logErrors = false;
@ -134,6 +135,18 @@ namespace Spine.Unity {
} }
return c; return c;
} }
/// <summary>Applies MeshGenerator settings to the SkeletonRenderer and its internal MeshGenerator.</summary>
public void SetMeshSettings (MeshGenerator.Settings settings) {
this.calculateTangents = settings.calculateTangents;
this.immutableTriangles = settings.immutableTriangles;
this.pmaVertexColors = settings.pmaVertexColors;
this.tintBlack = settings.tintBlack;
this.useClipping = settings.useClipping;
this.zSpacing = settings.zSpacing;
this.meshGenerator.settings = settings;
}
#endregion #endregion
public virtual void Awake () { public virtual void Awake () {
@ -147,6 +160,7 @@ namespace Spine.Unity {
void OnDestroy () { void OnDestroy () {
rendererBuffers.Dispose(); rendererBuffers.Dispose();
valid = false;
} }
public virtual void ClearState () { public virtual void ClearState () {