From 7a18b8122631a313541d492f583a7b46928c24e0 Mon Sep 17 00:00:00 2001 From: badlogic Date: Fri, 23 Feb 2018 15:45:45 +0100 Subject: [PATCH] [cpp] Added toString method for SpineObjects, fixed up math, fixed up IKConstraint. --- spine-cpp/spine-cpp/include/spine/Animation.h | 2 + .../spine-cpp/include/spine/AnimationState.h | 9 +- .../include/spine/AnimationStateData.h | 6 +- spine-cpp/spine-cpp/include/spine/Atlas.h | 17 ++ .../include/spine/AtlasAttachmentLoader.h | 2 + .../spine-cpp/include/spine/Attachment.h | 2 +- .../include/spine/AttachmentTimeline.h | 1 - spine-cpp/spine-cpp/include/spine/Bone.h | 3 +- spine-cpp/spine-cpp/include/spine/BoneData.h | 2 + .../include/spine/BoundingBoxAttachment.h | 2 + .../include/spine/ClippingAttachment.h | 2 + spine-cpp/spine-cpp/include/spine/Color.h | 8 +- spine-cpp/spine-cpp/include/spine/Event.h | 2 + spine-cpp/spine-cpp/include/spine/EventData.h | 4 +- spine-cpp/spine-cpp/include/spine/HashMap.h | 25 +- .../spine-cpp/include/spine/IkConstraint.h | 2 + .../include/spine/IkConstraintData.h | 4 +- spine-cpp/spine-cpp/include/spine/Json.h | 3 +- .../spine-cpp/include/spine/LinkedMesh.h | 3 +- spine-cpp/spine-cpp/include/spine/MathUtil.h | 28 +- .../spine-cpp/include/spine/MeshAttachment.h | 2 + .../spine-cpp/include/spine/PathAttachment.h | 2 + .../spine-cpp/include/spine/PathConstraint.h | 2 + .../include/spine/PathConstraintData.h | 3 +- .../spine-cpp/include/spine/PointAttachment.h | 2 + spine-cpp/spine-cpp/include/spine/Pool.h | 6 + spine-cpp/spine-cpp/include/spine/RTTI.h | 9 +- .../include/spine/RegionAttachment.h | 2 + spine-cpp/spine-cpp/include/spine/Skeleton.h | 4 +- .../spine-cpp/include/spine/SkeletonBinary.h | 4 + .../spine-cpp/include/spine/SkeletonBounds.h | 4 + .../include/spine/SkeletonClipping.h | 2 + .../spine-cpp/include/spine/SkeletonData.h | 4 +- .../spine-cpp/include/spine/SkeletonJson.h | 2 + spine-cpp/spine-cpp/include/spine/Skin.h | 6 +- spine-cpp/spine-cpp/include/spine/Slot.h | 4 +- spine-cpp/spine-cpp/include/spine/SlotData.h | 4 +- .../spine-cpp/include/spine/SpineObject.h | 1 + spine-cpp/spine-cpp/include/spine/String.h | 33 ++- spine-cpp/spine-cpp/include/spine/Timeline.h | 2 + .../include/spine/TransformConstraint.h | 2 + .../include/spine/TransformConstraintData.h | 2 + .../spine-cpp/include/spine/Triangulator.h | 2 + spine-cpp/spine-cpp/include/spine/Vector.h | 25 +- spine-cpp/spine-cpp/include/spine/Vertices.h | 4 + spine-cpp/spine-cpp/src/spine/Animation.cpp | 8 + .../spine-cpp/src/spine/AnimationState.cpp | 28 +- .../src/spine/AnimationStateData.cpp | 14 +- spine-cpp/spine-cpp/src/spine/Atlas.cpp | 4 + .../src/spine/AtlasAttachmentLoader.cpp | 4 + spine-cpp/spine-cpp/src/spine/Attachment.cpp | 2 +- spine-cpp/spine-cpp/src/spine/Bone.cpp | 36 ++- spine-cpp/spine-cpp/src/spine/BoneData.cpp | 4 + .../src/spine/BoundingBoxAttachment.cpp | 7 + .../src/spine/ClippingAttachment.cpp | 8 + spine-cpp/spine-cpp/src/spine/Event.cpp | 4 + spine-cpp/spine-cpp/src/spine/EventData.cpp | 4 + .../spine-cpp/src/spine/IkConstraint.cpp | 268 +++++++----------- .../spine-cpp/src/spine/IkConstraintData.cpp | 4 + spine-cpp/spine-cpp/src/spine/Json.cpp | 7 +- spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp | 4 + spine-cpp/spine-cpp/src/spine/MathUtil.cpp | 4 +- .../spine-cpp/src/spine/MeshAttachment.cpp | 6 + .../spine-cpp/src/spine/PathAttachment.cpp | 8 + .../spine-cpp/src/spine/PathConstraint.cpp | 18 +- .../src/spine/PathConstraintData.cpp | 6 + .../spine-cpp/src/spine/PointAttachment.cpp | 8 +- spine-cpp/spine-cpp/src/spine/RTTI.cpp | 6 + .../spine-cpp/src/spine/RegionAttachment.cpp | 6 + spine-cpp/spine-cpp/src/spine/Skeleton.cpp | 20 +- .../spine-cpp/src/spine/SkeletonBinary.cpp | 28 +- .../spine-cpp/src/spine/SkeletonBounds.cpp | 18 +- .../spine-cpp/src/spine/SkeletonClipping.cpp | 13 +- .../spine-cpp/src/spine/SkeletonData.cpp | 4 + .../spine-cpp/src/spine/SkeletonJson.cpp | 30 +- spine-cpp/spine-cpp/src/spine/Skin.cpp | 18 +- spine-cpp/spine-cpp/src/spine/Slot.cpp | 9 + spine-cpp/spine-cpp/src/spine/SlotData.cpp | 4 + spine-cpp/spine-cpp/src/spine/Timeline.cpp | 6 + .../src/spine/TransformConstraint.cpp | 44 +-- .../src/spine/TransformConstraintData.cpp | 4 + .../spine-cpp/src/spine/Triangulator.cpp | 6 +- spine-sfml/cpp/example/main.cpp | 24 +- spine-sfml/cpp/src/spine/spine-sfml.cpp | 4 + spine-sfml/cpp/src/spine/spine-sfml.h | 2 + 85 files changed, 646 insertions(+), 316 deletions(-) diff --git a/spine-cpp/spine-cpp/include/spine/Animation.h b/spine-cpp/spine-cpp/include/spine/Animation.h index 54398a851..4ea55fd7b 100644 --- a/spine-cpp/spine-cpp/include/spine/Animation.h +++ b/spine-cpp/spine-cpp/include/spine/Animation.h @@ -81,6 +81,8 @@ namespace Spine { float getDuration(); void setDuration(float inValue); + + String toString() const; private: Vector _timelines; diff --git a/spine-cpp/spine-cpp/include/spine/AnimationState.h b/spine-cpp/spine-cpp/include/spine/AnimationState.h index 7958eec57..55592a575 100644 --- a/spine-cpp/spine-cpp/include/spine/AnimationState.h +++ b/spine-cpp/spine-cpp/include/spine/AnimationState.h @@ -213,7 +213,8 @@ namespace Spine { void resetRotationDirections(); void setOnAnimationEventFunc(OnAnimationEventFunc inValue); - + + String toString() const; private: Animation* _animation; @@ -249,6 +250,8 @@ namespace Spine { Event* _event; EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event = NULL); + + String toString() const; }; class EventQueue : public SpineObject { @@ -282,6 +285,8 @@ namespace Spine { /// Raises all events in the queue and drains the queue. void drain(); + + String toString() const ; }; class AnimationState : public SpineObject { @@ -373,6 +378,8 @@ namespace Spine { void setOnAnimationEventFunc(OnAnimationEventFunc inValue); void setRendererObject(void* inValue); void* getRendererObject(); + + String toString() const; private: static const int Subsequent, First, Dip, DipMix; diff --git a/spine-cpp/spine-cpp/include/spine/AnimationStateData.h b/spine-cpp/spine-cpp/include/spine/AnimationStateData.h index 2136f9862..34920274a 100644 --- a/spine-cpp/spine-cpp/include/spine/AnimationStateData.h +++ b/spine-cpp/spine-cpp/include/spine/AnimationStateData.h @@ -67,7 +67,9 @@ namespace Spine { /// or the DefaultMix if no mix duration has been set. /// float getMix(Animation* from, Animation* to); - + + String toString() const; + private: class AnimationPair : public SpineObject { public: @@ -77,6 +79,8 @@ namespace Spine { explicit AnimationPair(Animation* a1 = NULL, Animation* a2 = NULL); bool operator==(const AnimationPair &other) const; + + String toString() const; }; struct HashAnimationPair : public SpineObject { diff --git a/spine-cpp/spine-cpp/include/spine/Atlas.h b/spine-cpp/spine-cpp/include/spine/Atlas.h index e139ad59a..67e1434b1 100644 --- a/spine-cpp/spine-cpp/include/spine/Atlas.h +++ b/spine-cpp/spine-cpp/include/spine/Atlas.h @@ -78,6 +78,15 @@ namespace Spine { magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge), vWrap(TextureWrap_ClampToEdge) { } + + String toString() const { + String str; + str.append("AtlasPage { name: ").appendString(name) + .append(", width: ").append(width) + .append(", height: ").append(height) + .append(" }"); + return str; + } }; class AtlasRegion : public SpineObject { @@ -92,6 +101,12 @@ namespace Spine { bool rotate; Vector splits; Vector pads; + + String toString() const { + String str; + str.append("AtlasRegion { name: ").appendString(name).append(" }"); + return str; + } }; class TextureLoader; @@ -112,6 +127,8 @@ namespace Spine { AtlasRegion* findRegion(const String& name); void dispose(); + + String toString() const; private: Vector _pages; diff --git a/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h b/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h index c01725da1..1662262f0 100644 --- a/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h +++ b/spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h @@ -63,6 +63,8 @@ namespace Spine { virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name); AtlasRegion* findRegion(const String& name); + + String toString() const; private: Atlas* _atlas; diff --git a/spine-cpp/spine-cpp/include/spine/Attachment.h b/spine-cpp/spine-cpp/include/spine/Attachment.h index b201619e6..00f9c50eb 100644 --- a/spine-cpp/spine-cpp/include/spine/Attachment.h +++ b/spine-cpp/spine-cpp/include/spine/Attachment.h @@ -43,7 +43,7 @@ namespace Spine { explicit Attachment(const String& name); virtual ~Attachment(); - const String& getName(); + const String& getName() const; private: const String _name; diff --git a/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h b/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h index 2c066fbc1..cdfe0e712 100644 --- a/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h @@ -66,7 +66,6 @@ namespace Spine { const Vector& getAttachmentNames(); void setAttachmentNames(Vector& inValue); int getFrameCount(); - private: int _slotIndex; Vector _frames; diff --git a/spine-cpp/spine-cpp/include/spine/Bone.h b/spine-cpp/spine-cpp/include/spine/Bone.h index 2f4afe1f6..3f2ea5845 100644 --- a/spine-cpp/spine-cpp/include/spine/Bone.h +++ b/spine-cpp/spine-cpp/include/spine/Bone.h @@ -180,7 +180,8 @@ namespace Spine { /// Returns the magnitide (always positive) of the world scale Y. float getWorldScaleY(); - + + String toString() const; private: static bool yDown; diff --git a/spine-cpp/spine-cpp/include/spine/BoneData.h b/spine-cpp/spine-cpp/include/spine/BoneData.h index 3e1a26c01..f85882758 100644 --- a/spine-cpp/spine-cpp/include/spine/BoneData.h +++ b/spine-cpp/spine-cpp/include/spine/BoneData.h @@ -93,6 +93,8 @@ namespace Spine { /// The transform mode for how parent world transforms affect this bone. TransformMode getTransformMode(); void setTransformMode(TransformMode inValue); + + String toString() const; private: const int _index; diff --git a/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h b/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h index 066aa0487..e20a4dd93 100644 --- a/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h @@ -40,6 +40,8 @@ namespace Spine { RTTI_DECL explicit BoundingBoxAttachment(const String& name); + + String toString() const; }; } diff --git a/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h b/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h index 7d69efc8f..8180b12c4 100644 --- a/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/ClippingAttachment.h @@ -49,6 +49,8 @@ namespace Spine { SlotData* getEndSlot(); void setEndSlot(SlotData* inValue); + + String toString() const; private: SlotData* _endSlot; diff --git a/spine-cpp/spine-cpp/include/spine/Color.h b/spine-cpp/spine-cpp/include/spine/Color.h index 7aa9e72fc..8b9504748 100644 --- a/spine-cpp/spine-cpp/include/spine/Color.h +++ b/spine-cpp/spine-cpp/include/spine/Color.h @@ -33,7 +33,7 @@ #include namespace Spine { - class Color { + class Color : public SpineObject { public: Color() : _r(0), _g(0), _b(0), _a(0) { } @@ -87,6 +87,12 @@ namespace Spine { } float _r, _g, _b, _a; + + inline String toString() const { + String str; + str.append("Color { r: ").append(_r).append(", g: ").append(_g).append(", b: ").append(_b).append(", a: ").append(_a).append(" }"); + return str; + } }; } diff --git a/spine-cpp/spine-cpp/include/spine/Event.h b/spine-cpp/spine-cpp/include/spine/Event.h index 8bf460de5..a21f2f3d3 100644 --- a/spine-cpp/spine-cpp/include/spine/Event.h +++ b/spine-cpp/spine-cpp/include/spine/Event.h @@ -59,6 +59,8 @@ namespace Spine { const String& getStringValue(); void setStringValue(const String& inValue); + + String toString() const; private: const EventData& _data; diff --git a/spine-cpp/spine-cpp/include/spine/EventData.h b/spine-cpp/spine-cpp/include/spine/EventData.h index c62cad002..efc37e7fa 100644 --- a/spine-cpp/spine-cpp/include/spine/EventData.h +++ b/spine-cpp/spine-cpp/include/spine/EventData.h @@ -55,7 +55,9 @@ namespace Spine { const String& getStringValue(); void setStringValue(const String& inValue); - + + String toString() const; + private: const String _name; int _intValue; diff --git a/spine-cpp/spine-cpp/include/spine/HashMap.h b/spine-cpp/spine-cpp/include/spine/HashMap.h index cca4b9aa4..bcd041bfc 100755 --- a/spine-cpp/spine-cpp/include/spine/HashMap.h +++ b/spine-cpp/spine-cpp/include/spine/HashMap.h @@ -34,6 +34,7 @@ #include #include #include +#include namespace Spine { template @@ -144,9 +145,25 @@ namespace Spine { else assert(false); } - Entries getEntries() { + Entries getEntries() const { return Entries(_head); } + + String toString() const { + String str; + + str.append("{"); + Entries entries = getEntries(); + + while(entries.hasNext()) { + Pair pair = entries.next(); + str.append(pair.key); + str.append("->"); + str.append(pair.value); + } + str.append("}"); + return str; + } private: Entry* find(const K& key) { @@ -165,6 +182,12 @@ namespace Spine { Entry* prev; Entry () : next(NULL), prev(NULL) {} + + String toString() const { + String str; + str.append("Entry { key: ").append(_key).append(" -> ").append(_value); + return str; + } }; Entry* _head; diff --git a/spine-cpp/spine-cpp/include/spine/IkConstraint.h b/spine-cpp/spine-cpp/include/spine/IkConstraint.h index 6884f25c2..e1da07105 100644 --- a/spine-cpp/spine-cpp/include/spine/IkConstraint.h +++ b/spine-cpp/spine-cpp/include/spine/IkConstraint.h @@ -77,6 +77,8 @@ namespace Spine { float getMix(); void setMix(float inValue); + + String toString() const; private: IkConstraintData& _data; diff --git a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h index 7e03b8459..274f39633 100644 --- a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h @@ -67,7 +67,9 @@ namespace Spine { float getMix(); void setMix(float inValue); - + + String toString() const; + private: const String _name; int _order; diff --git a/spine-cpp/spine-cpp/include/spine/Json.h b/spine-cpp/spine-cpp/include/spine/Json.h index 8f3dd15f7..ca471b893 100644 --- a/spine-cpp/spine-cpp/include/spine/Json.h +++ b/spine-cpp/spine-cpp/include/spine/Json.h @@ -68,7 +68,8 @@ namespace Spine { explicit Json(const char* value); ~Json(); - + + String toString() const; private: static const char* _error; diff --git a/spine-cpp/spine-cpp/include/spine/LinkedMesh.h b/spine-cpp/spine-cpp/include/spine/LinkedMesh.h index 6652468e1..86fba00b7 100644 --- a/spine-cpp/spine-cpp/include/spine/LinkedMesh.h +++ b/spine-cpp/spine-cpp/include/spine/LinkedMesh.h @@ -43,7 +43,8 @@ namespace Spine { public: LinkedMesh(MeshAttachment* mesh, const String& skin, int slotIndex, const String& parent); - + + String toString() const; private: MeshAttachment* _mesh; String _skin; diff --git a/spine-cpp/spine-cpp/include/spine/MathUtil.h b/spine-cpp/spine-cpp/include/spine/MathUtil.h index 17a49daab..9e5c4429f 100644 --- a/spine-cpp/spine-cpp/include/spine/MathUtil.h +++ b/spine-cpp/spine-cpp/include/spine/MathUtil.h @@ -36,27 +36,20 @@ #include #include -#define SPINE_PI 3.1415927f -#define SPINE_PI_2 (SPINE_PI * 2) -#define RadDeg (180.0f / SPINE_PI) -#define DegRad (SPINE_PI / 180.0f) -#define SIN_BITS 14 // 16KB. Adjust for accuracy. -#define SIN_MASK (~(-(1 << SIN_BITS))) -#define SIN_COUNT (SIN_MASK + 1) -#define RadFull (SPINE_PI * 2) -#define DegFull 360 -#define RadToIndex (SIN_COUNT / RadFull) -#define DegToIndex (SIN_COUNT / DegFull) -#define MAX(a, b) ((((a) > (b)) ? (a) : (b))) -#define MIN(a, b) ((((a) < (b)) ? (a) : (b))) - - namespace Spine { - + static const float PI = 3.1415927f; + static const float PI_2 = PI * 2; + static const float RAD_DEG = (180.0f / PI); + static const float DEG_RAD = (PI / 180.0f); + class MathUtil : public SpineObject { public: MathUtil(); + template static inline T min(T a, T b) { return a < b ? a : b; } + + template static inline T max(T a, T b) { return a > b ? a : b; } + static int sign(float val); static bool areFloatsPracticallyEqual(float A, float B, float maxDiff = 0.0000000000000001f, float maxRelDiff = FLT_EPSILON); @@ -88,9 +81,6 @@ namespace Spine { static float fmod(float a, float b); static bool isNan(float v); - - private: - static float SIN_TABLE[SIN_COUNT]; }; } diff --git a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h index d1902472f..b434122b2 100644 --- a/spine-cpp/spine-cpp/include/spine/MeshAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/MeshAttachment.h @@ -122,6 +122,8 @@ namespace Spine { float getHeight(); void setHeight(float inValue); + String toString() const; + private: float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight; MeshAttachment* _parentMesh; diff --git a/spine-cpp/spine-cpp/include/spine/PathAttachment.h b/spine-cpp/spine-cpp/include/spine/PathAttachment.h index c48889961..aedd05c27 100644 --- a/spine-cpp/spine-cpp/include/spine/PathAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/PathAttachment.h @@ -50,6 +50,8 @@ namespace Spine { void setClosed(bool inValue); bool isConstantSpeed(); void setConstantSpeed(bool inValue); + + String toString() const; private: Vector _lengths; diff --git a/spine-cpp/spine-cpp/include/spine/PathConstraint.h b/spine-cpp/spine-cpp/include/spine/PathConstraint.h index 9bc041010..80bdc0622 100644 --- a/spine-cpp/spine-cpp/include/spine/PathConstraint.h +++ b/spine-cpp/spine-cpp/include/spine/PathConstraint.h @@ -78,6 +78,8 @@ namespace Spine { void setTarget(Slot* inValue); PathConstraintData& getData(); + + String toString() const; private: static const float EPSILON; diff --git a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h index 00433c27d..7cba60758 100644 --- a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h @@ -88,7 +88,8 @@ namespace Spine { float getTranslateMix(); void setTranslateMix(float inValue); - + + String toString() const; private: const String _name; int _order; diff --git a/spine-cpp/spine-cpp/include/spine/PointAttachment.h b/spine-cpp/spine-cpp/include/spine/PointAttachment.h index 61ae21ba0..7768da3d5 100644 --- a/spine-cpp/spine-cpp/include/spine/PointAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/PointAttachment.h @@ -64,6 +64,8 @@ namespace Spine { float getRotation(); void setRotation(float inValue); + + String toString() const; private: float _x, _y, _rotation; diff --git a/spine-cpp/spine-cpp/include/spine/Pool.h b/spine-cpp/spine-cpp/include/spine/Pool.h index 1e19d4c99..eb185d706 100644 --- a/spine-cpp/spine-cpp/include/spine/Pool.h +++ b/spine-cpp/spine-cpp/include/spine/Pool.h @@ -67,6 +67,12 @@ namespace Spine { _objects.add(object); } } + + String toString () const { + String str; + str.append("Pool { size: ").append((int)_objects.size()).append(" }"); + return str; + } private: Vector _objects; diff --git a/spine-cpp/spine-cpp/include/spine/RTTI.h b/spine-cpp/spine-cpp/include/spine/RTTI.h index 0ce69179c..1acbd7a1e 100644 --- a/spine-cpp/spine-cpp/include/spine/RTTI.h +++ b/spine-cpp/spine-cpp/include/spine/RTTI.h @@ -47,7 +47,8 @@ namespace Spine { bool isExactly(const RTTI& rtti) const; bool instanceOf(const RTTI &rtti) const; - + + String toString() const; private: // Prevent copying RTTI(const RTTI& obj); @@ -61,15 +62,15 @@ namespace Spine { #define RTTI_DECL \ public: \ static const Spine::RTTI rtti; \ -virtual const Spine::RTTI& getRTTI(); +virtual const Spine::RTTI& getRTTI() const; #define RTTI_IMPL_NOPARENT(name) \ const Spine::RTTI name::rtti(#name); \ -const Spine::RTTI& name::getRTTI() { return rtti; } +const Spine::RTTI& name::getRTTI() const { return rtti; } #define RTTI_IMPL(name,parent) \ const Spine::RTTI name::rtti(#name, parent::rtti); \ -const Spine::RTTI& name::getRTTI() { return rtti; } +const Spine::RTTI& name::getRTTI() const { return rtti; } #endif /* Spine_RTTI_h */ diff --git a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h index 7f83583f3..5582b4a54 100644 --- a/spine-cpp/spine-cpp/include/spine/RegionAttachment.h +++ b/spine-cpp/spine-cpp/include/spine/RegionAttachment.h @@ -106,6 +106,8 @@ namespace Spine { Vector& getOffset(); Vector& getUVs(); + + String toString() const; private: static const int BLX; diff --git a/spine-cpp/spine-cpp/include/spine/Skeleton.h b/spine-cpp/spine-cpp/include/spine/Skeleton.h index e7568f4bd..830385134 100644 --- a/spine-cpp/spine-cpp/include/spine/Skeleton.h +++ b/spine-cpp/spine-cpp/include/spine/Skeleton.h @@ -169,7 +169,9 @@ namespace Spine { void setFlipX(bool inValue); bool getFlipY(); void setFlipY(bool inValue); - + + String toString() const; + private: SkeletonData* _data; Vector _bones; diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h b/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h index f58f1390e..0750628fc 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonBinary.h @@ -80,11 +80,15 @@ namespace Spine { void setScale(float scale) { _scale = scale; } String& getError() { return _error; } + + String toString() const; private: struct DataInput : public SpineObject { const unsigned char* cursor; const unsigned char* end; + + String toString() const { return String("DataInput"); } }; AttachmentLoader* _attachmentLoader; diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonBounds.h b/spine-cpp/spine-cpp/include/spine/SkeletonBounds.h index 4bcb53d8d..b14cee508 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonBounds.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonBounds.h @@ -85,6 +85,8 @@ namespace Spine { float getWidth(); float getHeight(); + + String toString() const; private: Vector _polygonPool; @@ -103,6 +105,8 @@ namespace Spine { Polygon() : _count(0) { _vertices.ensureCapacity(16); } + + String toString() const; }; } diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonClipping.h b/spine-cpp/spine-cpp/include/spine/SkeletonClipping.h index e887a7bfc..41a6b8645 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonClipping.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonClipping.h @@ -55,6 +55,8 @@ namespace Spine { Vector& getClippedVertices(); Vector& getClippedTriangles(); Vector& getClippedUVs(); + + String toString() const; private: Triangulator _triangulator; diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonData.h b/spine-cpp/spine-cpp/include/spine/SkeletonData.h index 9318ab53e..719247e6c 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonData.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonData.h @@ -140,7 +140,9 @@ namespace Spine { /// The dopesheet FPS in Spine. Available only when nonessential data was exported. float getFps(); void setFps(float inValue); - + + String toString() const; + private: String _name; Vector _bones; // Ordered parents first diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonJson.h b/spine-cpp/spine-cpp/include/spine/SkeletonJson.h index 91f02f9d4..4b3915f8f 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonJson.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonJson.h @@ -61,6 +61,8 @@ namespace Spine { void setScale (float scale) { _scale = scale; } String& getError() { return _error; } + + String toString() const; private: AttachmentLoader* _attachmentLoader; diff --git a/spine-cpp/spine-cpp/include/spine/Skin.h b/spine-cpp/spine-cpp/include/spine/Skin.h index f08ed7d99..dd2fb0552 100644 --- a/spine-cpp/spine-cpp/include/spine/Skin.h +++ b/spine-cpp/spine-cpp/include/spine/Skin.h @@ -46,7 +46,7 @@ namespace Spine { friend class Skeleton; public: - class AttachmentKey { + class AttachmentKey: public SpineObject { public: int _slotIndex; String _name; @@ -59,6 +59,8 @@ namespace Spine { } bool operator==(const AttachmentKey &other) const; + + String toString() const; }; struct HashAttachmentKey : public SpineObject { @@ -87,6 +89,8 @@ namespace Spine { const String& getName(); HashMap& getAttachments(); + + String toString() const; private: const String _name; diff --git a/spine-cpp/spine-cpp/include/spine/Slot.h b/spine-cpp/spine-cpp/include/spine/Slot.h index b320420ae..3cccdfe46 100644 --- a/spine-cpp/spine-cpp/include/spine/Slot.h +++ b/spine-cpp/spine-cpp/include/spine/Slot.h @@ -88,7 +88,9 @@ namespace Spine { Vector& getAttachmentVertices(); void setAttachmentVertices(Vector inValue); - + + String toString() const; + private: SlotData& _data; Bone& _bone; diff --git a/spine-cpp/spine-cpp/include/spine/SlotData.h b/spine-cpp/spine-cpp/include/spine/SlotData.h index f6f2d6c63..c6885d223 100644 --- a/spine-cpp/spine-cpp/include/spine/SlotData.h +++ b/spine-cpp/spine-cpp/include/spine/SlotData.h @@ -79,7 +79,9 @@ namespace Spine { BlendMode getBlendMode(); void setBlendMode(BlendMode inValue); - + + String toString() const; + private: const int _index; String _name; diff --git a/spine-cpp/spine-cpp/include/spine/SpineObject.h b/spine-cpp/spine-cpp/include/spine/SpineObject.h index 5534809fd..e4bac92db 100644 --- a/spine-cpp/spine-cpp/include/spine/SpineObject.h +++ b/spine-cpp/spine-cpp/include/spine/SpineObject.h @@ -42,6 +42,7 @@ namespace Spine { void* operator new(size_t sz, void* ptr); void operator delete(void* p); virtual ~SpineObject(); + virtual String toString() const = 0; }; } diff --git a/spine-cpp/spine-cpp/include/spine/String.h b/spine-cpp/spine-cpp/include/spine/String.h index 457d72f2f..81be44744 100644 --- a/spine-cpp/spine-cpp/include/spine/String.h +++ b/spine-cpp/spine-cpp/include/spine/String.h @@ -35,6 +35,7 @@ #include #include +#include namespace Spine { class String : public SpineObject { @@ -138,7 +139,7 @@ namespace Spine { return *this; } - String& operator+ (const char* chars) { + String& append (const char* chars) { size_t len = strlen(chars); size_t thisLen = _length; _length = _length + len; @@ -148,7 +149,7 @@ namespace Spine { return *this; } - String& operator+= (const String& other) { + String& appendString (const String& other) { size_t len = other.length(); size_t thisLen = _length; _length = _length + len; @@ -158,8 +159,28 @@ namespace Spine { return *this; } - friend String operator+ (const String& a, const String& b) { - return String(a) += b; + String& append (int other) { + char str[100]; + sprintf(str, "%i", other); + append(str); + return *this; + } + + String& append (float other) { + char str[100]; + sprintf(str, "%f", other); + append(str); + return *this; + } + + String& append(const SpineObject& object) { + appendString(object.toString()); + return *this; + } + + String& append(const SpineObject* object) { + appendString(object->toString()); + return *this; } friend bool operator== (const String& a, const String& b) { @@ -181,6 +202,10 @@ namespace Spine { SpineExtension::free(_buffer, __FILE__, __LINE__); } } + + String toString () const { + return *this; + } private: mutable size_t _length; mutable char* _buffer; diff --git a/spine-cpp/spine-cpp/include/spine/Timeline.h b/spine-cpp/spine-cpp/include/spine/Timeline.h index 614c47798..764f11366 100644 --- a/spine-cpp/spine-cpp/include/spine/Timeline.h +++ b/spine-cpp/spine-cpp/include/spine/Timeline.h @@ -63,6 +63,8 @@ namespace Spine { virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector* pEvents, float alpha, MixPose pose, MixDirection direction) = 0; virtual int getPropertyId() = 0; + + virtual String toString() const; }; } diff --git a/spine-cpp/spine-cpp/include/spine/TransformConstraint.h b/spine-cpp/spine-cpp/include/spine/TransformConstraint.h index 69dc172ff..b52c8b076 100644 --- a/spine-cpp/spine-cpp/include/spine/TransformConstraint.h +++ b/spine-cpp/spine-cpp/include/spine/TransformConstraint.h @@ -73,6 +73,8 @@ namespace Spine { float getShearMix(); void setShearMix(float inValue); + + String toString() const; private: TransformConstraintData& _data; diff --git a/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h b/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h index 7fb0cfcb3..6a264b0d6 100644 --- a/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h @@ -67,6 +67,8 @@ namespace Spine { bool isRelative(); bool isLocal(); + + String toString() const; private: const String _name; diff --git a/spine-cpp/spine-cpp/include/spine/Triangulator.h b/spine-cpp/spine-cpp/include/spine/Triangulator.h index 60ce246ff..178d1c2ba 100644 --- a/spine-cpp/spine-cpp/include/spine/Triangulator.h +++ b/spine-cpp/spine-cpp/include/spine/Triangulator.h @@ -40,6 +40,8 @@ namespace Spine { Vector& triangulate(Vector& vertices); Vector< Vector* > decompose(Vector& vertices, Vector& triangles); + + String toString() const; private: Vector< Vector* > _convexPolygons; diff --git a/spine-cpp/spine-cpp/include/spine/Vector.h b/spine-cpp/spine-cpp/include/spine/Vector.h index e16af63e5..c4745a126 100644 --- a/spine-cpp/spine-cpp/include/spine/Vector.h +++ b/spine-cpp/spine-cpp/include/spine/Vector.h @@ -32,12 +32,11 @@ #define Spine_Vector_h #include - +#include +#include #include #include #include -#include -#include namespace Spine { template @@ -109,13 +108,13 @@ namespace Spine { } inline void add(const T &inValue) { - if (_size == _capacity) { + if (_size == _capacity) { _capacity = (int)(_size * 1.75f); if (_capacity < 8) _capacity = 8; _buffer = Spine::SpineExtension::realloc(_buffer, _capacity, __FILE__, __LINE__); - } - construct(_buffer + _size++, inValue); - } + } + construct(_buffer + _size++, inValue); + } inline void removeAt(size_t inIndex) { assert(inIndex < _size); @@ -179,6 +178,18 @@ namespace Spine { return _buffer; } + String toString () const { + String str; + str.append("Vector { size: ").append((int)_size).append(", items: [\n"); + for (size_t i = 0; i < _size; i++) { + str.append(" ").append(_buffer[i]); + if (i != _size - 1) str.append(",\n"); + else str.append("\n"); + } + str.append("] }"); + return str; + } + private: size_t _size; size_t _capacity; diff --git a/spine-cpp/spine-cpp/include/spine/Vertices.h b/spine-cpp/spine-cpp/include/spine/Vertices.h index a2ffd1325..b94e9e073 100644 --- a/spine-cpp/spine-cpp/include/spine/Vertices.h +++ b/spine-cpp/spine-cpp/include/spine/Vertices.h @@ -38,6 +38,10 @@ namespace Spine { public: Vector _bones; Vector _vertices; + + String toString() const { + return String("Vertices"); + }; }; } diff --git a/spine-cpp/spine-cpp/src/spine/Animation.cpp b/spine-cpp/spine-cpp/src/spine/Animation.cpp index 501b994fc..1453dccb2 100644 --- a/spine-cpp/spine-cpp/src/spine/Animation.cpp +++ b/spine-cpp/spine-cpp/src/spine/Animation.cpp @@ -142,4 +142,12 @@ namespace Spine { return -1; } + + String Animation::toString() const { + String str; + str.append("Animation { name: ").appendString(_name).append(", duration: ").append(_duration); + str.append(",\n timelines: ").appendString(_timelines.toString()); + str.append("}"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp index 7b33b5872..0f0c04e5a 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp @@ -91,7 +91,7 @@ namespace Spine { return MathUtil::fmod(_trackTime, duration) + _animationStart; } - return MIN(_trackTime + _animationStart, _animationEnd); + return MathUtil::min(_trackTime + _animationStart, _animationEnd); } float TrackEntry::getTimeScale() { return _timeScale; } @@ -203,13 +203,21 @@ namespace Spine { _onAnimationEventFunc = dummyOnAnimationEventFunc; } - + + String TrackEntry::toString() const { + return String("TrackEntry"); + } + EventQueueEntry::EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event) : _type(eventType), _entry(trackEntry), _event(event) { } - + + String EventQueueEntry::toString() const { + return String("EventQueueEntry"); + } + EventQueue* EventQueue::newEventQueue(AnimationState& state, Pool& trackEntryPool) { return new (__FILE__, __LINE__) EventQueue(state, trackEntryPool); } @@ -292,7 +300,11 @@ namespace Spine { _drainDisabled = false; } - + + String EventQueue::toString() const { + return String("EventQueue"); + } + const int AnimationState::Subsequent = 0; const int AnimationState::First = 1; const int AnimationState::Dip = 2; @@ -804,7 +816,7 @@ namespace Spine { default: pose = MixPose_Setup; TrackEntry* dipMix = timelineDipMix[i]; - alpha = alphaDip * MAX(0, 1 - dipMix->_mixTime / dipMix->_mixDuration); + alpha = alphaDip * MathUtil::max(0.0f, 1 - dipMix->_mixTime / dipMix->_mixDuration); break; } from->_totalAlpha += alpha; @@ -882,7 +894,7 @@ namespace Spine { // Store interrupted mix percentage. if (from->_mixingFrom != NULL && from->_mixDuration > 0) { - current->_interruptAlpha *= MIN(1, from->_mixTime / from->_mixDuration); + current->_interruptAlpha *= MathUtil::min(1.0f, from->_mixTime / from->_mixDuration); } from->_timelinesRotation.clear(); // Reset rotation for mixing out, in case entry was mixed in. @@ -956,4 +968,8 @@ namespace Spine { } } } + + String AnimationState::toString() const { + return String("AnimationState"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp index 673f6fb63..5cd0648f3 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp @@ -73,14 +73,24 @@ namespace Spine { void AnimationStateData::setDefaultMix(float inValue) { _defaultMix = inValue; } - + + String AnimationStateData::toString() const { + return String("AnimationStateData"); + } + AnimationStateData::AnimationPair::AnimationPair(Animation* a1, Animation* a2) : _a1(a1), _a2(a2) { } bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const { return _a1->_name == other._a1->_name && _a2->_name == other._a2->_name; } - + + String AnimationStateData::AnimationPair::toString() const { + String str; + str.append("AnimationPair { ").append(_a1->_name).append(" -> ").append(_a2->_name).append(" } "); + return str; + } + std::size_t AnimationStateData::HashAnimationPair::operator()(const Spine::AnimationStateData::AnimationPair& val) const { std::size_t h1 = 7; size_t strlen = val._a1->_name.length(); diff --git a/spine-cpp/spine-cpp/src/spine/Atlas.cpp b/spine-cpp/spine-cpp/src/spine/Atlas.cpp index 71916b5f6..641b47560 100644 --- a/spine-cpp/spine-cpp/src/spine/Atlas.cpp +++ b/spine-cpp/spine-cpp/src/spine/Atlas.cpp @@ -352,4 +352,8 @@ namespace Spine { int Atlas::toInt(Str* str) { return (int)strtol(str->begin, (char**)&str->end, 10); } + + String Atlas::toString() const { + return String("Atlas"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp b/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp index b8cd1bd0f..0ef7b1a51 100644 --- a/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp +++ b/spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp @@ -111,4 +111,8 @@ namespace Spine { AtlasRegion* ret; return _atlas->findRegion(name); } + + String AtlasAttachmentLoader::toString() const { + return String("AtlasAttachmentLoader"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/Attachment.cpp b/spine-cpp/spine-cpp/src/spine/Attachment.cpp index 246faa984..5fad4b903 100644 --- a/spine-cpp/spine-cpp/src/spine/Attachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/Attachment.cpp @@ -42,7 +42,7 @@ namespace Spine { Attachment::~Attachment() { } - const String& Attachment::getName() { + const String& Attachment::getName() const { return _name; } } diff --git a/spine-cpp/spine-cpp/src/spine/Bone.cpp b/spine-cpp/spine-cpp/src/spine/Bone.cpp index 9b33d7d1f..788510e2f 100644 --- a/spine-cpp/spine-cpp/src/spine/Bone.cpp +++ b/spine-cpp/spine-cpp/src/spine/Bone.cpp @@ -164,12 +164,12 @@ namespace Spine { s = MathUtil::abs(pa * pd - pb * pc) / s; pb = pc * s; pd = pa * s; - prx = MathUtil::atan2(pc, pa) * RadDeg; + prx = MathUtil::atan2(pc, pa) * RAD_DEG; } else { pa = 0; pc = 0; - prx = 90 - MathUtil::atan2(pd, pb) * RadDeg; + prx = 90 - MathUtil::atan2(pd, pb) * RAD_DEG; } float rx = rotation + shearX - prx; float ry = rotation + shearY - prx + 90; @@ -199,7 +199,7 @@ namespace Spine { za *= s; zc *= s; s = MathUtil::sqrt(za * za + zc * zc); - float r = SPINE_PI / 2 + MathUtil::atan2(zc, za); + float r = PI / 2 + MathUtil::atan2(zc, za); float zb = MathUtil::cos(r) * s; float zd = MathUtil::sin(r) * s; float la = MathUtil::cosDeg(shearX) * scaleX; @@ -266,14 +266,14 @@ namespace Spine { float sin = MathUtil::sinDeg(worldRotation); float cos = MathUtil::cosDeg(worldRotation); - return MathUtil::atan2(_a * sin - _c * cos, _d * cos - _b * sin) * RadDeg; + return MathUtil::atan2(_a * sin - _c * cos, _d * cos - _b * sin) * RAD_DEG; } float Bone::localToWorldRotation(float localRotation) { float sin = MathUtil::sinDeg(localRotation); float cos = MathUtil::cosDeg(localRotation); - return MathUtil::atan2(cos * _c + sin * _d, cos * _a + sin * _b) * RadDeg; + return MathUtil::atan2(cos * _c + sin * _d, cos * _a + sin * _b) * RAD_DEG; } void Bone::rotateWorld(float degrees) { @@ -306,7 +306,7 @@ namespace Spine { float a = _a; float c = _c; - return MathUtil::atan2(pa * c - pc * a, pd * a - pb * c) * RadDeg; + return MathUtil::atan2(pa * c - pc * a, pd * a - pb * c) * RAD_DEG; } float Bone::getWorldToLocalRotationY() { @@ -322,7 +322,7 @@ namespace Spine { float b = _b; float d = _d; - return MathUtil::atan2(pa * d - pc * b, pd * b - pb * d) * RadDeg; + return MathUtil::atan2(pa * d - pc * b, pd * b - pb * d) * RAD_DEG; } BoneData& Bone::getData() { @@ -502,11 +502,11 @@ namespace Spine { } float Bone::getWorldRotationX() { - return MathUtil::atan2(_c, _a) * RadDeg; + return MathUtil::atan2(_c, _a) * RAD_DEG; } float Bone::getWorldRotationY() { - return MathUtil::atan2(_d, _b) * RadDeg; + return MathUtil::atan2(_d, _b) * RAD_DEG; } float Bone::getWorldScaleX() { @@ -523,11 +523,11 @@ namespace Spine { if (!parent) { _ax = _worldX; _ay = _worldY; - _arotation = MathUtil::atan2(_c, _a) * RadDeg; + _arotation = MathUtil::atan2(_c, _a) * RAD_DEG; _ascaleX = MathUtil::sqrt(_a * _a + _c * _c); _ascaleY = MathUtil::sqrt(_b * _b + _d * _d); _ashearX = 0; - _ashearY = MathUtil::atan2(_a * _b + _c * _d, _a * _d - _b * _c) * RadDeg; + _ashearY = MathUtil::atan2(_a * _b + _c * _d, _a * _d - _b * _c) * RAD_DEG; return; } @@ -560,14 +560,22 @@ namespace Spine { if (_ascaleX > 0.0001f) { float det = ra * rd - rb * rc; _ascaleY = det / _ascaleX; - _ashearY = MathUtil::atan2(ra * rb + rc * rd, det) * RadDeg; - _arotation = MathUtil::atan2(rc, ra) * RadDeg; + _ashearY = MathUtil::atan2(ra * rb + rc * rd, det) * RAD_DEG; + _arotation = MathUtil::atan2(rc, ra) * RAD_DEG; } else { _ascaleX = 0; _ascaleY = MathUtil::sqrt(rb * rb + rd * rd); _ashearY = 0; - _arotation = 90 - MathUtil::atan2(rd, rb) * RadDeg; + _arotation = 90 - MathUtil::atan2(rd, rb) * RAD_DEG; } } + + String Bone::toString() const { + String str; + str.append("Bone { name: ").appendString(_data.getName()); + str.append(", a: ").append(_a).append(", b: ").append(_b).append(", c").append(_c).append(", d: ").append(_d); + str.append(", worldX: ").append(_worldX).append(", worldY: ").append(_worldY).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/BoneData.cpp b/spine-cpp/spine-cpp/src/spine/BoneData.cpp index 02af9eb41..fa8f2ebcf 100644 --- a/spine-cpp/spine-cpp/src/spine/BoneData.cpp +++ b/spine-cpp/spine-cpp/src/spine/BoneData.cpp @@ -133,4 +133,8 @@ namespace Spine { void BoneData::setTransformMode(TransformMode inValue) { _transformMode = inValue; } + + String BoneData::toString() const { + return String("BoneData"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp b/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp index 37f20e5dd..cdc445e47 100644 --- a/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp @@ -35,4 +35,11 @@ namespace Spine { BoundingBoxAttachment::BoundingBoxAttachment(const String& name) : VertexAttachment(name) { } + + String BoundingBoxAttachment::toString() const { + String str; + str.append("BoundingBoxAttachment { name: ").appendString(getName()).append(", worldVerticesLength: ").append(_worldVerticesLength); + str.append(",\n bones: ").append(_bones).append(",\n weights: ").append(_vertices).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp b/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp index a3633ac61..f56aaa4ac 100644 --- a/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp @@ -45,4 +45,12 @@ namespace Spine { void ClippingAttachment::setEndSlot(SlotData* inValue) { _endSlot = inValue; } + + String ClippingAttachment::toString() const { + String str; + str.append("Clipping { name: ").appendString(getName()); + str.append(", worldVerticesLength: ").append(_worldVerticesLength); + str.append(", bones: ").append(_bones).append(", weights: ").append(_vertices).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/Event.cpp b/spine-cpp/spine-cpp/src/spine/Event.cpp index e1db606e9..38dca0a52 100644 --- a/spine-cpp/spine-cpp/src/spine/Event.cpp +++ b/spine-cpp/spine-cpp/src/spine/Event.cpp @@ -72,4 +72,8 @@ namespace Spine { void Event::setStringValue(const String& inValue) { _stringValue = inValue; } + + String Event::toString() const { + return String("Event"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/EventData.cpp b/spine-cpp/spine-cpp/src/spine/EventData.cpp index 56acb364e..3d6f1a1c9 100644 --- a/spine-cpp/spine-cpp/src/spine/EventData.cpp +++ b/spine-cpp/spine-cpp/src/spine/EventData.cpp @@ -69,4 +69,8 @@ namespace Spine { void EventData::setStringValue(const String& inValue) { _stringValue = inValue; } + + String EventData::toString() const { + return String("EventData"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp index af6424480..fdc200144 100644 --- a/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp +++ b/spine-cpp/spine-cpp/src/spine/IkConstraint.cpp @@ -41,204 +41,143 @@ namespace Spine { RTTI_IMPL(IkConstraint, Constraint); void IkConstraint::apply(Bone& bone, float targetX, float targetY, float alpha) { - if (!bone._appliedValid) { - bone.updateAppliedTransform(); - } - - Bone* parent = bone.getParent(); - Bone& p = *parent; - - float id = 1 / (p._a * p._d - p._b * p._c); - 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 rotationIK = MathUtil::atan2(ty, tx) * RadDeg - bone._ashearX - bone._arotation; - - if (bone._ascaleX < 0) { - rotationIK += 180; - } - - if (rotationIK > 180) { - rotationIK -= 360; - } - else if (rotationIK < -180) { - rotationIK += 360; - } - - bone.updateWorldTransform(bone._ax, bone._ay, bone._arotation + rotationIK * alpha, bone._ascaleX, bone._ascaleY, bone._ashearX, bone._ashearY); + Bone* p = bone.getParent(); + float id, x, y, tx, ty, rotationIK; + if (!bone._appliedValid) bone.updateAppliedTransform(); + id = 1 / (p->_a * p->_d - p->_b * p->_c); + x = targetX - p->_worldX, y = targetY - p->_worldY; + tx = (x * p->_d - y * p->_b) * id - bone._ax; ty = (y * p->_a - x * p->_c) * id - bone._ay; + rotationIK = MathUtil::atan2(ty, tx) * RAD_DEG - bone._ashearX - bone._arotation; + if (bone._ascaleX < 0) rotationIK += 180; + if (rotationIK > 180) rotationIK -= 360; + else if (rotationIK < -180) rotationIK += 360; + bone.updateWorldTransform(bone._ax, bone._ay, bone._arotation + rotationIK * alpha, bone._ascaleX, + bone._ascaleY, bone._ashearX, bone._ashearY); } void IkConstraint::apply(Bone& parent, Bone& child, float targetX, float targetY, int bendDir, float alpha) { - if (MathUtil::areFloatsPracticallyEqual(alpha, 0)) { + float px, py, psx, psy; + float cx, cy, csx, cwx, cwy; + int o1, o2, s2, u; + Bone* pp = parent.getParent(); + float tx, ty, dx, dy, l1, l2, a1, a2, r; + float id, x, y; + if (alpha == 0) { child.updateWorldTransform(); - return; } - - if (!parent._appliedValid) { - parent.updateAppliedTransform(); - } - - if (!child._appliedValid) { - child.updateAppliedTransform(); - } - - float px = parent._ax; - float py = parent._ay; - float psx = parent._ascaleX; - float psy = parent._ascaleY; - float csx = child._ascaleX; - - int os1, os2, s2; + if (!parent._appliedValid) parent.updateAppliedTransform(); + if (!child._appliedValid) child.updateAppliedTransform(); + px = parent._ax; py = parent._ay; psx = parent._ascaleX; psy = parent._ascaleY; csx = child._ascaleX; if (psx < 0) { psx = -psx; - os1 = 180; + o1 = 180; s2 = -1; - } - else { - os1 = 0; + } else { + o1 = 0; s2 = 1; } - if (psy < 0) { psy = -psy; s2 = -s2; } - if (csx < 0) { csx = -csx; - os2 = 180; - } - else { - os2 = 0; - } - - float cx = child._ax; - float cy; - float cwx; - float cwy; - float a = parent._a; - float b = parent._b; - float c = parent._c; - float d = parent._d; - - bool u = MathUtil::abs(psx - psy) <= 0.0001f; + o2 = 180; + } else + o2 = 0; + r = psx - psy; + cx = child._ax; + u = (r < 0 ? -r : r) <= 0.0001f; if (!u) { cy = 0; - cwx = a * cx + parent._worldX; - cwy = c * cx + parent._worldY; - } - else { + cwx = parent._a * cx + parent._worldX; + cwy = parent._c * cx + parent._worldY; + } else { cy = child._ay; - cwx = a * cx + b * cy + parent._worldX; - cwy = c * cx + d * cy + parent._worldY; + cwx = parent._a * cx + parent._b * cy + parent._worldX; + cwy = parent._c * cx + parent._d * cy + parent._worldY; } - - Bone* parentparent = parent._parent; - Bone& pp = *parentparent; - - a = pp._a; - b = pp._b; - c = pp._c; - d = pp._d; - - float id = 1 / (a * d - b * c), x = targetX - pp._worldX, y = targetY - pp._worldY; - float tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py; - x = cwx - pp._worldX; - y = cwy - pp._worldY; - float dx = (x * d - y * b) * id - px, dy = (y * a - x * c) * id - py; - float l1 = MathUtil::sqrt(dx * dx + dy * dy), l2 = child._data.getLength() * csx, a1, a2; + id = 1 / (pp->_a * pp->_d - pp->_b * pp->_c); + x = targetX - pp->_worldX; + y = targetY - pp->_worldY; + tx = (x * pp->_d - y * pp->_b) * id - px; + ty = (y * pp->_a - x * pp->_c) * id - py; + x = cwx - pp->_worldX; + y = cwy - pp->_worldY; + dx = (x * pp->_d - y * pp->_b) * id - px; + dy = (y * pp->_a - x * pp->_c) * id - py; + l1 = MathUtil::sqrt(dx * dx + dy * dy); + l2 = child.getData().getLength() * csx; if (u) { + float cosine, a, b; l2 *= psx; - float cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2); - if (cos < -1) { - cos = -1; - } - else if (cos > 1) { - cos = 1; - } - - a2 = MathUtil::acos(cos) * bendDir; - a = l1 + l2 * cos; + cosine = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2); + if (cosine < -1) cosine = -1; + else if (cosine > 1) cosine = 1; + a2 = MathUtil::acos(cosine) * bendDir; + a = l1 + l2 * cosine; b = l2 * MathUtil::sin(a2); a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b); - } - else { - a = psx * l2; - b = psy * l2; - float aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = MathUtil::atan2(ty, tx); - c = bb * l1 * l1 + aa * dd - aa * bb; - float c1 = -2 * bb * l1, c2 = bb - aa; - d = c1 * c1 - 4 * c2 * c; + } else { + float a = psx * l2, b = psy * l2; + float aa = a * a, bb = b * b, ll = l1 * l1, dd = tx * tx + ty * ty, ta = MathUtil::atan2(ty, tx); + float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa; + float d = c1 * c1 - 4 * c2 * c0; if (d >= 0) { - float q = MathUtil::sqrt(d); + float q = MathUtil::sqrt(d), r0, r1; if (c1 < 0) q = -q; q = -(c1 + q) / 2; - float r0 = q / c2, r1 = c / q; - float r = MathUtil::abs(r0) < MathUtil::abs(r1) ? r0 : r1; + r0 = q / c2; r1 = c0 / q; + r = MathUtil::abs(r0) < MathUtil::abs(r1) ? r0 : r1; if (r * r <= dd) { y = MathUtil::sqrt(dd - r * r) * bendDir; a1 = ta - MathUtil::atan2(y, r); a2 = MathUtil::atan2(y / psy, (r - l1) / psx); - - float os = MathUtil::atan2(cy, cx) * s2; - float rotation = parent._arotation; - a1 = (a1 - os) * RadDeg + os1 - rotation; - if (a1 > 180) { - a1 -= 360; - } - else if (a1 < -180) { - a1 += 360; - } - - parent.updateWorldTransform(px, py, rotation + a1 * alpha, parent._scaleX, parent._ascaleY, 0, 0); - rotation = child._arotation; - a2 = ((a2 + os) * RadDeg - child._ashearX) * s2 + os2 - rotation; - - if (a2 > 180) { - a2 -= 360; - } - else if (a2 < -180) { - a2 += 360; - } - - child.updateWorldTransform(cx, cy, rotation + a2 * alpha, child._ascaleX, child._ascaleY, child._ashearX, child._ashearY); - - return; + goto break_outer; } } - - float minAngle = SPINE_PI, minX = l1 - a, minDist = minX * minX, minY = 0; - float maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; - c = -a * l1 / (aa - bb); - if (c >= -1 && c <= 1) { - c = MathUtil::acos(c); - x = a * MathUtil::cos(c) + l1; - y = b * (float)MathUtil::sin(c); - d = x * x + y * y; - - if (d < minDist) { - minAngle = c; - minDist = d; - minX = x; - minY = y; + { + float minAngle = PI, minX = l1 - a, minDist = minX * minX, minY = 0; + float maxAngle = 0, maxX = l1 + a, maxDist = maxX * maxX, maxY = 0; + c0 = -a * l1 / (aa - bb); + if (c0 >= -1 && c0 <= 1) { + c0 = MathUtil::acos(c0); + x = a * MathUtil::cos(c0) + l1; + y = b * MathUtil::sin(c0); + d = x * x + y * y; + if (d < minDist) { + minAngle = c0; + minDist = d; + minX = x; + minY = y; + } + if (d > maxDist) { + maxAngle = c0; + maxDist = d; + maxX = x; + maxY = y; + } } - - if (d > maxDist) { - maxAngle = c; - maxDist = d; - maxX = x; - maxY = y; + if (dd <= (minDist + maxDist) / 2) { + a1 = ta - MathUtil::atan2(minY * bendDir, minX); + a2 = minAngle * bendDir; + } else { + a1 = ta - MathUtil::atan2(maxY * bendDir, maxX); + a2 = maxAngle * bendDir; } } - - if (dd <= (minDist + maxDist) / 2) { - a1 = ta - MathUtil::atan2(minY * bendDir, minX); - a2 = minAngle * bendDir; - } - else { - a1 = ta - MathUtil::atan2(maxY * bendDir, maxX); - a2 = maxAngle * bendDir; - } + } + break_outer: { + float os = MathUtil::atan2(cy, cx) * s2; + a1 = (a1 - os) * RAD_DEG + o1 - parent._arotation; + if (a1 > 180) a1 -= 360; + else if (a1 < -180) a1 += 360; + parent.updateWorldTransform(px, py, parent._rotation + a1 * alpha, parent._ascaleX, parent._ascaleY, 0, 0); + a2 = ((a2 + os) * RAD_DEG - child._ashearX) * s2 + o2 - child._arotation; + if (a2 > 180) a2 -= 360; + else if (a2 < -180) a2 += 360; + child.updateWorldTransform(cx, cy, child._arotation + a2 * alpha, child._ascaleX, child._ascaleY, child._ashearX, child._ashearY); } } @@ -310,4 +249,11 @@ namespace Spine { void IkConstraint::setMix(float inValue) { _mix = inValue; } + + String IkConstraint::toString() const { + String str; + str.append("IkConstraint { name: ").appendString(_data.getName()); + str.append("}"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp index 6e899f65c..e495b7ecd 100644 --- a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp @@ -80,4 +80,8 @@ namespace Spine { void IkConstraintData::setMix(float inValue) { _mix = inValue; } + + String IkConstraintData::toString() const { + return String("IkConstraintData"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/Json.cpp b/spine-cpp/spine-cpp/src/spine/Json.cpp index 1e1285260..7d98b2449 100644 --- a/spine-cpp/spine-cpp/src/spine/Json.cpp +++ b/spine-cpp/spine-cpp/src/spine/Json.cpp @@ -42,6 +42,8 @@ #endif #include +#include +#include #include #include @@ -49,7 +51,6 @@ #include #include /* strtod (C89), strtof (C99) */ #include /* strcasecmp (4.4BSD - compatibility), _stricmp (_WIN32) */ -#include #include namespace Spine { @@ -549,4 +550,8 @@ namespace Spine { } } } + + String Json::toString() const { + return String("Json"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp b/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp index e7f2e780f..1392e41b4 100644 --- a/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp +++ b/spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp @@ -39,4 +39,8 @@ namespace Spine { _slotIndex(slotIndex), _parent(parent) { } + + String LinkedMesh::toString() const { + return String("LinkedMesh"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/MathUtil.cpp b/spine-cpp/spine-cpp/src/spine/MathUtil.cpp index 1d3e3f628..a17085acc 100644 --- a/spine-cpp/spine-cpp/src/spine/MathUtil.cpp +++ b/spine-cpp/spine-cpp/src/spine/MathUtil.cpp @@ -72,12 +72,12 @@ namespace Spine { /// Returns the sine in radians from a lookup table. float MathUtil::sinDeg(float degrees) { - return ::sin(degrees * DegRad); + return ::sin(degrees * DEG_RAD); } /// Returns the cosine in radians from a lookup table. float MathUtil::cosDeg(float degrees) { - return ::cos(degrees * DegRad); + return ::cos(degrees * DEG_RAD); } /// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323 diff --git a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp index 110dcb7a7..43010f4f4 100644 --- a/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp @@ -270,4 +270,10 @@ Spine::Color& MeshAttachment::getColor() { return _color; } + + String MeshAttachment::toString() const { + String str; + str.append("RegionAttachment { name: ").appendString(getName()).append(", path: ").appendString(_path).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp index fad54fca1..bec550e6e 100644 --- a/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathAttachment.cpp @@ -59,4 +59,12 @@ namespace Spine { void PathAttachment::setConstantSpeed(bool inValue) { _constantSpeed = inValue; } + + String PathAttachment::toString() const { + String str; + str.append("PathAttachment { name: ").appendString(getName()).append(", closed: ").append(_closed).append(", constantSpeed: ").append(_constantSpeed); + str.append(", worldVerticesLength: ").append(_worldVerticesLength); + str.append(", bones: ").append(_bones).append(", weights: ").append(_vertices).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp b/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp index 5cd1190e6..9ecf614c2 100644 --- a/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathConstraint.cpp @@ -139,8 +139,8 @@ namespace Spine { } else { tip = false; - Bone p = _target->getBone(); - offsetRotation *= p.getA() * p.getD() - p.getB() * p.getC() > 0 ? DegRad : -DegRad; + Bone& p = _target->getBone(); + offsetRotation *= p.getA() * p.getD() - p.getB() * p.getC() > 0 ? DEG_RAD : -DEG_RAD; } for (int i = 0, p = 3; i < boneCount; i++, p += 3) { @@ -189,11 +189,11 @@ namespace Spine { r += offsetRotation; } - if (r > SPINE_PI) { - r -= SPINE_PI_2; + if (r > PI) { + r -= PI_2; } - else if (r < -SPINE_PI) { - r += SPINE_PI_2; + else if (r < -PI) { + r += PI_2; } r *= rotateMix; @@ -557,4 +557,10 @@ namespace Spine { output[o + 2] = MathUtil::atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt)); } } + + String PathConstraint::toString() const { + String str; + str.append("TransformConstraint { name: ").appendString(_data.getName()).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp index 24ff73ddf..3e9667028 100644 --- a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp @@ -138,4 +138,10 @@ namespace Spine { void PathConstraintData::setTranslateMix(float inValue) { _translateMix = inValue; } + + String PathConstraintData::toString() const { + String str; + str.append("PathConstraintData { name: ").appendString(_name).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp index 4bc4ea122..1ab7d28f7 100644 --- a/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/PointAttachment.cpp @@ -50,7 +50,7 @@ namespace Spine { float ix = cos * bone._a + sin * bone._b; float iy = cos * bone._c + sin * bone._d; - return MathUtil::atan2(iy, ix) * RadDeg; + return MathUtil::atan2(iy, ix) * RAD_DEG; } float PointAttachment::getX() { @@ -76,4 +76,10 @@ namespace Spine { void PointAttachment::setRotation(float inValue) { _rotation = inValue; } + + String PointAttachment::toString() const { + String str; + str.append("PointAttachment { name: ").appendString(getName()).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/RTTI.cpp b/spine-cpp/spine-cpp/src/spine/RTTI.cpp index f05bf1bea..9d472c8c2 100644 --- a/spine-cpp/spine-cpp/src/spine/RTTI.cpp +++ b/spine-cpp/spine-cpp/src/spine/RTTI.cpp @@ -59,4 +59,10 @@ namespace Spine { return false; } + + String RTTI::toString() const { + String str; + str.append("RTTI { name: ").append(_className.c_str()).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp index 433cac3bf..5b78d97d4 100644 --- a/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp @@ -287,4 +287,10 @@ namespace Spine { Spine::Color& RegionAttachment::getColor() { return _color; } + + String RegionAttachment::toString() const { + String str; + str.append("RegionAttachment { name: ").appendString(getName()).append(", path: ").appendString(_path).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp index 329539419..8298ea6b4 100644 --- a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp @@ -431,10 +431,10 @@ namespace Spine { float vx = outVertexBuffer[ii]; float vy = outVertexBuffer[ii + 1]; - minX = MIN(minX, vx); - minY = MIN(minY, vy); - maxX = MAX(maxX, vx); - maxY = MAX(maxY, vy); + minX = MathUtil::min(minX, vx); + minY = MathUtil::min(minY, vy); + maxX = MathUtil::max(maxX, vx); + maxY = MathUtil::max(maxY, vy); } } @@ -649,4 +649,16 @@ namespace Spine { bone->_sorted = false; } } + + String Skeleton::toString() const { + String str; + + str.append("Skeleton {\n"); + str.append(" bones: ").append(_bones); + str.append(",\n slots: ").append(_slots); + str.append(",\n drawOrder: ").append(_drawOrder); + str.append(",\n animations: ").append(_data->getAnimations()); + str.append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp index 8b1798a1a..bb11111b6 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp @@ -646,7 +646,7 @@ namespace Spine { timeline->setFrame(frameIndex, readFloat(input), String(readString(input), true)); } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[frameCount - 1]); + duration = MathUtil::max(duration, timeline->_frames[frameCount - 1]); break; } case SLOT_COLOR: { @@ -665,7 +665,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * ColorTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * ColorTimeline::ENTRIES]); break; } case SLOT_TWO_COLOR: { @@ -689,7 +689,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * TwoColorTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * TwoColorTimeline::ENTRIES]); break; } default: { @@ -718,7 +718,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * RotateTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * RotateTimeline::ENTRIES]); break; } case BONE_TRANSLATE: @@ -744,7 +744,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * TranslateTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * TranslateTimeline::ENTRIES]); break; } default: { @@ -769,7 +769,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * IkConstraintTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * IkConstraintTimeline::ENTRIES]); } // Transform constraint timelines. @@ -785,7 +785,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * TransformConstraintTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * TransformConstraintTimeline::ENTRIES]); } // Path constraint timelines. @@ -822,7 +822,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintPositionTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * PathConstraintPositionTimeline::ENTRIES]); break; } case PATH_MIX: { @@ -836,7 +836,7 @@ namespace Spine { } } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintMixTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * PathConstraintMixTimeline::ENTRIES]); break; } } @@ -915,7 +915,7 @@ namespace Spine { } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[frameCount - 1]); + duration = MathUtil::max(duration, timeline->_frames[frameCount - 1]); } } } @@ -964,7 +964,7 @@ namespace Spine { timeline->setFrame(i, time, drawOrder); } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[drawOrderCount - 1]); + duration = MathUtil::max(duration, timeline->_frames[drawOrderCount - 1]); } // Event timeline. @@ -989,7 +989,7 @@ namespace Spine { } timelines.add(timeline); - duration = MAX(duration, timeline->_frames[eventCount - 1]); + duration = MathUtil::max(duration, timeline->_frames[eventCount - 1]); } return new (__FILE__, __LINE__) Animation(String(name), timelines, duration); @@ -1011,4 +1011,8 @@ namespace Spine { } } } + + String SkeletonBinary::toString() const { + return String("SkeletonBinary"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp index 610338ecb..5858e09ba 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp @@ -222,10 +222,10 @@ namespace Spine { for (int ii = 0, nn = polygon->_count; ii < nn; ii += 2) { float x = vertices[ii]; float y = vertices[ii + 1]; - minX = MIN(minX, x); - minY = MIN(minY, y); - maxX = MAX(maxX, x); - maxY = MAX(maxY, y); + minX = MathUtil::min(minX, x); + minY = MathUtil::min(minY, y); + maxX = MathUtil::max(maxX, x); + maxY = MathUtil::max(maxY, y); } } _minX = minX; @@ -233,5 +233,15 @@ namespace Spine { _maxX = maxX; _maxY = maxY; } + + String SkeletonBounds::toString() const { + return String("SkeletonBounds"); + } + + String Polygon::toString() const { + String str; + str.append("Polygon { count: ").append(_count).append(", vertices: ").append(_vertices).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp index 306159734..158d3d4cc 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp @@ -96,8 +96,10 @@ namespace Spine { clippedVertices.clear(); _clippedUVs.clear(); clippedTriangles.clear(); - - for (int i = 0; i < trianglesLength; i += 3) { + + int i = 0; + continue_outer: + for (; i < trianglesLength; i += 3) { int vertexOffset = triangles[i] << 1; float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1]; float u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1]; @@ -170,7 +172,8 @@ namespace Spine { clippedTriangles[s + 1] = index + 1; clippedTriangles[s + 2] = index + 2; index += 3; - break; + i += 3; + goto continue_outer; } } } @@ -312,4 +315,8 @@ namespace Spine { polygon[other + 1] = y; } } + + String SkeletonClipping::toString() const { + return String("SkeletonClipping"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp index 578ce28d3..d0f76b180 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp @@ -232,4 +232,8 @@ namespace Spine { void SkeletonData::setFps(float inValue) { _fps = inValue; } + + String SkeletonData::toString() const { + return String("SkeletonData"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp index c395e2170..94083692e 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp @@ -810,7 +810,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[timelineMap->_size - 1]); + duration = MathUtil::max(duration, timeline->_frames[timelineMap->_size - 1]); } else if (strcmp(timelineMap->_name, "color") == 0) { @@ -825,7 +825,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * ColorTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * ColorTimeline::ENTRIES]); } else if (strcmp(timelineMap->_name, "twoColor") == 0) { @@ -842,7 +842,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TwoColorTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * TwoColorTimeline::ENTRIES]); } else { ContainerUtil::cleanUpVectorOfPointers(timelines); @@ -875,7 +875,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * RotateTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * RotateTimeline::ENTRIES]); } else { int isScale = strcmp(timelineMap->_name, "scale") == 0; @@ -902,7 +902,7 @@ namespace Spine { timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TranslateTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * TranslateTimeline::ENTRIES]); } else { ContainerUtil::cleanUpVectorOfPointers(timelines); @@ -930,7 +930,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(constraintMap->_size - 1) * IkConstraintTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(constraintMap->_size - 1) * IkConstraintTimeline::ENTRIES]); } /** Transform constraint timelines. */ @@ -950,7 +950,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(constraintMap->_size - 1) * TransformConstraintTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(constraintMap->_size - 1) * TransformConstraintTimeline::ENTRIES]); } /** Path constraint timelines. */ @@ -999,7 +999,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintPositionTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintPositionTimeline::ENTRIES]); } else if (strcmp(timelineName, "mix") == 0) { PathConstraintMixTimeline* timeline = new (__FILE__, __LINE__) PathConstraintMixTimeline(timelineMap->_size); @@ -1010,7 +1010,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintMixTimeline::ENTRIES]); + duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintMixTimeline::ENTRIES]); } } } @@ -1085,7 +1085,7 @@ namespace Spine { timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[timelineMap->_size - 1]); + duration = MathUtil::max(duration, timeline->_frames[timelineMap->_size - 1]); } } } @@ -1141,7 +1141,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[drawOrder->_size - 1]); + duration = MathUtil::max(duration, timeline->_frames[drawOrder->_size - 1]); } /** Event timeline. */ @@ -1165,7 +1165,7 @@ namespace Spine { } timelines.add(timeline); timelinesCount++; - duration = MAX(duration, timeline->_frames[events->_size - 1]); + duration = MathUtil::max(duration, timeline->_frames[events->_size - 1]); } return new (__FILE__, __LINE__) Animation(String(root->_name), timelines, duration); @@ -1217,8 +1217,12 @@ namespace Spine { } void SkeletonJson::setError(Json* root, const String& value1, const String& value2) { - _error = String(value1 + value2); + _error = String(value1).append(value2); delete root; } + + String SkeletonJson::toString() const { + return String("SkeletonJson"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/Skin.cpp b/spine-cpp/spine-cpp/src/spine/Skin.cpp index 7c66c6410..fc169daac 100644 --- a/spine-cpp/spine-cpp/src/spine/Skin.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skin.cpp @@ -46,8 +46,14 @@ namespace Spine { bool Skin::AttachmentKey::operator==(const AttachmentKey &other) const { return _slotIndex == other._slotIndex && _name == other._name; } - - std::size_t Skin::HashAttachmentKey::operator()(const Spine::Skin::AttachmentKey& val) const { + + String Skin::AttachmentKey::toString() const { + String str; + str.append("AttachmentKey { slotIndex: ").append(_slotIndex).append(", name: ").appendString(_name).append(" }"); + return str; + } + + std::size_t Skin::HashAttachmentKey::operator()(const Spine::Skin::AttachmentKey& val) const { std::size_t h1 = val._slotIndex; return h1; } @@ -122,4 +128,12 @@ namespace Spine { } } } + + String Skin::toString() const { + String str; + str.append("Skin { name: ").appendString(_name); + str.append(",\n attachments: ").append(_attachments); + str.append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/Slot.cpp b/spine-cpp/spine-cpp/src/spine/Slot.cpp index 615ac6e62..2df778d21 100644 --- a/spine-cpp/spine-cpp/src/spine/Slot.cpp +++ b/spine-cpp/spine-cpp/src/spine/Slot.cpp @@ -118,4 +118,13 @@ namespace Spine { void Slot::setAttachmentVertices(Vector inValue) { _attachmentVertices = inValue; } + + String Slot::toString() const { + String str; + str.append("Slot { name: ").appendString(_data.getName()); + str.append(", color: ").appendString(_color.toString()); + if (_hasDarkColor) str.append(", darkColor: ").appendString(_darkColor.toString()); + str.append("}"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/SlotData.cpp b/spine-cpp/spine-cpp/src/spine/SlotData.cpp index 0d402c833..71bdb3f22 100644 --- a/spine-cpp/spine-cpp/src/spine/SlotData.cpp +++ b/spine-cpp/spine-cpp/src/spine/SlotData.cpp @@ -89,4 +89,8 @@ namespace Spine { void SlotData::setBlendMode(BlendMode inValue) { _blendMode = inValue; } + + String SlotData::toString() const { + return String("SlotData"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/Timeline.cpp b/spine-cpp/spine-cpp/src/spine/Timeline.cpp index 524eb5758..e265841dd 100644 --- a/spine-cpp/spine-cpp/src/spine/Timeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/Timeline.cpp @@ -41,4 +41,10 @@ namespace Spine { Timeline::~Timeline() { } + + String Timeline::toString() const { + String str; + str.appendString(getRTTI().toString()); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/TransformConstraint.cpp b/spine-cpp/spine-cpp/src/spine/TransformConstraint.cpp index 883ca78fc..1cf89a290 100644 --- a/spine-cpp/spine-cpp/src/spine/TransformConstraint.cpp +++ b/spine-cpp/spine-cpp/src/spine/TransformConstraint.cpp @@ -134,7 +134,7 @@ namespace Spine { float rotateMix = _rotateMix, translateMix = _translateMix, scaleMix = _scaleMix, shearMix = _shearMix; Bone& target = *_target; float ta = target._a, tb = target._b, tc = target._c, td = target._d; - float degRadReflect = ta * td - tb * tc > 0 ? DegRad : -DegRad; + float degRadReflect = ta * td - tb * tc > 0 ? DEG_RAD : -DEG_RAD; float offsetRotation = _data._offsetRotation * degRadReflect, offsetShearY = _data._offsetShearY * degRadReflect; for (size_t i = 0; i < _bones.size(); ++i) { @@ -146,11 +146,11 @@ namespace Spine { if (rotateMix != 0) { float a = bone._a, b = bone._b, c = bone._c, d = bone._d; float r = MathUtil::atan2(tc, ta) - MathUtil::atan2(c, a) + offsetRotation; - if (r > SPINE_PI) { - r -= SPINE_PI_2; + if (r > PI) { + r -= PI_2; } - else if (r < -SPINE_PI) { - r += SPINE_PI_2; + else if (r < -PI) { + r += PI_2; } r *= rotateMix; @@ -192,11 +192,11 @@ namespace Spine { float b = bone._b, d = bone._d; float by = MathUtil::atan2(d, b); float r = MathUtil::atan2(td, tb) - MathUtil::atan2(tc, ta) - (by - MathUtil::atan2(bone._c, bone._a)); - if (r > SPINE_PI) { - r -= SPINE_PI_2; + if (r > PI) { + r -= PI_2; } - else if (r < -SPINE_PI) { - r += SPINE_PI_2; + else if (r < -PI) { + r += PI_2; } r = by + (r + offsetShearY) * shearMix; @@ -216,7 +216,7 @@ namespace Spine { float rotateMix = _rotateMix, translateMix = _translateMix, scaleMix = _scaleMix, shearMix = _shearMix; Bone& target = *_target; float ta = target._a, tb = target._b, tc = target._c, td = target._d; - float degRadReflect = ta * td - tb * tc > 0 ? DegRad : -DegRad; + float degRadReflect = ta * td - tb * tc > 0 ? DEG_RAD : -DEG_RAD; float offsetRotation = _data._offsetRotation * degRadReflect, offsetShearY = _data._offsetShearY * degRadReflect; for (size_t i = 0; i < _bones.size(); ++i) { Bone* item = _bones[i]; @@ -227,11 +227,11 @@ namespace Spine { if (rotateMix != 0) { float a = bone._a, b = bone._b, c = bone._c, d = bone._d; float r = MathUtil::atan2(tc, ta) + offsetRotation; - if (r > SPINE_PI) { - r -= SPINE_PI_2; + if (r > PI) { + r -= PI_2; } - else if (r < -SPINE_PI) { - r += SPINE_PI_2; + else if (r < -PI) { + r += PI_2; } r *= rotateMix; @@ -263,15 +263,15 @@ namespace Spine { if (shearMix > 0) { float r = MathUtil::atan2(td, tb) - MathUtil::atan2(tc, ta); - if (r > SPINE_PI) { - r -= SPINE_PI_2; + if (r > PI) { + r -= PI_2; } - else if (r < -SPINE_PI) { - r += SPINE_PI_2; + else if (r < -PI) { + r += PI_2; } float b = bone._b, d = bone._d; - r = MathUtil::atan2(d, b) + (r - SPINE_PI / 2 + offsetShearY) * shearMix; + r = MathUtil::atan2(d, b) + (r - PI / 2 + offsetShearY) * shearMix; float s = MathUtil::sqrt(b * b + d * d); bone._b = MathUtil::cos(r) * s; bone._d = MathUtil::sin(r) * s; @@ -379,4 +379,10 @@ namespace Spine { bone.updateWorldTransform(x, y, rotation, scaleX, scaleY, bone._ashearX, shearY); } } + + String TransformConstraint::toString() const { + String str; + str.append("TransformConstraint { name: ").appendString(_data.getName()).append(" }"); + return str; + } } diff --git a/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp index e69fc4c05..0708bdb35 100644 --- a/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp @@ -116,4 +116,8 @@ namespace Spine { bool TransformConstraintData::isLocal() { return _local; } + + String TransformConstraintData::toString() const { + return String("TransformConstraintData"); + } } diff --git a/spine-cpp/spine-cpp/src/spine/Triangulator.cpp b/spine-cpp/spine-cpp/src/spine/Triangulator.cpp index f4822a2fa..d5427db36 100644 --- a/spine-cpp/spine-cpp/src/spine/Triangulator.cpp +++ b/spine-cpp/spine-cpp/src/spine/Triangulator.cpp @@ -53,7 +53,7 @@ namespace Spine { Vector& triangles = _triangles; triangles.clear(); - triangles.ensureCapacity(MAX(0, vertexCount - 2) << 2); + triangles.ensureCapacity(MathUtil::max(0, vertexCount - 2) << 2); while (vertexCount > 3) { // Find ear tip. @@ -293,4 +293,8 @@ namespace Spine { return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1; } + + String Triangulator::toString() const { + return String("Triangulator"); + } } diff --git a/spine-sfml/cpp/example/main.cpp b/spine-sfml/cpp/example/main.cpp index c69bd056c..bd0da368f 100644 --- a/spine-sfml/cpp/example/main.cpp +++ b/spine-sfml/cpp/example/main.cpp @@ -340,6 +340,7 @@ void coin (SkeletonData* skeletonData, Atlas* atlas) { skeleton->updateWorldTransform(); drawable->state->setAnimation(0, "rotate", true); + drawable->update(0.1); sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - vine"); window.setFramerateLimit(60); @@ -353,7 +354,7 @@ void coin (SkeletonData* skeletonData, Atlas* atlas) { float delta = deltaClock.getElapsedTime().asSeconds(); deltaClock.restart(); - drawable->update(delta); + // drawable->update(delta); window.clear(); window.draw(*drawable); @@ -394,12 +395,12 @@ void owl (SkeletonData* skeletonData, Atlas* atlas) { if (event.type == sf::Event::Closed) window.close(); if (event.type == sf::Event::MouseMoved) { float x = event.mouseMove.x / 640.0f; - left->setAlpha((MAX(x, 0.5f) - 0.5f) * 2); - right->setAlpha((0.5 - MIN(x, 0.5)) * 2); + left->setAlpha((MathUtil::max(x, 0.5f) - 0.5f) * 2); + right->setAlpha((0.5 - MathUtil::min(x, 0.5f)) * 2); float y = event.mouseMove.y / 640.0f; - down->setAlpha((MAX(y, 0.5f) - 0.5f) * 2); - up->setAlpha((0.5 - MIN(y, 0.5)) * 2); + down->setAlpha((MathUtil::max(y, 0.5f) - 0.5f) * 2); + up->setAlpha((0.5 - MathUtil::min(y, 0.5f)) * 2); } } @@ -425,14 +426,10 @@ void test (SkeletonData* skeletonData, Atlas* atlas) { float d = 3; for (int i = 0; i < 1; i++) { - skeleton->update(d); animState->update(d); animState->apply(*skeleton); skeleton->updateWorldTransform(); - for (int ii = 0; ii < skeleton->getBones().size(); ii++) { - Bone* bone = skeleton->getBones()[ii]; - printf("%s %f %f %f %f %f %f\n", bone->getData().getName().buffer(), bone->getA(), bone->getB(), bone->getC(), bone->getD(), bone->getWorldX(), bone->getWorldY()); - } + printf("%s\n", skeleton->toString().buffer()); printf("========================================\n"); d += 0.1f; } @@ -444,15 +441,16 @@ void test (SkeletonData* skeletonData, Atlas* atlas) { int main () { DebugExtension dbgExtension; - SpineExtension::setInstance(&dbgExtension); - /*testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f); + // SpineExtension::setInstance(&dbgExtension); + testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f); + testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f); testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f); testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f); testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f); testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine.atlas", 0.5f); testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 0.2f); testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f); - testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins.atlas", 1.4f);*/ + testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins.atlas", 1.4f); testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman.atlas", 0.6f); dbgExtension.reportLeaks(); return 0; diff --git a/spine-sfml/cpp/src/spine/spine-sfml.cpp b/spine-sfml/cpp/src/spine/spine-sfml.cpp index 34772fbc9..803960563 100644 --- a/spine-sfml/cpp/src/spine/spine-sfml.cpp +++ b/spine-sfml/cpp/src/spine/spine-sfml.cpp @@ -296,4 +296,8 @@ void SFMLTextureLoader::load(AtlasPage &page, const String &path) { void SFMLTextureLoader::unload(void *texture) { delete (Texture*)texture; } + + String SFMLTextureLoader::toString() const { + return String("SFMLTextureLoader"); + } } /* namespace spine */ diff --git a/spine-sfml/cpp/src/spine/spine-sfml.h b/spine-sfml/cpp/src/spine/spine-sfml.h index 8db10f741..91778eb93 100644 --- a/spine-sfml/cpp/src/spine/spine-sfml.h +++ b/spine-sfml/cpp/src/spine/spine-sfml.h @@ -71,6 +71,8 @@ public: virtual void load(AtlasPage& page, const String& path); virtual void unload(void* texture); + + String toString() const; }; } /* namespace spine */