From ec034a0654fa168a843a4626b9d0ff76bac938b6 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 25 Jul 2022 16:15:26 +0200 Subject: [PATCH 1/3] [godot] Closes #2125, fix help menu --- spine-godot/spine_godot/SpineSkeleton.h | 1 - spine-godot/spine_godot/config.py | 3 +-- spine-godot/spine_godot/docs/SpineAnimation.xml | 6 +++--- .../spine_godot/docs/SpineAnimationState.xml | 2 +- .../spine_godot/docs/SpineAnimationTrack.xml | 2 ++ .../spine_godot/docs/SpineIkConstraint.xml | 2 +- .../spine_godot/docs/SpineIkConstraintData.xml | 2 +- .../spine_godot/docs/SpineObjectWrapper.xml | 15 --------------- spine-godot/spine_godot/docs/SpineSkeleton.xml | 4 ++-- spine-godot/spine_godot/docs/SpineTrackEntry.xml | 3 +-- spine-godot/spine_godot/register_types.cpp | 2 +- 11 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 spine-godot/spine_godot/docs/SpineObjectWrapper.xml diff --git a/spine-godot/spine_godot/SpineSkeleton.h b/spine-godot/spine_godot/SpineSkeleton.h index f312f2b31..dd9b8afd3 100644 --- a/spine-godot/spine_godot/SpineSkeleton.h +++ b/spine-godot/spine_godot/SpineSkeleton.h @@ -48,7 +48,6 @@ class SpineSkeleton : public REFCOUNTED { friend class SpineSprite; friend class SpineAnimation; friend class SpineAnimationState; - friend class SpineCollisionShapeProxy; friend class SpineAnimationTrack; friend class SpineBoneNode; friend class SpineSlotNode; diff --git a/spine-godot/spine_godot/config.py b/spine-godot/spine_godot/config.py index bf526daaf..7524f5225 100644 --- a/spine-godot/spine_godot/config.py +++ b/spine-godot/spine_godot/config.py @@ -34,6 +34,5 @@ def get_doc_classes(): "SpineTimeline", "SpineTrackEntry", "SpineTransformConstraint", - "SpineTransformConstraintData", - "SpineObjectWrapper" + "SpineTransformConstraintData" ] diff --git a/spine-godot/spine_godot/docs/SpineAnimation.xml b/spine-godot/spine_godot/docs/SpineAnimation.xml index 656442062..048bab53c 100644 --- a/spine-godot/spine_godot/docs/SpineAnimation.xml +++ b/spine-godot/spine_godot/docs/SpineAnimation.xml @@ -1,10 +1,10 @@ - Stores a list of timelines to animate a skeleton's pose over time. The timelines can not be modified through GDScript. + Stores a list of timelines to animate a skeleton's pose over time. The timelines can not be modified through GDScript. - Stores a list of timelines to animate a skeleton's pose over time. The timelines can not be modified through GDScript. + Stores a list of timelines to animate a skeleton's pose over time. The timelines can not be modified through GDScript. @@ -20,7 +20,7 @@ - Applies the animation's timelines to the specified skeleton. + Applies the animation's timelines to the specified skeleton. diff --git a/spine-godot/spine_godot/docs/SpineAnimationState.xml b/spine-godot/spine_godot/docs/SpineAnimationState.xml index e7af0fccb..84e3e4b55 100644 --- a/spine-godot/spine_godot/docs/SpineAnimationState.xml +++ b/spine-godot/spine_godot/docs/SpineAnimationState.xml @@ -27,7 +27,7 @@ Adds an empty animation to be played after the current or last queued animation for a track, and sets the track entry's mix duration. If the track is empty, it is equivalent to calling [code]set_empty_animation()[/code]. See [code]set_empty_animation()[/code]. - If [code]delay[/code]> 0, sets the track entry's delay. If <= 0, the delay set is the duration of the previous track entry minus any mix duration plus the specified [code]delay[/code] (ie the mix ends at ([code]delay[/code] = 0) or before ([code]delay[/code] < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration. + If [code]delay[/code]> 0, sets the track entry's delay. If <= 0, the delay set is the duration of the previous track entry minus any mix duration plus the specified [code]delay[/code] (ie the mix ends at ([code]delay[/code] = 0) or before ([code]delay[/code] < 0) the previous track entry duration). If the previous entry is looping, its next loop completion is used instead of its duration. Returns a track entry to allow further customization of animation playback. References to the track entry must not be kept after the dispose event occurs. diff --git a/spine-godot/spine_godot/docs/SpineAnimationTrack.xml b/spine-godot/spine_godot/docs/SpineAnimationTrack.xml index bfc606f75..3ab0a6e6c 100644 --- a/spine-godot/spine_godot/docs/SpineAnimationTrack.xml +++ b/spine-godot/spine_godot/docs/SpineAnimationTrack.xml @@ -43,6 +43,8 @@ + + diff --git a/spine-godot/spine_godot/docs/SpineIkConstraint.xml b/spine-godot/spine_godot/docs/SpineIkConstraint.xml index d64bb209b..68ed683e1 100644 --- a/spine-godot/spine_godot/docs/SpineIkConstraint.xml +++ b/spine-godot/spine_godot/docs/SpineIkConstraint.xml @@ -55,7 +55,7 @@ - When true and the target is out of range, the parent bone is scaled to reach it. For two bone IK: 1) the child bone's local Y translation is set to 0, 2) stretch is not applied if softness is > 0, and 3) if the parent bone has local nonuniform scale, stretch is not applied. + When true and the target is out of range, the parent bone is scaled to reach it. For two bone IK: 1) the child bone's local Y translation is set to 0, 2) stretch is not applied if softness is > 0, and 3) if the parent bone has local nonuniform scale, stretch is not applied. diff --git a/spine-godot/spine_godot/docs/SpineIkConstraintData.xml b/spine-godot/spine_godot/docs/SpineIkConstraintData.xml index 62ce586f1..9c79ba48e 100644 --- a/spine-godot/spine_godot/docs/SpineIkConstraintData.xml +++ b/spine-godot/spine_godot/docs/SpineIkConstraintData.xml @@ -45,7 +45,7 @@ When true and the target is out of range, the parent bone is scaled to reach it. - For two bone IK: 1) the child bone's local Y translation is set to 0, 2) stretch is not applied if softness is > 0, and 3) if the parent bone has local nonuniform scale, stretch is not applied. + For two bone IK: 1) the child bone's local Y translation is set to 0, 2) stretch is not applied if softness is > 0, and 3) if the parent bone has local nonuniform scale, stretch is not applied. diff --git a/spine-godot/spine_godot/docs/SpineObjectWrapper.xml b/spine-godot/spine_godot/docs/SpineObjectWrapper.xml deleted file mode 100644 index c7dcdf85f..000000000 --- a/spine-godot/spine_godot/docs/SpineObjectWrapper.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - The base class for anything that wraps a spine-cpp class. All wrappers are a Godot reference. - - - The base class for anything that wraps a spine-cpp class. All wrappers are a Godot reference. - - - - - - - - diff --git a/spine-godot/spine_godot/docs/SpineSkeleton.xml b/spine-godot/spine_godot/docs/SpineSkeleton.xml index d44bae661..2f4bd62df 100644 --- a/spine-godot/spine_godot/docs/SpineSkeleton.xml +++ b/spine-godot/spine_godot/docs/SpineSkeleton.xml @@ -51,7 +51,7 @@ Finds an attachment by looking in the active skin and default skin using the slot index and attachment name. First the skin is checked and if the attachment was not found, the default skin is checked. - See [url]http://esotericsoftware.com/spine-runtime-skins">Runtime skins[/url] in the Spine Runtimes Guide. + See [url]http://esotericsoftware.com/spine-runtime-skins[/url] in the Spine Runtimes Guide. @@ -60,7 +60,7 @@ Finds an attachment by looking in the active skin and default skin using the slot index and attachment name. First the skin is checked and if the attachment was not found, the default skin is checked. - See [url]http://esotericsoftware.com/spine-runtime-skins">Runtime skins[/url] in the Spine Runtimes Guide. + See [url]http://esotericsoftware.com/spine-runtime-skins[/url] in the Spine Runtimes Guide. diff --git a/spine-godot/spine_godot/docs/SpineTrackEntry.xml b/spine-godot/spine_godot/docs/SpineTrackEntry.xml index c0bb22b8b..a4c9de814 100644 --- a/spine-godot/spine_godot/docs/SpineTrackEntry.xml +++ b/spine-godot/spine_godot/docs/SpineTrackEntry.xml @@ -1,7 +1,6 @@ - Stores settings and other state for the playback of an animation on an animation state track. @@ -58,7 +57,7 @@ - Seconds to postpone playing the animation. When this track entry is the current track entry, delay postpones incrementing the [code]get_track_time()[/code]. When this track entry is queued, delay is the time from the start of the previous animation to when this track entry will become the current track entry (ie when the previous track entry [code]get_track_time()[/code] >= this track entry's delay). + Seconds to postpone playing the animation. When this track entry is the current track entry, delay postpones incrementing the [code]get_track_time()[/code]. When this track entry is queued, delay is the time from the start of the previous animation to when this track entry will become the current track entry (ie when the previous track entry [code]get_track_time()[/code] >= this track entry's delay). [code]get_time_scale()[/code] affects the delay. When using [code]AnimationState.add_animation()[/code] with a delay <= 0, the delay is set using the mix duration from the skeleton data resource. If mix duration is set afterward, the delay may need to be adjusted. diff --git a/spine-godot/spine_godot/register_types.cpp b/spine-godot/spine_godot/register_types.cpp index 5680b8a29..603c87bde 100644 --- a/spine-godot/spine_godot/register_types.cpp +++ b/spine-godot/spine_godot/register_types.cpp @@ -78,7 +78,7 @@ void register_spine_godot_types() { GDREGISTER_CLASS(SpineEditorPropertyAnimationMixes); #endif spine::Bone::setYDown(true); - + GDREGISTER_CLASS(SpineObjectWrapper); GDREGISTER_CLASS(SpineAtlasResource); GDREGISTER_CLASS(SpineSkeletonFileResource); GDREGISTER_CLASS(SpineSkeletonDataResource); From 4f4d339c57d8fcb896b98dab3f41b53937c0b3e3 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 25 Jul 2022 19:47:26 +0200 Subject: [PATCH 2/3] [unity] Fixed issues with image sequence import, including custom slot blend modes. Closes #2126, closes #2127. --- .../Asset Types/SkeletonDataAssetInspector.cs | 2 +- .../Editor/Utility/AssetUtility.cs | 26 ++++++++++++++++--- .../Utility/BlendModeMaterialsUtility.cs | 5 ++++ .../Asset Types/BlendModeMaterials.cs | 12 ++++++++- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs index bde3b42fc..990b655cf 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs @@ -669,7 +669,7 @@ namespace Spine.Unity.Editor { if (atlas == null) continue; for (int i = 0; i < missingPaths.Count; i++) { - if (atlas.FindRegion(missingPaths[i]) != null) { + if (atlas.FindRegionIgnoringNumberSuffix(missingPaths[i]) != null) { missingPaths.RemoveAt(i); i--; } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs index 8b68b516d..53455f111 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs @@ -221,6 +221,26 @@ namespace Spine.Unity.Editor { return GetMatchingAtlas(requiredPaths, atlasAssets); } + internal static AtlasRegion FindRegionIgnoringNumberSuffix (this Atlas atlas, string regionPath) { + AtlasRegion region = atlas.FindRegion(regionPath); + if (region != null) + return region; + return atlas.FindRegionWithNumberSuffix(regionPath); + } + + internal static AtlasRegion FindRegionWithNumberSuffix (this Atlas atlas, string regionPath) { + int pathLength = regionPath.Length; + foreach (AtlasRegion region in atlas.Regions) { + string name = region.name; + if (name.StartsWith(regionPath)) { + string suffix = name.Substring(pathLength); + if (suffix.All(c => c >= '0' && c <= '9')) + return region; + } + } + return null; + } + internal static AtlasAssetBase GetMatchingAtlas (List requiredPaths, List atlasAssets) { AtlasAssetBase atlasAssetMatch = null; @@ -228,7 +248,7 @@ namespace Spine.Unity.Editor { Atlas atlas = a.GetAtlas(); bool failed = false; foreach (string regionPath in requiredPaths) { - if (atlas.FindRegion(regionPath) == null) { + if (atlas.FindRegionIgnoringNumberSuffix(regionPath) == null) { failed = true; break; } @@ -1118,7 +1138,7 @@ namespace Spine.Unity.Editor { foreach (var atlasAsset in atlasAssets) { var atlas = atlasAsset.GetAtlas(); for (int i = 0; i < missingRegions.Count; i++) { - if (atlas.FindRegion(missingRegions[i]) != null) { + if (atlas.FindRegionIgnoringNumberSuffix(missingRegions[i]) != null) { missingRegions.RemoveAt(i); i--; } @@ -1152,7 +1172,7 @@ namespace Spine.Unity.Editor { var atlas = selectedAtlasAsset.GetAtlas(); bool hasValidRegion = false; foreach (string str in missingRegions) { - if (atlas.FindRegion(str) != null) { + if (atlas.FindRegionIgnoringNumberSuffix(str) != null) { hasValidRegion = true; break; } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs index 476b2d556..06b0faf1f 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/BlendModeMaterialsUtility.cs @@ -203,6 +203,11 @@ namespace Spine.Unity.Editor { var renderableAttachment = entry.Attachment as IHasTextureRegion; if (renderableAttachment != null) { var originalRegion = (AtlasRegion)renderableAttachment.Region; + Sequence sequence = null; + if (originalRegion == null && (sequence = renderableAttachment.Sequence) != null) { + if (sequence.Regions != null && sequence.Regions.Length > 0) + originalRegion = (AtlasRegion)sequence.Regions[0]; + } bool replacementExists = replacementMaterials.Exists( replacement => replacement.pageName == originalRegion.page.name); if (!replacementExists) { diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs index 0c2e76813..f568a63fa 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs @@ -127,8 +127,18 @@ namespace Spine.Unity { foreach (var entry in skinEntries) { var renderableAttachment = entry.Attachment as IHasTextureRegion; if (renderableAttachment != null) { - renderableAttachment.Region = CloneAtlasRegionWithMaterial( + if (renderableAttachment.Region != null) { + renderableAttachment.Region = CloneAtlasRegionWithMaterial( (AtlasRegion)renderableAttachment.Region, replacementMaterials); + } else { + if (renderableAttachment.Sequence != null) { + var regions = renderableAttachment.Sequence.Regions; + for (int i = 0; i < regions.Length; ++i) { + regions[i] = CloneAtlasRegionWithMaterial( + (AtlasRegion)regions[i], replacementMaterials); + } + } + } } } } From 72c547bd0125f4f8723a20eb06cf568d07059058 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Tue, 26 Jul 2022 10:06:05 +0200 Subject: [PATCH 3/3] [godot] Closes #2117, setting meshes of inactive slots invisible breaks draw order. Since we clear the mesh instances, we can refrain from setting them invisible. --- spine-godot/spine_godot/SpineSprite.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spine-godot/spine_godot/SpineSprite.cpp b/spine-godot/spine_godot/SpineSprite.cpp index 0826b7800..7a75649af 100644 --- a/spine-godot/spine_godot/SpineSprite.cpp +++ b/spine-godot/spine_godot/SpineSprite.cpp @@ -532,13 +532,11 @@ void SpineSprite::update_meshes(Ref skeleton_ref) { spine::Slot *slot = skeleton->getDrawOrder()[i]; spine::Attachment *attachment = slot->getAttachment(); MeshInstance2D *mesh_instance = mesh_instances[i]; + clear_mesh_instance(mesh_instance); if (!attachment) { - mesh_instances[i]->set_visible(false); skeleton_clipper->clipEnd(*slot); continue; } - mesh_instance->set_visible(true); - clear_mesh_instance(mesh_instance); spine::Color skeleton_color = skeleton->getColor(); spine::Color slot_color = slot->getColor(); @@ -598,6 +596,7 @@ void SpineSprite::update_meshes(Ref skeleton_ref) { } if (indices->size() > 0) { + // Set the mesh size_t num_vertices = vertices->size() / 2; scratch_points.resize((int) num_vertices); memcpy(scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));