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); fseek(file, 0, SEEK_SET);
data = MALLOC(char, *length); data = MALLOC(char, *length);
fread(data, 1, *length, file); size_t result = fread(data, 1, *length, file);
UNUSED(result);
fclose(file); fclose(file);
return data; return data;

View File

@ -31,6 +31,7 @@
#define Spine_SkeletonBounds_h #define Spine_SkeletonBounds_h
#include <spine/Vector.h> #include <spine/Vector.h>
#include <spine/Pool.h>
#include <spine/SpineObject.h> #include <spine/SpineObject.h>
namespace spine { namespace spine {
@ -43,6 +44,7 @@ namespace spine {
class SP_API SkeletonBounds : public SpineObject { class SP_API SkeletonBounds : public SpineObject {
public: public:
SkeletonBounds(); SkeletonBounds();
~SkeletonBounds();
/// Clears any previous polygons, finds all visible bounding box attachments, /// Clears any previous polygons, finds all visible bounding box attachments,
/// and computes the world vertices for each bounding box's polygon. /// and computes the world vertices for each bounding box's polygon.
@ -82,7 +84,7 @@ namespace spine {
float getHeight(); float getHeight();
private: private:
Vector<Polygon*> _polygonPool; Pool<Polygon> _polygonPool;
Vector<BoundingBoxAttachment*> _boundingBoxes; Vector<BoundingBoxAttachment*> _boundingBoxes;
Vector<Polygon*> _polygons; Vector<Polygon*> _polygons;
float _minX, _minY, _maxX, _maxY; 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() : _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) { void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
Vector<Slot *> &slots = skeleton._slots; Vector<Slot *> &slots = skeleton.getSlots();
size_t slotCount = slots.size(); size_t slotCount = slots.size();
_boundingBoxes.clear(); _boundingBoxes.clear();
for (size_t i = 0, n = _polygons.size(); i < n; ++i) { for (size_t i = 0, n = _polygons.size(); i < n; ++i) {
_polygonPool.add(_polygons[i]); _polygonPool.free(_polygons[i]);
} }
_polygons.clear(); _polygons.clear();
@ -66,14 +72,7 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
BoundingBoxAttachment *boundingBox = static_cast<BoundingBoxAttachment *>(attachment); BoundingBoxAttachment *boundingBox = static_cast<BoundingBoxAttachment *>(attachment);
_boundingBoxes.add(boundingBox); _boundingBoxes.add(boundingBox);
spine::Polygon *polygonP = NULL; spine::Polygon *polygonP = _polygonPool.obtain();
size_t poolCount = _polygonPool.size();
if (poolCount > 0) {
polygonP = _polygonPool[poolCount - 1];
_polygonPool.removeAt(poolCount - 1);
} else
polygonP = new(__FILE__, __LINE__) Polygon();
_polygons.add(polygonP); _polygons.add(polygonP);
Polygon &polygon = *polygonP; Polygon &polygon = *polygonP;