From bee4d4060caf704ab68f79006d96829542741d8a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 2 Jun 2023 15:21:37 +0200 Subject: [PATCH 1/6] [flutter] Batch by color as well, to avoid Impeller slow path See https://github.com/flutter/flutter/issues/127486 --- spine-flutter/lib/spine_flutter.dart | 16 +++++++++++++++- spine-flutter/src/spine_flutter.cpp | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spine-flutter/lib/spine_flutter.dart b/spine-flutter/lib/spine_flutter.dart index 469dc143e..dc39188cb 100644 --- a/spine-flutter/lib/spine_flutter.dart +++ b/spine-flutter/lib/spine_flutter.dart @@ -4071,7 +4071,21 @@ class RenderCommand { // is copied, so it doesn't matter that we free up the underlying memory on the next // render call. See the implementation of Vertices.raw() here: // https://github.com/flutter/engine/blob/5c60785b802ad2c8b8899608d949342d5c624952/lib/ui/painting/vertices.cc#L21 - vertices = Vertices.raw(VertexMode.triangles, positions, textureCoordinates: uvs, colors: colors, indices: indices); + // + // Impeller is currently using a slow path when using vertex colors. + // See https://github.com/flutter/flutter/issues/127486 + // + // We thus batch all meshes not only by atlas page and blend mode, but also vertex color. + // See spine_flutter.cpp, batch_commands(). + // + // If the vertex color equals (1, 1, 1, 1), we do not store + // colors, which will trigger the fast path in Impeller. Otherwise we have to go the slow path, which + // has to render to an offscreen surface. + if (colors.isNotEmpty && colors[0] == -1) { + vertices = Vertices.raw(VertexMode.triangles, positions, textureCoordinates: uvs, indices: indices); + } else { + vertices = Vertices.raw(VertexMode.triangles, positions, textureCoordinates: uvs, colors: colors, indices: indices); + } } else { // On the web, rendering is done through CanvasKit, which requires copies of the native data. final positionsCopy = Float32List.fromList(positions); diff --git a/spine-flutter/src/spine_flutter.cpp b/spine-flutter/src/spine_flutter.cpp index a970f6437..dfd3b8fea 100644 --- a/spine-flutter/src/spine_flutter.cpp +++ b/spine-flutter/src/spine_flutter.cpp @@ -695,6 +695,7 @@ static _spine_render_command *batch_commands(BlockAllocator &allocator, Vector<_ _spine_render_command *cmd = i < commands.size() ? commands[i] : nullptr; if (cmd != nullptr && cmd->atlasPage == first->atlasPage && cmd->blendMode == first->blendMode && + cmd->colors[0] == first->colors[0] && numIndices + cmd->numIndices < 0xffff) { numVertices += cmd->numVertices; numIndices += cmd->numIndices; From 03320547ca415226fbbe97863c7acbc4de634783 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 7 Jun 2023 13:25:39 +0200 Subject: [PATCH 2/6] [ue] Fix permissions of setup script. --- spine-ue4/setup.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 spine-ue4/setup.sh diff --git a/spine-ue4/setup.sh b/spine-ue4/setup.sh old mode 100644 new mode 100755 From 468985bd3563c2943a506a5b26f065ebe159582b Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 7 Jun 2023 13:52:03 +0200 Subject: [PATCH 3/6] [ue] Fix compilation error with Clang, closes #2301. --- .../Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp index cb7dd2f50..7d7652d6f 100644 --- a/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp +++ b/spine-ue4/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonDataAsset.cpp @@ -298,9 +298,9 @@ SkeletonData *USpineSkeletonDataAsset::GetSkeletonData(Atlas *Atlas) { void USpineSkeletonDataAsset::SetMixes(AnimationStateData *animationStateData) { for (auto &data : MixData) { if (!data.From.IsEmpty() && !data.To.IsEmpty()) { - const char *fromChar = TCHAR_TO_UTF8(*data.From); - const char *toChar = TCHAR_TO_UTF8(*data.To); - animationStateData->setMix(fromChar, toChar, data.Mix); + std::string fromChar = TCHAR_TO_UTF8(*data.From); + std::string toChar = TCHAR_TO_UTF8(*data.To); + animationStateData->setMix(fromChar.c_str(), toChar.c_str(), data.Mix); } } animationStateData->setDefaultMix(DefaultMix); From 9be78dbd20e6cddbbb1a28c940dcd33ad78a72d8 Mon Sep 17 00:00:00 2001 From: Jordan Schidlowsky <323868+jordo@users.noreply.github.com> Date: Wed, 7 Jun 2023 05:52:43 -0600 Subject: [PATCH 4/6] Support audio path in SpineEventData (#2303) --- spine-godot/spine_godot/SpineEventData.cpp | 12 ++++++++++++ spine-godot/spine_godot/SpineEventData.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/spine-godot/spine_godot/SpineEventData.cpp b/spine-godot/spine_godot/SpineEventData.cpp index 9142809d1..55e5f9b8e 100644 --- a/spine-godot/spine_godot/SpineEventData.cpp +++ b/spine-godot/spine_godot/SpineEventData.cpp @@ -38,6 +38,8 @@ void SpineEventData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_float_value", "v"), &SpineEventData::set_float_value); ClassDB::bind_method(D_METHOD("get_string_value"), &SpineEventData::get_string_value); ClassDB::bind_method(D_METHOD("set_string_value", "v"), &SpineEventData::set_string_value); + ClassDB::bind_method(D_METHOD("get_audio_path"), &SpineEventData::get_audio_path); + ClassDB::bind_method(D_METHOD("set_audio_path", "v"), &SpineEventData::set_audio_path); ClassDB::bind_method(D_METHOD("get_volume"), &SpineEventData::get_volume); ClassDB::bind_method(D_METHOD("set_volume", "v"), &SpineEventData::set_volume); ClassDB::bind_method(D_METHOD("get_balance"), &SpineEventData::get_balance); @@ -79,6 +81,16 @@ void SpineEventData::set_string_value(const String &v) { get_spine_object()->setStringValue(spine::String(v.utf8())); } +String SpineEventData::get_audio_path() { + SPINE_CHECK(get_spine_object(), "") + return get_spine_object()->getAudioPath().buffer(); +} + +void SpineEventData::set_audio_path(const String &v) { + SPINE_CHECK(get_spine_object(), ) + get_spine_object()->setAudioPath(spine::String(v.utf8())); +} + float SpineEventData::get_volume() { SPINE_CHECK(get_spine_object(), 0) return get_spine_object()->getVolume(); diff --git a/spine-godot/spine_godot/SpineEventData.h b/spine-godot/spine_godot/SpineEventData.h index b6bd18053..a515f9dde 100644 --- a/spine-godot/spine_godot/SpineEventData.h +++ b/spine-godot/spine_godot/SpineEventData.h @@ -55,6 +55,10 @@ public: void set_string_value(const String &v); + String get_audio_path(); + + void set_audio_path(const String &v); + float get_volume(); void set_volume(float v); From b77580048991fb1ade429ec37b87df96eff9bca7 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 7 Jun 2023 14:31:59 +0200 Subject: [PATCH 5/6] [sdl] Closes #2304, misnamed function declaration spSkeletonDrawable_dispose --- spine-sdl/src/spine-sdl-c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spine-sdl/src/spine-sdl-c.h b/spine-sdl/src/spine-sdl-c.h index 7d48cca66..a0b058b71 100644 --- a/spine-sdl/src/spine-sdl-c.h +++ b/spine-sdl/src/spine-sdl-c.h @@ -52,7 +52,7 @@ typedef struct spSkeletonDrawable { SP_API spSkeletonDrawable *spSkeletonDrawable_create(spSkeletonData *skeletonData, spAnimationStateData *animationStateData); -SP_API void spSkeletonDrawable_destroy(spSkeletonDrawable *self); +SP_API void spSkeletonDrawable_dispose(spSkeletonDrawable *self); SP_API void spSkeletonDrawable_update(spSkeletonDrawable *self, float delta); From 2d9bdb0ec383c58f79fa4a5f20e16dea6f270bdc Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Fri, 9 Jun 2023 19:05:22 +0200 Subject: [PATCH 6/6] [unity] Fixed scene preview conflict between Timeline and SkeletonAnimation animation. Closes #2307. --- .../Runtime/spine-unity/Components/SkeletonAnimation.cs | 4 ++++ .../Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs | 4 ++++ spine-unity/Assets/Spine/package.json | 2 +- .../SpineAnimationState/SpineAnimationStateMixerBehaviour.cs | 5 +++-- .../Modules/com.esotericsoftware.spine.timeline/package.json | 4 ++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs index 144285421..62cb69696 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonAnimation.cs @@ -253,6 +253,10 @@ namespace Spine.Unity { else state.ApplyEventTimelinesOnly(skeleton, issueEvents: true); + AfterAnimationApplied(); + } + + public void AfterAnimationApplied () { if (_UpdateLocal != null) _UpdateLocal(this); diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs index 9efa7e9cc..dee7bf448 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs @@ -387,6 +387,10 @@ namespace Spine.Unity { else state.ApplyEventTimelinesOnly(skeleton, issueEvents: true); + AfterAnimationApplied(); + } + + public void AfterAnimationApplied () { if (UpdateLocal != null) UpdateLocal(this); diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json index d99ebb46f..776032edd 100644 --- a/spine-unity/Assets/Spine/package.json +++ b/spine-unity/Assets/Spine/package.json @@ -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.1.12", + "version": "4.1.13", "unity": "2018.3", "author": { "name": "Esoteric Software", diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs index f77bddf8b..fbdaf8c5c 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/Runtime/SpineAnimationState/SpineAnimationStateMixerBehaviour.cs @@ -332,11 +332,12 @@ namespace Spine.Unity.Playables { toAnimation.Apply(skeleton, 0, toClipTime, clipData.loop, null, clipData.alpha, MixBlend.Setup, MixDirection.In); } + skeleton.UpdateWorldTransform(); if (skeletonAnimation) { - skeletonAnimation.Update(0); + skeletonAnimation.AfterAnimationApplied(); skeletonAnimation.LateUpdate(); } else if (skeletonGraphic) { - skeletonGraphic.Update(0); + skeletonGraphic.AfterAnimationApplied(); skeletonGraphic.LateUpdate(); } } diff --git a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json index 0452d87f1..4bf822a59 100644 --- a/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json +++ b/spine-unity/Modules/com.esotericsoftware.spine.timeline/package.json @@ -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.1.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)", - "version": "4.1.7", + "version": "4.1.8", "unity": "2018.3", "author": { "name": "Esoteric Software", @@ -11,7 +11,7 @@ }, "dependencies": { "com.unity.timeline": "1.2.10", - "com.esotericsoftware.spine.spine-unity": "4.1.11" + "com.esotericsoftware.spine.spine-unity": "4.1.13" }, "keywords": [ "spine",