mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 00:06:42 +08:00
Merge branch '4.1' into 4.2-beta
This commit is contained in:
commit
f221cf2085
@ -179,6 +179,7 @@
|
||||
4) Assign this *_Outline* material at the new child GameObject's `MeshRenderer` component.
|
||||
If you are using `SkeletonRenderSeparator` and need to enable and disable the `SkeletonRenderSeparator` component at runtime, you can increase the `RenderCombinedMesh` `Reference Renderers` array by one and assign the `SkeletonRenderer` itself at the last entry after the parts renderers. Disabled `MeshRenderer` components will be skipped when combining the final mesh, so the combined mesh is automatically filled from the desired active renderers.
|
||||
* Timeline extension package: Added static `EditorEvent` callback to allow editor scripts to react to animation events outside of play-mode. Register to the events via `Spine.Unity.Playables.SpineAnimationStateMixerBehaviour.EditorEvent += YourCallback;`.
|
||||
* URP Shaders: Added `Depth Write` property to shaders `Universal Render Pipeline/Spine/Skeleton` and `Universal Render Pipeline/Spine/Skeleton Lit`. Defaults to false to maintain existing behaviour.
|
||||
|
||||
* **Breaking changes**
|
||||
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.
|
||||
|
||||
@ -27,10 +27,12 @@
|
||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import openfl.utils.Assets;
|
||||
import spine.SkeletonData;
|
||||
import spine.animation.AnimationStateData;
|
||||
import spine.atlas.TextureAtlas;
|
||||
import spine.starling.SkeletonSprite;
|
||||
import spine.starling.StarlingTextureLoader;
|
||||
import starling.core.Starling;
|
||||
import starling.events.TouchEvent;
|
||||
import starling.events.TouchPhase;
|
||||
@ -39,8 +41,8 @@ class BasicExample extends Scene {
|
||||
var loadBinary = true;
|
||||
|
||||
public function load():Void {
|
||||
var atlas = TextureAtlas.fromAssets("assets/raptor.atlas");
|
||||
var skeletondata = SkeletonData.fromAssets("assets/raptor-pro" + (loadBinary ? ".skel" : ".json"), atlas);
|
||||
var atlas = new TextureAtlas(Assets.getText("assets/raptor.atlas"), new StarlingTextureLoader("assets/raptor-pro.atlas"));
|
||||
var skeletondata = SkeletonData.from(loadBinary ? Assets.getBytes("assets/raptor-pro.skel") : Assets.getText("assets/raptor-pro.json"), atlas);
|
||||
var animationStateData = new AnimationStateData(skeletondata);
|
||||
animationStateData.defaultMix = 0.25;
|
||||
|
||||
|
||||
@ -27,20 +27,22 @@
|
||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
import openfl.utils.Assets;
|
||||
import spine.SkeletonData;
|
||||
import spine.animation.AnimationStateData;
|
||||
import spine.atlas.TextureAtlas;
|
||||
import spine.starling.SkeletonSprite;
|
||||
import spine.starling.StarlingTextureLoader;
|
||||
import starling.core.Starling;
|
||||
import starling.events.TouchEvent;
|
||||
import starling.events.TouchPhase;
|
||||
|
||||
class SequenceExample extends Scene {
|
||||
var loadBinary = true;
|
||||
var loadBinary = false;
|
||||
|
||||
public function load():Void {
|
||||
var atlas = TextureAtlas.fromAssets("assets/dragon.atlas");
|
||||
var skeletondata = SkeletonData.fromAssets("assets/dragon-ess" + (loadBinary ? ".skel" : ".json"), atlas);
|
||||
var atlas = new TextureAtlas(Assets.getText("assets/dragon.atlas"), new StarlingTextureLoader("assets/dragon.atlas"));
|
||||
var skeletondata = SkeletonData.from(loadBinary ? Assets.getBytes("assets/dragon-ess.skel") : Assets.getText("assets/dragon-ess.json"), atlas);
|
||||
var animationStateData = new AnimationStateData(skeletondata);
|
||||
animationStateData.defaultMix = 0.25;
|
||||
|
||||
|
||||
@ -29,32 +29,48 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.utils.ByteArray;
|
||||
import openfl.Vector;
|
||||
import haxe.io.FPHelper;
|
||||
import haxe.io.Bytes;
|
||||
|
||||
class BinaryInput {
|
||||
private var bytes:ByteArray;
|
||||
private var bytes:Bytes;
|
||||
private var index:Int = 0;
|
||||
|
||||
public var strings:Vector<String> = new Vector<String>();
|
||||
public var strings:Array<String> = new Array<String>();
|
||||
|
||||
public function new(bytes:ByteArray) {
|
||||
public function new(bytes:Bytes) {
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public function readByte():Int {
|
||||
return bytes.readByte();
|
||||
var result = bytes.get(index++);
|
||||
if ((result & 0x80) != 0) {
|
||||
result |= 0xffffff00;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public function readUnsignedByte():Int {
|
||||
return bytes.readUnsignedByte();
|
||||
return bytes.get(index++);
|
||||
}
|
||||
|
||||
public function readShort():Int {
|
||||
return bytes.readShort();
|
||||
var ch1 = readUnsignedByte();
|
||||
var ch2 = readUnsignedByte();
|
||||
var result = ((ch1 << 8) | ch2);
|
||||
if ((result & 0x8000) != 0) {
|
||||
result |= 0xFFFF0000;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public function readInt32():Int {
|
||||
return bytes.readInt();
|
||||
var ch1 = readUnsignedByte();
|
||||
var ch2 = readUnsignedByte();
|
||||
var ch3 = readUnsignedByte();
|
||||
var ch4 = readUnsignedByte();
|
||||
var result = (ch1 << 24) | (ch2 << 16) | (ch3 << 8) | ch4;
|
||||
return result;
|
||||
}
|
||||
|
||||
public function readInt(optimizePositive:Bool):Int {
|
||||
@ -80,8 +96,8 @@ class BinaryInput {
|
||||
}
|
||||
|
||||
public function readStringRef():String {
|
||||
var index:Int = readInt(true);
|
||||
return index == 0 ? null : strings[index - 1];
|
||||
var idx:Int = readInt(true);
|
||||
return idx == 0 ? null : strings[idx - 1];
|
||||
}
|
||||
|
||||
public function readString():String {
|
||||
@ -113,7 +129,7 @@ class BinaryInput {
|
||||
}
|
||||
|
||||
public function readFloat():Float {
|
||||
return bytes.readFloat();
|
||||
return FPHelper.i32ToFloat(readInt32());
|
||||
}
|
||||
|
||||
public function readBoolean():Bool {
|
||||
|
||||
@ -29,15 +29,13 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class BlendMode {
|
||||
public static var normal(default, never):BlendMode = new BlendMode(0, "normal");
|
||||
public static var additive(default, never):BlendMode = new BlendMode(1, "additive");
|
||||
public static var multiply(default, never):BlendMode = new BlendMode(2, "multiply");
|
||||
public static var screen(default, never):BlendMode = new BlendMode(3, "screen");
|
||||
|
||||
public static var values(default, never):Vector<BlendMode> = Vector.ofArray([normal, additive, multiply, screen]);
|
||||
public static var values(default, never):Array<BlendMode> = [normal, additive, multiply, screen];
|
||||
|
||||
public var ordinal(default, null):Int;
|
||||
public var name(default, null):String;
|
||||
|
||||
@ -29,15 +29,13 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class Bone implements Updatable {
|
||||
static public var yDown:Bool = false;
|
||||
|
||||
private var _data:BoneData;
|
||||
private var _skeleton:Skeleton;
|
||||
private var _parent:Bone;
|
||||
private var _children:Vector<Bone> = new Vector<Bone>();
|
||||
private var _children:Array<Bone> = new Array<Bone>();
|
||||
|
||||
public var x:Float = 0;
|
||||
public var y:Float = 0;
|
||||
@ -230,9 +228,9 @@ class Bone implements Updatable {
|
||||
return _parent;
|
||||
}
|
||||
|
||||
public var children(get, never):Vector<Bone>;
|
||||
public var children(get, never):Array<Bone>;
|
||||
|
||||
private function get_children():Vector<Bone> {
|
||||
private function get_children():Array<Bone> {
|
||||
return _children;
|
||||
}
|
||||
|
||||
@ -308,7 +306,7 @@ class Bone implements Updatable {
|
||||
}
|
||||
}
|
||||
|
||||
public function worldToLocal(world:Vector<Float>):Void {
|
||||
public function worldToLocal(world:Array<Float>):Void {
|
||||
var a:Float = a, b:Float = b, c:Float = c, d:Float = d;
|
||||
var invDet:Float = 1 / (a * d - b * c);
|
||||
var x:Float = world[0] - worldX, y:Float = world[1] - worldY;
|
||||
@ -316,7 +314,7 @@ class Bone implements Updatable {
|
||||
world[1] = (y * a * invDet - x * c * invDet);
|
||||
}
|
||||
|
||||
public function localToWorld(local:Vector<Float>):Void {
|
||||
public function localToWorld(local:Array<Float>):Void {
|
||||
var localX:Float = local[0], localY:Float = local[1];
|
||||
local[0] = localX * a + localY * b + worldX;
|
||||
local[1] = localX * c + localY * d + worldY;
|
||||
|
||||
@ -29,12 +29,10 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class IkConstraint implements Updatable {
|
||||
private var _data:IkConstraintData;
|
||||
|
||||
public var bones:Vector<Bone>;
|
||||
public var bones:Array<Bone>;
|
||||
public var target:Bone;
|
||||
public var bendDirection:Int = 0;
|
||||
public var compress:Bool = false;
|
||||
@ -55,7 +53,7 @@ class IkConstraint implements Updatable {
|
||||
compress = data.compress;
|
||||
stretch = data.stretch;
|
||||
|
||||
bones = new Vector<Bone>();
|
||||
bones = new Array<Bone>();
|
||||
for (boneData in data.bones) {
|
||||
bones.push(skeleton.findBone(boneData.name));
|
||||
}
|
||||
|
||||
@ -29,10 +29,8 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class IkConstraintData extends ConstraintData {
|
||||
public var bones:Vector<BoneData> = new Vector<BoneData>();
|
||||
public var bones:Array<BoneData> = new Array<BoneData>();
|
||||
public var target:BoneData;
|
||||
public var mix:Float = 1;
|
||||
public var bendDirection:Int = 1;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.attachments.PathAttachment;
|
||||
|
||||
class PathConstraint implements Updatable {
|
||||
@ -39,7 +38,7 @@ class PathConstraint implements Updatable {
|
||||
private static inline var epsilon:Float = 0.00001;
|
||||
|
||||
private var _data:PathConstraintData;
|
||||
private var _bones:Vector<Bone>;
|
||||
private var _bones:Array<Bone>;
|
||||
|
||||
public var target:Slot;
|
||||
public var position:Float = 0;
|
||||
@ -48,12 +47,12 @@ class PathConstraint implements Updatable {
|
||||
public var mixX:Float = 0;
|
||||
public var mixY:Float = 0;
|
||||
|
||||
private var _spaces(default, never):Vector<Float> = new Vector<Float>();
|
||||
private var _positions(default, never):Vector<Float> = new Vector<Float>();
|
||||
private var _world(default, never):Vector<Float> = new Vector<Float>();
|
||||
private var _curves(default, never):Vector<Float> = new Vector<Float>();
|
||||
private var _lengths(default, never):Vector<Float> = new Vector<Float>();
|
||||
private var _segments(default, never):Vector<Float> = new Vector<Float>(10, true);
|
||||
private var _spaces(default, never):Array<Float> = new Array<Float>();
|
||||
private var _positions(default, never):Array<Float> = new Array<Float>();
|
||||
private var _world(default, never):Array<Float> = new Array<Float>();
|
||||
private var _curves(default, never):Array<Float> = new Array<Float>();
|
||||
private var _lengths(default, never):Array<Float> = new Array<Float>();
|
||||
private var _segments(default, never):Array<Float> = new Array<Float>();
|
||||
|
||||
public var active:Bool = false;
|
||||
|
||||
@ -63,7 +62,7 @@ class PathConstraint implements Updatable {
|
||||
if (skeleton == null)
|
||||
throw new SpineException("skeleton cannot be null.");
|
||||
_data = data;
|
||||
_bones = new Vector<Bone>();
|
||||
_bones = new Array<Bone>();
|
||||
for (boneData in data.bones) {
|
||||
_bones.push(skeleton.findBone(boneData.name));
|
||||
}
|
||||
@ -94,11 +93,11 @@ class PathConstraint implements Updatable {
|
||||
|
||||
var boneCount:Int = _bones.length;
|
||||
var spacesCount:Int = fTangents ? boneCount : boneCount + 1;
|
||||
var bones:Vector<Bone> = _bones;
|
||||
_spaces.length = spacesCount;
|
||||
var bones:Array<Bone> = _bones;
|
||||
_spaces.resize(spacesCount);
|
||||
|
||||
if (fScale)
|
||||
_lengths.length = boneCount;
|
||||
_lengths.resize(boneCount);
|
||||
|
||||
var i:Int,
|
||||
n:Int,
|
||||
@ -175,7 +174,7 @@ class PathConstraint implements Updatable {
|
||||
}
|
||||
}
|
||||
|
||||
var positions:Vector<Float> = computeWorldPositions(attachment, spacesCount, fTangents);
|
||||
var positions:Array<Float> = computeWorldPositions(attachment, spacesCount, fTangents);
|
||||
var boneX:Float = positions[0];
|
||||
var boneY:Float = positions[1];
|
||||
var offsetRotation:Float = data.offsetRotation;
|
||||
@ -253,10 +252,10 @@ class PathConstraint implements Updatable {
|
||||
}
|
||||
}
|
||||
|
||||
private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Vector<Float> {
|
||||
private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Array<Float> {
|
||||
var position:Float = this.position;
|
||||
_positions.length = spacesCount * 3 + 2;
|
||||
var out:Vector<Float> = _positions, world:Vector<Float>;
|
||||
_positions.resize(spacesCount * 3 + 2);
|
||||
var out:Array<Float> = _positions, world:Array<Float>;
|
||||
var closed:Bool = path.closed;
|
||||
var verticesLength:Int = path.worldVerticesLength;
|
||||
var curveCount:Int = Std.int(verticesLength / 6);
|
||||
@ -264,7 +263,7 @@ class PathConstraint implements Updatable {
|
||||
var multiplier:Float, i:Int;
|
||||
|
||||
if (!path.constantSpeed) {
|
||||
var lengths:Vector<Float> = path.lengths;
|
||||
var lengths:Array<Float> = path.lengths;
|
||||
curveCount -= closed ? 1 : 2;
|
||||
var pathLength:Float = lengths[curveCount];
|
||||
if (data.positionMode == PositionMode.percent)
|
||||
@ -278,7 +277,7 @@ class PathConstraint implements Updatable {
|
||||
multiplier = 1;
|
||||
}
|
||||
|
||||
_world.length = 8;
|
||||
_world.resize(8);
|
||||
world = _world;
|
||||
var i:Int = 0;
|
||||
var o:Int = 0;
|
||||
@ -344,7 +343,7 @@ class PathConstraint implements Updatable {
|
||||
// World vertices.
|
||||
if (closed) {
|
||||
verticesLength += 2;
|
||||
_world.length = verticesLength;
|
||||
_world.resize(verticesLength);
|
||||
world = _world;
|
||||
path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
|
||||
path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
|
||||
@ -353,14 +352,14 @@ class PathConstraint implements Updatable {
|
||||
} else {
|
||||
curveCount--;
|
||||
verticesLength -= 4;
|
||||
_world.length = verticesLength;
|
||||
_world.resize(verticesLength);
|
||||
world = _world;
|
||||
path.computeWorldVertices(target, 2, verticesLength, world, 0, 2);
|
||||
}
|
||||
|
||||
// Curve lengths.
|
||||
_curves.length = curveCount;
|
||||
var curves:Vector<Float> = _curves;
|
||||
_curves.resize(curveCount);
|
||||
var curves:Array<Float> = _curves;
|
||||
var pathLength:Float = 0;
|
||||
var x1:Float = world[0],
|
||||
y1:Float = world[1],
|
||||
@ -420,7 +419,7 @@ class PathConstraint implements Updatable {
|
||||
multiplier = 1;
|
||||
}
|
||||
|
||||
var segments:Vector<Float> = _segments;
|
||||
var segments:Array<Float> = _segments;
|
||||
var curveLength:Float = 0;
|
||||
var segment:Int;
|
||||
i = 0;
|
||||
@ -529,7 +528,7 @@ class PathConstraint implements Updatable {
|
||||
return out;
|
||||
}
|
||||
|
||||
private function addBeforePosition(p:Float, temp:Vector<Float>, i:Int, out:Vector<Float>, o:Int):Void {
|
||||
private function addBeforePosition(p:Float, temp:Array<Float>, i:Int, out:Array<Float>, o:Int):Void {
|
||||
var x1:Float = temp[i];
|
||||
var y1:Float = temp[i + 1];
|
||||
var dx:Float = temp[i + 2] - x1;
|
||||
@ -540,7 +539,7 @@ class PathConstraint implements Updatable {
|
||||
out[o + 2] = r;
|
||||
}
|
||||
|
||||
private function addAfterPosition(p:Float, temp:Vector<Float>, i:Int, out:Vector<Float>, o:Int):Void {
|
||||
private function addAfterPosition(p:Float, temp:Array<Float>, i:Int, out:Array<Float>, o:Int):Void {
|
||||
var x1:Float = temp[i + 2];
|
||||
var y1:Float = temp[i + 3];
|
||||
var dx:Float = x1 - temp[i];
|
||||
@ -551,7 +550,7 @@ class PathConstraint implements Updatable {
|
||||
out[o + 2] = r;
|
||||
}
|
||||
|
||||
private function addCurvePosition(p:Float, x1:Float, y1:Float, cx1:Float, cy1:Float, cx2:Float, cy2:Float, x2:Float, y2:Float, out:Vector<Float>, o:Int,
|
||||
private function addCurvePosition(p:Float, x1:Float, y1:Float, cx1:Float, cy1:Float, cx2:Float, cy2:Float, x2:Float, y2:Float, out:Array<Float>, o:Int,
|
||||
tangents:Bool):Void {
|
||||
if (p == 0 || Math.isNaN(p)) {
|
||||
out[o] = x1;
|
||||
@ -581,9 +580,9 @@ class PathConstraint implements Updatable {
|
||||
}
|
||||
}
|
||||
|
||||
public var bones(get, never):Vector<Bone>;
|
||||
public var bones(get, never):Array<Bone>;
|
||||
|
||||
private function get_bones():Vector<Bone> {
|
||||
private function get_bones():Array<Bone> {
|
||||
return _bones;
|
||||
}
|
||||
|
||||
|
||||
@ -29,10 +29,8 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class PathConstraintData extends ConstraintData {
|
||||
private var _bones:Vector<BoneData> = new Vector<BoneData>();
|
||||
private var _bones:Array<BoneData> = new Array<BoneData>();
|
||||
|
||||
public var target:SlotData;
|
||||
public var positionMode:PositionMode = PositionMode.fixed;
|
||||
@ -49,9 +47,9 @@ class PathConstraintData extends ConstraintData {
|
||||
super(name, 0, false);
|
||||
}
|
||||
|
||||
public var bones(get, never):Vector<BoneData>;
|
||||
public var bones(get, never):Array<BoneData>;
|
||||
|
||||
private function get_bones():Vector<BoneData> {
|
||||
private function get_bones():Array<BoneData> {
|
||||
return _bones;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,10 +29,8 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class Polygon {
|
||||
public var vertices:Vector<Float> = new Vector<Float>();
|
||||
public var vertices:Array<Float> = new Array<Float>();
|
||||
|
||||
public function new() {}
|
||||
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
#if flash
|
||||
typedef Function = Dynamic;
|
||||
#else
|
||||
@ -38,11 +36,11 @@ typedef Function = haxe.Constraints.Function;
|
||||
#end
|
||||
|
||||
@:generic class Pool<T> {
|
||||
private var items:Vector<T>;
|
||||
private var items:Array<T>;
|
||||
private var instantiator:Function;
|
||||
|
||||
public function new(instantiator:Void->T) {
|
||||
this.items = new Vector<T>();
|
||||
this.items = new Array<T>();
|
||||
this.instantiator = instantiator;
|
||||
}
|
||||
|
||||
@ -56,13 +54,13 @@ typedef Function = haxe.Constraints.Function;
|
||||
items.push(item);
|
||||
}
|
||||
|
||||
public function freeAll(items:Vector<T>):Void {
|
||||
public function freeAll(items:Array<T>):Void {
|
||||
for (item in items) {
|
||||
free(item);
|
||||
}
|
||||
}
|
||||
|
||||
public function clear():Void {
|
||||
items.length = 0;
|
||||
items.resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,13 +29,11 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class PositionMode {
|
||||
public static var fixed(default, never):PositionMode = new PositionMode("fixed");
|
||||
public static var percent(default, never):PositionMode = new PositionMode("percent");
|
||||
|
||||
public static var values(default, never):Vector<PositionMode> = Vector.ofArray([fixed, percent]);
|
||||
public static var values(default, never):Array<PositionMode> = [fixed, percent];
|
||||
|
||||
public var name(default, null):String;
|
||||
|
||||
|
||||
15
spine-haxe/spine-haxe/spine/Rectangle.hx
Normal file
15
spine-haxe/spine-haxe/spine/Rectangle.hx
Normal file
@ -0,0 +1,15 @@
|
||||
package spine;
|
||||
|
||||
class Rectangle {
|
||||
public var x:Float;
|
||||
public var y:Float;
|
||||
public var width:Float;
|
||||
public var height:Float;
|
||||
|
||||
public function new() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
@ -29,14 +29,12 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class RotateMode {
|
||||
public static var tangent(default, never):RotateMode = new RotateMode("tangent");
|
||||
public static var chain(default, never):RotateMode = new RotateMode("chain");
|
||||
public static var chainScale(default, never):RotateMode = new RotateMode("chainScale");
|
||||
|
||||
public static var values(default, never):Vector<RotateMode> = Vector.ofArray([tangent, chain, chainScale]);
|
||||
public static var values(default, never):Array<RotateMode> = [tangent, chain, chainScale];
|
||||
|
||||
public var name(default, null):String;
|
||||
|
||||
|
||||
@ -29,13 +29,11 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class Sequence {
|
||||
private static var _nextID = 0;
|
||||
|
||||
public var id = _nextID++;
|
||||
public var regions:Vector<TextureRegion>;
|
||||
public var regions:Array<TextureRegion>;
|
||||
public var start = 0;
|
||||
public var digits = 0;
|
||||
|
||||
@ -43,7 +41,8 @@ class Sequence {
|
||||
public var setupIndex = 0;
|
||||
|
||||
public function new(count:Int) {
|
||||
this.regions = new Vector<TextureRegion>(count);
|
||||
this.regions = new Array<TextureRegion>();
|
||||
this.regions.resize(count);
|
||||
}
|
||||
|
||||
public function copy():Sequence {
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class SequenceMode {
|
||||
public static var hold(default, never):SequenceMode = new SequenceMode("hold", 0);
|
||||
public static var once(default, never):SequenceMode = new SequenceMode("once", 1);
|
||||
@ -40,7 +38,7 @@ class SequenceMode {
|
||||
public static var loopReverse(default, never):SequenceMode = new SequenceMode("loopReverse", 5);
|
||||
public static var pingpongReverse(default, never):SequenceMode = new SequenceMode("pingpongReverse", 6);
|
||||
|
||||
public static var values(default, never):Vector<SequenceMode> = Vector.ofArray([hold, once, loop, pingpong, onceReverse, loopReverse, pingpongReverse]);
|
||||
public static var values(default, never):Array<SequenceMode> = [hold, once, loop, pingpong, onceReverse, loopReverse, pingpongReverse];
|
||||
|
||||
public var name(default, null):String;
|
||||
public var value:Int;
|
||||
|
||||
@ -29,9 +29,8 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.geom.Rectangle;
|
||||
import openfl.utils.Dictionary;
|
||||
import openfl.Vector;
|
||||
import lime.math.Rectangle;
|
||||
import haxe.ds.StringMap;
|
||||
import spine.attachments.Attachment;
|
||||
import spine.attachments.MeshAttachment;
|
||||
import spine.attachments.PathAttachment;
|
||||
@ -40,14 +39,14 @@ import spine.attachments.RegionAttachment;
|
||||
class Skeleton {
|
||||
private var _data:SkeletonData;
|
||||
|
||||
public var bones:Vector<Bone>;
|
||||
public var slots:Vector<Slot>;
|
||||
public var drawOrder:Vector<Slot>;
|
||||
public var ikConstraints:Vector<IkConstraint>;
|
||||
public var transformConstraints:Vector<TransformConstraint>;
|
||||
public var pathConstraints:Vector<PathConstraint>;
|
||||
public var bones:Array<Bone>;
|
||||
public var slots:Array<Slot>;
|
||||
public var drawOrder:Array<Slot>;
|
||||
public var ikConstraints:Array<IkConstraint>;
|
||||
public var transformConstraints:Array<TransformConstraint>;
|
||||
public var pathConstraints:Array<PathConstraint>;
|
||||
|
||||
private var _updateCache:Vector<Updatable> = new Vector<Updatable>();
|
||||
private var _updateCache:Array<Updatable> = new Array<Updatable>();
|
||||
private var _skin:Skin;
|
||||
|
||||
public var color:Color = new Color(1, 1, 1, 1);
|
||||
@ -62,7 +61,7 @@ class Skeleton {
|
||||
}
|
||||
_data = data;
|
||||
|
||||
bones = new Vector<Bone>();
|
||||
bones = new Array<Bone>();
|
||||
for (boneData in data.bones) {
|
||||
var bone:Bone;
|
||||
if (boneData.parent == null) {
|
||||
@ -75,8 +74,8 @@ class Skeleton {
|
||||
bones.push(bone);
|
||||
}
|
||||
|
||||
slots = new Vector<Slot>();
|
||||
drawOrder = new Vector<Slot>();
|
||||
slots = new Array<Slot>();
|
||||
drawOrder = new Array<Slot>();
|
||||
for (slotData in data.slots) {
|
||||
var bone = bones[slotData.boneData.index];
|
||||
var slot:Slot = new Slot(slotData, bone);
|
||||
@ -84,17 +83,17 @@ class Skeleton {
|
||||
drawOrder.push(slot);
|
||||
}
|
||||
|
||||
ikConstraints = new Vector<IkConstraint>();
|
||||
ikConstraints = new Array<IkConstraint>();
|
||||
for (ikConstraintData in data.ikConstraints) {
|
||||
ikConstraints.push(new IkConstraint(ikConstraintData, this));
|
||||
}
|
||||
|
||||
transformConstraints = new Vector<TransformConstraint>();
|
||||
transformConstraints = new Array<TransformConstraint>();
|
||||
for (transformConstraintData in data.transformConstraints) {
|
||||
transformConstraints.push(new TransformConstraint(transformConstraintData, this));
|
||||
}
|
||||
|
||||
pathConstraints = new Vector<PathConstraint>();
|
||||
pathConstraints = new Array<PathConstraint>();
|
||||
for (pathConstraintData in data.pathConstraints) {
|
||||
pathConstraints.push(new PathConstraint(pathConstraintData, this));
|
||||
}
|
||||
@ -105,7 +104,7 @@ class Skeleton {
|
||||
/** Caches information about bones and constraints. Must be called if bones, constraints, or weighted path attachments are
|
||||
* added or removed. */
|
||||
public function updateCache():Void {
|
||||
_updateCache.length = 0;
|
||||
_updateCache.resize(0);
|
||||
|
||||
for (bone in bones) {
|
||||
bone.sorted = bone.data.skinRequired;
|
||||
@ -113,7 +112,7 @@ class Skeleton {
|
||||
}
|
||||
|
||||
if (skin != null) {
|
||||
var skinBones:Vector<BoneData> = skin.bones;
|
||||
var skinBones:Array<BoneData> = skin.bones;
|
||||
for (i in 0...skin.bones.length) {
|
||||
var bone:Bone = bones[skinBones[i].index];
|
||||
do {
|
||||
@ -164,7 +163,7 @@ class Skeleton {
|
||||
}
|
||||
}
|
||||
|
||||
private static function contains(list:Vector<ConstraintData>, element:ConstraintData):Bool {
|
||||
private static function contains(list:Array<ConstraintData>, element:ConstraintData):Bool {
|
||||
return list.indexOf(element) != -1;
|
||||
}
|
||||
|
||||
@ -177,7 +176,7 @@ class Skeleton {
|
||||
var target:Bone = constraint.target;
|
||||
sortBone(target);
|
||||
|
||||
var constrained:Vector<Bone> = constraint.bones;
|
||||
var constrained:Array<Bone> = constraint.bones;
|
||||
var parent:Bone = constrained[0];
|
||||
sortBone(parent);
|
||||
|
||||
@ -222,7 +221,7 @@ class Skeleton {
|
||||
if (Std.isOfType(attachment, PathAttachment))
|
||||
sortPathConstraintAttachment2(attachment, slotBone);
|
||||
|
||||
var constrainedBones:Vector<Bone> = constraint.bones;
|
||||
var constrainedBones:Array<Bone> = constraint.bones;
|
||||
for (bone in constrainedBones) {
|
||||
sortBone(bone);
|
||||
}
|
||||
@ -245,7 +244,7 @@ class Skeleton {
|
||||
|
||||
sortBone(constraint.target);
|
||||
|
||||
var constrainedBones:Vector<Bone> = constraint.bones;
|
||||
var constrainedBones:Array<Bone> = constraint.bones;
|
||||
if (constraint.data.local) {
|
||||
for (bone in constrainedBones) {
|
||||
sortBone(bone.parent);
|
||||
@ -267,10 +266,10 @@ class Skeleton {
|
||||
}
|
||||
|
||||
private function sortPathConstraintAttachment(skin:Skin, slotIndex:Int, slotBone:Bone):Void {
|
||||
var dict:Dictionary<String, Attachment> = skin.attachments[slotIndex];
|
||||
var dict:StringMap<Attachment> = skin.attachments[slotIndex];
|
||||
if (dict != null) {
|
||||
for (attachment in dict.each()) {
|
||||
sortPathConstraintAttachment2(attachment, slotBone);
|
||||
for (attachment in dict.keyValueIterator()) {
|
||||
sortPathConstraintAttachment2(attachment.value, slotBone);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,7 +278,7 @@ class Skeleton {
|
||||
var pathAttachment:PathAttachment = cast(attachment, PathAttachment);
|
||||
if (pathAttachment == null)
|
||||
return;
|
||||
var pathBones:Vector<Int> = pathAttachment.bones;
|
||||
var pathBones:Array<Int> = pathAttachment.bones;
|
||||
if (pathBones == null) {
|
||||
sortBone(slotBone);
|
||||
} else {
|
||||
@ -305,7 +304,7 @@ class Skeleton {
|
||||
_updateCache.push(bone);
|
||||
}
|
||||
|
||||
private function sortReset(bones:Vector<Bone>):Void {
|
||||
private function sortReset(bones:Array<Bone>):Void {
|
||||
for (bone in bones) {
|
||||
if (!bone.active)
|
||||
continue;
|
||||
@ -411,9 +410,9 @@ class Skeleton {
|
||||
return _data;
|
||||
}
|
||||
|
||||
public var getUpdateCache(get, never):Vector<Updatable>;
|
||||
public var getUpdateCache(get, never):Array<Updatable>;
|
||||
|
||||
private function get_getUpdateCache():Vector<Updatable> {
|
||||
private function get_getUpdateCache():Array<Updatable> {
|
||||
return _updateCache;
|
||||
}
|
||||
|
||||
@ -590,7 +589,7 @@ class Skeleton {
|
||||
return _data.name != null ? _data.name : "Skeleton?";
|
||||
}
|
||||
|
||||
private var _tempVertices = new Vector<Float>();
|
||||
private var _tempVertices = new Array<Float>();
|
||||
private var _bounds = new Rectangle();
|
||||
|
||||
public function getBounds():Rectangle {
|
||||
@ -600,17 +599,17 @@ class Skeleton {
|
||||
var maxY:Float = Math.NEGATIVE_INFINITY;
|
||||
for (slot in drawOrder) {
|
||||
var verticesLength:Int = 0;
|
||||
var vertices:Vector<Float> = null;
|
||||
var vertices:Array<Float> = null;
|
||||
var attachment:Attachment = slot.attachment;
|
||||
if (Std.isOfType(attachment, RegionAttachment)) {
|
||||
verticesLength = 8;
|
||||
_tempVertices.length = verticesLength;
|
||||
_tempVertices.resize(verticesLength);
|
||||
vertices = _tempVertices;
|
||||
cast(attachment, RegionAttachment).computeWorldVertices(slot, vertices, 0, 2);
|
||||
} else if (Std.isOfType(attachment, MeshAttachment)) {
|
||||
var mesh:MeshAttachment = cast(attachment, MeshAttachment);
|
||||
verticesLength = mesh.worldVerticesLength;
|
||||
_tempVertices.length = verticesLength;
|
||||
_tempVertices.resize(verticesLength);
|
||||
vertices = _tempVertices;
|
||||
mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
|
||||
}
|
||||
|
||||
@ -29,10 +29,8 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import haxe.io.Bytes;
|
||||
import StringTools;
|
||||
import openfl.Vector;
|
||||
import openfl.utils.ByteArray;
|
||||
import openfl.utils.Endian;
|
||||
import spine.animation.AlphaTimeline;
|
||||
import spine.animation.Animation;
|
||||
import spine.animation.AttachmentTimeline;
|
||||
@ -78,7 +76,7 @@ class SkeletonBinary {
|
||||
public var attachmentLoader:AttachmentLoader;
|
||||
public var scale:Float = 1;
|
||||
|
||||
private var linkedMeshes:Vector<LinkedMeshBinary> = new Vector<LinkedMeshBinary>();
|
||||
private var linkedMeshes:Array<LinkedMeshBinary> = new Array<LinkedMeshBinary>();
|
||||
|
||||
private static inline var BONE_ROTATE:Int = 0;
|
||||
private static inline var BONE_TRANSLATE:Int = 1;
|
||||
@ -113,8 +111,8 @@ class SkeletonBinary {
|
||||
this.attachmentLoader = attachmentLoader;
|
||||
}
|
||||
|
||||
public function readSkeletonData(bytes:ByteArray):SkeletonData {
|
||||
bytes.endian = Endian.BIG_ENDIAN;
|
||||
public function readSkeletonData(bytes:Bytes):SkeletonData {
|
||||
// bytes.getData(). = Endian.BIG_ENDIAN;
|
||||
|
||||
var skeletonData:SkeletonData = new SkeletonData();
|
||||
skeletonData.name = null;
|
||||
@ -291,7 +289,7 @@ class SkeletonBinary {
|
||||
if (linkedMesh.mesh.region != null)
|
||||
linkedMesh.mesh.updateRegion();
|
||||
}
|
||||
linkedMeshes.length = 0;
|
||||
linkedMeshes.resize(0);
|
||||
|
||||
// Events.
|
||||
n = input.readInt(true);
|
||||
@ -327,7 +325,7 @@ class SkeletonBinary {
|
||||
skin = new Skin("default");
|
||||
} else {
|
||||
skin = new Skin(input.readStringRef());
|
||||
skin.bones.length = input.readInt(true);
|
||||
skin.bones.resize(input.readInt(true));
|
||||
for (i in 0...skin.bones.length) {
|
||||
skin.bones[i] = skeletonData.bones[input.readInt(true)];
|
||||
}
|
||||
@ -436,12 +434,12 @@ class SkeletonBinary {
|
||||
path = input.readStringRef();
|
||||
color = input.readInt32();
|
||||
vertexCount = input.readInt(true);
|
||||
var uvs:Vector<Float> = readFloatArray(input, vertexCount << 1, 1);
|
||||
var triangles:Vector<Int> = readShortArray(input);
|
||||
var uvs:Array<Float> = readFloatArray(input, vertexCount << 1, 1);
|
||||
var triangles:Array<Int> = readShortArray(input);
|
||||
vertices = readVertices(input, vertexCount);
|
||||
var hullLength:Int = input.readInt(true);
|
||||
var sequence = readSequence(input);
|
||||
var edges:Vector<Int> = null;
|
||||
var edges:Array<Int> = null;
|
||||
if (nonessential) {
|
||||
edges = readShortArray(input);
|
||||
width = input.readFloat();
|
||||
@ -502,8 +500,8 @@ class SkeletonBinary {
|
||||
var constantSpeed:Bool = input.readBoolean();
|
||||
vertexCount = input.readInt(true);
|
||||
vertices = readVertices(input, vertexCount);
|
||||
var lengths:Vector<Float> = new Vector<Float>();
|
||||
lengths.length = Std.int(vertexCount / 3);
|
||||
var lengths:Array<Float> = new Array<Float>();
|
||||
lengths.resize(Std.int(vertexCount / 3));
|
||||
for (i in 0...lengths.length) {
|
||||
lengths[i] = input.readFloat() * scale;
|
||||
}
|
||||
@ -567,8 +565,8 @@ class SkeletonBinary {
|
||||
vertices.vertices = readFloatArray(input, verticesLength, scale);
|
||||
return vertices;
|
||||
}
|
||||
var weights:Vector<Float> = new Vector<Float>();
|
||||
var bonesArray:Vector<Int> = new Vector<Int>();
|
||||
var weights:Array<Float> = new Array<Float>();
|
||||
var bonesArray:Array<Int> = new Array<Int>();
|
||||
for (i in 0...vertexCount) {
|
||||
var boneCount:Int = input.readInt(true);
|
||||
bonesArray.push(boneCount);
|
||||
@ -584,8 +582,8 @@ class SkeletonBinary {
|
||||
return vertices;
|
||||
}
|
||||
|
||||
private function readFloatArray(input:BinaryInput, n:Int, scale:Float):Vector<Float> {
|
||||
var array:Vector<Float> = new Vector<Float>();
|
||||
private function readFloatArray(input:BinaryInput, n:Int, scale:Float):Array<Float> {
|
||||
var array:Array<Float> = new Array<Float>();
|
||||
if (scale == 1) {
|
||||
for (i in 0...n) {
|
||||
array.push(input.readFloat());
|
||||
@ -598,9 +596,9 @@ class SkeletonBinary {
|
||||
return array;
|
||||
}
|
||||
|
||||
private function readShortArray(input:BinaryInput):Vector<Int> {
|
||||
private function readShortArray(input:BinaryInput):Array<Int> {
|
||||
var n:Int = input.readInt(true);
|
||||
var array:Vector<Int> = new Vector<Int>();
|
||||
var array:Array<Int> = new Array<Int>();
|
||||
for (i in 0...n) {
|
||||
array.push(input.readShort());
|
||||
}
|
||||
@ -609,7 +607,7 @@ class SkeletonBinary {
|
||||
|
||||
private function readAnimation(input:BinaryInput, name:String, skeletonData:SkeletonData):Animation {
|
||||
input.readInt(true); // Count of timelines.
|
||||
var timelines:Vector<Timeline> = new Vector<Timeline>();
|
||||
var timelines:Array<Timeline> = new Array<Timeline>();
|
||||
var i:Int = 0, n:Int = 0, ii:Int = 0, nn:Int = 0;
|
||||
|
||||
var index:Int, slotIndex:Int, timelineType:Int, timelineScale:Float;
|
||||
@ -1042,7 +1040,7 @@ class SkeletonBinary {
|
||||
case ATTACHMENT_DEFORM:
|
||||
var vertexAttachment = cast(attachment, VertexAttachment);
|
||||
var weighted:Bool = vertexAttachment.bones != null;
|
||||
var vertices:Vector<Float> = vertexAttachment.vertices;
|
||||
var vertices:Array<Float> = vertexAttachment.vertices;
|
||||
var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length;
|
||||
|
||||
bezierCount = input.readInt(true);
|
||||
@ -1052,17 +1050,19 @@ class SkeletonBinary {
|
||||
frame = 0;
|
||||
bezier = 0;
|
||||
while (true) {
|
||||
var deform:Vector<Float>;
|
||||
var deform:Array<Float>;
|
||||
var end:Int = input.readInt(true);
|
||||
if (end == 0) {
|
||||
if (weighted) {
|
||||
deform = new Vector<Float>(deformLength, true);
|
||||
deform = new Array<Float>();
|
||||
deform.resize(deformLength);
|
||||
} else {
|
||||
deform = vertices;
|
||||
}
|
||||
} else {
|
||||
var v:Int, vn:Int;
|
||||
deform = new Vector<Float>(deformLength, true);
|
||||
deform = new Array<Float>();
|
||||
deform.resize(deformLength);
|
||||
var start:Int = input.readInt(true);
|
||||
end += start;
|
||||
if (scale == 1) {
|
||||
@ -1118,12 +1118,14 @@ class SkeletonBinary {
|
||||
for (i in 0...drawOrderCount) {
|
||||
time = input.readFloat();
|
||||
var offsetCount:Int = input.readInt(true);
|
||||
var drawOrder:Vector<Int> = new Vector<Int>(slotCount, true);
|
||||
var drawOrder:Array<Int> = new Array<Int>();
|
||||
drawOrder.resize(slotCount);
|
||||
var ii:Int = slotCount - 1;
|
||||
while (ii >= 0) {
|
||||
drawOrder[ii--] = -1;
|
||||
}
|
||||
var unchanged:Vector<Int> = new Vector<Int>(slotCount - offsetCount, true);
|
||||
var unchanged:Array<Int> = new Array<Int>();
|
||||
unchanged.resize(slotCount - offsetCount);
|
||||
var originalIndex:Int = 0, unchangedIndex:Int = 0;
|
||||
for (ii in 0...offsetCount) {
|
||||
slotIndex = input.readInt(true);
|
||||
@ -1245,8 +1247,8 @@ class SkeletonBinary {
|
||||
}
|
||||
|
||||
class Vertices {
|
||||
public var vertices:Vector<Float> = new Vector<Float>();
|
||||
public var bones:Vector<Int> = new Vector<Int>();
|
||||
public var vertices:Array<Float> = new Array<Float>();
|
||||
public var bones:Array<Int> = new Array<Int>();
|
||||
|
||||
public function new() {}
|
||||
}
|
||||
|
||||
@ -29,22 +29,21 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.attachments.ClippingAttachment;
|
||||
|
||||
class SkeletonClipping {
|
||||
private var triangulator:Triangulator = new Triangulator();
|
||||
private var clippingPolygon:Vector<Float> = new Vector<Float>();
|
||||
private var clipOutput:Vector<Float> = new Vector<Float>();
|
||||
private var clippingPolygon:Array<Float> = new Array<Float>();
|
||||
private var clipOutput:Array<Float> = new Array<Float>();
|
||||
|
||||
public var clippedVertices:Vector<Float> = new Vector<Float>();
|
||||
public var clippedUvs:Vector<Float> = new Vector<Float>();
|
||||
public var clippedTriangles:Vector<Int> = new Vector<Int>();
|
||||
public var clippedVertices:Array<Float> = new Array<Float>();
|
||||
public var clippedUvs:Array<Float> = new Array<Float>();
|
||||
public var clippedTriangles:Array<Int> = new Array<Int>();
|
||||
|
||||
private var scratch:Vector<Float> = new Vector<Float>();
|
||||
private var scratch:Array<Float> = new Array<Float>();
|
||||
|
||||
private var clipAttachment:ClippingAttachment;
|
||||
private var clippingPolygons:Vector<Vector<Float>>;
|
||||
private var clippingPolygons:Array<Array<Float>>;
|
||||
|
||||
public function new() {}
|
||||
|
||||
@ -52,7 +51,7 @@ class SkeletonClipping {
|
||||
if (clipAttachment != null)
|
||||
return 0;
|
||||
clipAttachment = clip;
|
||||
clippingPolygon.length = clip.worldVerticesLength;
|
||||
clippingPolygon.resize(clip.worldVerticesLength);
|
||||
clip.computeWorldVertices(slot, 0, clippingPolygon.length, clippingPolygon, 0, 2);
|
||||
SkeletonClipping.makeClockwise(clippingPolygon);
|
||||
clippingPolygons = triangulator.decompose(clippingPolygon, triangulator.triangulate(clippingPolygon));
|
||||
@ -74,23 +73,23 @@ class SkeletonClipping {
|
||||
return;
|
||||
clipAttachment = null;
|
||||
clippingPolygons = null;
|
||||
clippedVertices.length = 0;
|
||||
clippedUvs.length = 0;
|
||||
clippedTriangles.length = 0;
|
||||
clippingPolygon.length = 0;
|
||||
clipOutput.length = 0;
|
||||
clippedVertices.resize(0);
|
||||
clippedUvs.resize(0);
|
||||
clippedTriangles.resize(0);
|
||||
clippingPolygon.resize(0);
|
||||
clipOutput.resize(0);
|
||||
}
|
||||
|
||||
public function isClipping():Bool {
|
||||
return clipAttachment != null;
|
||||
}
|
||||
|
||||
public function clipTriangles(vertices:Vector<Float>, triangles:Vector<Int>, trianglesLength:Float, uvs:Vector<Float>):Void {
|
||||
public function clipTriangles(vertices:Array<Float>, triangles:Array<Int>, trianglesLength:Float, uvs:Array<Float>):Void {
|
||||
var polygonsCount:Int = clippingPolygons.length;
|
||||
var index:Int = 0;
|
||||
clippedVertices.length = 0;
|
||||
clippedUvs.length = 0;
|
||||
clippedTriangles.length = 0;
|
||||
clippedVertices.resize(0);
|
||||
clippedUvs.resize(0);
|
||||
clippedTriangles.resize(0);
|
||||
var i:Int = 0;
|
||||
while (i < trianglesLength) {
|
||||
var vertexOffset:Int = triangles[i] << 1;
|
||||
@ -110,9 +109,9 @@ class SkeletonClipping {
|
||||
|
||||
for (p in 0...polygonsCount) {
|
||||
var s:Int = clippedVertices.length;
|
||||
var clippedVerticesItems:Vector<Float>;
|
||||
var clippedUvsItems:Vector<Float>;
|
||||
var clippedTrianglesItems:Vector<Int>;
|
||||
var clippedVerticesItems:Array<Float>;
|
||||
var clippedUvsItems:Array<Float>;
|
||||
var clippedTrianglesItems:Array<Int>;
|
||||
if (this.clip(x1, y1, x2, y2, x3, y3, clippingPolygons[p], clipOutput)) {
|
||||
var clipOutputLength:Int = clipOutput.length;
|
||||
if (clipOutputLength == 0)
|
||||
@ -124,11 +123,11 @@ class SkeletonClipping {
|
||||
var d:Float = 1 / (d0 * d2 + d1 * (y1 - y3));
|
||||
|
||||
var clipOutputCount:Int = clipOutputLength >> 1;
|
||||
var clipOutputItems:Vector<Float> = clipOutput;
|
||||
var clipOutputItems:Array<Float> = clipOutput;
|
||||
clippedVerticesItems = clippedVertices;
|
||||
clippedVerticesItems.length = s + clipOutputLength;
|
||||
clippedVerticesItems.resize(s + clipOutputLength);
|
||||
clippedUvsItems = clippedUvs;
|
||||
clippedUvsItems.length = s + clipOutputLength;
|
||||
clippedUvsItems.resize(s + clipOutputLength);
|
||||
|
||||
var ii:Int = 0;
|
||||
while (ii < clipOutputLength) {
|
||||
@ -149,7 +148,7 @@ class SkeletonClipping {
|
||||
|
||||
s = clippedTriangles.length;
|
||||
clippedTrianglesItems = clippedTriangles;
|
||||
clippedTrianglesItems.length = s + 3 * (clipOutputCount - 2);
|
||||
clippedTrianglesItems.resize(s + 3 * (clipOutputCount - 2));
|
||||
clipOutputCount--;
|
||||
for (ii in 1...clipOutputCount) {
|
||||
clippedTrianglesItems[s] = index;
|
||||
@ -160,7 +159,7 @@ class SkeletonClipping {
|
||||
index += clipOutputCount + 1;
|
||||
} else {
|
||||
clippedVerticesItems = clippedVertices;
|
||||
clippedVerticesItems.length = s + 3 * 2;
|
||||
clippedVerticesItems.resize(s + 3 * 2);
|
||||
clippedVerticesItems[s] = x1;
|
||||
clippedVerticesItems[s + 1] = y1;
|
||||
clippedVerticesItems[s + 2] = x2;
|
||||
@ -169,7 +168,7 @@ class SkeletonClipping {
|
||||
clippedVerticesItems[s + 5] = y3;
|
||||
|
||||
clippedUvsItems = clippedUvs;
|
||||
clippedUvsItems.length = s + 3 * 2;
|
||||
clippedUvsItems.resize(s + 3 * 2);
|
||||
clippedUvsItems[s] = u1;
|
||||
clippedUvsItems[s + 1] = v1;
|
||||
clippedUvsItems[s + 2] = u2;
|
||||
@ -179,7 +178,7 @@ class SkeletonClipping {
|
||||
|
||||
s = clippedTriangles.length;
|
||||
clippedTrianglesItems = clippedTriangles;
|
||||
clippedTrianglesItems.length = s + 3;
|
||||
clippedTrianglesItems.resize(s + 3);
|
||||
clippedTrianglesItems[s] = index;
|
||||
clippedTrianglesItems[s + 1] = (index + 1);
|
||||
clippedTrianglesItems[s + 2] = (index + 2);
|
||||
@ -194,12 +193,12 @@ class SkeletonClipping {
|
||||
|
||||
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
|
||||
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
|
||||
public function clip(x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float, clippingArea:Vector<Float>, output:Vector<Float>):Bool {
|
||||
var originalOutput:Vector<Float> = output;
|
||||
public function clip(x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float, clippingArea:Array<Float>, output:Array<Float>):Bool {
|
||||
var originalOutput:Array<Float> = output;
|
||||
var clipped:Bool = false;
|
||||
|
||||
// Avoid copy at the end.
|
||||
var input:Vector<Float> = null;
|
||||
var input:Array<Float> = null;
|
||||
if (clippingArea.length % 4 >= 2) {
|
||||
input = output;
|
||||
output = scratch;
|
||||
@ -207,7 +206,7 @@ class SkeletonClipping {
|
||||
input = scratch;
|
||||
}
|
||||
|
||||
input.length = 0;
|
||||
input.resize(0);
|
||||
input.push(x1);
|
||||
input.push(y1);
|
||||
input.push(x2);
|
||||
@ -216,9 +215,9 @@ class SkeletonClipping {
|
||||
input.push(y3);
|
||||
input.push(x1);
|
||||
input.push(y1);
|
||||
output.length = 0;
|
||||
output.resize(0);
|
||||
|
||||
var clippingVertices:Vector<Float> = clippingArea;
|
||||
var clippingVertices:Array<Float> = clippingArea;
|
||||
var clippingVerticesLast:Int = clippingArea.length - 4;
|
||||
var c0:Float, c2:Float, s:Float, ua:Float;
|
||||
var i:Int = 0;
|
||||
@ -230,7 +229,7 @@ class SkeletonClipping {
|
||||
edgeY2:Float = clippingVertices[i + 3];
|
||||
var deltaX:Float = edgeX - edgeX2, deltaY:Float = edgeY - edgeY2;
|
||||
|
||||
var inputVertices:Vector<Float> = input;
|
||||
var inputVertices:Array<Float> = input;
|
||||
var inputVerticesLength:Int = input.length - 2,
|
||||
outputStart:Int = output.length;
|
||||
var ii:Int = 0;
|
||||
@ -283,7 +282,7 @@ class SkeletonClipping {
|
||||
|
||||
if (outputStart == output.length) {
|
||||
// All edges outside.
|
||||
originalOutput.length = 0;
|
||||
originalOutput.resize(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -292,29 +291,29 @@ class SkeletonClipping {
|
||||
|
||||
if (i == clippingVerticesLast)
|
||||
break;
|
||||
var temp:Vector<Float> = output;
|
||||
var temp:Array<Float> = output;
|
||||
output = input;
|
||||
output.length = 0;
|
||||
output.resize(0);
|
||||
input = temp;
|
||||
|
||||
i += 2;
|
||||
}
|
||||
|
||||
if (originalOutput != output) {
|
||||
originalOutput.length = 0;
|
||||
originalOutput.resize(0);
|
||||
n = output.length - 2;
|
||||
for (i in 0...n) {
|
||||
originalOutput[i] = output[i];
|
||||
}
|
||||
} else {
|
||||
originalOutput.length = originalOutput.length - 2;
|
||||
originalOutput.resize(originalOutput.length - 2);
|
||||
}
|
||||
|
||||
return clipped;
|
||||
}
|
||||
|
||||
public static function makeClockwise(polygon:Vector<Float>):Void {
|
||||
var vertices:Vector<Float> = polygon;
|
||||
public static function makeClockwise(polygon:Array<Float>):Void {
|
||||
var vertices:Array<Float> = polygon;
|
||||
var verticeslength:Int = polygon.length;
|
||||
|
||||
var area:Float = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1];
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
import haxe.io.Bytes;
|
||||
import openfl.utils.Assets;
|
||||
import spine.animation.Animation;
|
||||
import spine.atlas.TextureAtlas;
|
||||
@ -39,15 +39,15 @@ class SkeletonData {
|
||||
/** May be null. */
|
||||
public var name:String;
|
||||
|
||||
public var bones:Vector<BoneData> = new Vector<BoneData>(); // Ordered parents first.
|
||||
public var slots:Vector<SlotData> = new Vector<SlotData>(); // Setup pose draw order.
|
||||
public var skins:Vector<Skin> = new Vector<Skin>();
|
||||
public var bones:Array<BoneData> = new Array<BoneData>(); // Ordered parents first.
|
||||
public var slots:Array<SlotData> = new Array<SlotData>(); // Setup pose draw order.
|
||||
public var skins:Array<Skin> = new Array<Skin>();
|
||||
public var defaultSkin:Skin;
|
||||
public var events:Vector<EventData> = new Vector<EventData>();
|
||||
public var animations:Vector<Animation> = new Vector<Animation>();
|
||||
public var ikConstraints:Vector<IkConstraintData> = new Vector<IkConstraintData>();
|
||||
public var transformConstraints:Vector<TransformConstraintData> = new Vector<TransformConstraintData>();
|
||||
public var pathConstraints:Vector<PathConstraintData> = new Vector<PathConstraintData>();
|
||||
public var events:Array<EventData> = new Array<EventData>();
|
||||
public var animations:Array<Animation> = new Array<Animation>();
|
||||
public var ikConstraints:Array<IkConstraintData> = new Array<IkConstraintData>();
|
||||
public var transformConstraints:Array<TransformConstraintData> = new Array<TransformConstraintData>();
|
||||
public var pathConstraints:Array<PathConstraintData> = new Array<PathConstraintData>();
|
||||
public var x:Float = 0;
|
||||
public var y:Float = 0;
|
||||
public var width:Float = 0;
|
||||
@ -58,19 +58,17 @@ class SkeletonData {
|
||||
public var imagesPath:String;
|
||||
public var audioPath:String;
|
||||
|
||||
public static function fromAssets(path:String, atlas:TextureAtlas, scale:Float = 1.0):SkeletonData {
|
||||
if (StringTools.endsWith(path, ".skel")) {
|
||||
var byteData = Assets.getBytes(path);
|
||||
public static function from(data:Dynamic, atlas:TextureAtlas, scale:Float = 1.0):SkeletonData {
|
||||
if (Std.isOfType(data, Bytes)) {
|
||||
var loader = new SkeletonBinary(new AtlasAttachmentLoader(atlas));
|
||||
loader.scale = scale;
|
||||
return loader.readSkeletonData(byteData);
|
||||
} else if (StringTools.endsWith(path, ".json")) {
|
||||
var jsonData = Assets.getText(path);
|
||||
return loader.readSkeletonData(cast(data, Bytes));
|
||||
} else if (Std.isOfType(data, String)) {
|
||||
var loader = new SkeletonJson(new AtlasAttachmentLoader(atlas));
|
||||
loader.scale = scale;
|
||||
return loader.readSkeletonData(jsonData);
|
||||
return loader.readSkeletonData(cast(data, String));
|
||||
} else {
|
||||
throw new SpineException("Path of skeleton data file must end with .json or .skel");
|
||||
throw new SpineException("Data must either be a String (.json) or Bytes (.skel) instance.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,8 +31,6 @@ package spine;
|
||||
|
||||
import Reflect;
|
||||
import haxe.Json;
|
||||
import openfl.Vector;
|
||||
import openfl.utils.Object;
|
||||
import spine.animation.AlphaTimeline;
|
||||
import spine.animation.Animation;
|
||||
import spine.animation.AttachmentTimeline;
|
||||
@ -78,7 +76,7 @@ class SkeletonJson {
|
||||
public var attachmentLoader:AttachmentLoader;
|
||||
public var scale:Float = 1;
|
||||
|
||||
private var linkedMeshes:Vector<LinkedMesh> = new Vector<LinkedMesh>();
|
||||
private var linkedMeshes:Array<LinkedMesh> = new Array<LinkedMesh>();
|
||||
|
||||
public function new(attachmentLoader:AttachmentLoader) {
|
||||
this.attachmentLoader = attachmentLoader;
|
||||
@ -93,7 +91,7 @@ class SkeletonJson {
|
||||
var skeletonData:SkeletonData = new SkeletonData();
|
||||
|
||||
// Skeleton.
|
||||
var skeletonMap:Object = getString(root, "skeleton", "");
|
||||
var skeletonMap = getString(root, "skeleton", "");
|
||||
if (skeletonMap != null) {
|
||||
skeletonData.hash = getString(skeletonMap, "hash", "");
|
||||
skeletonData.version = getString(skeletonMap, "spine", "");
|
||||
@ -318,11 +316,11 @@ class SkeletonJson {
|
||||
}
|
||||
|
||||
if (Reflect.hasField(skinMap, "attachments")) {
|
||||
var attachments:Object = Reflect.getProperty(skinMap, "attachments");
|
||||
for (slotName in attachments) {
|
||||
var attachments:Dynamic = Reflect.getProperty(skinMap, "attachments");
|
||||
for (slotName in Reflect.fields(attachments)) {
|
||||
var slot:SlotData = skeletonData.findSlot(slotName);
|
||||
var slotEntry:Object = Reflect.getProperty(attachments, slotName);
|
||||
for (attachmentName in slotEntry) {
|
||||
var slotEntry:Dynamic = Reflect.getProperty(attachments, slotName);
|
||||
for (attachmentName in Reflect.fields(slotEntry)) {
|
||||
var attachment:Attachment = readAttachment(Reflect.getProperty(slotEntry, attachmentName), skin, slot.index, attachmentName,
|
||||
skeletonData);
|
||||
if (attachment != null) {
|
||||
@ -352,12 +350,12 @@ class SkeletonJson {
|
||||
if (linkedMesh.mesh.region != null)
|
||||
linkedMesh.mesh.updateRegion();
|
||||
}
|
||||
linkedMeshes.length = 0;
|
||||
linkedMeshes.resize(0);
|
||||
|
||||
// Events.
|
||||
var events:Object = Reflect.getProperty(root, "events");
|
||||
for (eventName in events) {
|
||||
var eventMap:Map<String, Dynamic> = events[eventName];
|
||||
var events:Dynamic = Reflect.getProperty(root, "events");
|
||||
for (eventName in Reflect.fields(events)) {
|
||||
var eventMap:Map<String, Dynamic> = Reflect.field(events, eventName);
|
||||
var eventData:EventData = new EventData(eventName);
|
||||
eventData.intValue = getInt(eventMap, "int");
|
||||
eventData.floatValue = getFloat(eventMap, "float");
|
||||
@ -371,14 +369,14 @@ class SkeletonJson {
|
||||
}
|
||||
|
||||
// Animations.
|
||||
var animations:Object = Reflect.getProperty(root, "animations");
|
||||
for (animationName in animations) {
|
||||
readAnimation(animations[animationName], animationName, skeletonData);
|
||||
var animations:Dynamic = Reflect.getProperty(root, "animations");
|
||||
for (animationName in Reflect.fields(animations)) {
|
||||
readAnimation(Reflect.field(animations, animationName), animationName, skeletonData);
|
||||
}
|
||||
return skeletonData;
|
||||
}
|
||||
|
||||
private function readSequence(map:Object) {
|
||||
private function readSequence(map:Dynamic) {
|
||||
if (map == null)
|
||||
return null;
|
||||
var sequence = new Sequence(getInt(map, "count", 0));
|
||||
@ -388,15 +386,15 @@ class SkeletonJson {
|
||||
return sequence;
|
||||
}
|
||||
|
||||
private function readAttachment(map:Object, skin:Skin, slotIndex:Int, name:String, skeletonData:SkeletonData):Attachment {
|
||||
if (map["name"] != null)
|
||||
name = map["name"];
|
||||
private function readAttachment(map:Dynamic, skin:Skin, slotIndex:Int, name:String, skeletonData:SkeletonData):Attachment {
|
||||
if (Reflect.field(map, "name") != null)
|
||||
name = Reflect.field(map, "name");
|
||||
|
||||
var color:String;
|
||||
switch (AttachmentType.fromName(Reflect.hasField(map, "type") ? Reflect.getProperty(map, "type") : "region")) {
|
||||
case AttachmentType.region:
|
||||
var path = getString(map, "path", name);
|
||||
var sequence = readSequence(map["sequence"]);
|
||||
var sequence = readSequence(Reflect.field(map, "sequence"));
|
||||
var region:RegionAttachment = attachmentLoader.newRegionAttachment(skin, name, path, sequence);
|
||||
if (region == null)
|
||||
return null;
|
||||
@ -419,7 +417,7 @@ class SkeletonJson {
|
||||
return region;
|
||||
case AttachmentType.mesh, AttachmentType.linkedmesh:
|
||||
var path = getString(map, "path", name);
|
||||
var sequence = readSequence(map["sequence"]);
|
||||
var sequence = readSequence(Reflect.field(map, "sequence"));
|
||||
var mesh:MeshAttachment = attachmentLoader.newMeshAttachment(skin, name, path, sequence);
|
||||
if (mesh == null)
|
||||
return null;
|
||||
@ -434,20 +432,20 @@ class SkeletonJson {
|
||||
mesh.height = getFloat(map, "height") * scale;
|
||||
mesh.sequence = sequence;
|
||||
|
||||
if (map["parent"] != null) {
|
||||
var inheritTimelines:Bool = map.hasOwnProperty("timelines") ? cast(map["timelines"], Bool) : true;
|
||||
linkedMeshes.push(new LinkedMesh(mesh, map["skin"], slotIndex, map["parent"], inheritTimelines));
|
||||
if (Reflect.field(map, "parent") != null) {
|
||||
var inheritTimelines:Bool = map.hasOwnProperty("timelines") ? cast(Reflect.field(map, "timelines"), Bool) : true;
|
||||
linkedMeshes.push(new LinkedMesh(mesh, Reflect.field(map, "skin"), slotIndex, Reflect.field(map, "parent"), inheritTimelines));
|
||||
return mesh;
|
||||
}
|
||||
|
||||
var uvs:Vector<Float> = getFloatArray(map, "uvs");
|
||||
var uvs:Array<Float> = getFloatArray(map, "uvs");
|
||||
readVertices(map, mesh, uvs.length);
|
||||
mesh.triangles = getIntArray(map, "triangles");
|
||||
mesh.regionUVs = uvs;
|
||||
if (mesh.region != null)
|
||||
mesh.updateRegion();
|
||||
|
||||
if (map["edges"] != null)
|
||||
if (Reflect.field(map, "edges") != null)
|
||||
mesh.edges = getIntArray(map, "edges");
|
||||
mesh.hullLength = getInt(map, "hull") * 2;
|
||||
return mesh;
|
||||
@ -455,18 +453,18 @@ class SkeletonJson {
|
||||
var box:BoundingBoxAttachment = attachmentLoader.newBoundingBoxAttachment(skin, name);
|
||||
if (box == null)
|
||||
return null;
|
||||
readVertices(map, box, Std.parseInt(map["vertexCount"]) << 1);
|
||||
readVertices(map, box, Std.parseInt(Reflect.field(map, "vertexCount")) << 1);
|
||||
return box;
|
||||
case AttachmentType.path:
|
||||
var path:PathAttachment = attachmentLoader.newPathAttachment(skin, name);
|
||||
if (path == null)
|
||||
return null;
|
||||
path.closed = map.hasOwnProperty("closed") ? cast(map["closed"], Bool) : false;
|
||||
path.constantSpeed = map.hasOwnProperty("constantSpeed") ? cast(map["constantSpeed"], Bool) : true;
|
||||
var vertexCount:Int = Std.parseInt(map["vertexCount"]);
|
||||
path.closed = map.hasOwnProperty("closed") ? cast(Reflect.field(map, "closed"), Bool) : false;
|
||||
path.constantSpeed = map.hasOwnProperty("constantSpeed") ? cast(Reflect.field(map, "constantSpeed"), Bool) : true;
|
||||
var vertexCount:Int = Std.parseInt(Reflect.field(map, "vertexCount"));
|
||||
readVertices(map, path, vertexCount << 1);
|
||||
var lengths:Vector<Float> = new Vector<Float>();
|
||||
for (curves in cast(map["lengths"], Array<Dynamic>)) {
|
||||
var lengths:Array<Float> = new Array<Float>();
|
||||
for (curves in cast(Reflect.field(map, "lengths"), Array<Dynamic>)) {
|
||||
lengths.push(Std.parseFloat(curves) * scale);
|
||||
}
|
||||
path.lengths = lengths;
|
||||
@ -475,9 +473,9 @@ class SkeletonJson {
|
||||
var point:PointAttachment = attachmentLoader.newPointAttachment(skin, name);
|
||||
if (point == null)
|
||||
return null;
|
||||
point.x = map.hasOwnProperty("x") ? Std.parseFloat(map["x"]) * scale : 0;
|
||||
point.y = map.hasOwnProperty("y") ? Std.parseFloat(map["y"]) * scale : 0;
|
||||
point.rotation = map.hasOwnProperty("rotation") ? Std.parseFloat(map["rotation"]) : 0;
|
||||
point.x = getFloat(map, "x", 0) * scale;
|
||||
point.y = getFloat(map, "y", 0) * scale;
|
||||
point.rotation = getFloat(map, "rotation", 0);
|
||||
color = Reflect.getProperty(map, "color");
|
||||
if (color != null) {
|
||||
point.color.setFromString(color);
|
||||
@ -487,14 +485,14 @@ class SkeletonJson {
|
||||
var clip:ClippingAttachment = attachmentLoader.newClippingAttachment(skin, name);
|
||||
if (clip == null)
|
||||
return null;
|
||||
var end:String = map["end"];
|
||||
var end:String = getString(map, "end", null);
|
||||
if (end != null) {
|
||||
var slot:SlotData = skeletonData.findSlot(end);
|
||||
if (slot == null)
|
||||
throw new SpineException("Clipping end slot not found: " + end);
|
||||
clip.endSlot = slot;
|
||||
}
|
||||
var vertexCount:Int = Std.parseInt(map["vertexCount"]);
|
||||
var vertexCount:Int = getInt(map, "vertexCount", 0);
|
||||
readVertices(map, clip, vertexCount << 1);
|
||||
color = Reflect.getProperty(map, "color");
|
||||
if (color != null) {
|
||||
@ -505,9 +503,9 @@ class SkeletonJson {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function readVertices(map:Object, attachment:VertexAttachment, verticesLength:Int):Void {
|
||||
private function readVertices(map:Dynamic, attachment:VertexAttachment, verticesLength:Int):Void {
|
||||
attachment.worldVerticesLength = verticesLength;
|
||||
var vertices:Vector<Float> = getFloatArray(map, "vertices");
|
||||
var vertices:Array<Float> = getFloatArray(map, "vertices");
|
||||
if (verticesLength == vertices.length) {
|
||||
if (scale != 1) {
|
||||
for (i in 0...vertices.length) {
|
||||
@ -518,8 +516,8 @@ class SkeletonJson {
|
||||
return;
|
||||
}
|
||||
|
||||
var weights:Vector<Float> = new Vector<Float>();
|
||||
var bones:Vector<Int> = new Vector<Int>();
|
||||
var weights:Array<Float> = new Array<Float>();
|
||||
var bones:Array<Int> = new Array<Int>();
|
||||
var i:Int = 0;
|
||||
var n:Int = vertices.length;
|
||||
while (i < n) {
|
||||
@ -539,28 +537,28 @@ class SkeletonJson {
|
||||
attachment.vertices = weights;
|
||||
}
|
||||
|
||||
private function readAnimation(map:Object, name:String, skeletonData:SkeletonData):Void {
|
||||
var timelines:Vector<Timeline> = new Vector<Timeline>();
|
||||
private function readAnimation(map:Dynamic, name:String, skeletonData:SkeletonData):Void {
|
||||
var timelines:Array<Timeline> = new Array<Timeline>();
|
||||
|
||||
var slotMap:Object;
|
||||
var slotMap:Dynamic;
|
||||
var slotIndex:Int;
|
||||
var slotName:String;
|
||||
|
||||
var timelineMap:Array<Object>;
|
||||
var keyMap:Object;
|
||||
var nextMap:Object;
|
||||
var timelineMap:Array<Dynamic>;
|
||||
var keyMap:Dynamic;
|
||||
var nextMap:Dynamic;
|
||||
var frame:Int, bezier:Int;
|
||||
var time:Float, time2:Float;
|
||||
var curve:Object;
|
||||
var curve:Dynamic;
|
||||
var timelineName:String;
|
||||
|
||||
// Slot timelines.
|
||||
var slots:Object = Reflect.getProperty(map, "slots");
|
||||
for (slotName in slots) {
|
||||
slotMap = slots[slotName];
|
||||
var slots:Dynamic = Reflect.getProperty(map, "slots");
|
||||
for (slotName in Reflect.fields(slots)) {
|
||||
slotMap = Reflect.field(slots, slotName);
|
||||
slotIndex = skeletonData.findSlot(slotName).index;
|
||||
for (timelineName in slotMap) {
|
||||
timelineMap = slotMap[timelineName];
|
||||
for (timelineName in Reflect.fields(slotMap)) {
|
||||
timelineMap = Reflect.field(slotMap, timelineName);
|
||||
if (timelineMap == null)
|
||||
continue;
|
||||
if (timelineName == "attachment") {
|
||||
@ -721,14 +719,14 @@ class SkeletonJson {
|
||||
}
|
||||
|
||||
// Bone timelines.
|
||||
var bones:Object = Reflect.getProperty(map, "bones");
|
||||
for (boneName in bones) {
|
||||
var bones:Dynamic = Reflect.getProperty(map, "bones");
|
||||
for (boneName in Reflect.fields(bones)) {
|
||||
var boneIndex:Int = skeletonData.findBoneIndex(boneName);
|
||||
if (boneIndex == -1)
|
||||
throw new SpineException("Bone not found: " + boneName);
|
||||
var boneMap:Object = bones[boneName];
|
||||
for (timelineName in boneMap) {
|
||||
timelineMap = boneMap[timelineName];
|
||||
var boneMap:Dynamic = Reflect.field(bones, boneName);
|
||||
for (timelineName in Reflect.fields(boneMap)) {
|
||||
timelineMap = Reflect.field(boneMap, timelineName);
|
||||
if (timelineMap.length == 0)
|
||||
continue;
|
||||
|
||||
@ -768,9 +766,9 @@ class SkeletonJson {
|
||||
}
|
||||
|
||||
// IK constraint timelines.
|
||||
var iks:Object = Reflect.getProperty(map, "ik");
|
||||
for (ikConstraintName in iks) {
|
||||
timelineMap = iks[ikConstraintName];
|
||||
var iks:Dynamic = Reflect.getProperty(map, "ik");
|
||||
for (ikConstraintName in Reflect.fields(iks)) {
|
||||
timelineMap = Reflect.field(iks, ikConstraintName);
|
||||
keyMap = timelineMap[0];
|
||||
if (keyMap == null)
|
||||
continue;
|
||||
@ -819,9 +817,9 @@ class SkeletonJson {
|
||||
var mixRotate:Float, mixRotate2:Float;
|
||||
var mixX:Float, mixX2:Float;
|
||||
var mixY:Float, mixY2:Float;
|
||||
var transforms:Object = Reflect.getProperty(map, "transform");
|
||||
for (transformName in transforms) {
|
||||
timelineMap = transforms[transformName];
|
||||
var transforms:Dynamic = Reflect.getProperty(map, "transform");
|
||||
for (transformName in Reflect.fields(transforms)) {
|
||||
timelineMap = Reflect.field(transforms, transformName);
|
||||
keyMap = timelineMap[0];
|
||||
if (keyMap == null)
|
||||
continue;
|
||||
@ -879,16 +877,16 @@ class SkeletonJson {
|
||||
}
|
||||
|
||||
// Path constraint timelines.
|
||||
var paths:Object = Reflect.getProperty(map, "path");
|
||||
for (pathName in paths) {
|
||||
var paths:Dynamic = Reflect.getProperty(map, "path");
|
||||
for (pathName in Reflect.fields(paths)) {
|
||||
var index:Int = skeletonData.findPathConstraintIndex(pathName);
|
||||
if (index == -1)
|
||||
throw new SpineException("Path constraint not found: " + pathName);
|
||||
var pathData:PathConstraintData = skeletonData.pathConstraints[index];
|
||||
|
||||
var pathMap:Object = paths[pathName];
|
||||
for (timelineName in pathMap) {
|
||||
timelineMap = pathMap[timelineName];
|
||||
var pathMap:Dynamic = Reflect.field(paths, pathName);
|
||||
for (timelineName in Reflect.fields(pathMap)) {
|
||||
timelineMap = Reflect.field(pathMap, timelineName);
|
||||
keyMap = timelineMap[0];
|
||||
if (keyMap == null)
|
||||
continue;
|
||||
@ -941,26 +939,26 @@ class SkeletonJson {
|
||||
}
|
||||
|
||||
// Attachment timelines.
|
||||
var attachments:Object = Reflect.getProperty(map, "attachments");
|
||||
for (attachmentsName in attachments) {
|
||||
var attachmentsMap:Object = attachments[attachmentsName];
|
||||
var attachments:Dynamic = Reflect.getProperty(map, "attachments");
|
||||
for (attachmentsName in Reflect.fields(attachments)) {
|
||||
var attachmentsMap:Dynamic = Reflect.field(attachments, attachmentsName);
|
||||
var skin:Skin = skeletonData.findSkin(attachmentsName);
|
||||
if (skin == null)
|
||||
throw new SpineException("Skin not found: " + attachmentsName);
|
||||
|
||||
for (slotMapName in attachmentsMap) {
|
||||
slotMap = attachmentsMap[slotMapName];
|
||||
for (slotMapName in Reflect.fields(attachmentsMap)) {
|
||||
slotMap = Reflect.field(attachmentsMap, slotMapName);
|
||||
slotIndex = skeletonData.findSlot(slotMapName).index;
|
||||
if (slotIndex == -1)
|
||||
throw new SpineException("Slot not found: " + slotMapName);
|
||||
for (attachmentMapName in slotMap) {
|
||||
var attachmentMap = slotMap[attachmentMapName];
|
||||
for (attachmentMapName in Reflect.fields(slotMap)) {
|
||||
var attachmentMap = Reflect.field(slotMap, attachmentMapName);
|
||||
var attachment:Attachment = skin.getAttachment(slotIndex, attachmentMapName);
|
||||
if (attachment == null)
|
||||
throw new SpineException("Timeline attachment not found: " + attachmentMapName);
|
||||
|
||||
for (timelineMapName in attachmentMap) {
|
||||
var timelineMap = attachmentMap[timelineMapName];
|
||||
for (timelineMapName in Reflect.fields(attachmentMap)) {
|
||||
var timelineMap = Reflect.field(attachmentMap, timelineMapName);
|
||||
var keyMap = timelineMap[0];
|
||||
if (keyMap == null)
|
||||
continue;
|
||||
@ -968,7 +966,7 @@ class SkeletonJson {
|
||||
if (timelineMapName == "deform") {
|
||||
var vertexAttachment = cast(attachment, VertexAttachment);
|
||||
var weighted:Bool = vertexAttachment.bones != null;
|
||||
var vertices:Vector<Float> = vertexAttachment.vertices;
|
||||
var vertices:Array<Float> = vertexAttachment.vertices;
|
||||
var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length;
|
||||
|
||||
var deformTimeline:DeformTimeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, vertexAttachment);
|
||||
@ -976,14 +974,20 @@ class SkeletonJson {
|
||||
frame = 0;
|
||||
bezier = 0;
|
||||
while (true) {
|
||||
var deform:Vector<Float>;
|
||||
var verticesValue:Vector<Float> = Reflect.getProperty(keyMap, "vertices");
|
||||
var deform:Array<Float>;
|
||||
var verticesValue:Array<Float> = Reflect.getProperty(keyMap, "vertices");
|
||||
if (verticesValue == null) {
|
||||
deform = weighted ? new Vector<Float>(deformLength, true) : vertices;
|
||||
if (weighted) {
|
||||
deform = new Array<Float>();
|
||||
deform.resize(deformLength);
|
||||
} else {
|
||||
deform = vertices;
|
||||
}
|
||||
} else {
|
||||
deform = new Vector<Float>(deformLength, true);
|
||||
deform = new Array<Float>();
|
||||
deform.resize(deformLength);
|
||||
var start:Int = getInt(keyMap, "offset");
|
||||
var temp:Vector<Float> = getFloatArray(keyMap, "vertices");
|
||||
var temp:Array<Float> = getFloatArray(keyMap, "vertices");
|
||||
for (i in 0...temp.length) {
|
||||
deform[start + i] = temp[i];
|
||||
}
|
||||
@ -1040,21 +1044,23 @@ class SkeletonJson {
|
||||
|
||||
// Draw order timelines.
|
||||
if (Reflect.hasField(map, "drawOrder")) {
|
||||
var drawOrders:Array<Dynamic> = cast(map["drawOrder"], Array<Dynamic>);
|
||||
var drawOrders:Array<Dynamic> = cast(Reflect.field(map, "drawOrder"), Array<Dynamic>);
|
||||
if (drawOrders != null) {
|
||||
var drawOrderTimeline:DrawOrderTimeline = new DrawOrderTimeline(drawOrders.length);
|
||||
var slotCount:Int = skeletonData.slots.length;
|
||||
frame = 0;
|
||||
for (drawOrderMap in drawOrders) {
|
||||
var drawOrder:Vector<Int> = null;
|
||||
var drawOrder:Array<Int> = null;
|
||||
var offsets:Array<Dynamic> = Reflect.getProperty(drawOrderMap, "offsets");
|
||||
if (offsets != null) {
|
||||
drawOrder = new Vector<Int>(slotCount, true);
|
||||
drawOrder = new Array<Int>();
|
||||
drawOrder.resize(slotCount);
|
||||
var i = slotCount - 1;
|
||||
while (i >= 0) {
|
||||
drawOrder[i--] = -1;
|
||||
}
|
||||
var unchanged:Vector<Int> = new Vector<Int>(slotCount - offsets.length, true);
|
||||
var unchanged:Array<Int> = new Array<Int>();
|
||||
unchanged.resize(slotCount - offsets.length);
|
||||
var originalIndex:Int = 0, unchangedIndex:Int = 0;
|
||||
for (offsetMap in offsets) {
|
||||
slotIndex = skeletonData.findSlot(Reflect.getProperty(offsetMap, "slot")).index;
|
||||
@ -1087,7 +1093,7 @@ class SkeletonJson {
|
||||
|
||||
// Event timelines.
|
||||
if (Reflect.hasField(map, "events")) {
|
||||
var eventsMap:Array<Dynamic> = cast(map["events"], Array<Dynamic>);
|
||||
var eventsMap:Array<Dynamic> = cast(Reflect.field(map, "events"), Array<Dynamic>);
|
||||
if (eventsMap != null) {
|
||||
var eventTimeline:EventTimeline = new EventTimeline(eventsMap.length);
|
||||
frame = 0;
|
||||
@ -1120,21 +1126,21 @@ class SkeletonJson {
|
||||
}
|
||||
|
||||
static private function readTimeline(keys:Array<Dynamic>, timeline:CurveTimeline1, defaultValue:Float, scale:Float):CurveTimeline1 {
|
||||
var keyMap:Object = keys[0];
|
||||
var keyMap:Dynamic = keys[0];
|
||||
var time:Float = getFloat(keyMap, "time");
|
||||
var value:Float = getFloat(keyMap, "value", defaultValue) * scale;
|
||||
var bezier:Int = 0;
|
||||
var frame:Int = 0;
|
||||
while (true) {
|
||||
timeline.setFrame(frame, time, value);
|
||||
var nextMap:Object = keys[frame + 1];
|
||||
var nextMap:Dynamic = keys[frame + 1];
|
||||
if (nextMap == null) {
|
||||
timeline.shrink(bezier);
|
||||
break;
|
||||
}
|
||||
var time2:Float = getFloat(nextMap, "time");
|
||||
var value2:Float = getFloat(nextMap, "value", defaultValue) * scale;
|
||||
var curve:Object = keyMap.curve;
|
||||
var curve:Dynamic = keyMap.curve;
|
||||
if (curve != null) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value, value2, scale);
|
||||
}
|
||||
@ -1149,7 +1155,7 @@ class SkeletonJson {
|
||||
|
||||
static private function readTimeline2(keys:Array<Dynamic>, timeline:CurveTimeline2, name1:String, name2:String, defaultValue:Float,
|
||||
scale:Float):CurveTimeline2 {
|
||||
var keyMap:Object = keys[0];
|
||||
var keyMap:Dynamic = keys[0];
|
||||
var time:Float = getFloat(keyMap, "time");
|
||||
var value1:Float = getFloat(keyMap, name1, defaultValue) * scale;
|
||||
var value2:Float = getFloat(keyMap, name2, defaultValue) * scale;
|
||||
@ -1157,7 +1163,7 @@ class SkeletonJson {
|
||||
var frame:Int = 0;
|
||||
while (true) {
|
||||
timeline.setFrame(frame, time, value1, value2);
|
||||
var nextMap:Object = keys[frame + 1];
|
||||
var nextMap:Dynamic = keys[frame + 1];
|
||||
if (nextMap == null) {
|
||||
timeline.shrink(bezier);
|
||||
break;
|
||||
@ -1165,7 +1171,7 @@ class SkeletonJson {
|
||||
var time2:Float = getFloat(nextMap, "time");
|
||||
var nvalue1:Float = getFloat(nextMap, name1, defaultValue) * scale;
|
||||
var nvalue2:Float = getFloat(nextMap, name2, defaultValue) * scale;
|
||||
var curve:Object = keyMap.curve;
|
||||
var curve:Dynamic = keyMap.curve;
|
||||
if (curve != null) {
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value1, nvalue1, scale);
|
||||
bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, value2, nvalue2, scale);
|
||||
@ -1180,7 +1186,7 @@ class SkeletonJson {
|
||||
return timeline;
|
||||
}
|
||||
|
||||
static private function readCurve(curve:Object, timeline:CurveTimeline, bezier:Int, frame:Int, value:Int, time1:Float, time2:Float, value1:Float,
|
||||
static private function readCurve(curve:Dynamic, timeline:CurveTimeline, bezier:Int, frame:Int, value:Int, time1:Float, time2:Float, value1:Float,
|
||||
value2:Float, scale:Float):Int {
|
||||
if (curve == "stepped") {
|
||||
timeline.setStepped(frame);
|
||||
@ -1196,42 +1202,44 @@ class SkeletonJson {
|
||||
return bezier + 1;
|
||||
}
|
||||
|
||||
static private function getValue(map:Object, name:String, defaultValue:Dynamic):Dynamic {
|
||||
static private function getValue(map:Dynamic, name:String, defaultValue:Dynamic):Dynamic {
|
||||
if (map.hasOwnProperty(name))
|
||||
return map[name];
|
||||
return Reflect.field(map, name);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static private function getString(value:Object, name:String, defaultValue:String):String {
|
||||
if (Std.isOfType(value[name], String))
|
||||
return cast(value[name], String);
|
||||
static private function getString(value:Dynamic, name:String, defaultValue:String):String {
|
||||
if (Std.isOfType(Reflect.field(value, name), String))
|
||||
return cast(Reflect.field(value, name), String);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static private function getFloat(value:Object, name:String, defaultValue:Float = 0):Float {
|
||||
if (Std.isOfType(value[name], Float))
|
||||
return cast(value[name], Float);
|
||||
static private function getFloat(value:Dynamic, name:String, defaultValue:Float = 0):Float {
|
||||
if (Std.isOfType(Reflect.field(value, name), Float))
|
||||
return cast(Reflect.field(value, name), Float);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static private function getFloatArray(map:Object, name:String):Vector<Float> {
|
||||
var list:Array<Dynamic> = cast(map[name], Array<Dynamic>);
|
||||
var values:Vector<Float> = new Vector<Float>(list.length, true);
|
||||
static private function getFloatArray(map:Dynamic, name:String):Array<Float> {
|
||||
var list:Array<Dynamic> = cast(Reflect.field(map, name), Array<Dynamic>);
|
||||
var values:Array<Float> = new Array<Float>();
|
||||
values.resize(list.length);
|
||||
for (i in 0...list.length) {
|
||||
values[i] = cast(list[i], Float);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
static private function getInt(value:Object, name:String, defaultValue:Int = 0):Int {
|
||||
if (Std.isOfType(value[name], Int))
|
||||
return cast(value[name], Int);
|
||||
static private function getInt(value:Dynamic, name:String, defaultValue:Int = 0):Int {
|
||||
if (Std.isOfType(Reflect.field(value, name), Int))
|
||||
return cast(Reflect.field(value, name), Int);
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static private function getIntArray(map:Object, name:String):Vector<Int> {
|
||||
var list:Array<Dynamic> = cast(map[name], Array<Dynamic>);
|
||||
var values:Vector<Int> = new Vector<Int>(list.length, true);
|
||||
static private function getIntArray(map:Dynamic, name:String):Array<Int> {
|
||||
var list:Array<Dynamic> = cast(Reflect.field(map, name), Array<Dynamic>);
|
||||
var values:Array<Int> = new Array<Int>();
|
||||
values.resize(list.length);
|
||||
for (i in 0...list.length) {
|
||||
values[i] = Std.int(list[i]);
|
||||
}
|
||||
|
||||
@ -29,17 +29,16 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.utils.Dictionary;
|
||||
import openfl.Vector;
|
||||
import haxe.ds.StringMap;
|
||||
import spine.attachments.Attachment;
|
||||
import spine.attachments.MeshAttachment;
|
||||
|
||||
/** Stores attachments by slot index and attachment name. */
|
||||
class Skin {
|
||||
private var _name:String;
|
||||
private var _attachments:Vector<Dictionary<String, Attachment>> = new Vector<Dictionary<String, Attachment>>();
|
||||
private var _bones:Vector<BoneData> = new Vector<BoneData>();
|
||||
private var _constraints:Vector<ConstraintData> = new Vector<ConstraintData>();
|
||||
private var _attachments:Array<StringMap<Attachment>> = new Array<StringMap<Attachment>>();
|
||||
private var _bones:Array<BoneData> = new Array<BoneData>();
|
||||
private var _constraints:Array<ConstraintData> = new Array<ConstraintData>();
|
||||
|
||||
public function new(name:String) {
|
||||
if (name == null)
|
||||
@ -51,10 +50,10 @@ class Skin {
|
||||
if (attachment == null)
|
||||
throw new SpineException("attachment cannot be null.");
|
||||
if (slotIndex >= _attachments.length)
|
||||
_attachments.length = slotIndex + 1;
|
||||
_attachments.resize(slotIndex + 1);
|
||||
if (_attachments[slotIndex] == null)
|
||||
_attachments[slotIndex] = new Dictionary<String, Attachment>();
|
||||
_attachments[slotIndex][name] = attachment;
|
||||
_attachments[slotIndex] = new StringMap<Attachment>();
|
||||
_attachments[slotIndex].set(name, attachment);
|
||||
}
|
||||
|
||||
public function addSkin(skin:Skin):Void {
|
||||
@ -85,7 +84,7 @@ class Skin {
|
||||
_constraints.push(constraint);
|
||||
}
|
||||
|
||||
var attachments:Vector<SkinEntry> = skin.getAttachments();
|
||||
var attachments:Array<SkinEntry> = skin.getAttachments();
|
||||
for (i in 0...attachments.length) {
|
||||
var attachment:SkinEntry = attachments[i];
|
||||
setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
|
||||
@ -122,7 +121,7 @@ class Skin {
|
||||
_constraints.push(constraint);
|
||||
}
|
||||
|
||||
var attachments:Vector<SkinEntry> = skin.getAttachments();
|
||||
var attachments:Array<SkinEntry> = skin.getAttachments();
|
||||
for (i in 0...attachments.length) {
|
||||
attachment = attachments[i];
|
||||
if (attachment.attachment == null)
|
||||
@ -141,23 +140,23 @@ class Skin {
|
||||
public function getAttachment(slotIndex:Int, name:String):Attachment {
|
||||
if (slotIndex >= _attachments.length)
|
||||
return null;
|
||||
var dictionary:Dictionary<String, Attachment> = _attachments[slotIndex];
|
||||
return dictionary != null ? dictionary[name] : null;
|
||||
var dictionary:StringMap<Attachment> = _attachments[slotIndex];
|
||||
return dictionary != null ? dictionary.get(name) : null;
|
||||
}
|
||||
|
||||
public function removeAttachment(slotIndex:Int, name:String):Void {
|
||||
var dictionary:Dictionary<String, Attachment> = _attachments[slotIndex];
|
||||
var dictionary:StringMap<Attachment> = _attachments[slotIndex];
|
||||
if (dictionary != null)
|
||||
dictionary.remove(name);
|
||||
}
|
||||
|
||||
public function getAttachments():Vector<SkinEntry> {
|
||||
var entries:Vector<SkinEntry> = new Vector<SkinEntry>();
|
||||
public function getAttachments():Array<SkinEntry> {
|
||||
var entries:Array<SkinEntry> = new Array<SkinEntry>();
|
||||
for (slotIndex in 0..._attachments.length) {
|
||||
var attachments:Dictionary<String, Attachment> = _attachments[slotIndex];
|
||||
var attachments:StringMap<Attachment> = _attachments[slotIndex];
|
||||
if (attachments != null) {
|
||||
for (name in attachments.iterator()) {
|
||||
var attachment:Attachment = attachments[name];
|
||||
for (name in attachments.keys()) {
|
||||
var attachment:Attachment = attachments.get(name);
|
||||
if (attachment != null)
|
||||
entries.push(new SkinEntry(slotIndex, name, attachment));
|
||||
}
|
||||
@ -166,12 +165,12 @@ class Skin {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public function getAttachmentsForSlot(slotIndex:Int):Vector<SkinEntry> {
|
||||
var entries:Vector<SkinEntry> = new Vector<SkinEntry>();
|
||||
var attachments:Dictionary<String, Attachment> = _attachments[slotIndex];
|
||||
public function getAttachmentsForSlot(slotIndex:Int):Array<SkinEntry> {
|
||||
var entries:Array<SkinEntry> = new Array<SkinEntry>();
|
||||
var attachments:StringMap<Attachment> = _attachments[slotIndex];
|
||||
if (attachments != null) {
|
||||
for (name in attachments.iterator()) {
|
||||
var attachment:Attachment = attachments[name];
|
||||
for (name in attachments.keys()) {
|
||||
var attachment:Attachment = attachments.get(name);
|
||||
if (attachment != null)
|
||||
entries.push(new SkinEntry(slotIndex, name, attachment));
|
||||
}
|
||||
@ -180,26 +179,26 @@ class Skin {
|
||||
}
|
||||
|
||||
public function clear():Void {
|
||||
_attachments.length = 0;
|
||||
_bones.length = 0;
|
||||
_constraints.length = 0;
|
||||
_attachments.resize(0);
|
||||
_bones.resize(0);
|
||||
_constraints.resize(0);
|
||||
}
|
||||
|
||||
public var attachments(get, never):Vector<Dictionary<String, Attachment>>;
|
||||
public var attachments(get, never):Array<StringMap<Attachment>>;
|
||||
|
||||
private function get_attachments():Vector<Dictionary<String, Attachment>> {
|
||||
private function get_attachments():Array<StringMap<Attachment>> {
|
||||
return _attachments;
|
||||
}
|
||||
|
||||
public var bones(get, never):Vector<BoneData>;
|
||||
public var bones(get, never):Array<BoneData>;
|
||||
|
||||
private function get_bones():Vector<BoneData> {
|
||||
private function get_bones():Array<BoneData> {
|
||||
return _bones;
|
||||
}
|
||||
|
||||
public var constraints(get, never):Vector<ConstraintData>;
|
||||
public var constraints(get, never):Array<ConstraintData>;
|
||||
|
||||
private function get_constraints():Vector<ConstraintData> {
|
||||
private function get_constraints():Array<ConstraintData> {
|
||||
return _constraints;
|
||||
}
|
||||
|
||||
@ -221,9 +220,9 @@ class Skin {
|
||||
for (slot in skeleton.slots) {
|
||||
var slotAttachment:Attachment = slot.attachment;
|
||||
if (slotAttachment != null && slotIndex < oldSkin.attachments.length) {
|
||||
var dictionary:Dictionary<String, Attachment> = oldSkin.attachments[slotIndex];
|
||||
for (name in dictionary) {
|
||||
var skinAttachment:Attachment = dictionary[name];
|
||||
var dictionary:StringMap<Attachment> = oldSkin.attachments[slotIndex];
|
||||
for (name in dictionary.keys()) {
|
||||
var skinAttachment:Attachment = dictionary.get(name);
|
||||
if (slotAttachment == skinAttachment) {
|
||||
var attachment:Attachment = getAttachment(slotIndex, name);
|
||||
if (attachment != null)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.attachments.Attachment;
|
||||
import spine.attachments.VertexAttachment;
|
||||
|
||||
@ -45,7 +44,7 @@ class Slot {
|
||||
public var sequenceIndex = -1;
|
||||
|
||||
public var attachmentState:Int = 0;
|
||||
public var deform:Vector<Float> = new Vector<Float>();
|
||||
public var deform:Array<Float> = new Array<Float>();
|
||||
|
||||
public function new(data:SlotData, bone:Bone) {
|
||||
if (data == null)
|
||||
@ -93,7 +92,7 @@ class Slot {
|
||||
if (!Std.isOfType(attachmentNew, VertexAttachment)
|
||||
|| !Std.isOfType(attachment, VertexAttachment)
|
||||
|| cast(attachmentNew, VertexAttachment).timelineAttachment != cast(attachment, VertexAttachment).timelineAttachment) {
|
||||
deform = new Vector<Float>();
|
||||
deform = new Array<Float>();
|
||||
}
|
||||
_attachment = attachmentNew;
|
||||
sequenceIndex = -1;
|
||||
|
||||
@ -29,15 +29,13 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class SpacingMode {
|
||||
public static var length(default, never):SpacingMode = new SpacingMode("length");
|
||||
public static var fixed(default, never):SpacingMode = new SpacingMode("fixed");
|
||||
public static var percent(default, never):SpacingMode = new SpacingMode("percent");
|
||||
public static var proportional(default, never):SpacingMode = new SpacingMode("proportional");
|
||||
|
||||
public static var values(default, never):Vector<SpacingMode> = Vector.ofArray([length, fixed, percent, proportional]);
|
||||
public static var values(default, never):Array<SpacingMode> = [length, fixed, percent, proportional];
|
||||
|
||||
public var name(default, null):String;
|
||||
|
||||
|
||||
@ -29,11 +29,9 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class TransformConstraint implements Updatable {
|
||||
private var _data:TransformConstraintData;
|
||||
private var _bones:Vector<Bone>;
|
||||
private var _bones:Array<Bone>;
|
||||
|
||||
public var target:Bone;
|
||||
public var mixRotate:Float = 0;
|
||||
@ -43,7 +41,7 @@ class TransformConstraint implements Updatable {
|
||||
public var mixScaleY:Float = 0;
|
||||
public var mixShearY:Float = 0;
|
||||
|
||||
private var _temp:Vector<Float> = new Vector<Float>(2, true);
|
||||
private var _temp:Array<Float> = new Array<Float>();
|
||||
|
||||
public var active:Bool = false;
|
||||
|
||||
@ -59,7 +57,7 @@ class TransformConstraint implements Updatable {
|
||||
mixScaleX = data.mixScaleX;
|
||||
mixScaleY = data.mixScaleY;
|
||||
mixShearY = data.mixShearY;
|
||||
_bones = new Vector<Bone>();
|
||||
_bones = new Array<Bone>();
|
||||
for (boneData in data.bones) {
|
||||
_bones.push(skeleton.findBone(boneData.name));
|
||||
}
|
||||
@ -187,7 +185,7 @@ class TransformConstraint implements Updatable {
|
||||
}
|
||||
|
||||
if (translate) {
|
||||
var temp:Vector<Float> = _temp;
|
||||
var temp:Array<Float> = _temp;
|
||||
temp[0] = _data.offsetX;
|
||||
temp[1] = _data.offsetY;
|
||||
target.localToWorld(temp);
|
||||
@ -275,9 +273,9 @@ class TransformConstraint implements Updatable {
|
||||
return _data;
|
||||
}
|
||||
|
||||
public var bones(get, never):Vector<Bone>;
|
||||
public var bones(get, never):Array<Bone>;
|
||||
|
||||
private function get_bones():Vector<Bone> {
|
||||
private function get_bones():Array<Bone> {
|
||||
return _bones;
|
||||
}
|
||||
|
||||
|
||||
@ -29,10 +29,8 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class TransformConstraintData extends ConstraintData {
|
||||
private var _bones:Vector<BoneData> = new Vector<BoneData>();
|
||||
private var _bones:Array<BoneData> = new Array<BoneData>();
|
||||
|
||||
public var target:BoneData;
|
||||
public var mixRotate:Float = 0;
|
||||
@ -54,9 +52,9 @@ class TransformConstraintData extends ConstraintData {
|
||||
super(name, 0, false);
|
||||
}
|
||||
|
||||
public var bones(get, never):Vector<BoneData>;
|
||||
public var bones(get, never):Array<BoneData>;
|
||||
|
||||
private function get_bones():Vector<BoneData> {
|
||||
private function get_bones():Array<BoneData> {
|
||||
return _bones;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class TransformMode {
|
||||
public static var normal(default, never):TransformMode = new TransformMode("normal");
|
||||
public static var onlyTranslation(default, never):TransformMode = new TransformMode("onlyTranslation");
|
||||
@ -38,7 +36,7 @@ class TransformMode {
|
||||
public static var noScale(default, never):TransformMode = new TransformMode("noScale");
|
||||
public static var noScaleOrReflection(default, never):TransformMode = new TransformMode("noScaleOrReflection");
|
||||
|
||||
public static var values:Vector<TransformMode> = Vector.ofArray([normal, onlyTranslation, noRotationOrReflection, noScale, noScaleOrReflection]);
|
||||
public static var values:Array<TransformMode> = [normal, onlyTranslation, noRotationOrReflection, noScale, noScaleOrReflection];
|
||||
|
||||
public var name(default, null):String;
|
||||
|
||||
|
||||
@ -29,37 +29,35 @@
|
||||
|
||||
package spine;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class Triangulator {
|
||||
private var convexPolygons:Vector<Vector<Float>> = new Vector<Vector<Float>>();
|
||||
private var convexPolygonsIndices:Vector<Vector<Int>> = new Vector<Vector<Int>>();
|
||||
private var indicesArray:Vector<Int> = new Vector<Int>();
|
||||
private var isConcaveArray:Vector<Bool> = new Vector<Bool>();
|
||||
private var triangles:Vector<Int> = new Vector<Int>();
|
||||
private var polygonPool:Pool<Vector<Float>> = new Pool(function():Dynamic {
|
||||
return new Vector<Float>();
|
||||
private var convexPolygons:Array<Array<Float>> = new Array<Array<Float>>();
|
||||
private var convexPolygonsIndices:Array<Array<Int>> = new Array<Array<Int>>();
|
||||
private var indicesArray:Array<Int> = new Array<Int>();
|
||||
private var isConcaveArray:Array<Bool> = new Array<Bool>();
|
||||
private var triangles:Array<Int> = new Array<Int>();
|
||||
private var polygonPool:Pool<Array<Float>> = new Pool(function():Dynamic {
|
||||
return new Array<Float>();
|
||||
});
|
||||
private var polygonIndicesPool:Pool<Vector<Int>> = new Pool(function():Dynamic {
|
||||
return new Vector<Int>();
|
||||
private var polygonIndicesPool:Pool<Array<Int>> = new Pool(function():Dynamic {
|
||||
return new Array<Int>();
|
||||
});
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function triangulate(vertices:Vector<Float>):Vector<Int> {
|
||||
public function triangulate(vertices:Array<Float>):Array<Int> {
|
||||
var vertexCount:Int = vertices.length >> 1;
|
||||
|
||||
indicesArray.length = 0;
|
||||
indicesArray.resize(0);
|
||||
for (i in 0...vertexCount) {
|
||||
indicesArray.push(i);
|
||||
}
|
||||
|
||||
isConcaveArray.length = 0;
|
||||
isConcaveArray.resize(0);
|
||||
for (i in 0...vertexCount) {
|
||||
isConcaveArray.push(isConcave(i, vertexCount, vertices, indicesArray));
|
||||
}
|
||||
|
||||
triangles.length = 0;
|
||||
triangles.resize(0);
|
||||
|
||||
while (vertexCount > 3) {
|
||||
// Find ear tip.
|
||||
@ -131,22 +129,22 @@ class Triangulator {
|
||||
return triangles;
|
||||
}
|
||||
|
||||
public function decompose(vertices:Vector<Float>, triangles:Vector<Int>):Vector<Vector<Float>> {
|
||||
public function decompose(vertices:Array<Float>, triangles:Array<Int>):Array<Array<Float>> {
|
||||
for (i in 0...convexPolygons.length) {
|
||||
this.polygonPool.free(convexPolygons[i]);
|
||||
}
|
||||
convexPolygons.length = 0;
|
||||
convexPolygons.resize(0);
|
||||
|
||||
for (i in 0...convexPolygonsIndices.length) {
|
||||
this.polygonIndicesPool.free(convexPolygonsIndices[i]);
|
||||
}
|
||||
convexPolygonsIndices.length = 0;
|
||||
convexPolygonsIndices.resize(0);
|
||||
|
||||
var polygonIndices:Vector<Int> = polygonIndicesPool.obtain();
|
||||
polygonIndices.length = 0;
|
||||
var polygonIndices:Array<Int> = polygonIndicesPool.obtain();
|
||||
polygonIndices.resize(0);
|
||||
|
||||
var polygon:Vector<Float> = polygonPool.obtain();
|
||||
polygon.length = 0;
|
||||
var polygon:Array<Float> = polygonPool.obtain();
|
||||
polygon.resize(0);
|
||||
|
||||
// Merge subsequent triangles if they form a triangle fan.
|
||||
var fanBaseIndex:Int = -1, lastWinding:Int = 0;
|
||||
@ -188,7 +186,7 @@ class Triangulator {
|
||||
polygonIndicesPool.free(polygonIndices);
|
||||
}
|
||||
polygon = polygonPool.obtain();
|
||||
polygon.length = 0;
|
||||
polygon.resize(0);
|
||||
polygon.push(x1);
|
||||
polygon.push(y1);
|
||||
polygon.push(x2);
|
||||
@ -196,7 +194,7 @@ class Triangulator {
|
||||
polygon.push(x3);
|
||||
polygon.push(y3);
|
||||
polygonIndices = polygonIndicesPool.obtain();
|
||||
polygonIndices.length = 0;
|
||||
polygonIndices.resize(0);
|
||||
polygonIndices.push(t1);
|
||||
polygonIndices.push(t2);
|
||||
polygonIndices.push(t3);
|
||||
@ -238,7 +236,7 @@ class Triangulator {
|
||||
ii++;
|
||||
continue;
|
||||
}
|
||||
var otherIndices:Vector<Int> = convexPolygonsIndices[ii];
|
||||
var otherIndices:Array<Int> = convexPolygonsIndices[ii];
|
||||
if (otherIndices.length != 3) {
|
||||
ii++;
|
||||
continue;
|
||||
@ -247,7 +245,7 @@ class Triangulator {
|
||||
var otherSecondIndex:Int = otherIndices[1];
|
||||
var otherLastIndex:Int = otherIndices[2];
|
||||
|
||||
var otherPoly:Vector<Float> = convexPolygons[ii];
|
||||
var otherPoly:Array<Float> = convexPolygons[ii];
|
||||
x3 = otherPoly[otherPoly.length - 2];
|
||||
y3 = otherPoly[otherPoly.length - 1];
|
||||
|
||||
@ -258,8 +256,8 @@ class Triangulator {
|
||||
winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3);
|
||||
winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY);
|
||||
if (winding1 == currWinding && winding2 == currWinding) {
|
||||
otherPoly.length = 0;
|
||||
otherIndices.length = 0;
|
||||
otherPoly.resize(0);
|
||||
otherIndices.resize(0);
|
||||
polygon.push(x3);
|
||||
polygon.push(y3);
|
||||
polygonIndices.push(otherLastIndex);
|
||||
@ -294,7 +292,7 @@ class Triangulator {
|
||||
return convexPolygons;
|
||||
}
|
||||
|
||||
private static function isConcave(index:Int, vertexCount:Int, vertices:Vector<Float>, indices:Vector<Int>):Bool {
|
||||
private static function isConcave(index:Int, vertexCount:Int, vertices:Array<Float>, indices:Array<Int>):Bool {
|
||||
var previous:Int = indices[(vertexCount + index - 1) % vertexCount] << 1;
|
||||
var current:Int = indices[index] << 1;
|
||||
var next:Int = indices[(index + 1) % vertexCount] << 1;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
import spine.Slot;
|
||||
@ -43,7 +42,7 @@ class AlphaTimeline extends CurveTimeline1 implements SlotTimeline {
|
||||
private var slotIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.alpha + "|" + slotIndex]));
|
||||
super(frameCount, bezierCount, [Property.alpha + "|" + slotIndex]);
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
@ -55,7 +54,7 @@ class AlphaTimeline extends CurveTimeline1 implements SlotTimeline {
|
||||
return slotIndex;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (!slot.bone.active)
|
||||
|
||||
@ -29,19 +29,18 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.utils.Dictionary;
|
||||
import openfl.Vector;
|
||||
import haxe.ds.StringMap;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
|
||||
class Animation {
|
||||
private var _name:String;
|
||||
private var _timelines:Vector<Timeline>;
|
||||
private var _timelineIds:Dictionary<String, Bool> = new Dictionary<String, Bool>();
|
||||
private var _timelines:Array<Timeline>;
|
||||
private var _timelineIds:StringMap<Bool> = new StringMap<Bool>();
|
||||
|
||||
public var duration:Float = 0;
|
||||
|
||||
public function new(name:String, timelines:Vector<Timeline>, duration:Float) {
|
||||
public function new(name:String, timelines:Array<Timeline>, duration:Float) {
|
||||
if (name == null)
|
||||
throw new SpineException("name cannot be null.");
|
||||
_name = name;
|
||||
@ -49,29 +48,29 @@ class Animation {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public function setTimelines(timelines:Vector<Timeline>) {
|
||||
public function setTimelines(timelines:Array<Timeline>) {
|
||||
if (timelines == null)
|
||||
throw new SpineException("timelines cannot be null.");
|
||||
_timelines = timelines;
|
||||
_timelineIds = new Dictionary<String, Bool>();
|
||||
_timelineIds = new StringMap<Bool>();
|
||||
for (timeline in timelines) {
|
||||
var ids:Vector<String> = timeline.propertyIds;
|
||||
var ids:Array<String> = timeline.propertyIds;
|
||||
for (id in ids) {
|
||||
_timelineIds[id] = true;
|
||||
_timelineIds.set(id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function hasTimeline(ids:Vector<String>):Bool {
|
||||
public function hasTimeline(ids:Array<String>):Bool {
|
||||
for (id in ids) {
|
||||
if (_timelineIds[id])
|
||||
if (_timelineIds.exists(id))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Poses the skeleton at the specified time for this animation. */
|
||||
public function apply(skeleton:Skeleton, lastTime:Float, time:Float, loop:Bool, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public function apply(skeleton:Skeleton, lastTime:Float, time:Float, loop:Bool, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
if (skeleton == null)
|
||||
throw new SpineException("skeleton cannot be null.");
|
||||
@ -97,9 +96,9 @@ class Animation {
|
||||
return _name;
|
||||
}
|
||||
|
||||
public var timelines(get, never):Vector<Timeline>;
|
||||
public var timelines(get, never):Array<Timeline>;
|
||||
|
||||
private function get_timelines():Vector<Timeline> {
|
||||
private function get_timelines():Array<Timeline> {
|
||||
return _timelines;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,8 +29,7 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.utils.Dictionary;
|
||||
import openfl.Vector;
|
||||
import haxe.ds.StringMap;
|
||||
import spine.animation.Listeners.EventListeners;
|
||||
import spine.Event;
|
||||
import spine.Pool;
|
||||
@ -45,12 +44,12 @@ class AnimationState {
|
||||
public static inline var SETUP:Int = 1;
|
||||
public static inline var CURRENT:Int = 2;
|
||||
|
||||
private static var emptyAnimation:Animation = new Animation("<empty>", new Vector<Timeline>(), 0);
|
||||
private static var emptyAnimation:Animation = new Animation("<empty>", new Array<Timeline>(), 0);
|
||||
|
||||
public var data:AnimationStateData;
|
||||
public var tracks:Vector<TrackEntry> = new Vector<TrackEntry>();
|
||||
public var tracks:Array<TrackEntry> = new Array<TrackEntry>();
|
||||
|
||||
private var events:Vector<Event> = new Vector<Event>();
|
||||
private var events:Array<Event> = new Array<Event>();
|
||||
|
||||
public var onStart:Listeners = new Listeners();
|
||||
public var onInterrupt:Listeners = new Listeners();
|
||||
@ -193,12 +192,12 @@ class AnimationState {
|
||||
var animationLast:Float = current.animationLast,
|
||||
animationTime:Float = current.getAnimationTime(),
|
||||
applyTime:Float = animationTime;
|
||||
var applyEvents:Vector<Event> = events;
|
||||
var applyEvents:Array<Event> = events;
|
||||
if (current.reverse) {
|
||||
applyTime = current.animation.duration - applyTime;
|
||||
applyEvents = null;
|
||||
}
|
||||
var timelines:Vector<Timeline> = current.animation.timelines;
|
||||
var timelines:Array<Timeline> = current.animation.timelines;
|
||||
var timelineCount:Int = timelines.length;
|
||||
var timeline:Timeline;
|
||||
if ((i == 0 && mix == 1) || blend == MixBlend.add) {
|
||||
@ -206,12 +205,12 @@ class AnimationState {
|
||||
timeline.apply(skeleton, animationLast, applyTime, applyEvents, mix, blend, MixDirection.mixIn);
|
||||
}
|
||||
} else {
|
||||
var timelineMode:Vector<Int> = current.timelineMode;
|
||||
var timelineMode:Array<Int> = current.timelineMode;
|
||||
|
||||
var shortestRotation = current.shortestRotation;
|
||||
var firstFrame:Bool = !shortestRotation && current.timelinesRotation.length != timelineCount << 1;
|
||||
if (firstFrame)
|
||||
current.timelinesRotation.length = timelineCount << 1;
|
||||
current.timelinesRotation.resize(timelineCount << 1);
|
||||
|
||||
for (ii in 0...timelineCount) {
|
||||
var timeline:Timeline = timelines[ii];
|
||||
@ -227,7 +226,7 @@ class AnimationState {
|
||||
}
|
||||
}
|
||||
queueEvents(current, animationTime);
|
||||
events.length = 0;
|
||||
events.resize(0);
|
||||
current.nextAnimationLast = animationTime;
|
||||
current.nextTrackLast = current.trackTime;
|
||||
}
|
||||
@ -270,13 +269,13 @@ class AnimationState {
|
||||
var attachments:Bool = mix < from.attachmentThreshold,
|
||||
drawOrder:Bool = mix < from.drawOrderThreshold;
|
||||
var timelineCount:Int = from.animation.timelines.length;
|
||||
var timelines:Vector<Timeline> = from.animation.timelines;
|
||||
var timelines:Array<Timeline> = from.animation.timelines;
|
||||
var alphaHold:Float = from.alpha * to.interruptAlpha,
|
||||
alphaMix:Float = alphaHold * (1 - mix);
|
||||
var animationLast:Float = from.animationLast,
|
||||
animationTime:Float = from.getAnimationTime(),
|
||||
applyTime:Float = animationTime;
|
||||
var applyEvents:Vector<Event> = null;
|
||||
var applyEvents:Array<Event> = null;
|
||||
if (from.reverse) {
|
||||
applyTime = from.animation.duration - applyTime;
|
||||
} else if (mix < from.eventThreshold) {
|
||||
@ -288,14 +287,14 @@ class AnimationState {
|
||||
timeline.apply(skeleton, animationLast, applyTime, applyEvents, alphaMix, blend, MixDirection.mixOut);
|
||||
}
|
||||
} else {
|
||||
var timelineMode:Vector<Int> = from.timelineMode;
|
||||
var timelineHoldMix:Vector<TrackEntry> = from.timelineHoldMix;
|
||||
var timelineMode:Array<Int> = from.timelineMode;
|
||||
var timelineHoldMix:Array<TrackEntry> = from.timelineHoldMix;
|
||||
var shortestRotation = from.shortestRotation;
|
||||
|
||||
var firstFrame:Bool = !shortestRotation && from.timelinesRotation.length != timelineCount << 1;
|
||||
if (firstFrame)
|
||||
from.timelinesRotation.length = timelineCount << 1;
|
||||
var timelinesRotation:Vector<Float> = from.timelinesRotation;
|
||||
from.timelinesRotation.resize(timelineCount << 1);
|
||||
var timelinesRotation:Array<Float> = from.timelinesRotation;
|
||||
|
||||
from.totalAlpha = 0;
|
||||
for (i in 0...timelineCount) {
|
||||
@ -340,7 +339,7 @@ class AnimationState {
|
||||
|
||||
if (to.mixDuration > 0)
|
||||
queueEvents(from, animationTime);
|
||||
events.length = 0;
|
||||
events.resize(0);
|
||||
from.nextAnimationLast = animationTime;
|
||||
from.nextTrackLast = from.trackTime;
|
||||
|
||||
@ -363,7 +362,7 @@ class AnimationState {
|
||||
slot.attachmentState = this.unkeyedState + SETUP;
|
||||
}
|
||||
|
||||
public function applyRotateTimeline(timeline:RotateTimeline, skeleton:Skeleton, time:Float, alpha:Float, blend:MixBlend, timelinesRotation:Vector<Float>,
|
||||
public function applyRotateTimeline(timeline:RotateTimeline, skeleton:Skeleton, time:Float, alpha:Float, blend:MixBlend, timelinesRotation:Array<Float>,
|
||||
i:Int, firstFrame:Bool) {
|
||||
if (firstFrame)
|
||||
timelinesRotation[i] = 0;
|
||||
@ -478,7 +477,7 @@ class AnimationState {
|
||||
for (i in 0...tracks.length) {
|
||||
clearTrack(i);
|
||||
}
|
||||
tracks.length = 0;
|
||||
tracks.resize(0);
|
||||
queue.drainDisabled = oldTrainDisabled;
|
||||
queue.drain();
|
||||
}
|
||||
@ -525,7 +524,7 @@ class AnimationState {
|
||||
current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);
|
||||
}
|
||||
|
||||
from.timelinesRotation.length = 0; // Reset rotation for mixing out, in case entry was mixed in.
|
||||
from.timelinesRotation.resize(0); // Reset rotation for mixing out, in case entry was mixed in.
|
||||
}
|
||||
|
||||
queue.start(current);
|
||||
@ -627,7 +626,7 @@ class AnimationState {
|
||||
private function expandToIndex(index:Int):TrackEntry {
|
||||
if (index < tracks.length)
|
||||
return tracks[index];
|
||||
tracks.length = index + 1;
|
||||
tracks.resize(index + 1);
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -698,13 +697,13 @@ class AnimationState {
|
||||
|
||||
private function computeHold(entry:TrackEntry):Void {
|
||||
var to:TrackEntry = entry.mixingTo;
|
||||
var timelines:Vector<Timeline> = entry.animation.timelines;
|
||||
var timelines:Array<Timeline> = entry.animation.timelines;
|
||||
var timelinesCount:Int = entry.animation.timelines.length;
|
||||
var timelineMode:Vector<Int> = entry.timelineMode;
|
||||
timelineMode.length = timelinesCount;
|
||||
entry.timelineHoldMix.length = 0;
|
||||
var timelineHoldMix:Vector<TrackEntry> = entry.timelineHoldMix;
|
||||
timelineHoldMix.length = timelinesCount;
|
||||
var timelineMode:Array<Int> = entry.timelineMode;
|
||||
timelineMode.resize(timelinesCount);
|
||||
entry.timelineHoldMix.resize(0);
|
||||
var timelineHoldMix:Array<TrackEntry> = entry.timelineHoldMix;
|
||||
timelineHoldMix.resize(timelinesCount);
|
||||
|
||||
if (to != null && to.holdPrevious) {
|
||||
for (i in 0...timelinesCount) {
|
||||
@ -717,7 +716,7 @@ class AnimationState {
|
||||
for (i in 0...timelinesCount) {
|
||||
continueOuter = false;
|
||||
var timeline:Timeline = timelines[i];
|
||||
var ids:Vector<String> = timeline.propertyIds;
|
||||
var ids:Array<String> = timeline.propertyIds;
|
||||
if (!propertyIDs.addAll(ids)) {
|
||||
timelineMode[i] = SUBSEQUENT;
|
||||
} else if (to == null
|
||||
@ -761,12 +760,12 @@ class AnimationState {
|
||||
}
|
||||
|
||||
public function clearListeners():Void {
|
||||
onStart.listeners.length = 0;
|
||||
onInterrupt.listeners.length = 0;
|
||||
onEnd.listeners.length = 0;
|
||||
onDispose.listeners.length = 0;
|
||||
onComplete.listeners.length = 0;
|
||||
onEvent.listeners.length = 0;
|
||||
onStart.listeners.resize(0);
|
||||
onInterrupt.listeners.resize(0);
|
||||
onEnd.listeners.resize(0);
|
||||
onDispose.listeners.resize(0);
|
||||
onComplete.listeners.resize(0);
|
||||
onEvent.listeners.resize(0);
|
||||
}
|
||||
|
||||
public function clearListenerNotifications():Void {
|
||||
@ -775,14 +774,14 @@ class AnimationState {
|
||||
}
|
||||
|
||||
class StringSet {
|
||||
private var entries:Dictionary<String, Bool> = new Dictionary<String, Bool>();
|
||||
private var entries:StringMap<Bool> = new StringMap<Bool>();
|
||||
private var size:Int = 0;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function add(value:String):Bool {
|
||||
var contains:Bool = entries[value];
|
||||
entries[value] = true;
|
||||
var contains:Bool = entries.exists(value);
|
||||
entries.set(value, true);
|
||||
if (!contains) {
|
||||
size++;
|
||||
return true;
|
||||
@ -790,7 +789,7 @@ class StringSet {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addAll(values:Vector<String>):Bool {
|
||||
public function addAll(values:Array<String>):Bool {
|
||||
var oldSize:Int = size;
|
||||
for (i in 0...values.length) {
|
||||
add(values[i]);
|
||||
@ -799,11 +798,11 @@ class StringSet {
|
||||
}
|
||||
|
||||
public function contains(value:String):Bool {
|
||||
return entries[value];
|
||||
return entries.exists(value);
|
||||
}
|
||||
|
||||
public function clear():Void {
|
||||
entries = new Dictionary<String, Bool>();
|
||||
entries = new StringMap<Bool>();
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,12 +29,12 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.utils.Object;
|
||||
import haxe.ds.StringMap;
|
||||
import spine.SkeletonData;
|
||||
|
||||
class AnimationStateData {
|
||||
private var _skeletonData:SkeletonData;
|
||||
private var animationToMixTime:Object = new Object();
|
||||
private var animationToMixTime:StringMap<Float> = new StringMap<Float>();
|
||||
|
||||
public var defaultMix:Float = 0;
|
||||
|
||||
@ -63,13 +63,13 @@ class AnimationStateData {
|
||||
throw new SpineException("from cannot be null.");
|
||||
if (to == null)
|
||||
throw new SpineException("to cannot be null.");
|
||||
animationToMixTime[from.name + ":" + to.name] = duration;
|
||||
animationToMixTime.set(from.name + ":" + to.name, duration);
|
||||
}
|
||||
|
||||
public function getMix(from:Animation, to:Animation):Float {
|
||||
var time:Object = animationToMixTime[from.name + ":" + to.name];
|
||||
if (time == null)
|
||||
if (animationToMixTime.exists(from.name + ":" + to.name))
|
||||
return animationToMixTime.get(from.name + ":" + to.name);
|
||||
else
|
||||
return defaultMix;
|
||||
return cast(time, Float);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
import spine.Slot;
|
||||
@ -38,12 +37,13 @@ class AttachmentTimeline extends Timeline implements SlotTimeline {
|
||||
public var slotIndex:Int = 0;
|
||||
|
||||
/** The attachment name for each key frame. May contain null values to clear the attachment. */
|
||||
public var attachmentNames:Vector<String>;
|
||||
public var attachmentNames:Array<String>;
|
||||
|
||||
public function new(frameCount:Int, slotIndex:Int) {
|
||||
super(frameCount, Vector.ofArray([Property.attachment + "|" + slotIndex]));
|
||||
super(frameCount, [Property.attachment + "|" + slotIndex]);
|
||||
this.slotIndex = slotIndex;
|
||||
attachmentNames = new Vector<String>(frameCount, true);
|
||||
attachmentNames = new Array<String>();
|
||||
attachmentNames.resize(frameCount);
|
||||
}
|
||||
|
||||
public override function getFrameCount():Int {
|
||||
@ -60,7 +60,7 @@ class AttachmentTimeline extends Timeline implements SlotTimeline {
|
||||
attachmentNames[frame] = attachmentName;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (!slot.bone.active)
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
/** Base class for frames that use an interpolation bezier curve. */
|
||||
class CurveTimeline extends Timeline {
|
||||
private static inline var LINEAR:Int = 0;
|
||||
@ -38,11 +36,12 @@ class CurveTimeline extends Timeline {
|
||||
private static inline var BEZIER:Int = 2;
|
||||
private static inline var BEZIER_SIZE:Int = 18;
|
||||
|
||||
private var curves:Vector<Float>; // type, x, y, ...
|
||||
private var curves:Array<Float>; // type, x, y, ...
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector<String>) {
|
||||
public function new(frameCount:Int, bezierCount:Int, propertyIds:Array<String>) {
|
||||
super(frameCount, propertyIds);
|
||||
curves = new Vector<Float>(frameCount + bezierCount * BEZIER_SIZE, true);
|
||||
curves = new Array<Float>();
|
||||
curves.resize(frameCount + bezierCount * BEZIER_SIZE);
|
||||
curves[frameCount - 1] = STEPPED;
|
||||
}
|
||||
|
||||
@ -58,7 +57,7 @@ class CurveTimeline extends Timeline {
|
||||
* than the actual number of Bezier curves. */
|
||||
public function shrink(bezierCount:Int):Void {
|
||||
var size:Int = getFrameCount() + bezierCount * BEZIER_SIZE;
|
||||
curves.length = size;
|
||||
curves.resize(size);
|
||||
}
|
||||
|
||||
/** Stores the segments for the specified Bezier curve. For timelines that modify multiple values, there may be more than
|
||||
|
||||
@ -30,15 +30,13 @@
|
||||
package spine.animation;
|
||||
|
||||
/** The base class for a {@link CurveTimeline} that sets one property. */
|
||||
import openfl.Vector;
|
||||
|
||||
class CurveTimeline1 extends CurveTimeline {
|
||||
private static inline var ENTRIES:Int = 2;
|
||||
private static inline var VALUE:Int = 1;
|
||||
|
||||
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(Int)}.
|
||||
* @param propertyIds Unique identifiers for the properties the timeline modifies. */
|
||||
public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector<String>) {
|
||||
public function new(frameCount:Int, bezierCount:Int, propertyIds:Array<String>) {
|
||||
super(frameCount, bezierCount, propertyIds);
|
||||
}
|
||||
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
package spine.animation;
|
||||
|
||||
/** The base class for a {@link CurveTimeline} which sets two properties. */
|
||||
import openfl.Vector;
|
||||
|
||||
class CurveTimeline2 extends CurveTimeline {
|
||||
private static inline var ENTRIES:Int = 3;
|
||||
private static inline var VALUE1:Int = 1;
|
||||
@ -39,7 +37,7 @@ class CurveTimeline2 extends CurveTimeline {
|
||||
|
||||
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(Int)}.
|
||||
* @param propertyIds Unique identifiers for the properties the timeline modifies. */
|
||||
public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector<String>) {
|
||||
public function new(frameCount:Int, bezierCount:Int, propertyIds:Array<String>) {
|
||||
super(frameCount, bezierCount, propertyIds);
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.animation.Timeline;
|
||||
import spine.attachments.Attachment;
|
||||
import spine.attachments.VertexAttachment;
|
||||
@ -44,13 +43,14 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
|
||||
public var attachment:VertexAttachment;
|
||||
|
||||
/** The vertices for each key frame. */
|
||||
public var vertices:Vector<Vector<Float>>;
|
||||
public var vertices:Array<Array<Float>>;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int, attachment:VertexAttachment) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.deform + "|" + slotIndex + "|" + attachment.id]));
|
||||
super(frameCount, bezierCount, [Property.deform + "|" + slotIndex + "|" + attachment.id]);
|
||||
this.slotIndex = slotIndex;
|
||||
this.attachment = attachment;
|
||||
vertices = new Vector<Vector<Float>>(frameCount, true);
|
||||
vertices = new Array<Array<Float>>();
|
||||
vertices.resize(frameCount);
|
||||
}
|
||||
|
||||
public override function getFrameCount():Int {
|
||||
@ -63,7 +63,7 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
|
||||
|
||||
/** Sets the time in seconds and the vertices for the specified key frame.
|
||||
* @param vertices Vertex positions for an unweighted VertexAttachment, or deform offsets if it has weights. */
|
||||
public function setFrame(frame:Int, time:Float, verticesOrDeform:Vector<Float>):Void {
|
||||
public function setFrame(frame:Int, time:Float, verticesOrDeform:Array<Float>):Void {
|
||||
frames[frame] = time;
|
||||
vertices[frame] = verticesOrDeform;
|
||||
}
|
||||
@ -129,7 +129,7 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
|
||||
return y + (1 - y) * (time - x) / (frames[frame + getFrameEntries()] - x);
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (!slot.bone.active)
|
||||
@ -140,23 +140,23 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
|
||||
if (!Std.isOfType(slotAttachment, VertexAttachment) || cast(slotAttachment, VertexAttachment).timelineAttachment != attachment)
|
||||
return;
|
||||
|
||||
var deform:Vector<Float> = slot.deform;
|
||||
var deform:Array<Float> = slot.deform;
|
||||
if (deform.length == 0)
|
||||
blend = MixBlend.setup;
|
||||
|
||||
var vertexCount:Int = vertices[0].length;
|
||||
var i:Int, setupVertices:Vector<Float>;
|
||||
var i:Int, setupVertices:Array<Float>;
|
||||
|
||||
if (time < frames[0]) {
|
||||
switch (blend) {
|
||||
case MixBlend.setup:
|
||||
deform.length = 0;
|
||||
deform.resize(0);
|
||||
case MixBlend.first:
|
||||
if (alpha == 1) {
|
||||
deform.length = 0;
|
||||
deform.resize(0);
|
||||
return;
|
||||
}
|
||||
deform.length = vertexCount;
|
||||
deform.resize(vertexCount);
|
||||
var vertexAttachment:VertexAttachment = cast(slotAttachment, VertexAttachment);
|
||||
if (vertexAttachment.bones == null) {
|
||||
// Unweighted vertex positions.
|
||||
@ -175,11 +175,11 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
|
||||
return;
|
||||
}
|
||||
|
||||
deform.length = vertexCount;
|
||||
deform.resize(vertexCount);
|
||||
var setup:Float;
|
||||
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
||||
{
|
||||
var lastVertices:Vector<Float> = vertices[frames.length - 1];
|
||||
var lastVertices:Array<Float> = vertices[frames.length - 1];
|
||||
if (alpha == 1) {
|
||||
if (blend == MixBlend.add) {
|
||||
var vertexAttachment:VertexAttachment = cast(slotAttachment, VertexAttachment);
|
||||
@ -243,8 +243,8 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
|
||||
// Interpolate between the previous frame and the current frame.
|
||||
var frame:Int = Timeline.search1(frames, time);
|
||||
var percent:Float = getCurvePercent(time, frame);
|
||||
var prevVertices:Vector<Float> = vertices[frame], prev:Float;
|
||||
var nextVertices:Vector<Float> = vertices[frame + 1];
|
||||
var prevVertices:Array<Float> = vertices[frame], prev:Float;
|
||||
var nextVertices:Array<Float> = vertices[frame + 1];
|
||||
|
||||
if (alpha == 1) {
|
||||
if (blend == MixBlend.add) {
|
||||
|
||||
@ -29,17 +29,17 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
import spine.Slot;
|
||||
|
||||
class DrawOrderTimeline extends Timeline {
|
||||
public var drawOrders:Vector<Vector<Int>>;
|
||||
public var drawOrders:Array<Array<Int>>;
|
||||
|
||||
public function new(frameCount:Int) {
|
||||
super(frameCount, Vector.ofArray([Std.string(Property.drawOrder)]));
|
||||
drawOrders = new Vector<Vector<Int>>(frameCount, true);
|
||||
super(frameCount, [Std.string(Property.drawOrder)]);
|
||||
drawOrders = new Array<Array<Int>>();
|
||||
drawOrders.resize(frameCount);
|
||||
}
|
||||
|
||||
public var frameCount(get, never):Int;
|
||||
@ -49,15 +49,15 @@ class DrawOrderTimeline extends Timeline {
|
||||
}
|
||||
|
||||
/** Sets the time and value of the specified keyframe. */
|
||||
public function setFrame(frame:Int, time:Float, drawOrder:Vector<Int>):Void {
|
||||
public function setFrame(frame:Int, time:Float, drawOrder:Array<Int>):Void {
|
||||
frames[frame] = time;
|
||||
drawOrders[frame] = drawOrder;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var drawOrder:Vector<Slot> = skeleton.drawOrder;
|
||||
var slots:Vector<Slot> = skeleton.slots;
|
||||
var drawOrder:Array<Slot> = skeleton.drawOrder;
|
||||
var slots:Array<Slot> = skeleton.slots;
|
||||
var i:Int = 0, n:Int = slots.length;
|
||||
|
||||
if (direction == MixDirection.mixOut) {
|
||||
@ -78,7 +78,7 @@ class DrawOrderTimeline extends Timeline {
|
||||
return;
|
||||
}
|
||||
|
||||
var drawOrderToSetupIndex:Vector<Int> = drawOrders[Timeline.search1(frames, time)];
|
||||
var drawOrderToSetupIndex:Array<Int> = drawOrders[Timeline.search1(frames, time)];
|
||||
if (drawOrderToSetupIndex == null) {
|
||||
for (i in 0...n) {
|
||||
drawOrder[i] = slots[i];
|
||||
|
||||
@ -29,17 +29,17 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.animation.Timeline;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
|
||||
class EventTimeline extends Timeline {
|
||||
public var events:Vector<Event>;
|
||||
public var events:Array<Event>;
|
||||
|
||||
public function new(frameCount:Int) {
|
||||
super(frameCount, Vector.ofArray([Std.string(Property.event)]));
|
||||
events = new Vector<Event>(frameCount, true);
|
||||
super(frameCount, [Std.string(Property.event)]);
|
||||
events = new Array<Event>();
|
||||
events.resize(frameCount);
|
||||
}
|
||||
|
||||
public override function getFrameCount():Int {
|
||||
@ -53,7 +53,7 @@ class EventTimeline extends Timeline {
|
||||
}
|
||||
|
||||
/** Fires events for frames > `lastTime` and <= `time`. */
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
if (events == null)
|
||||
return;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.IkConstraint;
|
||||
import spine.Skeleton;
|
||||
@ -46,7 +45,7 @@ class IkConstraintTimeline extends CurveTimeline {
|
||||
public var ikConstraintIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, ikConstraintIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.ikConstraint + "|" + ikConstraintIndex]));
|
||||
super(frameCount, bezierCount, [Property.ikConstraint + "|" + ikConstraintIndex]);
|
||||
this.ikConstraintIndex = ikConstraintIndex;
|
||||
}
|
||||
|
||||
@ -65,7 +64,7 @@ class IkConstraintTimeline extends CurveTimeline {
|
||||
frames[frame + STRETCH] = stretch ? 1 : 0;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var constraint:IkConstraint = skeleton.ikConstraints[ikConstraintIndex];
|
||||
if (!constraint.active)
|
||||
|
||||
@ -29,19 +29,17 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class Listeners {
|
||||
private var _listeners:Vector<TrackEntry->Void>;
|
||||
private var _listeners:Array<TrackEntry->Void>;
|
||||
|
||||
public var listeners(get, never):Vector<TrackEntry->Void>;
|
||||
public var listeners(get, never):Array<TrackEntry->Void>;
|
||||
|
||||
private function get_listeners():Vector<TrackEntry->Void> {
|
||||
private function get_listeners():Array<TrackEntry->Void> {
|
||||
return _listeners;
|
||||
}
|
||||
|
||||
public function new() {
|
||||
_listeners = new Vector<TrackEntry->Void>();
|
||||
_listeners = new Array<TrackEntry->Void>();
|
||||
}
|
||||
|
||||
public function invoke(entry:TrackEntry) {
|
||||
@ -68,16 +66,16 @@ class Listeners {
|
||||
}
|
||||
|
||||
class EventListeners {
|
||||
private var _listeners:Vector<TrackEntry->Event->Void>;
|
||||
private var _listeners:Array<TrackEntry->Event->Void>;
|
||||
|
||||
public var listeners(get, never):Vector<TrackEntry->Event->Void>;
|
||||
public var listeners(get, never):Array<TrackEntry->Event->Void>;
|
||||
|
||||
private function get_listeners():Vector<TrackEntry->Event->Void> {
|
||||
private function get_listeners():Array<TrackEntry->Event->Void> {
|
||||
return _listeners;
|
||||
}
|
||||
|
||||
public function new() {
|
||||
_listeners = new Vector<TrackEntry->Event->Void>();
|
||||
_listeners = new Array<TrackEntry->Event->Void>();
|
||||
}
|
||||
|
||||
public function invoke(entry:TrackEntry, event:Event) {
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.PathConstraint;
|
||||
import spine.Skeleton;
|
||||
@ -44,7 +43,7 @@ class PathConstraintMixTimeline extends CurveTimeline {
|
||||
public var pathConstraintIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.pathConstraintMix + "|" + pathConstraintIndex]));
|
||||
super(frameCount, bezierCount, [Property.pathConstraintMix + "|" + pathConstraintIndex]);
|
||||
this.pathConstraintIndex = pathConstraintIndex;
|
||||
}
|
||||
|
||||
@ -60,7 +59,7 @@ class PathConstraintMixTimeline extends CurveTimeline {
|
||||
frames[frame + Y] = mixY;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||
if (!constraint.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.PathConstraint;
|
||||
import spine.Skeleton;
|
||||
@ -39,11 +38,11 @@ class PathConstraintPositionTimeline extends CurveTimeline1 {
|
||||
public var pathConstraintIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.pathConstraintPosition + "|" + pathConstraintIndex]));
|
||||
super(frameCount, bezierCount, [Property.pathConstraintPosition + "|" + pathConstraintIndex]);
|
||||
this.pathConstraintIndex = pathConstraintIndex;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||
if (!constraint.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.PathConstraint;
|
||||
import spine.Skeleton;
|
||||
@ -39,11 +38,11 @@ class PathConstraintSpacingTimeline extends CurveTimeline1 {
|
||||
public var pathConstraintIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.pathConstraintSpacing + "|" + pathConstraintIndex]));
|
||||
super(frameCount, bezierCount, [Property.pathConstraintSpacing + "|" + pathConstraintIndex]);
|
||||
this.pathConstraintIndex = pathConstraintIndex;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
|
||||
if (!constraint.active)
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class RGB2Timeline extends CurveTimeline implements SlotTimeline {
|
||||
private static inline var ENTRIES:Int = 7;
|
||||
private static inline var R:Int = 1;
|
||||
@ -43,7 +41,7 @@ class RGB2Timeline extends CurveTimeline implements SlotTimeline {
|
||||
private var slotIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.rgb + "|" + slotIndex, Property.rgb2 + "|" + slotIndex]));
|
||||
super(frameCount, bezierCount, [Property.rgb + "|" + slotIndex, Property.rgb2 + "|" + slotIndex]);
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
@ -67,7 +65,7 @@ class RGB2Timeline extends CurveTimeline implements SlotTimeline {
|
||||
frames[frame + B2] = b2;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (!slot.bone.active)
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class RGBA2Timeline extends CurveTimeline implements SlotTimeline {
|
||||
private static inline var ENTRIES:Int = 8;
|
||||
private static inline var R:Int = 1;
|
||||
@ -44,11 +42,11 @@ class RGBA2Timeline extends CurveTimeline implements SlotTimeline {
|
||||
private var slotIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([
|
||||
super(frameCount, bezierCount, [
|
||||
Property.rgb + "|" + slotIndex,
|
||||
Property.alpha + "|" + slotIndex,
|
||||
Property.rgb2 + "|" + slotIndex
|
||||
]));
|
||||
]);
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
@ -73,7 +71,7 @@ class RGBA2Timeline extends CurveTimeline implements SlotTimeline {
|
||||
frames[frame + B2] = b2;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (!slot.bone.active)
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class RGBATimeline extends CurveTimeline implements SlotTimeline {
|
||||
private static inline var ENTRIES:Int = 5;
|
||||
private static inline var R:Int = 1;
|
||||
@ -41,7 +39,7 @@ class RGBATimeline extends CurveTimeline implements SlotTimeline {
|
||||
private var slotIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.rgb + "|" + slotIndex, Property.alpha + "|" + slotIndex]));
|
||||
super(frameCount, bezierCount, [Property.rgb + "|" + slotIndex, Property.alpha + "|" + slotIndex]);
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
@ -63,7 +61,7 @@ class RGBATimeline extends CurveTimeline implements SlotTimeline {
|
||||
frames[frame + A] = a;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (!slot.bone.active)
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class RGBTimeline extends CurveTimeline implements SlotTimeline {
|
||||
private static inline var ENTRIES:Int = 4;
|
||||
private static inline var R:Int = 1;
|
||||
@ -40,7 +38,7 @@ class RGBTimeline extends CurveTimeline implements SlotTimeline {
|
||||
private var slotIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.rgb + "|" + slotIndex]));
|
||||
super(frameCount, bezierCount, [Property.rgb + "|" + slotIndex]);
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
@ -61,7 +59,7 @@ class RGBTimeline extends CurveTimeline implements SlotTimeline {
|
||||
frames[frame + B] = b;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot:Slot = skeleton.slots[slotIndex];
|
||||
if (!slot.bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
@ -38,7 +37,7 @@ class RotateTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
public var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.rotate + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.rotate + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ class RotateTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.MathUtils;
|
||||
@ -39,7 +38,7 @@ class ScaleTimeline extends CurveTimeline2 implements BoneTimeline {
|
||||
private var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.scaleX + "|" + boneIndex, Property.scaleY + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.scaleX + "|" + boneIndex, Property.scaleY + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -47,7 +46,7 @@ class ScaleTimeline extends CurveTimeline2 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.MathUtils;
|
||||
@ -39,7 +38,7 @@ class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
private var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.scaleX + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.scaleX + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -47,7 +46,7 @@ class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.MathUtils;
|
||||
@ -39,7 +38,7 @@ class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
private var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.scaleY + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.scaleY + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -47,7 +46,7 @@ class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.attachments.VertexAttachment;
|
||||
import spine.attachments.Attachment;
|
||||
|
||||
@ -42,9 +41,9 @@ class SequenceTimeline extends Timeline implements SlotTimeline {
|
||||
var attachment:HasTextureRegion;
|
||||
|
||||
public function new(frameCount:Int, slotIndex:Int, attachment:HasTextureRegion) {
|
||||
super(frameCount, Vector.ofArray([
|
||||
super(frameCount, [
|
||||
Std.string(Property.sequence) + "|" + Std.string(slotIndex) + "|" + Std.string(attachment.sequence.id)
|
||||
]));
|
||||
]);
|
||||
this.slotIndex = slotIndex;
|
||||
this.attachment = attachment;
|
||||
}
|
||||
@ -71,7 +70,7 @@ class SequenceTimeline extends Timeline implements SlotTimeline {
|
||||
frames[frame + SequenceTimeline.DELAY] = delay;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var slot = skeleton.slots[this.slotIndex];
|
||||
if (!slot.bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
@ -38,7 +37,7 @@ class ShearTimeline extends CurveTimeline2 implements BoneTimeline {
|
||||
private var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.shearX + "|" + boneIndex, Property.shearY + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.shearX + "|" + boneIndex, Property.shearY + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ class ShearTimeline extends CurveTimeline2 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
@ -38,7 +37,7 @@ class ShearXTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
private var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.shearX + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.shearX + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ class ShearXTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
@ -38,7 +37,7 @@ class ShearYTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
private var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.shearY + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.shearY + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ class ShearYTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -31,15 +31,15 @@ package spine.animation;
|
||||
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
import openfl.Vector;
|
||||
|
||||
class Timeline {
|
||||
public var propertyIds:Vector<String>;
|
||||
public var frames:Vector<Float>;
|
||||
public var propertyIds:Array<String>;
|
||||
public var frames:Array<Float>;
|
||||
|
||||
public function new(frameCount:Int, propertyIds:Vector<String>) {
|
||||
public function new(frameCount:Int, propertyIds:Array<String>) {
|
||||
this.propertyIds = propertyIds;
|
||||
frames = new Vector<Float>(frameCount * getFrameEntries(), true);
|
||||
frames = new Array<Float>();
|
||||
frames.resize(frameCount * getFrameEntries());
|
||||
}
|
||||
|
||||
public function getFrameEntries():Int {
|
||||
@ -54,11 +54,11 @@ class Timeline {
|
||||
return frames[frames.length - getFrameEntries()];
|
||||
}
|
||||
|
||||
public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, direction:MixDirection):Void {
|
||||
public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend, direction:MixDirection):Void {
|
||||
throw new SpineException("Timeline implementations must override apply()");
|
||||
}
|
||||
|
||||
public static function search1(frames:Vector<Float>, time:Float):Int {
|
||||
public static function search1(frames:Array<Float>, time:Float):Int {
|
||||
var n:Int = frames.length;
|
||||
for (i in 1...n) {
|
||||
if (frames[i] > time)
|
||||
@ -67,7 +67,7 @@ class Timeline {
|
||||
return n - 1;
|
||||
}
|
||||
|
||||
public static function search(values:Vector<Float>, time:Float, step:Int):Int {
|
||||
public static function search(values:Array<Float>, time:Float, step:Int):Int {
|
||||
var n:Int = values.length;
|
||||
var i:Int = step;
|
||||
while (i < n) {
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.animation.Listeners.EventListeners;
|
||||
import spine.Poolable;
|
||||
|
||||
@ -68,9 +67,9 @@ class TrackEntry implements Poolable {
|
||||
public var interruptAlpha:Float = 0;
|
||||
public var totalAlpha:Float = 0;
|
||||
public var mixBlend:MixBlend = MixBlend.replace;
|
||||
public var timelineMode:Vector<Int> = new Vector<Int>();
|
||||
public var timelineHoldMix:Vector<TrackEntry> = new Vector<TrackEntry>();
|
||||
public var timelinesRotation:Vector<Float> = new Vector<Float>();
|
||||
public var timelineMode:Array<Int> = new Array<Int>();
|
||||
public var timelineHoldMix:Array<TrackEntry> = new Array<TrackEntry>();
|
||||
public var timelinesRotation:Array<Float> = new Array<Float>();
|
||||
public var shortestRotation = false;
|
||||
|
||||
public function new() {}
|
||||
@ -105,18 +104,18 @@ class TrackEntry implements Poolable {
|
||||
mixingFrom = null;
|
||||
mixingTo = null;
|
||||
animation = null;
|
||||
onStart.listeners.length = 0;
|
||||
onInterrupt.listeners.length = 0;
|
||||
onEnd.listeners.length = 0;
|
||||
onDispose.listeners.length = 0;
|
||||
onComplete.listeners.length = 0;
|
||||
onEvent.listeners.length = 0;
|
||||
timelineMode.length = 0;
|
||||
timelineHoldMix.length = 0;
|
||||
timelinesRotation.length = 0;
|
||||
onStart.listeners.resize(0);
|
||||
onInterrupt.listeners.resize(0);
|
||||
onEnd.listeners.resize(0);
|
||||
onDispose.listeners.resize(0);
|
||||
onComplete.listeners.resize(0);
|
||||
onEvent.listeners.resize(0);
|
||||
timelineMode.resize(0);
|
||||
timelineHoldMix.resize(0);
|
||||
timelinesRotation.resize(0);
|
||||
}
|
||||
|
||||
public function resetRotationDirection():Void {
|
||||
timelinesRotation.length = 0;
|
||||
timelinesRotation.resize(0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
import spine.TransformConstraint;
|
||||
@ -48,7 +47,7 @@ class TransformConstraintTimeline extends CurveTimeline {
|
||||
public var transformConstraintIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, transformConstraintIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.transformConstraint + "|" + transformConstraintIndex]));
|
||||
super(frameCount, bezierCount, [Property.transformConstraint + "|" + transformConstraintIndex]);
|
||||
this.transformConstraintIndex = transformConstraintIndex;
|
||||
}
|
||||
|
||||
@ -68,7 +67,7 @@ class TransformConstraintTimeline extends CurveTimeline {
|
||||
frames[frame + SHEARY] = mixShearY;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var constraint:TransformConstraint = skeleton.transformConstraints[transformConstraintIndex];
|
||||
if (!constraint.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
@ -38,7 +37,7 @@ class TranslateTimeline extends CurveTimeline2 implements BoneTimeline {
|
||||
public var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.x + "|" + boneIndex, Property.y + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.x + "|" + boneIndex, Property.y + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ class TranslateTimeline extends CurveTimeline2 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
@ -38,7 +37,7 @@ class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
public var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.x + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.x + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.animation;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Event;
|
||||
import spine.Skeleton;
|
||||
@ -38,7 +37,7 @@ class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
public var boneIndex:Int = 0;
|
||||
|
||||
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
|
||||
super(frameCount, bezierCount, Vector.ofArray([Property.y + "|" + boneIndex]));
|
||||
super(frameCount, bezierCount, [Property.y + "|" + boneIndex]);
|
||||
this.boneIndex = boneIndex;
|
||||
}
|
||||
|
||||
@ -46,7 +45,7 @@ class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline {
|
||||
return boneIndex;
|
||||
}
|
||||
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend,
|
||||
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
|
||||
direction:MixDirection):Void {
|
||||
var bone:Bone = skeleton.bones[boneIndex];
|
||||
if (!bone.active)
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.atlas;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class Format {
|
||||
public static var alpha(default, never):Format = new Format(0, "alpha");
|
||||
public static var intensity(default, never):Format = new Format(1, "intensity");
|
||||
@ -40,7 +38,7 @@ class Format {
|
||||
public static var rgb888(default, never):Format = new Format(5, "rgb888");
|
||||
public static var rgba8888(default, never):Format = new Format(6, "rgba8888");
|
||||
|
||||
public static var values(default, never):Vector<Format> = Vector.ofArray([alpha, intensity, luminanceAlpha, rgb565, rgba4444, rgb888, rgba8888]);
|
||||
public static var values(default, never):Array<Format> = [alpha, intensity, luminanceAlpha, rgb565, rgba4444, rgb888, rgba8888];
|
||||
|
||||
public var ordinal(default, null):Int;
|
||||
public var name(default, null):String;
|
||||
|
||||
@ -29,39 +29,23 @@
|
||||
|
||||
package spine.atlas;
|
||||
|
||||
import haxe.ds.StringMap;
|
||||
import openfl.utils.Assets;
|
||||
import openfl.utils.ByteArray;
|
||||
import openfl.utils.Dictionary;
|
||||
import openfl.Vector;
|
||||
|
||||
class TextureAtlas {
|
||||
private var pages = new Vector<TextureAtlasPage>();
|
||||
private var regions = new Vector<TextureAtlasRegion>();
|
||||
private var pages = new Array<TextureAtlasPage>();
|
||||
private var regions = new Array<TextureAtlasRegion>();
|
||||
private var textureLoader:TextureLoader;
|
||||
|
||||
public static function fromAssets(path:String) {
|
||||
var basePath = "";
|
||||
var slashIndex = path.lastIndexOf("/");
|
||||
if (slashIndex != -1) {
|
||||
basePath = path.substring(0, slashIndex);
|
||||
}
|
||||
|
||||
var textureLoader = new AssetsTextureLoader(basePath);
|
||||
return new TextureAtlas(Assets.getText(path), textureLoader);
|
||||
}
|
||||
|
||||
/** @param object A String or ByteArray. */
|
||||
public function new(object:Dynamic, textureLoader:TextureLoader) {
|
||||
if (object == null) {
|
||||
return;
|
||||
public function new(atlasText:String, textureLoader:TextureLoader) {
|
||||
if (atlasText == null) {
|
||||
throw new SpineException("atlasText must not be null");
|
||||
}
|
||||
if (Std.isOfType(object, String)) {
|
||||
load(cast(object, String), textureLoader);
|
||||
} else if (Std.isOfType(object, ByteArrayData)) {
|
||||
load(cast(object, ByteArray).readUTFBytes(cast(object, ByteArray).length), textureLoader);
|
||||
} else {
|
||||
throw new SpineException("object must be a string or ByteArrayData.");
|
||||
if (textureLoader == null) {
|
||||
throw new SpineException("textureLoader must not be null");
|
||||
}
|
||||
load(atlasText, textureLoader);
|
||||
}
|
||||
|
||||
private function load(atlasText:String, textureLoader:TextureLoader):Void {
|
||||
@ -71,71 +55,72 @@ class TextureAtlas {
|
||||
this.textureLoader = textureLoader;
|
||||
|
||||
var reader:Reader = new Reader(atlasText);
|
||||
var entry:Vector<String> = new Vector<String>(5, true);
|
||||
var entry:Array<String> = new Array<String>();
|
||||
entry.resize(5);
|
||||
var page:TextureAtlasPage = null;
|
||||
var region:TextureAtlasRegion = null;
|
||||
|
||||
var pageFields:Dictionary<String, Void->Void> = new Dictionary<String, Void->Void>();
|
||||
pageFields["size"] = function():Void {
|
||||
var pageFields:StringMap<Void->Void> = new StringMap<Void->Void>();
|
||||
pageFields.set("size", function():Void {
|
||||
page.width = Std.parseInt(entry[1]);
|
||||
page.height = Std.parseInt(entry[2]);
|
||||
};
|
||||
pageFields["format"] = function():Void {
|
||||
});
|
||||
pageFields.set("format", function():Void {
|
||||
page.format = Format.fromName(entry[0]);
|
||||
};
|
||||
pageFields["filter"] = function():Void {
|
||||
});
|
||||
pageFields.set("filter", function():Void {
|
||||
page.minFilter = TextureFilter.fromName(entry[1]);
|
||||
page.magFilter = TextureFilter.fromName(entry[2]);
|
||||
};
|
||||
pageFields["repeat"] = function():Void {
|
||||
});
|
||||
pageFields.set("repeat", function():Void {
|
||||
if (entry[1].indexOf('x') != -1)
|
||||
page.uWrap = TextureWrap.repeat;
|
||||
if (entry[1].indexOf('y') != -1)
|
||||
page.vWrap = TextureWrap.repeat;
|
||||
};
|
||||
pageFields["pma"] = function():Void {
|
||||
});
|
||||
pageFields.set("pma", function():Void {
|
||||
page.pma = entry[1] == "true";
|
||||
};
|
||||
});
|
||||
|
||||
var regionFields:Dictionary<String, Void->Void> = new Dictionary<String, Void->Void>();
|
||||
regionFields["xy"] = function():Void {
|
||||
var regionFields:StringMap<Void->Void> = new StringMap<Void->Void>();
|
||||
regionFields.set("xy", function():Void {
|
||||
region.x = Std.parseInt(entry[1]);
|
||||
region.y = Std.parseInt(entry[2]);
|
||||
};
|
||||
regionFields["size"] = function():Void {
|
||||
});
|
||||
regionFields.set("size", function():Void {
|
||||
region.width = Std.parseInt(entry[1]);
|
||||
region.height = Std.parseInt(entry[2]);
|
||||
};
|
||||
regionFields["bounds"] = function():Void {
|
||||
});
|
||||
regionFields.set("bounds", function():Void {
|
||||
region.x = Std.parseInt(entry[1]);
|
||||
region.y = Std.parseInt(entry[2]);
|
||||
region.width = Std.parseInt(entry[3]);
|
||||
region.height = Std.parseInt(entry[4]);
|
||||
};
|
||||
regionFields["offset"] = function():Void {
|
||||
});
|
||||
regionFields.set("offset", function():Void {
|
||||
region.offsetX = Std.parseInt(entry[1]);
|
||||
region.offsetY = Std.parseInt(entry[2]);
|
||||
};
|
||||
regionFields["orig"] = function():Void {
|
||||
});
|
||||
regionFields.set("orig", function():Void {
|
||||
region.originalWidth = Std.parseInt(entry[1]);
|
||||
region.originalHeight = Std.parseInt(entry[2]);
|
||||
};
|
||||
regionFields["offsets"] = function():Void {
|
||||
});
|
||||
regionFields.set("offsets", function():Void {
|
||||
region.offsetX = Std.parseInt(entry[1]);
|
||||
region.offsetY = Std.parseInt(entry[2]);
|
||||
region.originalWidth = Std.parseInt(entry[3]);
|
||||
region.originalHeight = Std.parseInt(entry[4]);
|
||||
};
|
||||
regionFields["rotate"] = function():Void {
|
||||
});
|
||||
regionFields.set("rotate", function():Void {
|
||||
var value:String = entry[1];
|
||||
if (value == "true")
|
||||
region.degrees = 90;
|
||||
else if (value != "false")
|
||||
region.degrees = Std.parseInt(value);
|
||||
};
|
||||
regionFields["index"] = function():Void {
|
||||
});
|
||||
regionFields.set("index", function():Void {
|
||||
region.index = Std.parseInt(entry[1]);
|
||||
};
|
||||
});
|
||||
|
||||
var line:String = reader.readLine();
|
||||
// Ignore empty lines before first entry.
|
||||
@ -153,8 +138,8 @@ class TextureAtlas {
|
||||
}
|
||||
|
||||
// Page and region entries.
|
||||
var names:Vector<String> = null;
|
||||
var values:Vector<Vector<Float>> = null;
|
||||
var names:Array<String> = null;
|
||||
var values:Array<Array<Float>> = null;
|
||||
var field:Void->Void;
|
||||
while (true) {
|
||||
if (line == null)
|
||||
@ -167,7 +152,7 @@ class TextureAtlas {
|
||||
while (true) {
|
||||
if (reader.readEntry(entry, line = reader.readLine()) == 0)
|
||||
break;
|
||||
field = pageFields[entry[0]];
|
||||
field = pageFields.get(entry[0]);
|
||||
if (field != null) {
|
||||
field();
|
||||
}
|
||||
@ -180,16 +165,17 @@ class TextureAtlas {
|
||||
var count:Int = reader.readEntry(entry, line = reader.readLine());
|
||||
if (count == 0)
|
||||
break;
|
||||
field = regionFields[entry[0]];
|
||||
field = regionFields.get(entry[0]);
|
||||
if (field != null) {
|
||||
field();
|
||||
} else {
|
||||
if (names == null) {
|
||||
names = new Vector<String>();
|
||||
values = new Vector<Vector<Float>>();
|
||||
names = new Array<String>();
|
||||
values = new Array<Array<Float>>();
|
||||
}
|
||||
names.push(entry[0]);
|
||||
var entryValues:Vector<Float> = new Vector<Float>(count, true);
|
||||
var entryValues:Array<Float> = new Array<Float>();
|
||||
entryValues.resize(count);
|
||||
for (i in 0...count) {
|
||||
entryValues[i] = Std.parseInt(entry[i + 1]);
|
||||
}
|
||||
@ -262,7 +248,7 @@ class Reader {
|
||||
return index >= lines.length ? null : lines[index++];
|
||||
}
|
||||
|
||||
public function readEntry(entry:Vector<String>, line:String):Int {
|
||||
public function readEntry(entry:Array<String>, line:String):Int {
|
||||
if (line == null)
|
||||
return 0;
|
||||
if (line.length == 0)
|
||||
|
||||
@ -29,18 +29,16 @@
|
||||
|
||||
package spine.atlas;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class TextureAtlasRegion extends TextureRegion {
|
||||
public var page:TextureAtlasPage;
|
||||
public var name:String;
|
||||
public var x:Int = 0;
|
||||
public var y:Int = 0;
|
||||
public var index:Int = 0;
|
||||
public var splits:Vector<Int>;
|
||||
public var pads:Vector<Int>;
|
||||
public var names:Vector<String>;
|
||||
public var values:Vector<Vector<Float>>;
|
||||
public var splits:Array<Int>;
|
||||
public var pads:Array<Int>;
|
||||
public var names:Array<String>;
|
||||
public var values:Array<Array<Float>>;
|
||||
|
||||
public function new(page:TextureAtlasPage, name:String) {
|
||||
super();
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.atlas;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class TextureFilter {
|
||||
public static var nearest(default, never):TextureFilter = new TextureFilter(0, "nearest");
|
||||
public static var linear(default, never):TextureFilter = new TextureFilter(1, "linear");
|
||||
@ -40,7 +38,7 @@ class TextureFilter {
|
||||
public static var mipMapNearestLinear(default, never):TextureFilter = new TextureFilter(5, "mipMapNearestLinear");
|
||||
public static var mipMapLinearLinear(default, never):TextureFilter = new TextureFilter(6, "mipMapLinearLinear");
|
||||
|
||||
public static var values(default, never):Vector<TextureFilter> = Vector.ofArray([
|
||||
public static var values(default, never):Array<TextureFilter> = [
|
||||
nearest,
|
||||
linear,
|
||||
mipMap,
|
||||
@ -48,7 +46,7 @@ class TextureFilter {
|
||||
mipMapLinearNearest,
|
||||
mipMapNearestLinear,
|
||||
mipMapLinearLinear
|
||||
]);
|
||||
];
|
||||
|
||||
public var ordinal(default, null):Int;
|
||||
public var name(default, null):String;
|
||||
|
||||
@ -29,14 +29,12 @@
|
||||
|
||||
package spine.atlas;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class TextureWrap {
|
||||
public static var mirroredRepeat(default, never):TextureWrap = new TextureWrap(0, "mirroredRepeat");
|
||||
public static var clampToEdge(default, never):TextureWrap = new TextureWrap(1, "clampToEdge");
|
||||
public static var repeat(default, never):TextureWrap = new TextureWrap(2, "repeat");
|
||||
|
||||
public static var values(default, never):Vector<TextureWrap> = Vector.ofArray([mirroredRepeat, clampToEdge, repeat]);
|
||||
public static var values(default, never):Array<TextureWrap> = [mirroredRepeat, clampToEdge, repeat];
|
||||
|
||||
public var ordinal(default, null):Int;
|
||||
public var name(default, null):String;
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.attachments;
|
||||
|
||||
import openfl.Vector;
|
||||
|
||||
class AttachmentType {
|
||||
public static var region(default, never):AttachmentType = new AttachmentType(0, "region");
|
||||
public static var boundingbox(default, never):AttachmentType = new AttachmentType(1, "boundingbox");
|
||||
@ -40,7 +38,7 @@ class AttachmentType {
|
||||
public static var point(default, never):AttachmentType = new AttachmentType(5, "point");
|
||||
public static var clipping(default, never):AttachmentType = new AttachmentType(6, "clipping");
|
||||
|
||||
public static var values(default, never):Vector<AttachmentType> = Vector.ofArray([region, boundingbox, mesh, linkedmesh, path, point, clipping]);
|
||||
public static var values(default, never):Array<AttachmentType> = [region, boundingbox, mesh, linkedmesh, path, point, clipping];
|
||||
|
||||
public var ordinal(default, null):Int;
|
||||
public var name(default, null):String;
|
||||
|
||||
@ -29,21 +29,20 @@
|
||||
|
||||
package spine.attachments;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Color;
|
||||
import spine.atlas.TextureAtlasRegion;
|
||||
|
||||
class MeshAttachment extends VertexAttachment implements HasTextureRegion {
|
||||
public var region:TextureRegion;
|
||||
public var path:String;
|
||||
public var regionUVs = new Vector<Float>();
|
||||
public var uvs = new Vector<Float>();
|
||||
public var triangles = new Vector<Int>();
|
||||
public var regionUVs = new Array<Float>();
|
||||
public var uvs = new Array<Float>();
|
||||
public var triangles = new Array<Int>();
|
||||
public var color:Color = new Color(1, 1, 1, 1);
|
||||
public var width:Float = 0;
|
||||
public var height:Float = 0;
|
||||
public var hullLength:Int = 0;
|
||||
public var edges = new Vector<Int>();
|
||||
public var edges = new Array<Int>();
|
||||
public var rendererObject:Dynamic;
|
||||
public var sequence:Sequence;
|
||||
|
||||
@ -60,8 +59,10 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion {
|
||||
return;
|
||||
}
|
||||
var regionUVs = this.regionUVs;
|
||||
if (uvs.length != regionUVs.length)
|
||||
uvs = new Vector<Float>(regionUVs.length, true);
|
||||
if (uvs.length != regionUVs.length) {
|
||||
uvs = new Array<Float>();
|
||||
uvs.resize(regionUVs.length);
|
||||
}
|
||||
var n = uvs.length;
|
||||
var u = region.u, v = region.v, width:Float = 0, height:Float = 0;
|
||||
if (Std.isOfType(region, TextureAtlasRegion)) {
|
||||
@ -156,15 +157,15 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion {
|
||||
copy.rendererObject = rendererObject;
|
||||
|
||||
this.copyTo(copy);
|
||||
copy.regionUVs = regionUVs.concat();
|
||||
copy.uvs = uvs.concat();
|
||||
copy.triangles = triangles.concat();
|
||||
copy.regionUVs = regionUVs.copy();
|
||||
copy.uvs = uvs.copy();
|
||||
copy.triangles = triangles.copy();
|
||||
copy.hullLength = hullLength;
|
||||
|
||||
copy.sequence = sequence != null ? sequence.copy() : null;
|
||||
|
||||
if (edges != null) {
|
||||
copy.edges = edges.concat();
|
||||
copy.edges = edges.copy();
|
||||
}
|
||||
copy.width = width;
|
||||
copy.height = height;
|
||||
@ -172,7 +173,7 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion {
|
||||
return copy;
|
||||
}
|
||||
|
||||
public override function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Vector<Float>, offset:Int, stride:Int):Void {
|
||||
public override function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Array<Float>, offset:Int, stride:Int):Void {
|
||||
if (sequence != null)
|
||||
sequence.apply(slot, this);
|
||||
super.computeWorldVertices(slot, start, count, worldVertices, offset, stride);
|
||||
|
||||
@ -29,11 +29,10 @@
|
||||
|
||||
package spine.attachments;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Color;
|
||||
|
||||
class PathAttachment extends VertexAttachment {
|
||||
public var lengths:Vector<Float>;
|
||||
public var lengths:Array<Float>;
|
||||
public var closed:Bool = false;
|
||||
public var constantSpeed:Bool = false;
|
||||
public var color:Color = new Color(0, 0, 0, 0);
|
||||
@ -45,7 +44,7 @@ class PathAttachment extends VertexAttachment {
|
||||
override public function copy():Attachment {
|
||||
var copy:PathAttachment = new PathAttachment(name);
|
||||
copyTo(copy);
|
||||
copy.lengths = lengths.concat();
|
||||
copy.lengths = lengths.copy();
|
||||
copy.closed = closed;
|
||||
copy.constantSpeed = constantSpeed;
|
||||
return copy;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.attachments;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Color;
|
||||
import spine.MathUtils;
|
||||
@ -44,7 +43,7 @@ class PointAttachment extends VertexAttachment {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public function computeWorldPosition(bone:Bone, point:Vector<Float>):Vector<Float> {
|
||||
public function computeWorldPosition(bone:Bone, point:Array<Float>):Array<Float> {
|
||||
point[0] = x * bone.a + y * bone.b + bone.worldX;
|
||||
point[1] = x * bone.c + y * bone.d + bone.worldY;
|
||||
return point;
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
package spine.attachments;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Color;
|
||||
|
||||
class RegionAttachment extends Attachment implements HasTextureRegion {
|
||||
@ -56,9 +54,9 @@ class RegionAttachment extends Attachment implements HasTextureRegion {
|
||||
public var region:TextureRegion;
|
||||
public var sequence:Sequence;
|
||||
|
||||
private var offsets:Vector<Float> = new Vector<Float>(8, true);
|
||||
private var offsets:Array<Float> = new Array<Float>();
|
||||
|
||||
public var uvs:Vector<Float> = new Vector<Float>(8, true);
|
||||
public var uvs:Array<Float> = new Array<Float>();
|
||||
|
||||
public function new(name:String, path:String) {
|
||||
super(name);
|
||||
@ -128,7 +126,7 @@ class RegionAttachment extends Attachment implements HasTextureRegion {
|
||||
}
|
||||
}
|
||||
|
||||
public function computeWorldVertices(slot:Slot, worldVertices:Vector<Float>, offset:Int, stride:Int):Void {
|
||||
public function computeWorldVertices(slot:Slot, worldVertices:Array<Float>, offset:Int, stride:Int):Void {
|
||||
if (sequence != null)
|
||||
sequence.apply(slot, this);
|
||||
|
||||
@ -173,8 +171,8 @@ class RegionAttachment extends Attachment implements HasTextureRegion {
|
||||
copy.rotation = rotation;
|
||||
copy.width = width;
|
||||
copy.height = height;
|
||||
copy.uvs = uvs.concat();
|
||||
copy.offsets = offsets.concat();
|
||||
copy.uvs = uvs.copy();
|
||||
copy.offsets = offsets.copy();
|
||||
copy.color.setFromColor(color);
|
||||
copy.sequence = sequence != null ? sequence.copy() : null;
|
||||
return copy;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
|
||||
package spine.attachments;
|
||||
|
||||
import openfl.Vector;
|
||||
import spine.Bone;
|
||||
import spine.Skeleton;
|
||||
import spine.Slot;
|
||||
@ -37,8 +36,8 @@ import spine.Slot;
|
||||
class VertexAttachment extends Attachment {
|
||||
private static var nextID:Int = 0;
|
||||
|
||||
public var bones:Vector<Int>;
|
||||
public var vertices = new Vector<Float>();
|
||||
public var bones:Array<Int>;
|
||||
public var vertices = new Array<Float>();
|
||||
public var worldVerticesLength:Int = 0;
|
||||
public var id:Int = nextID++;
|
||||
public var timelineAttachment:VertexAttachment;
|
||||
@ -59,10 +58,10 @@ class VertexAttachment extends Attachment {
|
||||
* `stride` / 2.
|
||||
* @param offset The `worldVertices` index to begin writing values.
|
||||
* @param stride The number of `worldVertices` entries between the value pairs written. */
|
||||
public function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Vector<Float>, offset:Int, stride:Int):Void {
|
||||
public function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Array<Float>, offset:Int, stride:Int):Void {
|
||||
count = offset + (count >> 1) * stride;
|
||||
var skeleton:Skeleton = slot.skeleton;
|
||||
var deform:Vector<Float> = slot.deform;
|
||||
var deform:Array<Float> = slot.deform;
|
||||
|
||||
var v:Int, w:Int, n:Int, i:Int, skip:Int, b:Int, f:Int;
|
||||
var vx:Float, vy:Float;
|
||||
@ -100,7 +99,7 @@ class VertexAttachment extends Attachment {
|
||||
skip += n;
|
||||
i += 2;
|
||||
}
|
||||
var skeletonBones:Vector<Bone> = skeleton.bones;
|
||||
var skeletonBones:Array<Bone> = skeleton.bones;
|
||||
if (deform.length == 0) {
|
||||
w = offset;
|
||||
b = skip * 3;
|
||||
@ -152,13 +151,13 @@ class VertexAttachment extends Attachment {
|
||||
|
||||
public function copyTo(attachment:VertexAttachment):Void {
|
||||
if (bones != null) {
|
||||
attachment.bones = bones.concat();
|
||||
attachment.bones = bones.copy();
|
||||
} else {
|
||||
attachment.bones = null;
|
||||
}
|
||||
|
||||
if (this.vertices != null) {
|
||||
attachment.vertices = vertices.concat();
|
||||
attachment.vertices = vertices.copy();
|
||||
}
|
||||
|
||||
attachment.worldVerticesLength = worldVerticesLength;
|
||||
|
||||
@ -30,7 +30,6 @@
|
||||
package spine.starling;
|
||||
|
||||
import starling.animation.IAnimatable;
|
||||
import openfl.Vector;
|
||||
import openfl.geom.Matrix;
|
||||
import openfl.geom.Point;
|
||||
import openfl.geom.Rectangle;
|
||||
@ -58,8 +57,8 @@ import starling.utils.Max;
|
||||
class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
static private var _tempPoint:Point = new Point();
|
||||
static private var _tempMatrix:Matrix = new Matrix();
|
||||
static private var _tempVertices:Vector<Float> = new Vector<Float>();
|
||||
static private var blendModes:Vector<String> = Vector.ofArray([BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN]);
|
||||
static private var _tempVertices:Array<Float> = new Array<Float>();
|
||||
static private var blendModes:Array<String> = [BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN];
|
||||
|
||||
private var _skeleton:Skeleton;
|
||||
|
||||
@ -68,7 +67,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
private var _smoothing:String = "bilinear";
|
||||
|
||||
private static var clipper:SkeletonClipping = new SkeletonClipping();
|
||||
private static var QUAD_INDICES:Vector<Int> = Vector.ofArray([0, 1, 2, 2, 3, 0]);
|
||||
private static var QUAD_INDICES:Array<Int> = [0, 1, 2, 2, 3, 0];
|
||||
|
||||
private var tempLight:spine.Color = new spine.Color(0, 0, 0);
|
||||
private var tempDark:spine.Color = new spine.Color(0, 0, 0);
|
||||
@ -88,7 +87,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
var r:Float = skeleton.color.r * 255;
|
||||
var g:Float = skeleton.color.g * 255;
|
||||
var b:Float = skeleton.color.b * 255;
|
||||
var drawOrder:Vector<Slot> = skeleton.drawOrder;
|
||||
var drawOrder:Array<Slot> = skeleton.drawOrder;
|
||||
var attachmentColor:spine.Color;
|
||||
var rgb:Int;
|
||||
var a:Float;
|
||||
@ -98,9 +97,9 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
var verticesCount:Int;
|
||||
var indicesLength:Int;
|
||||
var indexData:IndexData;
|
||||
var indices:Vector<Int> = null;
|
||||
var indices:Array<Int> = null;
|
||||
var vertexData:VertexData;
|
||||
var uvs:Vector<Float>;
|
||||
var uvs:Array<Float>;
|
||||
|
||||
for (slot in drawOrder) {
|
||||
if (!slot.bone.active) {
|
||||
@ -108,13 +107,13 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
continue;
|
||||
}
|
||||
|
||||
var worldVertices:Vector<Float> = _tempVertices;
|
||||
var worldVertices:Array<Float> = _tempVertices;
|
||||
if (Std.isOfType(slot.attachment, RegionAttachment)) {
|
||||
var region:RegionAttachment = cast(slot.attachment, RegionAttachment);
|
||||
verticesLength = 8;
|
||||
verticesCount = verticesLength >> 1;
|
||||
if (worldVertices.length < verticesLength)
|
||||
worldVertices.length = verticesLength;
|
||||
worldVertices.resize(verticesLength);
|
||||
region.computeWorldVertices(slot, worldVertices, 0, 2);
|
||||
|
||||
mesh = null;
|
||||
@ -142,7 +141,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
verticesLength = meshAttachment.worldVerticesLength;
|
||||
verticesCount = verticesLength >> 1;
|
||||
if (worldVertices.length < verticesLength)
|
||||
worldVertices.length = verticesLength;
|
||||
worldVertices.resize(verticesLength);
|
||||
meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, 2);
|
||||
|
||||
mesh = null;
|
||||
@ -237,8 +236,8 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
var minY:Float = Max.MAX_VALUE;
|
||||
var maxX:Float = -Max.MAX_VALUE;
|
||||
var maxY:Float = -Max.MAX_VALUE;
|
||||
var slots:Vector<Slot> = skeleton.slots;
|
||||
var worldVertices:Vector<Float> = _tempVertices;
|
||||
var slots:Array<Slot> = skeleton.slots;
|
||||
var worldVertices:Array<Float> = _tempVertices;
|
||||
var empty:Bool = true;
|
||||
for (i in 0...slots.length) {
|
||||
var slot:Slot = slots[i];
|
||||
@ -254,7 +253,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
|
||||
var mesh:MeshAttachment = cast(attachment, MeshAttachment);
|
||||
verticesLength = mesh.worldVerticesLength;
|
||||
if (worldVertices.length < verticesLength)
|
||||
worldVertices.length = verticesLength;
|
||||
worldVertices.resize(verticesLength);
|
||||
mesh.computeWorldVertices(slot, 0, verticesLength, worldVertices, 0, 2);
|
||||
} else {
|
||||
continue;
|
||||
|
||||
@ -27,18 +27,22 @@
|
||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
package spine.atlas;
|
||||
package spine.starling;
|
||||
|
||||
import starling.textures.Texture;
|
||||
import spine.atlas.TextureAtlasRegion;
|
||||
import spine.atlas.TextureAtlasPage;
|
||||
import spine.atlas.TextureLoader;
|
||||
|
||||
class AssetsTextureLoader implements TextureLoader {
|
||||
class StarlingTextureLoader implements TextureLoader {
|
||||
private var basePath:String;
|
||||
|
||||
public function new(basePath:String) {
|
||||
this.basePath = basePath;
|
||||
public function new(atlasPath:String) {
|
||||
basePath = "";
|
||||
var slashIndex = atlasPath.lastIndexOf("/");
|
||||
if (slashIndex != -1) {
|
||||
basePath = atlasPath.substring(0, slashIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadPage(page:TextureAtlasPage, path:String) {
|
||||
@ -842,6 +842,11 @@ namespace Spine.Unity {
|
||||
SubmeshInstruction submeshInstructionItem = currentInstructions.submeshInstructions.Items[i];
|
||||
Material submeshMaterial = submeshInstructionItem.material;
|
||||
if (useOriginalTextureAndMaterial) {
|
||||
if (submeshMaterial == null) {
|
||||
usedMaterialItems[i] = null;
|
||||
usedTextureItems[i] = null;
|
||||
continue;
|
||||
}
|
||||
usedTextureItems[i] = submeshMaterial.mainTexture;
|
||||
if (!hasBlendModeMaterials) {
|
||||
usedMaterialItems[i] = this.materialForRendering;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "com.esotericsoftware.spine.spine-unity",
|
||||
"displayName": "spine-unity Runtime",
|
||||
"description": "This plugin provides the spine-unity runtime core.",
|
||||
"version": "4.2.23",
|
||||
"version": "4.2.24",
|
||||
"unity": "2018.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
|
||||
@ -3,6 +3,7 @@ Shader "Universal Render Pipeline/Spine/Skeleton" {
|
||||
_Cutoff("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[NoScaleOffset] _MainTex("Main Texture", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[Toggle(_ZWRITE)] _ZWrite("Depth Write", Float) = 0.0
|
||||
[MaterialToggle(_TINT_BLACK_ON)] _TintBlack("Tint Black", Float) = 0
|
||||
_Color(" Light Color", Color) = (1,1,1,1)
|
||||
_Black(" Dark Color", Color) = (0,0,0,0)
|
||||
@ -29,7 +30,7 @@ Shader "Universal Render Pipeline/Spine/Skeleton" {
|
||||
Name "Forward"
|
||||
Tags{"LightMode" = "UniversalForward"}
|
||||
|
||||
ZWrite Off
|
||||
ZWrite[_ZWrite]
|
||||
Cull Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
Shader "Universal Render Pipeline/Spine/Skeleton Lit" {
|
||||
Shader "Universal Render Pipeline/Spine/Skeleton Lit" {
|
||||
Properties {
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[Toggle(_ZWRITE)] _ZWrite("Depth Write", Float) = 0.0
|
||||
[Toggle(_RECEIVE_SHADOWS)] _ReceiveShadows("Receive Shadows", Int) = 0
|
||||
[Toggle(_DOUBLE_SIDED_LIGHTING)] _DoubleSidedLighting("Double-Sided Lighting", Int) = 0
|
||||
[MaterialToggle(_LIGHT_AFFECTS_ADDITIVE)] _LightAffectsAdditive("Light Affects Additive", Float) = 0
|
||||
@ -19,7 +20,7 @@
|
||||
Tags { "RenderPipeline" = "UniversalPipeline" "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
ZWrite[_ZWrite]
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
Stencil {
|
||||
@ -32,7 +33,7 @@
|
||||
Name "ForwardLit"
|
||||
Tags{"LightMode" = "UniversalForward"}
|
||||
|
||||
ZWrite Off
|
||||
ZWrite[_ZWrite]
|
||||
Cull Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "com.esotericsoftware.spine.urp-shaders",
|
||||
"displayName": "Spine Universal RP Shaders",
|
||||
"description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
||||
"version": "4.2.21",
|
||||
"version": "4.2.22",
|
||||
"unity": "2019.3",
|
||||
"author": {
|
||||
"name": "Esoteric Software",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user