Merge branch '3.6' into 3.7-beta

This commit is contained in:
badlogic 2018-06-15 15:32:23 +02:00
commit f38ffc75bf
9 changed files with 45 additions and 16 deletions

View File

@ -5,5 +5,5 @@
<AS3Classpath generateProblems="true" sdkBased="false" type="source" useAsSharedCode="false">src</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="false" type="source" useAsSharedCode="false">src</AS3Classpath>
<AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/spine-starling.swc</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/spine-starling.swc</AS3Classpath>
<AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/spine-as3.swc</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/spine-as3.swc</AS3Classpath>
<AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/starling-2.1.swc</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/starling-2.4.swc</AS3Classpath>
</AS3Classpath> </AS3Classpath>

View File

@ -4,5 +4,5 @@
<AS3Classpath generateProblems="true" sdkBased="false" type="source" useAsSharedCode="false">src</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="false" type="source" useAsSharedCode="false">src</AS3Classpath>
<AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/spine-as3.swc</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/spine-as3.swc</AS3Classpath>
<AS3Classpath generateProblems="true" sdkBased="true" type="lib" useAsSharedCode="false">frameworks/libs/air/airglobal.swc</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="true" type="lib" useAsSharedCode="false">frameworks/libs/air/airglobal.swc</AS3Classpath>
<AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/starling-2.1.swc</AS3Classpath> <AS3Classpath generateProblems="true" sdkBased="false" type="lib" useAsSharedCode="false">lib/starling-2.4.swc</AS3Classpath>
</AS3Classpath> </AS3Classpath>

Binary file not shown.

View File

@ -29,6 +29,7 @@
*****************************************************************************/ *****************************************************************************/
package spine.starling { package spine.starling {
import starling.styles.MeshStyle;
import spine.attachments.ClippingAttachment; import spine.attachments.ClippingAttachment;
import spine.SkeletonClipping; import spine.SkeletonClipping;
import spine.Bone; import spine.Bone;
@ -98,6 +99,7 @@ package spine.starling {
for (var i : int = 0, n : int = drawOrder.length; i < n; ++i) { for (var i : int = 0, n : int = drawOrder.length; i < n; ++i) {
var worldVertices : Vector.<Number> = _tempVertices; var worldVertices : Vector.<Number> = _tempVertices;
var slot : Slot = drawOrder[i]; var slot : Slot = drawOrder[i];
if (slot.attachment is RegionAttachment) { if (slot.attachment is RegionAttachment) {
var region : RegionAttachment = slot.attachment as RegionAttachment; var region : RegionAttachment = slot.attachment as RegionAttachment;
verticesLength = 4 * 2; verticesLength = 4 * 2;
@ -146,7 +148,7 @@ package spine.starling {
indexData.numIndices = indicesLength; indexData.numIndices = indicesLength;
indexData.trim(); indexData.trim();
} }
indexData = mesh.getIndexData(); indexData = mesh.getIndexData();
attachmentColor = meshAttachment.color; attachmentColor = meshAttachment.color;
uvs = meshAttachment.uvs; uvs = meshAttachment.uvs;
} else if (slot.attachment is ClippingAttachment) { } else if (slot.attachment is ClippingAttachment) {
@ -169,17 +171,22 @@ package spine.starling {
if (clipper.isClipping()) { if (clipper.isClipping()) {
clipper.clipTriangles(worldVertices, indices, indices.length, uvs); clipper.clipTriangles(worldVertices, indices, indices.length, uvs);
// Need to create a new mesh here, see https://github.com/EsotericSoftware/spine-runtimes/issues/1125
mesh = new SkeletonMesh(mesh.texture);
if (_twoColorTint) mesh.setStyle(new TwoColorMeshStyle());
indexData = mesh.getIndexData();
verticesCount = clipper.clippedVertices.length >> 1; verticesCount = clipper.clippedVertices.length >> 1;
worldVertices = clipper.clippedVertices; worldVertices = clipper.clippedVertices;
uvs = clipper.clippedUvs; uvs = clipper.clippedUvs;
indices = clipper.clippedTriangles; indices = clipper.clippedTriangles;
indicesLength = indices.length; indicesLength = indices.length;
indexData.numIndices = indicesLength;
indexData.trim();
for (ii = 0; ii < indicesLength; ii++) { for (ii = 0; ii < indicesLength; ii++) {
indexData.setIndex(ii, indices[ii]); indexData.setIndex(ii, indices[ii]);
} }
indexData.numIndices = indicesLength;
indexData.trim();
} }
vertexData = mesh.getVertexData(); vertexData = mesh.getVertexData();
@ -214,8 +221,10 @@ package spine.starling {
mesh.setTexCoords(ii, uvs[iii], uvs[iii + 1]); mesh.setTexCoords(ii, uvs[iii], uvs[iii + 1]);
} }
} }
painter.state.blendMode = blendModes[slot.data.blendMode.ordinal]; if (indexData.numIndices > 0 && vertexData.numVertices > 0) {
painter.batchMesh(mesh); painter.state.blendMode = blendModes[slot.data.blendMode.ordinal];
painter.batchMesh(mesh);
}
clipper.clipEndWithSlot(slot); clipper.clipEndWithSlot(slot);
} }

View File

@ -682,6 +682,7 @@ namespace Spine.Unity.Editor {
List<Spine.Event> currentAnimationEvents = new List<Spine.Event>(); List<Spine.Event> currentAnimationEvents = new List<Spine.Event>();
List<float> currentAnimationEventTimes = new List<float>(); List<float> currentAnimationEventTimes = new List<float>();
List<SpineEventTooltip> currentAnimationEventTooltips = new List<SpineEventTooltip>();
public bool IsValid { get { return skeletonAnimation != null && skeletonAnimation.valid; } } public bool IsValid { get { return skeletonAnimation != null && skeletonAnimation.valid; } }
@ -1071,7 +1072,7 @@ namespace Spine.Unity.Editor {
int loopCount = (int)(t.TrackTime / t.TrackEnd); int loopCount = (int)(t.TrackTime / t.TrackEnd);
float currentTime = t.TrackTime - (t.TrackEnd * loopCount); float currentTime = t.TrackTime - (t.TrackEnd * loopCount);
float normalizedTime = currentTime / t.Animation.Duration; float normalizedTime = currentTime / t.Animation.Duration;
float wrappedTime = normalizedTime % 1; float wrappedTime = normalizedTime % 1f;
lineRect.x = barRect.x + (lineRectWidth * wrappedTime) - 0.5f; lineRect.x = barRect.x + (lineRectWidth * wrappedTime) - 0.5f;
lineRect.width = 2; lineRect.width = 2;
@ -1080,11 +1081,13 @@ namespace Spine.Unity.Editor {
GUI.DrawTexture(lineRect, EditorGUIUtility.whiteTexture); GUI.DrawTexture(lineRect, EditorGUIUtility.whiteTexture);
GUI.color = Color.white; GUI.color = Color.white;
currentAnimationEventTooltips = currentAnimationEventTooltips ?? new List<SpineEventTooltip>();
currentAnimationEventTooltips.Clear();
for (int i = 0; i < currentAnimationEvents.Count; i++) { for (int i = 0; i < currentAnimationEvents.Count; i++) {
float fr = currentAnimationEventTimes[i]; float eventTime = currentAnimationEventTimes[i];
var userEventIcon = Icons.userEvent; var userEventIcon = Icons.userEvent;
var evRect = new Rect(barRect) { var evRect = new Rect(barRect) {
x = Mathf.Clamp(((fr / t.Animation.Duration) * lineRectWidth) - (userEventIcon.width / 2), barRect.x, float.MaxValue), x = Mathf.Max(((eventTime / t.Animation.Duration) * lineRectWidth) - (userEventIcon.width / 2), barRect.x),
y = barRect.y + userEventIcon.height, y = barRect.y + userEventIcon.height,
width = userEventIcon.width, width = userEventIcon.width,
height = userEventIcon.height height = userEventIcon.height
@ -1094,16 +1097,29 @@ namespace Spine.Unity.Editor {
Event ev = Event.current; Event ev = Event.current;
if (ev.type == EventType.Repaint) { if (ev.type == EventType.Repaint) {
if (evRect.Contains(ev.mousePosition)) { if (evRect.Contains(ev.mousePosition)) {
GUIStyle tooltipStyle = EditorStyles.helpBox; string eventName = currentAnimationEvents[i].Data.Name;
Rect tooltipRect = new Rect(evRect); Rect tooltipRect = new Rect(evRect) {
tooltipRect.width = tooltipStyle.CalcSize(new GUIContent(currentAnimationEvents[i].Data.Name)).x; width = EditorStyles.helpBox.CalcSize(new GUIContent(eventName)).x
};
tooltipRect.y -= 4; tooltipRect.y -= 4;
tooltipRect.y -= tooltipRect.height * currentAnimationEventTooltips.Count; // Avoid several overlapping tooltips.
tooltipRect.x += 4; tooltipRect.x += 4;
GUI.Label(tooltipRect, currentAnimationEvents[i].Data.Name, tooltipStyle);
GUI.tooltip = currentAnimationEvents[i].Data.Name; // Handle tooltip overflowing to the right.
float rightEdgeOverflow = (tooltipRect.x + tooltipRect.width) - (barRect.x + barRect.width);
if (rightEdgeOverflow > 0)
tooltipRect.x -= rightEdgeOverflow;
currentAnimationEventTooltips.Add(new SpineEventTooltip { rect = tooltipRect, text = eventName });
} }
} }
} }
// Draw tooltips.
for (int i = 0; i < currentAnimationEventTooltips.Count; i++) {
GUI.Label(currentAnimationEventTooltips[i].rect, currentAnimationEventTooltips[i].text, EditorStyles.helpBox);
GUI.tooltip = currentAnimationEventTooltips[i].text;
}
} }
} }
@ -1130,7 +1146,11 @@ namespace Spine.Unity.Editor {
previewGameObject = null; previewGameObject = null;
} }
} }
internal struct SpineEventTooltip {
public Rect rect;
public string text;
}
} }
} }