mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Various fixes.
This commit is contained in:
parent
9a7673c68a
commit
f71fb43552
@ -176,27 +176,27 @@ public class SkeletonJson {
|
|||||||
var color:String, vertices:Vector.<Number>;
|
var color:String, vertices:Vector.<Number>;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AttachmentType.region:
|
case AttachmentType.region:
|
||||||
var regionAttachment:RegionAttachment = attachmentLoader.newRegionAttachment(skin, name, path);
|
var region:RegionAttachment = attachmentLoader.newRegionAttachment(skin, name, path);
|
||||||
if (!regionAttachment) return null;
|
if (!region) return null;
|
||||||
regionAttachment.path = path;
|
region.path = path;
|
||||||
regionAttachment.x = (map["x"] || 0) * scale;
|
region.x = (map["x"] || 0) * scale;
|
||||||
regionAttachment.y = (map["y"] || 0) * scale;
|
region.y = (map["y"] || 0) * scale;
|
||||||
regionAttachment.scaleX = map.hasOwnProperty("scaleX") ? map["scaleX"] : 1;
|
region.scaleX = map.hasOwnProperty("scaleX") ? map["scaleX"] : 1;
|
||||||
regionAttachment.scaleY = map.hasOwnProperty("scaleY") ? map["scaleY"] : 1;
|
region.scaleY = map.hasOwnProperty("scaleY") ? map["scaleY"] : 1;
|
||||||
regionAttachment.rotation = map["rotation"] || 0;
|
region.rotation = map["rotation"] || 0;
|
||||||
regionAttachment.width = (map["width"] || 0) * scale;
|
region.width = (map["width"] || 0) * scale;
|
||||||
regionAttachment.height = (map["height"] || 0) * scale;
|
region.height = (map["height"] || 0) * scale;
|
||||||
|
|
||||||
color = map["color"];
|
color = map["color"];
|
||||||
if (color) {
|
if (color) {
|
||||||
regionAttachment.r = toColor(color, 0);
|
region.r = toColor(color, 0);
|
||||||
regionAttachment.g = toColor(color, 1);
|
region.g = toColor(color, 1);
|
||||||
regionAttachment.b = toColor(color, 2);
|
region.b = toColor(color, 2);
|
||||||
regionAttachment.a = toColor(color, 3);
|
region.a = toColor(color, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
regionAttachment.updateOffset();
|
region.updateOffset();
|
||||||
return regionAttachment;
|
return region;
|
||||||
|
|
||||||
case AttachmentType.mesh:
|
case AttachmentType.mesh:
|
||||||
var mesh:MeshAttachment = attachmentLoader.newMeshAttachment(skin, name, path);
|
var mesh:MeshAttachment = attachmentLoader.newMeshAttachment(skin, name, path);
|
||||||
@ -205,7 +205,7 @@ public class SkeletonJson {
|
|||||||
mesh.vertices = getFloatArray(map, "vertices", scale);
|
mesh.vertices = getFloatArray(map, "vertices", scale);
|
||||||
mesh.triangles = getIntArray(map, "triangles");
|
mesh.triangles = getIntArray(map, "triangles");
|
||||||
mesh.regionUVs = getFloatArray(map, "uvs", 1);
|
mesh.regionUVs = getFloatArray(map, "uvs", 1);
|
||||||
mesh.UpdateUVs();
|
mesh.updateUVs();
|
||||||
|
|
||||||
color = map["color"];
|
color = map["color"];
|
||||||
if (color) {
|
if (color) {
|
||||||
@ -216,15 +216,15 @@ public class SkeletonJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mesh.hullLength = (map["hull"] || 0) * 2;
|
mesh.hullLength = (map["hull"] || 0) * 2;
|
||||||
if (map["edges"]) mesh.Edges = getIntArray(map, "edges");
|
if (map["edges"]) mesh.edges = getIntArray(map, "edges");
|
||||||
mesh.width = (map["width"] || 0) * scale;
|
mesh.width = (map["width"] || 0) * scale;
|
||||||
mesh.height = (map["height"] || 0) * scale;
|
mesh.height = (map["height"] || 0) * scale;
|
||||||
return mesh;
|
return mesh;
|
||||||
case AttachmentType.skinnedmesh:
|
case AttachmentType.skinnedmesh:
|
||||||
var skinnedMesh:SkinnedMeshAttachment = attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
|
var skinnedMesh:SkinnedMeshAttachment = attachmentLoader.newSkinnedMeshAttachment(skin, name, path);
|
||||||
if (!skinnedMesh) return null;
|
if (!skinnedMesh) return null;
|
||||||
|
skinnedMesh.path = path;
|
||||||
|
|
||||||
skinnedMesh.Path = path;
|
|
||||||
var uvs:Vector.<Number> = getFloatArray(map, "uvs", 1);
|
var uvs:Vector.<Number> = getFloatArray(map, "uvs", 1);
|
||||||
vertices = getFloatArray(map, "vertices", 1);
|
vertices = getFloatArray(map, "vertices", 1);
|
||||||
var weights:Vector.<Number> = new Vector.<Number>();
|
var weights:Vector.<Number> = new Vector.<Number>();
|
||||||
@ -255,7 +255,7 @@ public class SkeletonJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
skinnedMesh.hullLength = (map["hull"] || 0) * 2;
|
skinnedMesh.hullLength = (map["hull"] || 0) * 2;
|
||||||
if (map["edges"]) skinnedMesh.Edges = getIntArray(map, "edges");
|
if (map["edges"]) skinnedMesh.edges = getIntArray(map, "edges");
|
||||||
skinnedMesh.width = (map["width"] || 0) * scale;
|
skinnedMesh.width = (map["width"] || 0) * scale;
|
||||||
skinnedMesh.height = (map["height"] || 0) * scale;
|
skinnedMesh.height = (map["height"] || 0) * scale;
|
||||||
return skinnedMesh;
|
return skinnedMesh;
|
||||||
@ -383,7 +383,7 @@ public class SkeletonJson {
|
|||||||
ffdTimeline.slotIndex = slotIndex;
|
ffdTimeline.slotIndex = slotIndex;
|
||||||
ffdTimeline.attachment = attachment;
|
ffdTimeline.attachment = attachment;
|
||||||
|
|
||||||
var vertexCount:int ;
|
var vertexCount:int;
|
||||||
if (attachment is MeshAttachment)
|
if (attachment is MeshAttachment)
|
||||||
vertexCount = (attachment as MeshAttachment).vertices.length;
|
vertexCount = (attachment as MeshAttachment).vertices.length;
|
||||||
else
|
else
|
||||||
@ -501,7 +501,7 @@ public class SkeletonJson {
|
|||||||
|
|
||||||
static private function getFloatArray (map:Object, name:String, scale:Number) : Vector.<Number> {
|
static private function getFloatArray (map:Object, name:String, scale:Number) : Vector.<Number> {
|
||||||
var list:Array = map[name];
|
var list:Array = map[name];
|
||||||
var values:Vector.<Number> = new Vector.<Number>(list.Count, true);
|
var values:Vector.<Number> = new Vector.<Number>(list.length, true);
|
||||||
var i:int = 0, n:int = list.length;
|
var i:int = 0, n:int = list.length;
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
for (; i < n; i++)
|
for (; i < n; i++)
|
||||||
@ -515,7 +515,7 @@ public class SkeletonJson {
|
|||||||
|
|
||||||
static private function getIntArray (map:Object, name:String) : Vector.<int> {
|
static private function getIntArray (map:Object, name:String) : Vector.<int> {
|
||||||
var list:Array = map[name];
|
var list:Array = map[name];
|
||||||
var values:Vector.<int> = new Vector.<int>(list.Count, true);
|
var values:Vector.<int> = new Vector.<int>(list.length, true);
|
||||||
for (var i:int = 0, n:int = list.length; i < n; i++)
|
for (var i:int = 0, n:int = list.length; i < n; i++)
|
||||||
values[i] = int(list[i]);
|
values[i] = int(list[i]);
|
||||||
return values;
|
return values;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class FfdTimeline extends CurveTimeline {
|
|||||||
|
|
||||||
var i:int;
|
var i:int;
|
||||||
if (time >= frames[frames.length - 1]) { // Time is after last frame.
|
if (time >= frames[frames.length - 1]) { // Time is after last frame.
|
||||||
var lastVertices:Vector.<Number> = frameVertices[frames.length - 1];
|
var lastVertices:Vector.<Number> = frameVertices[int(frames.length - 1)];
|
||||||
if (alpha < 1) {
|
if (alpha < 1) {
|
||||||
for (i = 0; i < vertexCount; i++)
|
for (i = 0; i < vertexCount; i++)
|
||||||
vertices[i] += (lastVertices[i] - vertices[i]) * alpha;
|
vertices[i] += (lastVertices[i] - vertices[i]) * alpha;
|
||||||
@ -88,10 +88,10 @@ public class FfdTimeline extends CurveTimeline {
|
|||||||
// Interpolate between the previous frame and the current frame.
|
// Interpolate between the previous frame and the current frame.
|
||||||
var frameIndex:int = Animation.binarySearch(frames, time, 1);
|
var frameIndex:int = Animation.binarySearch(frames, time, 1);
|
||||||
var frameTime:Number = frames[frameIndex];
|
var frameTime:Number = frames[frameIndex];
|
||||||
var percent:Number = 1 - (time - frameTime) / (frames[frameIndex - 1] - frameTime);
|
var percent:Number = 1 - (time - frameTime) / (frames[int(frameIndex - 1)] - frameTime);
|
||||||
percent = getCurvePercent(frameIndex - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
percent = getCurvePercent(frameIndex - 1, percent < 0 ? 0 : (percent > 1 ? 1 : percent));
|
||||||
|
|
||||||
var prevVertices:Vector.<Number> = frameVertices[frameIndex - 1];
|
var prevVertices:Vector.<Number> = frameVertices[int(frameIndex - 1)];
|
||||||
var nextVertices:Vector.<Number> = frameVertices[frameIndex];
|
var nextVertices:Vector.<Number> = frameVertices[frameIndex];
|
||||||
|
|
||||||
var prev:Number;
|
var prev:Number;
|
||||||
|
|||||||
@ -66,19 +66,19 @@ public dynamic class MeshAttachment extends Attachment {
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UpdateUVs () : void {
|
public function updateUVs () : void {
|
||||||
var width:Number = regionU2 - regionU, height:Number = regionV2 - regionV;
|
var width:Number = regionU2 - regionU, height:Number = regionV2 - regionV;
|
||||||
if (!uvs || uvs.length != regionUVs.length) uvs = new Vector.<Number>(regionUVs.length, true);
|
|
||||||
var i:int, n:int = uvs.length;
|
var i:int, n:int = uvs.length;
|
||||||
|
if (!uvs || uvs.length != n) uvs = new Vector.<Number>(n, true);
|
||||||
if (regionRotate) {
|
if (regionRotate) {
|
||||||
for (i = 0; i < n; i += 2) {
|
for (i = 0; i < n; i += 2) {
|
||||||
uvs[i] = regionU + regionUVs[i + 1] * width;
|
uvs[i] = regionU + regionUVs[int(i + 1)] * width;
|
||||||
uvs[i + 1] = regionV + height - regionUVs[i] * height;
|
uvs[int(i + 1)] = regionV + height - regionUVs[i] * height;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < n; i += 2) {
|
for (i = 0; i < n; i += 2) {
|
||||||
uvs[i] = regionU + regionUVs[i] * width;
|
uvs[i] = regionU + regionUVs[i] * width;
|
||||||
uvs[i + 1] = regionV + regionUVs[i + 1] * height;
|
uvs[int(i + 1)] = regionV + regionUVs[int(i + 1)] * height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,11 +94,11 @@ public dynamic class MeshAttachment extends Attachment {
|
|||||||
var vertices:Vector.<Number> = this.vertices;
|
var vertices:Vector.<Number> = this.vertices;
|
||||||
var verticesCount:int = vertices.length;
|
var verticesCount:int = vertices.length;
|
||||||
if (slot.attachmentVertices.length == verticesCount) vertices = slot.attachmentVertices;
|
if (slot.attachmentVertices.length == verticesCount) vertices = slot.attachmentVertices;
|
||||||
for (var i:int = 0; i < verticesCount; i += 2) {
|
for (var i:int = 0, ii:int = 0; i < verticesCount; i += 2, ii += 2) {
|
||||||
var vx:Number = vertices[i];
|
var vx:Number = vertices[i];
|
||||||
var vy:Number = vertices[i + 1];
|
var vy:Number = vertices[ii];
|
||||||
worldVertices[i] = vx * m00 + vy * m01 + x;
|
worldVertices[i] = vx * m00 + vy * m01 + x;
|
||||||
worldVertices[i + 1] = vx * m10 + vy * m11 + y;
|
worldVertices[ii] = vx * m10 + vy * m11 + y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,19 +67,19 @@ public dynamic class SkinnedMeshAttachment extends Attachment {
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function UpdateUVs () : void {
|
public function updateUVs () : void {
|
||||||
var width:Number = regionU2 - regionU, height:Number = regionV2 - regionV;
|
var width:Number = regionU2 - regionU, height:Number = regionV2 - regionV;
|
||||||
if (!uvs || uvs.length != regionUVs.length) uvs = new Vector.<Number>(regionUVs.length, true);
|
|
||||||
var i:int, n:int = uvs.length;
|
var i:int, n:int = uvs.length;
|
||||||
|
if (!uvs || uvs.length != n) uvs = new Vector.<Number>(n, true);
|
||||||
if (regionRotate) {
|
if (regionRotate) {
|
||||||
for (i = 0; i < n; i += 2) {
|
for (i = 0; i < n; i += 2) {
|
||||||
uvs[i] = regionU + regionUVs[i + 1] * width;
|
uvs[i] = regionU + regionUVs[int(i + 1)] * width;
|
||||||
uvs[i + 1] = regionV + height - regionUVs[i] * height;
|
uvs[int(i + 1)] = regionV + height - regionUVs[i] * height;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < n; i += 2) {
|
for (i = 0; i < n; i += 2) {
|
||||||
uvs[i] = regionU + regionUVs[i] * width;
|
uvs[i] = regionU + regionUVs[i] * width;
|
||||||
uvs[i + 1] = regionV + regionUVs[i + 1] * height;
|
uvs[int(i + 1)] = regionV + regionUVs[int(i + 1)] * height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,13 +99,13 @@ public dynamic class SkinnedMeshAttachment extends Attachment {
|
|||||||
for (; v < nn; v++, b += 3) {
|
for (; v < nn; v++, b += 3) {
|
||||||
bone = skeletonBones[bones[v]];
|
bone = skeletonBones[bones[v]];
|
||||||
vx = weights[b];
|
vx = weights[b];
|
||||||
vy = weights[b + 1];
|
vy = weights[int(b + 1)];
|
||||||
weight = weights[b + 2];
|
weight = weights[int(b + 2)];
|
||||||
wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight;
|
wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight;
|
||||||
wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight;
|
wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight;
|
||||||
}
|
}
|
||||||
worldVertices[w] = wx + x;
|
worldVertices[w] = wx + x;
|
||||||
worldVertices[w + 1] = wy + y;
|
worldVertices[int(w + 1)] = wy + y;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var ffd:Vector.<Number> = slot.attachmentVertices;
|
var ffd:Vector.<Number> = slot.attachmentVertices;
|
||||||
@ -116,13 +116,13 @@ public dynamic class SkinnedMeshAttachment extends Attachment {
|
|||||||
for (; v < nn; v++, b += 3, f += 2) {
|
for (; v < nn; v++, b += 3, f += 2) {
|
||||||
bone = skeletonBones[bones[v]];
|
bone = skeletonBones[bones[v]];
|
||||||
vx = weights[b] + ffd[f];
|
vx = weights[b] + ffd[f];
|
||||||
vy = weights[b + 1] + ffd[f + 1];
|
vy = weights[int(b + 1)] + ffd[int(f + 1)];
|
||||||
weight = weights[b + 2];
|
weight = weights[int(b + 2)];
|
||||||
wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight;
|
wx += (vx * bone.m00 + vy * bone.m01 + bone.worldX) * weight;
|
||||||
wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight;
|
wy += (vx * bone.m10 + vy * bone.m11 + bone.worldY) * weight;
|
||||||
}
|
}
|
||||||
worldVertices[w] = wx + x;
|
worldVertices[w] = wx + x;
|
||||||
worldVertices[w + 1] = wy + y;
|
worldVertices[int(w + 1)] = wy + y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user