mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +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
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// KANJI_DUMP_LEAKED_MEM will print out the memory block that was leaked.
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
|
||||
#include "teamcity_messages.h"
|
||||
|
||||
#pragma warning(disable:4996)
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace JetBrains {
|
||||
|
||||
@ -96,7 +96,7 @@
|
||||
#define RAD_DEG (180 / PI)
|
||||
|
||||
#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__
|
||||
#define FMOD(A,B) fmodf(A, B)
|
||||
|
||||
@ -166,7 +166,7 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
|
||||
za *= s;
|
||||
zc *= s;
|
||||
s = SQRT(za * za + zc * zc);
|
||||
r = PI / 2 + atan2(zc, za);
|
||||
r = PI / 2 + ATAN2(zc, za);
|
||||
zb = COS(r) * s;
|
||||
zd = SIN(r) * s;
|
||||
la = COS_DEG(shearX) * scaleX;
|
||||
|
||||
@ -147,7 +147,7 @@ static const char* parse_number (Json *item, const char* num) {
|
||||
|
||||
if (ptr != num) {
|
||||
/* Parse success, number found. */
|
||||
item->valueFloat = result;
|
||||
item->valueFloat = (float)result;
|
||||
item->valueInt = (int)result;
|
||||
item->type = Json_Number;
|
||||
return ptr;
|
||||
|
||||
@ -93,7 +93,7 @@ static float toColor (const char* value, int index) {
|
||||
char *error;
|
||||
int color;
|
||||
|
||||
if (index >= strlen(value) / 2)
|
||||
if ((size_t)index >= strlen(value) / 2)
|
||||
return -1;
|
||||
value += index * 2;
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ namespace Spine {
|
||||
void setMixDuration(float inValue);
|
||||
|
||||
|
||||
float getMixBlend();
|
||||
MixBlend getMixBlend();
|
||||
void setMixBlend(MixBlend blend);
|
||||
|
||||
///
|
||||
@ -319,10 +319,10 @@ namespace Spine {
|
||||
/// 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,
|
||||
/// 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)
|
||||
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.
|
||||
/// @param loop If true, the animation will repeat.
|
||||
@ -331,11 +331,11 @@ namespace Spine {
|
||||
/// @return
|
||||
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||
/// 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.
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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.
|
||||
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
|
||||
@ -361,14 +361,14 @@ namespace Spine {
|
||||
/// @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
|
||||
/// 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.
|
||||
void setEmptyAnimations(float mixDuration);
|
||||
|
||||
/// @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();
|
||||
|
||||
@ -405,7 +405,7 @@ namespace Spine {
|
||||
|
||||
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.
|
||||
bool updateMixingFrom(TrackEntry* to, float delta);
|
||||
@ -415,13 +415,13 @@ namespace Spine {
|
||||
void queueEvents(TrackEntry* entry, float animationTime);
|
||||
|
||||
/// 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.
|
||||
/// @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.
|
||||
void disposeNext(TrackEntry* entry);
|
||||
|
||||
@ -79,10 +79,6 @@ namespace Spine {
|
||||
bool operator==(const AnimationPair &other) const;
|
||||
};
|
||||
|
||||
struct HashAnimationPair : public SpineObject {
|
||||
std::size_t operator()(const Spine::AnimationStateData::AnimationPair& val) const;
|
||||
};
|
||||
|
||||
SkeletonData* _skeletonData;
|
||||
float _defaultMix;
|
||||
HashMap<AnimationPair, float> _animationToMixTime;
|
||||
|
||||
@ -58,13 +58,13 @@ namespace Spine {
|
||||
/// Sets the time and value of the specified keyframe.
|
||||
void setFrame(int frameIndex, float time, const String& attachmentName);
|
||||
|
||||
int getSlotIndex();
|
||||
void setSlotIndex(int inValue);
|
||||
size_t getSlotIndex();
|
||||
void setSlotIndex(size_t inValue);
|
||||
const Vector<float>& getFrames();
|
||||
const Vector<String>& getAttachmentNames();
|
||||
int getFrameCount();
|
||||
size_t getFrameCount();
|
||||
private:
|
||||
int _slotIndex;
|
||||
size_t _slotIndex;
|
||||
Vector<float> _frames;
|
||||
Vector<String> _attachmentNames;
|
||||
};
|
||||
|
||||
@ -59,7 +59,7 @@ public:
|
||||
|
||||
float getFloatValue();
|
||||
|
||||
void setFloatValue(int inValue);
|
||||
void setFloatValue(float inValue);
|
||||
|
||||
const String &getStringValue();
|
||||
|
||||
|
||||
@ -35,6 +35,9 @@
|
||||
#include <spine/Vector.h>
|
||||
#include <spine/SpineObject.h>
|
||||
|
||||
// Required for new with line number and file name in MSVC
|
||||
#pragma warning(disable:4291)
|
||||
|
||||
namespace Spine {
|
||||
template<typename K, typename V>
|
||||
class HashMap : public SpineObject {
|
||||
@ -143,8 +146,10 @@ public:
|
||||
V operator[](const K &key) {
|
||||
Entry *entry = find(key);
|
||||
if (entry) return entry->_value;
|
||||
else
|
||||
else {
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Entries getEntries() const {
|
||||
|
||||
@ -43,12 +43,12 @@ class LinkedMesh : public SpineObject {
|
||||
friend class SkeletonJson;
|
||||
|
||||
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:
|
||||
MeshAttachment *_mesh;
|
||||
String _skin;
|
||||
int _slotIndex;
|
||||
size_t _slotIndex;
|
||||
String _parent;
|
||||
};
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public:
|
||||
template<typename T>
|
||||
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);
|
||||
|
||||
@ -106,8 +106,8 @@ struct PowInterpolation: public Interpolation {
|
||||
}
|
||||
|
||||
float apply(float a) {
|
||||
if (a <= 0.5f) return MathUtil::pow(a * 2, power) / 2;
|
||||
return MathUtil::pow((a - 1) * 2, power) / (power % 2 == 0 ? -2 : 2) + 1;
|
||||
if (a <= 0.5f) return MathUtil::pow(a * 2.0f, (float)power) / 2.0f;
|
||||
return MathUtil::pow((a - 1.0f) * 2.0f, (float)power) / (power % 2 == 0 ? -2.0f : 2.0f) + 1.0f;
|
||||
}
|
||||
|
||||
int power;
|
||||
@ -118,7 +118,7 @@ struct PowOutInterpolation: public Interpolation {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -52,7 +52,7 @@ namespace Spine {
|
||||
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
||||
|
||||
int getHullLength();
|
||||
void setHullLength(float inValue);
|
||||
void setHullLength(int inValue);
|
||||
|
||||
Vector<float>& getRegionUVs();
|
||||
|
||||
@ -81,7 +81,7 @@ namespace Spine {
|
||||
void setRegionV2(float inValue);
|
||||
|
||||
bool getRegionRotate();
|
||||
void setRegionRotate(float inValue);
|
||||
void setRegionRotate(bool inValue);
|
||||
|
||||
float getRegionOffsetX();
|
||||
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 offset The worldVertices index to begin writing values.
|
||||
/// @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();
|
||||
void setX(float inValue);
|
||||
|
||||
@ -77,13 +77,13 @@ private:
|
||||
const bool _ownsLoader;
|
||||
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);
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
@ -51,11 +51,11 @@ public:
|
||||
|
||||
public:
|
||||
struct Entry {
|
||||
int _slotIndex;
|
||||
size_t _slotIndex;
|
||||
String _name;
|
||||
Attachment *_attachment;
|
||||
|
||||
Entry(int slotIndex, const String &name, Attachment *attachment) :
|
||||
Entry(size_t slotIndex, const String &name, Attachment *attachment) :
|
||||
_slotIndex(slotIndex),
|
||||
_name(name),
|
||||
_attachment(attachment) {
|
||||
@ -68,8 +68,8 @@ public:
|
||||
public:
|
||||
bool hasNext() {
|
||||
while(true) {
|
||||
if (_slotIndex >= (int) _buckets.size()) return false;
|
||||
if (_bucketIndex >= (int) _buckets[_slotIndex].size()) {
|
||||
if (_slotIndex >= _buckets.size()) return false;
|
||||
if (_bucketIndex >= _buckets[_slotIndex].size()) {
|
||||
_bucketIndex = 0;
|
||||
++_slotIndex;
|
||||
continue;
|
||||
@ -90,15 +90,15 @@ public:
|
||||
|
||||
private:
|
||||
Vector< Vector<Entry> > &_buckets;
|
||||
int _slotIndex;
|
||||
int _bucketIndex;
|
||||
size_t _slotIndex;
|
||||
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();
|
||||
|
||||
@ -118,20 +118,20 @@ public:
|
||||
|
||||
/// 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.
|
||||
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.
|
||||
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.
|
||||
/// @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, 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.
|
||||
/// @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, Vector<Attachment *> &attachments);
|
||||
void findAttachmentsForSlot(size_t slotIndex, Vector<Attachment *> &attachments);
|
||||
|
||||
const String &getName();
|
||||
|
||||
|
||||
@ -42,6 +42,10 @@ public:
|
||||
|
||||
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);
|
||||
|
||||
virtual ~SpineObject();
|
||||
|
||||
@ -37,6 +37,9 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Required for sprintf on MSVC
|
||||
#pragma warning(disable:4996)
|
||||
|
||||
namespace Spine {
|
||||
class String : public SpineObject {
|
||||
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 offset The worldVertices index to begin writing values.
|
||||
/// @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.
|
||||
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
||||
@ -67,17 +67,17 @@ namespace Spine {
|
||||
/// Gets a unique ID for this attachment.
|
||||
int getId();
|
||||
|
||||
Vector<int>& getBones();
|
||||
Vector<size_t>& getBones();
|
||||
|
||||
Vector<float>& getVertices();
|
||||
|
||||
int getWorldVerticesLength();
|
||||
void setWorldVerticesLength(int inValue);
|
||||
size_t getWorldVerticesLength();
|
||||
void setWorldVerticesLength(size_t inValue);
|
||||
|
||||
protected:
|
||||
Vector<int> _bones;
|
||||
Vector<size_t> _bones;
|
||||
Vector<float> _vertices;
|
||||
int _worldVerticesLength;
|
||||
size_t _worldVerticesLength;
|
||||
|
||||
private:
|
||||
const int _id;
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
namespace Spine {
|
||||
class Vertices : public SpineObject {
|
||||
public:
|
||||
Vector<int> _bones;
|
||||
Vector<size_t> _bones;
|
||||
Vector<float> _vertices;
|
||||
};
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ TrackEntry *TrackEntry::getMixingFrom() { return _mixingFrom; }
|
||||
|
||||
void TrackEntry::setMixBlend(MixBlend blend) { _mixBlend = blend; }
|
||||
|
||||
float TrackEntry::getMixBlend() { return _mixBlend; }
|
||||
MixBlend TrackEntry::getMixBlend() { return _mixBlend; }
|
||||
|
||||
void TrackEntry::resetRotationDirections() {
|
||||
_timelinesRotation.clear();
|
||||
@ -276,7 +276,7 @@ void EventQueue::drain() {
|
||||
AnimationState &state = _state;
|
||||
|
||||
// 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];
|
||||
TrackEntry *trackEntry = queueEntry->_entry;
|
||||
|
||||
@ -323,7 +323,7 @@ AnimationState::AnimationState(AnimationStateData *data) :
|
||||
}
|
||||
|
||||
AnimationState::~AnimationState() {
|
||||
for (int i = 0; i < _tracks.size(); i++) {
|
||||
for (size_t i = 0; i < _tracks.size(); i++) {
|
||||
TrackEntry* entry = _tracks[i];
|
||||
if (entry) {
|
||||
TrackEntry* from = entry->_mixingFrom;
|
||||
@ -492,7 +492,7 @@ void AnimationState::clearTracks() {
|
||||
_queue->drain();
|
||||
}
|
||||
|
||||
void AnimationState::clearTrack(int trackIndex) {
|
||||
void AnimationState::clearTrack(size_t trackIndex) {
|
||||
if (trackIndex >= _tracks.size()) {
|
||||
return;
|
||||
}
|
||||
@ -523,14 +523,14 @@ void AnimationState::clearTrack(int trackIndex) {
|
||||
_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);
|
||||
assert(animation != NULL);
|
||||
|
||||
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);
|
||||
|
||||
bool interrupt = true;
|
||||
@ -556,14 +556,14 @@ TrackEntry *AnimationState::setAnimation(int trackIndex, Animation *animation, b
|
||||
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);
|
||||
assert(animation != NULL);
|
||||
|
||||
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);
|
||||
|
||||
TrackEntry *last = expandToIndex(trackIndex);
|
||||
@ -599,14 +599,14 @@ TrackEntry *AnimationState::addAnimation(int trackIndex, Animation *animation, b
|
||||
return entry;
|
||||
}
|
||||
|
||||
TrackEntry *AnimationState::setEmptyAnimation(int trackIndex, float mixDuration) {
|
||||
TrackEntry *AnimationState::setEmptyAnimation(size_t trackIndex, float mixDuration) {
|
||||
TrackEntry *entry = setAnimation(trackIndex, AnimationState::getEmptyAnimation(), false);
|
||||
entry->_mixDuration = mixDuration;
|
||||
entry->_trackEnd = mixDuration;
|
||||
return entry;
|
||||
}
|
||||
|
||||
TrackEntry *AnimationState::addEmptyAnimation(int trackIndex, float mixDuration, float delay) {
|
||||
TrackEntry *AnimationState::addEmptyAnimation(size_t trackIndex, float mixDuration, float delay) {
|
||||
if (delay <= 0) {
|
||||
delay -= mixDuration;
|
||||
}
|
||||
@ -630,7 +630,7 @@ void AnimationState::setEmptyAnimations(float mixDuration) {
|
||||
_queue->drain();
|
||||
}
|
||||
|
||||
TrackEntry *AnimationState::getCurrent(int trackIndex) {
|
||||
TrackEntry *AnimationState::getCurrent(size_t 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,
|
||||
MixBlend blend, Vector<float> &timelinesRotation, int i, bool firstFrame) {
|
||||
MixBlend blend, Vector<float> &timelinesRotation, size_t i, bool firstFrame) {
|
||||
if (firstFrame) {
|
||||
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);
|
||||
_tracks[index] = current;
|
||||
|
||||
@ -920,7 +920,7 @@ void AnimationState::setCurrent(int index, TrackEntry *current, bool interrupt)
|
||||
_queue->start(current); // triggers animationsChanged
|
||||
}
|
||||
|
||||
TrackEntry *AnimationState::expandToIndex(int index) {
|
||||
TrackEntry *AnimationState::expandToIndex(size_t index) {
|
||||
if (index < _tracks.size()) {
|
||||
return _tracks[index];
|
||||
}
|
||||
@ -932,7 +932,7 @@ TrackEntry *AnimationState::expandToIndex(int index) {
|
||||
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 &entry = *entryP;
|
||||
|
||||
|
||||
@ -81,20 +81,3 @@ AnimationStateData::AnimationPair::AnimationPair(Animation *a1, Animation *a2) :
|
||||
bool AnimationStateData::AnimationPair::operator==(const AnimationPair &other) const {
|
||||
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);
|
||||
|
||||
assert(readValue(&begin, end, &str));
|
||||
region->rotate = equals(&str, "true");
|
||||
region->rotate = equals(&str, "true") ? true : false;
|
||||
|
||||
assert(readTuple(&begin, end, tuple) == 2);
|
||||
region->x = toInt(tuple);
|
||||
@ -222,8 +222,8 @@ void Atlas::load(const char *begin, int length, const char *dir) {
|
||||
region->originalHeight = toInt(tuple + 1);
|
||||
|
||||
readTuple(&begin, end, tuple);
|
||||
region->offsetX = toInt(tuple);
|
||||
region->offsetY = toInt(tuple + 1);
|
||||
region->offsetX = (float)toInt(tuple);
|
||||
region->offsetY = (float)toInt(tuple + 1);
|
||||
|
||||
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._regionOffsetX = region.offsetX;
|
||||
attachment._regionOffsetY = region.offsetY;
|
||||
attachment._regionWidth = region.width;
|
||||
attachment._regionHeight = region.height;
|
||||
attachment._regionOriginalWidth = region.originalWidth;
|
||||
attachment._regionOriginalHeight = region.originalHeight;
|
||||
attachment._regionWidth = (float)region.width;
|
||||
attachment._regionHeight = (float)region.height;
|
||||
attachment._regionOriginalWidth = (float)region.originalWidth;
|
||||
attachment._regionOriginalHeight = (float)region.originalHeight;
|
||||
return attachmentP;
|
||||
}
|
||||
|
||||
@ -83,10 +83,10 @@ MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const Strin
|
||||
attachment._regionRotate = region.rotate;
|
||||
attachment._regionOffsetX = region.offsetX;
|
||||
attachment._regionOffsetY = region.offsetY;
|
||||
attachment._regionWidth = region.width;
|
||||
attachment._regionHeight = region.height;
|
||||
attachment._regionOriginalWidth = region.originalWidth;
|
||||
attachment._regionOriginalHeight = region.originalHeight;
|
||||
attachment._regionWidth = (float)region.width;
|
||||
attachment._regionHeight = (float)region.height;
|
||||
attachment._regionOriginalWidth = (float)region.originalWidth;
|
||||
attachment._regionOriginalHeight = (float)region.originalHeight;
|
||||
|
||||
return attachmentP;
|
||||
}
|
||||
@ -108,7 +108,6 @@ ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, con
|
||||
}
|
||||
|
||||
AtlasRegion *AtlasAttachmentLoader::findRegion(const String &name) {
|
||||
AtlasRegion *ret;
|
||||
return _atlas->findRegion(name);
|
||||
}
|
||||
|
||||
|
||||
@ -97,11 +97,11 @@ void AttachmentTimeline::setFrame(int frameIndex, float time, const String &atta
|
||||
_attachmentNames[frameIndex] = attachmentName;
|
||||
}
|
||||
|
||||
int AttachmentTimeline::getSlotIndex() {
|
||||
size_t AttachmentTimeline::getSlotIndex() {
|
||||
return _slotIndex;
|
||||
}
|
||||
|
||||
void AttachmentTimeline::setSlotIndex(int inValue) {
|
||||
void AttachmentTimeline::setSlotIndex(size_t inValue) {
|
||||
_slotIndex = inValue;
|
||||
}
|
||||
|
||||
@ -113,6 +113,6 @@ const Vector<String> &AttachmentTimeline::getAttachmentNames() {
|
||||
return _attachmentNames;
|
||||
}
|
||||
|
||||
int AttachmentTimeline::getFrameCount() {
|
||||
return static_cast<int>(_frames.size());
|
||||
size_t AttachmentTimeline::getFrameCount() {
|
||||
return _frames.size();
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ float Event::getFloatValue() {
|
||||
return _floatValue;
|
||||
}
|
||||
|
||||
void Event::setFloatValue(int inValue) {
|
||||
void Event::setFloatValue(float inValue) {
|
||||
_floatValue = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
||||
|
||||
if (lastTime > time) {
|
||||
// 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;
|
||||
} else if (lastTime >= _frames[frameCount - 1]) {
|
||||
// Last time is after last frame.
|
||||
|
||||
@ -120,5 +120,5 @@ void IkConstraintTimeline::setFrame(int frameIndex, float time, float mix, int b
|
||||
frameIndex *= ENTRIES;
|
||||
_frames[frameIndex] = time;
|
||||
_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) {
|
||||
/* Parse success, number found. */
|
||||
item->_valueFloat = result;
|
||||
item->_valueFloat = (float)result;
|
||||
item->_valueInt = static_cast<int>(result);
|
||||
item->_type = JSON_NUMBER;
|
||||
return ptr;
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
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),
|
||||
_skin(skin),
|
||||
_slotIndex(slotIndex),
|
||||
|
||||
@ -37,8 +37,8 @@ float MathUtil::abs(float v) {
|
||||
return ((v) < 0 ? -(v) : (v));
|
||||
}
|
||||
|
||||
int MathUtil::sign(float v) {
|
||||
return ((v) < 0 ? -1 : (v) > 0 ? 1 : 0);
|
||||
float MathUtil::sign(float v) {
|
||||
return ((v) < 0 ? -1.0f : (v) > 0 ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
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) {
|
||||
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
|
||||
/// degrees), largest error of 0.00488 radians (0.2796 degrees).
|
||||
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.
|
||||
float MathUtil::cos(float radians) {
|
||||
return ::cos(radians);
|
||||
return (float)::cos(radians);
|
||||
}
|
||||
|
||||
/// Returns the sine in radians from a lookup table.
|
||||
float MathUtil::sin(float radians) {
|
||||
return ::sin(radians);
|
||||
return (float)::sin(radians);
|
||||
}
|
||||
|
||||
float MathUtil::sqrt(float v) {
|
||||
return ::sqrt(v);
|
||||
return (float)::sqrt(v);
|
||||
}
|
||||
|
||||
float MathUtil::acos(float v) {
|
||||
return ::acos(v);
|
||||
return (float)::acos(v);
|
||||
}
|
||||
|
||||
/// Returns the sine in radians from a lookup table.
|
||||
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.
|
||||
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 */
|
||||
@ -109,5 +109,5 @@ float MathUtil::randomTriangular(float min, float max, float mode) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void MeshAttachment::setHullLength(float inValue) {
|
||||
void MeshAttachment::setHullLength(int inValue) {
|
||||
_hullLength = inValue;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ bool MeshAttachment::getRegionRotate() {
|
||||
return _regionRotate;
|
||||
}
|
||||
|
||||
void MeshAttachment::setRegionRotate(float inValue) {
|
||||
void MeshAttachment::setRegionRotate(bool inValue) {
|
||||
_regionRotate = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -147,7 +147,7 @@ void PathConstraint::update() {
|
||||
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 &bone = *boneP;
|
||||
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));
|
||||
|
||||
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) {
|
||||
Slot *slot = _drawOrder[i];
|
||||
int verticesLength = 0;
|
||||
size_t verticesLength = 0;
|
||||
Attachment *attachment = slot->getAttachment();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
for (int ii = 0; ii < verticesLength; ii += 2) {
|
||||
for (size_t ii = 0; ii < verticesLength; ii += 2) {
|
||||
float vx = outVertexBuffer[ii];
|
||||
float vy = outVertexBuffer[ii + 1];
|
||||
|
||||
@ -570,9 +570,9 @@ void Skeleton::sortPathConstraint(PathConstraint *constraint) {
|
||||
|
||||
_updateCache.add(constraint);
|
||||
|
||||
for (int i = 0; i < boneCount; i++)
|
||||
for (size_t i = 0; i < boneCount; i++)
|
||||
sortReset(constrained[i]->getChildren());
|
||||
for (int i = 0; i < boneCount; i++)
|
||||
for (size_t i = 0; i < boneCount; i++)
|
||||
constrained[i]->_sorted = true;
|
||||
}
|
||||
|
||||
@ -615,12 +615,12 @@ void Skeleton::sortPathConstraintAttachment(Skin *skin, int slotIndex, Bone &slo
|
||||
|
||||
void Skeleton::sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone) {
|
||||
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)
|
||||
sortBone(&slotBone);
|
||||
else {
|
||||
for (size_t i = 0, n = pathBones.size(); i < n;) {
|
||||
int nn = pathBones[i++];
|
||||
size_t nn = pathBones[i++];
|
||||
nn += i;
|
||||
while (i < nn) {
|
||||
sortBone(_bones[pathBones[i++]]);
|
||||
|
||||
@ -269,7 +269,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
}
|
||||
|
||||
/* 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);
|
||||
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<int> &bones = attachment->getBones();
|
||||
Vector<size_t> &bones = attachment->getBones();
|
||||
vertices.ensureCapacity(verticesLength * 3 * 3);
|
||||
bones.ensureCapacity(verticesLength * 3);
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
|
||||
|
||||
Polygon &polygon = *polygonP;
|
||||
|
||||
int count = boundingBox->getWorldVerticesLength();
|
||||
size_t count = boundingBox->getWorldVerticesLength();
|
||||
polygon._count = count;
|
||||
if (polygon._vertices.size() < count) {
|
||||
polygon._vertices.setSize(count, 0);
|
||||
@ -84,10 +84,10 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
|
||||
if (updateAabb) {
|
||||
aabbCompute();
|
||||
} else {
|
||||
_minX = std::numeric_limits<int>::min();
|
||||
_minY = std::numeric_limits<int>::min();
|
||||
_maxX = std::numeric_limits<int>::max();
|
||||
_maxY = std::numeric_limits<int>::max();
|
||||
_minX = std::numeric_limits<float>::min();
|
||||
_minY = std::numeric_limits<float>::min();
|
||||
_maxX = std::numeric_limits<float>::max();
|
||||
_maxY = std::numeric_limits<float>::max();
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,12 +210,12 @@ float SkeletonBounds::getHeight() {
|
||||
}
|
||||
|
||||
void SkeletonBounds::aabbCompute() {
|
||||
float minX = std::numeric_limits<int>::min();
|
||||
float minY = std::numeric_limits<int>::min();
|
||||
float maxX = std::numeric_limits<int>::max();
|
||||
float maxY = std::numeric_limits<int>::max();
|
||||
float minX = std::numeric_limits<float>::min();
|
||||
float minY = std::numeric_limits<float>::min();
|
||||
float maxX = std::numeric_limits<float>::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];
|
||||
Vector<float> &vertices = polygon->_vertices;
|
||||
for (int ii = 0, nn = polygon->_count; ii < nn; ii += 2) {
|
||||
|
||||
@ -322,8 +322,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data->_local = Json::getInt(constraintMap, "local", 0);
|
||||
data->_relative = Json::getInt(constraintMap, "relative", 0);
|
||||
data->_local = Json::getInt(constraintMap, "local", 0) ? true : false;
|
||||
data->_relative = Json::getInt(constraintMap, "relative", 0) ? true : false;
|
||||
data->_offsetRotation = Json::getFloat(constraintMap, "rotation", 0);
|
||||
data->_offsetX = Json::getFloat(constraintMap, "x", 0) * _scale;
|
||||
data->_offsetY = Json::getFloat(constraintMap, "y", 0) * _scale;
|
||||
@ -549,7 +549,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1);
|
||||
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1) ? true : false;
|
||||
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh,
|
||||
String(Json::getString(
|
||||
attachmentMap,
|
||||
@ -575,8 +575,8 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
PathAttachment *pathAttatchment = static_cast<PathAttachment *>(attachment);
|
||||
|
||||
int vertexCount = 0;
|
||||
pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0);
|
||||
pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1);
|
||||
pathAttatchment->_closed = Json::getInt(attachmentMap, "closed", 0) ? true : false;
|
||||
pathAttatchment->_constantSpeed = Json::getInt(attachmentMap, "constantSpeed", 1) ? true : false;
|
||||
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0);
|
||||
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
|
||||
|
||||
@ -684,7 +684,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
return skeletonData;
|
||||
}
|
||||
|
||||
float SkeletonJson::toColor(const char *value, int index) {
|
||||
float SkeletonJson::toColor(const char *value, size_t index) {
|
||||
char digits[3];
|
||||
char *error;
|
||||
int color;
|
||||
@ -706,7 +706,7 @@ float SkeletonJson::toColor(const char *value, int index) {
|
||||
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");
|
||||
if (!curve) {
|
||||
return;
|
||||
@ -727,7 +727,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
||||
Vector<Timeline *> timelines;
|
||||
float duration = 0;
|
||||
|
||||
int frameIndex;
|
||||
size_t frameIndex;
|
||||
Json *valueMap;
|
||||
int timelinesCount = 0;
|
||||
|
||||
@ -950,7 +950,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
||||
|
||||
/** Path constraint timelines. */
|
||||
for (constraintMap = paths ? paths->_child : 0; constraintMap; constraintMap = constraintMap->_next) {
|
||||
int constraintIndex = 0, i;
|
||||
size_t constraintIndex = 0, i;
|
||||
Json *timelineMap;
|
||||
|
||||
PathConstraintData *data = skeletonData->findPathConstraint(constraintMap->_name);
|
||||
@ -1096,7 +1096,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
||||
Vector<int> unchanged;
|
||||
unchanged.ensureCapacity(skeletonData->_slots.size() - offsets->_size);
|
||||
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.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);
|
||||
}
|
||||
|
||||
void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, int verticesLength) {
|
||||
void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength) {
|
||||
Json *entry;
|
||||
int i, n, nn, entrySize;
|
||||
Vector<float> vertices;
|
||||
|
||||
@ -42,7 +42,7 @@ using namespace Spine;
|
||||
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())
|
||||
_buckets.setSize(slotIndex + 1, Vector<Entry>());
|
||||
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;
|
||||
int existing = findInBucket(_buckets[slotIndex], attachmentName);
|
||||
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;
|
||||
int existing = findInBucket(_buckets[slotIndex], attachmentName);
|
||||
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);
|
||||
_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);
|
||||
}
|
||||
|
||||
void Skin::findNamesForSlot(int slotIndex, Vector<String> &names) {
|
||||
void Skin::findNamesForSlot(size_t slotIndex, Vector<String> &names) {
|
||||
Skin::AttachmentMap::Entries entries = _attachments.getEntries();
|
||||
while (entries.hasNext()) {
|
||||
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();
|
||||
while (entries.hasNext()) {
|
||||
Skin::AttachmentMap::Entry &entry = entries.next();
|
||||
|
||||
@ -41,6 +41,14 @@ void *SpineObject::operator new(size_t sz, void *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) {
|
||||
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];
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -49,13 +49,13 @@ void VertexAttachment::computeWorldVertices(Slot &slot, Vector<float> &worldVert
|
||||
computeWorldVertices(slot, 0, _worldVerticesLength, worldVertices, 0);
|
||||
}
|
||||
|
||||
void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Vector<float> &worldVertices, int offset,
|
||||
int stride) {
|
||||
void VertexAttachment::computeWorldVertices(Slot &slot, size_t start, size_t count, Vector<float> &worldVertices, size_t offset,
|
||||
size_t stride) {
|
||||
count = offset + (count >> 1) * stride;
|
||||
Skeleton &skeleton = slot._bone._skeleton;
|
||||
Vector<float> *deformArray = &slot.getAttachmentVertices();
|
||||
Vector<float> *vertices = &_vertices;
|
||||
Vector<int> &bones = _bones;
|
||||
Vector<size_t> &bones = _bones;
|
||||
if (bones.size() == 0) {
|
||||
if (deformArray->size() > 0) {
|
||||
vertices = deformArray;
|
||||
@ -65,7 +65,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve
|
||||
float x = bone._worldX;
|
||||
float y = bone._worldY;
|
||||
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 vy = (*vertices)[vv + 1];
|
||||
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;
|
||||
for (int i = 0; i < start; i += 2) {
|
||||
for (size_t i = 0; i < start; i += 2) {
|
||||
int n = bones[v];
|
||||
v += n + 1;
|
||||
skip += n;
|
||||
@ -83,7 +83,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve
|
||||
|
||||
Vector<Bone *> &skeletonBones = skeleton.getBones();
|
||||
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;
|
||||
int n = bones[v++];
|
||||
n += v;
|
||||
@ -100,7 +100,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, int start, int count, Ve
|
||||
worldVertices[w + 1] = wy;
|
||||
}
|
||||
} 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;
|
||||
int n = bones[v++];
|
||||
n += v;
|
||||
@ -127,7 +127,7 @@ int VertexAttachment::getId() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
Vector<int> &VertexAttachment::getBones() {
|
||||
Vector<size_t> &VertexAttachment::getBones() {
|
||||
return _bones;
|
||||
}
|
||||
|
||||
@ -135,11 +135,11 @@ Vector<float> &VertexAttachment::getVertices() {
|
||||
return _vertices;
|
||||
}
|
||||
|
||||
int VertexAttachment::getWorldVerticesLength() {
|
||||
size_t VertexAttachment::getWorldVerticesLength() {
|
||||
return _worldVerticesLength;
|
||||
}
|
||||
|
||||
void VertexAttachment::setWorldVerticesLength(int inValue) {
|
||||
void VertexAttachment::setWorldVerticesLength(size_t inValue) {
|
||||
_worldVerticesLength = inValue;
|
||||
}
|
||||
|
||||
|
||||
@ -453,10 +453,10 @@ void test (SkeletonData* skeletonData, Atlas* atlas) {
|
||||
|
||||
int main () {
|
||||
DebugExtension dbgExtension;
|
||||
// SpineExtension::setInstance(&dbgExtension);
|
||||
SpineExtension::setInstance(&dbgExtension);
|
||||
|
||||
// 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(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(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(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(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);
|
||||
// dbgExtension.reportLeaks();
|
||||
dbgExtension.reportLeaks();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user