Scale bounding boxes on load.

This commit is contained in:
NathanSweet 2013-09-28 23:33:41 +02:00
parent 0c5e3b4400
commit b132231034
3 changed files with 7 additions and 7 deletions

View File

@ -464,7 +464,7 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
box->verticesCount = verticesArray->size; box->verticesCount = verticesArray->size;
box->vertices = MALLOC(float, verticesArray->size); box->vertices = MALLOC(float, verticesArray->size);
for (vertex = verticesArray->child, i = 0; vertex; vertex = vertex->next, ++i) for (vertex = verticesArray->child, i = 0; vertex; vertex = vertex->next, ++i)
box->vertices[i] = vertex->valueFloat; box->vertices[i] = vertex->valueFloat * self->scale;
break; break;
} }
} }

View File

@ -212,7 +212,7 @@ namespace Spine {
List<Object> values = (List<Object>)map["vertices"]; List<Object> values = (List<Object>)map["vertices"];
float[] vertices = new float[values.Count]; float[] vertices = new float[values.Count];
for (int i = 0, n = values.Count; i < n; i++) for (int i = 0, n = values.Count; i < n; i++)
vertices[i] = (float)values[i]; vertices[i] = (float)values[i] * scale;
boundingBox.Vertices = vertices; boundingBox.Vertices = vertices;
} }

View File

@ -197,12 +197,12 @@ public class SkeletonJson {
} else if (attachment instanceof BoundingBoxAttachment) { } else if (attachment instanceof BoundingBoxAttachment) {
BoundingBoxAttachment box = (BoundingBoxAttachment)attachment; BoundingBoxAttachment box = (BoundingBoxAttachment)attachment;
JsonValue pointsArray = map.require("vertices"); JsonValue verticesArray = map.require("vertices");
float[] points = new float[pointsArray.size]; float[] vertices = new float[verticesArray.size];
int i = 0; int i = 0;
for (JsonValue point = pointsArray.child; point != null; point = point.next()) for (JsonValue point = verticesArray.child; point != null; point = point.next())
points[i++] = point.asFloat(); vertices[i++] = point.asFloat() * scale;
box.setVertices(points); box.setVertices(vertices);
} }
return attachment; return attachment;