Merge branch '4.1' into 4.2-beta

This commit is contained in:
Harald Csaszar 2023-07-11 13:27:32 +02:00
commit 74819b6c59
10 changed files with 55 additions and 27 deletions

View File

@ -37,7 +37,7 @@
}
function create() {
const mixAndMatch = this.add.spine(400, 500, 'mix-and-match-data', "mix-and-match-atlas");
const mixAndMatch = this.add.spine(400, 500, 'mix-and-match-data', "mix-and-match-atlas", new spine.SkinsAndAnimationBoundsProvider(null, ["full-skins/girl"]));
mixAndMatch.scale = 0.5;
mixAndMatch.animationState.setAnimation(0, "walk", true);

View File

@ -25,7 +25,8 @@ export class SetupPoseBoundsProvider implements SpineGameObjectBoundsProvider {
const skeleton = new Skeleton(gameObject.skeleton.data);
skeleton.setToSetupPose();
skeleton.updateWorldTransform();
return skeleton.getBoundsRect();
const bounds = skeleton.getBoundsRect();
return bounds.width == Number.NEGATIVE_INFINITY ? { x: 0, y: 0, width: 0, height: 0 } : bounds;
}
}
@ -36,7 +37,7 @@ export class SkinsAndAnimationBoundsProvider implements SpineGameObjectBoundsPro
* @param skins The skins to use for calculating the bounds. If empty, the default skin is used.
* @param timeStep The time step to use for calculating the bounds. A smaller time step means more precision, but slower calculation.
*/
constructor (private animation: string, private skins: string[] = [], private timeStep: number = 0.05) {
constructor (private animation: string | null, private skins: string[] = [], private timeStep: number = 0.05) {
}
calculateBounds (gameObject: SpineGameObject): { x: number; y: number; width: number; height: number; } {
@ -61,7 +62,8 @@ export class SkinsAndAnimationBoundsProvider implements SpineGameObjectBoundsPro
const animation = this.animation != null ? data.findAnimation(this.animation!) : null;
if (animation == null) {
skeleton.updateWorldTransform();
return skeleton.getBoundsRect();
const bounds = skeleton.getBoundsRect();
return bounds.width == Number.NEGATIVE_INFINITY ? { x: 0, y: 0, width: 0, height: 0 } : bounds;
} else {
let minX = Number.POSITIVE_INFINITY, minY = Number.POSITIVE_INFINITY, maxX = Number.NEGATIVE_INFINITY, maxY = Number.NEGATIVE_INFINITY;
animationState.clearTracks();
@ -78,7 +80,8 @@ export class SkinsAndAnimationBoundsProvider implements SpineGameObjectBoundsPro
maxX = Math.max(maxX, minX + bounds.width);
maxY = Math.max(maxY, minY + bounds.height);
}
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
const bounds = { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
return bounds.width == Number.NEGATIVE_INFINITY ? { x: 0, y: 0, width: 0, height: 0 } : bounds;
}
}
}

View File

@ -27,6 +27,10 @@
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#if UNITY_2019_1_OR_NEWER
#define SPEED_INCLUDED_IN_CLIP_TIME
#endif
#define SPINE_EDITMODEPOSE
using System;
@ -212,7 +216,11 @@ namespace Spine.Unity.Playables {
float clipSpeed = (float)clipPlayable.GetSpeed();
trackEntry.EventThreshold = clipData.eventThreshold;
trackEntry.DrawOrderThreshold = clipData.drawOrderThreshold;
trackEntry.TrackTime = (float)clipPlayable.GetTime() * clipSpeed * rootPlayableSpeed;
#if SPEED_INCLUDED_IN_CLIP_TIME
trackEntry.TrackTime = (float)clipPlayable.GetTime();
#else
trackEntry.TrackTime = (float)clipPlayable.GetTime() * rootPlayableSpeed * clipSpeed;
#endif
trackEntry.TimeScale = clipSpeed * rootPlayableSpeed;
trackEntry.AttachmentThreshold = clipData.attachmentThreshold;
trackEntry.HoldPrevious = clipData.holdPrevious;
@ -283,12 +291,20 @@ namespace Spine.Unity.Playables {
var fromClip = (ScriptPlayable<SpineAnimationStateBehaviour>)playable.GetInput(lastNonZeroWeightTrack - 1);
SpineAnimationStateBehaviour fromClipData = fromClip.GetBehaviour();
fromAnimation = fromClipData.animationReference != null ? fromClipData.animationReference.Animation : null;
#if SPEED_INCLUDED_IN_CLIP_TIME
fromClipTime = (float)fromClip.GetTime();
#else
fromClipTime = (float)fromClip.GetTime() * (float)fromClip.GetSpeed() * rootSpeed;
#endif
fromClipLoop = fromClipData.loop;
}
Animation toAnimation = clipData.animationReference != null ? clipData.animationReference.Animation : null;
#if SPEED_INCLUDED_IN_CLIP_TIME
float toClipTime = (float)inputPlayableClip.GetTime();
#else
float toClipTime = (float)inputPlayableClip.GetTime() * (float)inputPlayableClip.GetSpeed() * rootSpeed;
#endif
float mixDuration = clipData.mixDuration;
if (!clipData.customDuration && fromAnimation != null && toAnimation != null) {

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.timeline",
"displayName": "Spine Timeline Extensions",
"description": "This plugin provides integration of spine-unity for the Unity Timeline.\n\nPrerequisites:\nIt requires a working installation of the spine-unity and spine-csharp runtimes as UPM packages (not as spine-unity unitypackage), version 4.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
"version": "4.2.8",
"version": "4.2.9",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",

View File

@ -1,8 +1,6 @@
#ifndef SPRITE_NORMALS_PASS_URP_INCLUDED
#define SPRITE_NORMALS_PASS_URP_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
#include "../Include/SpineCoreShaders/ShaderShared.cginc"
#include "../Include/SpineCoreShaders/SpriteLighting.cginc"

View File

@ -1,8 +1,6 @@
#ifndef SPRITE_STANDARD_PASS_URP_INCLUDED
#define SPRITE_STANDARD_PASS_URP_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
#include "../Include/SpineCoreShaders/ShaderShared.cginc"
#include "../Include/SpineCoreShaders/SpriteLighting.cginc"
#if defined(_ALPHAPREMULTIPLY_ON)

View File

@ -12,6 +12,11 @@
#define IS_URP_12_OR_NEWER 0
#endif
#endif
#if IS_URP_14_OR_NEWER && !defined(_USE_WEBGL1_LIGHTS)
#define IS_URP_15_OR_NEWER 1
#else
#define IS_URP_15_OR_NEWER 0
#endif
#if defined(_WRITE_RENDERING_LAYERS) && IS_URP_14_OR_NEWER
#define USE_WRITE_RENDERING_LAYERS

View File

@ -150,7 +150,11 @@ VertexOutput vert(appdata v) {
// Note: ambient light is also handled via SH.
half3 vertexSH;
#if IS_URP_15_OR_NEWER
OUTPUT_SH(positionWS, normalWS.xyz, GetWorldSpaceNormalizeViewDir(positionWS), vertexSH);
#else
OUTPUT_SH(normalWS.xyz, vertexSH);
#endif
color.rgb += SAMPLE_GI(v.lightmapUV, vertexSH, normalWS);
o.color = color;

View File

@ -311,7 +311,11 @@ VertexOutputLWRP ForwardPassVertexSprite(VertexInput input)
output.fogFactorAndVertexLight.x = fogFactor;
#endif
#if IS_URP_15_OR_NEWER
OUTPUT_SH(positionWS, normalWS.xyz, GetWorldSpaceNormalizeViewDir(positionWS), output.vertexSH);
#else
OUTPUT_SH(normalWS.xyz, output.vertexSH);
#endif
return output;
}

View File

@ -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.16",
"version": "4.2.17",
"unity": "2019.3",
"author": {
"name": "Esoteric Software",