[cpp] First Clang-Tidy run.

This commit is contained in:
badlogic 2018-02-16 17:36:07 +01:00
parent 895407b69d
commit a8af3fa07e
56 changed files with 178 additions and 183 deletions

View File

@ -3,8 +3,8 @@ project(spine_cpp_unit_test)
set(CMAKE_INSTALL_PREFIX "./") set(CMAKE_INSTALL_PREFIX "./")
set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti")
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wall -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti") set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti")
include_directories(../spine-cpp/include teamcity minicppunit tests memory) include_directories(../spine-cpp/include teamcity minicppunit tests memory)

View File

@ -78,7 +78,7 @@ void Spine::TestSpineExtension::reportLeaks() {
for (std::vector<Allocation>::iterator it = allocated.begin(); it != allocated.end(); it++) { for (std::vector<Allocation>::iterator it = allocated.begin(); it != allocated.end(); it++) {
printf("\"%s:%i (%zu bytes at %p)\n", it->fileName, it->line, it->size, it->address); printf("\"%s:%i (%zu bytes at %p)\n", it->fileName, it->line, it->size, it->address);
} }
if (allocated.size() == 0) printf("No leaks detected"); if (allocated.empty()) printf("No leaks detected");
} }
void Spine::TestSpineExtension::clearAllocations() { void Spine::TestSpineExtension::clearAllocations() {

View File

@ -42,7 +42,7 @@ namespace Spine {
const char* fileName; const char* fileName;
int line; int line;
Allocation() : address(0), size(0), fileName(0), line(0) { Allocation() : address(NULL), size(0), fileName(NULL), line(0) {
} }
Allocation(void* a, size_t s, const char* f, int l) : address(a), size(s), fileName(f), line(l) { Allocation(void* a, size_t s, const char* f, int l) : address(a), size(s), fileName(f), line(l) {

View File

@ -45,36 +45,36 @@
using namespace Spine; using namespace Spine;
void loadBinary(const char* binaryFile, const char* atlasFile, Atlas* &atlas, SkeletonData* &skeletonData, AnimationStateData* &stateData, Skeleton* &skeleton, AnimationState* &state) { void loadBinary(const char* binaryFile, const char* atlasFile, Atlas* &atlas, SkeletonData* &skeletonData, AnimationStateData* &stateData, Skeleton* &skeleton, AnimationState* &state) {
atlas = new (__FILE__, __LINE__) Atlas(atlasFile, 0); atlas = new (__FILE__, __LINE__) Atlas(atlasFile, NULL);
assert(atlas != 0); assert(atlas != NULL);
SkeletonBinary binary(atlas); SkeletonBinary binary(atlas);
skeletonData = binary.readSkeletonDataFile(binaryFile); skeletonData = binary.readSkeletonDataFile(binaryFile);
assert(skeletonData); assert(skeletonData);
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData); skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
assert(skeleton != 0); assert(skeleton != NULL);
stateData = new (__FILE__, __LINE__) AnimationStateData(skeletonData); stateData = new (__FILE__, __LINE__) AnimationStateData(skeletonData);
assert(stateData != 0); assert(stateData != NULL);
stateData->setDefaultMix(0.4f); stateData->setDefaultMix(0.4f);
state = new (__FILE__, __LINE__) AnimationState(stateData); state = new (__FILE__, __LINE__) AnimationState(stateData);
} }
void loadJson(const char* jsonFile, const char* atlasFile, Atlas* &atlas, SkeletonData* &skeletonData, AnimationStateData* &stateData, Skeleton* &skeleton, AnimationState* &state) { void loadJson(const char* jsonFile, const char* atlasFile, Atlas* &atlas, SkeletonData* &skeletonData, AnimationStateData* &stateData, Skeleton* &skeleton, AnimationState* &state) {
atlas = new (__FILE__, __LINE__) Atlas(atlasFile, 0); atlas = new (__FILE__, __LINE__) Atlas(atlasFile, NULL);
assert(atlas != 0); assert(atlas != NULL);
SkeletonJson json(atlas); SkeletonJson json(atlas);
skeletonData = json.readSkeletonDataFile(jsonFile); skeletonData = json.readSkeletonDataFile(jsonFile);
assert(skeletonData); assert(skeletonData);
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData); skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
assert(skeleton != 0); assert(skeleton != NULL);
stateData = new (__FILE__, __LINE__) AnimationStateData(skeletonData); stateData = new (__FILE__, __LINE__) AnimationStateData(skeletonData);
assert(stateData != 0); assert(stateData != NULL);
stateData->setDefaultMix(0.4f); stateData->setDefaultMix(0.4f);
state = new (__FILE__, __LINE__) AnimationState(stateData); state = new (__FILE__, __LINE__) AnimationState(stateData);
@ -89,11 +89,11 @@ void dispose(Atlas* atlas, SkeletonData* skeletonData, AnimationStateData* state
} }
void reproduceIssue_776() { void reproduceIssue_776() {
Atlas* atlas = 0; Atlas* atlas = NULL;
SkeletonData* skeletonData = 0; SkeletonData* skeletonData = NULL;
AnimationStateData* stateData = 0; AnimationStateData* stateData = NULL;
Skeleton* skeleton = 0; Skeleton* skeleton = NULL;
AnimationState* state = 0; AnimationState* state = NULL;
loadJson(R_JSON, R_ATLAS, atlas, skeletonData, stateData, skeleton, state); loadJson(R_JSON, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
dispose(atlas, skeletonData, stateData, skeleton, state); dispose(atlas, skeletonData, stateData, skeleton, state);

View File

@ -289,7 +289,7 @@ namespace Spine {
friend class EventQueue; friend class EventQueue;
public: public:
AnimationState(AnimationStateData* data); explicit AnimationState(AnimationStateData* data);
~AnimationState(); ~AnimationState();

View File

@ -53,7 +53,7 @@ namespace Spine {
float getDefaultMix(); float getDefaultMix();
void setDefaultMix(float inValue); void setDefaultMix(float inValue);
AnimationStateData(SkeletonData* skeletonData); explicit AnimationStateData(SkeletonData* skeletonData);
/// Sets a mix duration by animation names. /// Sets a mix duration by animation names.
void setMix(const String& fromName, const String& toName, float duration); void setMix(const String& fromName, const String& toName, float duration);
@ -74,7 +74,7 @@ namespace Spine {
Animation* _a1; Animation* _a1;
Animation* _a2; Animation* _a2;
AnimationPair(Animation* a1 = NULL, Animation* a2 = NULL); explicit AnimationPair(Animation* a1 = NULL, Animation* a2 = NULL);
bool operator==(const AnimationPair &other) const; bool operator==(const AnimationPair &other) const;
}; };

View File

@ -74,7 +74,10 @@ namespace Spine {
void* rendererObject; void* rendererObject;
int width, height; int width, height;
AtlasPage(const String& inName) : name(inName) {} explicit AtlasPage(const String& inName) : name(inName), format(Format_RGBA8888), minFilter(TextureFilter_Nearest),
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
vWrap(TextureWrap_ClampToEdge) {
}
}; };
class AtlasRegion : public SpineObject { class AtlasRegion : public SpineObject {

View File

@ -48,7 +48,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
AtlasAttachmentLoader(Atlas* atlas); explicit AtlasAttachmentLoader(Atlas* atlas);
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path); virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path);

View File

@ -40,7 +40,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
Attachment(const String& name); explicit Attachment(const String& name);
virtual ~Attachment(); virtual ~Attachment();
const String& getName(); const String& getName();

View File

@ -50,7 +50,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
AttachmentTimeline(int frameCount); explicit AttachmentTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -39,7 +39,7 @@ namespace Spine {
class BoundingBoxAttachment : public VertexAttachment { class BoundingBoxAttachment : public VertexAttachment {
RTTI_DECL RTTI_DECL
BoundingBoxAttachment(const String& name); explicit BoundingBoxAttachment(const String& name);
}; };
} }

View File

@ -45,7 +45,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
ClippingAttachment(const String& name); explicit ClippingAttachment(const String& name);
SlotData* getEndSlot(); SlotData* getEndSlot();
void setEndSlot(SlotData* inValue); void setEndSlot(SlotData* inValue);

View File

@ -43,7 +43,7 @@ namespace Spine {
public: public:
static const int ENTRIES; static const int ENTRIES;
ColorTimeline (int frameCount); explicit ColorTimeline (int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -34,15 +34,13 @@
#include <spine/Timeline.h> #include <spine/Timeline.h>
#include <spine/Vector.h> #include <spine/Vector.h>
#include <assert.h>
namespace Spine { namespace Spine {
/// Base class for frames that use an interpolation bezier curve. /// Base class for frames that use an interpolation bezier curve.
class CurveTimeline : public Timeline { class CurveTimeline : public Timeline {
RTTI_DECL RTTI_DECL
public: public:
CurveTimeline(int frameCount); explicit CurveTimeline(int frameCount);
virtual ~CurveTimeline(); virtual ~CurveTimeline();

View File

@ -43,7 +43,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
DeformTimeline(int frameCount); explicit DeformTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -41,7 +41,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
DrawOrderTimeline(int frameCount); explicit DrawOrderTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -42,7 +42,7 @@ namespace Spine {
friend class Event; friend class Event;
public: public:
EventData(const String& name); explicit EventData(const String& name);
/// The name of the event, which is unique within the skeleton. /// The name of the event, which is unique within the skeleton.
const String& getName(); const String& getName();

View File

@ -41,7 +41,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
EventTimeline(int frameCount); explicit EventTimeline(int frameCount);
~EventTimeline(); ~EventTimeline();

View File

@ -46,7 +46,7 @@ namespace Spine {
friend class HashMap; friend class HashMap;
public: public:
Iterator(Entry* entry = NULL) : _entry(entry) { explicit Iterator(Entry* entry = NULL) : _entry(entry) {
// Empty // Empty
} }

View File

@ -46,7 +46,7 @@ namespace Spine {
friend class IkConstraintTimeline; friend class IkConstraintTimeline;
public: public:
IkConstraintData(const String& name); explicit IkConstraintData(const String& name);
/// The IK constraint's name, which is unique within the skeleton. /// The IK constraint's name, which is unique within the skeleton.
const String& getName(); const String& getName();

View File

@ -43,7 +43,7 @@ namespace Spine {
public: public:
static const int ENTRIES; static const int ENTRIES;
IkConstraintTimeline(int frameCount); explicit IkConstraintTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -65,7 +65,7 @@ namespace Spine {
static const char* getError(); static const char* getError();
/* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */ /* Supply a block of JSON, and this returns a Json object you can interrogate. Call Json_dispose when finished. */
Json(const char* value); explicit Json(const char* value);
~Json(); ~Json();

View File

@ -37,18 +37,18 @@
#include <float.h> #include <float.h>
#define SPINE_PI 3.1415927f #define SPINE_PI 3.1415927f
#define SPINE_PI_2 SPINE_PI * 2 #define SPINE_PI_2 (SPINE_PI * 2)
#define RadDeg 180.0f / SPINE_PI #define RadDeg (180.0f / SPINE_PI)
#define DegRad SPINE_PI / 180.0f #define DegRad (SPINE_PI / 180.0f)
#define SIN_BITS 14 // 16KB. Adjust for accuracy. #define SIN_BITS 14 // 16KB. Adjust for accuracy.
#define SIN_MASK ~(-(1 << SIN_BITS)) #define SIN_MASK (~(-(1 << SIN_BITS)))
#define SIN_COUNT SIN_MASK + 1 #define SIN_COUNT (SIN_MASK + 1)
#define RadFull SPINE_PI * 2 #define RadFull (SPINE_PI * 2)
#define DegFull 360 #define DegFull 360
#define RadToIndex SIN_COUNT / RadFull #define RadToIndex (SIN_COUNT / RadFull)
#define DegToIndex SIN_COUNT / DegFull #define DegToIndex (SIN_COUNT / DegFull)
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MAX(a, b) ((((a) > (b)) ? (a) : (b)))
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MIN(a, b) ((((a) < (b)) ? (a) : (b)))
namespace Spine { namespace Spine {
template <typename T> template <typename T>

View File

@ -45,7 +45,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
MeshAttachment(const String& name); explicit MeshAttachment(const String& name);
void updateUVs(); void updateUVs();

View File

@ -41,7 +41,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
PathAttachment(const String& name); explicit PathAttachment(const String& name);
/// The length in the setup pose from the start of the path to the end of each curve. /// The length in the setup pose from the start of the path to the end of each curve.
Vector<float>& getLengths(); Vector<float>& getLengths();

View File

@ -53,7 +53,7 @@ namespace Spine {
friend class PathConstraintSpacingTimeline; friend class PathConstraintSpacingTimeline;
public: public:
PathConstraintData(const String& name); explicit PathConstraintData(const String& name);
const String& getName(); const String& getName();

View File

@ -43,7 +43,7 @@ namespace Spine {
public: public:
static const int ENTRIES; static const int ENTRIES;
PathConstraintMixTimeline(int frameCount); explicit PathConstraintMixTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -43,7 +43,7 @@ namespace Spine {
public: public:
static const int ENTRIES; static const int ENTRIES;
PathConstraintPositionTimeline(int frameCount); explicit PathConstraintPositionTimeline(int frameCount);
virtual ~PathConstraintPositionTimeline(); virtual ~PathConstraintPositionTimeline();

View File

@ -41,7 +41,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
PathConstraintSpacingTimeline(int frameCount); explicit PathConstraintSpacingTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -50,7 +50,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
PointAttachment(const String& name); explicit PointAttachment(const String& name);
void computeWorldPosition(Bone& bone, float& ox, float& oy); void computeWorldPosition(Bone& bone, float& ox, float& oy);

View File

@ -38,7 +38,7 @@
namespace Spine { namespace Spine {
class RTTI : public SpineObject { class RTTI : public SpineObject {
public: public:
RTTI(const std::string& className); explicit RTTI(const std::string& className);
RTTI(const std::string& className, const RTTI& baseRTTI); RTTI(const std::string& className, const RTTI& baseRTTI);
@ -53,7 +53,7 @@ namespace Spine {
RTTI(const RTTI& obj); RTTI(const RTTI& obj);
RTTI& operator=(const RTTI& obj); RTTI& operator=(const RTTI& obj);
const std::string& _className; const std::string _className;
const RTTI *_pBaseRTTI; const RTTI *_pBaseRTTI;
}; };
} }

View File

@ -51,7 +51,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
RegionAttachment(const String& name); explicit RegionAttachment(const String& name);
void updateOffset(); void updateOffset();

View File

@ -44,7 +44,7 @@ namespace Spine {
public: public:
static const int ENTRIES = 2; static const int ENTRIES = 2;
RotateTimeline(int frameCount); explicit RotateTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -41,7 +41,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
ScaleTimeline(int frameCount); explicit ScaleTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -41,7 +41,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
ShearTimeline(int frameCount); explicit ShearTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -70,7 +70,7 @@ namespace Spine {
friend class TwoColorTimeline; friend class TwoColorTimeline;
public: public:
Skeleton(SkeletonData* skeletonData); explicit Skeleton(SkeletonData* skeletonData);
~Skeleton(); ~Skeleton();
@ -169,9 +169,9 @@ namespace Spine {
float getY(); float getY();
void setY(float inValue); void setY(float inValue);
bool getFlipX(); bool getFlipX();
void setFlipX(float inValue); void setFlipX(bool inValue);
bool getFlipY(); bool getFlipY();
void setFlipY(float inValue); void setFlipY(bool inValue);
private: private:
SkeletonData* _data; SkeletonData* _data;

View File

@ -68,13 +68,13 @@ namespace Spine {
static const TransformMode TRANSFORM_MODE_VALUES[5]; static const TransformMode TRANSFORM_MODE_VALUES[5];
SkeletonBinary(Atlas* atlasArray); explicit SkeletonBinary(Atlas* atlasArray);
SkeletonBinary(AttachmentLoader* attachmentLoader); explicit SkeletonBinary(AttachmentLoader* attachmentLoader);
~SkeletonBinary(); ~SkeletonBinary();
SkeletonData* readSkeletonData(const unsigned char* binary, const int length); SkeletonData* readSkeletonData(const unsigned char* binary, int length);
SkeletonData* readSkeletonDataFile(const char* path); SkeletonData* readSkeletonDataFile(const char* path);
@ -100,7 +100,7 @@ namespace Spine {
signed char readSByte(DataInput* input); signed char readSByte(DataInput* input);
int readBoolean(DataInput* input); bool readBoolean(DataInput* input);
int readInt(DataInput* input); int readInt(DataInput* input);

View File

@ -47,9 +47,9 @@ namespace Spine {
class SkeletonJson : public SpineObject { class SkeletonJson : public SpineObject {
public: public:
SkeletonJson(Atlas* atlas); explicit SkeletonJson(Atlas* atlas);
SkeletonJson(AttachmentLoader* attachmentLoader); explicit SkeletonJson(AttachmentLoader* attachmentLoader);
~SkeletonJson(); ~SkeletonJson();

View File

@ -51,7 +51,7 @@ namespace Spine {
int _slotIndex; int _slotIndex;
String _name; String _name;
AttachmentKey(int slotIndex = 0, const String& name = ""); explicit AttachmentKey(int slotIndex = 0, const String& name = "");
AttachmentKey(const AttachmentKey &other) { AttachmentKey(const AttachmentKey &other) {
this->_slotIndex = other._slotIndex; this->_slotIndex = other._slotIndex;
@ -65,7 +65,7 @@ namespace Spine {
std::size_t operator()(const Spine::Skin::AttachmentKey& val) const; std::size_t operator()(const Spine::Skin::AttachmentKey& val) const;
}; };
Skin(const String& name); explicit Skin(const String& name);
~Skin(); ~Skin();
/// Adds an attachment to the skin for the specified slot index and name. /// Adds an attachment to the skin for the specified slot index and name.

View File

@ -47,7 +47,7 @@ namespace Spine {
friend class TransformConstraintTimeline; friend class TransformConstraintTimeline;
public: public:
TransformConstraintData(const String& name); explicit TransformConstraintData(const String& name);
const String& getName(); const String& getName();
int getOrder(); int getOrder();

View File

@ -43,7 +43,7 @@ namespace Spine {
public: public:
static const int ENTRIES; static const int ENTRIES;
TransformConstraintTimeline(int frameCount); explicit TransformConstraintTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -46,7 +46,7 @@ namespace Spine {
public: public:
static const int ENTRIES; static const int ENTRIES;
TranslateTimeline(int frameCount); explicit TranslateTimeline(int frameCount);
virtual ~TranslateTimeline(); virtual ~TranslateTimeline();

View File

@ -43,7 +43,7 @@ namespace Spine {
public: public:
static const int ENTRIES; static const int ENTRIES;
TwoColorTimeline(int frameCount); explicit TwoColorTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction); virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);

View File

@ -56,7 +56,7 @@ namespace Spine {
} }
} }
Vector& operator=(Vector& inVector) { Vector& operator=(const Vector& inVector) {
if (this != &inVector) { if (this != &inVector) {
clear(); clear();
deallocate(_buffer); deallocate(_buffer);

View File

@ -47,7 +47,7 @@ namespace Spine {
RTTI_DECL RTTI_DECL
public: public:
VertexAttachment(const String& name); explicit VertexAttachment(const String& name);
virtual ~VertexAttachment(); virtual ~VertexAttachment();

View File

@ -310,7 +310,8 @@ namespace Spine {
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)), _queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
_animationsChanged(false), _animationsChanged(false),
_onAnimationEventFunc(dummyOnAnimationEventFunc), _onAnimationEventFunc(dummyOnAnimationEventFunc),
_timeScale(1) { _timeScale(1),
_rendererObject(NULL){
// Empty // Empty
} }

View File

@ -279,7 +279,7 @@ namespace Spine {
int Atlas::beginPast(Str* str, char c) { int Atlas::beginPast(Str* str, char c) {
const char* begin = str->begin; const char* begin = str->begin;
while (1) { while (true) {
char lastSkippedChar = *begin; char lastSkippedChar = *begin;
if (begin == str->end) { if (begin == str->end) {
return 0; return 0;

View File

@ -32,7 +32,6 @@
#include <fstream> #include <fstream>
#include <assert.h> #include <assert.h>
#include <cstring>
namespace Spine { namespace Spine {
DefaultSpineExtension _defaultExtension; DefaultSpineExtension _defaultExtension;

View File

@ -51,7 +51,7 @@ namespace Spine {
float id = 1 / (p._a * p._d - p._b * p._c); float id = 1 / (p._a * p._d - p._b * p._c);
float x = targetX - p._worldX, y = targetY - p._worldY; float x = targetX - p._worldX, y = targetY - p._worldY;
float tx = (x * p._d - y * p._b) * id - bone._ax, ty = (y * p._a - x * p._c) * id - bone._ay; float tx = (x * p._d - y * p._b) * id - bone._ax, ty = (y * p._a - x * p._c) * id - bone._ay;
float rotationIK = (float)atan2(ty, tx) * RadDeg - bone._ashearX - bone._arotation; float rotationIK = atan2(ty, tx) * RadDeg - bone._ashearX - bone._arotation;
if (bone._ascaleX < 0) { if (bone._ascaleX < 0) {
rotationIK += 180; rotationIK += 180;
@ -146,7 +146,7 @@ namespace Spine {
x = cwx - pp._worldX; x = cwx - pp._worldX;
y = cwy - pp._worldY; y = cwy - pp._worldY;
float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py; float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py;
float l1 = (float)sqrt(dx * dx + dy * dy), l2 = child._data.getLength() * csx, a1, a2; float l1 = sqrt(dx * dx + dy * dy), l2 = child._data.getLength() * csx, a1, a2;
if (u) { if (u) {
l2 *= psx; l2 *= psx;
float cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2); float cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2);
@ -157,30 +157,30 @@ namespace Spine {
cos = 1; cos = 1;
} }
a2 = (float)acos(cos) * bendDir; a2 = acos(cos) * bendDir;
a = l1 + l2 * cos; a = l1 + l2 * cos;
b = l2 * (float)sin(a2); b = l2 * sin(a2);
a1 = (float)atan2(ty * a - tx * b, tx * a + ty * b); a1 = atan2(ty * a - tx * b, tx * a + ty * b);
} }
else { else {
a = psx * l2; a = psx * l2;
b = psy * l2; b = psy * l2;
float aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = (float)atan2(ty, tx); float aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = atan2(ty, tx);
c = bb * l1 * l1 + aa * dd - aa * bb; c = bb * l1 * l1 + aa * dd - aa * bb;
float c1 = -2 * bb * l1, c2 = bb - aa; float c1 = -2 * bb * l1, c2 = bb - aa;
d = c1 * c1 - 4 * c2 * c; d = c1 * c1 - 4 * c2 * c;
if (d >= 0) { if (d >= 0) {
float q = (float)sqrt(d); float q = sqrt(d);
if (c1 < 0) q = -q; if (c1 < 0) q = -q;
q = -(c1 + q) / 2; q = -(c1 + q) / 2;
float r0 = q / c2, r1 = c / q; float r0 = q / c2, r1 = c / q;
float r = fabs(r0) < fabs(r1) ? r0 : r1; float r = fabs(r0) < fabs(r1) ? r0 : r1;
if (r * r <= dd) { if (r * r <= dd) {
y = (float)sqrt(dd - r * r) * bendDir; y = sqrt(dd - r * r) * bendDir;
a1 = ta - (float)atan2(y, r); a1 = ta - atan2(y, r);
a2 = (float)atan2(y / psy, (r - l1) / psx); a2 = atan2(y / psy, (r - l1) / psx);
float os = (float)atan2(cy, cx) * s2; float os = atan2(cy, cx) * s2;
float rotation = parent._arotation; float rotation = parent._arotation;
a1 = (a1 - os) * RadDeg + os1 - rotation; a1 = (a1 - os) * RadDeg + os1 - rotation;
if (a1 > 180) { if (a1 > 180) {
@ -211,8 +211,8 @@ namespace Spine {
float maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; float maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0;
c = -a * l1 / (aa - bb); c = -a * l1 / (aa - bb);
if (c >= -1 && c <= 1) { if (c >= -1 && c <= 1) {
c = (float)acos(c); c = acos(c);
x = a * (float)cos(c) + l1; x = a * cos(c) + l1;
y = b * (float)sin(c); y = b * (float)sin(c);
d = x * x + y * y; d = x * x + y * y;
@ -232,11 +232,11 @@ namespace Spine {
} }
if (dd <= (minDist + maxDist) / 2) { if (dd <= (minDist + maxDist) / 2) {
a1 = ta - (float)atan2(minY * bendDir, minX); a1 = ta - atan2(minY * bendDir, minX);
a2 = minAngle * bendDir; a2 = minAngle * bendDir;
} }
else { else {
a1 = ta - (float)atan2(maxY * bendDir, maxX); a1 = ta - atan2(maxY * bendDir, maxX);
a2 = maxAngle * bendDir; a2 = maxAngle * bendDir;
} }
} }

View File

@ -114,9 +114,7 @@ namespace Spine {
} }
Json::~Json() { Json::~Json() {
if (_child) { delete _child;
delete _child;
}
if (_valueString) { if (_valueString) {
SpineExtension::free(_valueString, __FILE__, __LINE__); SpineExtension::free(_valueString, __FILE__, __LINE__);
@ -126,9 +124,7 @@ namespace Spine {
SpineExtension::free(_name, __FILE__, __LINE__); SpineExtension::free(_name, __FILE__, __LINE__);
} }
if (_next) { delete _next;
delete _next;
}
} }
const char* Json::skip(const char* inValue) { const char* Json::skip(const char* inValue) {
@ -223,7 +219,7 @@ namespace Spine {
} }
} }
out = (char*)SpineExtension::alloc<char>(len + 1, __FILE__, __LINE__); /* The length needed for the string, roughly. */ out = SpineExtension::alloc<char>(len + 1, __FILE__, __LINE__); /* The length needed for the string, roughly. */
if (!out) { if (!out) {
return 0; return 0;
} }

View File

@ -35,11 +35,11 @@ namespace Spine {
MathUtil::MathUtil() { MathUtil::MathUtil() {
for (int i = 0; i < SIN_COUNT; ++i) { for (int i = 0; i < SIN_COUNT; ++i) {
SIN_TABLE[i] = (float)sin((i + 0.5f) / SIN_COUNT * RadFull); SIN_TABLE[i] = sin((i + 0.5f) / SIN_COUNT * RadFull);
} }
for (int i = 0; i < 360; i += 90) { for (int i = 0; i < 360; i += 90) {
SIN_TABLE[(int)(i * DegToIndex) & SIN_MASK] = (float)sin(i * DegRad); SIN_TABLE[i * DegToIndex & SIN_MASK] = sin(i * DegRad);
} }
} }

View File

@ -118,7 +118,7 @@ namespace Spine {
else { else {
float x = setupLength * bone._a; float x = setupLength * bone._a;
float y = setupLength * bone._c; float y = setupLength * bone._c;
float length = (float)sqrt(x * x + y * y); float length = sqrt(x * x + y * y);
if (scale) { if (scale) {
_lengths[i] = length; _lengths[i] = length;
} }
@ -159,7 +159,7 @@ namespace Spine {
if (scale) { if (scale) {
float length = _lengths[i]; float length = _lengths[i];
if (length >= PathConstraint::EPSILON) { if (length >= PathConstraint::EPSILON) {
float s = ((float)sqrt(dx * dx + dy * dy) / length - 1) * rotateMix + 1; float s = (sqrt(dx * dx + dy * dy) / length - 1) * rotateMix + 1;
bone._a *= s; bone._a *= s;
bone._c *= s; bone._c *= s;
} }
@ -398,18 +398,18 @@ namespace Spine {
ddfy = tmpy * 2 + dddfy; ddfy = tmpy * 2 + dddfy;
dfx = (cx1 - x1) * 0.75f + tmpx + dddfx * 0.16666667f; dfx = (cx1 - x1) * 0.75f + tmpx + dddfx * 0.16666667f;
dfy = (cy1 - y1) * 0.75f + tmpy + dddfy * 0.16666667f; dfy = (cy1 - y1) * 0.75f + tmpy + dddfy * 0.16666667f;
pathLength += (float)sqrt(dfx * dfx + dfy * dfy); pathLength += sqrt(dfx * dfx + dfy * dfy);
dfx += ddfx; dfx += ddfx;
dfy += ddfy; dfy += ddfy;
ddfx += dddfx; ddfx += dddfx;
ddfy += dddfy; ddfy += dddfy;
pathLength += (float)sqrt(dfx * dfx + dfy * dfy); pathLength += sqrt(dfx * dfx + dfy * dfy);
dfx += ddfx; dfx += ddfx;
dfy += ddfy; dfy += ddfy;
pathLength += (float)sqrt(dfx * dfx + dfy * dfy); pathLength += sqrt(dfx * dfx + dfy * dfy);
dfx += ddfx + dddfx; dfx += ddfx + dddfx;
dfy += ddfy + dddfy; dfy += ddfy + dddfy;
pathLength += (float)sqrt(dfx * dfx + dfy * dfy); pathLength += sqrt(dfx * dfx + dfy * dfy);
_curves[i] = pathLength; _curves[i] = pathLength;
x1 = x2; x1 = x2;
y1 = y2; y1 = y2;
@ -485,23 +485,23 @@ namespace Spine {
ddfy = tmpy * 2 + dddfy; ddfy = tmpy * 2 + dddfy;
dfx = (cx1 - x1) * 0.3f + tmpx + dddfx * 0.16666667f; dfx = (cx1 - x1) * 0.3f + tmpx + dddfx * 0.16666667f;
dfy = (cy1 - y1) * 0.3f + tmpy + dddfy * 0.16666667f; dfy = (cy1 - y1) * 0.3f + tmpy + dddfy * 0.16666667f;
curveLength = (float)sqrt(dfx * dfx + dfy * dfy); curveLength = sqrt(dfx * dfx + dfy * dfy);
_segments[0] = curveLength; _segments[0] = curveLength;
for (ii = 1; ii < 8; ii++) { for (ii = 1; ii < 8; ii++) {
dfx += ddfx; dfx += ddfx;
dfy += ddfy; dfy += ddfy;
ddfx += dddfx; ddfx += dddfx;
ddfy += dddfy; ddfy += dddfy;
curveLength += (float)sqrt(dfx * dfx + dfy * dfy); curveLength += sqrt(dfx * dfx + dfy * dfy);
_segments[ii] = curveLength; _segments[ii] = curveLength;
} }
dfx += ddfx; dfx += ddfx;
dfy += ddfy; dfy += ddfy;
curveLength += (float)sqrt(dfx * dfx + dfy * dfy); curveLength += sqrt(dfx * dfx + dfy * dfy);
_segments[8] = curveLength; _segments[8] = curveLength;
dfx += ddfx + dddfx; dfx += ddfx + dddfx;
dfy += ddfy + dddfy; dfy += ddfy + dddfy;
curveLength += (float)sqrt(dfx * dfx + dfy * dfy); curveLength += sqrt(dfx * dfx + dfy * dfy);
_segments[9] = curveLength; _segments[9] = curveLength;
segment = 0; segment = 0;
} }
@ -563,7 +563,7 @@ namespace Spine {
output[o] = x; output[o] = x;
output[o + 1] = y; output[o + 1] = y;
if (tangents) { if (tangents) {
output[o + 2] = (float)atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); output[o + 2] = atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
} }
} }
} }

View File

@ -550,7 +550,7 @@ namespace Spine {
return _flipX; return _flipX;
} }
void Skeleton::setFlipX(float inValue) { void Skeleton::setFlipX(bool inValue) {
_flipX = inValue; _flipX = inValue;
} }
@ -558,7 +558,7 @@ namespace Spine {
return _flipY; return _flipY;
} }
void Skeleton::setFlipY(float inValue) { void Skeleton::setFlipY(bool inValue) {
_flipY = inValue; _flipY = inValue;
} }

View File

@ -153,14 +153,14 @@ namespace Spine {
} }
/* Bones. */ /* Bones. */
int bonesCount = readVarint(input, 1); int bonesCount = readVarint(input, true);
skeletonData->_bones.reserve(bonesCount); skeletonData->_bones.reserve(bonesCount);
skeletonData->_bones.setSize(bonesCount); skeletonData->_bones.setSize(bonesCount);
for (i = 0; i < bonesCount; ++i) { for (i = 0; i < bonesCount; ++i) {
BoneData* data; BoneData* data;
int mode; int mode;
const char* name = readString(input); const char* name = readString(input);
BoneData* parent = i == 0 ? 0 : skeletonData->_bones[readVarint(input, 1)]; BoneData* parent = i == 0 ? 0 : skeletonData->_bones[readVarint(input, true)];
data = new (__FILE__, __LINE__) BoneData(i, String(name, true), parent); data = new (__FILE__, __LINE__) BoneData(i, String(name, true), parent);
data->_rotation = readFloat(input); data->_rotation = readFloat(input);
@ -172,7 +172,7 @@ namespace Spine {
data->_shearY = readFloat(input); data->_shearY = readFloat(input);
data->_length = readFloat(input) * _scale; data->_length = readFloat(input) * _scale;
mode = readVarint(input, 1); mode = readVarint(input, true);
switch (mode) { switch (mode) {
case 0: case 0:
data->_transformMode = TransformMode_Normal; data->_transformMode = TransformMode_Normal;
@ -200,13 +200,13 @@ namespace Spine {
} }
/* Slots. */ /* Slots. */
int slotsCount = readVarint(input, 1); int slotsCount = readVarint(input, true);
skeletonData->_slots.reserve(slotsCount); skeletonData->_slots.reserve(slotsCount);
skeletonData->_slots.setSize(slotsCount); skeletonData->_slots.setSize(slotsCount);
for (i = 0; i < slotsCount; ++i) { for (i = 0; i < slotsCount; ++i) {
int r, g, b, a; int r, g, b, a;
const char* slotName = readString(input); const char* slotName = readString(input);
BoneData* boneData = skeletonData->_bones[readVarint(input, 1)]; BoneData* boneData = skeletonData->_bones[readVarint(input, true)];
SlotData* slotData = new (__FILE__, __LINE__) SlotData(i, String(slotName, true), *boneData); SlotData* slotData = new (__FILE__, __LINE__) SlotData(i, String(slotName, true), *boneData);
@ -221,13 +221,13 @@ namespace Spine {
slotData->_b2 = b / 255.0f; slotData->_b2 = b / 255.0f;
} }
slotData->_attachmentName.own(readString(input)); slotData->_attachmentName.own(readString(input));
slotData->_blendMode = static_cast<BlendMode>(readVarint(input, 1)); slotData->_blendMode = static_cast<BlendMode>(readVarint(input, true));
skeletonData->_slots[i] = slotData; skeletonData->_slots[i] = slotData;
} }
/* IK constraints. */ /* IK constraints. */
int ikConstraintsCount = readVarint(input, 1); int ikConstraintsCount = readVarint(input, true);
skeletonData->_ikConstraints.reserve(ikConstraintsCount); skeletonData->_ikConstraints.reserve(ikConstraintsCount);
skeletonData->_ikConstraints.setSize(ikConstraintsCount); skeletonData->_ikConstraints.setSize(ikConstraintsCount);
for (i = 0; i < ikConstraintsCount; ++i) { for (i = 0; i < ikConstraintsCount; ++i) {
@ -235,15 +235,15 @@ namespace Spine {
IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(String(name, true)); IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(String(name, true));
data->_order = readVarint(input, 1); data->_order = readVarint(input, true);
int bonesCount = readVarint(input, 1); int bonesCount = readVarint(input, true);
data->_bones.reserve(bonesCount); data->_bones.reserve(bonesCount);
data->_bones.setSize(bonesCount); data->_bones.setSize(bonesCount);
for (ii = 0; ii < bonesCount; ++ii) { for (ii = 0; ii < bonesCount; ++ii) {
data->_bones[ii] = skeletonData->_bones[readVarint(input, 1)]; data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
} }
data->_target = skeletonData->_bones[readVarint(input, 1)]; data->_target = skeletonData->_bones[readVarint(input, true)];
data->_mix = readFloat(input); data->_mix = readFloat(input);
data->_bendDirection = readSByte(input); data->_bendDirection = readSByte(input);
@ -251,7 +251,7 @@ namespace Spine {
} }
/* Transform constraints. */ /* Transform constraints. */
int transformConstraintsCount = readVarint(input, 1); int transformConstraintsCount = readVarint(input, true);
skeletonData->_transformConstraints.reserve(transformConstraintsCount); skeletonData->_transformConstraints.reserve(transformConstraintsCount);
skeletonData->_transformConstraints.setSize(transformConstraintsCount); skeletonData->_transformConstraints.setSize(transformConstraintsCount);
for (i = 0; i < transformConstraintsCount; ++i) { for (i = 0; i < transformConstraintsCount; ++i) {
@ -259,14 +259,14 @@ namespace Spine {
TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(String(name, true)); TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(String(name, true));
data->_order = readVarint(input, 1); data->_order = readVarint(input, true);
int bonesCount = readVarint(input, 1); int bonesCount = readVarint(input, true);
data->_bones.reserve(bonesCount); data->_bones.reserve(bonesCount);
data->_bones.setSize(bonesCount); data->_bones.setSize(bonesCount);
for (ii = 0; ii < bonesCount; ++ii) { for (ii = 0; ii < bonesCount; ++ii) {
data->_bones[ii] = skeletonData->_bones[readVarint(input, 1)]; data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
} }
data->_target = skeletonData->_bones[readVarint(input, 1)]; data->_target = skeletonData->_bones[readVarint(input, true)];
data->_local = readBoolean(input); data->_local = readBoolean(input);
data->_relative = readBoolean(input); data->_relative = readBoolean(input);
data->_offsetRotation = readFloat(input); data->_offsetRotation = readFloat(input);
@ -284,7 +284,7 @@ namespace Spine {
} }
/* Path constraints */ /* Path constraints */
int pathConstraintsCount = readVarint(input, 1); int pathConstraintsCount = readVarint(input, true);
skeletonData->_pathConstraints.reserve(pathConstraintsCount); skeletonData->_pathConstraints.reserve(pathConstraintsCount);
skeletonData->_pathConstraints.setSize(pathConstraintsCount); skeletonData->_pathConstraints.setSize(pathConstraintsCount);
for (i = 0; i < pathConstraintsCount; ++i) { for (i = 0; i < pathConstraintsCount; ++i) {
@ -292,18 +292,18 @@ namespace Spine {
PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(String(name, true)); PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(String(name, true));
data->_order = readVarint(input, 1); data->_order = readVarint(input, true);
int bonesCount = readVarint(input, 1); int bonesCount = readVarint(input, true);
data->_bones.reserve(bonesCount); data->_bones.reserve(bonesCount);
data->_bones.setSize(bonesCount); data->_bones.setSize(bonesCount);
for (ii = 0; ii < bonesCount; ++ii) { for (ii = 0; ii < bonesCount; ++ii) {
data->_bones[ii] = skeletonData->_bones[readVarint(input, 1)]; data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
} }
data->_target = skeletonData->_slots[readVarint(input, 1)]; data->_target = skeletonData->_slots[readVarint(input, true)];
data->_positionMode = static_cast<PositionMode>(readVarint(input, 1)); data->_positionMode = static_cast<PositionMode>(readVarint(input, true));
data->_spacingMode = static_cast<SpacingMode>(readVarint(input, 1)); data->_spacingMode = static_cast<SpacingMode>(readVarint(input, true));
data->_rotateMode = static_cast<RotateMode>(readVarint(input, 1)); data->_rotateMode = static_cast<RotateMode>(readVarint(input, true));
data->_offsetRotation = readFloat(input); data->_offsetRotation = readFloat(input);
data->_position = readFloat(input); data->_position = readFloat(input);
if (data->_positionMode == PositionMode_Fixed) { if (data->_positionMode == PositionMode_Fixed) {
@ -322,7 +322,7 @@ namespace Spine {
/* Default skin. */ /* Default skin. */
skeletonData->_defaultSkin = readSkin(input, "default", skeletonData, nonessential); skeletonData->_defaultSkin = readSkin(input, "default", skeletonData, nonessential);
int skinsCount = readVarint(input, 1); int skinsCount = readVarint(input, true);
if (skeletonData->_defaultSkin) { if (skeletonData->_defaultSkin) {
++skinsCount; ++skinsCount;
@ -365,13 +365,13 @@ namespace Spine {
_linkedMeshes.clear(); _linkedMeshes.clear();
/* Events. */ /* Events. */
int eventsCount = readVarint(input, 1); int eventsCount = readVarint(input, true);
skeletonData->_events.reserve(eventsCount); skeletonData->_events.reserve(eventsCount);
skeletonData->_events.setSize(eventsCount); skeletonData->_events.setSize(eventsCount);
for (i = 0; i < eventsCount; ++i) { for (i = 0; i < eventsCount; ++i) {
const char* name = readString(input); const char* name = readString(input);
EventData* eventData = new (__FILE__, __LINE__) EventData(String(name, true)); EventData* eventData = new (__FILE__, __LINE__) EventData(String(name, true));
eventData->_intValue = readVarint(input, 0); eventData->_intValue = readVarint(input, false);
eventData->_floatValue = readFloat(input); eventData->_floatValue = readFloat(input);
eventData->_stringValue.own(readString(input)); eventData->_stringValue.own(readString(input));
SpineExtension::free(readString(input), __FILE__, __LINE__); // skip audio path SpineExtension::free(readString(input), __FILE__, __LINE__); // skip audio path
@ -379,7 +379,7 @@ namespace Spine {
} }
/* Animations. */ /* Animations. */
int animationsCount = readVarint(input, 1); int animationsCount = readVarint(input, true);
skeletonData->_animations.reserve(animationsCount); skeletonData->_animations.reserve(animationsCount);
skeletonData->_animations.setSize(animationsCount); skeletonData->_animations.setSize(animationsCount);
for (i = 0; i < animationsCount; ++i) { for (i = 0; i < animationsCount; ++i) {
@ -421,11 +421,11 @@ namespace Spine {
strncat(message + length, value2, 255 - length); strncat(message + length, value2, 255 - length);
} }
_error = message; _error = String(message);
} }
char* SkeletonBinary::readString(DataInput* input) { char* SkeletonBinary::readString(DataInput* input) {
int length = readVarint(input, 1); int length = readVarint(input, true);
char* string; char* string;
if (length == 0) { if (length == 0) {
return NULL; return NULL;
@ -456,7 +456,7 @@ namespace Spine {
return (signed char)readByte(input); return (signed char)readByte(input);
} }
int SkeletonBinary::readBoolean(DataInput* input) { bool SkeletonBinary::readBoolean(DataInput* input) {
return readByte(input) != 0; return readByte(input) != 0;
} }
@ -504,7 +504,7 @@ namespace Spine {
Skin* SkeletonBinary::readSkin(DataInput* input, const char* skinName, SkeletonData* skeletonData, bool nonessential) { Skin* SkeletonBinary::readSkin(DataInput* input, const char* skinName, SkeletonData* skeletonData, bool nonessential) {
Skin* skin = NULL; Skin* skin = NULL;
int slotCount = readVarint(input, 1); int slotCount = readVarint(input, true);
int i, ii, nn; int i, ii, nn;
if (slotCount == 0) { if (slotCount == 0) {
return NULL; return NULL;
@ -513,8 +513,8 @@ namespace Spine {
skin = new (__FILE__, __LINE__) Skin(String(skinName)); skin = new (__FILE__, __LINE__) Skin(String(skinName));
for (i = 0; i < slotCount; ++i) { for (i = 0; i < slotCount; ++i) {
int slotIndex = readVarint(input, 1); int slotIndex = readVarint(input, true);
for (ii = 0, nn = readVarint(input, 1); ii < nn; ++ii) { for (ii = 0, nn = readVarint(input, true); ii < nn; ++ii) {
const char* name = readString(input); const char* name = readString(input);
Attachment* attachment = readAttachment(input, skin, slotIndex, name, skeletonData, nonessential); Attachment* attachment = readAttachment(input, skin, slotIndex, name, skeletonData, nonessential);
if (attachment) { if (attachment) {
@ -565,7 +565,7 @@ namespace Spine {
return region; return region;
} }
case AttachmentType_Boundingbox: { case AttachmentType_Boundingbox: {
int vertexCount = readVarint(input, 1); int vertexCount = readVarint(input, true);
BoundingBoxAttachment* box = _attachmentLoader->newBoundingBoxAttachment(*skin, String(name)); BoundingBoxAttachment* box = _attachmentLoader->newBoundingBoxAttachment(*skin, String(name));
readVertices(input, static_cast<VertexAttachment*>(box), vertexCount); readVertices(input, static_cast<VertexAttachment*>(box), vertexCount);
if (nonessential) { if (nonessential) {
@ -588,14 +588,14 @@ namespace Spine {
mesh = _attachmentLoader->newMeshAttachment(*skin, String(name), String(path)); mesh = _attachmentLoader->newMeshAttachment(*skin, String(name), String(path));
mesh->_path = String(path); mesh->_path = String(path);
readColor(input, &mesh->_r, &mesh->_g, &mesh->_b, &mesh->_a); readColor(input, &mesh->_r, &mesh->_g, &mesh->_b, &mesh->_a);
vertexCount = readVarint(input, 1); vertexCount = readVarint(input, true);
Vector<float> float_array = readFloatArray(input, vertexCount << 1, 1); Vector<float> float_array = readFloatArray(input, vertexCount << 1, 1);
mesh->setRegionUVs(float_array); mesh->setRegionUVs(float_array);
Vector<short> triangles = readShortArray(input); Vector<short> triangles = readShortArray(input);
mesh->setTriangles(triangles); mesh->setTriangles(triangles);
readVertices(input, static_cast<VertexAttachment*>(mesh), vertexCount); readVertices(input, static_cast<VertexAttachment*>(mesh), vertexCount);
mesh->updateUVs(); mesh->updateUVs();
mesh->_hullLength = readVarint(input, 1) << 1; mesh->_hullLength = readVarint(input, true) << 1;
if (nonessential) { if (nonessential) {
Vector<short> edges = readShortArray(input); Vector<short> edges = readShortArray(input);
mesh->setEdges(edges); mesh->setEdges(edges);
@ -650,7 +650,7 @@ namespace Spine {
int vertexCount = 0; int vertexCount = 0;
path->_closed = readBoolean(input); path->_closed = readBoolean(input);
path->_constantSpeed = readBoolean(input); path->_constantSpeed = readBoolean(input);
vertexCount = readVarint(input, 1); vertexCount = readVarint(input, true);
readVertices(input, static_cast<VertexAttachment*>(path), vertexCount); readVertices(input, static_cast<VertexAttachment*>(path), vertexCount);
int lengthsLength = vertexCount / 3; int lengthsLength = vertexCount / 3;
path->_lengths.reserve(lengthsLength); path->_lengths.reserve(lengthsLength);
@ -684,8 +684,8 @@ namespace Spine {
return point; return point;
} }
case AttachmentType_Clipping: { case AttachmentType_Clipping: {
int endSlotIndex = readVarint(input, 1); int endSlotIndex = readVarint(input, true);
int vertexCount = readVarint(input, 1); int vertexCount = readVarint(input, true);
ClippingAttachment* clip = _attachmentLoader->newClippingAttachment(*skin, name); ClippingAttachment* clip = _attachmentLoader->newClippingAttachment(*skin, name);
readVertices(input, static_cast<VertexAttachment*>(clip), vertexCount); readVertices(input, static_cast<VertexAttachment*>(clip), vertexCount);
@ -760,7 +760,7 @@ namespace Spine {
} }
Vector<short> SkeletonBinary::readShortArray(DataInput *input) { Vector<short> SkeletonBinary::readShortArray(DataInput *input) {
int n = readVarint(input, 1); int n = readVarint(input, true);
Vector<short> array; Vector<short> array;
array.reserve(n); array.reserve(n);

View File

@ -1226,8 +1226,6 @@ namespace Spine {
_error = String(message); _error = String(message);
if (root) { delete root;
delete root;
}
} }
} }

View File

@ -171,17 +171,17 @@ namespace Spine {
} }
if (scaleMix > 0) { if (scaleMix > 0) {
float s = (float)sqrt(bone._a * bone._a + bone._c * bone._c); float s = sqrt(bone._a * bone._a + bone._c * bone._c);
if (s > 0.00001f) { if (s > 0.00001f) {
s = (s + ((float)sqrt(ta * ta + tc * tc) - s + _data._offsetScaleX) * scaleMix) / s; s = (s + (sqrt(ta * ta + tc * tc) - s + _data._offsetScaleX) * scaleMix) / s;
} }
bone._a *= s; bone._a *= s;
bone._c *= s; bone._c *= s;
s = (float)sqrt(bone._b * bone._b + bone._d * bone._d); s = sqrt(bone._b * bone._b + bone._d * bone._d);
if (s > 0.00001f) { if (s > 0.00001f) {
s = (s + ((float)sqrt(tb * tb + td * td) - s + _data._offsetScaleY) * scaleMix) / s; s = (s + (sqrt(tb * tb + td * td) - s + _data._offsetScaleY) * scaleMix) / s;
} }
bone._b *= s; bone._b *= s;
bone._d *= s; bone._d *= s;
@ -200,7 +200,7 @@ namespace Spine {
} }
r = by + (r + offsetShearY) * shearMix; r = by + (r + offsetShearY) * shearMix;
float s = (float)sqrt(b * b + d * d); float s = sqrt(b * b + d * d);
bone._b = MathUtil::cos(r) * s; bone._b = MathUtil::cos(r) * s;
bone._d = MathUtil::sin(r) * s; bone._d = MathUtil::sin(r) * s;
modified = true; modified = true;
@ -252,10 +252,10 @@ namespace Spine {
} }
if (scaleMix > 0) { if (scaleMix > 0) {
float s = ((float)sqrt(ta * ta + tc * tc) - 1 + _data._offsetScaleX) * scaleMix + 1; float s = (sqrt(ta * ta + tc * tc) - 1 + _data._offsetScaleX) * scaleMix + 1;
bone._a *= s; bone._a *= s;
bone._c *= s; bone._c *= s;
s = ((float)sqrt(tb * tb + td * td) - 1 + _data._offsetScaleY) * scaleMix + 1; s = (sqrt(tb * tb + td * td) - 1 + _data._offsetScaleY) * scaleMix + 1;
bone._b *= s; bone._b *= s;
bone._d *= s; bone._d *= s;
modified = true; modified = true;
@ -272,7 +272,7 @@ namespace Spine {
float b = bone._b, d = bone._d; float b = bone._b, d = bone._d;
r = MathUtil::atan2(d, b) + (r - SPINE_PI / 2 + offsetShearY) * shearMix; r = MathUtil::atan2(d, b) + (r - SPINE_PI / 2 + offsetShearY) * shearMix;
float s = (float)sqrt(b * b + d * d); float s = sqrt(b * b + d * d);
bone._b = MathUtil::cos(r) * s; bone._b = MathUtil::cos(r) * s;
bone._d = MathUtil::sin(r) * s; bone._d = MathUtil::sin(r) * s;
modified = true; modified = true;