Browse Source

Merge branch '4.1' into 4.2-beta

Mario Zechner 3 years ago
parent
commit
d7f5b2a798

+ 0 - 1
spine-godot/spine_godot/SpineSkeleton.h

@@ -48,7 +48,6 @@ class SpineSkeleton : public REFCOUNTED {
 	friend class SpineSprite;
 	friend class SpineSprite;
 	friend class SpineAnimation;
 	friend class SpineAnimation;
 	friend class SpineAnimationState;
 	friend class SpineAnimationState;
-	friend class SpineCollisionShapeProxy;
 	friend class SpineAnimationTrack;
 	friend class SpineAnimationTrack;
 	friend class SpineBoneNode;
 	friend class SpineBoneNode;
 	friend class SpineSlotNode;
 	friend class SpineSlotNode;

+ 2 - 3
spine-godot/spine_godot/SpineSprite.cpp

@@ -532,13 +532,11 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
 		spine::Slot *slot = skeleton->getDrawOrder()[i];
 		spine::Slot *slot = skeleton->getDrawOrder()[i];
 		spine::Attachment *attachment = slot->getAttachment();
 		spine::Attachment *attachment = slot->getAttachment();
 		MeshInstance2D *mesh_instance = mesh_instances[i];
 		MeshInstance2D *mesh_instance = mesh_instances[i];
+		clear_mesh_instance(mesh_instance);
 		if (!attachment) {
 		if (!attachment) {
-			mesh_instances[i]->set_visible(false);
 			skeleton_clipper->clipEnd(*slot);
 			skeleton_clipper->clipEnd(*slot);
 			continue;
 			continue;
 		}
 		}
-		mesh_instance->set_visible(true);
-		clear_mesh_instance(mesh_instance);
 
 
 		spine::Color skeleton_color = skeleton->getColor();
 		spine::Color skeleton_color = skeleton->getColor();
 		spine::Color slot_color = slot->getColor();
 		spine::Color slot_color = slot->getColor();
@@ -598,6 +596,7 @@ void SpineSprite::update_meshes(Ref<SpineSkeleton> skeleton_ref) {
 		}
 		}
 
 
 		if (indices->size() > 0) {
 		if (indices->size() > 0) {
+			// Set the mesh
 			size_t num_vertices = vertices->size() / 2;
 			size_t num_vertices = vertices->size() / 2;
 			scratch_points.resize((int) num_vertices);
 			scratch_points.resize((int) num_vertices);
 			memcpy(scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));
 			memcpy(scratch_points.ptrw(), vertices->buffer(), num_vertices * 2 * sizeof(float));

+ 1 - 2
spine-godot/spine_godot/config.py

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

+ 3 - 3
spine-godot/spine_godot/docs/SpineAnimation.xml

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

+ 1 - 1
spine-godot/spine_godot/docs/SpineAnimationState.xml

@@ -27,7 +27,7 @@
 			<argument index="2" name="delay" type="float" />
 			<argument index="2" name="delay" type="float" />
 			<description>
 			<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].
 				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
 				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.
 				after the dispose event occurs.
 			</description>
 			</description>

+ 2 - 0
spine-godot/spine_godot/docs/SpineAnimationTrack.xml

@@ -43,6 +43,8 @@
 		</member>
 		</member>
 		<member name="attachment_threshold" type="float" setter="set_attachment_threshold" getter="get_attachment_threshold" default="0.0">
 		<member name="attachment_threshold" type="float" setter="set_attachment_threshold" getter="get_attachment_threshold" default="0.0">
 		</member>
 		</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 name="debug" type="bool" setter="set_debug" getter="get_debug" default="false">
 		</member>
 		</member>
 		<member name="draw_order_threshold" type="float" setter="set_draw_order_threshold" getter="get_draw_order_threshold" default="0.0">
 		<member name="draw_order_threshold" type="float" setter="set_draw_order_threshold" getter="get_draw_order_threshold" default="0.0">

+ 1 - 1
spine-godot/spine_godot/docs/SpineIkConstraint.xml

@@ -55,7 +55,7 @@
 		<method name="get_stretch">
 		<method name="get_stretch">
 			<return type="bool" />
 			<return type="bool" />
 			<description>
 			<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>
 			</description>
 		</method>
 		</method>
 		<method name="get_target">
 		<method name="get_target">

+ 1 - 1
spine-godot/spine_godot/docs/SpineIkConstraintData.xml

@@ -45,7 +45,7 @@
 			<return type="bool" />
 			<return type="bool" />
 			<description>
 			<description>
 				When true and the target is out of range, the parent bone is scaled to reach it.
 				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>
 			</description>
 		</method>
 		</method>
 		<method name="get_target">
 		<method name="get_target">

+ 0 - 15
spine-godot/spine_godot/docs/SpineObjectWrapper.xml

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

+ 2 - 2
spine-godot/spine_godot/docs/SpineSkeleton.xml

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

+ 1 - 2
spine-godot/spine_godot/docs/SpineTrackEntry.xml

@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <?xml version="1.0" encoding="UTF-8" ?>
 <class name="SpineTrackEntry" inherits="SpineObjectWrapper" version="3.4">
 <class name="SpineTrackEntry" inherits="SpineObjectWrapper" version="3.4">
 	<brief_description>
 	<brief_description>
-
 	</brief_description>
 	</brief_description>
 	<description>
 	<description>
 		Stores settings and other state for the playback of an animation on an animation state track.
 		Stores settings and other state for the playback of an animation on an animation state track.
@@ -58,7 +57,7 @@
 		<method name="get_delay">
 		<method name="get_delay">
 			<return type="float" />
 			<return type="float" />
 			<description>
 			<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.
 				[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.
 				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>
 			</description>

+ 1 - 1
spine-godot/spine_godot/register_types.cpp

@@ -78,7 +78,7 @@ void register_spine_godot_types() {
 	GDREGISTER_CLASS(SpineEditorPropertyAnimationMixes);
 	GDREGISTER_CLASS(SpineEditorPropertyAnimationMixes);
 #endif
 #endif
 	spine::Bone::setYDown(true);
 	spine::Bone::setYDown(true);
-
+	GDREGISTER_CLASS(SpineObjectWrapper);
 	GDREGISTER_CLASS(SpineAtlasResource);
 	GDREGISTER_CLASS(SpineAtlasResource);
 	GDREGISTER_CLASS(SpineSkeletonFileResource);
 	GDREGISTER_CLASS(SpineSkeletonFileResource);
 	GDREGISTER_CLASS(SpineSkeletonDataResource);
 	GDREGISTER_CLASS(SpineSkeletonDataResource);

+ 1 - 1
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs

@@ -669,7 +669,7 @@ namespace Spine.Unity.Editor {
 									if (atlas == null)
 									if (atlas == null)
 										continue;
 										continue;
 									for (int i = 0; i < missingPaths.Count; i++) {
 									for (int i = 0; i < missingPaths.Count; i++) {
-										if (atlas.FindRegion(missingPaths[i]) != null) {
+										if (atlas.FindRegionIgnoringNumberSuffix(missingPaths[i]) != null) {
 											missingPaths.RemoveAt(i);
 											missingPaths.RemoveAt(i);
 											i--;
 											i--;
 										}
 										}

+ 23 - 3
spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs

@@ -221,6 +221,26 @@ namespace Spine.Unity.Editor {
 			return GetMatchingAtlas(requiredPaths, atlasAssets);
 			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) {
 		internal static AtlasAssetBase GetMatchingAtlas (List<string> requiredPaths, List<AtlasAssetBase> atlasAssets) {
 			AtlasAssetBase atlasAssetMatch = null;
 			AtlasAssetBase atlasAssetMatch = null;
 
 
@@ -228,7 +248,7 @@ namespace Spine.Unity.Editor {
 				Atlas atlas = a.GetAtlas();
 				Atlas atlas = a.GetAtlas();
 				bool failed = false;
 				bool failed = false;
 				foreach (string regionPath in requiredPaths) {
 				foreach (string regionPath in requiredPaths) {
-					if (atlas.FindRegion(regionPath) == null) {
+					if (atlas.FindRegionIgnoringNumberSuffix(regionPath) == null) {
 						failed = true;
 						failed = true;
 						break;
 						break;
 					}
 					}
@@ -1118,7 +1138,7 @@ namespace Spine.Unity.Editor {
 					foreach (var atlasAsset in atlasAssets) {
 					foreach (var atlasAsset in atlasAssets) {
 						var atlas = atlasAsset.GetAtlas();
 						var atlas = atlasAsset.GetAtlas();
 						for (int i = 0; i < missingRegions.Count; i++) {
 						for (int i = 0; i < missingRegions.Count; i++) {
-							if (atlas.FindRegion(missingRegions[i]) != null) {
+							if (atlas.FindRegionIgnoringNumberSuffix(missingRegions[i]) != null) {
 								missingRegions.RemoveAt(i);
 								missingRegions.RemoveAt(i);
 								i--;
 								i--;
 							}
 							}
@@ -1152,7 +1172,7 @@ namespace Spine.Unity.Editor {
 							var atlas = selectedAtlasAsset.GetAtlas();
 							var atlas = selectedAtlasAsset.GetAtlas();
 							bool hasValidRegion = false;
 							bool hasValidRegion = false;
 							foreach (string str in missingRegions) {
 							foreach (string str in missingRegions) {
-								if (atlas.FindRegion(str) != null) {
+								if (atlas.FindRegionIgnoringNumberSuffix(str) != null) {
 									hasValidRegion = true;
 									hasValidRegion = true;
 									break;
 									break;
 								}
 								}

+ 5 - 0
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;
 					var renderableAttachment = entry.Attachment as IHasTextureRegion;
 					if (renderableAttachment != null) {
 					if (renderableAttachment != null) {
 						var originalRegion = (AtlasRegion)renderableAttachment.Region;
 						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(
 						bool replacementExists = replacementMaterials.Exists(
 							replacement => replacement.pageName == originalRegion.page.name);
 							replacement => replacement.pageName == originalRegion.page.name);
 						if (!replacementExists) {
 						if (!replacementExists) {

+ 11 - 1
spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/BlendModeMaterials.cs

@@ -127,8 +127,18 @@ namespace Spine.Unity {
 				foreach (var entry in skinEntries) {
 				foreach (var entry in skinEntries) {
 					var renderableAttachment = entry.Attachment as IHasTextureRegion;
 					var renderableAttachment = entry.Attachment as IHasTextureRegion;
 					if (renderableAttachment != null) {
 					if (renderableAttachment != null) {
-						renderableAttachment.Region = CloneAtlasRegionWithMaterial(
+						if (renderableAttachment.Region != null) {
+							renderableAttachment.Region = CloneAtlasRegionWithMaterial(
 							(AtlasRegion)renderableAttachment.Region, replacementMaterials);
 							(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);
+								}
+							}
+						}
 					}
 					}
 				}
 				}
 			}
 			}