mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Merge remote-tracking branch 'origin/3.6' into 3.6
This commit is contained in:
commit
751c99ad2d
Binary file not shown.
@ -33,6 +33,7 @@ package spine {
|
||||
|
||||
public class PathConstraint implements Constraint {
|
||||
private static const NONE : int = -1, BEFORE : int = -2, AFTER : int = -3;
|
||||
private static const epsilon : Number = 0.00001;
|
||||
internal var _data : PathConstraintData;
|
||||
internal var _bones : Vector.<Bone>;
|
||||
public var target : Slot;
|
||||
@ -88,11 +89,15 @@ package spine {
|
||||
for (var i : int = 0, n : int = spacesCount - 1; i < n;) {
|
||||
var bone : Bone = bones[i];
|
||||
var setupLength : Number = bone.data.length;
|
||||
if (setupLength == 0) setupLength = 0.000000001;
|
||||
var x : Number = setupLength * bone.a, y : Number = setupLength * bone.c;
|
||||
var length : Number = Math.sqrt(x * x + y * y);
|
||||
if (scale) lengths[i] = length;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
if (setupLength < epsilon) {
|
||||
if (scale) lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
} else {
|
||||
var x : Number = setupLength * bone.a, y : Number = setupLength * bone.c;
|
||||
var length : Number = Math.sqrt(x * x + y * y);
|
||||
if (scale) lengths[i] = length;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 1; i < spacesCount; i++)
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#define PATHCONSTRAINT_NONE -1
|
||||
#define PATHCONSTRAINT_BEFORE -2
|
||||
#define PATHCONSTRAINT_AFTER -3
|
||||
#define EPSILON 0.00001f
|
||||
|
||||
spPathConstraint* spPathConstraint_create (spPathConstraintData* data, const spSkeleton* skeleton) {
|
||||
int i;
|
||||
@ -113,13 +114,17 @@ void spPathConstraint_apply (spPathConstraint* self) {
|
||||
lengths = self->lengths;
|
||||
}
|
||||
for (i = 0, n = spacesCount - 1; i < n;) {
|
||||
spBone* bone = bones[i];
|
||||
spBone *bone = bones[i];
|
||||
setupLength = bone->data->length;
|
||||
if (setupLength == 0) setupLength = 0.000000001f;
|
||||
x = setupLength * bone->a, y = setupLength * bone->c;
|
||||
length = SQRT(x * x + y * y);
|
||||
if (scale) lengths[i] = length;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
if (setupLength < EPSILON) {
|
||||
if (scale) lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
} else {
|
||||
x = setupLength * bone->a, y = setupLength * bone->c;
|
||||
length = SQRT(x * x + y * y);
|
||||
if (scale) lengths[i] = length;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 1; i < spacesCount; i++) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
//
|
||||
//
|
||||
// System.Collections.Generic.List
|
||||
//
|
||||
// Authors:
|
||||
@ -97,9 +97,9 @@ namespace Spine {
|
||||
// var newItems = new T[newSize];
|
||||
// Array.Copy(oldItems, newItems, Count);
|
||||
// Items = newItems;
|
||||
} else if (newSize > itemsLength) {
|
||||
} else if (newSize < itemsLength) {
|
||||
// Allow nulling of T reference type to allow GC.
|
||||
for (int i = Count; i < itemsLength; i++)
|
||||
for (int i = newSize; i < itemsLength; i++)
|
||||
oldItems[i] = default(T);
|
||||
}
|
||||
Count = newSize;
|
||||
|
||||
@ -33,6 +33,7 @@ using System;
|
||||
namespace Spine {
|
||||
public class PathConstraint : IConstraint {
|
||||
const int NONE = -1, BEFORE = -2, AFTER = -3;
|
||||
const float Epsilon = 0.00001f;
|
||||
|
||||
internal PathConstraintData data;
|
||||
internal ExposedList<Bone> bones;
|
||||
@ -93,11 +94,15 @@ namespace Spine {
|
||||
for (int i = 0, n = spacesCount - 1; i < n;) {
|
||||
Bone bone = bonesItems[i];
|
||||
float setupLength = bone.data.length;
|
||||
if (setupLength == 0) setupLength = 0.000000001f;
|
||||
float x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
float length = (float)Math.Sqrt(x * x + y * y);
|
||||
if (scale) lengths.Items[i] = length;
|
||||
spaces.Items[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
if (setupLength < PathConstraint.Epsilon) {
|
||||
if (scale) lengths.Items[i] = 0;
|
||||
spaces.Items[++i] = 0;
|
||||
} else {
|
||||
float x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
float length = (float)Math.Sqrt(x * x + y * y);
|
||||
if (scale) lengths.Items[i] = length;
|
||||
spaces.Items[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 1; i < spacesCount; i++)
|
||||
@ -122,7 +127,7 @@ namespace Spine {
|
||||
float x = positions[p], y = positions[p + 1], dx = x - boneX, dy = y - boneY;
|
||||
if (scale) {
|
||||
float length = lengths.Items[i];
|
||||
if (length != 0) {
|
||||
if (length >= PathConstraint.Epsilon) {
|
||||
float s = ((float)Math.Sqrt(dx * dx + dy * dy) / length - 1) * rotateMix + 1;
|
||||
bone.a *= s;
|
||||
bone.c *= s;
|
||||
@ -134,7 +139,7 @@ namespace Spine {
|
||||
float a = bone.a, b = bone.b, c = bone.c, d = bone.d, r, cos, sin;
|
||||
if (tangents)
|
||||
r = positions[p - 1];
|
||||
else if (spaces.Items[i + 1] == 0)
|
||||
else if (spaces.Items[i + 1] < PathConstraint.Epsilon)
|
||||
r = positions[p + 2];
|
||||
else
|
||||
r = MathUtils.Atan2(dy, dx);
|
||||
@ -230,7 +235,7 @@ namespace Spine {
|
||||
path.ComputeWorldVertices(target, curve * 6 + 2, 8, world, 0);
|
||||
}
|
||||
AddCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7], output, o,
|
||||
tangents || (i > 0 && space == 0));
|
||||
tangents || (i > 0 && space < PathConstraint.Epsilon));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
@ -378,7 +383,7 @@ namespace Spine {
|
||||
}
|
||||
break;
|
||||
}
|
||||
AddCurvePosition(p * 0.1f, x1, y1, cx1, cy1, cx2, cy2, x2, y2, output, o, tangents || (i > 0 && space == 0));
|
||||
AddCurvePosition(p * 0.1f, x1, y1, cx1, cy1, cx2, cy2, x2, y2, output, o, tangents || (i > 0 && space < PathConstraint.Epsilon));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
@ -399,13 +404,14 @@ namespace Spine {
|
||||
|
||||
static void AddCurvePosition (float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2,
|
||||
float[] output, int o, bool tangents) {
|
||||
if (p == 0 || float.IsNaN(p)) p = 0.0001f;
|
||||
if (p < PathConstraint.Epsilon || float.IsNaN(p)) p = PathConstraint.Epsilon;
|
||||
float tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
|
||||
float ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
|
||||
float x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
|
||||
output[o] = x;
|
||||
output[o + 1] = y;
|
||||
if (tangents) output[o + 2] = (float)Math.Atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
|
||||
if (tangents)
|
||||
output[o + 2] = (float)Math.Atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ PathConstraint.__index = PathConstraint
|
||||
PathConstraint.NONE = -1
|
||||
PathConstraint.BEFORE = -2
|
||||
PathConstraint.AFTER = -3
|
||||
PathConstraint.epsilon = 0.00001
|
||||
|
||||
function PathConstraint.new (data, skeleton)
|
||||
if not data then error("data cannot be nil", 2) end
|
||||
@ -118,13 +119,22 @@ function PathConstraint:update ()
|
||||
while i < n do
|
||||
local bone = bones[i + 1];
|
||||
local setupLength = bone.data.length
|
||||
if setupLength == 0 then setupLength = 0.0000001 end
|
||||
local x = setupLength * bone.a
|
||||
local y = setupLength * bone.c
|
||||
local length = math_sqrt(x * x + y * y)
|
||||
if scale then lengths[i + 1] = length end
|
||||
i = i + 1
|
||||
if lengthSpacing then spaces[i + 1] = (setupLength + spacing) * length / setupLength else spaces[i + 1] = spacing * length / setupLength end
|
||||
if setupLength < PathConstraint.epsilon then
|
||||
if scale then lengths[i + 1] = 0 end
|
||||
i = i + 1
|
||||
spaces[i + 1] = 0
|
||||
else
|
||||
local x = setupLength * bone.a
|
||||
local y = setupLength * bone.c
|
||||
local length = math_sqrt(x * x + y * y)
|
||||
if scale then lengths[i + 1] = length end
|
||||
i = i + 1
|
||||
if lengthSpacing then
|
||||
spaces[i + 1] = (setupLength + spacing) * length / setupLength
|
||||
else
|
||||
spaces[i + 1] = spacing * length / setupLength
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
local i = 1
|
||||
|
||||
Binary file not shown.
Binary file not shown.
1
spine-ts/build/spine-all.d.ts
vendored
1
spine-ts/build/spine-all.d.ts
vendored
@ -752,6 +752,7 @@ declare module spine {
|
||||
static NONE: number;
|
||||
static BEFORE: number;
|
||||
static AFTER: number;
|
||||
static epsilon: number;
|
||||
data: PathConstraintData;
|
||||
bones: Array<Bone>;
|
||||
target: Slot;
|
||||
|
||||
@ -3290,13 +3290,18 @@ var spine;
|
||||
for (var i = 0, n = spacesCount - 1; i < n;) {
|
||||
var bone = bones[i];
|
||||
var setupLength = bone.data.length;
|
||||
if (setupLength == 0)
|
||||
setupLength = 0.0000001;
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
if (setupLength < PathConstraint.epsilon) {
|
||||
if (scale)
|
||||
lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
}
|
||||
else {
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3602,6 +3607,7 @@ var spine;
|
||||
PathConstraint.NONE = -1;
|
||||
PathConstraint.BEFORE = -2;
|
||||
PathConstraint.AFTER = -3;
|
||||
PathConstraint.epsilon = 0.00001;
|
||||
return PathConstraint;
|
||||
}());
|
||||
spine.PathConstraint = PathConstraint;
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-canvas.d.ts
vendored
1
spine-ts/build/spine-canvas.d.ts
vendored
@ -752,6 +752,7 @@ declare module spine {
|
||||
static NONE: number;
|
||||
static BEFORE: number;
|
||||
static AFTER: number;
|
||||
static epsilon: number;
|
||||
data: PathConstraintData;
|
||||
bones: Array<Bone>;
|
||||
target: Slot;
|
||||
|
||||
@ -3290,13 +3290,18 @@ var spine;
|
||||
for (var i = 0, n = spacesCount - 1; i < n;) {
|
||||
var bone = bones[i];
|
||||
var setupLength = bone.data.length;
|
||||
if (setupLength == 0)
|
||||
setupLength = 0.0000001;
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
if (setupLength < PathConstraint.epsilon) {
|
||||
if (scale)
|
||||
lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
}
|
||||
else {
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3602,6 +3607,7 @@ var spine;
|
||||
PathConstraint.NONE = -1;
|
||||
PathConstraint.BEFORE = -2;
|
||||
PathConstraint.AFTER = -3;
|
||||
PathConstraint.epsilon = 0.00001;
|
||||
return PathConstraint;
|
||||
}());
|
||||
spine.PathConstraint = PathConstraint;
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-core.d.ts
vendored
1
spine-ts/build/spine-core.d.ts
vendored
@ -681,6 +681,7 @@ declare module spine {
|
||||
static NONE: number;
|
||||
static BEFORE: number;
|
||||
static AFTER: number;
|
||||
static epsilon: number;
|
||||
data: PathConstraintData;
|
||||
bones: Array<Bone>;
|
||||
target: Slot;
|
||||
|
||||
@ -2969,13 +2969,18 @@ var spine;
|
||||
for (var i = 0, n = spacesCount - 1; i < n;) {
|
||||
var bone = bones[i];
|
||||
var setupLength = bone.data.length;
|
||||
if (setupLength == 0)
|
||||
setupLength = 0.0000001;
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
if (setupLength < PathConstraint.epsilon) {
|
||||
if (scale)
|
||||
lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
}
|
||||
else {
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3281,6 +3286,7 @@ var spine;
|
||||
PathConstraint.NONE = -1;
|
||||
PathConstraint.BEFORE = -2;
|
||||
PathConstraint.AFTER = -3;
|
||||
PathConstraint.epsilon = 0.00001;
|
||||
return PathConstraint;
|
||||
}());
|
||||
spine.PathConstraint = PathConstraint;
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-threejs.d.ts
vendored
1
spine-ts/build/spine-threejs.d.ts
vendored
@ -681,6 +681,7 @@ declare module spine {
|
||||
static NONE: number;
|
||||
static BEFORE: number;
|
||||
static AFTER: number;
|
||||
static epsilon: number;
|
||||
data: PathConstraintData;
|
||||
bones: Array<Bone>;
|
||||
target: Slot;
|
||||
|
||||
@ -2969,13 +2969,18 @@ var spine;
|
||||
for (var i = 0, n = spacesCount - 1; i < n;) {
|
||||
var bone = bones[i];
|
||||
var setupLength = bone.data.length;
|
||||
if (setupLength == 0)
|
||||
setupLength = 0.0000001;
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
if (setupLength < PathConstraint.epsilon) {
|
||||
if (scale)
|
||||
lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
}
|
||||
else {
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3281,6 +3286,7 @@ var spine;
|
||||
PathConstraint.NONE = -1;
|
||||
PathConstraint.BEFORE = -2;
|
||||
PathConstraint.AFTER = -3;
|
||||
PathConstraint.epsilon = 0.00001;
|
||||
return PathConstraint;
|
||||
}());
|
||||
spine.PathConstraint = PathConstraint;
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-webgl.d.ts
vendored
1
spine-ts/build/spine-webgl.d.ts
vendored
@ -681,6 +681,7 @@ declare module spine {
|
||||
static NONE: number;
|
||||
static BEFORE: number;
|
||||
static AFTER: number;
|
||||
static epsilon: number;
|
||||
data: PathConstraintData;
|
||||
bones: Array<Bone>;
|
||||
target: Slot;
|
||||
|
||||
@ -2969,13 +2969,18 @@ var spine;
|
||||
for (var i = 0, n = spacesCount - 1; i < n;) {
|
||||
var bone = bones[i];
|
||||
var setupLength = bone.data.length;
|
||||
if (setupLength == 0)
|
||||
setupLength = 0.0000001;
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
if (setupLength < PathConstraint.epsilon) {
|
||||
if (scale)
|
||||
lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
}
|
||||
else {
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3281,6 +3286,7 @@ var spine;
|
||||
PathConstraint.NONE = -1;
|
||||
PathConstraint.BEFORE = -2;
|
||||
PathConstraint.AFTER = -3;
|
||||
PathConstraint.epsilon = 0.00001;
|
||||
return PathConstraint;
|
||||
}());
|
||||
spine.PathConstraint = PathConstraint;
|
||||
|
||||
File diff suppressed because one or more lines are too long
1
spine-ts/build/spine-widget.d.ts
vendored
1
spine-ts/build/spine-widget.d.ts
vendored
@ -681,6 +681,7 @@ declare module spine {
|
||||
static NONE: number;
|
||||
static BEFORE: number;
|
||||
static AFTER: number;
|
||||
static epsilon: number;
|
||||
data: PathConstraintData;
|
||||
bones: Array<Bone>;
|
||||
target: Slot;
|
||||
|
||||
@ -2969,13 +2969,18 @@ var spine;
|
||||
for (var i = 0, n = spacesCount - 1; i < n;) {
|
||||
var bone = bones[i];
|
||||
var setupLength = bone.data.length;
|
||||
if (setupLength == 0)
|
||||
setupLength = 0.0000001;
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
if (setupLength < PathConstraint.epsilon) {
|
||||
if (scale)
|
||||
lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
}
|
||||
else {
|
||||
var x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
var length_1 = Math.sqrt(x * x + y * y);
|
||||
if (scale)
|
||||
lengths[i] = length_1;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length_1 / setupLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -3281,6 +3286,7 @@ var spine;
|
||||
PathConstraint.NONE = -1;
|
||||
PathConstraint.BEFORE = -2;
|
||||
PathConstraint.AFTER = -3;
|
||||
PathConstraint.epsilon = 0.00001;
|
||||
return PathConstraint;
|
||||
}());
|
||||
spine.PathConstraint = PathConstraint;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -31,6 +31,7 @@
|
||||
module spine {
|
||||
export class PathConstraint implements Constraint {
|
||||
static NONE = -1; static BEFORE = -2; static AFTER = -3;
|
||||
static epsilon = 0.00001;
|
||||
|
||||
data: PathConstraintData;
|
||||
bones: Array<Bone>;
|
||||
@ -81,11 +82,15 @@ module spine {
|
||||
for (let i = 0, n = spacesCount - 1; i < n;) {
|
||||
let bone = bones[i];
|
||||
let setupLength = bone.data.length;
|
||||
if (setupLength == 0) setupLength = 0.0000001;
|
||||
let x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
let length = Math.sqrt(x * x + y * y);
|
||||
if (scale) lengths[i] = length;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
if (setupLength < PathConstraint.epsilon) {
|
||||
if (scale) lengths[i] = 0;
|
||||
spaces[++i] = 0;
|
||||
} else {
|
||||
let x = setupLength * bone.a, y = setupLength * bone.c;
|
||||
let length = Math.sqrt(x * x + y * y);
|
||||
if (scale) lengths[i] = length;
|
||||
spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (let i = 1; i < spacesCount; i++)
|
||||
|
||||
@ -230,9 +230,16 @@ namespace Spine.Unity.Editor {
|
||||
EditorApplication.hierarchyWindowItemOnGUI += HierarchyDragAndDrop;
|
||||
|
||||
// Hierarchy Icons
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
EditorApplication.playModeStateChanged -= HierarchyIconsOnPlaymodeStateChanged;
|
||||
EditorApplication.playModeStateChanged += HierarchyIconsOnPlaymodeStateChanged;
|
||||
HierarchyIconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
|
||||
#else
|
||||
EditorApplication.playmodeStateChanged -= HierarchyIconsOnPlaymodeStateChanged;
|
||||
EditorApplication.playmodeStateChanged += HierarchyIconsOnPlaymodeStateChanged;
|
||||
HierarchyIconsOnPlaymodeStateChanged();
|
||||
#endif
|
||||
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
@ -255,7 +262,11 @@ namespace Spine.Unity.Editor {
|
||||
showHierarchyIcons = EditorGUILayout.Toggle(new GUIContent("Show Hierarchy Icons", "Show relevant icons on GameObjects with Spine Components on them. Disable this if you have large, complex scenes."), showHierarchyIcons);
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
EditorPrefs.SetBool(SHOW_HIERARCHY_ICONS_KEY, showHierarchyIcons);
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
HierarchyIconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
|
||||
#else
|
||||
HierarchyIconsOnPlaymodeStateChanged();
|
||||
#endif
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
@ -496,7 +507,11 @@ namespace Spine.Unity.Editor {
|
||||
#endregion
|
||||
|
||||
#region Hierarchy
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
static void HierarchyIconsOnPlaymodeStateChanged (PlayModeStateChange stateChange) {
|
||||
#else
|
||||
static void HierarchyIconsOnPlaymodeStateChanged () {
|
||||
#endif
|
||||
skeletonRendererTable.Clear();
|
||||
skeletonUtilityBoneTable.Clear();
|
||||
boundingBoxFollowerTable.Clear();
|
||||
|
||||
@ -113,37 +113,37 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
||||
#region Runtime RegionAttachments
|
||||
/// <summary>
|
||||
/// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses a new AtlasPage with the Material provided./// </summary>
|
||||
public static RegionAttachment ToRegionAttachment (this Sprite sprite, Material material) {
|
||||
return sprite.ToRegionAttachment(material.ToSpineAtlasPage());
|
||||
public static RegionAttachment ToRegionAttachment (this Sprite sprite, Material material, float rotation = 0f) {
|
||||
return sprite.ToRegionAttachment(material.ToSpineAtlasPage(), rotation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a RegionAttachment based on a sprite. This method creates a real, usable AtlasRegion. That AtlasRegion uses the AtlasPage provided./// </summary>
|
||||
public static RegionAttachment ToRegionAttachment (this Sprite sprite, AtlasPage page) {
|
||||
public static RegionAttachment ToRegionAttachment (this Sprite sprite, AtlasPage page, float rotation = 0f) {
|
||||
if (sprite == null) throw new System.ArgumentNullException("sprite");
|
||||
if (page == null) throw new System.ArgumentNullException("page");
|
||||
var region = sprite.ToAtlasRegion(page);
|
||||
var unitsPerPixel = 1f / sprite.pixelsPerUnit;
|
||||
return region.ToRegionAttachment(sprite.name, unitsPerPixel);
|
||||
return region.ToRegionAttachment(sprite.name, unitsPerPixel, rotation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Spine.AtlasRegion that uses a premultiplied alpha duplicate texture of the Sprite's texture data. Returns a RegionAttachment that uses it. Use this if you plan to use a premultiply alpha shader such as "Spine/Skeleton"</summary>
|
||||
public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Shader shader, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps, Material materialPropertySource = null) {
|
||||
public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Shader shader, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps, Material materialPropertySource = null, float rotation = 0f) {
|
||||
if (sprite == null) throw new System.ArgumentNullException("sprite");
|
||||
if (shader == null) throw new System.ArgumentNullException("shader");
|
||||
var region = sprite.ToAtlasRegionPMAClone(shader, textureFormat, mipmaps, materialPropertySource);
|
||||
var unitsPerPixel = 1f / sprite.pixelsPerUnit;
|
||||
return region.ToRegionAttachment(sprite.name, unitsPerPixel);
|
||||
return region.ToRegionAttachment(sprite.name, unitsPerPixel, rotation);
|
||||
}
|
||||
|
||||
public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Material materialPropertySource, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps) {
|
||||
return sprite.ToRegionAttachmentPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource);
|
||||
public static RegionAttachment ToRegionAttachmentPMAClone (this Sprite sprite, Material materialPropertySource, TextureFormat textureFormat = AtlasUtilities.SpineTextureFormat, bool mipmaps = AtlasUtilities.UseMipMaps, float rotation = 0f) {
|
||||
return sprite.ToRegionAttachmentPMAClone(materialPropertySource.shader, textureFormat, mipmaps, materialPropertySource, rotation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new RegionAttachment from a given AtlasRegion.</summary>
|
||||
public static RegionAttachment ToRegionAttachment (this AtlasRegion region, string attachmentName, float scale = 0.01f) {
|
||||
public static RegionAttachment ToRegionAttachment (this AtlasRegion region, string attachmentName, float scale = 0.01f, float rotation = 0f) {
|
||||
if (string.IsNullOrEmpty(attachmentName)) throw new System.ArgumentException("attachmentName can't be null or empty.", "attachmentName");
|
||||
if (region == null) throw new System.ArgumentNullException("region");
|
||||
|
||||
@ -162,14 +162,13 @@ namespace Spine.Unity.Modules.AttachmentTools {
|
||||
attachment.Path = region.name;
|
||||
attachment.scaleX = 1;
|
||||
attachment.scaleY = 1;
|
||||
attachment.rotation = 0;
|
||||
attachment.rotation = rotation;
|
||||
|
||||
attachment.r = 1;
|
||||
attachment.g = 1;
|
||||
attachment.b = 1;
|
||||
attachment.a = 1;
|
||||
|
||||
|
||||
// pass OriginalWidth and OriginalHeight because UpdateOffset uses it in its calculation.
|
||||
attachment.width = attachment.regionOriginalWidth * scale;
|
||||
attachment.height = attachment.regionOriginalHeight * scale;
|
||||
|
||||
@ -344,8 +344,8 @@ VertexOutput vert(VertexInput input)
|
||||
output.pos = calculateLocalPos(input.vertex);
|
||||
output.color = calculateVertexColor(input.color);
|
||||
output.texcoord = float3(calculateTextureCoord(input.texcoord), 0);
|
||||
|
||||
float3 viewPos = mul(UNITY_MATRIX_MV, input.vertex);
|
||||
|
||||
float3 viewPos = UnityObjectViewPos(input.vertex); //float3 viewPos = mul(UNITY_MATRIX_MV, input.vertex);
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING) || defined(_RIM_LIGHTING)
|
||||
float4 powWorld = calculateWorldPos(input.vertex);
|
||||
#endif
|
||||
|
||||
@ -110,9 +110,9 @@ Shader "Spine/SkeletonGraphic Tint Black (Premultiply Alpha)"
|
||||
clip (texColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
return (texColor * IN.color) + float4(((1-texColor.rgb) * (_Black.rgb + float3(IN.uv1.r, IN.uv1.g, IN.uv2.r)) * texColor.a*_Color.a*i.vertexColor.a), 0);
|
||||
return (texColor * IN.color) + float4(((1-texColor.rgb) * (_Black.rgb + float3(IN.uv1.r, IN.uv1.g, IN.uv2.r)) * texColor.a * _Color.a * IN.color.a), 0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user