This commit is contained in:
Stephen Gowen 2017-10-21 11:34:38 -04:00
parent 7b585cde41
commit 9129d64100
26 changed files with 485 additions and 103 deletions

View File

@ -33,7 +33,7 @@
#include <spine/Updatable.h>
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
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<Bone*>& getChildren();
Vector<Bone*>& getChildren();
/// The local X translation.
float getX();
@ -169,7 +169,7 @@ namespace Spine
BoneData& _data;
Skeleton& _skeleton;
Bone* _parent;
SimpleArray<Bone*> _children;
Vector<Bone*> _children;
float _x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY;
float _ax, _ay, _arotation, _ascaleX, _ascaleY, _ashearX, _ashearY;
bool _appliedValid;

View File

@ -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();

View File

@ -31,7 +31,7 @@
#ifndef Spine_Attachment_h
#define Spine_Attachment_h
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <spine/HashMap.h>
namespace Spine
@ -40,7 +40,7 @@ namespace Spine
{
public:
template<typename T>
static void cleanUpSimpleArrayOfPointers(SimpleArray<T*>& items)
static void cleanUpVectorOfPointers(Vector<T*>& items)
{
for (size_t i = 0; i < items.size(); )
{

View File

@ -32,7 +32,7 @@
#define Spine_CurveTimeline_h
#include <spine/Timeline.h>
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <assert.h>
@ -44,7 +44,7 @@ namespace Spine
public:
CurveTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, SimpleArray<Event*>& events, float alpha, MixPose pose, MixDirection direction) = 0;
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& 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<float> _curves; // type, x, y, ...
Vector<float> _curves; // type, x, y, ...
};
}

View File

@ -31,7 +31,7 @@
#ifndef Spine_IkConstraintData_h
#define Spine_IkConstraintData_h
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <string>
@ -51,7 +51,7 @@ namespace Spine
void setOrder(int inValue);
/// The bones that are constrained by this IK Constraint.
SimpleArray<BoneData*>& getBones();
Vector<BoneData*>& getBones();
/// The bone that is the IK target.
BoneData* getTarget();
@ -67,7 +67,7 @@ namespace Spine
private:
const std::string _name;
int _order;
SimpleArray<BoneData*> _bones;
Vector<BoneData*> _bones;
BoneData* _target;
int _bendDirection;
float _mix;

View File

@ -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,

View File

@ -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).

View File

@ -34,7 +34,7 @@
#include <spine/PositionMode.h>
#include <spine/SpacingMode.h>
#include <spine/RotateMode.h>
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <string>
@ -53,7 +53,7 @@ namespace Spine
int getOrder();
void setOrder(int inValue);
SimpleArray<BoneData*>& getBones();
Vector<BoneData*>& getBones();
SlotData* getTarget();
void setTarget(SlotData* inValue);
@ -85,7 +85,7 @@ namespace Spine
private:
const std::string _name;
int _order;
SimpleArray<BoneData*> _bones;
Vector<BoneData*> _bones;
SlotData* _target;
PositionMode _positionMode;
SpacingMode _spacingMode;

View File

@ -42,7 +42,7 @@ namespace Spine
RotateTimeline(int frameCount);
virtual void apply(Skeleton& skeleton, float lastTime, float time, SimpleArray<Event*>& events, float alpha, MixPose pose, MixDirection direction);
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction);
virtual int getPropertyId();
@ -52,8 +52,8 @@ namespace Spine
int getBoneIndex();
void setBoneIndex(int inValue);
SimpleArray<float>& getFrames();
void setFrames(SimpleArray<float> inValue);
Vector<float>& getFrames();
void setFrames(Vector<float> inValue);
private:
static const int PREV_TIME = -2;
@ -61,7 +61,7 @@ namespace Spine
static const int ROTATION = 1;
int _boneIndex;
SimpleArray<float> _frames; // time, angle, ...
Vector<float> _frames; // time, angle, ...
};
}

View File

@ -31,7 +31,7 @@
#ifndef Spine_Skeleton_h
#define Spine_Skeleton_h
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <spine/MathUtil.h>
#include <string>
@ -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<float>& 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<float>& outVertexBuffer);
Bone* getRootBone();
const SkeletonData& getData();
SimpleArray<Bone*>& getBones();
SimpleArray<Updatable*>& getUpdateCacheList();
SimpleArray<Slot*>& getSlots();
SimpleArray<Slot*>& getDrawOrder();
SimpleArray<IkConstraint*>& getIkConstraints();
SimpleArray<PathConstraint*>& getPathConstraints();
SimpleArray<TransformConstraint*>& getTransformConstraints();
Vector<Bone*>& getBones();
Vector<Updatable*>& getUpdateCacheList();
Vector<Slot*>& getSlots();
Vector<Slot*>& getDrawOrder();
Vector<IkConstraint*>& getIkConstraints();
Vector<PathConstraint*>& getPathConstraints();
Vector<TransformConstraint*>& getTransformConstraints();
Skin* getSkin();
void setSkin(Skin* inValue);
@ -156,14 +156,14 @@ namespace Spine
private:
const SkeletonData& _data;
SimpleArray<Bone*> _bones;
SimpleArray<Slot*> _slots;
SimpleArray<Slot*> _drawOrder;
SimpleArray<IkConstraint*> _ikConstraints;
SimpleArray<TransformConstraint*> _transformConstraints;
SimpleArray<PathConstraint*> _pathConstraints;
SimpleArray<Updatable*> _updateCache;
SimpleArray<Bone*> _updateCacheReset;
Vector<Bone*> _bones;
Vector<Slot*> _slots;
Vector<Slot*> _drawOrder;
Vector<IkConstraint*> _ikConstraints;
Vector<TransformConstraint*> _transformConstraints;
Vector<PathConstraint*> _pathConstraints;
Vector<Updatable*> _updateCache;
Vector<Bone*> _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<Bone*>& bones);
static void sortReset(Vector<Bone*>& bones);
};
}

View File

@ -31,9 +31,128 @@
#ifndef Spine_SkeletonData_h
#define Spine_SkeletonData_h
#include <spine/Vector.h>
#include <string>
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<BoneData*>& getBones();
Vector<SlotData*>& getSlots();
/// All skins, including the default skin.
Vector<Skin*>& getSkins();
void setSkins(Vector<Skin*>& 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<EventData*>& getEvents();
void setEvents(Vector<EventData*>& inValue);
Vector<Animation*>& getAnimations();
void setAnimations(Vector<Animation*>& inValue);
Vector<IkConstraintData*>& getIkConstraints();
void setIkConstraints(Vector<IkConstraintData*>& inValue);
Vector<TransformConstraintData*>& getTransformConstraints();
void setTransformConstraints(Vector<TransformConstraintData*>& inValue);
Vector<PathConstraintData*>& getPathConstraints();
void setPathConstraints(Vector<PathConstraintData*>& 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<BoneData*> _bones; // Ordered parents first
Vector<SlotData*> _slots; // Setup pose draw order.
Vector<Skin*> _skins;
Skin* _defaultSkin;
Vector<EventData*> _events;
Vector<Animation*> _animations;
Vector<IkConstraintData*> _ikConstraints;
Vector<TransformConstraintData*> _transformConstraints;
Vector<PathConstraintData*> _pathConstraints;
float _width, _height;
std::string _version;
std::string _hash;
// Nonessential.
float _fps;
std::string _imagesPath;
};
}
#endif /* Spine_SkeletonData_h */

View File

@ -33,7 +33,7 @@
#include <string>
#include <spine/HashMap.h>
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
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<std::string>& names);
void findNamesForSlot(int slotIndex, Vector<std::string>& 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<Attachment*>& attachments);
void findAttachmentsForSlot(int slotIndex, Vector<Attachment*>& attachments);
const std::string& getName();
HashMap<AttachmentKey, Attachment*, HashAttachmentKey>& getAttachments();

View File

@ -31,7 +31,7 @@
#ifndef Spine_Slot_h
#define Spine_Slot_h
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <string>
@ -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<float>& getAttachmentVertices();
void setAttachmentVertices(SimpleArray<float> inValue);
Vector<float>& getAttachmentVertices();
void setAttachmentVertices(Vector<float> inValue);
private:
const SlotData& _slotData;
@ -90,7 +90,7 @@ namespace Spine
bool _hasSecondColor;
Attachment* _attachment;
float _attachmentTime;
SimpleArray<float> _attachmentVertices;
Vector<float> _attachmentVertices;
};
}

View File

@ -31,7 +31,7 @@
#ifndef Spine_Timeline_h
#define Spine_Timeline_h
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <spine/MixPose.h>
#include <spine/MixDirection.h>
@ -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<Event*>& events, float alpha, MixPose pose, MixDirection direction) = 0;
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction) = 0;
virtual int getPropertyId() = 0;
};

View File

@ -31,7 +31,7 @@
#ifndef Spine_TransformConstraintData_h
#define Spine_TransformConstraintData_h
#include <spine/SimpleArray.h>
#include <spine/Vector.h>
#include <string>
@ -46,7 +46,7 @@ namespace Spine
const std::string& getName();
int getOrder();
SimpleArray<BoneData*>& getBones();
Vector<BoneData*>& getBones();
BoneData* getTarget();
float getRotateMix();
float getTranslateMix();
@ -66,7 +66,7 @@ namespace Spine
private:
const std::string _name;
int _order;
SimpleArray<BoneData*> _bones;
Vector<BoneData*> _bones;
BoneData* _target;
float _rotateMix, _translateMix, _scaleMix, _shearMix;
float _offsetRotation, _offsetX, _offsetY, _offsetScaleX, _offsetScaleY, _offsetShearY;

View File

@ -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 <memory>
#include <assert.h>
@ -37,19 +37,19 @@
namespace Spine
{
template <typename T>
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 */

View File

@ -369,7 +369,7 @@ namespace Spine
return _parent;
}
SimpleArray<Bone*>& Bone::getChildren()
Vector<Bone*>& Bone::getChildren()
{
return _children;
}

View File

@ -57,7 +57,7 @@ namespace Spine
_order = inValue;
}
SimpleArray<BoneData*>& IkConstraintData::getBones()
Vector<BoneData*>& IkConstraintData::getBones()
{
return _bones;
}

View File

@ -68,7 +68,7 @@ namespace Spine
_order = inValue;
}
SimpleArray<BoneData*>& PathConstraintData::getBones()
Vector<BoneData*>& PathConstraintData::getBones()
{
return _bones;
}

View File

@ -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
}

View File

@ -43,7 +43,7 @@ namespace Spine
_frames.reserve(frameCount << 1);
}
void RotateTimeline::apply(Skeleton& skeleton, float lastTime, float time, SimpleArray<Event*>& events, float alpha, MixPose pose, MixDirection direction)
void RotateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>& events, float alpha, MixPose pose, MixDirection direction)
{
Bone* bone = skeleton.getBones().at(_boneIndex);
@ -127,12 +127,12 @@ namespace Spine
_boneIndex = inValue;
}
SimpleArray<float>& RotateTimeline::getFrames()
Vector<float>& RotateTimeline::getFrames()
{
return _frames;
}
void RotateTimeline::setFrames(SimpleArray<float> inValue)
void RotateTimeline::setFrames(Vector<float> inValue)
{
_frames = inValue;
}

View File

@ -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<IkConstraint>(data.ikConstraints.Count);
ikConstraints = new Vector<IkConstraint>(data.ikConstraints.Count);
foreach (IkConstraintData ikConstraintData in data.ikConstraints)
{
ikConstraints.Add(new IkConstraint(ikConstraintData, this));
}
transformConstraints = new SimpleArray<TransformConstraint>(data.transformConstraints.Count);
transformConstraints = new Vector<TransformConstraint>(data.transformConstraints.Count);
foreach (TransformConstraintData transformConstraintData in data.transformConstraints)
{
transformConstraints.Add(new TransformConstraint(transformConstraintData, this));
}
pathConstraints = new SimpleArray<PathConstraint> (data.pathConstraints.Count);
pathConstraints = new Vector<PathConstraint> (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<IUpdatable> updateCache = _updateCache;
Vector<IUpdatable> updateCache = _updateCache;
updateCache.Clear();
_updateCacheReset.Clear();
SimpleArray<Bone> bones = _bones;
Vector<Bone> bones = _bones;
for (int i = 0, n = bones.Count; i < n; ++i)
{
bones.Items[i].sorted = false;
}
SimpleArray<IkConstraint> ikConstraints = _ikConstraints;
Vector<IkConstraint> 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<Slot> slots = _slots;
Vector<Slot> 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<Slot> slots = _slots;
Vector<Slot> 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<IkConstraint> ikConstraints = _ikConstraints;
Vector<IkConstraint> 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<TransformConstraint> transformConstraints = _transformConstraints;
Vector<TransformConstraint> 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<PathConstraint> pathConstraints = _pathConstraints;
Vector<PathConstraint> 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<float>& outVertexBuffer)
void Skeleton::getBounds(float& outX, float& outY, float& outWidth, float& outHeight, Vector<float>& outVertexBuffer)
{
float minX = std::numeric_limits<float>::max();
float minY = std::numeric_limits<float>::max();
@ -527,37 +527,37 @@ namespace Spine
return _data;
}
SimpleArray<Bone*>& Skeleton::getBones()
Vector<Bone*>& Skeleton::getBones()
{
return _bones;
}
SimpleArray<Updatable*>& Skeleton::getUpdateCacheList()
Vector<Updatable*>& Skeleton::getUpdateCacheList()
{
return _updateCache;
}
SimpleArray<Slot*>& Skeleton::getSlots()
Vector<Slot*>& Skeleton::getSlots()
{
return _slots;
}
SimpleArray<Slot*>& Skeleton::getDrawOrder()
Vector<Slot*>& Skeleton::getDrawOrder()
{
return _drawOrder;
}
SimpleArray<IkConstraint*>& Skeleton::getIkConstraints()
Vector<IkConstraint*>& Skeleton::getIkConstraints()
{
return _ikConstraints;
}
SimpleArray<PathConstraint*>& Skeleton::getPathConstraints()
Vector<PathConstraint*>& Skeleton::getPathConstraints()
{
return _pathConstraints;
}
SimpleArray<TransformConstraint*>& Skeleton::getTransformConstraints()
Vector<TransformConstraint*>& Skeleton::getTransformConstraints()
{
return _transformConstraints;
}
@ -826,7 +826,7 @@ namespace Spine
updateCache.Add(bone);
}
void Skeleton::sortReset(SimpleArray<Bone*>& bones)
void Skeleton::sortReset(Vector<Bone*>& bones)
{
for (Bone* i = bones.begin(); i != bones.end(); ++i)
{

View File

@ -28,7 +28,270 @@
* POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
#include <spine/SkeletonData.h>
#include <spine/BoneData.h>
#include <spine/SlotData.h>
#include <spine/Skin.h>
#include <spine/EventData.h>
#include <spine/Animation.h>
#include <spine/IkConstraintData.h>
#include <spine/TransformConstraintData.h>
#include <spine/PathConstraintData.h>
#include <assert.h>
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<SlotData> 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<SlotData> 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<Animation*> 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<IkConstraintData> 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<TransformConstraintData> 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<PathConstraintData> 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<PathConstraintData> 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<BoneData*>& SkeletonData::getBones() { return _bones; }
Vector<SlotData*>& SkeletonData::getSlots() { return _slots; }
Vector<Skin*>& SkeletonData::getSkins() { return _skins; }
void SkeletonData::setSkins(Vector<Skin*>& inValue) { _skins = inValue; }
Skin* SkeletonData::getDefaultSkin() { return _defaultSkin; }
void SkeletonData::setDefaultSkin(Skin* inValue) { _defaultSkin = inValue; }
Vector<EventData*>& SkeletonData::getEvents() { return _events; }
void SkeletonData::setEvents(Vector<EventData*>& inValue) { _events = inValue; }
Vector<Animation*>& SkeletonData::getAnimations() { return _animations; }
void SkeletonData::setAnimations(Vector<Animation*>& inValue) { _animations = inValue; }
Vector<IkConstraintData*>& SkeletonData::getIkConstraints() { return _ikConstraints; }
void SkeletonData::setIkConstraints(Vector<IkConstraintData*>& inValue) { _ikConstraints = inValue; }
Vector<TransformConstraintData*>& SkeletonData::getTransformConstraints() { return _transformConstraints; }
void SkeletonData::setTransformConstraints(Vector<TransformConstraintData*>& inValue) { _transformConstraints = inValue; }
Vector<PathConstraintData*>& SkeletonData::getPathConstraints() { return _pathConstraints; }
void SkeletonData::setPathConstraints(Vector<PathConstraintData*>& 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; }
}

View File

@ -77,7 +77,7 @@ namespace Spine
return ret;
}
void Skin::findNamesForSlot(int slotIndex, SimpleArray<std::string>& names)
void Skin::findNamesForSlot(int slotIndex, Vector<std::string>& names)
{
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin(); i != _attachments.end(); ++i)
{
@ -88,7 +88,7 @@ namespace Spine
}
}
void Skin::findAttachmentsForSlot(int slotIndex, SimpleArray<Attachment*>& attachments)
void Skin::findAttachmentsForSlot(int slotIndex, Vector<Attachment*>& attachments)
{
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin(); i != _attachments.end(); ++i)
{

View File

@ -196,12 +196,12 @@ namespace Spine
_attachmentTime = _skeleton.getTime() - inValue;
}
SimpleArray<float>& Slot::getAttachmentVertices()
Vector<float>& Slot::getAttachmentVertices()
{
return _attachmentVertices;
}
void Slot::setAttachmentVertices(SimpleArray<float> inValue)
void Slot::setAttachmentVertices(Vector<float> inValue)
{
_attachmentVertices = inValue;
}

View File

@ -65,7 +65,7 @@ namespace Spine
{
return _order;
}
SimpleArray<BoneData*>& TransformConstraintData::getBones()
Vector<BoneData*>& TransformConstraintData::getBones()
{
return _bones;
}