Merge branch '4.1' into 4.2-beta

This commit is contained in:
Mario Zechner 2022-07-26 10:06:26 +02:00
commit d7f5b2a798
16 changed files with 55 additions and 37 deletions

View File

@ -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;

View File

@ -532,13 +532,11 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> 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<SpineSkeleton> 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));

View File

@ -34,6 +34,5 @@ def get_doc_classes():
"SpineTimeline",
"SpineTrackEntry",
"SpineTransformConstraint",
"SpineTransformConstraintData",
"SpineObjectWrapper"
"SpineTransformConstraintData"
]

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SpineAnimation" inherits="SpineObjectWrapper" version="3.4">
<brief_description>
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.
</brief_description>
<description>
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.
</description>
<tutorials>
</tutorials>
@ -20,7 +20,7 @@
<argument index="6" name="blend" type="int" enum="SpineConstant.MixBlend" />
<argument index="7" name="direction" type="int" enum="SpineConstant.MixDirection" />
<description>
Applies the animation's timelines to the specified skeleton.
Applies the animation's timelines to the specified skeleton.
</description>
</method>
<method name="get_duration">

View File

@ -27,7 +27,7 @@
<argument index="2" name="delay" type="float" />
<description>
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 &lt;= 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] &lt; 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]&gt; 0, sets the track entry's delay. If &lt;= 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] &lt; 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.
</description>

View File

@ -43,6 +43,8 @@
</member>
<member name="attachment_threshold" type="float" setter="set_attachment_threshold" getter="get_attachment_threshold" default="0.0">
</member>
<member name="blend_tree_mode" type="bool" setter="set_blend_tree_mode" getter="get_blend_tree_mode" default="false">
</member>
<member name="debug" type="bool" setter="set_debug" getter="get_debug" default="false">
</member>
<member name="draw_order_threshold" type="float" setter="set_draw_order_threshold" getter="get_draw_order_threshold" default="0.0">

View File

@ -55,7 +55,7 @@
<method name="get_stretch">
<return type="bool" />
<description>
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 &gt; 0, and 3) if the parent bone has local nonuniform scale, stretch is not applied.
</description>
</method>
<method name="get_target">

View File

@ -45,7 +45,7 @@
<return type="bool" />
<description>
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 &gt; 0, and 3) if the parent bone has local nonuniform scale, stretch is not applied.
</description>
</method>
<method name="get_target">

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SpineObjectWrapper" version="3.4">
<brief_description>
The base class for anything that wraps a spine-cpp class. All wrappers are a Godot reference.
</brief_description>
<description>
The base class for anything that wraps a spine-cpp class. All wrappers are a Godot reference.
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<constants>
</constants>
</class>

View File

@ -51,7 +51,7 @@
<argument index="1" name="attachment_name" type="String" />
<description>
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.
</description>
</method>
<method name="get_attachment_by_slot_name">
@ -60,7 +60,7 @@
<argument index="1" name="attachment_name" type="String" />
<description>
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.
</description>
</method>
<method name="get_bones">

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SpineTrackEntry" inherits="SpineObjectWrapper" version="3.4">
<brief_description>
</brief_description>
<description>
Stores settings and other state for the playback of an animation on an animation state track.
@ -58,7 +57,7 @@
<method name="get_delay">
<return type="float" />
<description>
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] &gt;= this track entry's delay).
[code]get_time_scale()[/code] affects the delay.
When using [code]AnimationState.add_animation()[/code] with a delay &lt;= 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.
</description>

View File

@ -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);

View File

@ -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--;
}

View File

@ -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<string> requiredPaths, List<AtlasAssetBase> 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;
}

View File

@ -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) {

View File

@ -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);
}
}
}
}
}
}