diff --git a/spine-cpp/spine-cpp/include/spine/Attachment.h b/spine-cpp/spine-cpp/include/spine/Attachment.h index 02a2f69d8..9f9f8460d 100644 --- a/spine-cpp/spine-cpp/include/spine/Attachment.h +++ b/spine-cpp/spine-cpp/include/spine/Attachment.h @@ -44,8 +44,6 @@ namespace Spine private: const std::string _name; - - friend std::ostream& operator <<(std::ostream& os, const Attachment& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/Bone.h b/spine-cpp/spine-cpp/include/spine/Bone.h index b35dbdc87..3ddcfa48b 100644 --- a/spine-cpp/spine-cpp/include/spine/Bone.h +++ b/spine-cpp/spine-cpp/include/spine/Bone.h @@ -388,8 +388,6 @@ namespace Spine this.d = sin * b + cos * d; appliedValid = false; } - - friend std::ostream& operator <<(std::ostream& os, const Bone& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/BoneData.h b/spine-cpp/spine-cpp/include/spine/BoneData.h index 79467a035..ef81b1e62 100644 --- a/spine-cpp/spine-cpp/include/spine/BoneData.h +++ b/spine-cpp/spine-cpp/include/spine/BoneData.h @@ -93,8 +93,6 @@ namespace Spine float _length; float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY; TransformMode _transformMode; - - friend std::ostream& operator <<(std::ostream& os, const BoneData& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/CurveTimeline.h b/spine-cpp/spine-cpp/include/spine/CurveTimeline.h index 323198f41..24b3ad527 100644 --- a/spine-cpp/spine-cpp/include/spine/CurveTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/CurveTimeline.h @@ -32,8 +32,8 @@ #define Spine_CurveTimeline_h #include +#include -#include #include namespace Spine @@ -44,7 +44,7 @@ namespace Spine public: CurveTimeline(int frameCount); - virtual void apply(Skeleton& skeleton, float lastTime, float time, std::vector& events, float alpha, MixPose pose, MixDirection direction) = 0; + virtual void apply(Skeleton& skeleton, float lastTime, float time, SimpleArray& events, float alpha, MixPose pose, MixDirection direction) = 0; virtual int getPropertyId() = 0; @@ -70,7 +70,7 @@ namespace Spine static const int BEZIER_SIZE; private: - std::vector _curves; // type, x, y, ... + SimpleArray _curves; // type, x, y, ... }; } diff --git a/spine-cpp/spine-cpp/include/spine/Event.h b/spine-cpp/spine-cpp/include/spine/Event.h index 37d1acd6a..07d36999c 100644 --- a/spine-cpp/spine-cpp/include/spine/Event.h +++ b/spine-cpp/spine-cpp/include/spine/Event.h @@ -63,8 +63,6 @@ namespace Spine int _intValue; float _floatValue; std::string _stringValue; - - friend std::ostream& operator <<(std::ostream& os, const Event& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/EventData.h b/spine-cpp/spine-cpp/include/spine/EventData.h index e26a44d7c..9705f5d89 100644 --- a/spine-cpp/spine-cpp/include/spine/EventData.h +++ b/spine-cpp/spine-cpp/include/spine/EventData.h @@ -60,8 +60,6 @@ namespace Spine private: friend class Event; const std::string _name; - - friend std::ostream& operator <<(std::ostream& os, const EventData& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/HashMap.h b/spine-cpp/spine-cpp/include/spine/HashMap.h new file mode 100755 index 000000000..466970ca5 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/HashMap.h @@ -0,0 +1,352 @@ +/****************************************************************************** + * Spine Runtimes Software License v2.5 + * + * Copyright (c) 2013-2016, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable, and + * non-transferable license to use, install, execute, and perform the Spine + * Runtimes software and derivative works solely for personal or internal + * use. Without the written permission of Esoteric Software (see Section 2 of + * the Spine Software License Agreement), you may not (a) modify, translate, + * adapt, or develop new applications using the Spine Runtimes or otherwise + * create derivative works or improvements of the Spine Runtimes or (b) remove, + * delete, alter, or obscure any trademarks or any copyright, trademark, patent, + * or other intellectual property or proprietary rights notices on or in the + * Software, including any copy thereof. Redistributions in binary or source + * form must include this license and terms. + * + * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF + * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef Spine_HashMap_h +#define Spine_HashMap_h + +#include +#include + +namespace Spine +{ + template + class HashMap + { + private: + class Entry; + + public: + class Iterator + { + friend class HashMap; + + public: + Iterator(Entry* entry = NULL) : _entry(entry) + { + // Empty + } + + Iterator& operator++() + { + _entry = _entry->next; + return *this; + } + + Iterator& operator--() + { + _entry = _entry->prev; + return *this; + } + + bool operator==(const Iterator& p) const + { + return _entry == p._entry; + } + + bool operator!=(const Iterator& p) const + { + return _entry != p._entry; + } + + K& first() + { + return _entry->_key; + } + + V& second() + { + return _entry->_value; + } + + private: + Entry* _entry; + }; + + HashMap(int capacity) : _capacity(capacity), _hashFunction(), _header(), _trailer() + { + _hashTable = new Entry[capacity]; + for (int i = 0; i < _capacity; ++i) + { + _hashTable[i] = Entry(); + } + + _header.prev = &_header; + _header.next = &_trailer; + _trailer.prev = &_header; + _trailer.next = &_trailer; + _hashSize = 0; + } + + ~HashMap() + { + delete [] _hashTable; + + _hashSize = 0; + } + + size_t size() + { + return _hashSize; + } + + Iterator begin() + { + return Iterator(_header.next); + } + + Iterator end() + { + return Iterator(&_trailer); + } + + Iterator rbegin() + { + return Iterator(_trailer.prev); + } + + Iterator rend() + { + return Iterator(_header); + } + + Iterator insert(const K& key, const V& value) + { + Iterator iter = find(key); + + if (iter._entry != &_trailer) + { + return Iterator(&_trailer); + } + + size_t index = hash(key); + + Entry* entry = new Entry; + entry->_key = key; + entry->_value = value; + + _hashSize++; + + if (_header.next == (&_trailer)) + { + _hashTable[index].next = entry; + _hashTable[index].prev = entry; + _header.next = entry; + entry->prev = &_header; + entry->next = &_trailer; + _trailer.prev = entry; + + return Iterator(entry); + } + + if (_hashTable[index].next == NULL) + { + _hashTable[index].next = entry; + _hashTable[index].prev = entry; + if (index < hash(_header.next->_key)) + { + entry->next = _header.next; + entry->prev = &_header; + _header.next->prev = entry; + _header.next = entry; + } + else if (index > hash(_header.next->_key) && index < hash(_trailer.prev->_key)) + { + size_t prev_index = index; + + while (_hashTable[--prev_index].next != NULL) + { + // Empty + } + + entry->next = _hashTable[prev_index].prev->next; + entry->prev = _hashTable[prev_index].prev; + _hashTable[prev_index].prev->next = entry; + entry->next->prev = entry; + } + else + { + entry->next = &_trailer; + entry->prev = _trailer.prev; + _trailer.prev = entry; + entry->prev->next = entry; + } + + return Iterator(entry); + } + + if (index == hash(_header.next->_key)) + { + _header.next = entry; + entry->next = _hashTable[index].next; + entry->prev = &_header; + _hashTable[index].next->prev = entry; + _hashTable[index].next = entry; + } + else + { + entry->next = _hashTable[index].next; + entry->prev = _hashTable[index].next->prev; + entry->next->prev = entry; + entry->prev->next = entry; + _hashTable[index].next = entry; + } + + return Iterator(entry); + } + + Iterator find(const K& key) + { + const size_t index = hash(key); + Iterator iter(_hashTable[index].next); + + if (iter._entry != NULL) + { + for ( ; hash(iter._entry->_key) == index ; ++iter) + { + if (iter._entry->_key == key) + { + return iter; + } + } + } + + return Iterator(&_trailer); + } + + void erase(Iterator pos) + { + if (pos._entry != &_header && pos._entry != &_trailer) + { + size_t index = hash(pos._entry->_key); + + if (_hashTable[index].next == pos._entry && _hashTable[index].prev == pos._entry) + { + _hashTable[index].next = NULL; + _hashTable[index].prev = NULL; + + if (_header.next == pos._entry) + { + _header.next = pos._entry->next; + pos._entry->next->prev = &_header; + } + else if (_trailer.prev == pos._entry) + { + _trailer.prev = pos._entry->prev; + pos._entry->prev->next = &_trailer; + } + else + { + pos._entry->prev->next = pos._entry->next; + pos._entry->next->prev = pos._entry->prev; + } + + delete pos._entry; + } + else if (_hashTable[index].next == pos._entry) + { + _hashTable[index].next = pos._entry->next; + if (_header.next == pos._entry) + { + _header.next = pos._entry->next; + pos._entry->next->prev = &_header; + } + else + { + pos._entry->prev->next = pos._entry->next; + pos._entry->next->prev = pos._entry->prev; + } + + delete pos._entry; + } + else if (_hashTable[index].prev == pos._entry) + { + _hashTable[index].prev = pos._entry->prev; + if (_trailer.prev == pos._entry) + { + _trailer.prev = pos._entry->prev; + pos._entry->prev->next = &_trailer; + } + else + { + pos._entry->prev->next = pos._entry->next; + pos._entry->next->prev = pos._entry->prev; + } + + delete pos._entry; + } + else + { + pos._entry->prev->next = pos._entry->next; + pos._entry->next->prev = pos._entry->prev; + + delete pos._entry; + } + + _hashSize--; + } + } + + V operator[](const K& key) + { + Iterator iter = find(key); + + if (iter._entry != _trailer) + { + return iter._entry->_value; + } + + return V(); + } + + private: + class Entry + { + public: + K _key; + V _value; + Entry* next; + Entry* prev; + }; + + const H _hashFunction; + const int _capacity; + Entry* _hashTable; + Entry _header; + Entry _trailer; + size_t _hashSize; + + size_t hash(const K& key) + { + return _hashFunction(key) % _capacity; + } + }; +} + +#endif /* Spine_HashMap_h */ diff --git a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h index ad0018068..0e54049a0 100644 --- a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h @@ -31,8 +31,9 @@ #ifndef Spine_IkConstraintData_h #define Spine_IkConstraintData_h +#include + #include -#include class BoneData; @@ -50,7 +51,7 @@ namespace Spine void setOrder(int inValue); /// The bones that are constrained by this IK Constraint. - std::vector& getBones(); + SimpleArray& getBones(); /// The bone that is the IK target. BoneData* getTarget(); @@ -66,12 +67,10 @@ namespace Spine private: const std::string _name; int _order; - std::vector _bones; + SimpleArray _bones; BoneData* _target; int _bendDirection; float _mix; - - friend std::ostream& operator <<(std::ostream& os, const IkConstraintData& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/MixDirection.h b/spine-cpp/spine-cpp/include/spine/MixDirection.h index 637e61e2d..1400e1b3a 100644 --- a/spine-cpp/spine-cpp/include/spine/MixDirection.h +++ b/spine-cpp/spine-cpp/include/spine/MixDirection.h @@ -35,7 +35,7 @@ namespace Spine { /// /// Indicates whether a timeline's alpha is mixing out over time toward 0 (the setup or current pose) or mixing in toward 1 (the timeline's pose). - /// See also Timeline::apply(Skeleton&, float, float, std::vector&, float, MixPose, MixDirection) + /// See also Timeline::apply(Skeleton&, float, float, SimpleArray&, float, MixPose, MixDirection) enum MixDirection { MixDirection_In = 0, diff --git a/spine-cpp/spine-cpp/include/spine/MixPose.h b/spine-cpp/spine-cpp/include/spine/MixPose.h index 70f08931c..487165890 100644 --- a/spine-cpp/spine-cpp/include/spine/MixPose.h +++ b/spine-cpp/spine-cpp/include/spine/MixPose.h @@ -35,7 +35,7 @@ namespace Spine { /// /// Controls how a timeline is mixed with the setup or current pose. - /// See also Timeline::apply(Skeleton&, float, float, std::vector&, float, MixPose, MixDirection) + /// See also Timeline::apply(Skeleton&, float, float, SimpleArray&, float, MixPose, MixDirection) enum MixPose { /// The timeline value is mixed with the setup pose (the current pose is not used). diff --git a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h index 17f0b02d3..63c5ddcc6 100644 --- a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h @@ -34,9 +34,9 @@ #include #include #include +#include #include -#include namespace Spine { @@ -53,7 +53,7 @@ namespace Spine int getOrder(); void setOrder(int inValue); - std::vector& getBones(); + SimpleArray& getBones(); SlotData* getTarget(); void setTarget(SlotData* inValue); @@ -85,15 +85,13 @@ namespace Spine private: const std::string _name; int _order; - std::vector _bones; + SimpleArray _bones; SlotData* _target; PositionMode _positionMode; SpacingMode _spacingMode; RotateMode _rotateMode; float _offsetRotation; float _position, _spacing, _rotateMix, _translateMix; - - friend std::ostream& operator <<(std::ostream& os, const PathConstraintData& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/RotateTimeline.h b/spine-cpp/spine-cpp/include/spine/RotateTimeline.h index 0c05a331d..41547f417 100644 --- a/spine-cpp/spine-cpp/include/spine/RotateTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/RotateTimeline.h @@ -42,7 +42,7 @@ namespace Spine RotateTimeline(int frameCount); - virtual void apply(Skeleton& skeleton, float lastTime, float time, std::vector& events, float alpha, MixPose pose, MixDirection direction); + virtual void apply(Skeleton& skeleton, float lastTime, float time, SimpleArray& events, float alpha, MixPose pose, MixDirection direction); virtual int getPropertyId(); @@ -52,8 +52,8 @@ namespace Spine int getBoneIndex(); void setBoneIndex(int inValue); - std::vector& getFrames(); - void setFrames(std::vector inValue); + SimpleArray& getFrames(); + void setFrames(SimpleArray inValue); private: static const int PREV_TIME = -2; @@ -61,7 +61,7 @@ namespace Spine static const int ROTATION = 1; int _boneIndex; - std::vector _frames; // time, angle, ... + SimpleArray _frames; // time, angle, ... }; } diff --git a/spine-cpp/spine-cpp/include/spine/SimpleArray.h b/spine-cpp/spine-cpp/include/spine/SimpleArray.h new file mode 100644 index 000000000..e544c8104 --- /dev/null +++ b/spine-cpp/spine-cpp/include/spine/SimpleArray.h @@ -0,0 +1,187 @@ +/****************************************************************************** + * Spine Runtimes Software License v2.5 + * + * Copyright (c) 2013-2016, Esoteric Software + * All rights reserved. + * + * You are granted a perpetual, non-exclusive, non-sublicensable, and + * non-transferable license to use, install, execute, and perform the Spine + * Runtimes software and derivative works solely for personal or internal + * use. Without the written permission of Esoteric Software (see Section 2 of + * the Spine Software License Agreement), you may not (a) modify, translate, + * adapt, or develop new applications using the Spine Runtimes or otherwise + * create derivative works or improvements of the Spine Runtimes or (b) remove, + * delete, alter, or obscure any trademarks or any copyright, trademark, patent, + * or other intellectual property or proprietary rights notices on or in the + * Software, including any copy thereof. Redistributions in binary or source + * form must include this license and terms. + * + * THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL ESOTERIC SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS INTERRUPTION, OR LOSS OF + * USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef Spine_SimpleArray_h +#define Spine_SimpleArray_h + +#include +#include + +namespace Spine +{ + template + class SimpleArray + { + public: + SimpleArray() : _size(0), _capacity(0), _buffer(nullptr) + { + // Empty + } + + SimpleArray(const SimpleArray& inArray) + { + _size = inArray._size; + _capacity = inArray._capacity; + if (_capacity) + { + _buffer = allocate(_capacity); + for (size_t i = 0; i < _size; ++i) + { + construct(_buffer + i, inArray._buffer[i]); + } + } + } + + ~SimpleArray() + { + clear(); + deallocate(_buffer); + } + + void push_back(const T& _value) + { + if (_size == _capacity) + { + reserve(); + } + + construct(_buffer + _size++, _value); + } + + void insert(size_t _index, const T& _value) + { + assert(_index < _size); + + if (_size == _capacity) + { + reserve(); + } + + for (size_t i = ++_size - 1; i > _index; --i) + { + construct(_buffer + i, _buffer[i - 1]); + destroy(_buffer + (i - 1)); + } + + construct(_buffer + _index, _value); + } + + void erase(size_t _index) + { + assert(_index < _size); + + --_size; + + if (_index != _size) + { + for (size_t i = _index; i < _size; ++i) + { + _buffer[i] = std::move(_buffer[i + 1]); + } + } + + destroy(_buffer + _size); + } + + void clear() + { + for (size_t i = 0; i < _size; ++i) + { + destroy(_buffer + (_size - 1 - i)); + } + + _size = 0; + } + + size_t size() const + { + return _size; + } + + T& operator[](size_t _index) + { + assert(_index < _size); + + return _buffer[_index]; + } + + void reserve(long inCapacity = -1) + { + size_t newCapacity = inCapacity != -1 ? inCapacity : _capacity ? _capacity * 2 : 1; + _buffer = static_cast(realloc(_buffer, newCapacity * sizeof(T))); + _capacity = newCapacity; + } + + T* begin() + { + return &_buffer[0]; + } + + T* end() + { + return &_buffer[_size]; + } + + private: + size_t _size; + size_t _capacity; + T* _buffer; + + T* allocate(size_t n) + { + assert(n > 0); + + void* ptr = malloc(n * sizeof(T)); + assert(ptr); + + return static_cast(ptr); + } + + void deallocate(T* buffer) + { + free(buffer); + } + + void construct(T* buffer, const T& val) + { + /// This is a placement new operator + /// which basically means we are contructing a new object + /// using pre-allocated memory + new (buffer) T(val); + } + + void destroy(T* buffer) + { + buffer->~T(); + } + }; +} + +#endif /* Spine_SimpleArray_h */ diff --git a/spine-cpp/spine-cpp/include/spine/Skeleton.h b/spine-cpp/spine-cpp/include/spine/Skeleton.h index b7dd1ca51..93ecaecc8 100644 --- a/spine-cpp/spine-cpp/include/spine/Skeleton.h +++ b/spine-cpp/spine-cpp/include/spine/Skeleton.h @@ -31,8 +31,9 @@ #ifndef Spine_Skeleton_h #define Spine_Skeleton_h +#include + #include -#include namespace Spine { @@ -49,13 +50,13 @@ namespace Spine { public: SkeletonData* getData(); - std::vector getBones(); - std::vector getUpdateCacheList(); - std::vector getSlots(); - std::vector getDrawOrder(); - std::vector getIkConstraints(); - std::vector getPathConstraints(); - std::vector getTransformConstraints(); + SimpleArray getBones(); + SimpleArray getUpdateCacheList(); + SimpleArray getSlots(); + SimpleArray getDrawOrder(); + SimpleArray getIkConstraints(); + SimpleArray getPathConstraints(); + SimpleArray getTransformConstraints(); Skin* getSkin { get { return skin; } set { skin = value; } } float getR { get { return r; } set { r = value; } } @@ -83,7 +84,7 @@ namespace Spine this.data = data; - bones = new std::vector(data.bones.Count); + bones = new SimpleArray(data.bones.Count); foreach (BoneData boneData in data.bones) { Bone bone; @@ -100,8 +101,8 @@ namespace Spine bones.Add(bone); } - slots = new std::vector(data.slots.Count); - drawOrder = new std::vector(data.slots.Count); + slots = new SimpleArray(data.slots.Count); + drawOrder = new SimpleArray(data.slots.Count); foreach (SlotData slotData in data.slots) { Bone bone = bones.Items[slotData.boneData.index]; @@ -110,15 +111,15 @@ namespace Spine drawOrder.Add(slot); } - ikConstraints = new std::vector(data.ikConstraints.Count); + ikConstraints = new SimpleArray(data.ikConstraints.Count); foreach (IkConstraintData ikConstraintData in data.ikConstraints) ikConstraints.Add(new IkConstraint(ikConstraintData, this)); - transformConstraints = new std::vector(data.transformConstraints.Count); + transformConstraints = new SimpleArray(data.transformConstraints.Count); foreach (TransformConstraintData transformConstraintData in data.transformConstraints) transformConstraints.Add(new TransformConstraint(transformConstraintData, this)); - pathConstraints = new std::vector (data.pathConstraints.Count); + pathConstraints = new SimpleArray (data.pathConstraints.Count); foreach (PathConstraintData pathConstraintData in data.pathConstraints) pathConstraints.Add(new PathConstraint(pathConstraintData, this)); @@ -135,17 +136,17 @@ namespace Spine /// or removed. void updateCache() { - std::vector updateCache = this.updateCache; + SimpleArray updateCache = this.updateCache; updateCache.Clear(); this.updateCacheReset.Clear(); - std::vector bones = this.bones; + SimpleArray bones = this.bones; for (int i = 0, n = bones.Count; i < n; i++) { bones.Items[i].sorted = false; } - std::vector ikConstraints = this.ikConstraints; + SimpleArray ikConstraints = this.ikConstraints; var transformConstraints = this.transformConstraints; var pathConstraints = this.pathConstraints; int ikCount = IkConstraints.Count, transformCount = transformConstraints.Count, pathCount = pathConstraints.Count; @@ -391,7 +392,7 @@ namespace Spine } else { - std::vector slots = this.slots; + SimpleArray slots = this.slots; for (int i = 0, n = slots.Count; i < n; i++) { Slot slot = slots.Items[i]; @@ -445,7 +446,7 @@ namespace Spine throw new ArgumentNullException("slotName", "slotName cannot be null."); } - std::vector slots = this.slots; + SimpleArray slots = this.slots; for (int i = 0, n = slots.Count; i < n; i++) { Slot slot = slots.Items[i]; @@ -478,7 +479,7 @@ namespace Spine throw new ArgumentNullException("constraintName", "constraintName cannot be null."); } - std::vector ikConstraints = this.ikConstraints; + SimpleArray ikConstraints = this.ikConstraints; for (int i = 0, n = ikConstraints.Count; i < n; i++) { IkConstraint ikConstraint = ikConstraints.Items[i]; @@ -496,7 +497,7 @@ namespace Spine throw new ArgumentNullException("constraintName", "constraintName cannot be null."); } - std::vector transformConstraints = this.transformConstraints; + SimpleArray transformConstraints = this.transformConstraints; for (int i = 0, n = transformConstraints.Count; i < n; i++) { TransformConstraint transformConstraint = transformConstraints.Items[i]; @@ -514,7 +515,7 @@ namespace Spine throw new ArgumentNullException("constraintName", "constraintName cannot be null."); } - std::vector pathConstraints = this.pathConstraints; + SimpleArray pathConstraints = this.pathConstraints; for (int i = 0, n = pathConstraints.Count; i < n; i++) { PathConstraint constraint = pathConstraints.Items[i]; @@ -594,14 +595,14 @@ namespace Spine private: SkeletonData* _data; - std::vector _bones; - std::vector _slots; - std::vector _drawOrder; - std::vector _ikConstraints; - std::vector _transformConstraints; - std::vector _pathConstraints; - std::vector _updateCache = new std::vector(); - std::vector _updateCacheReset = new std::vector(); + SimpleArray _bones; + SimpleArray _slots; + SimpleArray _drawOrder; + SimpleArray _ikConstraints; + SimpleArray _transformConstraints; + SimpleArray _pathConstraints; + SimpleArray _updateCache = new SimpleArray(); + SimpleArray _updateCacheReset = new SimpleArray(); Skin _skin; float _r = 1, _g = 1, _b = 1, _a = 1; float _time; @@ -763,7 +764,7 @@ namespace Spine updateCache.Add(bone); } - static void sortReset(std::vector& bones) + static void sortReset(SimpleArray& bones) { var bonesItems = bones.Items; for (int i = 0, n = bones.Count; i < n; i++) diff --git a/spine-cpp/spine-cpp/include/spine/Skin.h b/spine-cpp/spine-cpp/include/spine/Skin.h index 7a8b0f31a..72ee57f50 100644 --- a/spine-cpp/spine-cpp/include/spine/Skin.h +++ b/spine-cpp/spine-cpp/include/spine/Skin.h @@ -32,8 +32,10 @@ #define Spine_Skin_h #include -#include -#include +#include +#include + +struct HashAttachmentKey; namespace Spine { @@ -66,43 +68,37 @@ namespace Spine /// Returns the attachment for the specified slot index and name, or null. Attachment* getAttachment(int slotIndex, std::string name); - /// Finds the skin keys for a given slot. The results are added to the passed vector names. + /// Finds the skin keys for a given slot. The results are added to the passed array of names. /// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex - /// @param names Found skin key names will be added to this vector. - void findNamesForSlot(int slotIndex, std::vector& names); + /// @param names Found skin key names will be added to this array. + void findNamesForSlot(int slotIndex, SimpleArray& names); - /// Finds the attachments for a given slot. The results are added to the passed List(Attachment). + /// Finds the attachments for a given slot. The results are added to the passed array of Attachments. /// @param slotIndex The target slotIndex. To find the slot index, use Skeleton::findSlotIndex or SkeletonData::findSlotIndex - /// @param attachments Found Attachments will be added to this vector. - void findAttachmentsForSlot(int slotIndex, std::vector& attachments); + /// @param attachments Found Attachments will be added to this array. + void findAttachmentsForSlot(int slotIndex, SimpleArray& attachments); const std::string& getName(); - std::unordered_map& getAttachments(); + HashMap& getAttachments(); private: const std::string _name; - std::unordered_map _attachments; + HashMap _attachments; /// Attach all attachments from this skin if the corresponding attachment from the old skin is currently attached. void attachAll(Skeleton& skeleton, Skin& oldSkin); - - friend std::ostream& operator <<(std::ostream& os, const Skin& ref); }; } -namespace std +struct HashAttachmentKey { - template <> - struct hash + std::size_t operator()(const Spine::Skin::AttachmentKey& val) const { - std::size_t operator()(const Spine::Skin::AttachmentKey& val) const - { - size_t h1 = hash{}(val._slotIndex); - size_t h2 = hash{}(val._name); - - return h1 ^ (h2 << 1); - } - }; -} + std::size_t h1 = std::hash{}(val._slotIndex); + std::size_t h2 = std::hash{}(val._name); + + return h1 ^ (h2 << 1); + } +}; #endif /* Spine_Skin_h */ diff --git a/spine-cpp/spine-cpp/include/spine/Slot.h b/spine-cpp/spine-cpp/include/spine/Slot.h index edce64ffa..2f2ae4bc4 100644 --- a/spine-cpp/spine-cpp/include/spine/Slot.h +++ b/spine-cpp/spine-cpp/include/spine/Slot.h @@ -31,8 +31,9 @@ #ifndef Spine_Slot_h #define Spine_Slot_h +#include + #include -#include namespace Spine { @@ -77,8 +78,8 @@ namespace Spine float getAttachmentTime(); void setAttachmentTime(float inValue); - std::vector& getAttachmentVertices(); - void setAttachmentVertices(std::vector inValue); + SimpleArray& getAttachmentVertices(); + void setAttachmentVertices(SimpleArray inValue); private: const SlotData& _slotData; @@ -89,10 +90,8 @@ namespace Spine bool _hasSecondColor; Attachment* _attachment; float _attachmentTime; - std::vector _attachmentVertices; - - friend std::ostream& operator <<(std::ostream& os, const Slot& ref); - } + SimpleArray _attachmentVertices; + }; } #endif /* Spine_Slot_h */ diff --git a/spine-cpp/spine-cpp/include/spine/SlotData.h b/spine-cpp/spine-cpp/include/spine/SlotData.h index 6eb358a40..e843d545c 100644 --- a/spine-cpp/spine-cpp/include/spine/SlotData.h +++ b/spine-cpp/spine-cpp/include/spine/SlotData.h @@ -84,8 +84,6 @@ namespace Spine bool _hasSecondColor; std::string _attachmentName; BlendMode _blendMode; - - friend std::ostream& operator <<(std::ostream& os, const SlotData& ref); }; } diff --git a/spine-cpp/spine-cpp/include/spine/Timeline.h b/spine-cpp/spine-cpp/include/spine/Timeline.h index db09f8086..f74944694 100644 --- a/spine-cpp/spine-cpp/include/spine/Timeline.h +++ b/spine-cpp/spine-cpp/include/spine/Timeline.h @@ -31,11 +31,10 @@ #ifndef Spine_Timeline_h #define Spine_Timeline_h +#include #include #include -#include - namespace Spine { class Skeleton; @@ -52,14 +51,14 @@ namespace Spine /// @param skeleton The skeleton the timeline is being applied to. This provides access to the bones, slots, and other skeleton components the timeline may change. /// @param lastTime lastTime The time this timeline was last applied. Timelines such as EventTimeline trigger only at specific times rather than every frame. In that case, the timeline triggers everything between lastTime (exclusive) and time (inclusive). /// @param time The time within the animation. Most timelines find the key before and the key after this time so they can interpolate between the keys. - /// @param events If any events are fired, they are added to this list. Can be null to ignore firing events or if the timeline does not fire events. May be null. + /// @param events If any events are fired, they are added to this array. Can be null to ignore firing events or if the timeline does not fire events. May be null. /// @param alpha alpha 0 applies the current or setup pose value (depending on pose parameter). 1 applies the timeline /// value. Between 0 and 1 applies a value between the current or setup pose and the timeline value. By adjusting /// alpha over time, an animation can be mixed in or out. alpha can also be useful to /// apply animations on top of each other (layered). /// @param pose Controls how mixing is applied when alpha is than 1. /// @param direction Indicates whether the timeline is mixing in or out. Used by timelines which perform instant transitions such as DrawOrderTimeline and AttachmentTimeline. - virtual void apply(Skeleton& skeleton, float lastTime, float time, std::vector& events, float alpha, MixPose pose, MixDirection direction) = 0; + virtual void apply(Skeleton& skeleton, float lastTime, float time, SimpleArray& events, float alpha, MixPose pose, MixDirection direction) = 0; virtual int getPropertyId() = 0; }; diff --git a/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h b/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h index 5ce55ac79..bd4f9bd1b 100644 --- a/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h @@ -31,8 +31,9 @@ #ifndef Spine_TransformConstraintData_h #define Spine_TransformConstraintData_h +#include + #include -#include namespace Spine { @@ -45,7 +46,7 @@ namespace Spine const std::string& getName(); int getOrder(); - std::vector& getBones(); + SimpleArray& getBones(); BoneData* getTarget(); float getRotateMix(); float getTranslateMix(); @@ -65,13 +66,11 @@ namespace Spine private: const std::string _name; int _order; - std::vector _bones; + SimpleArray _bones; BoneData* _target; float _rotateMix, _translateMix, _scaleMix, _shearMix; float _offsetRotation, _offsetX, _offsetY, _offsetScaleX, _offsetScaleY, _offsetShearY; bool _relative, _local; - - friend std::ostream& operator <<(std::ostream& os, const TransformConstraintData& ref); }; } diff --git a/spine-cpp/spine-cpp/src/spine/Attachment.cpp b/spine-cpp/spine-cpp/src/spine/Attachment.cpp index 8ea383eea..fdd42ea70 100644 --- a/spine-cpp/spine-cpp/src/spine/Attachment.cpp +++ b/spine-cpp/spine-cpp/src/spine/Attachment.cpp @@ -43,11 +43,4 @@ namespace Spine { return _name; } - - std::ostream& operator <<(std::ostream& os, const Attachment& ref) - { - os << ref._name; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/Bone.cpp b/spine-cpp/spine-cpp/src/spine/Bone.cpp index 246ca7413..001098b6f 100644 --- a/spine-cpp/spine-cpp/src/spine/Bone.cpp +++ b/spine-cpp/spine-cpp/src/spine/Bone.cpp @@ -32,10 +32,5 @@ namespace Spine { - std::ostream& operator <<(std::ostream& os, const Bone& ref) - { - os << ref._data._name; - - return os; - } + // TODO } diff --git a/spine-cpp/spine-cpp/src/spine/BoneData.cpp b/spine-cpp/spine-cpp/src/spine/BoneData.cpp index 17f508e1a..ed87124ff 100644 --- a/spine-cpp/spine-cpp/src/spine/BoneData.cpp +++ b/spine-cpp/spine-cpp/src/spine/BoneData.cpp @@ -156,11 +156,4 @@ namespace Spine { _transformMode = inValue; } - - std::ostream& operator <<(std::ostream& os, const BoneData& ref) - { - os << ref._name; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/Event.cpp b/spine-cpp/spine-cpp/src/spine/Event.cpp index 548a32798..5f1458815 100644 --- a/spine-cpp/spine-cpp/src/spine/Event.cpp +++ b/spine-cpp/spine-cpp/src/spine/Event.cpp @@ -83,11 +83,4 @@ namespace Spine { _stringValue = inValue; } - - std::ostream& operator <<(std::ostream& os, const Event& ref) - { - os << ref._data; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/EventData.cpp b/spine-cpp/spine-cpp/src/spine/EventData.cpp index 1f6438a09..e0eccf90b 100644 --- a/spine-cpp/spine-cpp/src/spine/EventData.cpp +++ b/spine-cpp/spine-cpp/src/spine/EventData.cpp @@ -78,11 +78,4 @@ namespace Spine { _stringValue = inValue; } - - std::ostream& operator <<(std::ostream& os, const EventData& ref) - { - os << ref._name; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp index b8f3b9373..36d16b307 100644 --- a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp @@ -57,7 +57,7 @@ namespace Spine _order = inValue; } - std::vector& IkConstraintData::getBones() + SimpleArray& IkConstraintData::getBones() { return _bones; } @@ -91,11 +91,4 @@ namespace Spine { _mix = inValue; } - - std::ostream& operator <<(std::ostream& os, const IkConstraintData& ref) - { - os << ref._name; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp index 71ae38541..a9e1d07ef 100644 --- a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp @@ -68,7 +68,7 @@ namespace Spine _order = inValue; } - std::vector& PathConstraintData::getBones() + SimpleArray& PathConstraintData::getBones() { return _bones; } @@ -162,11 +162,4 @@ namespace Spine { _translateMix = inValue; } - - std::ostream& operator <<(std::ostream& os, const PathConstraintData& ref) - { - os << ref._name; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/RotateTimeline.cpp b/spine-cpp/spine-cpp/src/spine/RotateTimeline.cpp index 87bdef551..6d2302612 100644 --- a/spine-cpp/spine-cpp/src/spine/RotateTimeline.cpp +++ b/spine-cpp/spine-cpp/src/spine/RotateTimeline.cpp @@ -43,7 +43,7 @@ namespace Spine _frames.reserve(frameCount << 1); } - void RotateTimeline::apply(Skeleton& skeleton, float lastTime, float time, std::vector& events, float alpha, MixPose pose, MixDirection direction) + void RotateTimeline::apply(Skeleton& skeleton, float lastTime, float time, SimpleArray& events, float alpha, MixPose pose, MixDirection direction) { Bone* bone = skeleton.getBones().at(_boneIndex); @@ -127,12 +127,12 @@ namespace Spine _boneIndex = inValue; } - std::vector& RotateTimeline::getFrames() + SimpleArray& RotateTimeline::getFrames() { return _frames; } - void RotateTimeline::setFrames(std::vector inValue) + void RotateTimeline::setFrames(SimpleArray inValue) { _frames = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/Skin.cpp b/spine-cpp/spine-cpp/src/spine/Skin.cpp index c4e9ab0d5..d0a8c2663 100644 --- a/spine-cpp/spine-cpp/src/spine/Skin.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skin.cpp @@ -65,36 +65,36 @@ namespace Spine Attachment* Skin::getAttachment(int slotIndex, std::string name) { - std::unordered_map::iterator q = _attachments.find(AttachmentKey(slotIndex, name)); + HashMap::Iterator i = _attachments.find(AttachmentKey(slotIndex, name)); Attachment* ret = nullptr; - if (q != _attachments.end()) + if (i != _attachments.end()) { - ret = q->second; + ret = i.second(); } return ret; } - void Skin::findNamesForSlot(int slotIndex, std::vector& names) + void Skin::findNamesForSlot(int slotIndex, SimpleArray& names) { - for (std::unordered_map::iterator i = _attachments.begin(); i != _attachments.end(); ++i) + for (HashMap::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) { - if (i->first._slotIndex == slotIndex) + if (i.first()._slotIndex == slotIndex) { - names.push_back(i->first._name); + names.push_back(i.first()._name); } } } - void Skin::findAttachmentsForSlot(int slotIndex, std::vector& attachments) + void Skin::findAttachmentsForSlot(int slotIndex, SimpleArray& attachments) { - for (std::unordered_map::iterator i = _attachments.begin(); i != _attachments.end(); ++i) + for (HashMap::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) { - if (i->first._slotIndex == slotIndex) + if (i.first()._slotIndex == slotIndex) { - attachments.push_back(i->second); + attachments.push_back(i.second()); } } } @@ -104,33 +104,26 @@ namespace Spine return _name; } - std::unordered_map& Skin::getAttachments() + HashMap& Skin::getAttachments() { return _attachments; } void Skin::attachAll(Skeleton& skeleton, Skin& oldSkin) { - for (std::unordered_map::iterator i = oldSkin.getAttachments().begin(); i != oldSkin.getAttachments().end(); ++i) + for (HashMap::Iterator i = oldSkin.getAttachments().begin(); i != oldSkin.getAttachments().end(); ++i) { - int slotIndex = i->first._slotIndex; + int slotIndex = i.first()._slotIndex; Slot* slot = skeleton.getSlots().at(slotIndex); - if (slot->getAttachment() == i->second) + if (slot->getAttachment() == i.second()) { Attachment* attachment = nullptr; - if ((attachment = getAttachment(slotIndex, i->first._name))) + if ((attachment = getAttachment(slotIndex, i.first()._name))) { slot->setAttachment(attachment); } } } } - - std::ostream& operator <<(std::ostream& os, const Skin& ref) - { - os << ref._name; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/Slot.cpp b/spine-cpp/spine-cpp/src/spine/Slot.cpp index 5e0af36aa..6b587cd5d 100644 --- a/spine-cpp/spine-cpp/src/spine/Slot.cpp +++ b/spine-cpp/spine-cpp/src/spine/Slot.cpp @@ -196,20 +196,13 @@ namespace Spine _attachmentTime = _skeleton.getTime() - inValue; } - std::vector& Slot::getAttachmentVertices() + SimpleArray& Slot::getAttachmentVertices() { return _attachmentVertices; } - void Slot::setAttachmentVertices(std::vector inValue) + void Slot::setAttachmentVertices(SimpleArray inValue) { _attachmentVertices = inValue; } - - std::ostream& operator <<(std::ostream& os, const Slot& ref) - { - os << ref._slotData.getName(); - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/SlotData.cpp b/spine-cpp/spine-cpp/src/spine/SlotData.cpp index a8bf97ff7..01eb96540 100644 --- a/spine-cpp/spine-cpp/src/spine/SlotData.cpp +++ b/spine-cpp/spine-cpp/src/spine/SlotData.cpp @@ -167,11 +167,4 @@ namespace Spine { _blendMode = inValue; } - - std::ostream& operator <<(std::ostream& os, const SlotData& ref) - { - os << ref._name; - - return os; - } } diff --git a/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp index 7d099b4e7..b3d0006fd 100644 --- a/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp +++ b/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp @@ -65,7 +65,7 @@ namespace Spine { return _order; } - std::vector& TransformConstraintData::getBones() + SimpleArray& TransformConstraintData::getBones() { return _bones; } @@ -134,11 +134,4 @@ namespace Spine { return _local; } - - std::ostream& operator <<(std::ostream& os, const TransformConstraintData& ref) - { - os << ref._name; - - return os; - } }