diff --git a/spine-cpp/spine-cpp/include/spine/Bone.h b/spine-cpp/spine-cpp/include/spine/Bone.h index 1657b74a9..e189750b2 100644 --- a/spine-cpp/spine-cpp/include/spine/Bone.h +++ b/spine-cpp/spine-cpp/include/spine/Bone.h @@ -33,7 +33,7 @@ #include -#include +#include namespace Spine { @@ -54,7 +54,7 @@ namespace Spine static bool isYDown(); - /// @param parent May be null. + /// @param parent May be NULL. Bone(BoneData& data, Skeleton& skeleton, Bone* parent); /// Same as updateWorldTransform. This method exists for Bone to implement Spine::Updatable. @@ -89,7 +89,7 @@ namespace Spine BoneData& getData(); Skeleton& getSkeleton(); Bone* getParent(); - SimpleArray& getChildren(); + Vector& getChildren(); /// The local X translation. float getX(); @@ -169,7 +169,7 @@ namespace Spine BoneData& _data; Skeleton& _skeleton; Bone* _parent; - SimpleArray _children; + Vector _children; float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY; float _ax, _ay, _arotation, _ascaleX, _ascaleY, _ashearX, _ashearY; bool _appliedValid; diff --git a/spine-cpp/spine-cpp/include/spine/BoneData.h b/spine-cpp/spine-cpp/include/spine/BoneData.h index ef81b1e62..292f4a4c4 100644 --- a/spine-cpp/spine-cpp/include/spine/BoneData.h +++ b/spine-cpp/spine-cpp/include/spine/BoneData.h @@ -48,7 +48,7 @@ namespace Spine /// The name of the bone, which is unique within the skeleton. const std::string& getName(); - /// May be null. + /// May be NULL. const BoneData* getParent(); float getLength(); diff --git a/spine-cpp/spine-cpp/include/spine/ContainerUtil.h b/spine-cpp/spine-cpp/include/spine/ContainerUtil.h index 33156e7ef..ecc52e168 100644 --- a/spine-cpp/spine-cpp/include/spine/ContainerUtil.h +++ b/spine-cpp/spine-cpp/include/spine/ContainerUtil.h @@ -31,7 +31,7 @@ #ifndef Spine_Attachment_h #define Spine_Attachment_h -#include +#include #include namespace Spine @@ -40,7 +40,7 @@ namespace Spine { public: template - static void cleanUpSimpleArrayOfPointers(SimpleArray& items) + static void cleanUpVectorOfPointers(Vector& items) { for (size_t i = 0; i < items.size(); ) { diff --git a/spine-cpp/spine-cpp/include/spine/CurveTimeline.h b/spine-cpp/spine-cpp/include/spine/CurveTimeline.h index 24b3ad527..ccf3b1f86 100644 --- a/spine-cpp/spine-cpp/include/spine/CurveTimeline.h +++ b/spine-cpp/spine-cpp/include/spine/CurveTimeline.h @@ -32,7 +32,7 @@ #define Spine_CurveTimeline_h #include -#include +#include #include @@ -44,7 +44,7 @@ namespace Spine public: CurveTimeline(int frameCount); - virtual void apply(Skeleton& skeleton, float lastTime, float time, SimpleArray& events, float alpha, MixPose pose, MixDirection direction) = 0; + virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector& events, float alpha, MixPose pose, MixDirection direction) = 0; virtual int getPropertyId() = 0; @@ -70,7 +70,7 @@ namespace Spine static const int BEZIER_SIZE; private: - SimpleArray _curves; // type, x, y, ... + Vector _curves; // type, x, y, ... }; } diff --git a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h index 0e54049a0..4f231f711 100644 --- a/spine-cpp/spine-cpp/include/spine/IkConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/IkConstraintData.h @@ -31,7 +31,7 @@ #ifndef Spine_IkConstraintData_h #define Spine_IkConstraintData_h -#include +#include #include @@ -51,7 +51,7 @@ namespace Spine void setOrder(int inValue); /// The bones that are constrained by this IK Constraint. - SimpleArray& getBones(); + Vector& getBones(); /// The bone that is the IK target. BoneData* getTarget(); @@ -67,7 +67,7 @@ namespace Spine private: const std::string _name; int _order; - SimpleArray _bones; + Vector _bones; BoneData* _target; int _bendDirection; float _mix; diff --git a/spine-cpp/spine-cpp/include/spine/MixDirection.h b/spine-cpp/spine-cpp/include/spine/MixDirection.h index 1400e1b3a..ab14a3823 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, SimpleArray&, float, MixPose, MixDirection) + /// See also Timeline::apply(Skeleton&, float, float, Vector&, 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 487165890..f95fce969 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, SimpleArray&, float, MixPose, MixDirection) + /// See also Timeline::apply(Skeleton&, float, float, Vector&, 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 63c5ddcc6..4acdf4513 100644 --- a/spine-cpp/spine-cpp/include/spine/PathConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/PathConstraintData.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include @@ -53,7 +53,7 @@ namespace Spine int getOrder(); void setOrder(int inValue); - SimpleArray& getBones(); + Vector& getBones(); SlotData* getTarget(); void setTarget(SlotData* inValue); @@ -85,7 +85,7 @@ namespace Spine private: const std::string _name; int _order; - SimpleArray _bones; + Vector _bones; SlotData* _target; PositionMode _positionMode; SpacingMode _spacingMode; diff --git a/spine-cpp/spine-cpp/include/spine/RotateTimeline.h b/spine-cpp/spine-cpp/include/spine/RotateTimeline.h index 41547f417..9b2ff0403 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, SimpleArray& events, float alpha, MixPose pose, MixDirection direction); + virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector& events, float alpha, MixPose pose, MixDirection direction); virtual int getPropertyId(); @@ -52,8 +52,8 @@ namespace Spine int getBoneIndex(); void setBoneIndex(int inValue); - SimpleArray& getFrames(); - void setFrames(SimpleArray inValue); + Vector& getFrames(); + void setFrames(Vector inValue); private: static const int PREV_TIME = -2; @@ -61,7 +61,7 @@ namespace Spine static const int ROTATION = 1; int _boneIndex; - SimpleArray _frames; // time, angle, ... + Vector _frames; // time, angle, ... }; } diff --git a/spine-cpp/spine-cpp/include/spine/Skeleton.h b/spine-cpp/spine-cpp/include/spine/Skeleton.h index 07bfd9e3b..cbc6cdfbd 100644 --- a/spine-cpp/spine-cpp/include/spine/Skeleton.h +++ b/spine-cpp/spine-cpp/include/spine/Skeleton.h @@ -31,7 +31,7 @@ #ifndef Spine_Skeleton_h #define Spine_Skeleton_h -#include +#include #include #include @@ -115,23 +115,23 @@ namespace Spine void update(float delta); /// Returns the axis aligned bounding box (AABB) of the region and mesh attachments for the current pose. - /// @param x The horizontal distance between the skeleton origin and the left side of the AABB. - /// @param y The vertical distance between the skeleton origin and the bottom side of the AABB. - /// @param width The width of the AABB - /// @param height The height of the AABB. - /// @param vertexBuffer Reference to hold a SimpleArray of floats. This method will assign it with new floats as needed. - void getBounds(float& outX, float& outY, float& outWidth, float& outHeight, SimpleArray& outVertexBuffer); + /// @param outX The horizontal distance between the skeleton origin and the left side of the AABB. + /// @param outY The vertical distance between the skeleton origin and the bottom side of the AABB. + /// @param outWidth The width of the AABB + /// @param outHeight The height of the AABB. + /// @param outVertexBuffer Reference to hold a Vector of floats. This method will assign it with new floats as needed. + void getBounds(float& outX, float& outY, float& outWidth, float& outHeight, Vector& outVertexBuffer); Bone* getRootBone(); const SkeletonData& getData(); - SimpleArray& getBones(); - SimpleArray& getUpdateCacheList(); - SimpleArray& getSlots(); - SimpleArray& getDrawOrder(); - SimpleArray& getIkConstraints(); - SimpleArray& getPathConstraints(); - SimpleArray& getTransformConstraints(); + Vector& getBones(); + Vector& getUpdateCacheList(); + Vector& getSlots(); + Vector& getDrawOrder(); + Vector& getIkConstraints(); + Vector& getPathConstraints(); + Vector& getTransformConstraints(); Skin* getSkin(); void setSkin(Skin* inValue); @@ -156,14 +156,14 @@ namespace Spine private: const SkeletonData& _data; - SimpleArray _bones; - SimpleArray _slots; - SimpleArray _drawOrder; - SimpleArray _ikConstraints; - SimpleArray _transformConstraints; - SimpleArray _pathConstraints; - SimpleArray _updateCache; - SimpleArray _updateCacheReset; + Vector _bones; + Vector _slots; + Vector _drawOrder; + Vector _ikConstraints; + Vector _transformConstraints; + Vector _pathConstraints; + Vector _updateCache; + Vector _updateCacheReset; Skin* _skin; float _r = 1, _g = 1, _b = 1, _a = 1; float _time; @@ -182,7 +182,7 @@ namespace Spine void sortBone(Bone bone); - static void sortReset(SimpleArray& bones); + static void sortReset(Vector& bones); }; } diff --git a/spine-cpp/spine-cpp/include/spine/SkeletonData.h b/spine-cpp/spine-cpp/include/spine/SkeletonData.h index 37b27397f..4508d537a 100644 --- a/spine-cpp/spine-cpp/include/spine/SkeletonData.h +++ b/spine-cpp/spine-cpp/include/spine/SkeletonData.h @@ -31,9 +31,128 @@ #ifndef Spine_SkeletonData_h #define Spine_SkeletonData_h +#include + +#include + namespace Spine { - // TODO + class BoneData; + class SlotData; + class Skin; + class EventData; + class Animation; + class IkConstraintData; + class TransformConstraintData; + class PathConstraintData; + + /// Stores the setup pose and all of the stateless data for a skeleton. + class SkeletonData + { + public: + SkeletonData(); + + /// Finds a bone by comparing each bone's name. + /// It is more efficient to cache the results of this method than to call it multiple times. + /// @return May be NULL. + BoneData* findBone(std::string boneName); + + /// @return -1 if the bone was not found. + int findBoneIndex(std::string boneName); + + /// @return May be NULL. + SlotData* findSlot(std::string slotName); + + /// @return -1 if the slot was not found. + int findSlotIndex(std::string slotName); + + /// @return May be NULL. + Skin* findSkin(std::string skinName); + + /// @return May be NULL. + EventData* findEvent(std::string eventDataName); + + /// @return May be NULL. + Animation* findAnimation(std::string animationName); + + /// @return May be NULL. + IkConstraintData* findIkConstraint(std::string constraintName); + + /// @return May be NULL. + TransformConstraintData* findTransformConstraint(std::string constraintName); + + /// @return May be NULL. + PathConstraintData* findPathConstraint(std::string constraintName); + + /// @return -1 if the path constraint was not found. + int findPathConstraintIndex(std::string pathConstraintName); + + std::string getName(); + void setName(std::string inValue); + + /// The skeleton's bones, sorted parent first. The root bone is always the first bone. + Vector& getBones(); + + Vector& getSlots(); + + /// All skins, including the default skin. + Vector& getSkins(); + void setSkins(Vector& inValue); + + /// The skeleton's default skin. + /// By default this skin contains all attachments that were not in a skin in Spine. + /// + /// @return May be NULL. + Skin* getDefaultSkin(); + void setDefaultSkin(Skin* inValue); + + Vector& getEvents(); + void setEvents(Vector& inValue); + Vector& getAnimations(); + void setAnimations(Vector& inValue); + Vector& getIkConstraints(); + void setIkConstraints(Vector& inValue); + Vector& getTransformConstraints(); + void setTransformConstraints(Vector& inValue); + Vector& getPathConstraints(); + void setPathConstraints(Vector& inValue); + + float getWidth(); + void setWidth(float inValue); + float getHeight(); + void setHeight(float inValue); + + /// The Spine version used to export this data, or NULL. + std::string getVersion(); + void setVersion(std::string inValue); + std::string getHash(); + void setHash(std::string inValue); + std::string getImagesPath(); + void setImagesPath(std::string inValue); + + /// The dopesheet FPS in Spine. Available only when nonessential data was exported. + float getFps(); + void setFps(float inValue); + + private: + std::string _name; + Vector _bones; // Ordered parents first + Vector _slots; // Setup pose draw order. + Vector _skins; + Skin* _defaultSkin; + Vector _events; + Vector _animations; + Vector _ikConstraints; + Vector _transformConstraints; + Vector _pathConstraints; + float _width, _height; + std::string _version; + std::string _hash; + + // Nonessential. + float _fps; + std::string _imagesPath; + }; } #endif /* Spine_SkeletonData_h */ diff --git a/spine-cpp/spine-cpp/include/spine/Skin.h b/spine-cpp/spine-cpp/include/spine/Skin.h index b0f858f39..b6f36dd9c 100644 --- a/spine-cpp/spine-cpp/include/spine/Skin.h +++ b/spine-cpp/spine-cpp/include/spine/Skin.h @@ -33,7 +33,7 @@ #include #include -#include +#include struct HashAttachmentKey; @@ -65,18 +65,18 @@ namespace Spine /// If the name already exists for the slot, the previous value is replaced. void addAttachment(int slotIndex, std::string name, Attachment* attachment); - /// Returns the attachment for the specified slot index and name, or null. + /// 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 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 array. - void findNamesForSlot(int slotIndex, SimpleArray& names); + void findNamesForSlot(int slotIndex, Vector& names); /// 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 array. - void findAttachmentsForSlot(int slotIndex, SimpleArray& attachments); + void findAttachmentsForSlot(int slotIndex, Vector& attachments); const std::string& getName(); HashMap& getAttachments(); diff --git a/spine-cpp/spine-cpp/include/spine/Slot.h b/spine-cpp/spine-cpp/include/spine/Slot.h index 2f2ae4bc4..767373056 100644 --- a/spine-cpp/spine-cpp/include/spine/Slot.h +++ b/spine-cpp/spine-cpp/include/spine/Slot.h @@ -31,7 +31,7 @@ #ifndef Spine_Slot_h #define Spine_Slot_h -#include +#include #include @@ -71,15 +71,15 @@ namespace Spine bool hasSecondColor(); void setHasSecondColor(bool inValue); - /// May be null. + /// May be NULL. Attachment* getAttachment(); void setAttachment(Attachment* inValue); float getAttachmentTime(); void setAttachmentTime(float inValue); - SimpleArray& getAttachmentVertices(); - void setAttachmentVertices(SimpleArray inValue); + Vector& getAttachmentVertices(); + void setAttachmentVertices(Vector inValue); private: const SlotData& _slotData; @@ -90,7 +90,7 @@ namespace Spine bool _hasSecondColor; Attachment* _attachment; float _attachmentTime; - SimpleArray _attachmentVertices; + Vector _attachmentVertices; }; } diff --git a/spine-cpp/spine-cpp/include/spine/Timeline.h b/spine-cpp/spine-cpp/include/spine/Timeline.h index f74944694..056ba8d39 100644 --- a/spine-cpp/spine-cpp/include/spine/Timeline.h +++ b/spine-cpp/spine-cpp/include/spine/Timeline.h @@ -31,7 +31,7 @@ #ifndef Spine_Timeline_h #define Spine_Timeline_h -#include +#include #include #include @@ -51,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 array. 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, SimpleArray& events, float alpha, MixPose pose, MixDirection direction) = 0; + virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector& 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 bd4f9bd1b..eb978ad6c 100644 --- a/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h +++ b/spine-cpp/spine-cpp/include/spine/TransformConstraintData.h @@ -31,7 +31,7 @@ #ifndef Spine_TransformConstraintData_h #define Spine_TransformConstraintData_h -#include +#include #include @@ -46,7 +46,7 @@ namespace Spine const std::string& getName(); int getOrder(); - SimpleArray& getBones(); + Vector& getBones(); BoneData* getTarget(); float getRotateMix(); float getTranslateMix(); @@ -66,7 +66,7 @@ namespace Spine private: const std::string _name; int _order; - SimpleArray _bones; + Vector _bones; BoneData* _target; float _rotateMix, _translateMix, _scaleMix, _shearMix; float _offsetRotation, _offsetX, _offsetY, _offsetScaleX, _offsetScaleY, _offsetShearY; diff --git a/spine-cpp/spine-cpp/include/spine/SimpleArray.h b/spine-cpp/spine-cpp/include/spine/Vector.h similarity index 94% rename from spine-cpp/spine-cpp/include/spine/SimpleArray.h rename to spine-cpp/spine-cpp/include/spine/Vector.h index e544c8104..df2e18e7d 100644 --- a/spine-cpp/spine-cpp/include/spine/SimpleArray.h +++ b/spine-cpp/spine-cpp/include/spine/Vector.h @@ -28,8 +28,8 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef Spine_SimpleArray_h -#define Spine_SimpleArray_h +#ifndef Spine_Vector_h +#define Spine_Vector_h #include #include @@ -37,19 +37,19 @@ namespace Spine { template - class SimpleArray + class Vector { public: - SimpleArray() : _size(0), _capacity(0), _buffer(nullptr) + Vector() : _size(0), _capacity(0), _buffer(NULL) { // Empty } - SimpleArray(const SimpleArray& inArray) + Vector(const Vector& inArray) { _size = inArray._size; _capacity = inArray._capacity; - if (_capacity) + if (_capacity > 0) { _buffer = allocate(_capacity); for (size_t i = 0; i < _size; ++i) @@ -59,7 +59,7 @@ namespace Spine } } - ~SimpleArray() + ~Vector() { clear(); deallocate(_buffer); @@ -184,4 +184,4 @@ namespace Spine }; } -#endif /* Spine_SimpleArray_h */ +#endif /* Spine_Vector_h */ diff --git a/spine-cpp/spine-cpp/src/spine/Bone.cpp b/spine-cpp/spine-cpp/src/spine/Bone.cpp index 1e3882573..a2dacdbe8 100644 --- a/spine-cpp/spine-cpp/src/spine/Bone.cpp +++ b/spine-cpp/spine-cpp/src/spine/Bone.cpp @@ -369,7 +369,7 @@ namespace Spine return _parent; } - SimpleArray& Bone::getChildren() + Vector& Bone::getChildren() { return _children; } diff --git a/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/IkConstraintData.cpp index 70158d296..4f84d1f83 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; } - SimpleArray& IkConstraintData::getBones() + Vector& IkConstraintData::getBones() { return _bones; } diff --git a/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/PathConstraintData.cpp index 9a82bcbf5..f3ef57df7 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; } - SimpleArray& PathConstraintData::getBones() + Vector& PathConstraintData::getBones() { return _bones; } diff --git a/spine-cpp/spine-cpp/src/spine/RTTI.cpp b/spine-cpp/spine-cpp/src/spine/RTTI.cpp index 3905c9d6b..9d271f894 100644 --- a/spine-cpp/spine-cpp/src/spine/RTTI.cpp +++ b/spine-cpp/spine-cpp/src/spine/RTTI.cpp @@ -32,7 +32,7 @@ namespace Spine { - RTTI::RTTI(const std::string& className) : m_className(className), m_pBaseRTTI(nullptr) + RTTI::RTTI(const std::string& className) : m_className(className), m_pBaseRTTI(NULL) { // Empty } diff --git a/spine-cpp/spine-cpp/src/spine/RotateTimeline.cpp b/spine-cpp/spine-cpp/src/spine/RotateTimeline.cpp index 6d2302612..b77b60858 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, SimpleArray& events, float alpha, MixPose pose, MixDirection direction) + void RotateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector& events, float alpha, MixPose pose, MixDirection direction) { Bone* bone = skeleton.getBones().at(_boneIndex); @@ -127,12 +127,12 @@ namespace Spine _boneIndex = inValue; } - SimpleArray& RotateTimeline::getFrames() + Vector& RotateTimeline::getFrames() { return _frames; } - void RotateTimeline::setFrames(SimpleArray inValue) + void RotateTimeline::setFrames(Vector inValue) { _frames = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp index 0807ea2d0..88eefbd5a 100644 --- a/spine-cpp/spine-cpp/src/spine/Skeleton.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skeleton.cpp @@ -57,7 +57,7 @@ namespace Spine { _bones.reserve(_data.getBones().size()); - foreach (BoneData boneData in data.bones) + foreach (BoneData boneData in _data.getBones()) { Bone bone; if (boneData.parent == NULL) @@ -85,20 +85,20 @@ namespace Spine drawOrder.Add(slot); } - ikConstraints = new SimpleArray(data.ikConstraints.Count); + ikConstraints = new Vector(data.ikConstraints.Count); foreach (IkConstraintData ikConstraintData in data.ikConstraints) { ikConstraints.Add(new IkConstraint(ikConstraintData, this)); } - transformConstraints = new SimpleArray(data.transformConstraints.Count); + transformConstraints = new Vector(data.transformConstraints.Count); foreach (TransformConstraintData transformConstraintData in data.transformConstraints) { transformConstraints.Add(new TransformConstraint(transformConstraintData, this)); } - pathConstraints = new SimpleArray (data.pathConstraints.Count); + pathConstraints = new Vector (data.pathConstraints.Count); foreach (PathConstraintData pathConstraintData in data.pathConstraints) { pathConstraints.Add(new PathConstraint(pathConstraintData, this)); @@ -110,17 +110,17 @@ namespace Spine void Skeleton::updateCache() { - SimpleArray updateCache = _updateCache; + Vector updateCache = _updateCache; updateCache.Clear(); _updateCacheReset.Clear(); - SimpleArray bones = _bones; + Vector bones = _bones; for (int i = 0, n = bones.Count; i < n; ++i) { bones.Items[i].sorted = false; } - SimpleArray ikConstraints = _ikConstraints; + Vector ikConstraints = _ikConstraints; var transformConstraints = _transformConstraints; var pathConstraints = _pathConstraints; int ikCount = IkConstraints.Count, transformCount = transformConstraints.Count, pathCount = pathConstraints.Count; @@ -338,7 +338,7 @@ namespace Spine } else { - SimpleArray slots = _slots; + Vector slots = _slots; for (int i = 0, n = slots.Count; i < n; ++i) { Slot slot = slots.Items[i]; @@ -382,7 +382,7 @@ namespace Spine { assert(slotName.length() > 0); - SimpleArray slots = _slots; + Vector slots = _slots; for (int i = 0, n = slots.Count; i < n; ++i) { Slot slot = slots.Items[i]; @@ -411,7 +411,7 @@ namespace Spine { assert(constraintName.length() > 0); - SimpleArray ikConstraints = _ikConstraints; + Vector ikConstraints = _ikConstraints; for (int i = 0, n = ikConstraints.Count; i < n; ++i) { IkConstraint ikConstraint = ikConstraints.Items[i]; @@ -427,7 +427,7 @@ namespace Spine { assert(constraintName.length() > 0); - SimpleArray transformConstraints = _transformConstraints; + Vector transformConstraints = _transformConstraints; for (int i = 0, n = transformConstraints.Count; i < n; ++i) { TransformConstraint transformConstraint = transformConstraints.Items[i]; @@ -444,7 +444,7 @@ namespace Spine { assert(constraintName.length() > 0); - SimpleArray pathConstraints = _pathConstraints; + Vector pathConstraints = _pathConstraints; for (int i = 0, n = pathConstraints.Count; i < n; ++i) { PathConstraint constraint = pathConstraints.Items[i]; @@ -462,7 +462,7 @@ namespace Spine _time += delta; } - void Skeleton::getBounds(float& outX, float& outY, float& outWidth, float& outHeight, SimpleArray& outVertexBuffer) + void Skeleton::getBounds(float& outX, float& outY, float& outWidth, float& outHeight, Vector& outVertexBuffer) { float minX = std::numeric_limits::max(); float minY = std::numeric_limits::max(); @@ -527,37 +527,37 @@ namespace Spine return _data; } - SimpleArray& Skeleton::getBones() + Vector& Skeleton::getBones() { return _bones; } - SimpleArray& Skeleton::getUpdateCacheList() + Vector& Skeleton::getUpdateCacheList() { return _updateCache; } - SimpleArray& Skeleton::getSlots() + Vector& Skeleton::getSlots() { return _slots; } - SimpleArray& Skeleton::getDrawOrder() + Vector& Skeleton::getDrawOrder() { return _drawOrder; } - SimpleArray& Skeleton::getIkConstraints() + Vector& Skeleton::getIkConstraints() { return _ikConstraints; } - SimpleArray& Skeleton::getPathConstraints() + Vector& Skeleton::getPathConstraints() { return _pathConstraints; } - SimpleArray& Skeleton::getTransformConstraints() + Vector& Skeleton::getTransformConstraints() { return _transformConstraints; } @@ -826,7 +826,7 @@ namespace Spine updateCache.Add(bone); } - void Skeleton::sortReset(SimpleArray& bones) + void Skeleton::sortReset(Vector& bones) { for (Bone* i = bones.begin(); i != bones.end(); ++i) { diff --git a/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp b/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp index bb4d2ccfe..bd5cac04d 100644 --- a/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp +++ b/spine-cpp/spine-cpp/src/spine/SkeletonData.cpp @@ -28,7 +28,270 @@ * POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + namespace Spine { - // TODO + SkeletonData::SkeletonData() : + _defaultSkin(NULL), + _width(0), + _height(0), + _fps(0) + { + // Empty + } + + BoneData* SkeletonData::findBone(std::string boneName) + { + assert(boneName.length() > 0); + + for (BoneData** i = _bones.begin(); i != _bones.end(); ++i) + { + BoneData* boneData = (*i); + if (boneData->getName() == boneName) + { + return boneData; + } + } + + return NULL; + } + + int SkeletonData::findBoneIndex(std::string boneName) + { + assert(boneName.length() > 0); + + var bones = this.bones; + var bonesItems = bones.Items; + for (int i = 0, n = bones.Count; i < n; ++i) + { + if (bonesItems[i].name == boneName) + { + return i; + } + } + + return -1; + } + + /// Use a template findWithName method instead to reduce redundant data container traversal code + SlotData* SkeletonData::findSlot(std::string slotName) + { + assert(slotName.length() > 0); + + Vector slots = this.slots; + for (int i = 0, n = slots.Count; i < n; ++i) + { + SlotData slot = slots.Items[i]; + if (slot.name == slotName) + { + return slot; + } + } + + return NULL; + } + + int SkeletonData::findSlotIndex(std::string slotName) + { + assert(slotName.length() > 0); + + Vector slots = this.slots; + for (int i = 0, n = slots.Count; i < n; ++i) + { + if (slots.Items[i].name == slotName) + { + return i; + } + } + + return -1; + } + + Skin* SkeletonData::findSkin(std::string skinName) + { + assert(skinName.length() > 0); + + foreach (Skin skin in skins) + { + if (skin.name == skinName) + { + return skin; + } + } + + return NULL; + } + + EventData* SkeletonData::findEvent(std::string eventDataName) + { + assert(eventDataName.length() > 0); + + foreach (EventData eventData in events) + { + if (eventData.name == eventDataName) + { + return eventData; + } + } + + return NULL; + } + + Animation* SkeletonData::findAnimation(std::string animationName) + { + assert(animationName.length() > 0); + + Vector animations = this.animations; + for (int i = 0, n = animations.Count; i < n; ++i) + { + Animation animation = animations.Items[i]; + if (animation.name == animationName) + { + return animation; + } + } + + return NULL; + } + + IkConstraintData* SkeletonData::findIkConstraint(std::string constraintName) + { + assert(constraintName.length() > 0); + + Vector ikConstraints = this.ikConstraints; + for (int i = 0, n = ikConstraints.Count; i < n; ++i) + { + IkConstraintData ikConstraint = ikConstraints.Items[i]; + if (ikConstraint.name == constraintName) + { + return ikConstraint; + } + } + + return NULL; + } + + TransformConstraintData* SkeletonData::findTransformConstraint(std::string constraintName) + { + assert(constraintName.length() > 0); + + Vector transformConstraints = this.transformConstraints; + for (int i = 0, n = transformConstraints.Count; i < n; ++i) + { + TransformConstraintData transformConstraint = transformConstraints.Items[i]; + if (transformConstraint.name == constraintName) + { + return transformConstraint; + } + } + + return NULL; + } + + PathConstraintData* SkeletonData::findPathConstraint(std::string constraintName) + { + assert(constraintName.length() > 0); + + Vector pathConstraints = this.pathConstraints; + for (int i = 0, n = pathConstraints.Count; i < n; ++i) + { + PathConstraintData constraint = pathConstraints.Items[i]; + if (constraint.name.Equals(constraintName)) + { + return constraint; + } + } + + return NULL; + } + + int SkeletonData::findPathConstraintIndex(std::string pathConstraintName) + { + assert(pathConstraintName.length() > 0); + + Vector pathConstraints = this.pathConstraints; + for (int i = 0, n = pathConstraints.Count; i < n; ++i) + { + if (pathConstraints.Items[i].name.Equals(pathConstraintName)) + { + return i; + } + } + + return -1; + } + + std::string SkeletonData::getName() { return _name; } + + void SkeletonData::setName(std::string inValue) { _name = inValue; } + + Vector& SkeletonData::getBones() { return _bones; } + + Vector& SkeletonData::getSlots() { return _slots; } + + Vector& SkeletonData::getSkins() { return _skins; } + + void SkeletonData::setSkins(Vector& inValue) { _skins = inValue; } + + Skin* SkeletonData::getDefaultSkin() { return _defaultSkin; } + + void SkeletonData::setDefaultSkin(Skin* inValue) { _defaultSkin = inValue; } + + Vector& SkeletonData::getEvents() { return _events; } + + void SkeletonData::setEvents(Vector& inValue) { _events = inValue; } + + Vector& SkeletonData::getAnimations() { return _animations; } + + void SkeletonData::setAnimations(Vector& inValue) { _animations = inValue; } + + Vector& SkeletonData::getIkConstraints() { return _ikConstraints; } + + void SkeletonData::setIkConstraints(Vector& inValue) { _ikConstraints = inValue; } + + Vector& SkeletonData::getTransformConstraints() { return _transformConstraints; } + + void SkeletonData::setTransformConstraints(Vector& inValue) { _transformConstraints = inValue; } + + Vector& SkeletonData::getPathConstraints() { return _pathConstraints; } + + void SkeletonData::setPathConstraints(Vector& inValue) { _pathConstraints = inValue; } + + float SkeletonData::getWidth() { return _width; } + + void SkeletonData::setWidth(float inValue) { _width = inValue; } + + float SkeletonData::getHeight() { return _height; } + + void SkeletonData::setHeight(float inValue) { _height = inValue; } + + /// The Spine version used to export this data, or NULL. + std::string SkeletonData::getVersion() { return _version; } + + void SkeletonData::setVersion(std::string inValue) { _version = inValue; } + + std::string SkeletonData::getHash() { return _hash; } + + void SkeletonData::setHash(std::string inValue) { _hash = inValue; } + + std::string SkeletonData::getImagesPath() { return _imagesPath; } + + void SkeletonData::setImagesPath(std::string inValue) { _imagesPath = inValue; } + + /// The dopesheet FPS in Spine. Available only when nonessential data was exported. + float SkeletonData::getFps { return _fps; } + + void SkeletonData::setFps(float inValue) { _fps = inValue; } } diff --git a/spine-cpp/spine-cpp/src/spine/Skin.cpp b/spine-cpp/spine-cpp/src/spine/Skin.cpp index 949ac6504..291ded0bf 100644 --- a/spine-cpp/spine-cpp/src/spine/Skin.cpp +++ b/spine-cpp/spine-cpp/src/spine/Skin.cpp @@ -77,7 +77,7 @@ namespace Spine return ret; } - void Skin::findNamesForSlot(int slotIndex, SimpleArray& names) + void Skin::findNamesForSlot(int slotIndex, Vector& names) { for (HashMap::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) { @@ -88,7 +88,7 @@ namespace Spine } } - void Skin::findAttachmentsForSlot(int slotIndex, SimpleArray& attachments) + void Skin::findAttachmentsForSlot(int slotIndex, Vector& attachments) { for (HashMap::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) { diff --git a/spine-cpp/spine-cpp/src/spine/Slot.cpp b/spine-cpp/spine-cpp/src/spine/Slot.cpp index c9ee69fb1..e4bc6b1e7 100644 --- a/spine-cpp/spine-cpp/src/spine/Slot.cpp +++ b/spine-cpp/spine-cpp/src/spine/Slot.cpp @@ -196,12 +196,12 @@ namespace Spine _attachmentTime = _skeleton.getTime() - inValue; } - SimpleArray& Slot::getAttachmentVertices() + Vector& Slot::getAttachmentVertices() { return _attachmentVertices; } - void Slot::setAttachmentVertices(SimpleArray inValue) + void Slot::setAttachmentVertices(Vector inValue) { _attachmentVertices = inValue; } diff --git a/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp b/spine-cpp/spine-cpp/src/spine/TransformConstraintData.cpp index d67e2e1b9..6a9942c32 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; } - SimpleArray& TransformConstraintData::getBones() + Vector& TransformConstraintData::getBones() { return _bones; }