Просмотр исходного кода

[cpp] Added toString method for SpineObjects, fixed up math, fixed up IKConstraint.

badlogic 7 лет назад
Родитель
Сommit
7a18b81226
85 измененных файлов с 646 добавлено и 316 удалено
  1. 2 0
      spine-cpp/spine-cpp/include/spine/Animation.h
  2. 8 1
      spine-cpp/spine-cpp/include/spine/AnimationState.h
  3. 5 1
      spine-cpp/spine-cpp/include/spine/AnimationStateData.h
  4. 17 0
      spine-cpp/spine-cpp/include/spine/Atlas.h
  5. 2 0
      spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h
  6. 1 1
      spine-cpp/spine-cpp/include/spine/Attachment.h
  7. 0 1
      spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h
  8. 2 1
      spine-cpp/spine-cpp/include/spine/Bone.h
  9. 2 0
      spine-cpp/spine-cpp/include/spine/BoneData.h
  10. 2 0
      spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h
  11. 2 0
      spine-cpp/spine-cpp/include/spine/ClippingAttachment.h
  12. 7 1
      spine-cpp/spine-cpp/include/spine/Color.h
  13. 2 0
      spine-cpp/spine-cpp/include/spine/Event.h
  14. 3 1
      spine-cpp/spine-cpp/include/spine/EventData.h
  15. 24 1
      spine-cpp/spine-cpp/include/spine/HashMap.h
  16. 2 0
      spine-cpp/spine-cpp/include/spine/IkConstraint.h
  17. 3 1
      spine-cpp/spine-cpp/include/spine/IkConstraintData.h
  18. 2 1
      spine-cpp/spine-cpp/include/spine/Json.h
  19. 2 1
      spine-cpp/spine-cpp/include/spine/LinkedMesh.h
  20. 9 19
      spine-cpp/spine-cpp/include/spine/MathUtil.h
  21. 2 0
      spine-cpp/spine-cpp/include/spine/MeshAttachment.h
  22. 2 0
      spine-cpp/spine-cpp/include/spine/PathAttachment.h
  23. 2 0
      spine-cpp/spine-cpp/include/spine/PathConstraint.h
  24. 2 1
      spine-cpp/spine-cpp/include/spine/PathConstraintData.h
  25. 2 0
      spine-cpp/spine-cpp/include/spine/PointAttachment.h
  26. 6 0
      spine-cpp/spine-cpp/include/spine/Pool.h
  27. 5 4
      spine-cpp/spine-cpp/include/spine/RTTI.h
  28. 2 0
      spine-cpp/spine-cpp/include/spine/RegionAttachment.h
  29. 3 1
      spine-cpp/spine-cpp/include/spine/Skeleton.h
  30. 4 0
      spine-cpp/spine-cpp/include/spine/SkeletonBinary.h
  31. 4 0
      spine-cpp/spine-cpp/include/spine/SkeletonBounds.h
  32. 2 0
      spine-cpp/spine-cpp/include/spine/SkeletonClipping.h
  33. 3 1
      spine-cpp/spine-cpp/include/spine/SkeletonData.h
  34. 2 0
      spine-cpp/spine-cpp/include/spine/SkeletonJson.h
  35. 5 1
      spine-cpp/spine-cpp/include/spine/Skin.h
  36. 3 1
      spine-cpp/spine-cpp/include/spine/Slot.h
  37. 3 1
      spine-cpp/spine-cpp/include/spine/SlotData.h
  38. 1 0
      spine-cpp/spine-cpp/include/spine/SpineObject.h
  39. 29 4
      spine-cpp/spine-cpp/include/spine/String.h
  40. 2 0
      spine-cpp/spine-cpp/include/spine/Timeline.h
  41. 2 0
      spine-cpp/spine-cpp/include/spine/TransformConstraint.h
  42. 2 0
      spine-cpp/spine-cpp/include/spine/TransformConstraintData.h
  43. 2 0
      spine-cpp/spine-cpp/include/spine/Triangulator.h
  44. 18 7
      spine-cpp/spine-cpp/include/spine/Vector.h
  45. 4 0
      spine-cpp/spine-cpp/include/spine/Vertices.h
  46. 8 0
      spine-cpp/spine-cpp/src/spine/Animation.cpp
  47. 22 6
      spine-cpp/spine-cpp/src/spine/AnimationState.cpp
  48. 12 2
      spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp
  49. 4 0
      spine-cpp/spine-cpp/src/spine/Atlas.cpp
  50. 4 0
      spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp
  51. 1 1
      spine-cpp/spine-cpp/src/spine/Attachment.cpp
  52. 22 14
      spine-cpp/spine-cpp/src/spine/Bone.cpp
  53. 4 0
      spine-cpp/spine-cpp/src/spine/BoneData.cpp
  54. 7 0
      spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp
  55. 8 0
      spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp
  56. 4 0
      spine-cpp/spine-cpp/src/spine/Event.cpp
  57. 4 0
      spine-cpp/spine-cpp/src/spine/EventData.cpp
  58. 107 161
      spine-cpp/spine-cpp/src/spine/IkConstraint.cpp
  59. 4 0
      spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp
  60. 6 1
      spine-cpp/spine-cpp/src/spine/Json.cpp
  61. 4 0
      spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp
  62. 2 2
      spine-cpp/spine-cpp/src/spine/MathUtil.cpp
  63. 6 0
      spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp
  64. 8 0
      spine-cpp/spine-cpp/src/spine/PathAttachment.cpp
  65. 12 6
      spine-cpp/spine-cpp/src/spine/PathConstraint.cpp
  66. 6 0
      spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp
  67. 7 1
      spine-cpp/spine-cpp/src/spine/PointAttachment.cpp
  68. 6 0
      spine-cpp/spine-cpp/src/spine/RTTI.cpp
  69. 6 0
      spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp
  70. 16 4
      spine-cpp/spine-cpp/src/spine/Skeleton.cpp
  71. 16 12
      spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp
  72. 14 4
      spine-cpp/spine-cpp/src/spine/SkeletonBounds.cpp
  73. 10 3
      spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp
  74. 4 0
      spine-cpp/spine-cpp/src/spine/SkeletonData.cpp
  75. 17 13
      spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp
  76. 16 2
      spine-cpp/spine-cpp/src/spine/Skin.cpp
  77. 9 0
      spine-cpp/spine-cpp/src/spine/Slot.cpp
  78. 4 0
      spine-cpp/spine-cpp/src/spine/SlotData.cpp
  79. 6 0
      spine-cpp/spine-cpp/src/spine/Timeline.cpp
  80. 25 19
      spine-cpp/spine-cpp/src/spine/TransformConstraint.cpp
  81. 4 0
      spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp
  82. 5 1
      spine-cpp/spine-cpp/src/spine/Triangulator.cpp
  83. 11 13
      spine-sfml/cpp/example/main.cpp
  84. 4 0
      spine-sfml/cpp/src/spine/spine-sfml.cpp
  85. 2 0
      spine-sfml/cpp/src/spine/spine-sfml.h

+ 2 - 0
spine-cpp/spine-cpp/include/spine/Animation.h

@@ -81,6 +81,8 @@ namespace Spine {
         float getDuration();
         float getDuration();
         
         
         void setDuration(float inValue);
         void setDuration(float inValue);
+
+        String toString() const;
         
         
     private:
     private:
         Vector<Timeline*> _timelines;
         Vector<Timeline*> _timelines;

+ 8 - 1
spine-cpp/spine-cpp/include/spine/AnimationState.h

@@ -213,7 +213,8 @@ namespace Spine {
         void resetRotationDirections();
         void resetRotationDirections();
         
         
         void setOnAnimationEventFunc(OnAnimationEventFunc inValue);
         void setOnAnimationEventFunc(OnAnimationEventFunc inValue);
-        
+
+        String toString() const;
     private:
     private:
         Animation* _animation;
         Animation* _animation;
         
         
@@ -249,6 +250,8 @@ namespace Spine {
         Event* _event;
         Event* _event;
         
         
         EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event = NULL);
         EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event = NULL);
+
+		String toString() const;
     };
     };
     
     
     class EventQueue : public SpineObject {
     class EventQueue : public SpineObject {
@@ -282,6 +285,8 @@ namespace Spine {
 
 
         /// Raises all events in the queue and drains the queue.
         /// Raises all events in the queue and drains the queue.
         void drain();
         void drain();
+
+		String toString() const ;
     };
     };
     
     
     class AnimationState : public SpineObject {
     class AnimationState : public SpineObject {
@@ -373,6 +378,8 @@ namespace Spine {
         void setOnAnimationEventFunc(OnAnimationEventFunc inValue);
         void setOnAnimationEventFunc(OnAnimationEventFunc inValue);
         void setRendererObject(void* inValue);
         void setRendererObject(void* inValue);
         void* getRendererObject();
         void* getRendererObject();
+
+        String toString() const;
         
         
     private:
     private:
         static const int Subsequent, First, Dip, DipMix;
         static const int Subsequent, First, Dip, DipMix;

+ 5 - 1
spine-cpp/spine-cpp/include/spine/AnimationStateData.h

@@ -67,7 +67,9 @@ namespace Spine {
         /// or the DefaultMix if no mix duration has been set.
         /// or the DefaultMix if no mix duration has been set.
         ///
         ///
         float getMix(Animation* from, Animation* to);
         float getMix(Animation* from, Animation* to);
-        
+
+        String toString() const;
+
     private:
     private:
         class AnimationPair : public SpineObject {
         class AnimationPair : public SpineObject {
         public:
         public:
@@ -77,6 +79,8 @@ namespace Spine {
             explicit 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;
+
+            String toString() const;
         };
         };
         
         
         struct HashAnimationPair : public SpineObject {
         struct HashAnimationPair : public SpineObject {

+ 17 - 0
spine-cpp/spine-cpp/include/spine/Atlas.h

@@ -78,6 +78,15 @@ namespace Spine {
                                           magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
                                           magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
                                           vWrap(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 {
     class AtlasRegion : public SpineObject {
@@ -92,6 +101,12 @@ namespace Spine {
         bool rotate;
         bool rotate;
         Vector<int> splits;
         Vector<int> splits;
         Vector<int> pads;
         Vector<int> pads;
+
+        String toString() const {
+            String str;
+            str.append("AtlasRegion { name: ").appendString(name).append(" }");
+            return str;
+        }
     };
     };
     
     
     class TextureLoader;
     class TextureLoader;
@@ -112,6 +127,8 @@ namespace Spine {
         AtlasRegion* findRegion(const String& name);
         AtlasRegion* findRegion(const String& name);
         
         
         void dispose();
         void dispose();
+
+        String toString() const;
         
         
     private:
     private:
         Vector<AtlasPage*> _pages;
         Vector<AtlasPage*> _pages;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/AtlasAttachmentLoader.h

@@ -63,6 +63,8 @@ namespace Spine {
         virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
         virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
         
         
         AtlasRegion* findRegion(const String& name);
         AtlasRegion* findRegion(const String& name);
+
+        String toString() const;
         
         
     private:
     private:
         Atlas* _atlas;
         Atlas* _atlas;

+ 1 - 1
spine-cpp/spine-cpp/include/spine/Attachment.h

@@ -43,7 +43,7 @@ namespace Spine {
         explicit Attachment(const String& name);
         explicit Attachment(const String& name);
         virtual ~Attachment();
         virtual ~Attachment();
 
 
-        const String& getName();
+        const String& getName() const;
         
         
     private:
     private:
         const String _name;
         const String _name;

+ 0 - 1
spine-cpp/spine-cpp/include/spine/AttachmentTimeline.h

@@ -66,7 +66,6 @@ namespace Spine {
         const Vector<String>& getAttachmentNames();
         const Vector<String>& getAttachmentNames();
         void setAttachmentNames(Vector<String>& inValue);
         void setAttachmentNames(Vector<String>& inValue);
         int getFrameCount();
         int getFrameCount();
-        
     private:
     private:
         int _slotIndex;
         int _slotIndex;
         Vector<float> _frames;
         Vector<float> _frames;

+ 2 - 1
spine-cpp/spine-cpp/include/spine/Bone.h

@@ -180,7 +180,8 @@ namespace Spine {
         
         
         /// Returns the magnitide (always positive) of the world scale Y.
         /// Returns the magnitide (always positive) of the world scale Y.
         float getWorldScaleY();
         float getWorldScaleY();
-        
+
+        String toString() const;
     private:
     private:
         static bool yDown;
         static bool yDown;
         
         

+ 2 - 0
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.
         /// The transform mode for how parent world transforms affect this bone.
         TransformMode getTransformMode();
         TransformMode getTransformMode();
         void setTransformMode(TransformMode inValue);
         void setTransformMode(TransformMode inValue);
+
+        String toString() const;
         
         
     private:
     private:
         const int _index;
         const int _index;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/BoundingBoxAttachment.h

@@ -40,6 +40,8 @@ namespace Spine {
         RTTI_DECL
         RTTI_DECL
         
         
         explicit BoundingBoxAttachment(const String& name);
         explicit BoundingBoxAttachment(const String& name);
+
+        String toString() const;
     };
     };
 }
 }
 
 

+ 2 - 0
spine-cpp/spine-cpp/include/spine/ClippingAttachment.h

@@ -49,6 +49,8 @@ namespace Spine {
         
         
         SlotData* getEndSlot();
         SlotData* getEndSlot();
         void setEndSlot(SlotData* inValue);
         void setEndSlot(SlotData* inValue);
+
+        String toString() const;
         
         
     private:
     private:
         SlotData* _endSlot;
         SlotData* _endSlot;

+ 7 - 1
spine-cpp/spine-cpp/include/spine/Color.h

@@ -33,7 +33,7 @@
 #include <spine/MathUtil.h>
 #include <spine/MathUtil.h>
 
 
 namespace Spine {
 namespace Spine {
-	class Color {
+	class Color : public SpineObject {
 	public:
 	public:
 		Color() : _r(0), _g(0), _b(0), _a(0) {
 		Color() : _r(0), _g(0), _b(0), _a(0) {
 		}
 		}
@@ -87,6 +87,12 @@ namespace Spine {
 		}
 		}
 
 
 		float _r, _g, _b, _a;
 		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;
+		}
 	};
 	};
 }
 }
 
 

+ 2 - 0
spine-cpp/spine-cpp/include/spine/Event.h

@@ -59,6 +59,8 @@ namespace Spine {
 
 
         const String& getStringValue();
         const String& getStringValue();
         void setStringValue(const String& inValue);
         void setStringValue(const String& inValue);
+
+        String toString() const;
         
         
     private:
     private:
         const EventData& _data;
         const EventData& _data;

+ 3 - 1
spine-cpp/spine-cpp/include/spine/EventData.h

@@ -55,7 +55,9 @@ namespace Spine {
         
         
         const String& getStringValue();
         const String& getStringValue();
         void setStringValue(const String& inValue);
         void setStringValue(const String& inValue);
-        
+
+        String toString() const;
+
     private:
     private:
         const String _name;
         const String _name;
         int _intValue;
         int _intValue;

+ 24 - 1
spine-cpp/spine-cpp/include/spine/HashMap.h

@@ -34,6 +34,7 @@
 #include <spine/Extension.h>
 #include <spine/Extension.h>
 #include <spine/Vector.h>
 #include <spine/Vector.h>
 #include <spine/SpineObject.h>
 #include <spine/SpineObject.h>
+#include <spine/String.h>
 
 
 namespace Spine {
 namespace Spine {
     template <typename K, typename V>
     template <typename K, typename V>
@@ -144,9 +145,25 @@ namespace Spine {
             else assert(false);
             else assert(false);
         }
         }
 
 
-        Entries getEntries() {
+        Entries getEntries() const {
             return Entries(_head);
             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:
     private:
         Entry* find(const K& key) {
         Entry* find(const K& key) {
@@ -165,6 +182,12 @@ namespace Spine {
             Entry* prev;
             Entry* prev;
 
 
             Entry () : next(NULL), prev(NULL) {}
             Entry () : next(NULL), prev(NULL) {}
+
+            String toString() const {
+                String str;
+                str.append("Entry { key: ").append(_key).append(" -> ").append(_value);
+                return str;
+            }
         };
         };
 
 
         Entry* _head;
         Entry* _head;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/IkConstraint.h

@@ -77,6 +77,8 @@ namespace Spine {
         
         
         float getMix();
         float getMix();
         void setMix(float inValue);
         void setMix(float inValue);
+
+        String toString() const;
         
         
     private:
     private:
         IkConstraintData& _data;
         IkConstraintData& _data;

+ 3 - 1
spine-cpp/spine-cpp/include/spine/IkConstraintData.h

@@ -67,7 +67,9 @@ namespace Spine {
         
         
         float getMix();
         float getMix();
         void setMix(float inValue);
         void setMix(float inValue);
-        
+
+        String toString() const;
+
     private:
     private:
         const String _name;
         const String _name;
         int _order;
         int _order;

+ 2 - 1
spine-cpp/spine-cpp/include/spine/Json.h

@@ -68,7 +68,8 @@ namespace Spine {
         explicit Json(const char* value);
         explicit Json(const char* value);
         
         
         ~Json();
         ~Json();
-        
+
+        String toString() const;
     private:
     private:
         static const char* _error;
         static const char* _error;
         
         

+ 2 - 1
spine-cpp/spine-cpp/include/spine/LinkedMesh.h

@@ -43,7 +43,8 @@ namespace Spine {
         
         
     public:
     public:
         LinkedMesh(MeshAttachment* mesh, const String& skin, int slotIndex, const String& parent);
         LinkedMesh(MeshAttachment* mesh, const String& skin, int slotIndex, const String& parent);
-        
+
+        String toString() const;
     private:
     private:
         MeshAttachment* _mesh;
         MeshAttachment* _mesh;
         String _skin;
         String _skin;

+ 9 - 19
spine-cpp/spine-cpp/include/spine/MathUtil.h

@@ -36,27 +36,20 @@
 #include <float.h>
 #include <float.h>
 #include <string.h>
 #include <string.h>
 
 
-#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 {
 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 {
     class MathUtil : public SpineObject {
     public:
     public:
         MathUtil();
         MathUtil();
 
 
+        template <typename T> static inline T min(T a, T b) { return a < b ? a : b; }
+
+        template <typename T> static inline T max(T a, T b) { return a > b ? a : b; }
+
         static int sign(float val);
         static int sign(float val);
 
 
         static bool areFloatsPracticallyEqual(float A, float B, float maxDiff = 0.0000000000000001f, float maxRelDiff = FLT_EPSILON);
         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 float fmod(float a, float b);
 
 
         static bool isNan(float v);
         static bool isNan(float v);
-    
-    private:
-        static float SIN_TABLE[SIN_COUNT];
     };
     };
 }
 }
 
 

+ 2 - 0
spine-cpp/spine-cpp/include/spine/MeshAttachment.h

@@ -122,6 +122,8 @@ namespace Spine {
         float getHeight();
         float getHeight();
         void setHeight(float inValue);
         void setHeight(float inValue);
 
 
+        String toString() const;
+
     private:
     private:
         float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
         float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
         MeshAttachment* _parentMesh;
         MeshAttachment* _parentMesh;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/PathAttachment.h

@@ -50,6 +50,8 @@ namespace Spine {
         void setClosed(bool inValue);
         void setClosed(bool inValue);
         bool isConstantSpeed();
         bool isConstantSpeed();
         void setConstantSpeed(bool inValue);
         void setConstantSpeed(bool inValue);
+
+        String toString() const;
         
         
     private:
     private:
         Vector<float> _lengths;
         Vector<float> _lengths;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/PathConstraint.h

@@ -78,6 +78,8 @@ namespace Spine {
         void setTarget(Slot* inValue);
         void setTarget(Slot* inValue);
         
         
         PathConstraintData& getData();
         PathConstraintData& getData();
+
+        String toString() const;
         
         
     private:
     private:
         static const float EPSILON;
         static const float EPSILON;

+ 2 - 1
spine-cpp/spine-cpp/include/spine/PathConstraintData.h

@@ -88,7 +88,8 @@ namespace Spine {
         
         
         float getTranslateMix();
         float getTranslateMix();
         void setTranslateMix(float inValue);
         void setTranslateMix(float inValue);
-        
+
+        String toString() const;
     private:
     private:
         const String _name;
         const String _name;
         int _order;
         int _order;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/PointAttachment.h

@@ -64,6 +64,8 @@ namespace Spine {
         
         
         float getRotation();
         float getRotation();
         void setRotation(float inValue);
         void setRotation(float inValue);
+
+        String toString() const;
         
         
     private:
     private:
         float _x, _y, _rotation;
         float _x, _y, _rotation;

+ 6 - 0
spine-cpp/spine-cpp/include/spine/Pool.h

@@ -67,6 +67,12 @@ namespace Spine {
                 _objects.add(object);
                 _objects.add(object);
             }
             }
         }
         }
+
+		String toString () const {
+			String str;
+			str.append("Pool { size: ").append((int)_objects.size()).append(" }");
+			return str;
+		}
         
         
     private:
     private:
         Vector<T*> _objects;
         Vector<T*> _objects;

+ 5 - 4
spine-cpp/spine-cpp/include/spine/RTTI.h

@@ -47,7 +47,8 @@ namespace Spine {
         bool isExactly(const RTTI& rtti) const;
         bool isExactly(const RTTI& rtti) const;
 
 
         bool instanceOf(const RTTI &rtti) const;
         bool instanceOf(const RTTI &rtti) const;
-        
+
+        String toString() const;
     private:
     private:
         // Prevent copying
         // Prevent copying
         RTTI(const RTTI& obj);
         RTTI(const RTTI& obj);
@@ -61,15 +62,15 @@ namespace Spine {
 #define RTTI_DECL \
 #define RTTI_DECL \
 public: \
 public: \
 static const Spine::RTTI rtti; \
 static const Spine::RTTI rtti; \
-virtual const Spine::RTTI& getRTTI();
+virtual const Spine::RTTI& getRTTI() const;
 
 
 #define RTTI_IMPL_NOPARENT(name) \
 #define RTTI_IMPL_NOPARENT(name) \
 const Spine::RTTI name::rtti(#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) \
 #define RTTI_IMPL(name,parent) \
 const Spine::RTTI name::rtti(#name, parent::rtti); \
 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 */
 #endif /* Spine_RTTI_h */
 
 

+ 2 - 0
spine-cpp/spine-cpp/include/spine/RegionAttachment.h

@@ -106,6 +106,8 @@ namespace Spine {
         
         
         Vector<float>& getOffset();
         Vector<float>& getOffset();
         Vector<float>& getUVs();
         Vector<float>& getUVs();
+
+        String toString() const;
         
         
     private:
     private:
         static const int BLX;
         static const int BLX;

+ 3 - 1
spine-cpp/spine-cpp/include/spine/Skeleton.h

@@ -169,7 +169,9 @@ namespace Spine {
         void setFlipX(bool inValue);
         void setFlipX(bool inValue);
         bool getFlipY();
         bool getFlipY();
         void setFlipY(bool inValue);
         void setFlipY(bool inValue);
-        
+
+        String toString() const;
+
     private:
     private:
         SkeletonData* _data;
         SkeletonData* _data;
         Vector<Bone*> _bones;
         Vector<Bone*> _bones;

+ 4 - 0
spine-cpp/spine-cpp/include/spine/SkeletonBinary.h

@@ -80,11 +80,15 @@ namespace Spine {
         void setScale(float scale) { _scale = scale; }
         void setScale(float scale) { _scale = scale; }
 
 
         String& getError() { return _error; }
         String& getError() { return _error; }
+
+        String toString() const;
         
         
     private:
     private:
         struct DataInput : public SpineObject {
         struct DataInput : public SpineObject {
             const unsigned char* cursor;
             const unsigned char* cursor;
             const unsigned char* end;
             const unsigned char* end;
+
+            String toString() const { return String("DataInput"); }
         };
         };
         
         
         AttachmentLoader* _attachmentLoader;
         AttachmentLoader* _attachmentLoader;

+ 4 - 0
spine-cpp/spine-cpp/include/spine/SkeletonBounds.h

@@ -85,6 +85,8 @@ namespace Spine {
 
 
         float getWidth();
         float getWidth();
         float getHeight();
         float getHeight();
+
+        String toString() const;
         
         
     private:
     private:
         Vector<Polygon*> _polygonPool;
         Vector<Polygon*> _polygonPool;
@@ -103,6 +105,8 @@ namespace Spine {
         Polygon() : _count(0) {
         Polygon() : _count(0) {
 			_vertices.ensureCapacity(16);
 			_vertices.ensureCapacity(16);
         }
         }
+
+        String toString() const;
     };
     };
 }
 }
 
 

+ 2 - 0
spine-cpp/spine-cpp/include/spine/SkeletonClipping.h

@@ -55,6 +55,8 @@ namespace Spine {
         Vector<float>& getClippedVertices();
         Vector<float>& getClippedVertices();
         Vector<unsigned short>& getClippedTriangles();
         Vector<unsigned short>& getClippedTriangles();
         Vector<float>& getClippedUVs();
         Vector<float>& getClippedUVs();
+
+        String toString() const;
         
         
     private:
     private:
         Triangulator _triangulator;
         Triangulator _triangulator;

+ 3 - 1
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.
         /// The dopesheet FPS in Spine. Available only when nonessential data was exported.
         float getFps();
         float getFps();
         void setFps(float inValue);
         void setFps(float inValue);
-        
+
+        String toString() const;
+
     private:
     private:
         String _name;
         String _name;
         Vector<BoneData*> _bones; // Ordered parents first
         Vector<BoneData*> _bones; // Ordered parents first

+ 2 - 0
spine-cpp/spine-cpp/include/spine/SkeletonJson.h

@@ -61,6 +61,8 @@ namespace Spine {
         void setScale (float scale) { _scale = scale; }
         void setScale (float scale) { _scale = scale; }
 
 
         String& getError() { return _error; }
         String& getError() { return _error; }
+
+        String toString() const;
         
         
     private:
     private:
         AttachmentLoader* _attachmentLoader;
         AttachmentLoader* _attachmentLoader;

+ 5 - 1
spine-cpp/spine-cpp/include/spine/Skin.h

@@ -46,7 +46,7 @@ namespace Spine {
         friend class Skeleton;
         friend class Skeleton;
         
         
     public:
     public:
-        class AttachmentKey {
+        class AttachmentKey: public SpineObject {
         public:
         public:
             int _slotIndex;
             int _slotIndex;
             String _name;
             String _name;
@@ -59,6 +59,8 @@ namespace Spine {
             }
             }
             
             
             bool operator==(const AttachmentKey &other) const;
             bool operator==(const AttachmentKey &other) const;
+
+            String toString() const;
         };
         };
         
         
         struct HashAttachmentKey : public SpineObject {
         struct HashAttachmentKey : public SpineObject {
@@ -87,6 +89,8 @@ namespace Spine {
 
 
         const String& getName();
         const String& getName();
         HashMap<AttachmentKey, Attachment*>& getAttachments();
         HashMap<AttachmentKey, Attachment*>& getAttachments();
+
+        String toString() const;
         
         
     private:
     private:
         const String _name;
         const String _name;

+ 3 - 1
spine-cpp/spine-cpp/include/spine/Slot.h

@@ -88,7 +88,9 @@ namespace Spine {
         
         
         Vector<float>& getAttachmentVertices();
         Vector<float>& getAttachmentVertices();
         void setAttachmentVertices(Vector<float> inValue);
         void setAttachmentVertices(Vector<float> inValue);
-        
+
+        String toString() const;
+
     private:
     private:
         SlotData& _data;
         SlotData& _data;
         Bone& _bone;
         Bone& _bone;

+ 3 - 1
spine-cpp/spine-cpp/include/spine/SlotData.h

@@ -79,7 +79,9 @@ namespace Spine {
         
         
         BlendMode getBlendMode();
         BlendMode getBlendMode();
         void setBlendMode(BlendMode inValue);
         void setBlendMode(BlendMode inValue);
-        
+
+        String toString() const;
+
     private:
     private:
         const int _index;
         const int _index;
         String _name;
         String _name;

+ 1 - 0
spine-cpp/spine-cpp/include/spine/SpineObject.h

@@ -42,6 +42,7 @@ namespace Spine {
 		void* operator new(size_t sz, void* ptr);
 		void* operator new(size_t sz, void* ptr);
 		void operator delete(void* p);
 		void operator delete(void* p);
 		virtual ~SpineObject();
 		virtual ~SpineObject();
+		virtual String toString() const = 0;
 	};
 	};
 }
 }
 
 

+ 29 - 4
spine-cpp/spine-cpp/include/spine/String.h

@@ -35,6 +35,7 @@
 #include <spine/Extension.h>
 #include <spine/Extension.h>
 
 
 #include <string.h>
 #include <string.h>
+#include <stdio.h>
 
 
 namespace Spine {
 namespace Spine {
 	class String : public SpineObject {
 	class String : public SpineObject {
@@ -138,7 +139,7 @@ namespace Spine {
 			return *this;
 			return *this;
 		}
 		}
 
 
-		String& operator+ (const char* chars) {
+		String& append (const char* chars) {
 			size_t len = strlen(chars);
 			size_t len = strlen(chars);
 			size_t thisLen = _length;
 			size_t thisLen = _length;
 			_length = _length + len;
 			_length = _length + len;
@@ -148,7 +149,7 @@ namespace Spine {
 			return *this;
 			return *this;
 		}
 		}
 
 
-		String& operator+= (const String& other) {
+		String& appendString (const String& other) {
 			size_t len = other.length();
 			size_t len = other.length();
 			size_t thisLen = _length;
 			size_t thisLen = _length;
 			_length = _length + len;
 			_length = _length + len;
@@ -158,8 +159,28 @@ namespace Spine {
 			return *this;
 			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) {
 		friend bool operator== (const String& a, const String& b) {
@@ -181,6 +202,10 @@ namespace Spine {
 				SpineExtension::free(_buffer, __FILE__, __LINE__);
 				SpineExtension::free(_buffer, __FILE__, __LINE__);
 			}
 			}
 		}
 		}
+
+		String toString () const {
+			return *this;
+		}
 	private:
 	private:
 		mutable size_t _length;
 		mutable size_t _length;
 		mutable char* _buffer;
 		mutable char* _buffer;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/Timeline.h

@@ -63,6 +63,8 @@ namespace Spine {
         virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) = 0;
         virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) = 0;
         
         
         virtual int getPropertyId() = 0;
         virtual int getPropertyId() = 0;
+
+        virtual String toString() const;
     };
     };
 }
 }
 
 

+ 2 - 0
spine-cpp/spine-cpp/include/spine/TransformConstraint.h

@@ -73,6 +73,8 @@ namespace Spine {
         
         
         float getShearMix();
         float getShearMix();
         void setShearMix(float inValue);
         void setShearMix(float inValue);
+
+        String toString() const;
         
         
     private:
     private:
         TransformConstraintData& _data;
         TransformConstraintData& _data;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/TransformConstraintData.h

@@ -67,6 +67,8 @@ namespace Spine {
         
         
         bool isRelative();
         bool isRelative();
         bool isLocal();
         bool isLocal();
+
+        String toString() const;
         
         
     private:
     private:
         const String _name;
         const String _name;

+ 2 - 0
spine-cpp/spine-cpp/include/spine/Triangulator.h

@@ -40,6 +40,8 @@ namespace Spine {
         Vector<int>& triangulate(Vector<float>& vertices);
         Vector<int>& triangulate(Vector<float>& vertices);
         
         
         Vector< Vector<float>* > decompose(Vector<float>& vertices, Vector<int>& triangles);
         Vector< Vector<float>* > decompose(Vector<float>& vertices, Vector<int>& triangles);
+
+        String toString() const;
         
         
     private:
     private:
         Vector< Vector<float>* > _convexPolygons;
         Vector< Vector<float>* > _convexPolygons;

+ 18 - 7
spine-cpp/spine-cpp/include/spine/Vector.h

@@ -32,12 +32,11 @@
 #define Spine_Vector_h
 #define Spine_Vector_h
 
 
 #include <spine/Extension.h>
 #include <spine/Extension.h>
-
+#include <spine/SpineObject.h>
+#include <spine/String.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <memory>
 #include <memory>
 #include <assert.h>
 #include <assert.h>
-#include <spine/SpineObject.h>
-#include <spine/Extension.h>
 
 
 namespace Spine {
 namespace Spine {
     template <typename T>
     template <typename T>
@@ -109,13 +108,13 @@ namespace Spine {
         }
         }
 
 
 		inline void add(const T &inValue) {
 		inline void add(const T &inValue) {
-			if (_size == _capacity) {
+            if (_size == _capacity) {
                 _capacity = (int)(_size  * 1.75f);
                 _capacity = (int)(_size  * 1.75f);
                 if (_capacity < 8) _capacity = 8;
                 if (_capacity < 8) _capacity = 8;
                 _buffer = Spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
                 _buffer = Spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
-			}
-			construct(_buffer + _size++, inValue);
-		}
+            }
+            construct(_buffer + _size++, inValue);
+        }
 
 
         inline void removeAt(size_t inIndex) {
         inline void removeAt(size_t inIndex) {
             assert(inIndex < _size);
             assert(inIndex < _size);
@@ -179,6 +178,18 @@ namespace Spine {
 			return _buffer;
 			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:
     private:
         size_t _size;
         size_t _size;
         size_t _capacity;
         size_t _capacity;

+ 4 - 0
spine-cpp/spine-cpp/include/spine/Vertices.h

@@ -38,6 +38,10 @@ namespace Spine {
     public:
     public:
         Vector<int> _bones;
         Vector<int> _bones;
         Vector<float> _vertices;
         Vector<float> _vertices;
+
+        String toString() const {
+            return String("Vertices");
+        };
     };
     };
 }
 }
 
 

+ 8 - 0
spine-cpp/spine-cpp/src/spine/Animation.cpp

@@ -142,4 +142,12 @@ namespace Spine {
         
         
         return -1;
         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;
+	}
 }
 }

+ 22 - 6
spine-cpp/spine-cpp/src/spine/AnimationState.cpp

@@ -91,7 +91,7 @@ namespace Spine {
             return MathUtil::fmod(_trackTime, duration) + _animationStart;
             return MathUtil::fmod(_trackTime, duration) + _animationStart;
         }
         }
 
 
-        return MIN(_trackTime + _animationStart, _animationEnd);
+        return MathUtil::min(_trackTime + _animationStart, _animationEnd);
     }
     }
 
 
     float TrackEntry::getTimeScale() { return _timeScale; }
     float TrackEntry::getTimeScale() { return _timeScale; }
@@ -203,13 +203,21 @@ namespace Spine {
         
         
         _onAnimationEventFunc = dummyOnAnimationEventFunc;
         _onAnimationEventFunc = dummyOnAnimationEventFunc;
     }
     }
-    
+
+    String TrackEntry::toString() const {
+        return String("TrackEntry");
+    }
+
     EventQueueEntry::EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event) :
     EventQueueEntry::EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event) :
     _type(eventType),
     _type(eventType),
     _entry(trackEntry),
     _entry(trackEntry),
     _event(event) {
     _event(event) {
     }
     }
-    
+
+    String EventQueueEntry::toString() const {
+        return String("EventQueueEntry");
+    }
+
     EventQueue* EventQueue::newEventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool) {
     EventQueue* EventQueue::newEventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool) {
         return new (__FILE__, __LINE__) EventQueue(state, trackEntryPool);
         return new (__FILE__, __LINE__) EventQueue(state, trackEntryPool);
     }
     }
@@ -292,7 +300,11 @@ namespace Spine {
         
         
         _drainDisabled = false;
         _drainDisabled = false;
     }
     }
-    
+
+    String EventQueue::toString() const {
+        return String("EventQueue");
+    }
+
     const int AnimationState::Subsequent = 0;
     const int AnimationState::Subsequent = 0;
     const int AnimationState::First = 1;
     const int AnimationState::First = 1;
     const int AnimationState::Dip = 2;
     const int AnimationState::Dip = 2;
@@ -804,7 +816,7 @@ namespace Spine {
                 default:
                 default:
                     pose = MixPose_Setup;
                     pose = MixPose_Setup;
                     TrackEntry* dipMix = timelineDipMix[i];
                     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;
                     break;
             }
             }
             from->_totalAlpha += alpha;
             from->_totalAlpha += alpha;
@@ -882,7 +894,7 @@ namespace Spine {
             
             
             // Store interrupted mix percentage.
             // Store interrupted mix percentage.
             if (from->_mixingFrom != NULL && from->_mixDuration > 0) {
             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.
             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");
+    }
 }
 }

+ 12 - 2
spine-cpp/spine-cpp/src/spine/AnimationStateData.cpp

@@ -73,14 +73,24 @@ namespace Spine {
     void AnimationStateData::setDefaultMix(float inValue) {
     void AnimationStateData::setDefaultMix(float inValue) {
         _defaultMix = inValue;
         _defaultMix = inValue;
     }
     }
-    
+
+    String AnimationStateData::toString() const {
+        return String("AnimationStateData");
+    }
+
     AnimationStateData::AnimationPair::AnimationPair(Animation* a1, Animation* a2) : _a1(a1), _a2(a2) {
     AnimationStateData::AnimationPair::AnimationPair(Animation* a1, Animation* a2) : _a1(a1), _a2(a2) {
     }
     }
     
     
     bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const {
     bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const {
         return _a1->_name == other._a1->_name && _a2->_name == other._a2->_name;
         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 AnimationStateData::HashAnimationPair::operator()(const Spine::AnimationStateData::AnimationPair& val) const {
         std::size_t h1 = 7;
         std::size_t h1 = 7;
         size_t strlen = val._a1->_name.length();
         size_t strlen = val._a1->_name.length();

+ 4 - 0
spine-cpp/spine-cpp/src/spine/Atlas.cpp

@@ -352,4 +352,8 @@ namespace Spine {
     int Atlas::toInt(Str* str) {
     int Atlas::toInt(Str* str) {
         return (int)strtol(str->begin, (char**)&str->end, 10);
         return (int)strtol(str->begin, (char**)&str->end, 10);
     }
     }
+
+    String Atlas::toString() const {
+        return String("Atlas");
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/AtlasAttachmentLoader.cpp

@@ -111,4 +111,8 @@ namespace Spine {
         AtlasRegion* ret;
         AtlasRegion* ret;
         return _atlas->findRegion(name);
         return _atlas->findRegion(name);
     }
     }
+
+    String AtlasAttachmentLoader::toString() const {
+        return String("AtlasAttachmentLoader");
+    }
 }
 }

+ 1 - 1
spine-cpp/spine-cpp/src/spine/Attachment.cpp

@@ -42,7 +42,7 @@ namespace Spine {
     Attachment::~Attachment() {
     Attachment::~Attachment() {
     }
     }
 
 
-    const String& Attachment::getName() {
+    const String& Attachment::getName() const {
         return _name;
         return _name;
     }
     }
 }
 }

+ 22 - 14
spine-cpp/spine-cpp/src/spine/Bone.cpp

@@ -164,12 +164,12 @@ namespace Spine {
                     s = MathUtil::abs(pa * pd - pb * pc) / s;
                     s = MathUtil::abs(pa * pd - pb * pc) / s;
                     pb = pc * s;
                     pb = pc * s;
                     pd = pa * s;
                     pd = pa * s;
-                    prx = MathUtil::atan2(pc, pa) * RadDeg;
+                    prx = MathUtil::atan2(pc, pa) * RAD_DEG;
                 }
                 }
                 else {
                 else {
                     pa = 0;
                     pa = 0;
                     pc = 0;
                     pc = 0;
-                    prx = 90 - MathUtil::atan2(pd, pb) * RadDeg;
+                    prx = 90 - MathUtil::atan2(pd, pb) * RAD_DEG;
                 }
                 }
                 float rx = rotation + shearX - prx;
                 float rx = rotation + shearX - prx;
                 float ry = rotation + shearY - prx + 90;
                 float ry = rotation + shearY - prx + 90;
@@ -199,7 +199,7 @@ namespace Spine {
                 za *= s;
                 za *= s;
                 zc *= s;
                 zc *= s;
                 s = MathUtil::sqrt(za * za + zc * zc);
                 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 zb = MathUtil::cos(r) * s;
                 float zd = MathUtil::sin(r) * s;
                 float zd = MathUtil::sin(r) * s;
                 float la = MathUtil::cosDeg(shearX) * scaleX;
                 float la = MathUtil::cosDeg(shearX) * scaleX;
@@ -266,14 +266,14 @@ namespace Spine {
         float sin = MathUtil::sinDeg(worldRotation);
         float sin = MathUtil::sinDeg(worldRotation);
         float cos = MathUtil::cosDeg(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 Bone::localToWorldRotation(float localRotation) {
         float sin = MathUtil::sinDeg(localRotation);
         float sin = MathUtil::sinDeg(localRotation);
         float cos = MathUtil::cosDeg(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) {
     void Bone::rotateWorld(float degrees) {
@@ -306,7 +306,7 @@ namespace Spine {
         float a = _a;
         float a = _a;
         float c = _c;
         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() {
     float Bone::getWorldToLocalRotationY() {
@@ -322,7 +322,7 @@ namespace Spine {
         float b = _b;
         float b = _b;
         float d = _d;
         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() {
     BoneData& Bone::getData() {
@@ -502,11 +502,11 @@ namespace Spine {
     }
     }
     
     
     float Bone::getWorldRotationX() {
     float Bone::getWorldRotationX() {
-        return MathUtil::atan2(_c, _a) * RadDeg;
+        return MathUtil::atan2(_c, _a) * RAD_DEG;
     }
     }
     
     
     float Bone::getWorldRotationY() {
     float Bone::getWorldRotationY() {
-        return MathUtil::atan2(_d, _b) * RadDeg;
+        return MathUtil::atan2(_d, _b) * RAD_DEG;
     }
     }
     
     
     float Bone::getWorldScaleX() {
     float Bone::getWorldScaleX() {
@@ -523,11 +523,11 @@ namespace Spine {
         if (!parent) {
         if (!parent) {
             _ax = _worldX;
             _ax = _worldX;
             _ay = _worldY;
             _ay = _worldY;
-            _arotation = MathUtil::atan2(_c, _a) * RadDeg;
+            _arotation = MathUtil::atan2(_c, _a) * RAD_DEG;
             _ascaleX = MathUtil::sqrt(_a * _a + _c * _c);
             _ascaleX = MathUtil::sqrt(_a * _a + _c * _c);
             _ascaleY = MathUtil::sqrt(_b * _b + _d * _d);
             _ascaleY = MathUtil::sqrt(_b * _b + _d * _d);
             _ashearX = 0;
             _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;
             return;
         }
         }
@@ -560,14 +560,22 @@ namespace Spine {
         if (_ascaleX > 0.0001f) {
         if (_ascaleX > 0.0001f) {
             float det = ra * rd - rb * rc;
             float det = ra * rd - rb * rc;
             _ascaleY = det / _ascaleX;
             _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 {
         else {
             _ascaleX = 0;
             _ascaleX = 0;
             _ascaleY = MathUtil::sqrt(rb * rb + rd * rd);
             _ascaleY = MathUtil::sqrt(rb * rb + rd * rd);
             _ashearY = 0;
             _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;
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/BoneData.cpp

@@ -133,4 +133,8 @@ namespace Spine {
     void BoneData::setTransformMode(TransformMode inValue) {
     void BoneData::setTransformMode(TransformMode inValue) {
         _transformMode = inValue;
         _transformMode = inValue;
     }
     }
+
+    String BoneData::toString() const {
+        return String("BoneData");
+    }
 }
 }

+ 7 - 0
spine-cpp/spine-cpp/src/spine/BoundingBoxAttachment.cpp

@@ -35,4 +35,11 @@ namespace Spine {
     
     
     BoundingBoxAttachment::BoundingBoxAttachment(const String& name) : VertexAttachment(name) {
     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;
+    }
 }
 }

+ 8 - 0
spine-cpp/spine-cpp/src/spine/ClippingAttachment.cpp

@@ -45,4 +45,12 @@ namespace Spine {
     void ClippingAttachment::setEndSlot(SlotData* inValue) {
     void ClippingAttachment::setEndSlot(SlotData* inValue) {
         _endSlot = 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;
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/Event.cpp

@@ -72,4 +72,8 @@ namespace Spine {
     void Event::setStringValue(const String& inValue) {
     void Event::setStringValue(const String& inValue) {
         _stringValue = inValue;
         _stringValue = inValue;
     }
     }
+
+    String Event::toString() const {
+        return String("Event");
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/EventData.cpp

@@ -69,4 +69,8 @@ namespace Spine {
     void EventData::setStringValue(const String& inValue) {
     void EventData::setStringValue(const String& inValue) {
         _stringValue = inValue;
         _stringValue = inValue;
     }
     }
+
+    String EventData::toString() const {
+        return String("EventData");
+    }
 }
 }

+ 107 - 161
spine-cpp/spine-cpp/src/spine/IkConstraint.cpp

@@ -41,204 +41,143 @@ namespace Spine {
     RTTI_IMPL(IkConstraint, Constraint);
     RTTI_IMPL(IkConstraint, Constraint);
     
     
     void IkConstraint::apply(Bone& bone, float targetX, float targetY, float alpha) {
     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) {
     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();
             child.updateWorldTransform();
-            
             return;
             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) {
         if (psx < 0) {
             psx = -psx;
             psx = -psx;
-            os1 = 180;
+            o1 = 180;
             s2 = -1;
             s2 = -1;
-        }
-        else {
-            os1 = 0;
+        } else {
+            o1 = 0;
             s2 = 1;
             s2 = 1;
         }
         }
-        
         if (psy < 0) {
         if (psy < 0) {
             psy = -psy;
             psy = -psy;
             s2 = -s2;
             s2 = -s2;
         }
         }
-        
         if (csx < 0) {
         if (csx < 0) {
             csx = -csx;
             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) {
         if (!u) {
             cy = 0;
             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;
             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) {
         if (u) {
+            float cosine, a, b;
             l2 *= psx;
             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);
             b = l2 * MathUtil::sin(a2);
             a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b);
             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) {
             if (d >= 0) {
-                float q = MathUtil::sqrt(d);
+                float q = MathUtil::sqrt(d), r0, r1;
                 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 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) {
                 if (r * r <= dd) {
                     y = MathUtil::sqrt(dd - r * r) * bendDir;
                     y = MathUtil::sqrt(dd - r * r) * bendDir;
                     a1 = ta - MathUtil::atan2(y, r);
                     a1 = ta - MathUtil::atan2(y, r);
                     a2 = MathUtil::atan2(y / psy, (r - l1) / psx);
                     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) {
     void IkConstraint::setMix(float inValue) {
         _mix = inValue;
         _mix = inValue;
     }
     }
+
+    String IkConstraint::toString() const {
+        String str;
+        str.append("IkConstraint { name: ").appendString(_data.getName());
+        str.append("}");
+        return str;
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp

@@ -80,4 +80,8 @@ namespace Spine {
     void IkConstraintData::setMix(float inValue) {
     void IkConstraintData::setMix(float inValue) {
         _mix = inValue;
         _mix = inValue;
     }
     }
+
+    String IkConstraintData::toString() const {
+        return String("IkConstraintData");
+    }
 }
 }

+ 6 - 1
spine-cpp/spine-cpp/src/spine/Json.cpp

@@ -42,6 +42,8 @@
 #endif
 #endif
 
 
 #include <spine/Json.h>
 #include <spine/Json.h>
+#include <spine/Extension.h>
+#include <spine/String.h>
 
 
 #include <assert.h>
 #include <assert.h>
 #include <math.h>
 #include <math.h>
@@ -49,7 +51,6 @@
 #include <ctype.h>
 #include <ctype.h>
 #include <stdlib.h> /* strtod (C89), strtof (C99) */
 #include <stdlib.h> /* strtod (C89), strtof (C99) */
 #include <string.h> /* strcasecmp (4.4BSD - compatibility), _stricmp (_WIN32) */
 #include <string.h> /* strcasecmp (4.4BSD - compatibility), _stricmp (_WIN32) */
-#include <spine/Extension.h>
 #include <new>
 #include <new>
 
 
 namespace Spine {
 namespace Spine {
@@ -549,4 +550,8 @@ namespace Spine {
             }
             }
         }
         }
     }
     }
+
+    String Json::toString() const {
+        return String("Json");
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/LinkedMesh.cpp

@@ -39,4 +39,8 @@ namespace Spine {
     _slotIndex(slotIndex),
     _slotIndex(slotIndex),
     _parent(parent) {
     _parent(parent) {
     }
     }
+
+    String LinkedMesh::toString() const {
+        return String("LinkedMesh");
+    }
 }
 }

+ 2 - 2
spine-cpp/spine-cpp/src/spine/MathUtil.cpp

@@ -72,12 +72,12 @@ namespace Spine {
     
     
     /// Returns the sine in radians from a lookup table.
     /// Returns the sine in radians from a lookup table.
     float MathUtil::sinDeg(float degrees) {
     float MathUtil::sinDeg(float degrees) {
-        return ::sin(degrees * DegRad);
+        return ::sin(degrees * DEG_RAD);
     }
     }
     
     
     /// Returns the cosine in radians from a lookup table.
     /// Returns the cosine in radians from a lookup table.
     float MathUtil::cosDeg(float degrees) {
     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
     /// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323

+ 6 - 0
spine-cpp/spine-cpp/src/spine/MeshAttachment.cpp

@@ -270,4 +270,10 @@
     Spine::Color& MeshAttachment::getColor() {
     Spine::Color& MeshAttachment::getColor() {
         return _color;
         return _color;
     }
     }
+
+    String MeshAttachment::toString() const {
+        String str;
+        str.append("RegionAttachment { name: ").appendString(getName()).append(", path: ").appendString(_path).append(" }");
+        return str;
+    }
 }
 }

+ 8 - 0
spine-cpp/spine-cpp/src/spine/PathAttachment.cpp

@@ -59,4 +59,12 @@ namespace Spine {
     void PathAttachment::setConstantSpeed(bool inValue) {
     void PathAttachment::setConstantSpeed(bool inValue) {
         _constantSpeed = 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;
+    }
 }
 }

+ 12 - 6
spine-cpp/spine-cpp/src/spine/PathConstraint.cpp

@@ -139,8 +139,8 @@ namespace Spine {
         }
         }
         else {
         else {
             tip = false;
             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) {
         for (int i = 0, p = 3; i < boneCount; i++, p += 3) {
@@ -189,11 +189,11 @@ namespace Spine {
                     r += offsetRotation;
                     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;
                 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));
             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;
+    }
 }
 }

+ 6 - 0
spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp

@@ -138,4 +138,10 @@ namespace Spine {
     void PathConstraintData::setTranslateMix(float inValue) {
     void PathConstraintData::setTranslateMix(float inValue) {
         _translateMix = inValue;
         _translateMix = inValue;
     }
     }
+
+	String PathConstraintData::toString() const {
+		String str;
+        str.append("PathConstraintData { name: ").appendString(_name).append(" }");
+        return str;
+	}
 }
 }

+ 7 - 1
spine-cpp/spine-cpp/src/spine/PointAttachment.cpp

@@ -50,7 +50,7 @@ namespace Spine {
         float ix = cos * bone._a + sin * bone._b;
         float ix = cos * bone._a + sin * bone._b;
         float iy = cos * bone._c + sin * bone._d;
         float iy = cos * bone._c + sin * bone._d;
         
         
-        return MathUtil::atan2(iy, ix) * RadDeg;
+        return MathUtil::atan2(iy, ix) * RAD_DEG;
     }
     }
     
     
     float PointAttachment::getX() {
     float PointAttachment::getX() {
@@ -76,4 +76,10 @@ namespace Spine {
     void PointAttachment::setRotation(float inValue) {
     void PointAttachment::setRotation(float inValue) {
         _rotation = inValue;
         _rotation = inValue;
     }
     }
+
+    String PointAttachment::toString() const {
+        String str;
+        str.append("PointAttachment { name: ").appendString(getName()).append(" }");
+        return str;
+    }
 }
 }

+ 6 - 0
spine-cpp/spine-cpp/src/spine/RTTI.cpp

@@ -59,4 +59,10 @@ namespace Spine {
 
 
         return false;
         return false;
     }
     }
+
+    String RTTI::toString() const {
+        String str;
+        str.append("RTTI { name: ").append(_className.c_str()).append(" }");
+        return str;
+    }
 }
 }

+ 6 - 0
spine-cpp/spine-cpp/src/spine/RegionAttachment.cpp

@@ -287,4 +287,10 @@ namespace Spine {
     Spine::Color& RegionAttachment::getColor() {
     Spine::Color& RegionAttachment::getColor() {
         return _color;
         return _color;
     }
     }
+
+	String RegionAttachment::toString() const {
+	    String str;
+        str.append("RegionAttachment { name: ").appendString(getName()).append(", path: ").appendString(_path).append(" }");
+        return str;
+	}
 }
 }

+ 16 - 4
spine-cpp/spine-cpp/src/spine/Skeleton.cpp

@@ -431,10 +431,10 @@ namespace Spine {
                 float vx = outVertexBuffer[ii];
                 float vx = outVertexBuffer[ii];
                 float vy = outVertexBuffer[ii + 1];
                 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;
             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;
+    }
 }
 }

+ 16 - 12
spine-cpp/spine-cpp/src/spine/SkeletonBinary.cpp

@@ -646,7 +646,7 @@ namespace Spine {
                             timeline->setFrame(frameIndex, readFloat(input), String(readString(input), true));
                             timeline->setFrame(frameIndex, readFloat(input), String(readString(input), true));
                         }
                         }
 						timelines.add(timeline);
 						timelines.add(timeline);
-                        duration = MAX(duration, timeline->_frames[frameCount - 1]);
+                        duration = MathUtil::max(duration, timeline->_frames[frameCount - 1]);
                         break;
                         break;
                     }
                     }
                     case SLOT_COLOR: {
                     case SLOT_COLOR: {
@@ -665,7 +665,7 @@ namespace Spine {
                             }
                             }
                         }
                         }
 						timelines.add(timeline);
 						timelines.add(timeline);
-                        duration = MAX(duration, timeline->_frames[(frameCount - 1) * ColorTimeline::ENTRIES]);
+                        duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * ColorTimeline::ENTRIES]);
                         break;
                         break;
                     }
                     }
                     case SLOT_TWO_COLOR: {
                     case SLOT_TWO_COLOR: {
@@ -689,7 +689,7 @@ namespace Spine {
                             }
                             }
                         }
                         }
 						timelines.add(timeline);
 						timelines.add(timeline);
-                        duration = MAX(duration, timeline->_frames[(frameCount - 1) * TwoColorTimeline::ENTRIES]);
+                        duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * TwoColorTimeline::ENTRIES]);
                         break;
                         break;
                     }
                     }
                     default: {
                     default: {
@@ -718,7 +718,7 @@ namespace Spine {
                             }
                             }
                         }
                         }
 						timelines.add(timeline);
 						timelines.add(timeline);
-                        duration = MAX(duration, timeline->_frames[(frameCount - 1) * RotateTimeline::ENTRIES]);
+                        duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * RotateTimeline::ENTRIES]);
                         break;
                         break;
                     }
                     }
                     case BONE_TRANSLATE:
                     case BONE_TRANSLATE:
@@ -744,7 +744,7 @@ namespace Spine {
                             }
                             }
                         }
                         }
 						timelines.add(timeline);
 						timelines.add(timeline);
-                        duration = MAX(duration, timeline->_frames[(frameCount - 1) * TranslateTimeline::ENTRIES]);
+                        duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * TranslateTimeline::ENTRIES]);
                         break;
                         break;
                     }
                     }
                     default: {
                     default: {
@@ -769,7 +769,7 @@ namespace Spine {
                 }
                 }
             }
             }
 			timelines.add(timeline);
 			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.
         // Transform constraint timelines.
@@ -785,7 +785,7 @@ namespace Spine {
                 }
                 }
             }
             }
 			timelines.add(timeline);
 			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.
         // Path constraint timelines.
@@ -822,7 +822,7 @@ namespace Spine {
                             }
                             }
                         }
                         }
 						timelines.add(timeline);
 						timelines.add(timeline);
-                        duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintPositionTimeline::ENTRIES]);
+                        duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * PathConstraintPositionTimeline::ENTRIES]);
                         break;
                         break;
                     }
                     }
                     case PATH_MIX: {
                     case PATH_MIX: {
@@ -836,7 +836,7 @@ namespace Spine {
                             }
                             }
                         }
                         }
 						timelines.add(timeline);
 						timelines.add(timeline);
-                        duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintMixTimeline::ENTRIES]);
+                        duration = MathUtil::max(duration, timeline->_frames[(frameCount - 1) * PathConstraintMixTimeline::ENTRIES]);
                         break;
                         break;
                     }
                     }
                 }
                 }
@@ -915,7 +915,7 @@ namespace Spine {
                     }
                     }
 
 
 					timelines.add(timeline);
 					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);
                 timeline->setFrame(i, time, drawOrder);
             }
             }
 			timelines.add(timeline);
 			timelines.add(timeline);
-            duration = MAX(duration, timeline->_frames[drawOrderCount - 1]);
+            duration = MathUtil::max(duration, timeline->_frames[drawOrderCount - 1]);
         }
         }
 
 
         // Event timeline.
         // Event timeline.
@@ -989,7 +989,7 @@ namespace Spine {
             }
             }
 
 
 			timelines.add(timeline);
 			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);
         return new (__FILE__, __LINE__) Animation(String(name), timelines, duration);
@@ -1011,4 +1011,8 @@ namespace Spine {
             }
             }
         }
         }
     }
     }
+
+	String SkeletonBinary::toString() const {
+		return String("SkeletonBinary");
+	}
 }
 }

+ 14 - 4
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) {
             for (int ii = 0, nn = polygon->_count; ii < nn; ii += 2) {
                 float x = vertices[ii];
                 float x = vertices[ii];
                 float y = vertices[ii + 1];
                 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;
         _minX = minX;
@@ -233,5 +233,15 @@ namespace Spine {
         _maxX = maxX;
         _maxX = maxX;
         _maxY = maxY;
         _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;
+    }
 }
 }
 
 

+ 10 - 3
spine-cpp/spine-cpp/src/spine/SkeletonClipping.cpp

@@ -96,8 +96,10 @@ namespace Spine {
         clippedVertices.clear();
         clippedVertices.clear();
         _clippedUVs.clear();
         _clippedUVs.clear();
         clippedTriangles.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;
             int vertexOffset = triangles[i] << 1;
             float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
             float x1 = vertices[vertexOffset], y1 = vertices[vertexOffset + 1];
             float u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
             float u1 = uvs[vertexOffset], v1 = uvs[vertexOffset + 1];
@@ -170,7 +172,8 @@ namespace Spine {
                     clippedTriangles[s + 1] = index + 1;
                     clippedTriangles[s + 1] = index + 1;
                     clippedTriangles[s + 2] = index + 2;
                     clippedTriangles[s + 2] = index + 2;
                     index += 3;
                     index += 3;
-                    break;
+                    i += 3;
+                    goto continue_outer;
                 }
                 }
             }
             }
         }
         }
@@ -312,4 +315,8 @@ namespace Spine {
             polygon[other + 1] = y;
             polygon[other + 1] = y;
         }
         }
     }
     }
+
+	String SkeletonClipping::toString() const {
+		return String("SkeletonClipping");
+	}
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/SkeletonData.cpp

@@ -232,4 +232,8 @@ namespace Spine {
     void SkeletonData::setFps(float inValue) {
     void SkeletonData::setFps(float inValue) {
         _fps = inValue;
         _fps = inValue;
     }
     }
+
+    String SkeletonData::toString() const {
+        return String("SkeletonData");
+    }
 }
 }

+ 17 - 13
spine-cpp/spine-cpp/src/spine/SkeletonJson.cpp

@@ -810,7 +810,7 @@ namespace Spine {
                     }
                     }
 					timelines.add(timeline);
 					timelines.add(timeline);
                     timelinesCount++;
                     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) {
                 else if (strcmp(timelineMap->_name, "color") == 0) {
@@ -825,7 +825,7 @@ namespace Spine {
                     }
                     }
 					timelines.add(timeline);
 					timelines.add(timeline);
                     timelinesCount++;
                     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) {
                 else if (strcmp(timelineMap->_name, "twoColor") == 0) {
@@ -842,7 +842,7 @@ namespace Spine {
                     }
                     }
 					timelines.add(timeline);
 					timelines.add(timeline);
                     timelinesCount++;
                     timelinesCount++;
-                    duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TwoColorTimeline::ENTRIES]);
+                    duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * TwoColorTimeline::ENTRIES]);
                 }
                 }
                 else {
                 else {
                     ContainerUtil::cleanUpVectorOfPointers(timelines);
                     ContainerUtil::cleanUpVectorOfPointers(timelines);
@@ -875,7 +875,7 @@ namespace Spine {
                     }
                     }
 					timelines.add(timeline);
 					timelines.add(timeline);
                     timelinesCount++;
                     timelinesCount++;
-                    duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * RotateTimeline::ENTRIES]);
+                    duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * RotateTimeline::ENTRIES]);
                 }
                 }
                 else {
                 else {
                     int isScale = strcmp(timelineMap->_name, "scale") == 0;
                     int isScale = strcmp(timelineMap->_name, "scale") == 0;
@@ -902,7 +902,7 @@ namespace Spine {
 
 
 						timelines.add(timeline);
 						timelines.add(timeline);
                     timelinesCount++;
                     timelinesCount++;
-                        duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TranslateTimeline::ENTRIES]);
+                        duration = MathUtil::max(duration, timeline->_frames[(timelineMap->_size - 1) * TranslateTimeline::ENTRIES]);
                     }
                     }
                     else {
                     else {
                         ContainerUtil::cleanUpVectorOfPointers(timelines);
                         ContainerUtil::cleanUpVectorOfPointers(timelines);
@@ -930,7 +930,7 @@ namespace Spine {
             }
             }
 			timelines.add(timeline);
 			timelines.add(timeline);
                     timelinesCount++;
                     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. */
         /** Transform constraint timelines. */
@@ -950,7 +950,7 @@ namespace Spine {
             }
             }
 			timelines.add(timeline);
 			timelines.add(timeline);
                     timelinesCount++;
                     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. */
         /** Path constraint timelines. */
@@ -999,7 +999,7 @@ namespace Spine {
                     }
                     }
 					timelines.add(timeline);
 					timelines.add(timeline);
                     timelinesCount++;
                     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) {
                 else if (strcmp(timelineName, "mix") == 0) {
                     PathConstraintMixTimeline* timeline = new (__FILE__, __LINE__) PathConstraintMixTimeline(timelineMap->_size);
                     PathConstraintMixTimeline* timeline = new (__FILE__, __LINE__) PathConstraintMixTimeline(timelineMap->_size);
@@ -1010,7 +1010,7 @@ namespace Spine {
                     }
                     }
 					timelines.add(timeline);
 					timelines.add(timeline);
                     timelinesCount++;
                     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);
 					timelines.add(timeline);
                     timelinesCount++;
                     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);
 			timelines.add(timeline);
                     timelinesCount++;
                     timelinesCount++;
-            duration = MAX(duration, timeline->_frames[drawOrder->_size - 1]);
+            duration = MathUtil::max(duration, timeline->_frames[drawOrder->_size - 1]);
         }
         }
 
 
         /** Event timeline. */
         /** Event timeline. */
@@ -1165,7 +1165,7 @@ namespace Spine {
             }
             }
 			timelines.add(timeline);
 			timelines.add(timeline);
                     timelinesCount++;
                     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);
         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) {
     void SkeletonJson::setError(Json* root, const String& value1, const String& value2) {
-        _error = String(value1 + value2);
+        _error = String(value1).append(value2);
 
 
         delete root;
         delete root;
     }
     }
+
+    String SkeletonJson::toString() const {
+        return String("SkeletonJson");
+    }
 }
 }

+ 16 - 2
spine-cpp/spine-cpp/src/spine/Skin.cpp

@@ -46,8 +46,14 @@ namespace Spine {
     bool Skin::AttachmentKey::operator==(const AttachmentKey &other) const {
     bool Skin::AttachmentKey::operator==(const AttachmentKey &other) const {
         return _slotIndex == other._slotIndex && _name == other._name;
         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;
         std::size_t h1 = val._slotIndex;
         return h1;
         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;
+    }
 }
 }

+ 9 - 0
spine-cpp/spine-cpp/src/spine/Slot.cpp

@@ -118,4 +118,13 @@ namespace Spine {
     void Slot::setAttachmentVertices(Vector<float> inValue) {
     void Slot::setAttachmentVertices(Vector<float> inValue) {
         _attachmentVertices = 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;
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/SlotData.cpp

@@ -89,4 +89,8 @@ namespace Spine {
     void SlotData::setBlendMode(BlendMode inValue) {
     void SlotData::setBlendMode(BlendMode inValue) {
         _blendMode = inValue;
         _blendMode = inValue;
     }
     }
+
+    String SlotData::toString() const {
+        return String("SlotData");
+    }
 }
 }

+ 6 - 0
spine-cpp/spine-cpp/src/spine/Timeline.cpp

@@ -41,4 +41,10 @@ namespace Spine {
     
     
     Timeline::~Timeline() {
     Timeline::~Timeline() {
     }
     }
+
+	String Timeline::toString() const {
+		String str;
+		str.appendString(getRTTI().toString());
+		return str;
+	}
 }
 }

+ 25 - 19
spine-cpp/spine-cpp/src/spine/TransformConstraint.cpp

@@ -134,7 +134,7 @@ namespace Spine {
         float rotateMix = _rotateMix, translateMix = _translateMix, scaleMix = _scaleMix, shearMix = _shearMix;
         float rotateMix = _rotateMix, translateMix = _translateMix, scaleMix = _scaleMix, shearMix = _shearMix;
         Bone& target = *_target;
         Bone& target = *_target;
         float ta = target._a, tb = target._b, tc = target._c, td = target._d;
         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;
         float offsetRotation = _data._offsetRotation * degRadReflect, offsetShearY = _data._offsetShearY * degRadReflect;
         
         
         for (size_t i = 0; i < _bones.size(); ++i) {
         for (size_t i = 0; i < _bones.size(); ++i) {
@@ -146,11 +146,11 @@ namespace Spine {
             if (rotateMix != 0) {
             if (rotateMix != 0) {
                 float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
                 float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
                 float r = MathUtil::atan2(tc, ta) - MathUtil::atan2(c, a) + offsetRotation;
                 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;
                 r *= rotateMix;
@@ -192,11 +192,11 @@ namespace Spine {
                 float b = bone._b, d = bone._d;
                 float b = bone._b, d = bone._d;
                 float by = MathUtil::atan2(d, b);
                 float by = MathUtil::atan2(d, b);
                 float r = MathUtil::atan2(td, tb) - MathUtil::atan2(tc, ta) - (by - MathUtil::atan2(bone._c, bone._a));
                 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;
                 r = by + (r + offsetShearY) * shearMix;
@@ -216,7 +216,7 @@ namespace Spine {
         float rotateMix = _rotateMix, translateMix = _translateMix, scaleMix = _scaleMix, shearMix = _shearMix;
         float rotateMix = _rotateMix, translateMix = _translateMix, scaleMix = _scaleMix, shearMix = _shearMix;
         Bone& target = *_target;
         Bone& target = *_target;
         float ta = target._a, tb = target._b, tc = target._c, td = target._d;
         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;
         float offsetRotation = _data._offsetRotation * degRadReflect, offsetShearY = _data._offsetShearY * degRadReflect;
         for (size_t i = 0; i < _bones.size(); ++i) {
         for (size_t i = 0; i < _bones.size(); ++i) {
             Bone* item = _bones[i];
             Bone* item = _bones[i];
@@ -227,11 +227,11 @@ namespace Spine {
             if (rotateMix != 0) {
             if (rotateMix != 0) {
                 float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
                 float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
                 float r = MathUtil::atan2(tc, ta) + offsetRotation;
                 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;
                 r *= rotateMix;
@@ -263,15 +263,15 @@ namespace Spine {
             
             
             if (shearMix > 0) {
             if (shearMix > 0) {
                 float r = MathUtil::atan2(td, tb) - MathUtil::atan2(tc, ta);
                 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;
                 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);
                 float s = MathUtil::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;
@@ -379,4 +379,10 @@ namespace Spine {
             bone.updateWorldTransform(x, y, rotation, scaleX, scaleY, bone._ashearX, shearY);
             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;
+    }
 }
 }

+ 4 - 0
spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp

@@ -116,4 +116,8 @@ namespace Spine {
     bool TransformConstraintData::isLocal() {
     bool TransformConstraintData::isLocal() {
         return _local;
         return _local;
     }
     }
+
+    String TransformConstraintData::toString() const {
+        return String("TransformConstraintData");
+    }
 }
 }

+ 5 - 1
spine-cpp/spine-cpp/src/spine/Triangulator.cpp

@@ -53,7 +53,7 @@ namespace Spine {
         
         
         Vector<int>& triangles = _triangles;
         Vector<int>& triangles = _triangles;
         triangles.clear();
         triangles.clear();
-		triangles.ensureCapacity(MAX(0, vertexCount - 2) << 2);
+		triangles.ensureCapacity(MathUtil::max(0, vertexCount - 2) << 2);
         
         
         while (vertexCount > 3) {
         while (vertexCount > 3) {
             // Find ear tip.
             // Find ear tip.
@@ -293,4 +293,8 @@ namespace Spine {
         
         
         return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1;
         return p3x * py - p3y * px + px * p1y - p1x * py >= 0 ? 1 : -1;
     }
     }
+
+	String Triangulator::toString() const {
+		return String("Triangulator");
+	}
 }
 }

+ 11 - 13
spine-sfml/cpp/example/main.cpp

@@ -340,6 +340,7 @@ void coin (SkeletonData* skeletonData, Atlas* atlas) {
 	skeleton->updateWorldTransform();
 	skeleton->updateWorldTransform();
 
 
 	drawable->state->setAnimation(0, "rotate", true);
 	drawable->state->setAnimation(0, "rotate", true);
+	drawable->update(0.1);
 
 
 	sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - vine");
 	sf::RenderWindow window(sf::VideoMode(640, 640), "Spine SFML - vine");
 	window.setFramerateLimit(60);
 	window.setFramerateLimit(60);
@@ -353,7 +354,7 @@ void coin (SkeletonData* skeletonData, Atlas* atlas) {
 		float delta = deltaClock.getElapsedTime().asSeconds();
 		float delta = deltaClock.getElapsedTime().asSeconds();
 		deltaClock.restart();
 		deltaClock.restart();
 
 
-		drawable->update(delta);
+		// drawable->update(delta);
 
 
 		window.clear();
 		window.clear();
 		window.draw(*drawable);
 		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::Closed) window.close();
 			if (event.type == sf::Event::MouseMoved) {
 			if (event.type == sf::Event::MouseMoved) {
 				float x = event.mouseMove.x / 640.0f;
 				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;
 				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;
 	float d = 3;
 	for (int i = 0; i < 1; i++) {
 	for (int i = 0; i < 1; i++) {
-		skeleton->update(d);
 		animState->update(d);
 		animState->update(d);
 		animState->apply(*skeleton);
 		animState->apply(*skeleton);
 		skeleton->updateWorldTransform();
 		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");
 		printf("========================================\n");
 		d += 0.1f;
 		d += 0.1f;
 	}
 	}
@@ -444,15 +441,16 @@ void test (SkeletonData* skeletonData, Atlas* atlas) {
 
 
 int main () {
 int main () {
 	DebugExtension dbgExtension;
 	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(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(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(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(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(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(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);
 	testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman.atlas", 0.6f);
 	dbgExtension.reportLeaks();
 	dbgExtension.reportLeaks();
 	return 0;
 	return 0;

+ 4 - 0
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) {
 void SFMLTextureLoader::unload(void *texture) {
 	delete (Texture*)texture;
 	delete (Texture*)texture;
 }
 }
+
+	String SFMLTextureLoader::toString() const {
+		return String("SFMLTextureLoader");
+	}
 } /* namespace spine */
 } /* namespace spine */

+ 2 - 0
spine-sfml/cpp/src/spine/spine-sfml.h

@@ -71,6 +71,8 @@ public:
 	virtual void load(AtlasPage& page, const String& path);
 	virtual void load(AtlasPage& page, const String& path);
 
 
 	virtual void unload(void* texture);
 	virtual void unload(void* texture);
+
+	String toString() const;
 };
 };
 
 
 } /* namespace spine */
 } /* namespace spine */