Skip to content

Commit

Permalink
Merge branch '4.2' into spine-android
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Jul 17, 2024
2 parents ff32e3e + 3e8c9df commit e2bdecd
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 64 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@

### Unity

- **Officially supported Unity versions are 2017.1-2022.1**.
- **Officially supported Unity versions are 2017.1-2023.1**.

- **Additions**

Expand Down Expand Up @@ -161,6 +161,7 @@
- Added support for BlendModeMaterials at runtime instantiation from files via an additional method `SkeletonDataAsset.SetupRuntimeBlendModeMaterials`. See example scene `Spine Examples/Other Examples/Instantiate from Script` for a usage example.
- SkeletonGraphic: You can now offset the skeleton mesh relative to the pivot via a newly added green circle handle. This allows you to e.g. frame only the face of a skeleton inside a masked frame. Previously offsetting the pivot downwards fails when `Layout Scale Mode` scales the mesh smaller and towards the pivot (e.g. the feet) and thus out of the frame. Now you can keep the pivot in the center of the `RectTransform` while offsetting only the mesh downwards, keeping the desired skeleton area (e.g. the face) centered while resizing. Moving the new larger green circle handle moves the mesh offset, while moving the blue pivot circle handle moves the pivot as usual.
- `Universal Render Pipeline/Spine/Skeleton` shader now performs proper alpha-testing when `Depth Write` is enabled, using the existing `Shadow alpha cutoff` parameter.
- `SkeletonRootMotion` components now provide a public `Initialize()` method which is automatically called when calling `skeletonAnimation.Initialize(true)` to update the necessary skeleton references. If a different root bone shall be used, be sure to set `skeletonRootMotion.rootMotionBoneName` before calling `skeletonAnimation.Initialize(true)`.

- **Breaking changes**

Expand All @@ -173,6 +174,7 @@
- Inspector: String attribute `SpineSkin()` now allows to include `<None>` in the list of parameters. Previously the `includeNone=true` parameter of the `SpineSkin()` attribute defaulted to `true` but was ignored. Now it defaults to `false` and has an effect on the list. Only the Inspector GUI is affected by this behaviour change.
- `SkeletonGraphicRenderTexture` example component: `protected RawImage quadRawImage` was changed to `protected SkeletonSubmeshGraphic quadMaskableGraphic` for a bugfix. This is only relevant for subclasses of `SkeletonGraphicRenderTexture` or when querying the `RawImage` component via e.g. `skeletonGraphicRenderTexture.quad.GetComponent<RawImage>()`.
- Fixed a bug where when Linear color space is used and `PMA vertex colors` enabled, additive slots add a too dark (too transparent) color value. If you want the old incorrect behaviour (darker additive slots) or are not using Linear but Gamma color space, you can comment-out the define `LINEAR_COLOR_SPACE_FIX_ADDITIVE_ALPHA` in `MeshGenerator.cs` to deactivate the fix or just to skip unnecessary instructions.
- Fixed SkeletonRootMotion components ignoring parent bone scale when set by transform constraints. Using applied scale of parent bone now. If you need the old behaviour, comment out the line `#define USE_APPLIED_PARENT_SCALE` in SkeletonRootMotionBase.cs.

- **Changes of default values**

Expand Down
38 changes: 21 additions & 17 deletions spine-csharp/src/PhysicsConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public void Update (Physics physics) {
Reset();
goto case Physics.Update; // Fall through.
case Physics.Update:
Skeleton skeleton = this.skeleton;
float delta = Math.Max(skeleton.time - lastTime, 0);
remaining += delta;
lastTime = skeleton.time;
Expand All @@ -157,21 +158,24 @@ public void Update (Physics physics) {
ux = bx;
uy = by;
} else {
float a = this.remaining, i = inertia, q = data.limit * delta, t = data.step, f = skeleton.data.referenceScale;
float a = remaining, i = inertia, t = data.step, f = skeleton.data.referenceScale, d = -1;
float qx = data.limit * delta, qy = qx * Math.Abs(skeleton.ScaleY);
qx *= Math.Abs(skeleton.ScaleX);

if (x || y) {
if (x) {
float u = (ux - bx) * i;
xOffset += u > q ? q : u < -q ? -q : u;
xOffset += u > qx ? qx : u < -qx ? -qx : u;
ux = bx;
}
if (y) {
float u = (uy - by) * i;
yOffset += u > q ? q : u < -q ? -q : u;
yOffset += u > qy ? qy : u < -qy ? -qy : u;
uy = by;
}
if (a >= t) {
d = (float)Math.Pow(damping, 60 * t);
float m = massInverse * t, e = strength, w = wind * f, g = (Bone.yDown ? -gravity : gravity) * f;
float d = (float)Math.Pow(damping, 60 * t);
do {
if (x) {
xVelocity += (w - xOffset * e) * m;
Expand All @@ -192,14 +196,14 @@ public void Update (Physics physics) {
if (rotateOrShearX || scaleX) {
float ca = (float)Math.Atan2(bone.c, bone.a), c, s, mr = 0;
float dx = cx - bone.worldX, dy = cy - bone.worldY;
if (dx > q)
dx = q;
else if (dx < -q)
dx = -q;
if (dy > q)
dy = q;
else if (dy < -q)
dy = -q;
if (dx > qx)
dx = qx;
else if (dx < -qx)
dx = -qx;
if (dy > qy)
dy = qy;
else if (dy < -qy)
dy = -qy;
if (rotateOrShearX) {
mr = (data.rotate + data.shearX) * mix;
float r = (float)Math.Atan2(dy + ty, dx + tx) - ca - rotateOffset * mr;
Expand All @@ -217,10 +221,10 @@ public void Update (Physics physics) {
float r = l * bone.WorldScaleX;
if (r > 0) scaleOffset += (dx * c + dy * s) * i / r;
}
a = this.remaining;
a = remaining;
if (a >= t) {
float m = massInverse * t, e = strength, w = wind, g = (Bone.yDown ? -gravity : gravity);
float d = (float)Math.Pow(damping, 60 * t), h = l / f;
if (d == -1) d = (float)Math.Pow(damping, 60 * t);
float m = massInverse * t, e = strength, w = wind, g = (Bone.yDown ? -gravity : gravity), h = l / f;
while (true) {
a -= t;
if (scaleX) {
Expand All @@ -241,7 +245,7 @@ public void Update (Physics physics) {
}
}
}
this.remaining = a;
remaining = a;
}
cx = bone.worldX;
cy = bone.worldY;
Expand Down Expand Up @@ -295,7 +299,7 @@ public void Update (Physics physics) {
}

/// <summary>The bone constrained by this physics constraint.</summary>
public Bone Bone { get {return bone;} set { bone = value; } }
public Bone Bone { get { return bone; } set { bone = value; } }
public float Inertia { get { return inertia; } set { inertia = value; } }
public float Strength { get { return strength; } set { strength = value; } }
public float Damping { get { return damping; } set { damping = value; } }
Expand Down
2 changes: 1 addition & 1 deletion spine-csharp/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-csharp",
"displayName": "spine-csharp Runtime",
"description": "This plugin provides the spine-csharp core runtime.",
"version": "4.2.25",
"version": "4.2.27",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",
Expand Down
31 changes: 17 additions & 14 deletions spine-haxe/spine-haxe/spine/PhysicsConstraint.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ package spine;
class PhysicsConstraint implements Updatable {
private var _data:PhysicsConstraintData;
private var _bone:Bone = null;

public var inertia:Float = 0;
public var strength:Float = 0;
public var damping:Float = 0;
Expand Down Expand Up @@ -63,7 +63,7 @@ class PhysicsConstraint implements Updatable {
private var _skeleton:Skeleton;
public var remaining:Float = 0;
public var lastTime:Float = 0;

public function new(data: PhysicsConstraintData, skeleton: Skeleton) {
_data = data;
_skeleton = skeleton;
Expand Down Expand Up @@ -123,7 +123,7 @@ class PhysicsConstraint implements Updatable {
return;
case Physics.reset, Physics.update:
if (physics == Physics.reset) reset();

var delta:Float = Math.max(skeleton.time - lastTime, 0);
remaining += delta;
lastTime = _skeleton.time;
Expand All @@ -136,19 +136,22 @@ class PhysicsConstraint implements Updatable {
} else {
var a:Float = remaining,
i:Float = inertia,
q:Float = _data.limit * delta,
t:Float = _data.step,
f:Float = skeleton.data.referenceScale,
d:Float = -1;

var qx:Float = _data.limit * delta,
qy:Float = qx * Math.abs(skeleton.scaleY);
qx *= Math.abs(skeleton.scaleX);
if (x || y) {
if (x) {
var u:Float = (ux - bx) * i;
xOffset += u > q ? q : u < -q ? -q : u;
xOffset += u > qx ? qx : u < -qx ? -qx : u;
ux = bx;
}
if (y) {
var u:Float = (uy - by) * i;
yOffset += u > q ? q : u < -q ? -q : u;
yOffset += u > qy ? qy : u < -qy ? -qy : u;
uy = by;
}
if (a >= t) {
Expand Down Expand Up @@ -181,14 +184,14 @@ class PhysicsConstraint implements Updatable {
mr:Float = 0;
var dx:Float = cx - bone.worldX,
dy:Float = cy - bone.worldY;
if (dx > q)
dx = q;
else if (dx < -q) //
dx = -q;
if (dy > q)
dy = q;
else if (dy < -q) //
dy = -q;
if (dx > qx)
dx = qx;
else if (dx < -qx) //
dx = -qx;
if (dy > qy)
dy = qy;
else if (dy < -qy) //
dy = -qy;
if (rotateOrShearX) {
mr = (_data.rotate + _data.shearX) * mix;
var r:Float = Math.atan2(dy + ty, dx + tx) - ca - rotateOffset * mr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public void update (Physics physics) {
reset();
// Fall through.
case update:
Skeleton skeleton = this.skeleton;
float delta = Math.max(skeleton.time - lastTime, 0);
remaining += delta;
lastTime = skeleton.time;
Expand All @@ -151,16 +152,18 @@ public void update (Physics physics) {
ux = bx;
uy = by;
} else {
float a = remaining, i = inertia, q = data.limit * delta, t = data.step, f = skeleton.data.referenceScale, d = -1;
float a = remaining, i = inertia, t = data.step, f = skeleton.data.referenceScale, d = -1;
float qx = data.limit * delta, qy = qx * Math.abs(skeleton.scaleY);
qx *= Math.abs(skeleton.scaleX);
if (x || y) {
if (x) {
float u = (ux - bx) * i;
xOffset += u > q ? q : u < -q ? -q : u;
xOffset += u > qx ? qx : u < -qx ? -qx : u;
ux = bx;
}
if (y) {
float u = (uy - by) * i;
yOffset += u > q ? q : u < -q ? -q : u;
yOffset += u > qy ? qy : u < -qy ? -qy : u;
uy = by;
}
if (a >= t) {
Expand All @@ -186,14 +189,14 @@ public void update (Physics physics) {
if (rotateOrShearX || scaleX) {
float ca = atan2(bone.c, bone.a), c, s, mr = 0;
float dx = cx - bone.worldX, dy = cy - bone.worldY;
if (dx > q)
dx = q;
else if (dx < -q) //
dx = -q;
if (dy > q)
dy = q;
else if (dy < -q) //
dy = -q;
if (dx > qx)
dx = qx;
else if (dx < -qx) //
dx = -qx;
if (dy > qy)
dy = qy;
else if (dy < -qy) //
dy = -qy;
if (rotateOrShearX) {
mr = (data.rotate + data.shearX) * mix;
float r = atan2(dy + ty, dx + tx) - ca - rotateOffset * mr;
Expand Down
27 changes: 15 additions & 12 deletions spine-ts/spine-core/src/PhysicsConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,29 @@ export class PhysicsConstraint implements Updatable {
this.reset();
// Fall through.
case Physics.update:
const skeleton = this.skeleton;
const delta = Math.max(this.skeleton.time - this.lastTime, 0);
this.remaining += delta;
this.lastTime = this.skeleton.time;
this.lastTime = skeleton.time;

const bx = bone.worldX, by = bone.worldY;
if (this._reset) {
this._reset = false;
this.ux = bx;
this.uy = by;
} else {
let a = this.remaining, i = this.inertia, q = this.data.limit * delta, t = this.data.step, f = this.skeleton.data.referenceScale, d = -1;
let a = this.remaining, i = this.inertia, t = this.data.step, f = this.skeleton.data.referenceScale, d = -1;
let qx = this.data.limit * delta, qy = qx * Math.abs(skeleton.scaleY);
qx *= Math.abs(skeleton.scaleX);
if (x || y) {
if (x) {
const u = (this.ux - bx) * i;
this.xOffset += u > q ? q : u < -q ? -q : u;
this.xOffset += u > qx ? qx : u < -qx ? -qx : u;
this.ux = bx;
}
if (y) {
const u = (this.uy - by) * i;
this.yOffset += u > q ? q : u < -q ? -q : u;
this.yOffset += u > qy ? qy : u < -qy ? -qy : u;
this.uy = by;
}
if (a >= t) {
Expand All @@ -181,14 +184,14 @@ export class PhysicsConstraint implements Updatable {
if (rotateOrShearX || scaleX) {
let ca = Math.atan2(bone.c, bone.a), c = 0, s = 0, mr = 0;
let dx = this.cx - bone.worldX, dy = this.cy - bone.worldY;
if (dx > q)
dx = q;
else if (dx < -q) //
dx = -q;
if (dy > q)
dy = q;
else if (dy < -q) //
dy = -q;
if (dx > qx)
dx = qx;
else if (dx < -qx) //
dx = -qx;
if (dy > qy)
dy = qy;
else if (dy < -qy) //
dy = -qy;
if (rotateOrShearX) {
mr = (this.data.rotate + this.data.shearX) * mix;
let r = Math.atan2(dy + this.ty, dx + this.tx) - ca - this.rotateOffset * mr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ protected override void Reset () {
mecanimLayerFlags = DefaultMecanimLayerFlags;
}

protected override void Start () {
base.Start();
public override void Initialize () {
base.Initialize();
skeletonMecanim = GetComponent<SkeletonMecanim>();
if (skeletonMecanim) {
skeletonMecanim.Translator.OnClipApplied -= OnClipApplied;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ protected override void Reset () {
animationTrackFlags = DefaultAnimationTrackFlags;
}

protected override void Start () {
base.Start();
public override void Initialize () {
base.Initialize();
IAnimationStateComponent animstateComponent = skeletonComponent as IAnimationStateComponent;
this.animationState = (animstateComponent != null) ? animstateComponent.AnimationState : null;

Expand Down
Loading

0 comments on commit e2bdecd

Please sign in to comment.