mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Fixed all warnings on MSVC, fixed up usage of int instead of size_t, fixed some signatures.
This commit is contained in:
parent
b7ae63f743
commit
265b18571c
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "KMemory.h" // last include
|
#include "KMemory.h" // last include
|
||||||
|
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// KANJI_DUMP_LEAKED_MEM will print out the memory block that was leaked.
|
// KANJI_DUMP_LEAKED_MEM will print out the memory block that was leaked.
|
||||||
|
|||||||
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "teamcity_messages.h"
|
#include "teamcity_messages.h"
|
||||||
|
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace JetBrains {
|
namespace JetBrains {
|
||||||
|
|||||||
@ -96,7 +96,7 @@
|
|||||||
#define RAD_DEG (180 / PI)
|
#define RAD_DEG (180 / PI)
|
||||||
|
|
||||||
#define ABS(A) ((A) < 0? -(A): (A))
|
#define ABS(A) ((A) < 0? -(A): (A))
|
||||||
#define SIGNUM(A) ((A) < 0? -1: (A) > 0 ? 1 : 0)
|
#define SIGNUM(A) ((A) < 0? -1.0f: (A) > 0 ? 1.0f : 0.0f)
|
||||||
|
|
||||||
#ifdef __STDC_VERSION__
|
#ifdef __STDC_VERSION__
|
||||||
#define FMOD(A,B) fmodf(A, B)
|
#define FMOD(A,B) fmodf(A, B)
|
||||||
|
|||||||
@ -166,7 +166,7 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
|
|||||||
za *= s;
|
za *= s;
|
||||||
zc *= s;
|
zc *= s;
|
||||||
s = SQRT(za * za + zc * zc);
|
s = SQRT(za * za + zc * zc);
|
||||||
r = PI / 2 + atan2(zc, za);
|
r = PI / 2 + ATAN2(zc, za);
|
||||||
zb = COS(r) * s;
|
zb = COS(r) * s;
|
||||||
zd = SIN(r) * s;
|
zd = SIN(r) * s;
|
||||||
la = COS_DEG(shearX) * scaleX;
|
la = COS_DEG(shearX) * scaleX;
|
||||||
|
|||||||
@ -147,7 +147,7 @@ static const char* parse_number (Json *item, const char* num) {
|
|||||||
|
|
||||||
if (ptr != num) {
|
if (ptr != num) {
|
||||||
/* Parse success, number found. */
|
/* Parse success, number found. */
|
||||||
item->valueFloat = result;
|
item->valueFloat = (float)result;
|
||||||
item->valueInt = (int)result;
|
item->valueInt = (int)result;
|
||||||
item->type = Json_Number;
|
item->type = Json_Number;
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|||||||
@ -93,7 +93,7 @@ static float toColor (const char* value, int index) {
|
|||||||
char *error;
|
char *error;
|
||||||
int color;
|
int color;
|
||||||
|
|
||||||
if (index >= strlen(value) / 2)
|
if ((size_t)index >= strlen(value) / 2)
|
||||||
return -1;
|
return -1;
|
||||||
value += index * 2;
|
value += index * 2;
|
||||||
|
|
||||||
|
|||||||
@ -198,7 +198,7 @@ namespace Spine {
|
|||||||
void setMixDuration(float inValue);
|
void setMixDuration(float inValue);
|
||||||
|
|
||||||
|
|
||||||
float getMixBlend();
|
MixBlend getMixBlend();
|
||||||
void setMixBlend(MixBlend blend);
|
void setMixBlend(MixBlend blend);
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -319,10 +319,10 @@ namespace Spine {
|
|||||||
/// Removes all animations from the tracks, leaving skeletons in their previous pose.
|
/// Removes all animations from the tracks, leaving skeletons in their previous pose.
|
||||||
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
|
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
|
||||||
/// rather than leaving them in their previous pose.
|
/// rather than leaving them in their previous pose.
|
||||||
void clearTrack(int trackIndex);
|
void clearTrack(size_t trackIndex);
|
||||||
|
|
||||||
/// Sets an animation by name. setAnimation(int, Animation, bool)
|
/// Sets an animation by name. setAnimation(int, Animation, bool)
|
||||||
TrackEntry* setAnimation(int trackIndex, const String& animationName, bool loop);
|
TrackEntry* setAnimation(size_t trackIndex, const String& animationName, bool loop);
|
||||||
|
|
||||||
/// Sets the current animation for a track, discarding any queued animations.
|
/// Sets the current animation for a track, discarding any queued animations.
|
||||||
/// @param loop If true, the animation will repeat.
|
/// @param loop If true, the animation will repeat.
|
||||||
@ -331,11 +331,11 @@ namespace Spine {
|
|||||||
/// @return
|
/// @return
|
||||||
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||||
/// after AnimationState.Dispose.
|
/// after AnimationState.Dispose.
|
||||||
TrackEntry* setAnimation(int trackIndex, Animation* animation, bool loop);
|
TrackEntry* setAnimation(size_t trackIndex, Animation* animation, bool loop);
|
||||||
|
|
||||||
/// Queues an animation by name.
|
/// Queues an animation by name.
|
||||||
/// addAnimation(int, Animation, bool, float)
|
/// addAnimation(int, Animation, bool, float)
|
||||||
TrackEntry* addAnimation(int trackIndex, const String& animationName, bool loop, float delay);
|
TrackEntry* addAnimation(size_t trackIndex, const String& animationName, bool loop, float delay);
|
||||||
|
|
||||||
/// Adds an animation to be played delay seconds after the current or last queued animation
|
/// Adds an animation to be played delay seconds after the current or last queued animation
|
||||||
/// for a track. If the track is empty, it is equivalent to calling setAnimation.
|
/// for a track. If the track is empty, it is equivalent to calling setAnimation.
|
||||||
@ -345,11 +345,11 @@ namespace Spine {
|
|||||||
///
|
///
|
||||||
/// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
/// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||||
/// after AnimationState.Dispose
|
/// after AnimationState.Dispose
|
||||||
TrackEntry* addAnimation(int trackIndex, Animation* animation, bool loop, float delay);
|
TrackEntry* addAnimation(size_t trackIndex, Animation* animation, bool loop, float delay);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration.
|
/// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration.
|
||||||
TrackEntry* setEmptyAnimation(int trackIndex, float mixDuration);
|
TrackEntry* setEmptyAnimation(size_t trackIndex, float mixDuration);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the
|
/// Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the
|
||||||
@ -361,14 +361,14 @@ namespace Spine {
|
|||||||
/// @param mixDuration Mix duration.
|
/// @param mixDuration Mix duration.
|
||||||
/// @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation
|
/// @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation
|
||||||
/// duration of the previous track minus any mix duration plus the negative delay.
|
/// duration of the previous track minus any mix duration plus the negative delay.
|
||||||
TrackEntry* addEmptyAnimation(int trackIndex, float mixDuration, float delay);
|
TrackEntry* addEmptyAnimation(size_t trackIndex, float mixDuration, float delay);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.
|
/// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.
|
||||||
void setEmptyAnimations(float mixDuration);
|
void setEmptyAnimations(float mixDuration);
|
||||||
|
|
||||||
/// @return The track entry for the animation currently playing on the track, or NULL if no animation is currently playing.
|
/// @return The track entry for the animation currently playing on the track, or NULL if no animation is currently playing.
|
||||||
TrackEntry* getCurrent(int trackIndex);
|
TrackEntry* getCurrent(size_t trackIndex);
|
||||||
|
|
||||||
AnimationStateData* getData();
|
AnimationStateData* getData();
|
||||||
|
|
||||||
@ -405,7 +405,7 @@ namespace Spine {
|
|||||||
|
|
||||||
static Animation* getEmptyAnimation();
|
static Animation* getEmptyAnimation();
|
||||||
|
|
||||||
static void applyRotateTimeline(RotateTimeline* rotateTimeline, Skeleton& skeleton, float time, float alpha, MixBlend pose, Vector<float>& timelinesRotation, int i, bool firstFrame);
|
static void applyRotateTimeline(RotateTimeline* rotateTimeline, Skeleton& skeleton, float time, float alpha, MixBlend pose, Vector<float>& timelinesRotation, size_t i, bool firstFrame);
|
||||||
|
|
||||||
/// Returns true when all mixing from entries are complete.
|
/// Returns true when all mixing from entries are complete.
|
||||||
bool updateMixingFrom(TrackEntry* to, float delta);
|
bool updateMixingFrom(TrackEntry* to, float delta);
|
||||||
@ -415,13 +415,13 @@ namespace Spine {
|
|||||||
void queueEvents(TrackEntry* entry, float animationTime);
|
void queueEvents(TrackEntry* entry, float animationTime);
|
||||||
|
|
||||||
/// Sets the active TrackEntry for a given track number.
|
/// Sets the active TrackEntry for a given track number.
|
||||||
void setCurrent(int index, TrackEntry* current, bool interrupt);
|
void setCurrent(size_t index, TrackEntry* current, bool interrupt);
|
||||||
|
|
||||||
TrackEntry* expandToIndex(int index);
|
TrackEntry* expandToIndex(size_t index);
|
||||||
|
|
||||||
/// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values.
|
/// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values.
|
||||||
/// @param last May be NULL.
|
/// @param last May be NULL.
|
||||||
TrackEntry* newTrackEntry(int trackIndex, Animation* animation, bool loop, TrackEntry* last);
|
TrackEntry* newTrackEntry(size_t trackIndex, Animation* animation, bool loop, TrackEntry* last);
|
||||||
|
|
||||||
/// Dispose all track entries queued after the given TrackEntry.
|
/// Dispose all track entries queued after the given TrackEntry.
|
||||||
void disposeNext(TrackEntry* entry);
|
void disposeNext(TrackEntry* entry);
|
||||||
|
|||||||
@ -79,10 +79,6 @@ namespace Spine {
|
|||||||
bool operator==(const AnimationPair &other) const;
|
bool operator==(const AnimationPair &other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HashAnimationPair : public SpineObject {
|
|
||||||
std::size_t operator()(const Spine::AnimationStateData::AnimationPair& val) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
SkeletonData* _skeletonData;
|
SkeletonData* _skeletonData;
|
||||||
float _defaultMix;
|
float _defaultMix;
|
||||||
HashMap<AnimationPair, float> _animationToMixTime;
|
HashMap<AnimationPair, float> _animationToMixTime;
|
||||||
|
|||||||
@ -58,13 +58,13 @@ namespace Spine {
|
|||||||
/// Sets the time and value of the specified keyframe.
|
/// Sets the time and value of the specified keyframe.
|
||||||
void setFrame(int frameIndex, float time, const String& attachmentName);
|
void setFrame(int frameIndex, float time, const String& attachmentName);
|
||||||
|
|
||||||
int getSlotIndex();
|
size_t getSlotIndex();
|
||||||
void setSlotIndex(int inValue);
|
void setSlotIndex(size_t inValue);
|
||||||
const Vector<float>& getFrames();
|
const Vector<float>& getFrames();
|
||||||
const Vector<String>& getAttachmentNames();
|
const Vector<String>& getAttachmentNames();
|
||||||
int getFrameCount();
|
size_t getFrameCount();
|
||||||
private:
|
private:
|
||||||
int _slotIndex;
|
size_t _slotIndex;
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
Vector<String> _attachmentNames;
|
Vector<String> _attachmentNames;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
float getFloatValue();
|
float getFloatValue();
|
||||||
|
|
||||||
void setFloatValue(int inValue);
|
void setFloatValue(float inValue);
|
||||||
|
|
||||||
const String &getStringValue();
|
const String &getStringValue();
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,9 @@
|
|||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
#include <spine/SpineObject.h>
|
#include <spine/SpineObject.h>
|
||||||
|
|
||||||
|
// Required for new with line number and file name in MSVC
|
||||||
|
#pragma warning(disable:4291)
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
template<typename K, typename V>
|
template<typename K, typename V>
|
||||||
class HashMap : public SpineObject {
|
class HashMap : public SpineObject {
|
||||||
@ -143,8 +146,10 @@ public:
|
|||||||
V operator[](const K &key) {
|
V operator[](const K &key) {
|
||||||
Entry *entry = find(key);
|
Entry *entry = find(key);
|
||||||
if (entry) return entry->_value;
|
if (entry) return entry->_value;
|
||||||
else
|
else {
|
||||||
assert(false);
|
assert(false);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entries getEntries() const {
|
Entries getEntries() const {
|
||||||
|
|||||||
@ -43,12 +43,12 @@ class LinkedMesh : public SpineObject {
|
|||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LinkedMesh(MeshAttachment *mesh, const String &skin, int slotIndex, const String &parent);
|
LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MeshAttachment *_mesh;
|
MeshAttachment *_mesh;
|
||||||
String _skin;
|
String _skin;
|
||||||
int _slotIndex;
|
size_t _slotIndex;
|
||||||
String _parent;
|
String _parent;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T max(T a, T b) { return a > b ? a : b; }
|
static inline T max(T a, T b) { return a > b ? a : b; }
|
||||||
|
|
||||||
static int sign(float val);
|
static float sign(float val);
|
||||||
|
|
||||||
static float clamp(float x, float lower, float upper);
|
static float clamp(float x, float lower, float upper);
|
||||||
|
|
||||||
@ -106,8 +106,8 @@ struct PowInterpolation: public Interpolation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float apply(float a) {
|
float apply(float a) {
|
||||||
if (a <= 0.5f) return MathUtil::pow(a * 2, power) / 2;
|
if (a <= 0.5f) return MathUtil::pow(a * 2.0f, (float)power) / 2.0f;
|
||||||
return MathUtil::pow((a - 1) * 2, power) / (power % 2 == 0 ? -2 : 2) + 1;
|
return MathUtil::pow((a - 1.0f) * 2.0f, (float)power) / (power % 2 == 0 ? -2.0f : 2.0f) + 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
int power;
|
int power;
|
||||||
@ -118,7 +118,7 @@ struct PowOutInterpolation: public Interpolation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float apply(float a) {
|
float apply(float a) {
|
||||||
return MathUtil::pow(a - 1, power) * (power % 2 == 0 ? -1 : 1) + 1;
|
return MathUtil::pow(a - 1, (float)power) * (power % 2 == 0 ? -1.0f : 1.0f) + 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
int power;
|
int power;
|
||||||
|
|||||||
@ -52,7 +52,7 @@ namespace Spine {
|
|||||||
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
||||||
|
|
||||||
int getHullLength();
|
int getHullLength();
|
||||||
void setHullLength(float inValue);
|
void setHullLength(int inValue);
|
||||||
|
|
||||||
Vector<float>& getRegionUVs();
|
Vector<float>& getRegionUVs();
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ namespace Spine {
|
|||||||
void setRegionV2(float inValue);
|
void setRegionV2(float inValue);
|
||||||
|
|
||||||
bool getRegionRotate();
|
bool getRegionRotate();
|
||||||
void setRegionRotate(float inValue);
|
void setRegionRotate(bool inValue);
|
||||||
|
|
||||||
float getRegionOffsetX();
|
float getRegionOffsetX();
|
||||||
void setRegionOffsetX(float inValue);
|
void setRegionOffsetX(float inValue);
|
||||||
|
|||||||
@ -62,7 +62,7 @@ namespace Spine {
|
|||||||
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
|
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
|
||||||
/// @param offset The worldVertices index to begin writing values.
|
/// @param offset The worldVertices index to begin writing values.
|
||||||
/// @param stride The number of worldVertices entries between the value pairs written.
|
/// @param stride The number of worldVertices entries between the value pairs written.
|
||||||
void computeWorldVertices(Bone& bone, Vector<float>& worldVertices, int offset, int stride = 2);
|
void computeWorldVertices(Bone& bone, Vector<float>& worldVertices, size_t offset, size_t stride = 2);
|
||||||
|
|
||||||
float getX();
|
float getX();
|
||||||
void setX(float inValue);
|
void setX(float inValue);
|
||||||
|
|||||||
@ -77,13 +77,13 @@ private:
|
|||||||
const bool _ownsLoader;
|
const bool _ownsLoader;
|
||||||
String _error;
|
String _error;
|
||||||
|
|
||||||
static float toColor(const char *value, int index);
|
static float toColor(const char *value, size_t index);
|
||||||
|
|
||||||
static void readCurve(Json *frame, CurveTimeline *timeline, int frameIndex);
|
static void readCurve(Json *frame, CurveTimeline *timeline, size_t frameIndex);
|
||||||
|
|
||||||
Animation *readAnimation(Json *root, SkeletonData *skeletonData);
|
Animation *readAnimation(Json *root, SkeletonData *skeletonData);
|
||||||
|
|
||||||
void readVertices(Json *attachmentMap, VertexAttachment *attachment, int verticesLength);
|
void readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength);
|
||||||
|
|
||||||
void setError(Json *root, const String &value1, const String &value2);
|
void setError(Json *root, const String &value1, const String &value2);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -51,11 +51,11 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
struct Entry {
|
struct Entry {
|
||||||
int _slotIndex;
|
size_t _slotIndex;
|
||||||
String _name;
|
String _name;
|
||||||
Attachment *_attachment;
|
Attachment *_attachment;
|
||||||
|
|
||||||
Entry(int slotIndex, const String &name, Attachment *attachment) :
|
Entry(size_t slotIndex, const String &name, Attachment *attachment) :
|
||||||
_slotIndex(slotIndex),
|
_slotIndex(slotIndex),
|
||||||
_name(name),
|
_name(name),
|
||||||
_attachment(attachment) {
|
_attachment(attachment) {
|
||||||
@ -68,8 +68,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
bool hasNext() {
|
bool hasNext() {
|
||||||
while(true) {
|
while(true) {
|
||||||
if (_slotIndex >= (int) _buckets.size()) return false;
|
if (_slotIndex >= _buckets.size()) return false;
|
||||||
if (_bucketIndex >= (int) _buckets[_slotIndex].size()) {
|
if (_bucketIndex >= _buckets[_slotIndex].size()) {
|
||||||
_bucketIndex = 0;
|
_bucketIndex = 0;
|
||||||
++_slotIndex;
|
++_slotIndex;
|
||||||
continue;
|
continue;
|
||||||
@ -90,15 +90,15 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Vector< Vector<Entry> > &_buckets;
|
Vector< Vector<Entry> > &_buckets;
|
||||||
int _slotIndex;
|
size_t _slotIndex;
|
||||||
int _bucketIndex;
|
size_t _bucketIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
void put(int slotIndex, const String &attachmentName, Attachment *attachment);
|
void put(size_t slotIndex, const String &attachmentName, Attachment *attachment);
|
||||||
|
|
||||||
Attachment *get(int slotIndex, const String &attachmentName);
|
Attachment *get(size_t slotIndex, const String &attachmentName);
|
||||||
|
|
||||||
void remove(int slotIndex, const String &attachmentName);
|
void remove(size_t slotIndex, const String &attachmentName);
|
||||||
|
|
||||||
Entries getEntries();
|
Entries getEntries();
|
||||||
|
|
||||||
@ -118,20 +118,20 @@ public:
|
|||||||
|
|
||||||
/// Adds an attachment to the skin for the specified slot index and name.
|
/// Adds an attachment to the skin for the specified slot index and name.
|
||||||
/// If the name already exists for the slot, the previous value is replaced.
|
/// If the name already exists for the slot, the previous value is replaced.
|
||||||
void addAttachment(int slotIndex, const String &name, Attachment *attachment);
|
void addAttachment(size_t slotIndex, const 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, const String &name);
|
Attachment *getAttachment(size_t slotIndex, const String &name);
|
||||||
|
|
||||||
/// Finds the skin keys for a given slot. The results are added to the passed array of 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 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.
|
/// @param names Found skin key names will be added to this array.
|
||||||
void findNamesForSlot(int slotIndex, Vector <String> &names);
|
void findNamesForSlot(size_t slotIndex, Vector <String> &names);
|
||||||
|
|
||||||
/// Finds the attachments for a given slot. The results are added to the passed array of Attachments.
|
/// 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 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.
|
/// @param attachments Found Attachments will be added to this array.
|
||||||
void findAttachmentsForSlot(int slotIndex, Vector<Attachment *> &attachments);
|
void findAttachmentsForSlot(size_t slotIndex, Vector<Attachment *> &attachments);
|
||||||
|
|
||||||
const String &getName();
|
const String &getName();
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,10 @@ public:
|
|||||||
|
|
||||||
void *operator new(size_t sz, void *ptr);
|
void *operator new(size_t sz, void *ptr);
|
||||||
|
|
||||||
|
void operator delete(void *p, const char *file, int line);
|
||||||
|
|
||||||
|
void operator delete(void *p, void *mem);
|
||||||
|
|
||||||
void operator delete(void *p);
|
void operator delete(void *p);
|
||||||
|
|
||||||
virtual ~SpineObject();
|
virtual ~SpineObject();
|
||||||
|
|||||||
@ -37,6 +37,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
// Required for sprintf on MSVC
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
class String : public SpineObject {
|
class String : public SpineObject {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -59,7 +59,7 @@ namespace Spine {
|
|||||||
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + count.
|
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + count.
|
||||||
/// @param offset The worldVertices index to begin writing values.
|
/// @param offset The worldVertices index to begin writing values.
|
||||||
/// @param stride The number of worldVertices entries between the value pairs written.
|
/// @param stride The number of worldVertices entries between the value pairs written.
|
||||||
void computeWorldVertices(Slot& slot, int start, int count, Vector<float>& worldVertices, int offset, int stride = 2);
|
void computeWorldVertices(Slot& slot, size_t start, size_t count, Vector<float>& worldVertices, size_t offset, size_t stride = 2);
|
||||||
|
|
||||||
/// @return true if a deform originally applied to the specified attachment should be applied to this attachment.
|
/// @return true if a deform originally applied to the specified attachment should be applied to this attachment.
|
||||||
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
||||||
@ -67,17 +67,17 @@ namespace Spine {
|
|||||||
/// Gets a unique ID for this attachment.
|
/// Gets a unique ID for this attachment.
|
||||||
int getId();
|
int getId();
|
||||||
|
|
||||||
Vector<int>& getBones();
|
Vector<size_t>& getBones();
|
||||||
|
|
||||||
Vector<float>& getVertices();
|
Vector<float>& getVertices();
|
||||||
|
|
||||||
int getWorldVerticesLength();
|
size_t getWorldVerticesLength();
|
||||||
void setWorldVerticesLength(int inValue);
|
void setWorldVerticesLength(size_t inValue);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Vector<int> _bones;
|
Vector<size_t> _bones;
|
||||||
Vector<float> _vertices;
|
Vector<float> _vertices;
|
||||||
int _worldVerticesLength;
|
size_t _worldVerticesLength;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int _id;
|
const int _id;
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
namespace Spine {
|
namespace Spine {
|
||||||
class Vertices : public SpineObject {
|
class Vertices : public SpineObject {
|
||||||
public:
|
public:
|
||||||
Vector<int> _bones;
|
Vector<size_t> _bones;
|
||||||
Vector<float> _vertices;
|
Vector<float> _vertices;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,7 +141,7 @@ TrackEntry *TrackEntry::getMixingFrom() { return _mixingFrom; }
|
|||||||
|
|
||||||
void TrackEntry::setMixBlend(MixBlend blend) { _mixBlend = blend; }
|
void TrackEntry::setMixBlend(MixBlend blend) { _mixBlend = blend; }
|
||||||
|
|
||||||
float TrackEntry::getMixBlend() { return _mixBlend; }
|
MixBlend TrackEntry::getMixBlend() { return _mixBlend; }
|
||||||
|
|
||||||
void TrackEntry::resetRotationDirections() {
|
void TrackEntry::resetRotationDirections() {
|
||||||
_timelinesRotation.clear();
|
_timelinesRotation.clear();
|
||||||
@ -276,7 +276,7 @@ void EventQueue::drain() {
|
|||||||
AnimationState &state = _state;
|
AnimationState &state = _state;
|
||||||
|
|
||||||
// Don't cache _eventQueueEntries.size() so callbacks can queue their own events (eg, call setAnimation in AnimationState_Complete).
|
// Don't cache _eventQueueEntries.size() so callbacks can queue their own events (eg, call setAnimation in AnimationState_Complete).
|
||||||
for (int i = 0; i < _eventQueueEntries.size(); ++i) {
|
for (size_t i = 0; i < _eventQueueEntries.size(); ++i) {
|
||||||
EventQueueEntry *queueEntry = &_eventQueueEntries[i];
|
EventQueueEntry *queueEntry = &_eventQueueEntries[i];
|
||||||
TrackEntry *trackEntry = queueEntry->_entry;
|
TrackEntry *trackEntry = queueEntry->_entry;
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ AnimationState::AnimationState(AnimationStateData *data) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
AnimationState::~AnimationState() {
|
AnimationState::~AnimationState() {
|
||||||
for (int i = 0; i < _tracks.size(); i++) {
|
for (size_t i = 0; i < _tracks.size(); i++) {
|
||||||
TrackEntry* entry = _tracks[i];
|
TrackEntry* entry = _tracks[i];
|
||||||
if (entry) {
|
if (entry) {
|
||||||
TrackEntry* from = entry->_mixingFrom;
|
TrackEntry* from = entry->_mixingFrom;
|
||||||
@ -492,7 +492,7 @@ void AnimationState::clearTracks() {
|
|||||||
_queue->drain();
|
_queue->drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState::clearTrack(int trackIndex) {
|
void AnimationState::clearTrack(size_t trackIndex) {
|
||||||
if (trackIndex >= _tracks.size()) {
|
if (trackIndex >= _tracks.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -523,14 +523,14 @@ void AnimationState::clearTrack(int trackIndex) {
|
|||||||
_queue->drain();
|
_queue->drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::setAnimation(int trackIndex, const String &animationName, bool loop) {
|
TrackEntry *AnimationState::setAnimation(size_t trackIndex, const String &animationName, bool loop) {
|
||||||
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
||||||
assert(animation != NULL);
|
assert(animation != NULL);
|
||||||
|
|
||||||
return setAnimation(trackIndex, animation, loop);
|
return setAnimation(trackIndex, animation, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::setAnimation(int trackIndex, Animation *animation, bool loop) {
|
TrackEntry *AnimationState::setAnimation(size_t trackIndex, Animation *animation, bool loop) {
|
||||||
assert(animation != NULL);
|
assert(animation != NULL);
|
||||||
|
|
||||||
bool interrupt = true;
|
bool interrupt = true;
|
||||||
@ -556,14 +556,14 @@ TrackEntry *AnimationState::setAnimation(int trackIndex, Animation *animation, b
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::addAnimation(int trackIndex, const String &animationName, bool loop, float delay) {
|
TrackEntry *AnimationState::addAnimation(size_t trackIndex, const String &animationName, bool loop, float delay) {
|
||||||
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
||||||
assert(animation != NULL);
|
assert(animation != NULL);
|
||||||
|
|
||||||
return addAnimation(trackIndex, animation, loop, delay);
|
return addAnimation(trackIndex, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::addAnimation(int trackIndex, Animation *animation, bool loop, float delay) {
|
TrackEntry *AnimationState::addAnimation(size_t trackIndex, Animation *animation, bool loop, float delay) {
|
||||||
assert(animation != NULL);
|
assert(animation != NULL);
|
||||||
|
|
||||||
TrackEntry *last = expandToIndex(trackIndex);
|
TrackEntry *last = expandToIndex(trackIndex);
|
||||||
@ -599,14 +599,14 @@ TrackEntry *AnimationState::addAnimation(int trackIndex, Animation *animation, b
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::setEmptyAnimation(int trackIndex, float mixDuration) {
|
TrackEntry *AnimationState::setEmptyAnimation(size_t trackIndex, float mixDuration) {
|
||||||
TrackEntry *entry = setAnimation(trackIndex, AnimationState::getEmptyAnimation(), false);
|
TrackEntry *entry = setAnimation(trackIndex, AnimationState::getEmptyAnimation(), false);
|
||||||
entry->_mixDuration = mixDuration;
|
entry->_mixDuration = mixDuration;
|
||||||
entry->_trackEnd = mixDuration;
|
entry->_trackEnd = mixDuration;
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::addEmptyAnimation(int trackIndex, float mixDuration, float delay) {
|
TrackEntry *AnimationState::addEmptyAnimation(size_t trackIndex, float mixDuration, float delay) {
|
||||||
if (delay <= 0) {
|
if (delay <= 0) {
|
||||||
delay -= mixDuration;
|
delay -= mixDuration;
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ void AnimationState::setEmptyAnimations(float mixDuration) {
|
|||||||
_queue->drain();
|
_queue->drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::getCurrent(int trackIndex) {
|
TrackEntry *AnimationState::getCurrent(size_t trackIndex) {
|
||||||
return trackIndex >= _tracks.size() ? NULL : _tracks[trackIndex];
|
return trackIndex >= _tracks.size() ? NULL : _tracks[trackIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,7 +669,7 @@ Animation *AnimationState::getEmptyAnimation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleton &skeleton, float time, float alpha,
|
void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleton &skeleton, float time, float alpha,
|
||||||
MixBlend blend, Vector<float> &timelinesRotation, int i, bool firstFrame) {
|
MixBlend blend, Vector<float> &timelinesRotation, size_t i, bool firstFrame) {
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
timelinesRotation[i] = 0;
|
timelinesRotation[i] = 0;
|
||||||
}
|
}
|
||||||
@ -897,7 +897,7 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState::setCurrent(int index, TrackEntry *current, bool interrupt) {
|
void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrupt) {
|
||||||
TrackEntry *from = expandToIndex(index);
|
TrackEntry *from = expandToIndex(index);
|
||||||
_tracks[index] = current;
|
_tracks[index] = current;
|
||||||
|
|
||||||
@ -920,7 +920,7 @@ void AnimationState::setCurrent(int index, TrackEntry *current, bool interrupt)
|
|||||||
_queue->start(current); // triggers animationsChanged
|
_queue->start(current); // triggers animationsChanged
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::expandToIndex(int index) {
|
TrackEntry *AnimationState::expandToIndex(size_t index) {
|
||||||
if (index < _tracks.size()) {
|
if (index < _tracks.size()) {
|
||||||
return _tracks[index];
|
return _tracks[index];
|
||||||
}
|
}
|
||||||
@ -932,7 +932,7 @@ TrackEntry *AnimationState::expandToIndex(int index) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::newTrackEntry(int trackIndex, Animation *animation, bool loop, TrackEntry *last) {
|
TrackEntry *AnimationState::newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last) {
|
||||||
TrackEntry *entryP = _trackEntryPool.obtain(); // Pooling
|
TrackEntry *entryP = _trackEntryPool.obtain(); // Pooling
|
||||||
TrackEntry &entry = *entryP;
|
TrackEntry &entry = *entryP;
|
||||||
|
|
||||||
|
|||||||
@ -81,20 +81,3 @@ AnimationStateData::AnimationPair::AnimationPair(Animation *a1, Animation *a2) :
|
|||||||
bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const {
|
bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const {
|
||||||
return _a1->_name == other._a1->_name && _a2->_name == other._a2->_name;
|
return _a1->_name == other._a1->_name && _a2->_name == other._a2->_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t
|
|
||||||
AnimationStateData::HashAnimationPair::operator()(const Spine::AnimationStateData::AnimationPair &val) const {
|
|
||||||
std::size_t h1 = 7;
|
|
||||||
size_t strlen = val._a1->_name.length();
|
|
||||||
for (int i = 0; i < strlen; ++i) {
|
|
||||||
h1 = h1 * 31 + val._a1->_name.buffer()[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t h2 = 7;
|
|
||||||
strlen = val._a2->_name.length();
|
|
||||||
for (int i = 0; i < strlen; ++i) {
|
|
||||||
h2 = h2 * 31 + val._a2->_name.buffer()[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return (((h1 << 5) + h1) ^ h2);
|
|
||||||
}
|
|
||||||
|
|||||||
@ -172,7 +172,7 @@ void Atlas::load(const char *begin, int length, const char *dir) {
|
|||||||
region->name = String(mallocString(&str), true);
|
region->name = String(mallocString(&str), true);
|
||||||
|
|
||||||
assert(readValue(&begin, end, &str));
|
assert(readValue(&begin, end, &str));
|
||||||
region->rotate = equals(&str, "true");
|
region->rotate = equals(&str, "true") ? true : false;
|
||||||
|
|
||||||
assert(readTuple(&begin, end, tuple) == 2);
|
assert(readTuple(&begin, end, tuple) == 2);
|
||||||
region->x = toInt(tuple);
|
region->x = toInt(tuple);
|
||||||
@ -222,8 +222,8 @@ void Atlas::load(const char *begin, int length, const char *dir) {
|
|||||||
region->originalHeight = toInt(tuple + 1);
|
region->originalHeight = toInt(tuple + 1);
|
||||||
|
|
||||||
readTuple(&begin, end, tuple);
|
readTuple(&begin, end, tuple);
|
||||||
region->offsetX = toInt(tuple);
|
region->offsetX = (float)toInt(tuple);
|
||||||
region->offsetY = toInt(tuple + 1);
|
region->offsetY = (float)toInt(tuple + 1);
|
||||||
|
|
||||||
assert(readValue(&begin, end, &str));
|
assert(readValue(&begin, end, &str));
|
||||||
|
|
||||||
|
|||||||
@ -59,10 +59,10 @@ RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const S
|
|||||||
attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate);
|
attachment.setUVs(region.u, region.v, region.u2, region.v2, region.rotate);
|
||||||
attachment._regionOffsetX = region.offsetX;
|
attachment._regionOffsetX = region.offsetX;
|
||||||
attachment._regionOffsetY = region.offsetY;
|
attachment._regionOffsetY = region.offsetY;
|
||||||
attachment._regionWidth = region.width;
|
attachment._regionWidth = (float)region.width;
|
||||||
attachment._regionHeight = region.height;
|
attachment._regionHeight = (float)region.height;
|
||||||
attachment._regionOriginalWidth = region.originalWidth;
|
attachment._regionOriginalWidth = (float)region.originalWidth;
|
||||||
attachment._regionOriginalHeight = region.originalHeight;
|
attachment._regionOriginalHeight = (float)region.originalHeight;
|
||||||
return attachmentP;
|
return attachmentP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,10 +83,10 @@ MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const Strin
|
|||||||
attachment._regionRotate = region.rotate;
|
attachment._regionRotate = region.rotate;
|
||||||
attachment._regionOffsetX = region.offsetX;
|
attachment._regionOffsetX = region.offsetX;
|
||||||
attachment._regionOffsetY = region.offsetY;
|
attachment._regionOffsetY = region.offsetY;
|
||||||
attachment._regionWidth = region.width;
|
attachment._regionWidth = (float)region.width;
|
||||||
attachment._regionHeight = region.height;
|
attachment._regionHeight = (float)region.height;
|
||||||
attachment._regionOriginalWidth = region.originalWidth;
|
attachment._regionOriginalWidth = (float)region.originalWidth;
|
||||||
attachment._regionOriginalHeight = region.originalHeight;
|
attachment._regionOriginalHeight = (float)region.originalHeight;
|
||||||
|
|
||||||
return attachmentP;
|
return attachmentP;
|
||||||
}
|
}
|
||||||
@ -108,7 +108,6 @@ ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
|
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
|
||||||
AtlasRegion *ret;
|
|
||||||
return _atlas->findRegion(name);
|
return _atlas->findRegion(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,11 +97,11 @@ void AttachmentTimeline::setFrame(int frameIndex, float time, const String &atta
|
|||||||
_attachmentNames[frameIndex] = attachmentName;
|
_attachmentNames[frameIndex] = attachmentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AttachmentTimeline::getSlotIndex() {
|
size_t AttachmentTimeline::getSlotIndex() {
|
||||||
return _slotIndex;
|
return _slotIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentTimeline::setSlotIndex(int inValue) {
|
void AttachmentTimeline::setSlotIndex(size_t inValue) {
|
||||||
_slotIndex = inValue;
|
_slotIndex = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,6 +113,6 @@ const Vector<String> &AttachmentTimeline::getAttachmentNames() {
|
|||||||
return _attachmentNames;
|
return _attachmentNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AttachmentTimeline::getFrameCount() {
|
size_t AttachmentTimeline::getFrameCount() {
|
||||||
return static_cast<int>(_frames.size());
|
return _frames.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,7 +62,7 @@ float Event::getFloatValue() {
|
|||||||
return _floatValue;
|
return _floatValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::setFloatValue(int inValue) {
|
void Event::setFloatValue(float inValue) {
|
||||||
_floatValue = inValue;
|
_floatValue = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -69,7 +69,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
|
|
||||||
if (lastTime > time) {
|
if (lastTime > time) {
|
||||||
// Fire events after last time for looped animations.
|
// Fire events after last time for looped animations.
|
||||||
apply(skeleton, lastTime, std::numeric_limits<int>::max(), pEvents, alpha, blend, direction);
|
apply(skeleton, lastTime, std::numeric_limits<float>::max(), pEvents, alpha, blend, direction);
|
||||||
lastTime = -1.0f;
|
lastTime = -1.0f;
|
||||||
} else if (lastTime >= _frames[frameCount - 1]) {
|
} else if (lastTime >= _frames[frameCount - 1]) {
|
||||||
// Last time is after last frame.
|
// Last time is after last frame.
|
||||||
|
|||||||
@ -120,5 +120,5 @@ void IkConstraintTimeline::setFrame(int frameIndex, float time, float mix, int b
|
|||||||
frameIndex *= ENTRIES;
|
frameIndex *= ENTRIES;
|
||||||
_frames[frameIndex] = time;
|
_frames[frameIndex] = time;
|
||||||
_frames[frameIndex + MIX] = mix;
|
_frames[frameIndex + MIX] = mix;
|
||||||
_frames[frameIndex + BEND_DIRECTION] = bendDirection;
|
_frames[frameIndex + BEND_DIRECTION] = (float)bendDirection;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -376,7 +376,7 @@ const char *Json::parseNumber(Json *item, const char *num) {
|
|||||||
|
|
||||||
if (ptr != num) {
|
if (ptr != num) {
|
||||||
/* Parse success, number found. */
|
/* Parse success, number found. */
|
||||||
item->_valueFloat = result;
|
item->_valueFloat = (float)result;
|
||||||
item->_valueInt = static_cast<int>(result);
|
item->_valueInt = static_cast<int>(result);
|
||||||
item->_type = JSON_NUMBER;
|
item->_type = JSON_NUMBER;
|
||||||
return ptr;
|
return ptr;
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, int slotIndex, const String &parent) :
|
LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent) :
|
||||||
_mesh(mesh),
|
_mesh(mesh),
|
||||||
_skin(skin),
|
_skin(skin),
|
||||||
_slotIndex(slotIndex),
|
_slotIndex(slotIndex),
|
||||||
|
|||||||
@ -37,8 +37,8 @@ float MathUtil::abs(float v) {
|
|||||||
return ((v) < 0 ? -(v) : (v));
|
return ((v) < 0 ? -(v) : (v));
|
||||||
}
|
}
|
||||||
|
|
||||||
int MathUtil::sign(float v) {
|
float MathUtil::sign(float v) {
|
||||||
return ((v) < 0 ? -1 : (v) > 0 ? 1 : 0);
|
return ((v) < 0 ? -1.0f : (v) > 0 ? 1.0f : 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MathUtil::clamp(float x, float min, float max) {
|
float MathUtil::clamp(float x, float min, float max) {
|
||||||
@ -46,41 +46,41 @@ float MathUtil::clamp(float x, float min, float max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float MathUtil::fmod(float a, float b) {
|
float MathUtil::fmod(float a, float b) {
|
||||||
return ::fmod(a, b);
|
return (float)::fmod(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323
|
/// Returns atan2 in radians, faster but less accurate than Math.Atan2. Average error of 0.00231 radians (0.1323
|
||||||
/// degrees), largest error of 0.00488 radians (0.2796 degrees).
|
/// degrees), largest error of 0.00488 radians (0.2796 degrees).
|
||||||
float MathUtil::atan2(float y, float x) {
|
float MathUtil::atan2(float y, float x) {
|
||||||
return ::atan2(y, x);
|
return (float)::atan2(y, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the cosine in radians from a lookup table.
|
/// Returns the cosine in radians from a lookup table.
|
||||||
float MathUtil::cos(float radians) {
|
float MathUtil::cos(float radians) {
|
||||||
return ::cos(radians);
|
return (float)::cos(radians);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the sine in radians from a lookup table.
|
/// Returns the sine in radians from a lookup table.
|
||||||
float MathUtil::sin(float radians) {
|
float MathUtil::sin(float radians) {
|
||||||
return ::sin(radians);
|
return (float)::sin(radians);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MathUtil::sqrt(float v) {
|
float MathUtil::sqrt(float v) {
|
||||||
return ::sqrt(v);
|
return (float)::sqrt(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MathUtil::acos(float v) {
|
float MathUtil::acos(float v) {
|
||||||
return ::acos(v);
|
return (float)::acos(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the sine in radians from a lookup table.
|
/// Returns the sine in radians from a lookup table.
|
||||||
float MathUtil::sinDeg(float degrees) {
|
float MathUtil::sinDeg(float degrees) {
|
||||||
return ::sin(degrees * DEG_RAD);
|
return (float)::sin(degrees * DEG_RAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the cosine in radians from a lookup table.
|
/// Returns the cosine in radians from a lookup table.
|
||||||
float MathUtil::cosDeg(float degrees) {
|
float MathUtil::cosDeg(float degrees) {
|
||||||
return ::cos(degrees * DEG_RAD);
|
return (float)::cos(degrees * DEG_RAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
|
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
|
||||||
@ -109,5 +109,5 @@ float MathUtil::randomTriangular(float min, float max, float mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float MathUtil::pow(float a, float b) {
|
float MathUtil::pow(float a, float b) {
|
||||||
return ::pow(a, b);
|
return (float)::pow(a, b);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@ int MeshAttachment::getHullLength() {
|
|||||||
return _hullLength;
|
return _hullLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshAttachment::setHullLength(float inValue) {
|
void MeshAttachment::setHullLength(int inValue) {
|
||||||
_hullLength = inValue;
|
_hullLength = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ bool MeshAttachment::getRegionRotate() {
|
|||||||
return _regionRotate;
|
return _regionRotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshAttachment::setRegionRotate(float inValue) {
|
void MeshAttachment::setRegionRotate(bool inValue) {
|
||||||
_regionRotate = inValue;
|
_regionRotate = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -147,7 +147,7 @@ void PathConstraint::update() {
|
|||||||
offsetRotation *= p.getA() * p.getD() - p.getB() * p.getC() > 0 ? DEG_RAD : -DEG_RAD;
|
offsetRotation *= p.getA() * p.getD() - p.getB() * p.getC() > 0 ? DEG_RAD : -DEG_RAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, p = 3; i < boneCount; i++, p += 3) {
|
for (size_t i = 0, p = 3; i < boneCount; i++, p += 3) {
|
||||||
Bone *boneP = _bones[i];
|
Bone *boneP = _bones[i];
|
||||||
Bone &bone = *boneP;
|
Bone &bone = *boneP;
|
||||||
bone._worldX += (boneX - bone._worldX) * translateMix;
|
bone._worldX += (boneX - bone._worldX) * translateMix;
|
||||||
|
|||||||
@ -122,7 +122,7 @@ void RegionAttachment::setUVs(float u, float v, float u2, float v2, bool rotate)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionAttachment::computeWorldVertices(Bone &bone, Vector<float> &worldVertices, int offset, int stride) {
|
void RegionAttachment::computeWorldVertices(Bone &bone, Vector<float> &worldVertices, size_t offset, size_t stride) {
|
||||||
assert(worldVertices.size() >= (offset + 8));
|
assert(worldVertices.size() >= (offset + 8));
|
||||||
|
|
||||||
float x = bone.getWorldX(), y = bone.getWorldY();
|
float x = bone.getWorldX(), y = bone.getWorldY();
|
||||||
|
|||||||
@ -401,7 +401,7 @@ void Skeleton::getBounds(float &outX, float &outY, float &outWidth, float &outHe
|
|||||||
|
|
||||||
for (size_t i = 0; i < _drawOrder.size(); ++i) {
|
for (size_t i = 0; i < _drawOrder.size(); ++i) {
|
||||||
Slot *slot = _drawOrder[i];
|
Slot *slot = _drawOrder[i];
|
||||||
int verticesLength = 0;
|
size_t verticesLength = 0;
|
||||||
Attachment *attachment = slot->getAttachment();
|
Attachment *attachment = slot->getAttachment();
|
||||||
|
|
||||||
if (attachment != NULL && attachment->getRTTI().instanceOf(RegionAttachment::rtti)) {
|
if (attachment != NULL && attachment->getRTTI().instanceOf(RegionAttachment::rtti)) {
|
||||||
@ -423,7 +423,7 @@ void Skeleton::getBounds(float &outX, float &outY, float &outWidth, float &outHe
|
|||||||
mesh->computeWorldVertices(*slot, 0, verticesLength, outVertexBuffer, 0);
|
mesh->computeWorldVertices(*slot, 0, verticesLength, outVertexBuffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ii = 0; ii < verticesLength; ii += 2) {
|
for (size_t ii = 0; ii < verticesLength; ii += 2) {
|
||||||
float vx = outVertexBuffer[ii];
|
float vx = outVertexBuffer[ii];
|
||||||
float vy = outVertexBuffer[ii + 1];
|
float vy = outVertexBuffer[ii + 1];
|
||||||
|
|
||||||
@ -570,9 +570,9 @@ void Skeleton::sortPathConstraint(PathConstraint *constraint) {
|
|||||||
|
|
||||||
_updateCache.add(constraint);
|
_updateCache.add(constraint);
|
||||||
|
|
||||||
for (int i = 0; i < boneCount; i++)
|
for (size_t i = 0; i < boneCount; i++)
|
||||||
sortReset(constrained[i]->getChildren());
|
sortReset(constrained[i]->getChildren());
|
||||||
for (int i = 0; i < boneCount; i++)
|
for (size_t i = 0; i < boneCount; i++)
|
||||||
constrained[i]->_sorted = true;
|
constrained[i]->_sorted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,12 +615,12 @@ void Skeleton::sortPathConstraintAttachment(Skin *skin, int slotIndex, Bone &slo
|
|||||||
|
|
||||||
void Skeleton::sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone) {
|
void Skeleton::sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone) {
|
||||||
if (attachment == NULL || !attachment->getRTTI().instanceOf(PathAttachment::rtti)) return;
|
if (attachment == NULL || !attachment->getRTTI().instanceOf(PathAttachment::rtti)) return;
|
||||||
Vector<int> &pathBones = static_cast<PathAttachment *>(attachment)->getBones();
|
Vector<size_t> &pathBones = static_cast<PathAttachment *>(attachment)->getBones();
|
||||||
if (pathBones.size() == 0)
|
if (pathBones.size() == 0)
|
||||||
sortBone(&slotBone);
|
sortBone(&slotBone);
|
||||||
else {
|
else {
|
||||||
for (size_t i = 0, n = pathBones.size(); i < n;) {
|
for (size_t i = 0, n = pathBones.size(); i < n;) {
|
||||||
int nn = pathBones[i++];
|
size_t nn = pathBones[i++];
|
||||||
nn += i;
|
nn += i;
|
||||||
while (i < nn) {
|
while (i < nn) {
|
||||||
sortBone(_bones[pathBones[i++]]);
|
sortBone(_bones[pathBones[i++]]);
|
||||||
|
|||||||
@ -269,7 +269,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Skins. */
|
/* Skins. */
|
||||||
for (int i = skeletonData->_defaultSkin ? 1 : 0; i < skeletonData->_skins.size(); ++i) {
|
for (size_t i = skeletonData->_defaultSkin ? 1 : 0; i < skeletonData->_skins.size(); ++i) {
|
||||||
String skinName(readString(input), true);
|
String skinName(readString(input), true);
|
||||||
skeletonData->_skins[i] = readSkin(input, skinName, skeletonData, nonessential);
|
skeletonData->_skins[i] = readSkin(input, skinName, skeletonData, nonessential);
|
||||||
}
|
}
|
||||||
@ -583,7 +583,7 @@ void SkeletonBinary::readVertices(DataInput *input, VertexAttachment *attachment
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<float> &vertices = attachment->getVertices();
|
Vector<float> &vertices = attachment->getVertices();
|
||||||
Vector<int> &bones = attachment->getBones();
|
Vector<size_t> &bones = attachment->getBones();
|
||||||
vertices.ensureCapacity(verticesLength * 3 * 3);
|
vertices.ensureCapacity(verticesLength * 3 * 3);
|
||||||
bones.ensureCapacity(verticesLength * 3);
|
bones.ensureCapacity(verticesLength * 3);
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
|
|||||||
|
|
||||||
Polygon &polygon = *polygonP;
|
Polygon &polygon = *polygonP;
|
||||||
|
|
||||||
int count = boundingBox->getWorldVerticesLength();
|
size_t count = boundingBox->getWorldVerticesLength();
|
||||||
polygon._count = count;
|
polygon._count = count;
|
||||||
if (polygon._vertices.size() < count) {
|
if (polygon._vertices.size() < count) {
|
||||||
polygon._vertices.setSize(count, 0);
|
polygon._vertices.setSize(count, 0);
|
||||||
@ -84,10 +84,10 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
|
|||||||
if (updateAabb) {
|
if (updateAabb) {
|
||||||
aabbCompute();
|
aabbCompute();
|
||||||
} else {
|
} else {
|
||||||
_minX = std::numeric_limits<int>::min();
|
_minX = std::numeric_limits<float>::min();
|
||||||
_minY = std::numeric_limits<int>::min();
|
_minY = std::numeric_limits<float>::min();
|
||||||
_maxX = std::numeric_limits<int>::max();
|
_maxX = std::numeric_limits<float>::max();
|
||||||
_maxY = std::numeric_limits<int>::max();
|
_maxY = std::numeric_limits<float>::max();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,12 +210,12 @@ float SkeletonBounds::getHeight() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonBounds::aabbCompute() {
|
void SkeletonBounds::aabbCompute() {
|
||||||
float minX = std::numeric_limits<int>::min();
|
float minX = std::numeric_limits<float>::min();
|
||||||
float minY = std::numeric_limits<int>::min();
|
float minY = std::numeric_limits<float>::min();
|
||||||
float maxX = std::numeric_limits<int>::max();
|
float maxX = std::numeric_limits<float>::max();
|
||||||
float maxY = std::numeric_limits<int>::max();
|
float maxY = std::numeric_limits<float>::max();
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i) {
|
for (size_t i = 0, n = _polygons.size(); i < n; ++i) {
|
||||||
Polygon *polygon = _polygons[i];
|
Polygon *polygon = _polygons[i];
|
||||||
Vector<float> &vertices = polygon->_vertices;
|
Vector<float> &vertices = polygon->_vertices;
|
||||||
for (int ii = 0, nn = polygon->_count; ii < nn; ii += 2) {
|
for (int ii = 0, nn = polygon->_count; ii < nn; ii += 2) {
|
||||||
|
|||||||
@ -322,8 +322,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->_local = Json::getInt(constraintMap, "local", 0);
|
data->_local = Json::getInt(constraintMap, "local", 0) ? true : false;
|
||||||
data->_relative = Json::getInt(constraintMap, "relative", 0);
|
data->_relative = Json::getInt(constraintMap, "relative", 0) ? true : false;
|
||||||
data->_offsetRotation = Json::getFloat(constraintMap, "rotation", 0);
|
data->_offsetRotation = Json::getFloat(constraintMap, "rotation", 0);
|
||||||
data->_offsetX = Json::getFloat(constraintMap, "x", 0) * _scale;
|
data->_offsetX = Json::getFloat(constraintMap, "x", 0) * _scale;
|
||||||
data->_offsetY = Json::getFloat(constraintMap, "y", 0) * _scale;
|
data->_offsetY = Json::getFloat(constraintMap, "y", 0) * _scale;
|
||||||
@ -549,7 +549,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1);
|
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1) ? true : false;
|
||||||
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh,
|
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh,
|
||||||
String(Json::getString(
|
String(Json::getString(
|
||||||
attachmentMap,
|
attachmentMap,
|
||||||
@ -575,8 +575,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
PathAttachment *pathAttatchment = static_cast<PathAttachment *>(attachment);
|
PathAttachment *pathAttatchment = static_cast<PathAttachment *>(attachment);
|
||||||
|
|
||||||
int vertexCount = 0;
|
int vertexCount = 0;
|
||||||
pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0);
|
pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0) ? true : false;
|
||||||
pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1);
|
pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1) ? true : false;
|
||||||
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0);
|
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0);
|
||||||
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
|
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
|
||||||
|
|
||||||
@ -684,7 +684,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
return skeletonData;
|
return skeletonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
float SkeletonJson::toColor(const char *value, int index) {
|
float SkeletonJson::toColor(const char *value, size_t index) {
|
||||||
char digits[3];
|
char digits[3];
|
||||||
char *error;
|
char *error;
|
||||||
int color;
|
int color;
|
||||||
@ -706,7 +706,7 @@ float SkeletonJson::toColor(const char *value, int index) {
|
|||||||
return color / (float) 255;
|
return color / (float) 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonJson::readCurve(Json *frame, CurveTimeline *timeline, int frameIndex) {
|
void SkeletonJson::readCurve(Json *frame, CurveTimeline *timeline, size_t frameIndex) {
|
||||||
Json *curve = Json::getItem(frame, "curve");
|
Json *curve = Json::getItem(frame, "curve");
|
||||||
if (!curve) {
|
if (!curve) {
|
||||||
return;
|
return;
|
||||||
@ -727,7 +727,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
Vector<Timeline *> timelines;
|
Vector<Timeline *> timelines;
|
||||||
float duration = 0;
|
float duration = 0;
|
||||||
|
|
||||||
int frameIndex;
|
size_t frameIndex;
|
||||||
Json *valueMap;
|
Json *valueMap;
|
||||||
int timelinesCount = 0;
|
int timelinesCount = 0;
|
||||||
|
|
||||||
@ -950,7 +950,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
|
|
||||||
/** Path constraint timelines. */
|
/** Path constraint timelines. */
|
||||||
for (constraintMap = paths ? paths->_child : 0; constraintMap; constraintMap = constraintMap->_next) {
|
for (constraintMap = paths ? paths->_child : 0; constraintMap; constraintMap = constraintMap->_next) {
|
||||||
int constraintIndex = 0, i;
|
size_t constraintIndex = 0, i;
|
||||||
Json *timelineMap;
|
Json *timelineMap;
|
||||||
|
|
||||||
PathConstraintData *data = skeletonData->findPathConstraint(constraintMap->_name);
|
PathConstraintData *data = skeletonData->findPathConstraint(constraintMap->_name);
|
||||||
@ -1096,7 +1096,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
Vector<int> unchanged;
|
Vector<int> unchanged;
|
||||||
unchanged.ensureCapacity(skeletonData->_slots.size() - offsets->_size);
|
unchanged.ensureCapacity(skeletonData->_slots.size() - offsets->_size);
|
||||||
unchanged.setSize(skeletonData->_slots.size() - offsets->_size, 0);
|
unchanged.setSize(skeletonData->_slots.size() - offsets->_size, 0);
|
||||||
int originalIndex = 0, unchangedIndex = 0;
|
size_t originalIndex = 0, unchangedIndex = 0;
|
||||||
|
|
||||||
drawOrder2.ensureCapacity(skeletonData->_slots.size());
|
drawOrder2.ensureCapacity(skeletonData->_slots.size());
|
||||||
drawOrder2.setSize(skeletonData->_slots.size(), 0);
|
drawOrder2.setSize(skeletonData->_slots.size(), 0);
|
||||||
@ -1164,7 +1164,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
return new(__FILE__, __LINE__) Animation(String(root->_name), timelines, duration);
|
return new(__FILE__, __LINE__) Animation(String(root->_name), timelines, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, int verticesLength) {
|
void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength) {
|
||||||
Json *entry;
|
Json *entry;
|
||||||
int i, n, nn, entrySize;
|
int i, n, nn, entrySize;
|
||||||
Vector<float> vertices;
|
Vector<float> vertices;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ using namespace Spine;
|
|||||||
Skin::AttachmentMap::AttachmentMap() {
|
Skin::AttachmentMap::AttachmentMap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin::AttachmentMap::put(int slotIndex, const String &attachmentName, Attachment *attachment) {
|
void Skin::AttachmentMap::put(size_t slotIndex, const String &attachmentName, Attachment *attachment) {
|
||||||
if (slotIndex >= _buckets.size())
|
if (slotIndex >= _buckets.size())
|
||||||
_buckets.setSize(slotIndex + 1, Vector<Entry>());
|
_buckets.setSize(slotIndex + 1, Vector<Entry>());
|
||||||
Vector<Entry> &bucket = _buckets[slotIndex];
|
Vector<Entry> &bucket = _buckets[slotIndex];
|
||||||
@ -54,13 +54,13 @@ void Skin::AttachmentMap::put(int slotIndex, const String &attachmentName, Attac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment *Skin::AttachmentMap::get(int slotIndex, const String &attachmentName) {
|
Attachment *Skin::AttachmentMap::get(size_t slotIndex, const String &attachmentName) {
|
||||||
if (slotIndex >= _buckets.size()) return NULL;
|
if (slotIndex >= _buckets.size()) return NULL;
|
||||||
int existing = findInBucket(_buckets[slotIndex], attachmentName);
|
int existing = findInBucket(_buckets[slotIndex], attachmentName);
|
||||||
return existing >= 0 ? _buckets[slotIndex][existing]._attachment : NULL;
|
return existing >= 0 ? _buckets[slotIndex][existing]._attachment : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin::AttachmentMap::remove(int slotIndex, const String &attachmentName) {
|
void Skin::AttachmentMap::remove(size_t slotIndex, const String &attachmentName) {
|
||||||
if (slotIndex >= _buckets.size()) return;
|
if (slotIndex >= _buckets.size()) return;
|
||||||
int existing = findInBucket(_buckets[slotIndex], attachmentName);
|
int existing = findInBucket(_buckets[slotIndex], attachmentName);
|
||||||
if (existing >= 0) _buckets[slotIndex].removeAt(existing);
|
if (existing >= 0) _buckets[slotIndex].removeAt(existing);
|
||||||
@ -88,16 +88,16 @@ Skin::~Skin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin::addAttachment(int slotIndex, const String &name, Attachment *attachment) {
|
void Skin::addAttachment(size_t slotIndex, const String &name, Attachment *attachment) {
|
||||||
assert(attachment);
|
assert(attachment);
|
||||||
_attachments.put(slotIndex, name, attachment);
|
_attachments.put(slotIndex, name, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment *Skin::getAttachment(int slotIndex, const String &name) {
|
Attachment *Skin::getAttachment(size_t slotIndex, const String &name) {
|
||||||
return _attachments.get(slotIndex, name);
|
return _attachments.get(slotIndex, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin::findNamesForSlot(int slotIndex, Vector<String> &names) {
|
void Skin::findNamesForSlot(size_t slotIndex, Vector<String> &names) {
|
||||||
Skin::AttachmentMap::Entries entries = _attachments.getEntries();
|
Skin::AttachmentMap::Entries entries = _attachments.getEntries();
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
Skin::AttachmentMap::Entry &entry = entries.next();
|
Skin::AttachmentMap::Entry &entry = entries.next();
|
||||||
@ -107,7 +107,7 @@ void Skin::findNamesForSlot(int slotIndex, Vector<String> &names) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin::findAttachmentsForSlot(int slotIndex, Vector<Attachment *> &attachments) {
|
void Skin::findAttachmentsForSlot(size_t slotIndex, Vector<Attachment *> &attachments) {
|
||||||
Skin::AttachmentMap::Entries entries = _attachments.getEntries();
|
Skin::AttachmentMap::Entries entries = _attachments.getEntries();
|
||||||
while (entries.hasNext()) {
|
while (entries.hasNext()) {
|
||||||
Skin::AttachmentMap::Entry &entry = entries.next();
|
Skin::AttachmentMap::Entry &entry = entries.next();
|
||||||
|
|||||||
@ -41,6 +41,14 @@ void *SpineObject::operator new(size_t sz, void *ptr) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpineObject::operator delete(void *p, const char *file, int line) {
|
||||||
|
SpineExtension::free(p, file, line);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpineObject::operator delete(void *p, void *mem) {
|
||||||
|
SpineExtension::free(p, __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
void SpineObject::operator delete(void *p) {
|
void SpineObject::operator delete(void *p) {
|
||||||
SpineExtension::free(p, __FILE__, __LINE__);
|
SpineExtension::free(p, __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,7 +221,7 @@ Vector<Vector<float> *> &Triangulator::decompose(Vector<float> &vertices, Vector
|
|||||||
float secondX = p[2], secondY = p[3];
|
float secondX = p[2], secondY = p[3];
|
||||||
int winding0 = winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY);
|
int winding0 = winding(prevPrevX, prevPrevY, prevX, prevY, firstX, firstY);
|
||||||
|
|
||||||
for (int ii = 0; ii < n; ++ii) {
|
for (size_t ii = 0; ii < n; ++ii) {
|
||||||
if (ii == i) {
|
if (ii == i) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,13 +49,13 @@ void VertexAttachment::computeWorldVertices(Slot &slot, Vector<float> &worldVert
|
|||||||
computeWorldVertices(slot, 0, _worldVerticesLength, worldVertices, 0);
|
computeWorldVertices(slot, 0, _worldVerticesLength, worldVertices, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Vector<float> &worldVertices, int offset,
|
void VertexAttachment::computeWorldVertices(Slot &slot, size_t start, size_t count, Vector<float> &worldVertices, size_t offset,
|
||||||
int stride) {
|
size_t stride) {
|
||||||
count = offset + (count >> 1) * stride;
|
count = offset + (count >> 1) * stride;
|
||||||
Skeleton &skeleton = slot._bone._skeleton;
|
Skeleton &skeleton = slot._bone._skeleton;
|
||||||
Vector<float> *deformArray = &slot.getAttachmentVertices();
|
Vector<float> *deformArray = &slot.getAttachmentVertices();
|
||||||
Vector<float> *vertices = &_vertices;
|
Vector<float> *vertices = &_vertices;
|
||||||
Vector<int> &bones = _bones;
|
Vector<size_t> &bones = _bones;
|
||||||
if (bones.size() == 0) {
|
if (bones.size() == 0) {
|
||||||
if (deformArray->size() > 0) {
|
if (deformArray->size() > 0) {
|
||||||
vertices = deformArray;
|
vertices = deformArray;
|
||||||
@ -65,7 +65,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve
|
|||||||
float x = bone._worldX;
|
float x = bone._worldX;
|
||||||
float y = bone._worldY;
|
float y = bone._worldY;
|
||||||
float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
|
float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
|
||||||
for (int vv = start, w = offset; w < count; vv += 2, w += stride) {
|
for (size_t vv = start, w = offset; w < count; vv += 2, w += stride) {
|
||||||
float vx = (*vertices)[vv];
|
float vx = (*vertices)[vv];
|
||||||
float vy = (*vertices)[vv + 1];
|
float vy = (*vertices)[vv + 1];
|
||||||
worldVertices[w] = vx * a + vy * b + x;
|
worldVertices[w] = vx * a + vy * b + x;
|
||||||
@ -75,7 +75,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
int v = 0, skip = 0;
|
int v = 0, skip = 0;
|
||||||
for (int i = 0; i < start; i += 2) {
|
for (size_t i = 0; i < start; i += 2) {
|
||||||
int n = bones[v];
|
int n = bones[v];
|
||||||
v += n + 1;
|
v += n + 1;
|
||||||
skip += n;
|
skip += n;
|
||||||
@ -83,7 +83,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve
|
|||||||
|
|
||||||
Vector<Bone *> &skeletonBones = skeleton.getBones();
|
Vector<Bone *> &skeletonBones = skeleton.getBones();
|
||||||
if (deformArray->size() == 0) {
|
if (deformArray->size() == 0) {
|
||||||
for (int w = offset, b = skip * 3; w < count; w += stride) {
|
for (size_t w = offset, b = skip * 3; w < count; w += stride) {
|
||||||
float wx = 0, wy = 0;
|
float wx = 0, wy = 0;
|
||||||
int n = bones[v++];
|
int n = bones[v++];
|
||||||
n += v;
|
n += v;
|
||||||
@ -100,7 +100,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve
|
|||||||
worldVertices[w + 1] = wy;
|
worldVertices[w + 1] = wy;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {
|
for (size_t w = offset, b = skip * 3, f = skip << 1; w < count; w += stride) {
|
||||||
float wx = 0, wy = 0;
|
float wx = 0, wy = 0;
|
||||||
int n = bones[v++];
|
int n = bones[v++];
|
||||||
n += v;
|
n += v;
|
||||||
@ -127,7 +127,7 @@ int VertexAttachment::getId() {
|
|||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<int> &VertexAttachment::getBones() {
|
Vector<size_t> &VertexAttachment::getBones() {
|
||||||
return _bones;
|
return _bones;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,11 +135,11 @@ Vector<float> &VertexAttachment::getVertices() {
|
|||||||
return _vertices;
|
return _vertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VertexAttachment::getWorldVerticesLength() {
|
size_t VertexAttachment::getWorldVerticesLength() {
|
||||||
return _worldVerticesLength;
|
return _worldVerticesLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexAttachment::setWorldVerticesLength(int inValue) {
|
void VertexAttachment::setWorldVerticesLength(size_t inValue) {
|
||||||
_worldVerticesLength = inValue;
|
_worldVerticesLength = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -453,10 +453,10 @@ void test (SkeletonData* skeletonData, Atlas* atlas) {
|
|||||||
|
|
||||||
int main () {
|
int main () {
|
||||||
DebugExtension dbgExtension;
|
DebugExtension dbgExtension;
|
||||||
// SpineExtension::setInstance(&dbgExtension);
|
SpineExtension::setInstance(&dbgExtension);
|
||||||
|
|
||||||
// testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
|
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
|
||||||
// testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f);
|
testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f);
|
||||||
testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f);
|
testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f);
|
||||||
testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f);
|
testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f);
|
||||||
testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f);
|
testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f);
|
||||||
@ -465,6 +465,6 @@ int main () {
|
|||||||
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
|
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
|
||||||
testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins.atlas", 1.4f);
|
testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins.atlas", 1.4f);
|
||||||
testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman.atlas", 0.6f);
|
testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman.atlas", 0.6f);
|
||||||
// dbgExtension.reportLeaks();
|
dbgExtension.reportLeaks();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user