mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 10:16:54 +08:00
[cpp] Crashes and leaks everywhere :D
This commit is contained in:
parent
3254747e94
commit
e7e240d109
@ -61,16 +61,16 @@ void *Spine::TestSpineExtension::_realloc(void *ptr, size_t size, const char *fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Spine::TestSpineExtension::_free(void *mem, const char *file, int line) {
|
void Spine::TestSpineExtension::_free(void *mem, const char *file, int line) {
|
||||||
DefaultSpineExtension::_free(mem, file, line);
|
|
||||||
|
|
||||||
for (std::vector<Allocation>::iterator it = allocated.begin(); it != allocated.end(); it++) {
|
for (std::vector<Allocation>::iterator it = allocated.begin(); it != allocated.end(); it++) {
|
||||||
if (it->address == mem) {
|
if (it->address == mem) {
|
||||||
|
DefaultSpineExtension::_free(mem, file, line);
|
||||||
allocated.erase(it);
|
allocated.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s:%i (address %p): Double free or not allocatedö through SpineExtension", file, line, mem);
|
printf("%s:%i (address %p): Double free or not allocated through SpineExtension\n", file, line, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spine::TestSpineExtension::reportLeaks() {
|
void Spine::TestSpineExtension::reportLeaks() {
|
||||||
|
|||||||
@ -33,19 +33,53 @@
|
|||||||
|
|
||||||
#include "TestHarness.h"
|
#include "TestHarness.h"
|
||||||
|
|
||||||
#define SPINEBOY_JSON "testdata/spineboy/spineboy-ess.json"
|
#define SPINEBOY_JSON "testdata/raptor/raptor-pro.json"
|
||||||
#define SPINEBOY_ATLAS "testdata/spineboy/spineboy.atlas"
|
#define SPINEBOY_ATLAS "testdata/raptor/raptor.atlas"
|
||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
|
void loadSpineboy(Atlas* &atlas, SkeletonData* &skeletonData, AnimationStateData* &stateData, Skeleton* &skeleton, AnimationState* &state) {
|
||||||
|
atlas = new (__FILE__, __LINE__) Atlas(SPINEBOY_ATLAS, 0);
|
||||||
|
assert(atlas != 0);
|
||||||
|
|
||||||
|
SkeletonJson json(atlas);
|
||||||
|
skeletonData = json.readSkeletonDataFile(SPINEBOY_JSON);
|
||||||
|
assert(skeletonData);
|
||||||
|
|
||||||
|
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
|
||||||
|
assert(skeleton != 0);
|
||||||
|
|
||||||
|
stateData = new (__FILE__, __LINE__) AnimationStateData(skeletonData);
|
||||||
|
assert(stateData != 0);
|
||||||
|
stateData->setDefaultMix(0.4f);
|
||||||
|
|
||||||
|
state = new (__FILE__, __LINE__) AnimationState(stateData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dispose(Atlas* atlas, SkeletonData* skeletonData, AnimationStateData* stateData, Skeleton* skeleton, AnimationState* state) {
|
||||||
|
delete skeleton;
|
||||||
|
delete state;
|
||||||
|
delete stateData;
|
||||||
|
delete skeletonData;
|
||||||
|
delete atlas;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reproduceIssue_776() {
|
||||||
|
Atlas* atlas = 0;
|
||||||
|
SkeletonData* skeletonData = 0;
|
||||||
|
AnimationStateData* stateData = 0;
|
||||||
|
Skeleton* skeleton = 0;
|
||||||
|
AnimationState* state = 0;
|
||||||
|
|
||||||
|
loadSpineboy(atlas, skeletonData, stateData, skeleton, state);
|
||||||
|
dispose(atlas, skeletonData, stateData, skeleton, state);
|
||||||
|
}
|
||||||
|
|
||||||
int main (int argc, char** argv) {
|
int main (int argc, char** argv) {
|
||||||
TestSpineExtension* ext = new TestSpineExtension();
|
TestSpineExtension* ext = new TestSpineExtension();
|
||||||
SpineExtension::setInstance(ext);
|
SpineExtension::setInstance(ext);
|
||||||
|
|
||||||
Atlas* atlas = new (__FILE__, __LINE__) Atlas(SPINEBOY_ATLAS, 0);
|
reproduceIssue_776();
|
||||||
|
|
||||||
|
|
||||||
delete atlas;
|
|
||||||
|
|
||||||
ext->reportLeaks();
|
ext->reportLeaks();
|
||||||
}
|
}
|
||||||
@ -288,7 +288,7 @@ namespace Spine {
|
|||||||
friend class EventQueue;
|
friend class EventQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnimationState(AnimationStateData& data);
|
AnimationState(AnimationStateData* data);
|
||||||
|
|
||||||
~AnimationState();
|
~AnimationState();
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ namespace Spine {
|
|||||||
/// @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(int trackIndex);
|
||||||
|
|
||||||
AnimationStateData& getData();
|
AnimationStateData* getData();
|
||||||
|
|
||||||
/// A list of tracks that have animations, which may contain NULLs.
|
/// A list of tracks that have animations, which may contain NULLs.
|
||||||
Vector<TrackEntry*> getTracks();
|
Vector<TrackEntry*> getTracks();
|
||||||
@ -376,7 +376,7 @@ namespace Spine {
|
|||||||
private:
|
private:
|
||||||
static const int Subsequent, First, Dip, DipMix;
|
static const int Subsequent, First, Dip, DipMix;
|
||||||
|
|
||||||
AnimationStateData& _data;
|
AnimationStateData* _data;
|
||||||
|
|
||||||
Pool<TrackEntry> _trackEntryPool;
|
Pool<TrackEntry> _trackEntryPool;
|
||||||
Vector<TrackEntry*> _tracks;
|
Vector<TrackEntry*> _tracks;
|
||||||
|
|||||||
@ -47,13 +47,13 @@ namespace Spine {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/// The SkeletonData to look up animations when they are specified by name.
|
/// The SkeletonData to look up animations when they are specified by name.
|
||||||
SkeletonData& getSkeletonData();
|
SkeletonData* getSkeletonData();
|
||||||
|
|
||||||
/// The mix duration to use when no mix duration has been specifically defined between two animations.
|
/// The mix duration to use when no mix duration has been specifically defined between two animations.
|
||||||
float getDefaultMix();
|
float getDefaultMix();
|
||||||
void setDefaultMix(float inValue);
|
void setDefaultMix(float inValue);
|
||||||
|
|
||||||
AnimationStateData(SkeletonData& skeletonData);
|
AnimationStateData(SkeletonData* skeletonData);
|
||||||
|
|
||||||
/// Sets a mix duration by animation names.
|
/// Sets a mix duration by animation names.
|
||||||
void setMix(std::string fromName, std::string toName, float duration);
|
void setMix(std::string fromName, std::string toName, float duration);
|
||||||
@ -83,7 +83,7 @@ namespace Spine {
|
|||||||
std::size_t operator()(const Spine::AnimationStateData::AnimationPair& val) const;
|
std::size_t operator()(const Spine::AnimationStateData::AnimationPair& val) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
SkeletonData& _skeletonData;
|
SkeletonData* _skeletonData;
|
||||||
float _defaultMix;
|
float _defaultMix;
|
||||||
HashMap<AnimationPair, float, HashAnimationPair> _animationToMixTime;
|
HashMap<AnimationPair, float, HashAnimationPair> _animationToMixTime;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace Spine {
|
|||||||
RTTI_DECL;
|
RTTI_DECL;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AtlasAttachmentLoader(Atlas& atlas);
|
AtlasAttachmentLoader(Atlas* atlas);
|
||||||
|
|
||||||
virtual RegionAttachment* newRegionAttachment(Skin& skin, std::string name, std::string path);
|
virtual RegionAttachment* newRegionAttachment(Skin& skin, std::string name, std::string path);
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ namespace Spine {
|
|||||||
AtlasRegion* findRegion(std::string name);
|
AtlasRegion* findRegion(std::string name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Atlas& _atlas;
|
Atlas* _atlas;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ namespace Spine {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Attachment(std::string name);
|
Attachment(std::string name);
|
||||||
|
virtual ~Attachment();
|
||||||
|
|
||||||
const std::string& getName();
|
const std::string& getName();
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,8 @@ namespace Spine {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CurveTimeline(int frameCount);
|
CurveTimeline(int frameCount);
|
||||||
|
|
||||||
|
virtual ~CurveTimeline();
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) = 0;
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) = 0;
|
||||||
|
|
||||||
|
|||||||
@ -51,14 +51,9 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Iterator& operator++() {
|
Iterator& operator++() {
|
||||||
_entry = _entry->next;
|
_entry = _entry->next;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator& operator--() {
|
|
||||||
_entry = _entry->prev;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Iterator& p) const {
|
bool operator==(const Iterator& p) const {
|
||||||
return _entry == p._entry;
|
return _entry == p._entry;
|
||||||
@ -68,11 +63,11 @@ namespace Spine {
|
|||||||
return _entry != p._entry;
|
return _entry != p._entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
K& first() {
|
K& key() {
|
||||||
return _entry->_key;
|
return _entry->_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
V& second() {
|
V& value() {
|
||||||
return _entry->_value;
|
return _entry->_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +93,9 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~HashMap() {
|
~HashMap() {
|
||||||
|
for (Iterator it = begin(); it != end(); ++it) {
|
||||||
|
delete it._entry;
|
||||||
|
}
|
||||||
_hashSize = 0;
|
_hashSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,14 +111,6 @@ namespace Spine {
|
|||||||
return Iterator(&_trailer);
|
return Iterator(&_trailer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator rbegin() {
|
|
||||||
return Iterator(_trailer.prev);
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator rend() {
|
|
||||||
return Iterator(_header);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<Iterator, bool> insert(const K& key, const V& value) {
|
std::pair<Iterator, bool> insert(const K& key, const V& value) {
|
||||||
Iterator iter = find(key);
|
Iterator iter = find(key);
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,8 @@ namespace Spine {
|
|||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
PathConstraintPositionTimeline(int frameCount);
|
PathConstraintPositionTimeline(int frameCount);
|
||||||
|
|
||||||
|
virtual ~PathConstraintPositionTimeline();
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ namespace Spine {
|
|||||||
friend class TwoColorTimeline;
|
friend class TwoColorTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Skeleton(SkeletonData& skeletonData);
|
Skeleton(SkeletonData* skeletonData);
|
||||||
|
|
||||||
~Skeleton();
|
~Skeleton();
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ namespace Spine {
|
|||||||
|
|
||||||
Bone* getRootBone();
|
Bone* getRootBone();
|
||||||
|
|
||||||
const SkeletonData& getData();
|
const SkeletonData* getData();
|
||||||
Vector<Bone*>& getBones();
|
Vector<Bone*>& getBones();
|
||||||
Vector<Updatable*>& getUpdateCacheList();
|
Vector<Updatable*>& getUpdateCacheList();
|
||||||
Vector<Slot*>& getSlots();
|
Vector<Slot*>& getSlots();
|
||||||
@ -174,7 +174,7 @@ namespace Spine {
|
|||||||
void setFlipY(float inValue);
|
void setFlipY(float inValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SkeletonData& _data;
|
SkeletonData* _data;
|
||||||
Vector<Bone*> _bones;
|
Vector<Bone*> _bones;
|
||||||
Vector<Slot*> _slots;
|
Vector<Slot*> _slots;
|
||||||
Vector<Slot*> _drawOrder;
|
Vector<Slot*> _drawOrder;
|
||||||
|
|||||||
@ -69,7 +69,7 @@ namespace Spine {
|
|||||||
|
|
||||||
static const TransformMode TRANSFORM_MODE_VALUES[5];
|
static const TransformMode TRANSFORM_MODE_VALUES[5];
|
||||||
|
|
||||||
SkeletonBinary(Atlas& atlasArray);
|
SkeletonBinary(Atlas* atlasArray);
|
||||||
|
|
||||||
SkeletonBinary(AttachmentLoader* attachmentLoader);
|
SkeletonBinary(AttachmentLoader* attachmentLoader);
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ namespace Spine {
|
|||||||
|
|
||||||
class SkeletonJson : public SpineObject {
|
class SkeletonJson : public SpineObject {
|
||||||
public:
|
public:
|
||||||
SkeletonJson(Atlas& atlas);
|
SkeletonJson(Atlas* atlas);
|
||||||
|
|
||||||
SkeletonJson(AttachmentLoader* attachmentLoader);
|
SkeletonJson(AttachmentLoader* attachmentLoader);
|
||||||
|
|
||||||
|
|||||||
@ -61,6 +61,7 @@ namespace Spine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Skin(std::string name);
|
Skin(std::string name);
|
||||||
|
~Skin();
|
||||||
|
|
||||||
/// 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.
|
||||||
|
|||||||
@ -38,6 +38,7 @@ namespace Spine {
|
|||||||
public:
|
public:
|
||||||
void* operator new(size_t sz, const char* file, int line);
|
void* operator new(size_t sz, const char* file, int line);
|
||||||
void operator delete(void* p);
|
void operator delete(void* p);
|
||||||
|
virtual ~SpineObject();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,6 +47,8 @@ namespace Spine {
|
|||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
TranslateTimeline(int frameCount);
|
TranslateTimeline(int frameCount);
|
||||||
|
|
||||||
|
virtual ~TranslateTimeline();
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction);
|
||||||
|
|
||||||
|
|||||||
@ -56,7 +56,6 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~Vector() {
|
~Vector() {
|
||||||
clear();
|
|
||||||
deallocate(_buffer);
|
deallocate(_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,21 +148,21 @@ namespace Spine {
|
|||||||
T* end() {
|
T* end() {
|
||||||
return &_buffer[_size];
|
return &_buffer[_size];
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator==(Vector<T>& lhs, Vector<T>& rhs) {
|
friend bool operator==(Vector<T>& lhs, Vector<T>& rhs) {
|
||||||
if (lhs.size() != rhs.size()) {
|
if (lhs.size() != rhs.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(lhs.size()); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(lhs.size()); i < n; ++i) {
|
||||||
if (lhs[i] != rhs[i]) {
|
if (lhs[i] != rhs[i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator!=(Vector<T>& lhs, Vector<T>& rhs) {
|
friend bool operator!=(Vector<T>& lhs, Vector<T>& rhs) {
|
||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
@ -186,6 +185,7 @@ namespace Spine {
|
|||||||
void deallocate(T* buffer) {
|
void deallocate(T* buffer) {
|
||||||
if (_buffer) {
|
if (_buffer) {
|
||||||
SpineExtension::free<T>(buffer, __FILE__, __LINE__);
|
SpineExtension::free<T>(buffer, __FILE__, __LINE__);
|
||||||
|
// _buffer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -48,6 +48,8 @@ namespace Spine {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
VertexAttachment(std::string name);
|
VertexAttachment(std::string name);
|
||||||
|
|
||||||
|
virtual ~VertexAttachment();
|
||||||
|
|
||||||
void computeWorldVertices(Slot& slot, Vector<float>& worldVertices);
|
void computeWorldVertices(Slot& slot, Vector<float>& worldVertices);
|
||||||
|
|
||||||
|
|||||||
@ -305,7 +305,7 @@ namespace Spine {
|
|||||||
const int AnimationState::Dip = 2;
|
const int AnimationState::Dip = 2;
|
||||||
const int AnimationState::DipMix = 3;
|
const int AnimationState::DipMix = 3;
|
||||||
|
|
||||||
AnimationState::AnimationState(AnimationStateData& data) :
|
AnimationState::AnimationState(AnimationStateData* data) :
|
||||||
_data(data),
|
_data(data),
|
||||||
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
|
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
|
||||||
_animationsChanged(false),
|
_animationsChanged(false),
|
||||||
@ -501,7 +501,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* AnimationState::setAnimation(int trackIndex, std::string animationName, bool loop) {
|
TrackEntry* AnimationState::setAnimation(int trackIndex, std::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);
|
||||||
@ -535,7 +535,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* AnimationState::addAnimation(int trackIndex, std::string animationName, bool loop, float delay) {
|
TrackEntry* AnimationState::addAnimation(int trackIndex, std::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);
|
||||||
@ -567,7 +567,7 @@ namespace Spine {
|
|||||||
} else {
|
} else {
|
||||||
delay += duration;
|
delay += duration;
|
||||||
}
|
}
|
||||||
delay -= _data.getMix(last->_animation, animation);
|
delay -= _data->getMix(last->_animation, animation);
|
||||||
} else {
|
} else {
|
||||||
delay = 0;
|
delay = 0;
|
||||||
}
|
}
|
||||||
@ -613,7 +613,7 @@ namespace Spine {
|
|||||||
return trackIndex >= _tracks.size() ? NULL : _tracks[trackIndex];
|
return trackIndex >= _tracks.size() ? NULL : _tracks[trackIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationStateData& AnimationState::getData() {
|
AnimationStateData* AnimationState::getData() {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,7 +940,7 @@ namespace Spine {
|
|||||||
entry._alpha = 1;
|
entry._alpha = 1;
|
||||||
entry._interruptAlpha = 1;
|
entry._interruptAlpha = 1;
|
||||||
entry._mixTime = 0;
|
entry._mixTime = 0;
|
||||||
entry._mixDuration = (last == NULL) ? 0 : _data.getMix(last->_animation, animation);
|
entry._mixDuration = (last == NULL) ? 0 : _data->getMix(last->_animation, animation);
|
||||||
|
|
||||||
return entryP;
|
return entryP;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,13 +34,13 @@
|
|||||||
#include <spine/Animation.h>
|
#include <spine/Animation.h>
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
AnimationStateData::AnimationStateData(SkeletonData& skeletonData) : _skeletonData(skeletonData), _defaultMix(0) {
|
AnimationStateData::AnimationStateData(SkeletonData* skeletonData) : _skeletonData(skeletonData), _defaultMix(0) {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationStateData::setMix(std::string fromName, std::string toName, float duration) {
|
void AnimationStateData::setMix(std::string fromName, std::string toName, float duration) {
|
||||||
Animation* from = _skeletonData.findAnimation(fromName);
|
Animation* from = _skeletonData->findAnimation(fromName);
|
||||||
Animation* to = _skeletonData.findAnimation(toName);
|
Animation* to = _skeletonData->findAnimation(toName);
|
||||||
|
|
||||||
setMix(from, to, duration);
|
setMix(from, to, duration);
|
||||||
}
|
}
|
||||||
@ -64,13 +64,13 @@ namespace Spine {
|
|||||||
HashMap<AnimationPair, float, HashAnimationPair>::Iterator i = _animationToMixTime.find(key);
|
HashMap<AnimationPair, float, HashAnimationPair>::Iterator i = _animationToMixTime.find(key);
|
||||||
|
|
||||||
if (i != _animationToMixTime.end()) {
|
if (i != _animationToMixTime.end()) {
|
||||||
return i.second();
|
return i.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _defaultMix;
|
return _defaultMix;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonData& AnimationStateData::getSkeletonData() {
|
SkeletonData* AnimationStateData::getSkeletonData() {
|
||||||
return _skeletonData;
|
return _skeletonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
******************************************************S**********************/
|
||||||
|
|
||||||
#include <spine/AtlasAttachmentLoader.h>
|
#include <spine/AtlasAttachmentLoader.h>
|
||||||
|
|
||||||
@ -43,7 +43,7 @@
|
|||||||
namespace Spine {
|
namespace Spine {
|
||||||
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader);
|
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader);
|
||||||
|
|
||||||
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas& atlas) : AttachmentLoader(), _atlas(atlas) {
|
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas* atlas) : AttachmentLoader(), _atlas(atlas) {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ namespace Spine {
|
|||||||
attachment._regionHeight = region.height;
|
attachment._regionHeight = region.height;
|
||||||
attachment._regionOriginalWidth = region.originalWidth;
|
attachment._regionOriginalWidth = region.originalWidth;
|
||||||
attachment._regionOriginalHeight = region.originalHeight;
|
attachment._regionOriginalHeight = region.originalHeight;
|
||||||
|
printf("New region attachment, %p %p\n", &attachmentP->getUVs(), &attachmentP->getOffset());
|
||||||
return attachmentP;
|
return attachmentP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +111,6 @@ namespace Spine {
|
|||||||
|
|
||||||
AtlasRegion* AtlasAttachmentLoader::findRegion(std::string name) {
|
AtlasRegion* AtlasAttachmentLoader::findRegion(std::string name) {
|
||||||
AtlasRegion* ret;
|
AtlasRegion* ret;
|
||||||
return _atlas.findRegion(name);
|
return _atlas->findRegion(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,9 @@ namespace Spine {
|
|||||||
Attachment::Attachment(std::string name) : _name(name) {
|
Attachment::Attachment(std::string name) : _name(name) {
|
||||||
assert(_name.length() > 0);
|
assert(_name.length() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Attachment::~Attachment() {
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& Attachment::getName() {
|
const std::string& Attachment::getName() {
|
||||||
return _name;
|
return _name;
|
||||||
|
|||||||
@ -46,6 +46,9 @@ namespace Spine {
|
|||||||
_curves.reserve((frameCount - 1) * BEZIER_SIZE);
|
_curves.reserve((frameCount - 1) * BEZIER_SIZE);
|
||||||
_curves.setSize((frameCount - 1) * BEZIER_SIZE);
|
_curves.setSize((frameCount - 1) * BEZIER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CurveTimeline::~CurveTimeline() {
|
||||||
|
}
|
||||||
|
|
||||||
int CurveTimeline::getFrameCount() {
|
int CurveTimeline::getFrameCount() {
|
||||||
return static_cast<int>(_curves.size() / BEZIER_SIZE + 1);
|
return static_cast<int>(_curves.size() / BEZIER_SIZE + 1);
|
||||||
|
|||||||
@ -78,23 +78,39 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* DefaultSpineExtension::_alloc(size_t size, const char* file, int line) {
|
void* DefaultSpineExtension::_alloc(size_t size, const char* file, int line) {
|
||||||
return ::malloc(size);
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
void* ptr = ::malloc(size);
|
||||||
|
printf("alloc %lu bytes at %p\n", size, ptr);
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* DefaultSpineExtension::_calloc(size_t size, const char* file, int line) {
|
void* DefaultSpineExtension::_calloc(size_t size, const char* file, int line) {
|
||||||
void* ptr = _alloc(size, file, line);
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
void* ptr = ::malloc(size);
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
memset(ptr, 0, size);
|
memset(ptr, 0, size);
|
||||||
}
|
}
|
||||||
|
printf("calloc %lu bytes at %p\n", size, ptr);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* DefaultSpineExtension::_realloc(void* ptr, size_t size, const char* file, int line) {
|
void* DefaultSpineExtension::_realloc(void* ptr, size_t size, const char* file, int line) {
|
||||||
return ::realloc(ptr, size);
|
void* mem = NULL;
|
||||||
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
if (ptr == NULL)
|
||||||
|
mem = ::malloc(size);
|
||||||
|
else
|
||||||
|
mem = ::realloc(ptr, size);
|
||||||
|
printf("realloc %lu bytes from %p to %p\n", size, ptr, mem);
|
||||||
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultSpineExtension::_free(void* mem, const char* file, int line) {
|
void DefaultSpineExtension::_free(void* mem, const char* file, int line) {
|
||||||
|
printf("free %p\n", mem);
|
||||||
::free(mem);
|
::free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,10 @@ namespace Spine {
|
|||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.reserve(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PathConstraintPositionTimeline::~PathConstraintPositionTimeline() {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
|
||||||
void PathConstraintPositionTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void PathConstraintPositionTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
PathConstraint* constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
PathConstraint* constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
||||||
|
|||||||
@ -53,7 +53,7 @@
|
|||||||
#include <spine/Extension.h>
|
#include <spine/Extension.h>
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
Skeleton::Skeleton(SkeletonData& skeletonData) :
|
Skeleton::Skeleton(SkeletonData* skeletonData) :
|
||||||
_data(skeletonData),
|
_data(skeletonData),
|
||||||
_skin(NULL),
|
_skin(NULL),
|
||||||
_r(1),
|
_r(1),
|
||||||
@ -65,8 +65,8 @@ namespace Spine {
|
|||||||
_flipY(false),
|
_flipY(false),
|
||||||
_x(0),
|
_x(0),
|
||||||
_y(0) {
|
_y(0) {
|
||||||
_bones.reserve(_data.getBones().size());
|
_bones.reserve(_data->getBones().size());
|
||||||
for (BoneData** i = _data.getBones().begin(); i != _data.getBones().end(); ++i) {
|
for (BoneData** i = _data->getBones().begin(); i != _data->getBones().end(); ++i) {
|
||||||
BoneData* data = (*i);
|
BoneData* data = (*i);
|
||||||
|
|
||||||
Bone* bone;
|
Bone* bone;
|
||||||
@ -82,9 +82,9 @@ namespace Spine {
|
|||||||
_bones.push_back(bone);
|
_bones.push_back(bone);
|
||||||
}
|
}
|
||||||
|
|
||||||
_slots.reserve(_data.getSlots().size());
|
_slots.reserve(_data->getSlots().size());
|
||||||
_drawOrder.reserve(_data.getSlots().size());
|
_drawOrder.reserve(_data->getSlots().size());
|
||||||
for (SlotData** i = _data.getSlots().begin(); i != _data.getSlots().end(); ++i) {
|
for (SlotData** i = _data->getSlots().begin(); i != _data->getSlots().end(); ++i) {
|
||||||
SlotData* data = (*i);
|
SlotData* data = (*i);
|
||||||
|
|
||||||
Bone* bone = _bones[data->getBoneData().getIndex()];
|
Bone* bone = _bones[data->getBoneData().getIndex()];
|
||||||
@ -94,8 +94,8 @@ namespace Spine {
|
|||||||
_drawOrder.push_back(slot);
|
_drawOrder.push_back(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ikConstraints.reserve(_data.getIkConstraints().size());
|
_ikConstraints.reserve(_data->getIkConstraints().size());
|
||||||
for (IkConstraintData** i = _data.getIkConstraints().begin(); i != _data.getIkConstraints().end(); ++i) {
|
for (IkConstraintData** i = _data->getIkConstraints().begin(); i != _data->getIkConstraints().end(); ++i) {
|
||||||
IkConstraintData* data = (*i);
|
IkConstraintData* data = (*i);
|
||||||
|
|
||||||
IkConstraint* constraint = new (__FILE__, __LINE__) IkConstraint(*data, *this);
|
IkConstraint* constraint = new (__FILE__, __LINE__) IkConstraint(*data, *this);
|
||||||
@ -103,8 +103,8 @@ namespace Spine {
|
|||||||
_ikConstraints.push_back(constraint);
|
_ikConstraints.push_back(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
_transformConstraints.reserve(_data.getTransformConstraints().size());
|
_transformConstraints.reserve(_data->getTransformConstraints().size());
|
||||||
for (TransformConstraintData** i = _data.getTransformConstraints().begin(); i != _data.getTransformConstraints().end(); ++i) {
|
for (TransformConstraintData** i = _data->getTransformConstraints().begin(); i != _data->getTransformConstraints().end(); ++i) {
|
||||||
TransformConstraintData* data = (*i);
|
TransformConstraintData* data = (*i);
|
||||||
|
|
||||||
TransformConstraint* constraint = new (__FILE__, __LINE__) TransformConstraint(*data, *this);
|
TransformConstraint* constraint = new (__FILE__, __LINE__) TransformConstraint(*data, *this);
|
||||||
@ -112,8 +112,8 @@ namespace Spine {
|
|||||||
_transformConstraints.push_back(constraint);
|
_transformConstraints.push_back(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
_pathConstraints.reserve(_data.getPathConstraints().size());
|
_pathConstraints.reserve(_data->getPathConstraints().size());
|
||||||
for (PathConstraintData** i = _data.getPathConstraints().begin(); i != _data.getPathConstraints().end(); ++i) {
|
for (PathConstraintData** i = _data->getPathConstraints().begin(); i != _data->getPathConstraints().end(); ++i) {
|
||||||
PathConstraintData* data = (*i);
|
PathConstraintData* data = (*i);
|
||||||
|
|
||||||
PathConstraint* constraint = new (__FILE__, __LINE__) PathConstraint(*data, *this);
|
PathConstraint* constraint = new (__FILE__, __LINE__) PathConstraint(*data, *this);
|
||||||
@ -286,7 +286,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::setSkin(std::string skinName) {
|
void Skeleton::setSkin(std::string skinName) {
|
||||||
Skin* foundSkin = _data.findSkin(skinName);
|
Skin* foundSkin = _data->findSkin(skinName);
|
||||||
|
|
||||||
assert(foundSkin != NULL);
|
assert(foundSkin != NULL);
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Attachment* Skeleton::getAttachment(std::string slotName, std::string attachmentName) {
|
Attachment* Skeleton::getAttachment(std::string slotName, std::string attachmentName) {
|
||||||
return getAttachment(_data.findSlotIndex(slotName), attachmentName);
|
return getAttachment(_data->findSlotIndex(slotName), attachmentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* Skeleton::getAttachment(int slotIndex, std::string attachmentName) {
|
Attachment* Skeleton::getAttachment(int slotIndex, std::string attachmentName) {
|
||||||
@ -331,7 +331,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _data.getDefaultSkin() != NULL ? _data.getDefaultSkin()->getAttachment(slotIndex, attachmentName) : NULL;
|
return _data->getDefaultSkin() != NULL ? _data->getDefaultSkin()->getAttachment(slotIndex, attachmentName) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::setAttachment(std::string slotName, std::string attachmentName) {
|
void Skeleton::setAttachment(std::string slotName, std::string attachmentName) {
|
||||||
@ -454,7 +454,7 @@ namespace Spine {
|
|||||||
return _bones.size() == 0 ? NULL : _bones[0];
|
return _bones.size() == 0 ? NULL : _bones[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const SkeletonData& Skeleton::getData() {
|
const SkeletonData* Skeleton::getData() {
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,12 +592,12 @@ namespace Spine {
|
|||||||
sortPathConstraintAttachment(_skin, slotIndex, slotBone);
|
sortPathConstraintAttachment(_skin, slotIndex, slotBone);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data._defaultSkin != NULL && _data._defaultSkin != _skin) {
|
if (_data->_defaultSkin != NULL && _data->_defaultSkin != _skin) {
|
||||||
sortPathConstraintAttachment(_data._defaultSkin, slotIndex, slotBone);
|
sortPathConstraintAttachment(_data->_defaultSkin, slotIndex, slotBone);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ii = 0, nn = static_cast<int>(_data._skins.size()); ii < nn; ++ii) {
|
for (int ii = 0, nn = static_cast<int>(_data->_skins.size()); ii < nn; ++ii) {
|
||||||
sortPathConstraintAttachment(_data._skins[ii], slotIndex, slotBone);
|
sortPathConstraintAttachment(_data->_skins[ii], slotIndex, slotBone);
|
||||||
}
|
}
|
||||||
|
|
||||||
Attachment* attachment = slot->_attachment;
|
Attachment* attachment = slot->_attachment;
|
||||||
@ -657,9 +657,9 @@ namespace Spine {
|
|||||||
HashMap<Skin::AttachmentKey, Attachment*, Skin::HashAttachmentKey>& attachments = skin->getAttachments();
|
HashMap<Skin::AttachmentKey, Attachment*, Skin::HashAttachmentKey>& attachments = skin->getAttachments();
|
||||||
|
|
||||||
for (typename HashMap<Skin::AttachmentKey, Attachment*, Skin::HashAttachmentKey>::Iterator i = attachments.begin(); i != attachments.end(); ++i) {
|
for (typename HashMap<Skin::AttachmentKey, Attachment*, Skin::HashAttachmentKey>::Iterator i = attachments.begin(); i != attachments.end(); ++i) {
|
||||||
Skin::AttachmentKey key = i.first();
|
Skin::AttachmentKey key = i.key();
|
||||||
if (key._slotIndex == slotIndex) {
|
if (key._slotIndex == slotIndex) {
|
||||||
Attachment* value = i.second();
|
Attachment* value = i.value();
|
||||||
sortPathConstraintAttachment(value, slotBone);
|
sortPathConstraintAttachment(value, slotBone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -106,7 +106,7 @@ namespace Spine {
|
|||||||
TransformMode_NoScaleOrReflection
|
TransformMode_NoScaleOrReflection
|
||||||
};
|
};
|
||||||
|
|
||||||
SkeletonBinary::SkeletonBinary(Atlas& atlasArray) : _attachmentLoader(new (__FILE__, __LINE__) AtlasAttachmentLoader(atlasArray)), _error(), _scale(1), _ownsLoader(true) {
|
SkeletonBinary::SkeletonBinary(Atlas* atlasArray) : _attachmentLoader(new (__FILE__, __LINE__) AtlasAttachmentLoader(atlasArray)), _error(), _scale(1), _ownsLoader(true) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
SkeletonJson::SkeletonJson(Atlas& atlas) : _attachmentLoader(new (__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _scale(1), _ownsLoader(true) {
|
SkeletonJson::SkeletonJson(Atlas* atlas) : _attachmentLoader(new (__FILE__, __LINE__) AtlasAttachmentLoader(atlas)), _scale(1), _ownsLoader(true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonJson::SkeletonJson(AttachmentLoader* attachmentLoader) : _attachmentLoader(attachmentLoader), _scale(1), _ownsLoader(false) {
|
SkeletonJson::SkeletonJson(AttachmentLoader* attachmentLoader) : _attachmentLoader(attachmentLoader), _scale(1), _ownsLoader(false) {
|
||||||
|
|||||||
@ -57,6 +57,16 @@ namespace Spine {
|
|||||||
Skin::Skin(std::string name) : _name(name) {
|
Skin::Skin(std::string name) : _name(name) {
|
||||||
assert(_name.length() > 0);
|
assert(_name.length() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Skin::~Skin() {
|
||||||
|
HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin();
|
||||||
|
printf("Disposing skin\n");
|
||||||
|
for (; i != _attachments.end(); ++i) {
|
||||||
|
printf("%p %s\n", i.value(), i.value()->getName().c_str());
|
||||||
|
delete i.value();
|
||||||
|
}
|
||||||
|
printf("Disposing skin done\n");
|
||||||
|
}
|
||||||
|
|
||||||
void Skin::addAttachment(int slotIndex, std::string name, Attachment* attachment) {
|
void Skin::addAttachment(int slotIndex, std::string name, Attachment* attachment) {
|
||||||
assert(attachment);
|
assert(attachment);
|
||||||
@ -70,7 +80,7 @@ namespace Spine {
|
|||||||
Attachment* ret = NULL;
|
Attachment* ret = NULL;
|
||||||
|
|
||||||
if (i != _attachments.end()) {
|
if (i != _attachments.end()) {
|
||||||
ret = i.second();
|
ret = i.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -78,16 +88,16 @@ namespace Spine {
|
|||||||
|
|
||||||
void Skin::findNamesForSlot(int slotIndex, Vector<std::string>& names) {
|
void Skin::findNamesForSlot(int slotIndex, Vector<std::string>& names) {
|
||||||
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) {
|
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) {
|
||||||
if (i.first()._slotIndex == slotIndex) {
|
if (i.key()._slotIndex == slotIndex) {
|
||||||
names.push_back(i.first()._name);
|
names.push_back(i.key()._name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skin::findAttachmentsForSlot(int slotIndex, Vector<Attachment*>& attachments) {
|
void Skin::findAttachmentsForSlot(int slotIndex, Vector<Attachment*>& attachments) {
|
||||||
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) {
|
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = _attachments.begin(); i != _attachments.end(); ++i) {
|
||||||
if (i.first()._slotIndex == slotIndex) {
|
if (i.key()._slotIndex == slotIndex) {
|
||||||
attachments.push_back(i.second());
|
attachments.push_back(i.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,12 +114,12 @@ namespace Spine {
|
|||||||
Vector<Slot*>& slots = skeleton.getSlots();
|
Vector<Slot*>& slots = skeleton.getSlots();
|
||||||
|
|
||||||
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = oldSkin.getAttachments().begin(); i != oldSkin.getAttachments().end(); ++i) {
|
for (HashMap<AttachmentKey, Attachment*, HashAttachmentKey>::Iterator i = oldSkin.getAttachments().begin(); i != oldSkin.getAttachments().end(); ++i) {
|
||||||
int slotIndex = i.first()._slotIndex;
|
int slotIndex = i.key()._slotIndex;
|
||||||
Slot* slot = slots[slotIndex];
|
Slot* slot = slots[slotIndex];
|
||||||
|
|
||||||
if (slot->getAttachment() == i.second()) {
|
if (slot->getAttachment() == i.value()) {
|
||||||
Attachment* attachment = NULL;
|
Attachment* attachment = NULL;
|
||||||
if ((attachment = getAttachment(slotIndex, i.first()._name))) {
|
if ((attachment = getAttachment(slotIndex, i.key()._name))) {
|
||||||
slot->setAttachment(attachment);
|
slot->setAttachment(attachment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,11 +34,14 @@
|
|||||||
namespace Spine {
|
namespace Spine {
|
||||||
|
|
||||||
void *SpineObject::operator new(size_t sz, const char* file, int line) {
|
void *SpineObject::operator new(size_t sz, const char* file, int line) {
|
||||||
return SpineExtension::alloc<SpineObject>(sz, file, line);
|
return SpineExtension::calloc<SpineObject>(sz, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineObject::operator delete(void *p) {
|
void SpineObject::operator delete(void *p) {
|
||||||
((SpineObject*)p)->~SpineObject();
|
|
||||||
SpineExtension::free(p, __FILE__, __LINE__);
|
SpineExtension::free(p, __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpineObject::~SpineObject() {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -54,6 +54,10 @@ namespace Spine {
|
|||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.reserve(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TranslateTimeline::~TranslateTimeline() {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
|
||||||
void TranslateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void TranslateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
Bone* boneP = skeleton._bones[_boneIndex];
|
Bone* boneP = skeleton._bones[_boneIndex];
|
||||||
|
|||||||
@ -41,6 +41,10 @@ namespace Spine {
|
|||||||
VertexAttachment::VertexAttachment(std::string name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) {
|
VertexAttachment::VertexAttachment(std::string name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) {
|
||||||
// Empty
|
// Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VertexAttachment::~VertexAttachment() {
|
||||||
|
// Empty
|
||||||
|
}
|
||||||
|
|
||||||
void VertexAttachment::computeWorldVertices(Slot& slot, Vector<float>& worldVertices) {
|
void VertexAttachment::computeWorldVertices(Slot& slot, Vector<float>& worldVertices) {
|
||||||
computeWorldVertices(slot, 0, _worldVerticesLength, worldVertices, 0);
|
computeWorldVertices(slot, 0, _worldVerticesLength, worldVertices, 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user