mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Scale bounding boxes on load.
This commit is contained in:
parent
0c5e3b4400
commit
b132231034
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user