Merge branch '3.8' into 3.9-beta

This commit is contained in:
badlogic 2020-04-13 11:20:42 +02:00
commit f0ab1da1b7
3 changed files with 14 additions and 12 deletions

View File

@ -92,7 +92,8 @@ char* _spReadFile (const char* path, int* length) {
fseek(file, 0, SEEK_SET);
data = MALLOC(char, *length);
fread(data, 1, *length, file);
size_t result = fread(data, 1, *length, file);
UNUSED(result);
fclose(file);
return data;

View File

@ -31,6 +31,7 @@
#define Spine_SkeletonBounds_h
#include <spine/Vector.h>
#include <spine/Pool.h>
#include <spine/SpineObject.h>
namespace spine {
@ -43,6 +44,7 @@ namespace spine {
class SP_API SkeletonBounds : public SpineObject {
public:
SkeletonBounds();
~SkeletonBounds();
/// Clears any previous polygons, finds all visible bounding box attachments,
/// and computes the world vertices for each bounding box's polygon.
@ -82,7 +84,7 @@ namespace spine {
float getHeight();
private:
Vector<Polygon*> _polygonPool;
Pool<Polygon> _polygonPool;
Vector<BoundingBoxAttachment*> _boundingBoxes;
Vector<Polygon*> _polygons;
float _minX, _minY, _maxX, _maxY;

View File

@ -46,13 +46,19 @@ using namespace spine;
SkeletonBounds::SkeletonBounds() : _minX(0), _minY(0), _maxX(0), _maxY(0) {
}
SkeletonBounds::~SkeletonBounds() {
for (size_t i = 0, n = _polygons.size(); i < n; i++)
_polygonPool.free(_polygons[i]);
_polygons.clear();
}
void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
Vector<Slot *> &slots = skeleton._slots;
Vector<Slot *> &slots = skeleton.getSlots();
size_t slotCount = slots.size();
_boundingBoxes.clear();
for (size_t i = 0, n = _polygons.size(); i < n; ++i) {
_polygonPool.add(_polygons[i]);
_polygonPool.free(_polygons[i]);
}
_polygons.clear();
@ -66,14 +72,7 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
BoundingBoxAttachment *boundingBox = static_cast<BoundingBoxAttachment *>(attachment);
_boundingBoxes.add(boundingBox);
spine::Polygon *polygonP = NULL;
size_t poolCount = _polygonPool.size();
if (poolCount > 0) {
polygonP = _polygonPool[poolCount - 1];
_polygonPool.removeAt(poolCount - 1);
} else
polygonP = new(__FILE__, __LINE__) Polygon();
spine::Polygon *polygonP = _polygonPool.obtain();
_polygons.add(polygonP);
Polygon &polygon = *polygonP;