Merge branch '3.8' into 3.9-beta

This commit is contained in:
Harald Csaszar 2020-05-20 16:48:55 +02:00
commit 69f78b03e1
24 changed files with 112 additions and 30 deletions

View File

@ -121,6 +121,8 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
float prx, rx, ry, la, lb, lc, ld;
if (s > 0.0001f) {
s = ABS(pa * pd - pb * pc) / s;
pa /= self->skeleton->scaleX;
pc /= self->skeleton->scaleY;
pb = pc * s;
pd = pa * s;
prx = ATAN2(pc, pa) * RAD_DEG;
@ -139,7 +141,7 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
CONST_CAST(float, self->b) = pa * lb - pb * ld;
CONST_CAST(float, self->c) = pc * la + pd * lc;
CONST_CAST(float, self->d) = pc * lb + pd * ld;
return;
break;
}
case SP_TRANSFORMMODE_NOSCALE:
case SP_TRANSFORMMODE_NOSCALEORREFLECTION: {

View File

@ -150,6 +150,8 @@ void Bone::updateWorldTransform(float x, float y, float rotation, float scaleX,
float prx, rx, ry, la, lb, lc, ld;
if (s > 0.0001f) {
s = MathUtil::abs(pa * pd - pb * pc) / s;
pa /= _skeleton.getScaleX();
pc /= _skeleton.getScaleY();
pb = pc * s;
pd = pa * s;
prx = MathUtil::atan2(pc, pa) * MathUtil::Rad_Deg;
@ -168,7 +170,7 @@ void Bone::updateWorldTransform(float x, float y, float rotation, float scaleX,
_b = pa * lb - pb * ld;
_c = pc * la + pd * lc;
_d = pc * lb + pd * ld;
return;
break;
}
case TransformMode_NoScale:
case TransformMode_NoScaleOrReflection: {

View File

@ -189,6 +189,8 @@ namespace Spine {
float s = pa * pa + pc * pc, prx;
if (s > 0.0001f) {
s = Math.Abs(pa * pd - pb * pc) / s;
pa /= skeleton.ScaleX;
pc /= skeleton.ScaleY;
pb = pc * s;
pd = pa * s;
prx = MathUtils.Atan2(pc, pa) * MathUtils.RadDeg;
@ -207,7 +209,7 @@ namespace Spine {
b = pa * lb - pb * ld;
c = pc * la + pd * lc;
d = pc * lb + pd * ld;
return;
break;
}
case TransformMode.NoScale:
case TransformMode.NoScaleOrReflection: {

View File

@ -150,6 +150,8 @@ public class Bone implements Updatable {
float s = pa * pa + pc * pc, prx;
if (s > 0.0001f) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= skeleton.scaleX;
pc /= skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = atan2(pc, pa) * radDeg;
@ -168,7 +170,7 @@ public class Bone implements Updatable {
b = pa * lb - pb * ld;
c = pc * la + pd * lc;
d = pc * lb + pd * ld;
return;
break;
}
case noScale:
case noScaleOrReflection: {

View File

@ -2564,6 +2564,8 @@ var spine;
var prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= this.skeleton.scaleX;
pc /= this.skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
@ -2583,7 +2585,7 @@ var spine;
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
break;
}
case spine.TransformMode.NoScale:
case spine.TransformMode.NoScaleOrReflection: {

File diff suppressed because one or more lines are too long

View File

@ -2564,6 +2564,8 @@ var spine;
var prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= this.skeleton.scaleX;
pc /= this.skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
@ -2583,7 +2585,7 @@ var spine;
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
break;
}
case spine.TransformMode.NoScale:
case spine.TransformMode.NoScaleOrReflection: {

File diff suppressed because one or more lines are too long

View File

@ -2564,6 +2564,8 @@ var spine;
var prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= this.skeleton.scaleX;
pc /= this.skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
@ -2583,7 +2585,7 @@ var spine;
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
break;
}
case spine.TransformMode.NoScale:
case spine.TransformMode.NoScaleOrReflection: {

File diff suppressed because one or more lines are too long

View File

@ -2564,6 +2564,8 @@ var spine;
var prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= this.skeleton.scaleX;
pc /= this.skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
@ -2583,7 +2585,7 @@ var spine;
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
break;
}
case spine.TransformMode.NoScale:
case spine.TransformMode.NoScaleOrReflection: {

File diff suppressed because one or more lines are too long

View File

@ -2564,6 +2564,8 @@ var spine;
var prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= this.skeleton.scaleX;
pc /= this.skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
@ -2583,7 +2585,7 @@ var spine;
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
break;
}
case spine.TransformMode.NoScale:
case spine.TransformMode.NoScaleOrReflection: {

File diff suppressed because one or more lines are too long

View File

@ -2564,6 +2564,8 @@ var spine;
var prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= this.skeleton.scaleX;
pc /= this.skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * spine.MathUtils.radDeg;
@ -2583,7 +2585,7 @@ var spine;
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
break;
}
case spine.TransformMode.NoScale:
case spine.TransformMode.NoScaleOrReflection: {

File diff suppressed because one or more lines are too long

View File

@ -201,6 +201,8 @@ module spine {
let prx = 0;
if (s > 0.0001) {
s = Math.abs(pa * pd - pb * pc) / s;
pa /= this.skeleton.scaleX;
pc /= this.skeleton.scaleY;
pb = pc * s;
pd = pa * s;
prx = Math.atan2(pc, pa) * MathUtils.radDeg;
@ -219,7 +221,7 @@ module spine {
this.b = pa * lb - pb * ld;
this.c = pc * la + pd * lc;
this.d = pc * lb + pd * ld;
return;
break;
}
case TransformMode.NoScale:
case TransformMode.NoScaleOrReflection: {

View File

@ -73,6 +73,11 @@ namespace Spine.Unity.Examples {
collectedSkin.AddSkin(equipsSkin);
// 2. Create a repacked skin.
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
if (runtimeMaterial)
Destroy(runtimeMaterial);
if (runtimeAtlas)
Destroy(runtimeAtlas);
var repackedSkin = collectedSkin.GetRepackedSkin("Repacked skin", skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial, out runtimeMaterial, out runtimeAtlas);
collectedSkin.Clear();

View File

@ -121,6 +121,11 @@ namespace Spine.Unity.Examples {
var repackedSkin = new Skin("repacked skin");
repackedSkin.AddSkin(skeleton.Data.DefaultSkin); // Include the "default" skin. (everything outside of skin placeholders)
repackedSkin.AddSkin(customSkin); // Include your new custom skin.
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
if (runtimeMaterial)
Destroy(runtimeMaterial);
if (runtimeAtlas)
Destroy(runtimeAtlas);
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas); // Pack all the items in the skin.
skeleton.SetSkin(repackedSkin); // Assign the repacked skin to your Skeleton.
if (bbFollower != null) bbFollower.Initialize(true);

View File

@ -119,6 +119,11 @@ namespace Spine.Unity.Examples {
var repackedSkin = new Skin("repacked skin");
repackedSkin.AddSkin(skeleton.Data.DefaultSkin);
repackedSkin.AddSkin(customSkin);
// Note: materials and textures returned by GetRepackedSkin() behave like 'new Texture2D()' and need to be destroyed
if (runtimeMaterial)
Destroy(runtimeMaterial);
if (runtimeAtlas)
Destroy(runtimeAtlas);
repackedSkin = repackedSkin.GetRepackedSkin("repacked skin", sourceMaterial, out runtimeMaterial, out runtimeAtlas);
skeleton.SetSkin(repackedSkin);
} else {

View File

@ -68,6 +68,7 @@ namespace Spine.Unity.Examples {
public int colliderLayer = 0;
[Range(0, 1)]
public float mix = 1;
public bool oldRagdollBehaviour = true;
#endregion
ISkeletonAnimation targetSkeletonComponent;
@ -322,6 +323,12 @@ namespace Spine.Unity.Examples {
var t = pair.Value;
bool isStartingBone = b == StartingBone;
Transform parentTransform = isStartingBone ? ragdollRoot : boneTable[b.Parent];
if (!oldRagdollBehaviour && isStartingBone) {
if (b != skeleton.RootBone) { // RagdollRoot is not skeleton root.
ragdollRoot.localPosition = new Vector3(b.Parent.WorldX, b.Parent.WorldY, 0);
ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetPropagatedRotation(b.Parent));
}
}
Vector3 parentTransformWorldPosition = parentTransform.position;
Quaternion parentTransformWorldRotation = parentTransform.rotation;

View File

@ -71,6 +71,7 @@ namespace Spine.Unity.Examples {
public int colliderLayer = 0;
[Range(0, 1)]
public float mix = 1;
public bool oldRagdollBehaviour = true;
#endregion
ISkeletonAnimation targetSkeletonComponent;
@ -338,6 +339,13 @@ namespace Spine.Unity.Examples {
var t = pair.Value;
bool isStartingBone = (b == startingBone);
Transform parentTransform = isStartingBone ? ragdollRoot : boneTable[b.Parent];
if (!oldRagdollBehaviour && isStartingBone) {
if (b != skeleton.RootBone) { // RagdollRoot is not skeleton root.
ragdollRoot.localPosition = new Vector3(b.Parent.WorldX, b.Parent.WorldY, 0);
ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetPropagatedRotation(b.Parent));
}
}
Vector3 parentTransformWorldPosition = parentTransform.position;
Quaternion parentTransformWorldRotation = parentTransform.rotation;

View File

@ -213,14 +213,18 @@ namespace Spine.Unity {
for (int c = 0; c < clipInfoCount; c++) {
var info = clipInfo[c];
float weight = info.weight * layerWeight; if (weight == 0) continue;
previousAnimations.Add(GetAnimation(info.clip));
var clip = GetAnimation(info.clip);
if (clip != null)
previousAnimations.Add(clip);
}
if (hasNext) {
for (int c = 0; c < nextClipInfoCount; c++) {
var info = nextClipInfo[c];
float weight = info.weight * layerWeight; if (weight == 0) continue;
previousAnimations.Add(GetAnimation(info.clip));
var clip = GetAnimation(info.clip);
if (clip != null)
previousAnimations.Add(clip);
}
}
@ -230,7 +234,9 @@ namespace Spine.Unity {
var info = interruptingClipInfo[c];
float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
float weight = clipWeight * layerWeight; if (weight == 0) continue;
previousAnimations.Add(GetAnimation(info.clip));
var clip = GetAnimation(info.clip);
if (clip != null)
previousAnimations.Add(clip);
}
}
}
@ -261,12 +267,16 @@ namespace Spine.Unity {
// Always use Mix instead of Applying the first non-zero weighted clip.
for (int c = 0; c < clipInfoCount; c++) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
}
if (hasNext) {
for (int c = 0; c < nextClipInfoCount; c++) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
}
}
if (isInterruptionActive) {
@ -275,7 +285,9 @@ namespace Spine.Unity {
var info = interruptingClipInfo[c];
float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
float weight = clipWeight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0),
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0),
interruptingStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
}
}
@ -284,13 +296,17 @@ namespace Spine.Unity {
int c = 0;
for (; c < clipInfoCount; c++) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
++c; break;
}
// Mix the rest
for (; c < clipInfoCount; c++) {
var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
}
c = 0;
@ -299,14 +315,18 @@ namespace Spine.Unity {
if (mode == MixMode.Hard) {
for (; c < nextClipInfoCount; c++) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
++c; break;
}
}
// Mix the rest
for (; c < nextClipInfoCount; c++) {
var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
}
}
@ -318,7 +338,9 @@ namespace Spine.Unity {
var info = interruptingClipInfo[c];
float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
float weight = clipWeight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
++c; break;
}
}
@ -327,7 +349,9 @@ namespace Spine.Unity {
var info = interruptingClipInfo[c];
float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
float weight = clipWeight * layerWeight; if (weight == 0) continue;
GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
var clip = GetAnimation(info.clip);
if (clip != null)
clip.Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
}
}
}

View File

@ -219,6 +219,8 @@ namespace Spine.Unity.AttachmentTools {
/// <summary>
/// Fills the outputAttachments list with new attachment objects based on the attachments in sourceAttachments,
/// but mapped to a new single texture using the same material.</summary>
/// <remarks>Returned <c>Material</c> and <c>Texture</c> behave like <c>new Texture2D()</c>, thus you need to call <c>Destroy()</c>
/// to free resources.</remarks>
/// <param name="sourceAttachments">The list of attachments to be repacked.</param>
/// <param name = "outputAttachments">The List(Attachment) to populate with the newly created Attachment objects.
/// May be equal to <c>sourceAttachments</c> for in-place operation.</param>
@ -257,6 +259,8 @@ namespace Spine.Unity.AttachmentTools {
/// <summary>
/// Fills the outputAttachments list with new attachment objects based on the attachments in sourceAttachments,
/// but mapped to a new single texture using the same material.</summary>
/// <remarks>Returned <c>Material</c> and <c>Texture</c> behave like <c>new Texture2D()</c>, thus you need to call <c>Destroy()</c>
/// to free resources.</remarks>
/// <param name="sourceAttachments">The list of attachments to be repacked.</param>
/// <param name = "outputAttachments">The List(Attachment) to populate with the newly created Attachment objects.
/// May be equal to <c>sourceAttachments</c> for in-place operation.</param>
@ -413,7 +417,9 @@ namespace Spine.Unity.AttachmentTools {
/// Creates and populates a duplicate skin with cloned attachments that are backed by a new packed texture atlas
/// comprised of all the regions from the original skin.</summary>
/// <remarks>GetRepackedSkin is an expensive operation, preferably call it at level load time.
/// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.</remarks>
/// No Spine.Atlas object is created so there is no way to find AtlasRegions except through the Attachments using them.
/// Returned <c>Material</c> and <c>Texture</c> behave like <c>new Texture2D()</c>, thus you need to call <c>Destroy()</c>
/// to free resources.</remarks>
/// <param name="additionalTexturePropertyIDsToCopy">Optional additional textures (such as normal maps) to copy while repacking.
/// To copy e.g. the main texture and normal maps, pass 'new int[] { Shader.PropertyToID("_BumpMap") }' at this parameter.</param>
/// <param name="additionalOutputTextures">When <c>additionalTexturePropertyIDsToCopy</c> is non-null,