mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-28 12:41:25 +08:00
[cpp] Refactored String and Vector.
This commit is contained in:
parent
88a1a58813
commit
bef01b8e89
@ -98,8 +98,8 @@ void reproduceIssue_776() {
|
|||||||
loadJson(R_JSON, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
|
loadJson(R_JSON, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
|
||||||
dispose(atlas, skeletonData, stateData, skeleton, state);
|
dispose(atlas, skeletonData, stateData, skeleton, state);
|
||||||
|
|
||||||
// loadBinary(R_BINARY, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
|
loadBinary(R_BINARY, R_ATLAS, atlas, skeletonData, stateData, skeleton, state);
|
||||||
// dispose(atlas, skeletonData, stateData, skeleton, state);
|
dispose(atlas, skeletonData, stateData, skeleton, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char** argv) {
|
int main (int argc, char** argv) {
|
||||||
|
|||||||
@ -112,8 +112,8 @@ namespace Spine {
|
|||||||
T* item = items[i];
|
T* item = items[i];
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
items.erase(i);
|
items.removeAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,7 +52,7 @@ namespace Spine {
|
|||||||
if (_objects.size() > 0) {
|
if (_objects.size() > 0) {
|
||||||
T** object = _objects.begin();
|
T** object = _objects.begin();
|
||||||
T* ret = *object;
|
T* ret = *object;
|
||||||
_objects.erase(0);
|
_objects.removeAt(0);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ namespace Spine {
|
|||||||
|
|
||||||
void free(T* object) {
|
void free(T* object) {
|
||||||
if (!_objects.contains(object)) {
|
if (!_objects.contains(object)) {
|
||||||
_objects.push_back(object);
|
_objects.add(object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -101,7 +101,7 @@ namespace Spine {
|
|||||||
int _count;
|
int _count;
|
||||||
|
|
||||||
Polygon() : _count(0) {
|
Polygon() : _count(0) {
|
||||||
_vertices.reserve(16);
|
_vertices.ensureCapacity(16);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,6 +34,8 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
|
class String;
|
||||||
|
|
||||||
class SpineObject {
|
class SpineObject {
|
||||||
public:
|
public:
|
||||||
void* operator new(size_t sz, const char* file, int line);
|
void* operator new(size_t sz, const char* file, int line);
|
||||||
|
|||||||
@ -52,7 +52,7 @@ namespace Spine {
|
|||||||
_buffer = SpineExtension::alloc<char>(_length + 1, __FILE__, __LINE__);
|
_buffer = SpineExtension::alloc<char>(_length + 1, __FILE__, __LINE__);
|
||||||
memcpy((void *) _buffer, chars, _length + 1);
|
memcpy((void *) _buffer, chars, _length + 1);
|
||||||
} else {
|
} else {
|
||||||
_buffer = chars;
|
_buffer = (char*)chars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ namespace Spine {
|
|||||||
_buffer = 0;
|
_buffer = 0;
|
||||||
} else {
|
} else {
|
||||||
_length = strlen(chars);
|
_length = strlen(chars);
|
||||||
_buffer = chars;
|
_buffer = (char*)chars;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +134,26 @@ namespace Spine {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String& operator+ (const char* chars) {
|
||||||
|
size_t len = strlen(chars);
|
||||||
|
size_t thisLen = _length;
|
||||||
|
_length = _length + len;
|
||||||
|
bool same = chars == _buffer;
|
||||||
|
_buffer = SpineExtension::realloc(_buffer, _length + 1, __FILE__, __LINE__);
|
||||||
|
memcpy((void*)(_buffer + thisLen), (void*)(same ? _buffer: chars), len + 1);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
String& operator+ (const String& other) {
|
||||||
|
size_t len = other.length();
|
||||||
|
size_t thisLen = _length;
|
||||||
|
_length = _length + len;
|
||||||
|
bool same = other._buffer == _buffer;
|
||||||
|
_buffer = SpineExtension::realloc(_buffer, _length + 1, __FILE__, __LINE__);
|
||||||
|
memcpy((void*)(_buffer + thisLen), (void*)(same ? _buffer: other._buffer), len + 1);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
friend bool operator== (const String& a, const String& b) {
|
friend bool operator== (const String& a, const String& b) {
|
||||||
if (a._buffer == b._buffer) return true;
|
if (a._buffer == b._buffer) return true;
|
||||||
if (a._length != b._length) return false;
|
if (a._length != b._length) return false;
|
||||||
@ -155,7 +175,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
mutable size_t _length;
|
mutable size_t _length;
|
||||||
mutable const char* _buffer;
|
mutable char* _buffer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,6 +81,57 @@ namespace Spine {
|
|||||||
deallocate(_buffer);
|
deallocate(_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear () {
|
||||||
|
for (size_t i = 0; i < _size; ++i) {
|
||||||
|
destroy(_buffer + (_size - 1 - i));
|
||||||
|
}
|
||||||
|
|
||||||
|
_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size() const {
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSize(size_t newSize) {
|
||||||
|
assert(newSize >= 0);
|
||||||
|
_size = newSize;
|
||||||
|
if (_capacity < newSize) {
|
||||||
|
_capacity = (int)(_size * 1.75f);
|
||||||
|
if (_capacity < 8) _capacity = 8;
|
||||||
|
_buffer = Spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ensureCapacity(size_t newCapacity = 0) {
|
||||||
|
if (_capacity >= newCapacity) return;
|
||||||
|
_capacity = newCapacity;
|
||||||
|
_buffer = SpineExtension::realloc<T>(_buffer, newCapacity, __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add(const T &inValue) {
|
||||||
|
if (_size == _capacity) {
|
||||||
|
_capacity = (int)(_size * 1.75f);
|
||||||
|
if (_capacity < 8) _capacity = 8;
|
||||||
|
_buffer = Spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
|
||||||
|
}
|
||||||
|
construct(_buffer + _size++, inValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeAt(size_t inIndex) {
|
||||||
|
assert(inIndex < _size);
|
||||||
|
|
||||||
|
--_size;
|
||||||
|
|
||||||
|
if (inIndex != _size) {
|
||||||
|
for (size_t i = inIndex; i < _size; ++i) {
|
||||||
|
std::swap(_buffer[i], _buffer[i + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy(_buffer + _size);
|
||||||
|
}
|
||||||
|
|
||||||
bool contains(const T& inValue) {
|
bool contains(const T& inValue) {
|
||||||
for (size_t i = 0; i < _size; ++i) {
|
for (size_t i = 0; i < _size; ++i) {
|
||||||
if (_buffer[i] == inValue) {
|
if (_buffer[i] == inValue) {
|
||||||
@ -101,75 +152,12 @@ namespace Spine {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_back(const T& inValue) {
|
|
||||||
if (_size == _capacity) {
|
|
||||||
reserve();
|
|
||||||
}
|
|
||||||
|
|
||||||
construct(_buffer + _size++, inValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void insert(size_t inIndex, const T& inValue) {
|
|
||||||
assert(inIndex < _size);
|
|
||||||
|
|
||||||
if (_size == _capacity) {
|
|
||||||
reserve();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = ++_size - 1; i > inIndex; --i) {
|
|
||||||
construct(_buffer + i, _buffer[i - 1]);
|
|
||||||
destroy(_buffer + (i - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
construct(_buffer + inIndex, inValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
void erase(size_t inIndex) {
|
|
||||||
assert(inIndex < _size);
|
|
||||||
|
|
||||||
--_size;
|
|
||||||
|
|
||||||
if (inIndex != _size) {
|
|
||||||
for (size_t i = inIndex; i < _size; ++i) {
|
|
||||||
std::swap(_buffer[i], _buffer[i + 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy(_buffer + _size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear() {
|
|
||||||
for (size_t i = 0; i < _size; ++i) {
|
|
||||||
destroy(_buffer + (_size - 1 - i));
|
|
||||||
}
|
|
||||||
|
|
||||||
_size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t size() const {
|
|
||||||
return _size;
|
|
||||||
}
|
|
||||||
|
|
||||||
T& operator[](size_t inIndex) {
|
T& operator[](size_t inIndex) {
|
||||||
assert(inIndex < _size);
|
assert(inIndex < _size);
|
||||||
|
|
||||||
return _buffer[inIndex];
|
return _buffer[inIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
void reserve(size_t inCapacity = 0) {
|
|
||||||
size_t newCapacity = inCapacity > 0 ? inCapacity : _capacity > 0 ? _capacity * 2 : 1;
|
|
||||||
if (newCapacity > _capacity) {
|
|
||||||
_buffer = SpineExtension::realloc<T>(_buffer, newCapacity, __FILE__, __LINE__);
|
|
||||||
_capacity = newCapacity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSize(size_t inValue) {
|
|
||||||
assert(inValue <= _capacity);
|
|
||||||
|
|
||||||
_size = inValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
T* begin() {
|
T* begin() {
|
||||||
return &_buffer[0];
|
return &_buffer[0];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,22 +135,22 @@ namespace Spine {
|
|||||||
|
|
||||||
TrackEntry* TrackEntry::setTimelineData(TrackEntry* to, Vector<TrackEntry*>& mixingToArray, Vector<int>& propertyIDs) {
|
TrackEntry* TrackEntry::setTimelineData(TrackEntry* to, Vector<TrackEntry*>& mixingToArray, Vector<int>& propertyIDs) {
|
||||||
if (to != NULL) {
|
if (to != NULL) {
|
||||||
mixingToArray.push_back(to);
|
mixingToArray.add(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry* lastEntry = _mixingFrom != NULL ? _mixingFrom->setTimelineData(this, mixingToArray, propertyIDs) : this;
|
TrackEntry* lastEntry = _mixingFrom != NULL ? _mixingFrom->setTimelineData(this, mixingToArray, propertyIDs) : this;
|
||||||
|
|
||||||
if (to != NULL) {
|
if (to != NULL) {
|
||||||
mixingToArray.erase(mixingToArray.size() - 1);
|
mixingToArray.removeAt(mixingToArray.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mixingToLast = static_cast<int>(mixingToArray.size()) - 1;
|
int mixingToLast = static_cast<int>(mixingToArray.size()) - 1;
|
||||||
Vector<Timeline*>& timelines = _animation->_timelines;
|
Vector<Timeline*>& timelines = _animation->_timelines;
|
||||||
int timelinesCount = static_cast<int>(timelines.size());
|
int timelinesCount = static_cast<int>(timelines.size());
|
||||||
_timelineData.reserve(timelinesCount);
|
_timelineData.ensureCapacity(timelinesCount);
|
||||||
_timelineData.setSize(timelinesCount);
|
_timelineData.setSize(timelinesCount);
|
||||||
_timelineDipMix.clear();
|
_timelineDipMix.clear();
|
||||||
_timelineDipMix.reserve(timelinesCount);
|
_timelineDipMix.ensureCapacity(timelinesCount);
|
||||||
_timelineDipMix.setSize(timelinesCount);
|
_timelineDipMix.setSize(timelinesCount);
|
||||||
|
|
||||||
// outer:
|
// outer:
|
||||||
@ -160,7 +160,7 @@ namespace Spine {
|
|||||||
_timelineData[i] = AnimationState::Subsequent;
|
_timelineData[i] = AnimationState::Subsequent;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
propertyIDs.push_back(id);
|
propertyIDs.add(id);
|
||||||
|
|
||||||
if (to == NULL || !to->hasTimeline(id)) {
|
if (to == NULL || !to->hasTimeline(id)) {
|
||||||
_timelineData[i] = AnimationState::First;
|
_timelineData[i] = AnimationState::First;
|
||||||
@ -232,29 +232,29 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::start(TrackEntry* entry) {
|
void EventQueue::start(TrackEntry* entry) {
|
||||||
_eventQueueEntries.push_back(newEventQueueEntry(EventType_Start, entry));
|
_eventQueueEntries.add(newEventQueueEntry(EventType_Start, entry));
|
||||||
_state._animationsChanged = true;
|
_state._animationsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::interrupt(TrackEntry* entry) {
|
void EventQueue::interrupt(TrackEntry* entry) {
|
||||||
_eventQueueEntries.push_back(newEventQueueEntry(EventType_Interrupt, entry));
|
_eventQueueEntries.add(newEventQueueEntry(EventType_Interrupt, entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::end(TrackEntry* entry) {
|
void EventQueue::end(TrackEntry* entry) {
|
||||||
_eventQueueEntries.push_back(newEventQueueEntry(EventType_End, entry));
|
_eventQueueEntries.add(newEventQueueEntry(EventType_End, entry));
|
||||||
_state._animationsChanged = true;
|
_state._animationsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::dispose(TrackEntry* entry) {
|
void EventQueue::dispose(TrackEntry* entry) {
|
||||||
_eventQueueEntries.push_back(newEventQueueEntry(EventType_Dispose, entry));
|
_eventQueueEntries.add(newEventQueueEntry(EventType_Dispose, entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::complete(TrackEntry* entry) {
|
void EventQueue::complete(TrackEntry* entry) {
|
||||||
_eventQueueEntries.push_back(newEventQueueEntry(EventType_Complete, entry));
|
_eventQueueEntries.add(newEventQueueEntry(EventType_Complete, entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventQueue::event(TrackEntry* entry, Event* event) {
|
void EventQueue::event(TrackEntry* entry, Event* event) {
|
||||||
_eventQueueEntries.push_back(newEventQueueEntry(EventType_Event, entry, event));
|
_eventQueueEntries.add(newEventQueueEntry(EventType_Event, entry, event));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Raises all events in the queue and drains the queue.
|
/// Raises all events in the queue and drains the queue.
|
||||||
@ -424,7 +424,7 @@ namespace Spine {
|
|||||||
|
|
||||||
bool firstFrame = current._timelinesRotation.size() == 0;
|
bool firstFrame = current._timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
current._timelinesRotation.reserve(timelines.size() << 1);
|
current._timelinesRotation.ensureCapacity(timelines.size() << 1);
|
||||||
current._timelinesRotation.setSize(timelines.size() << 1);
|
current._timelinesRotation.setSize(timelines.size() << 1);
|
||||||
}
|
}
|
||||||
Vector<float>& timelinesRotation = current._timelinesRotation;
|
Vector<float>& timelinesRotation = current._timelinesRotation;
|
||||||
@ -781,7 +781,7 @@ namespace Spine {
|
|||||||
bool firstFrame = from->_timelinesRotation.size() == 0;
|
bool firstFrame = from->_timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
// from.timelinesRotation.setSize
|
// from.timelinesRotation.setSize
|
||||||
from->_timelinesRotation.reserve(timelines.size() << 1);
|
from->_timelinesRotation.ensureCapacity(timelines.size() << 1);
|
||||||
from->_timelinesRotation.setSize(timelines.size() << 1);
|
from->_timelinesRotation.setSize(timelines.size() << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,7 +908,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (index >= _tracks.size()) {
|
while (index >= _tracks.size()) {
|
||||||
_tracks.push_back(NULL);
|
_tracks.add(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@ -163,7 +163,7 @@ namespace Spine {
|
|||||||
|
|
||||||
SpineExtension::free(path, __FILE__, __LINE__);
|
SpineExtension::free(path, __FILE__, __LINE__);
|
||||||
|
|
||||||
_pages.push_back(page);
|
_pages.add(page);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AtlasRegion* region = new (__FILE__, __LINE__) AtlasRegion();
|
AtlasRegion* region = new (__FILE__, __LINE__) AtlasRegion();
|
||||||
@ -198,7 +198,7 @@ namespace Spine {
|
|||||||
|
|
||||||
if (count == 4) {
|
if (count == 4) {
|
||||||
/* split is optional */
|
/* split is optional */
|
||||||
region->splits.reserve(4);
|
region->splits.ensureCapacity(4);
|
||||||
region->splits.setSize(4);
|
region->splits.setSize(4);
|
||||||
region->splits[0] = toInt(tuple);
|
region->splits[0] = toInt(tuple);
|
||||||
region->splits[1] = toInt(tuple + 1);
|
region->splits[1] = toInt(tuple + 1);
|
||||||
@ -210,7 +210,7 @@ namespace Spine {
|
|||||||
|
|
||||||
if (count == 4) {
|
if (count == 4) {
|
||||||
/* pad is optional, but only present with splits */
|
/* pad is optional, but only present with splits */
|
||||||
region->pads.reserve(4);
|
region->pads.ensureCapacity(4);
|
||||||
region->pads.setSize(4);
|
region->pads.setSize(4);
|
||||||
region->pads[0] = toInt(tuple);
|
region->pads[0] = toInt(tuple);
|
||||||
region->pads[1] = toInt(tuple + 1);
|
region->pads[1] = toInt(tuple + 1);
|
||||||
@ -232,7 +232,7 @@ namespace Spine {
|
|||||||
|
|
||||||
region->index = toInt(&str);
|
region->index = toInt(&str);
|
||||||
|
|
||||||
_regions.push_back(region);
|
_regions.add(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,13 +42,13 @@ namespace Spine {
|
|||||||
RTTI_IMPL(AttachmentTimeline, Timeline);
|
RTTI_IMPL(AttachmentTimeline, Timeline);
|
||||||
|
|
||||||
AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(0) {
|
AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(0) {
|
||||||
_frames.reserve(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
_attachmentNames.reserve(frameCount);
|
_attachmentNames.ensureCapacity(frameCount);
|
||||||
|
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount);
|
||||||
|
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
_attachmentNames.push_back(String());
|
_attachmentNames.add(String());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@ namespace Spine {
|
|||||||
const int ColorTimeline::A = 4;
|
const int ColorTimeline::A = 4;
|
||||||
|
|
||||||
ColorTimeline::ColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) {
|
ColorTimeline::ColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) {
|
||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,14 +42,14 @@ namespace Spine {
|
|||||||
|
|
||||||
CurveTimeline::CurveTimeline(int frameCount) {
|
CurveTimeline::CurveTimeline(int frameCount) {
|
||||||
assert(frameCount > 0);
|
assert(frameCount > 0);
|
||||||
|
|
||||||
_curves.reserve((frameCount - 1) * BEZIER_SIZE);
|
_curves.ensureCapacity((frameCount - 1) * BEZIER_SIZE);
|
||||||
_curves.setSize((frameCount - 1) * BEZIER_SIZE);
|
_curves.setSize((frameCount - 1) * BEZIER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveTimeline::~CurveTimeline() {
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,14 +44,14 @@ namespace Spine {
|
|||||||
RTTI_IMPL(DeformTimeline, CurveTimeline);
|
RTTI_IMPL(DeformTimeline, CurveTimeline);
|
||||||
|
|
||||||
DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0), _attachment(NULL) {
|
DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0), _attachment(NULL) {
|
||||||
_frames.reserve(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
_frameVertices.reserve(frameCount);
|
_frameVertices.ensureCapacity(frameCount);
|
||||||
|
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount);
|
||||||
|
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
Vector<float> vec;
|
Vector<float> vec;
|
||||||
_frameVertices.push_back(vec);
|
_frameVertices.add(vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure size and preemptively set count.
|
// Ensure size and preemptively set count.
|
||||||
vertices.reserve(vertexCount);
|
vertices.ensureCapacity(vertexCount);
|
||||||
vertices.setSize(vertexCount);
|
vertices.setSize(vertexCount);
|
||||||
|
|
||||||
if (vertexAttachment->_bones.size() == 0) {
|
if (vertexAttachment->_bones.size() == 0) {
|
||||||
@ -111,7 +111,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure size and preemptively set count.
|
// Ensure size and preemptively set count.
|
||||||
vertices.reserve(vertexCount);
|
vertices.ensureCapacity(vertexCount);
|
||||||
vertices.setSize(vertexCount);
|
vertices.setSize(vertexCount);
|
||||||
|
|
||||||
if (time >= _frames[_frames.size() - 1]) {
|
if (time >= _frames[_frames.size() - 1]) {
|
||||||
@ -122,7 +122,7 @@ namespace Spine {
|
|||||||
vertices.clear();
|
vertices.clear();
|
||||||
for (int i = 0; i < vertexCount; ++i) {
|
for (int i = 0; i < vertexCount; ++i) {
|
||||||
float vertex = lastVertices[i];
|
float vertex = lastVertices[i];
|
||||||
vertices.push_back(vertex);
|
vertices.add(vertex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pose == MixPose_Setup) {
|
else if (pose == MixPose_Setup) {
|
||||||
|
|||||||
@ -42,14 +42,14 @@ namespace Spine {
|
|||||||
RTTI_IMPL(DrawOrderTimeline, Timeline);
|
RTTI_IMPL(DrawOrderTimeline, Timeline);
|
||||||
|
|
||||||
DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline() {
|
DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline() {
|
||||||
_frames.reserve(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
_drawOrders.reserve(frameCount);
|
_drawOrders.ensureCapacity(frameCount);
|
||||||
|
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount);
|
||||||
|
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
Vector<int> vec;
|
Vector<int> vec;
|
||||||
_drawOrders.push_back(vec);
|
_drawOrders.add(vec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,9 +58,9 @@ namespace Spine {
|
|||||||
Vector<Slot*>& slots = skeleton._slots;
|
Vector<Slot*>& slots = skeleton._slots;
|
||||||
if (direction == MixDirection_Out && pose == MixPose_Setup) {
|
if (direction == MixDirection_Out && pose == MixPose_Setup) {
|
||||||
drawOrder.clear();
|
drawOrder.clear();
|
||||||
drawOrder.reserve(slots.size());
|
drawOrder.ensureCapacity(slots.size());
|
||||||
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
||||||
drawOrder.push_back(slots[i]);
|
drawOrder.add(slots[i]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -68,9 +68,9 @@ namespace Spine {
|
|||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
if (pose == MixPose_Setup) {
|
if (pose == MixPose_Setup) {
|
||||||
drawOrder.clear();
|
drawOrder.clear();
|
||||||
drawOrder.reserve(slots.size());
|
drawOrder.ensureCapacity(slots.size());
|
||||||
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
||||||
drawOrder.push_back(slots[i]);
|
drawOrder.add(slots[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -89,7 +89,7 @@ namespace Spine {
|
|||||||
if (drawOrderToSetupIndex.size() == 0) {
|
if (drawOrderToSetupIndex.size() == 0) {
|
||||||
drawOrder.clear();
|
drawOrder.clear();
|
||||||
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
||||||
drawOrder.push_back(slots[i]);
|
drawOrder.add(slots[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@ -44,8 +44,8 @@ namespace Spine {
|
|||||||
RTTI_IMPL(EventTimeline, Timeline);
|
RTTI_IMPL(EventTimeline, Timeline);
|
||||||
|
|
||||||
EventTimeline::EventTimeline(int frameCount) : Timeline() {
|
EventTimeline::EventTimeline(int frameCount) : Timeline() {
|
||||||
_frames.reserve(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
_events.reserve(frameCount);
|
_events.ensureCapacity(frameCount);
|
||||||
|
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount);
|
||||||
_events.setSize(frameCount);
|
_events.setSize(frameCount);
|
||||||
@ -99,7 +99,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; frame < frameCount && time >= _frames[frame]; ++frame) {
|
for (; frame < frameCount && time >= _frames[frame]; ++frame) {
|
||||||
events.push_back(_events[frame]);
|
events.add(_events[frame]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -247,11 +247,11 @@ namespace Spine {
|
|||||||
_mix(data.getMix()),
|
_mix(data.getMix()),
|
||||||
_bendDirection(data.getBendDirection()),
|
_bendDirection(data.getBendDirection()),
|
||||||
_target(skeleton.findBone(data.getTarget()->getName())) {
|
_target(skeleton.findBone(data.getTarget()->getName())) {
|
||||||
_bones.reserve(_data.getBones().size());
|
_bones.ensureCapacity(_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* boneData = (*i);
|
BoneData* boneData = (*i);
|
||||||
|
|
||||||
_bones.push_back(skeleton.findBone(boneData->getName()));
|
_bones.add(skeleton.findBone(boneData->getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ namespace Spine {
|
|||||||
const int IkConstraintTimeline::BEND_DIRECTION = 2;
|
const int IkConstraintTimeline::BEND_DIRECTION = 2;
|
||||||
|
|
||||||
IkConstraintTimeline::IkConstraintTimeline(int frameCount) : CurveTimeline(frameCount), _ikConstraintIndex(0) {
|
IkConstraintTimeline::IkConstraintTimeline(int frameCount) : CurveTimeline(frameCount), _ikConstraintIndex(0) {
|
||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ namespace Spine {
|
|||||||
void MeshAttachment::updateUVs() {
|
void MeshAttachment::updateUVs() {
|
||||||
float u = _regionU, v = _regionV, width = _regionU2 - _regionU, height = _regionV2 - _regionV;
|
float u = _regionU, v = _regionV, width = _regionU2 - _regionU, height = _regionV2 - _regionV;
|
||||||
if (_uvs.size() != _regionUVs.size()) {
|
if (_uvs.size() != _regionUVs.size()) {
|
||||||
_uvs.reserve(_regionUVs.size());
|
_uvs.ensureCapacity(_regionUVs.size());
|
||||||
_uvs.setSize(_regionUVs.size());
|
_uvs.setSize(_regionUVs.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,14 +58,14 @@ namespace Spine {
|
|||||||
_spacing(data.getSpacing()),
|
_spacing(data.getSpacing()),
|
||||||
_rotateMix(data.getRotateMix()),
|
_rotateMix(data.getRotateMix()),
|
||||||
_translateMix(data.getTranslateMix()) {
|
_translateMix(data.getTranslateMix()) {
|
||||||
_bones.reserve(_data.getBones().size());
|
_bones.ensureCapacity(_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* boneData = (*i);
|
BoneData* boneData = (*i);
|
||||||
|
|
||||||
_bones.push_back(skeleton.findBone(boneData->getName()));
|
_bones.add(skeleton.findBone(boneData->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
_segments.reserve(10);
|
_segments.ensureCapacity(10);
|
||||||
_segments.setSize(10);
|
_segments.setSize(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,12 +96,12 @@ namespace Spine {
|
|||||||
bool tangents = rotateMode == RotateMode_Tangent, scale = rotateMode == RotateMode_ChainScale;
|
bool tangents = rotateMode == RotateMode_Tangent, scale = rotateMode == RotateMode_ChainScale;
|
||||||
size_t boneCount = _bones.size();
|
size_t boneCount = _bones.size();
|
||||||
int spacesCount = static_cast<int>(tangents ? boneCount : boneCount + 1);
|
int spacesCount = static_cast<int>(tangents ? boneCount : boneCount + 1);
|
||||||
_spaces.reserve(spacesCount);
|
_spaces.ensureCapacity(spacesCount);
|
||||||
_spaces.setSize(spacesCount);
|
_spaces.setSize(spacesCount);
|
||||||
float spacing = _spacing;
|
float spacing = _spacing;
|
||||||
if (scale || lengthSpacing) {
|
if (scale || lengthSpacing) {
|
||||||
if (scale) {
|
if (scale) {
|
||||||
_lengths.reserve(boneCount);
|
_lengths.ensureCapacity(boneCount);
|
||||||
_lengths.setSize(boneCount);
|
_lengths.setSize(boneCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ namespace Spine {
|
|||||||
Vector<float> PathConstraint::computeWorldPositions(PathAttachment& path, int spacesCount, bool tangents, bool percentPosition, bool percentSpacing) {
|
Vector<float> PathConstraint::computeWorldPositions(PathAttachment& path, int spacesCount, bool tangents, bool percentPosition, bool percentSpacing) {
|
||||||
Slot& target = *_target;
|
Slot& target = *_target;
|
||||||
float position = _position;
|
float position = _position;
|
||||||
_positions.reserve(spacesCount * 3 + 2);
|
_positions.ensureCapacity(spacesCount * 3 + 2);
|
||||||
_positions.setSize(spacesCount * 3 + 2);
|
_positions.setSize(spacesCount * 3 + 2);
|
||||||
bool closed = path.isClosed();
|
bool closed = path.isClosed();
|
||||||
int verticesLength = path.getWorldVerticesLength();
|
int verticesLength = path.getWorldVerticesLength();
|
||||||
@ -289,8 +289,8 @@ namespace Spine {
|
|||||||
_spaces[i] *= pathLength;
|
_spaces[i] *= pathLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_world.reserve(8);
|
_world.ensureCapacity(8);
|
||||||
_world.setSize(8);
|
_world.setSize(8);
|
||||||
for (int i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {
|
for (int i = 0, o = 0, curve = 0; i < spacesCount; i++, o += 3) {
|
||||||
float space = _spaces[i];
|
float space = _spaces[i];
|
||||||
@ -362,7 +362,7 @@ namespace Spine {
|
|||||||
// World vertices.
|
// World vertices.
|
||||||
if (closed) {
|
if (closed) {
|
||||||
verticesLength += 2;
|
verticesLength += 2;
|
||||||
_world.reserve(verticesLength);
|
_world.ensureCapacity(verticesLength);
|
||||||
_world.setSize(verticesLength);
|
_world.setSize(verticesLength);
|
||||||
path.computeWorldVertices(target, 2, verticesLength - 4, _world, 0);
|
path.computeWorldVertices(target, 2, verticesLength - 4, _world, 0);
|
||||||
path.computeWorldVertices(target, 0, 2, _world, verticesLength - 4);
|
path.computeWorldVertices(target, 0, 2, _world, verticesLength - 4);
|
||||||
@ -372,13 +372,13 @@ namespace Spine {
|
|||||||
else {
|
else {
|
||||||
curveCount--;
|
curveCount--;
|
||||||
verticesLength -= 4;
|
verticesLength -= 4;
|
||||||
_world.reserve(verticesLength);
|
_world.ensureCapacity(verticesLength);
|
||||||
_world.setSize(verticesLength);
|
_world.setSize(verticesLength);
|
||||||
path.computeWorldVertices(target, 2, verticesLength, _world, 0);
|
path.computeWorldVertices(target, 2, verticesLength, _world, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Curve lengths.
|
// Curve lengths.
|
||||||
_curves.reserve(curveCount);
|
_curves.ensureCapacity(curveCount);
|
||||||
_curves.setSize(curveCount);
|
_curves.setSize(curveCount);
|
||||||
pathLength = 0;
|
pathLength = 0;
|
||||||
float x1 = _world[0], y1 = _world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
|
float x1 = _world[0], y1 = _world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
|
||||||
|
|||||||
@ -51,7 +51,7 @@ namespace Spine {
|
|||||||
const int PathConstraintMixTimeline::TRANSLATE = 2;
|
const int PathConstraintMixTimeline::TRANSLATE = 2;
|
||||||
|
|
||||||
PathConstraintMixTimeline::PathConstraintMixTimeline(int frameCount) : CurveTimeline(frameCount), _pathConstraintIndex(0) {
|
PathConstraintMixTimeline::PathConstraintMixTimeline(int frameCount) : CurveTimeline(frameCount), _pathConstraintIndex(0) {
|
||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace Spine {
|
|||||||
const int PathConstraintPositionTimeline::VALUE = 1;
|
const int PathConstraintPositionTimeline::VALUE = 1;
|
||||||
|
|
||||||
PathConstraintPositionTimeline::PathConstraintPositionTimeline(int frameCount) : CurveTimeline(frameCount), _pathConstraintIndex(0) {
|
PathConstraintPositionTimeline::PathConstraintPositionTimeline(int frameCount) : CurveTimeline(frameCount), _pathConstraintIndex(0) {
|
||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -72,8 +72,8 @@ namespace Spine {
|
|||||||
_g(0),
|
_g(0),
|
||||||
_b(0),
|
_b(0),
|
||||||
_a(0) {
|
_a(0) {
|
||||||
_offset.reserve(NUM_UVS);
|
_offset.ensureCapacity(NUM_UVS);
|
||||||
_uvs.reserve(NUM_UVS);
|
_uvs.ensureCapacity(NUM_UVS);
|
||||||
|
|
||||||
_offset.setSize(NUM_UVS);
|
_offset.setSize(NUM_UVS);
|
||||||
_uvs.setSize(NUM_UVS);
|
_uvs.setSize(NUM_UVS);
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace Spine {
|
|||||||
RTTI_IMPL(RotateTimeline, CurveTimeline);
|
RTTI_IMPL(RotateTimeline, CurveTimeline);
|
||||||
|
|
||||||
RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
||||||
_frames.reserve(frameCount << 1);
|
_frames.ensureCapacity(frameCount << 1);
|
||||||
_frames.setSize(frameCount << 1);
|
_frames.setSize(frameCount << 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,7 +65,7 @@ namespace Spine {
|
|||||||
_flipY(false),
|
_flipY(false),
|
||||||
_x(0),
|
_x(0),
|
||||||
_y(0) {
|
_y(0) {
|
||||||
_bones.reserve(_data->getBones().size());
|
_bones.ensureCapacity(_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);
|
||||||
|
|
||||||
@ -76,49 +76,49 @@ namespace Spine {
|
|||||||
else {
|
else {
|
||||||
Bone* parent = _bones[data->getParent()->getIndex()];
|
Bone* parent = _bones[data->getParent()->getIndex()];
|
||||||
bone = new (__FILE__, __LINE__) Bone(*data, *this, parent);
|
bone = new (__FILE__, __LINE__) Bone(*data, *this, parent);
|
||||||
parent->getChildren().push_back(bone);
|
parent->getChildren().add(bone);
|
||||||
}
|
}
|
||||||
|
|
||||||
_bones.push_back(bone);
|
_bones.add(bone);
|
||||||
}
|
}
|
||||||
|
|
||||||
_slots.reserve(_data->getSlots().size());
|
_slots.ensureCapacity(_data->getSlots().size());
|
||||||
_drawOrder.reserve(_data->getSlots().size());
|
_drawOrder.ensureCapacity(_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()];
|
||||||
Slot* slot = new (__FILE__, __LINE__) Slot(*data, *bone);
|
Slot* slot = new (__FILE__, __LINE__) Slot(*data, *bone);
|
||||||
|
|
||||||
_slots.push_back(slot);
|
_slots.add(slot);
|
||||||
_drawOrder.push_back(slot);
|
_drawOrder.add(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ikConstraints.reserve(_data->getIkConstraints().size());
|
_ikConstraints.ensureCapacity(_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);
|
||||||
|
|
||||||
_ikConstraints.push_back(constraint);
|
_ikConstraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
_transformConstraints.reserve(_data->getTransformConstraints().size());
|
_transformConstraints.ensureCapacity(_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);
|
||||||
|
|
||||||
_transformConstraints.push_back(constraint);
|
_transformConstraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
_pathConstraints.reserve(_data->getPathConstraints().size());
|
_pathConstraints.ensureCapacity(_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);
|
||||||
|
|
||||||
_pathConstraints.push_back(constraint);
|
_pathConstraints.add(constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCache();
|
updateCache();
|
||||||
@ -261,7 +261,7 @@ namespace Spine {
|
|||||||
void Skeleton::setSlotsToSetupPose() {
|
void Skeleton::setSlotsToSetupPose() {
|
||||||
_drawOrder.clear();
|
_drawOrder.clear();
|
||||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
||||||
_drawOrder.push_back(_slots[i]);
|
_drawOrder.add(_slots[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
||||||
@ -416,7 +416,7 @@ namespace Spine {
|
|||||||
|
|
||||||
verticesLength = 8;
|
verticesLength = 8;
|
||||||
if (outVertexBuffer.size() < 8) {
|
if (outVertexBuffer.size() < 8) {
|
||||||
outVertexBuffer.reserve(8);
|
outVertexBuffer.ensureCapacity(8);
|
||||||
outVertexBuffer.setSize(8);
|
outVertexBuffer.setSize(8);
|
||||||
}
|
}
|
||||||
regionAttachment->computeWorldVertices(slot->getBone(), outVertexBuffer, 0);
|
regionAttachment->computeWorldVertices(slot->getBone(), outVertexBuffer, 0);
|
||||||
@ -426,7 +426,7 @@ namespace Spine {
|
|||||||
|
|
||||||
verticesLength = mesh->getWorldVerticesLength();
|
verticesLength = mesh->getWorldVerticesLength();
|
||||||
if (outVertexBuffer.size() < verticesLength) {
|
if (outVertexBuffer.size() < verticesLength) {
|
||||||
outVertexBuffer.reserve(verticesLength);
|
outVertexBuffer.ensureCapacity(verticesLength);
|
||||||
outVertexBuffer.setSize(verticesLength);
|
outVertexBuffer.setSize(verticesLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,11 +573,11 @@ namespace Spine {
|
|||||||
if (constrained.size() > 1) {
|
if (constrained.size() > 1) {
|
||||||
Bone* child = constrained[constrained.size() - 1];
|
Bone* child = constrained[constrained.size() - 1];
|
||||||
if (!_updateCache.contains(child)) {
|
if (!_updateCache.contains(child)) {
|
||||||
_updateCacheReset.push_back(child);
|
_updateCacheReset.add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateCache.push_back(constraint);
|
_updateCache.add(constraint);
|
||||||
|
|
||||||
sortReset(parent->getChildren());
|
sortReset(parent->getChildren());
|
||||||
constrained[constrained.size() - 1]->_sorted = true;
|
constrained[constrained.size() - 1]->_sorted = true;
|
||||||
@ -610,8 +610,8 @@ namespace Spine {
|
|||||||
for (int i = 0; i < boneCount; ++i) {
|
for (int i = 0; i < boneCount; ++i) {
|
||||||
sortBone(constrained[i]);
|
sortBone(constrained[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateCache.push_back(constraint);
|
_updateCache.add(constraint);
|
||||||
|
|
||||||
for (int i = 0; i < boneCount; ++i) {
|
for (int i = 0; i < boneCount; ++i) {
|
||||||
sortReset(constrained[i]->getChildren());
|
sortReset(constrained[i]->getChildren());
|
||||||
@ -632,7 +632,7 @@ namespace Spine {
|
|||||||
Bone* child = constrained[i];
|
Bone* child = constrained[i];
|
||||||
sortBone(child->getParent());
|
sortBone(child->getParent());
|
||||||
if (!_updateCache.contains(child)) {
|
if (!_updateCache.contains(child)) {
|
||||||
_updateCacheReset.push_back(child);
|
_updateCacheReset.add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -641,8 +641,8 @@ namespace Spine {
|
|||||||
sortBone(constrained[i]);
|
sortBone(constrained[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateCache.push_back(constraint);
|
_updateCache.add(constraint);
|
||||||
|
|
||||||
for (int i = 0; i < boneCount; ++i) {
|
for (int i = 0; i < boneCount; ++i) {
|
||||||
sortReset(constrained[i]->getChildren());
|
sortReset(constrained[i]->getChildren());
|
||||||
@ -700,8 +700,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bone->_sorted = true;
|
bone->_sorted = true;
|
||||||
|
|
||||||
_updateCache.push_back(bone);
|
_updateCache.add(bone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::sortReset(Vector<Bone*>& bones) {
|
void Skeleton::sortReset(Vector<Bone*>& bones) {
|
||||||
|
|||||||
@ -154,7 +154,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Bones. */
|
/* Bones. */
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
skeletonData->_bones.reserve(bonesCount);
|
skeletonData->_bones.ensureCapacity(bonesCount);
|
||||||
skeletonData->_bones.setSize(bonesCount);
|
skeletonData->_bones.setSize(bonesCount);
|
||||||
for (i = 0; i < bonesCount; ++i) {
|
for (i = 0; i < bonesCount; ++i) {
|
||||||
BoneData* data;
|
BoneData* data;
|
||||||
@ -201,7 +201,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Slots. */
|
/* Slots. */
|
||||||
int slotsCount = readVarint(input, true);
|
int slotsCount = readVarint(input, true);
|
||||||
skeletonData->_slots.reserve(slotsCount);
|
skeletonData->_slots.ensureCapacity(slotsCount);
|
||||||
skeletonData->_slots.setSize(slotsCount);
|
skeletonData->_slots.setSize(slotsCount);
|
||||||
for (i = 0; i < slotsCount; ++i) {
|
for (i = 0; i < slotsCount; ++i) {
|
||||||
int r, g, b, a;
|
int r, g, b, a;
|
||||||
@ -228,7 +228,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* IK constraints. */
|
/* IK constraints. */
|
||||||
int ikConstraintsCount = readVarint(input, true);
|
int ikConstraintsCount = readVarint(input, true);
|
||||||
skeletonData->_ikConstraints.reserve(ikConstraintsCount);
|
skeletonData->_ikConstraints.ensureCapacity(ikConstraintsCount);
|
||||||
skeletonData->_ikConstraints.setSize(ikConstraintsCount);
|
skeletonData->_ikConstraints.setSize(ikConstraintsCount);
|
||||||
for (i = 0; i < ikConstraintsCount; ++i) {
|
for (i = 0; i < ikConstraintsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
@ -238,7 +238,7 @@ namespace Spine {
|
|||||||
data->_order = readVarint(input, true);
|
data->_order = readVarint(input, true);
|
||||||
|
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
data->_bones.reserve(bonesCount);
|
data->_bones.ensureCapacity(bonesCount);
|
||||||
data->_bones.setSize(bonesCount);
|
data->_bones.setSize(bonesCount);
|
||||||
for (ii = 0; ii < bonesCount; ++ii) {
|
for (ii = 0; ii < bonesCount; ++ii) {
|
||||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||||
@ -252,7 +252,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Transform constraints. */
|
/* Transform constraints. */
|
||||||
int transformConstraintsCount = readVarint(input, true);
|
int transformConstraintsCount = readVarint(input, true);
|
||||||
skeletonData->_transformConstraints.reserve(transformConstraintsCount);
|
skeletonData->_transformConstraints.ensureCapacity(transformConstraintsCount);
|
||||||
skeletonData->_transformConstraints.setSize(transformConstraintsCount);
|
skeletonData->_transformConstraints.setSize(transformConstraintsCount);
|
||||||
for (i = 0; i < transformConstraintsCount; ++i) {
|
for (i = 0; i < transformConstraintsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
@ -261,7 +261,7 @@ namespace Spine {
|
|||||||
|
|
||||||
data->_order = readVarint(input, true);
|
data->_order = readVarint(input, true);
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
data->_bones.reserve(bonesCount);
|
data->_bones.ensureCapacity(bonesCount);
|
||||||
data->_bones.setSize(bonesCount);
|
data->_bones.setSize(bonesCount);
|
||||||
for (ii = 0; ii < bonesCount; ++ii) {
|
for (ii = 0; ii < bonesCount; ++ii) {
|
||||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||||
@ -285,7 +285,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Path constraints */
|
/* Path constraints */
|
||||||
int pathConstraintsCount = readVarint(input, true);
|
int pathConstraintsCount = readVarint(input, true);
|
||||||
skeletonData->_pathConstraints.reserve(pathConstraintsCount);
|
skeletonData->_pathConstraints.ensureCapacity(pathConstraintsCount);
|
||||||
skeletonData->_pathConstraints.setSize(pathConstraintsCount);
|
skeletonData->_pathConstraints.setSize(pathConstraintsCount);
|
||||||
for (i = 0; i < pathConstraintsCount; ++i) {
|
for (i = 0; i < pathConstraintsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
@ -295,7 +295,7 @@ namespace Spine {
|
|||||||
data->_order = readVarint(input, true);
|
data->_order = readVarint(input, true);
|
||||||
|
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
data->_bones.reserve(bonesCount);
|
data->_bones.ensureCapacity(bonesCount);
|
||||||
data->_bones.setSize(bonesCount);
|
data->_bones.setSize(bonesCount);
|
||||||
for (ii = 0; ii < bonesCount; ++ii) {
|
for (ii = 0; ii < bonesCount; ++ii) {
|
||||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||||
@ -328,7 +328,7 @@ namespace Spine {
|
|||||||
++skinsCount;
|
++skinsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
skeletonData->_skins.reserve(skinsCount);
|
skeletonData->_skins.ensureCapacity(skinsCount);
|
||||||
skeletonData->_skins.setSize(skinsCount);
|
skeletonData->_skins.setSize(skinsCount);
|
||||||
|
|
||||||
if (skeletonData->_defaultSkin) {
|
if (skeletonData->_defaultSkin) {
|
||||||
@ -366,7 +366,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Events. */
|
/* Events. */
|
||||||
int eventsCount = readVarint(input, true);
|
int eventsCount = readVarint(input, true);
|
||||||
skeletonData->_events.reserve(eventsCount);
|
skeletonData->_events.ensureCapacity(eventsCount);
|
||||||
skeletonData->_events.setSize(eventsCount);
|
skeletonData->_events.setSize(eventsCount);
|
||||||
for (i = 0; i < eventsCount; ++i) {
|
for (i = 0; i < eventsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
@ -380,7 +380,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Animations. */
|
/* Animations. */
|
||||||
int animationsCount = readVarint(input, true);
|
int animationsCount = readVarint(input, true);
|
||||||
skeletonData->_animations.reserve(animationsCount);
|
skeletonData->_animations.ensureCapacity(animationsCount);
|
||||||
skeletonData->_animations.setSize(animationsCount);
|
skeletonData->_animations.setSize(animationsCount);
|
||||||
for (i = 0; i < animationsCount; ++i) {
|
for (i = 0; i < animationsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
@ -634,7 +634,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(skinName), slotIndex, String(parent));
|
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(skinName), slotIndex, String(parent));
|
||||||
_linkedMeshes.push_back(linkedMesh);
|
_linkedMeshes.add(linkedMesh);
|
||||||
|
|
||||||
if (freeName) {
|
if (freeName) {
|
||||||
SpineExtension::free(name, __FILE__, __LINE__);
|
SpineExtension::free(name, __FILE__, __LINE__);
|
||||||
@ -653,7 +653,7 @@ namespace Spine {
|
|||||||
vertexCount = readVarint(input, true);
|
vertexCount = readVarint(input, true);
|
||||||
readVertices(input, static_cast<VertexAttachment*>(path), vertexCount);
|
readVertices(input, static_cast<VertexAttachment*>(path), vertexCount);
|
||||||
int lengthsLength = vertexCount / 3;
|
int lengthsLength = vertexCount / 3;
|
||||||
path->_lengths.reserve(lengthsLength);
|
path->_lengths.ensureCapacity(lengthsLength);
|
||||||
path->_lengths.setSize(lengthsLength);
|
path->_lengths.setSize(lengthsLength);
|
||||||
for (i = 0; i < lengthsLength; ++i) {
|
for (i = 0; i < lengthsLength; ++i) {
|
||||||
path->_lengths[i] = readFloat(input) * _scale;
|
path->_lengths[i] = readFloat(input) * _scale;
|
||||||
@ -721,17 +721,17 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vertices vertices;
|
Vertices vertices;
|
||||||
vertices._bones.reserve(verticesLength * 3);
|
vertices._bones.ensureCapacity(verticesLength * 3);
|
||||||
vertices._vertices.reserve(verticesLength * 3 * 3);
|
vertices._vertices.ensureCapacity(verticesLength * 3 * 3);
|
||||||
|
|
||||||
for (int i = 0; i < vertexCount; ++i) {
|
for (int i = 0; i < vertexCount; ++i) {
|
||||||
int boneCount = readVarint(input, true);
|
int boneCount = readVarint(input, true);
|
||||||
vertices._bones.push_back(boneCount);
|
vertices._bones.add(boneCount);
|
||||||
for (int ii = 0; ii < boneCount; ++ii) {
|
for (int ii = 0; ii < boneCount; ++ii) {
|
||||||
vertices._bones.push_back(readVarint(input, true));
|
vertices._bones.add(readVarint(input, true));
|
||||||
vertices._vertices.push_back(readFloat(input) * scale);
|
vertices._vertices.add(readFloat(input) * scale);
|
||||||
vertices._vertices.push_back(readFloat(input) * scale);
|
vertices._vertices.add(readFloat(input) * scale);
|
||||||
vertices._vertices.push_back(readFloat(input));
|
vertices._vertices.add(readFloat(input));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,7 +741,7 @@ namespace Spine {
|
|||||||
|
|
||||||
Vector<float> SkeletonBinary::readFloatArray(DataInput *input, int n, float scale) {
|
Vector<float> SkeletonBinary::readFloatArray(DataInput *input, int n, float scale) {
|
||||||
Vector<float> array;
|
Vector<float> array;
|
||||||
array.reserve(n);
|
array.ensureCapacity(n);
|
||||||
array.setSize(n);
|
array.setSize(n);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -763,7 +763,7 @@ namespace Spine {
|
|||||||
int n = readVarint(input, true);
|
int n = readVarint(input, true);
|
||||||
|
|
||||||
Vector<short> array;
|
Vector<short> array;
|
||||||
array.reserve(n);
|
array.ensureCapacity(n);
|
||||||
array.setSize(n);
|
array.setSize(n);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@ -791,10 +791,9 @@ namespace Spine {
|
|||||||
AttachmentTimeline* timeline = new (__FILE__, __LINE__) AttachmentTimeline(frameCount);
|
AttachmentTimeline* timeline = new (__FILE__, __LINE__) AttachmentTimeline(frameCount);
|
||||||
timeline->_slotIndex = slotIndex;
|
timeline->_slotIndex = slotIndex;
|
||||||
for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
const char* attachmentName = readString(input);
|
timeline->setFrame(frameIndex, readFloat(input), String(readString(input), true));
|
||||||
timeline->setFrame(frameIndex, readFloat(input), String(attachmentName, true));
|
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[frameCount - 1]);
|
duration = MAX(duration, timeline->_frames[frameCount - 1]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -813,7 +812,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * ColorTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * ColorTimeline::ENTRIES]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -837,7 +836,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * TwoColorTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * TwoColorTimeline::ENTRIES]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -866,7 +865,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * RotateTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * RotateTimeline::ENTRIES]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -892,7 +891,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * TranslateTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * TranslateTimeline::ENTRIES]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -917,7 +916,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * IkConstraintTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * IkConstraintTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,7 +932,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * TransformConstraintTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * TransformConstraintTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -970,7 +969,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintPositionTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintPositionTimeline::ENTRIES]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -984,7 +983,7 @@ namespace Spine {
|
|||||||
readCurve(input, frameIndex, timeline);
|
readCurve(input, frameIndex, timeline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintMixTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(frameCount - 1) * PathConstraintMixTimeline::ENTRIES]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1026,9 +1025,9 @@ namespace Spine {
|
|||||||
int end = readVarint(input, true);
|
int end = readVarint(input, true);
|
||||||
if (end == 0) {
|
if (end == 0) {
|
||||||
if (weighted) {
|
if (weighted) {
|
||||||
deform.reserve(deformLength);
|
deform.setSize(deformLength);
|
||||||
for (int i = 0; i < deformLength; ++i) {
|
for (int i = 0; i < deformLength; ++i) {
|
||||||
deform.push_back(0);
|
deform.add(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1036,7 +1035,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deform.reserve(deformLength);
|
deform.setSize(deformLength);
|
||||||
int start = readVarint(input, true);
|
int start = readVarint(input, true);
|
||||||
end += start;
|
end += start;
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
@ -1063,7 +1062,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[frameCount - 1]);
|
duration = MAX(duration, timeline->_frames[frameCount - 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1080,13 +1079,13 @@ namespace Spine {
|
|||||||
int offsetCount = readVarint(input, true);
|
int offsetCount = readVarint(input, true);
|
||||||
|
|
||||||
Vector<int> drawOrder;
|
Vector<int> drawOrder;
|
||||||
drawOrder.reserve(slotCount);
|
drawOrder.ensureCapacity(slotCount);
|
||||||
for (int ii = slotCount - 1; ii >= 0; --ii) {
|
for (int ii = slotCount - 1; ii >= 0; --ii) {
|
||||||
drawOrder[ii] = -1;
|
drawOrder[ii] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<int> unchanged;
|
Vector<int> unchanged;
|
||||||
unchanged.reserve(slotCount - offsetCount);
|
unchanged.ensureCapacity(slotCount - offsetCount);
|
||||||
int originalIndex = 0, unchangedIndex = 0;
|
int originalIndex = 0, unchangedIndex = 0;
|
||||||
for (int ii = 0; ii < offsetCount; ++ii) {
|
for (int ii = 0; ii < offsetCount; ++ii) {
|
||||||
int slotIndex = readVarint(input, true);
|
int slotIndex = readVarint(input, true);
|
||||||
@ -1112,7 +1111,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
timeline->setFrame(i, time, drawOrder);
|
timeline->setFrame(i, time, drawOrder);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[drawOrderCount - 1]);
|
duration = MAX(duration, timeline->_frames[drawOrderCount - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,7 +1136,7 @@ namespace Spine {
|
|||||||
timeline->setFrame(i, event);
|
timeline->setFrame(i, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
duration = MAX(duration, timeline->_frames[eventCount - 1]);
|
duration = MAX(duration, timeline->_frames[eventCount - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace Spine {
|
|||||||
|
|
||||||
_boundingBoxes.clear();
|
_boundingBoxes.clear();
|
||||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i) {
|
||||||
_polygonPool.push_back(_polygons[i]);
|
_polygonPool.add(_polygons[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_polygons.clear();
|
_polygons.clear();
|
||||||
@ -59,26 +59,26 @@ namespace Spine {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BoundingBoxAttachment* boundingBox = static_cast<BoundingBoxAttachment*>(attachment);
|
BoundingBoxAttachment* boundingBox = static_cast<BoundingBoxAttachment*>(attachment);
|
||||||
_boundingBoxes.push_back(boundingBox);
|
_boundingBoxes.add(boundingBox);
|
||||||
|
|
||||||
Polygon* polygonP = NULL;
|
Polygon* polygonP = NULL;
|
||||||
int poolCount = static_cast<int>(_polygonPool.size());
|
int poolCount = static_cast<int>(_polygonPool.size());
|
||||||
if (poolCount > 0) {
|
if (poolCount > 0) {
|
||||||
polygonP = _polygonPool[poolCount - 1];
|
polygonP = _polygonPool[poolCount - 1];
|
||||||
_polygonPool.erase(poolCount - 1);
|
_polygonPool.removeAt(poolCount - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Polygon* polygonP = new (__FILE__, __LINE__) Polygon();
|
Polygon* polygonP = new (__FILE__, __LINE__) Polygon();
|
||||||
}
|
}
|
||||||
|
|
||||||
_polygons.push_back(polygonP);
|
_polygons.add(polygonP);
|
||||||
|
|
||||||
Polygon& polygon = *polygonP;
|
Polygon& polygon = *polygonP;
|
||||||
|
|
||||||
int count = boundingBox->getWorldVerticesLength();
|
int count = boundingBox->getWorldVerticesLength();
|
||||||
polygon._count = count;
|
polygon._count = count;
|
||||||
if (polygon._vertices.size() < count) {
|
if (polygon._vertices.size() < count) {
|
||||||
polygon._vertices.reserve(count);
|
polygon._vertices.ensureCapacity(count);
|
||||||
}
|
}
|
||||||
boundingBox->computeWorldVertices(*slot, polygon._vertices);
|
boundingBox->computeWorldVertices(*slot, polygon._vertices);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,10 +35,10 @@
|
|||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
SkeletonClipping::SkeletonClipping() : _clipAttachment(NULL) {
|
SkeletonClipping::SkeletonClipping() : _clipAttachment(NULL) {
|
||||||
_clipOutput.reserve(128);
|
_clipOutput.ensureCapacity(128);
|
||||||
_clippedVertices.reserve(128);
|
_clippedVertices.ensureCapacity(128);
|
||||||
_clippedTriangles.reserve(128);
|
_clippedTriangles.ensureCapacity(128);
|
||||||
_clippedUVs.reserve(128);
|
_clippedUVs.ensureCapacity(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SkeletonClipping::clipStart(Slot& slot, ClippingAttachment* clip) {
|
int SkeletonClipping::clipStart(Slot& slot, ClippingAttachment* clip) {
|
||||||
@ -49,7 +49,7 @@ namespace Spine {
|
|||||||
_clipAttachment = clip;
|
_clipAttachment = clip;
|
||||||
|
|
||||||
int n = clip->getWorldVerticesLength();
|
int n = clip->getWorldVerticesLength();
|
||||||
_clippingPolygon.reserve(n);
|
_clippingPolygon.ensureCapacity(n);
|
||||||
_clippingPolygon.setSize(n);
|
_clippingPolygon.setSize(n);
|
||||||
clip->computeWorldVertices(slot, 0, n, _clippingPolygon, 0, 2);
|
clip->computeWorldVertices(slot, 0, n, _clippingPolygon, 0, 2);
|
||||||
makeClockwise(_clippingPolygon);
|
makeClockwise(_clippingPolygon);
|
||||||
@ -61,8 +61,8 @@ namespace Spine {
|
|||||||
Vector<float>* polygonP = (*i);
|
Vector<float>* polygonP = (*i);
|
||||||
Vector<float>& polygon = *polygonP;
|
Vector<float>& polygon = *polygonP;
|
||||||
makeClockwise(polygon);
|
makeClockwise(polygon);
|
||||||
polygon.push_back(polygon[0]);
|
polygon.add(polygon[0]);
|
||||||
polygon.push_back(polygon[1]);
|
polygon.add(polygon[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<int>(_clippingPolygons.size());
|
return static_cast<int>(_clippingPolygons.size());
|
||||||
@ -122,9 +122,9 @@ namespace Spine {
|
|||||||
float d = 1 / (d0 * d2 + d1 * (y1 - y3));
|
float d = 1 / (d0 * d2 + d1 * (y1 - y3));
|
||||||
|
|
||||||
int clipOutputCount = clipOutputLength >> 1;
|
int clipOutputCount = clipOutputLength >> 1;
|
||||||
clippedVertices.reserve(s + clipOutputCount * 2);
|
clippedVertices.ensureCapacity(s + clipOutputCount * 2);
|
||||||
clippedVertices.setSize(s + clipOutputCount * 2);
|
clippedVertices.setSize(s + clipOutputCount * 2);
|
||||||
_clippedUVs.reserve(s + clipOutputCount * 2);
|
_clippedUVs.ensureCapacity(s + clipOutputCount * 2);
|
||||||
_clippedUVs.setSize(s + clipOutputCount * 2);
|
_clippedUVs.setSize(s + clipOutputCount * 2);
|
||||||
for (int ii = 0; ii < clipOutputLength; ii += 2) {
|
for (int ii = 0; ii < clipOutputLength; ii += 2) {
|
||||||
float x = clipOutput[ii], y = clipOutput[ii + 1];
|
float x = clipOutput[ii], y = clipOutput[ii + 1];
|
||||||
@ -140,7 +140,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s = static_cast<int>(clippedTriangles.size());
|
s = static_cast<int>(clippedTriangles.size());
|
||||||
clippedTriangles.reserve(s + 3 * (clipOutputCount - 2));
|
clippedTriangles.ensureCapacity(s + 3 * (clipOutputCount - 2));
|
||||||
clippedTriangles.setSize(s + 3 * (clipOutputCount - 2));
|
clippedTriangles.setSize(s + 3 * (clipOutputCount - 2));
|
||||||
clipOutputCount--;
|
clipOutputCount--;
|
||||||
for (int ii = 1; ii < clipOutputCount; ii++) {
|
for (int ii = 1; ii < clipOutputCount; ii++) {
|
||||||
@ -152,9 +152,9 @@ namespace Spine {
|
|||||||
index += clipOutputCount + 1;
|
index += clipOutputCount + 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clippedVertices.reserve(s + 3 * 2);
|
clippedVertices.ensureCapacity(s + 3 * 2);
|
||||||
clippedVertices.setSize(s + 3 * 2);
|
clippedVertices.setSize(s + 3 * 2);
|
||||||
_clippedUVs.reserve(s + 3 * 2);
|
_clippedUVs.ensureCapacity(s + 3 * 2);
|
||||||
_clippedUVs.setSize(s + 3 * 2);
|
_clippedUVs.setSize(s + 3 * 2);
|
||||||
clippedVertices[s] = x1;
|
clippedVertices[s] = x1;
|
||||||
clippedVertices[s + 1] = y1;
|
clippedVertices[s + 1] = y1;
|
||||||
@ -171,7 +171,7 @@ namespace Spine {
|
|||||||
_clippedUVs[s + 5] = v3;
|
_clippedUVs[s + 5] = v3;
|
||||||
|
|
||||||
s = static_cast<int>(clippedTriangles.size());
|
s = static_cast<int>(clippedTriangles.size());
|
||||||
clippedTriangles.reserve(s + 3);
|
clippedTriangles.ensureCapacity(s + 3);
|
||||||
clippedTriangles.setSize(s + 3);
|
clippedTriangles.setSize(s + 3);
|
||||||
clippedTriangles[s] = index;
|
clippedTriangles[s] = index;
|
||||||
clippedTriangles[s + 1] = index + 1;
|
clippedTriangles[s + 1] = index + 1;
|
||||||
@ -214,14 +214,14 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input.clear();
|
input.clear();
|
||||||
input.push_back(x1);
|
input.add(x1);
|
||||||
input.push_back(y1);
|
input.add(y1);
|
||||||
input.push_back(x2);
|
input.add(x2);
|
||||||
input.push_back(y2);
|
input.add(y2);
|
||||||
input.push_back(x3);
|
input.add(x3);
|
||||||
input.push_back(y3);
|
input.add(y3);
|
||||||
input.push_back(x1);
|
input.add(x1);
|
||||||
input.push_back(y1);
|
input.add(y1);
|
||||||
output.clear();
|
output.clear();
|
||||||
|
|
||||||
Vector<float>& clippingVertices = clippingArea;
|
Vector<float>& clippingVertices = clippingArea;
|
||||||
@ -240,24 +240,24 @@ namespace Spine {
|
|||||||
if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {
|
if (deltaX * (inputY - edgeY2) - deltaY * (inputX - edgeX2) > 0) {
|
||||||
if (side2) {
|
if (side2) {
|
||||||
// v1 inside, v2 inside
|
// v1 inside, v2 inside
|
||||||
output.push_back(inputX2);
|
output.add(inputX2);
|
||||||
output.push_back(inputY2);
|
output.add(inputY2);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// v1 inside, v2 outside
|
// v1 inside, v2 outside
|
||||||
float c0 = inputY2 - inputY, c2 = inputX2 - inputX;
|
float c0 = inputY2 - inputY, c2 = inputX2 - inputX;
|
||||||
float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY));
|
float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY));
|
||||||
output.push_back(edgeX + (edgeX2 - edgeX) * ua);
|
output.add(edgeX + (edgeX2 - edgeX) * ua);
|
||||||
output.push_back(edgeY + (edgeY2 - edgeY) * ua);
|
output.add(edgeY + (edgeY2 - edgeY) * ua);
|
||||||
}
|
}
|
||||||
else if (side2) {
|
else if (side2) {
|
||||||
// v1 outside, v2 inside
|
// v1 outside, v2 inside
|
||||||
float c0 = inputY2 - inputY, c2 = inputX2 - inputX;
|
float c0 = inputY2 - inputY, c2 = inputX2 - inputX;
|
||||||
float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY));
|
float ua = (c2 * (edgeY - inputY) - c0 * (edgeX - inputX)) / (c0 * (edgeX2 - edgeX) - c2 * (edgeY2 - edgeY));
|
||||||
output.push_back(edgeX + (edgeX2 - edgeX) * ua);
|
output.add(edgeX + (edgeX2 - edgeX) * ua);
|
||||||
output.push_back(edgeY + (edgeY2 - edgeY) * ua);
|
output.add(edgeY + (edgeY2 - edgeY) * ua);
|
||||||
output.push_back(inputX2);
|
output.add(inputX2);
|
||||||
output.push_back(inputY2);
|
output.add(inputY2);
|
||||||
}
|
}
|
||||||
clipped = true;
|
clipped = true;
|
||||||
}
|
}
|
||||||
@ -268,8 +268,8 @@ namespace Spine {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.push_back(output[0]);
|
output.add(output[0]);
|
||||||
output.push_back(output[1]);
|
output.add(output[1]);
|
||||||
|
|
||||||
if (i == clippingVerticesLast) {
|
if (i == clippingVerticesLast) {
|
||||||
break;
|
break;
|
||||||
@ -283,11 +283,11 @@ namespace Spine {
|
|||||||
if (originalOutput != output) {
|
if (originalOutput != output) {
|
||||||
originalOutput.clear();
|
originalOutput.clear();
|
||||||
for (int i = 0, n = static_cast<int>(output.size()) - 2; i < n; ++i) {
|
for (int i = 0, n = static_cast<int>(output.size()) - 2; i < n; ++i) {
|
||||||
originalOutput.push_back(output[i]);
|
originalOutput.add(output[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
originalOutput.reserve(originalOutput.size() - 2);
|
originalOutput.ensureCapacity(originalOutput.size() - 2);
|
||||||
originalOutput.setSize(originalOutput.size() - 2);
|
originalOutput.setSize(originalOutput.size() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Bones. */
|
/* Bones. */
|
||||||
bones = Json::getItem(root, "bones");
|
bones = Json::getItem(root, "bones");
|
||||||
skeletonData->_bones.reserve(bones->_size);
|
skeletonData->_bones.ensureCapacity(bones->_size);
|
||||||
skeletonData->_bones.setSize(bones->_size);
|
skeletonData->_bones.setSize(bones->_size);
|
||||||
int bonesCount = 0;
|
int bonesCount = 0;
|
||||||
for (boneMap = bones->_child, i = 0; boneMap; boneMap = boneMap->_next, ++i) {
|
for (boneMap = bones->_child, i = 0; boneMap; boneMap = boneMap->_next, ++i) {
|
||||||
@ -198,7 +198,7 @@ namespace Spine {
|
|||||||
slots = Json::getItem(root, "slots");
|
slots = Json::getItem(root, "slots");
|
||||||
if (slots) {
|
if (slots) {
|
||||||
Json *slotMap;
|
Json *slotMap;
|
||||||
skeletonData->_slots.reserve(slots->_size);
|
skeletonData->_slots.ensureCapacity(slots->_size);
|
||||||
skeletonData->_slots.setSize(slots->_size);
|
skeletonData->_slots.setSize(slots->_size);
|
||||||
for (slotMap = slots->_child, i = 0; slotMap; slotMap = slotMap->_next, ++i) {
|
for (slotMap = slots->_child, i = 0; slotMap; slotMap = slotMap->_next, ++i) {
|
||||||
SlotData* data;
|
SlotData* data;
|
||||||
@ -259,7 +259,7 @@ namespace Spine {
|
|||||||
ik = Json::getItem(root, "ik");
|
ik = Json::getItem(root, "ik");
|
||||||
if (ik) {
|
if (ik) {
|
||||||
Json *constraintMap;
|
Json *constraintMap;
|
||||||
skeletonData->_ikConstraints.reserve(ik->_size);
|
skeletonData->_ikConstraints.ensureCapacity(ik->_size);
|
||||||
skeletonData->_ikConstraints.setSize(ik->_size);
|
skeletonData->_ikConstraints.setSize(ik->_size);
|
||||||
for (constraintMap = ik->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
for (constraintMap = ik->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
||||||
const char* targetName;
|
const char* targetName;
|
||||||
@ -269,7 +269,7 @@ namespace Spine {
|
|||||||
data->_order = Json::getInt(constraintMap, "order", 0);
|
data->_order = Json::getInt(constraintMap, "order", 0);
|
||||||
|
|
||||||
boneMap = Json::getItem(constraintMap, "bones");
|
boneMap = Json::getItem(constraintMap, "bones");
|
||||||
data->_bones.reserve(boneMap->_size);
|
data->_bones.ensureCapacity(boneMap->_size);
|
||||||
data->_bones.setSize(boneMap->_size);
|
data->_bones.setSize(boneMap->_size);
|
||||||
for (boneMap = boneMap->_child, ii = 0; boneMap; boneMap = boneMap->_next, ++ii) {
|
for (boneMap = boneMap->_child, ii = 0; boneMap; boneMap = boneMap->_next, ++ii) {
|
||||||
data->_bones[ii] = skeletonData->findBone(boneMap->_valueString);
|
data->_bones[ii] = skeletonData->findBone(boneMap->_valueString);
|
||||||
@ -299,7 +299,7 @@ namespace Spine {
|
|||||||
transform = Json::getItem(root, "transform");
|
transform = Json::getItem(root, "transform");
|
||||||
if (transform) {
|
if (transform) {
|
||||||
Json *constraintMap;
|
Json *constraintMap;
|
||||||
skeletonData->_transformConstraints.reserve(transform->_size);
|
skeletonData->_transformConstraints.ensureCapacity(transform->_size);
|
||||||
skeletonData->_transformConstraints.setSize(transform->_size);
|
skeletonData->_transformConstraints.setSize(transform->_size);
|
||||||
for (constraintMap = transform->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
for (constraintMap = transform->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
||||||
const char* name;
|
const char* name;
|
||||||
@ -309,7 +309,7 @@ namespace Spine {
|
|||||||
data->_order = Json::getInt(constraintMap, "order", 0);
|
data->_order = Json::getInt(constraintMap, "order", 0);
|
||||||
|
|
||||||
boneMap = Json::getItem(constraintMap, "bones");
|
boneMap = Json::getItem(constraintMap, "bones");
|
||||||
data->_bones.reserve(boneMap->_size);
|
data->_bones.ensureCapacity(boneMap->_size);
|
||||||
data->_bones.setSize(boneMap->_size);
|
data->_bones.setSize(boneMap->_size);
|
||||||
for (boneMap = boneMap->_child, ii = 0; boneMap; boneMap = boneMap->_next, ++ii) {
|
for (boneMap = boneMap->_child, ii = 0; boneMap; boneMap = boneMap->_next, ++ii) {
|
||||||
data->_bones[ii] = skeletonData->findBone(boneMap->_valueString);
|
data->_bones[ii] = skeletonData->findBone(boneMap->_valueString);
|
||||||
@ -350,7 +350,7 @@ namespace Spine {
|
|||||||
path = Json::getItem(root, "path");
|
path = Json::getItem(root, "path");
|
||||||
if (path) {
|
if (path) {
|
||||||
Json *constraintMap;
|
Json *constraintMap;
|
||||||
skeletonData->_pathConstraints.reserve(path->_size);
|
skeletonData->_pathConstraints.ensureCapacity(path->_size);
|
||||||
skeletonData->_pathConstraints.setSize(path->_size);
|
skeletonData->_pathConstraints.setSize(path->_size);
|
||||||
for (constraintMap = path->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
for (constraintMap = path->_child, i = 0; constraintMap; constraintMap = constraintMap->_next, ++i) {
|
||||||
const char* name;
|
const char* name;
|
||||||
@ -361,7 +361,7 @@ namespace Spine {
|
|||||||
data->_order = Json::getInt(constraintMap, "order", 0);
|
data->_order = Json::getInt(constraintMap, "order", 0);
|
||||||
|
|
||||||
boneMap = Json::getItem(constraintMap, "bones");
|
boneMap = Json::getItem(constraintMap, "bones");
|
||||||
data->_bones.reserve(boneMap->_size);
|
data->_bones.ensureCapacity(boneMap->_size);
|
||||||
data->_bones.setSize(boneMap->_size);
|
data->_bones.setSize(boneMap->_size);
|
||||||
for (boneMap = boneMap->_child, ii = 0; boneMap; boneMap = boneMap->_next, ++ii) {
|
for (boneMap = boneMap->_child, ii = 0; boneMap; boneMap = boneMap->_next, ++ii) {
|
||||||
data->_bones[ii] = skeletonData->findBone(boneMap->_valueString);
|
data->_bones[ii] = skeletonData->findBone(boneMap->_valueString);
|
||||||
@ -430,7 +430,7 @@ namespace Spine {
|
|||||||
skins = Json::getItem(root, "skins");
|
skins = Json::getItem(root, "skins");
|
||||||
if (skins) {
|
if (skins) {
|
||||||
Json *skinMap;
|
Json *skinMap;
|
||||||
skeletonData->_skins.reserve(skins->_size);
|
skeletonData->_skins.ensureCapacity(skins->_size);
|
||||||
skeletonData->_skins.setSize(skins->_size);
|
skeletonData->_skins.setSize(skins->_size);
|
||||||
int skinsIndex = 0;
|
int skinsIndex = 0;
|
||||||
for (skinMap = skins->_child, i = 0; skinMap; skinMap = skinMap->_next, ++i) {
|
for (skinMap = skins->_child, i = 0; skinMap; skinMap = skinMap->_next, ++i) {
|
||||||
@ -536,7 +536,7 @@ namespace Spine {
|
|||||||
if (!entry) {
|
if (!entry) {
|
||||||
int verticesLength;
|
int verticesLength;
|
||||||
entry = Json::getItem(attachmentMap, "triangles");
|
entry = Json::getItem(attachmentMap, "triangles");
|
||||||
mesh->_triangles.reserve(entry->_size);
|
mesh->_triangles.ensureCapacity(entry->_size);
|
||||||
mesh->_triangles.setSize(entry->_size);
|
mesh->_triangles.setSize(entry->_size);
|
||||||
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii) {
|
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii) {
|
||||||
mesh->_triangles[ii] = (unsigned short)entry->_valueInt;
|
mesh->_triangles[ii] = (unsigned short)entry->_valueInt;
|
||||||
@ -544,7 +544,7 @@ namespace Spine {
|
|||||||
|
|
||||||
entry = Json::getItem(attachmentMap, "uvs");
|
entry = Json::getItem(attachmentMap, "uvs");
|
||||||
verticesLength = entry->_size;
|
verticesLength = entry->_size;
|
||||||
mesh->_regionUVs.reserve(verticesLength);
|
mesh->_regionUVs.ensureCapacity(verticesLength);
|
||||||
mesh->_regionUVs.setSize(verticesLength);
|
mesh->_regionUVs.setSize(verticesLength);
|
||||||
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii) {
|
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii) {
|
||||||
mesh->_regionUVs[ii] = entry->_valueFloat;
|
mesh->_regionUVs[ii] = entry->_valueFloat;
|
||||||
@ -558,7 +558,7 @@ namespace Spine {
|
|||||||
|
|
||||||
entry = Json::getItem(attachmentMap, "edges");
|
entry = Json::getItem(attachmentMap, "edges");
|
||||||
if (entry) {
|
if (entry) {
|
||||||
mesh->_edges.reserve(entry->_size);
|
mesh->_edges.ensureCapacity(entry->_size);
|
||||||
mesh->_edges.setSize(entry->_size);
|
mesh->_edges.setSize(entry->_size);
|
||||||
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii) {
|
for (entry = entry->_child, ii = 0; entry; entry = entry->_next, ++ii) {
|
||||||
mesh->_edges[ii] = entry->_valueInt;
|
mesh->_edges[ii] = entry->_valueInt;
|
||||||
@ -568,7 +568,7 @@ namespace Spine {
|
|||||||
else {
|
else {
|
||||||
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1);
|
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1);
|
||||||
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(Json::getString(attachmentMap, "skin", 0)), slotIndex, String(entry->_valueString));
|
LinkedMesh* linkedMesh = new (__FILE__, __LINE__) LinkedMesh(mesh, String(Json::getString(attachmentMap, "skin", 0)), slotIndex, String(entry->_valueString));
|
||||||
_linkedMeshes.push_back(linkedMesh);
|
_linkedMeshes.add(linkedMesh);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -592,7 +592,7 @@ namespace Spine {
|
|||||||
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0);
|
vertexCount = Json::getInt(attachmentMap, "vertexCount", 0);
|
||||||
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
|
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
|
||||||
|
|
||||||
pathAttatchment->_lengths.reserve(vertexCount / 3);
|
pathAttatchment->_lengths.ensureCapacity(vertexCount / 3);
|
||||||
pathAttatchment->_lengths.setSize(vertexCount / 3);
|
pathAttatchment->_lengths.setSize(vertexCount / 3);
|
||||||
|
|
||||||
curves = Json::getItem(attachmentMap, "lengths");
|
curves = Json::getItem(attachmentMap, "lengths");
|
||||||
@ -658,7 +658,7 @@ namespace Spine {
|
|||||||
events = Json::getItem(root, "events");
|
events = Json::getItem(root, "events");
|
||||||
if (events) {
|
if (events) {
|
||||||
Json *eventMap;
|
Json *eventMap;
|
||||||
skeletonData->_events.reserve(events->_size);
|
skeletonData->_events.ensureCapacity(events->_size);
|
||||||
skeletonData->_events.setSize(events->_size);
|
skeletonData->_events.setSize(events->_size);
|
||||||
for (eventMap = events->_child, i = 0; eventMap; eventMap = eventMap->_next, ++i) {
|
for (eventMap = events->_child, i = 0; eventMap; eventMap = eventMap->_next, ++i) {
|
||||||
EventData* eventData = new (__FILE__, __LINE__) EventData(String(eventMap->_name));
|
EventData* eventData = new (__FILE__, __LINE__) EventData(String(eventMap->_name));
|
||||||
@ -675,7 +675,7 @@ namespace Spine {
|
|||||||
animations = Json::getItem(root, "animations");
|
animations = Json::getItem(root, "animations");
|
||||||
if (animations) {
|
if (animations) {
|
||||||
Json *animationMap;
|
Json *animationMap;
|
||||||
skeletonData->_animations.reserve(animations->_size);
|
skeletonData->_animations.ensureCapacity(animations->_size);
|
||||||
skeletonData->_animations.setSize(animations->_size);
|
skeletonData->_animations.setSize(animations->_size);
|
||||||
int animationsIndex = 0;
|
int animationsIndex = 0;
|
||||||
for (animationMap = animations->_child; animationMap; animationMap = animationMap->_next) {
|
for (animationMap = animations->_child; animationMap; animationMap = animationMap->_next) {
|
||||||
@ -805,7 +805,7 @@ namespace Spine {
|
|||||||
String attachmentName = name->_type == Json::JSON_NULL ? "" : name->_valueString;
|
String attachmentName = name->_type == Json::JSON_NULL ? "" : name->_valueString;
|
||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), attachmentName);
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), attachmentName);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[timelineMap->_size - 1]);
|
duration = MAX(duration, timeline->_frames[timelineMap->_size - 1]);
|
||||||
|
|
||||||
@ -820,7 +820,7 @@ namespace Spine {
|
|||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2), toColor(s, 3));
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2), toColor(s, 3));
|
||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * ColorTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * ColorTimeline::ENTRIES]);
|
||||||
|
|
||||||
@ -837,7 +837,7 @@ namespace Spine {
|
|||||||
toColor(s, 3), toColor(ds, 0), toColor(ds, 1), toColor(ds, 2));
|
toColor(s, 3), toColor(ds, 0), toColor(ds, 1), toColor(ds, 2));
|
||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TwoColorTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TwoColorTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
@ -870,7 +870,7 @@ namespace Spine {
|
|||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "angle", 0));
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "angle", 0));
|
||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * RotateTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * RotateTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
@ -897,7 +897,7 @@ namespace Spine {
|
|||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TranslateTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * TranslateTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
@ -925,7 +925,7 @@ namespace Spine {
|
|||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "mix", 1), Json::getInt(valueMap, "bendPositive", 1) ? 1 : -1);
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "mix", 1), Json::getInt(valueMap, "bendPositive", 1) ? 1 : -1);
|
||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(constraintMap->_size - 1) * IkConstraintTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(constraintMap->_size - 1) * IkConstraintTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
@ -945,7 +945,7 @@ namespace Spine {
|
|||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "rotateMix", 1), Json::getFloat(valueMap, "translateMix", 1), Json::getFloat(valueMap, "scaleMix", 1), Json::getFloat(valueMap, "shearMix", 1));
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "rotateMix", 1), Json::getFloat(valueMap, "translateMix", 1), Json::getFloat(valueMap, "scaleMix", 1), Json::getFloat(valueMap, "shearMix", 1));
|
||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(constraintMap->_size - 1) * TransformConstraintTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(constraintMap->_size - 1) * TransformConstraintTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
@ -994,7 +994,7 @@ namespace Spine {
|
|||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, timelineName, 0) * timelineScale);
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, timelineName, 0) * timelineScale);
|
||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintPositionTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintPositionTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
@ -1005,7 +1005,7 @@ namespace Spine {
|
|||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "rotateMix", 1), Json::getFloat(valueMap, "translateMix", 1));
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), Json::getFloat(valueMap, "rotateMix", 1), Json::getFloat(valueMap, "translateMix", 1));
|
||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintMixTimeline::ENTRIES]);
|
duration = MAX(duration, timeline->_frames[(timelineMap->_size - 1) * PathConstraintMixTimeline::ENTRIES]);
|
||||||
}
|
}
|
||||||
@ -1036,9 +1036,9 @@ namespace Spine {
|
|||||||
Vector<float>& vertices = attachment->_vertices;
|
Vector<float>& vertices = attachment->_vertices;
|
||||||
deformLength = weighted ? static_cast<int>(vertices.size()) / 3 * 2 : static_cast<int>(vertices.size());
|
deformLength = weighted ? static_cast<int>(vertices.size()) / 3 * 2 : static_cast<int>(vertices.size());
|
||||||
Vector<float> tempDeform;
|
Vector<float> tempDeform;
|
||||||
tempDeform.reserve(deformLength);
|
tempDeform.ensureCapacity(deformLength);
|
||||||
for (int i = 0; i < deformLength; ++i) {
|
for (int i = 0; i < deformLength; ++i) {
|
||||||
tempDeform.push_back(0);
|
tempDeform.add(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeline = new (__FILE__, __LINE__) DeformTimeline(timelineMap->_size);
|
timeline = new (__FILE__, __LINE__) DeformTimeline(timelineMap->_size);
|
||||||
@ -1082,7 +1082,7 @@ namespace Spine {
|
|||||||
readCurve(valueMap, timeline, frameIndex);
|
readCurve(valueMap, timeline, frameIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[timelineMap->_size - 1]);
|
duration = MAX(duration, timeline->_frames[timelineMap->_size - 1]);
|
||||||
}
|
}
|
||||||
@ -1100,11 +1100,11 @@ namespace Spine {
|
|||||||
if (offsets) {
|
if (offsets) {
|
||||||
Json* offsetMap;
|
Json* offsetMap;
|
||||||
Vector<int> unchanged;
|
Vector<int> unchanged;
|
||||||
unchanged.reserve(skeletonData->_slots.size() - offsets->_size);
|
unchanged.ensureCapacity(skeletonData->_slots.size() - offsets->_size);
|
||||||
unchanged.setSize(skeletonData->_slots.size() - offsets->_size);
|
unchanged.setSize(skeletonData->_slots.size() - offsets->_size);
|
||||||
int originalIndex = 0, unchangedIndex = 0;
|
int originalIndex = 0, unchangedIndex = 0;
|
||||||
|
|
||||||
drawOrder2.reserve(skeletonData->_slots.size());
|
drawOrder2.ensureCapacity(skeletonData->_slots.size());
|
||||||
drawOrder2.setSize(skeletonData->_slots.size());
|
drawOrder2.setSize(skeletonData->_slots.size());
|
||||||
for (ii = static_cast<int>(skeletonData->_slots.size()) - 1; ii >= 0; --ii) {
|
for (ii = static_cast<int>(skeletonData->_slots.size()) - 1; ii >= 0; --ii) {
|
||||||
drawOrder2[ii] = -1;
|
drawOrder2[ii] = -1;
|
||||||
@ -1138,7 +1138,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), drawOrder2);
|
timeline->setFrame(frameIndex, Json::getFloat(valueMap, "time", 0), drawOrder2);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[drawOrder->_size - 1]);
|
duration = MAX(duration, timeline->_frames[drawOrder->_size - 1]);
|
||||||
}
|
}
|
||||||
@ -1162,7 +1162,7 @@ namespace Spine {
|
|||||||
event->_stringValue = Json::getString(valueMap, "string", eventData->_stringValue.buffer());
|
event->_stringValue = Json::getString(valueMap, "string", eventData->_stringValue.buffer());
|
||||||
timeline->setFrame(frameIndex, event);
|
timeline->setFrame(frameIndex, event);
|
||||||
}
|
}
|
||||||
timelines.push_back(timeline);
|
timelines.add(timeline);
|
||||||
timelinesCount++;
|
timelinesCount++;
|
||||||
duration = MAX(duration, timeline->_frames[events->_size - 1]);
|
duration = MAX(duration, timeline->_frames[events->_size - 1]);
|
||||||
}
|
}
|
||||||
@ -1179,7 +1179,7 @@ namespace Spine {
|
|||||||
|
|
||||||
entry = Json::getItem(attachmentMap, "vertices");
|
entry = Json::getItem(attachmentMap, "vertices");
|
||||||
entrySize = entry->_size;
|
entrySize = entry->_size;
|
||||||
vertices.reserve(entrySize);
|
vertices.ensureCapacity(entrySize);
|
||||||
vertices.setSize(entrySize);
|
vertices.setSize(entrySize);
|
||||||
for (entry = entry->_child, i = 0; entry; entry = entry->_next, ++i) {
|
for (entry = entry->_child, i = 0; entry; entry = entry->_next, ++i) {
|
||||||
vertices[i] = entry->_valueFloat;
|
vertices[i] = entry->_valueFloat;
|
||||||
@ -1197,17 +1197,17 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vertices bonesAndWeights;
|
Vertices bonesAndWeights;
|
||||||
bonesAndWeights._bones.reserve(verticesLength * 3);
|
bonesAndWeights._bones.ensureCapacity(verticesLength * 3);
|
||||||
bonesAndWeights._vertices.reserve(verticesLength * 3 * 3);
|
bonesAndWeights._vertices.ensureCapacity(verticesLength * 3 * 3);
|
||||||
|
|
||||||
for (i = 0, n = entrySize; i < n;) {
|
for (i = 0, n = entrySize; i < n;) {
|
||||||
int boneCount = (int)vertices[i++];
|
int boneCount = (int)vertices[i++];
|
||||||
bonesAndWeights._bones.push_back(boneCount);
|
bonesAndWeights._bones.add(boneCount);
|
||||||
for (nn = i + boneCount * 4; i < nn; i += 4) {
|
for (nn = i + boneCount * 4; i < nn; i += 4) {
|
||||||
bonesAndWeights._bones.push_back((int)vertices[i]);
|
bonesAndWeights._bones.add((int) vertices[i]);
|
||||||
bonesAndWeights._vertices.push_back(vertices[i + 1] * _scale);
|
bonesAndWeights._vertices.add(vertices[i + 1] * _scale);
|
||||||
bonesAndWeights._vertices.push_back(vertices[i + 2] * _scale);
|
bonesAndWeights._vertices.add(vertices[i + 2] * _scale);
|
||||||
bonesAndWeights._vertices.push_back(vertices[i + 3]);
|
bonesAndWeights._vertices.add(vertices[i + 3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1225,7 +1225,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_error = String(message);
|
_error = String(message);
|
||||||
|
|
||||||
delete root;
|
delete root;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,7 @@ namespace Spine {
|
|||||||
void Skin::findNamesForSlot(int slotIndex, Vector<String>& names) {
|
void Skin::findNamesForSlot(int slotIndex, Vector<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.key()._slotIndex == slotIndex) {
|
if (i.key()._slotIndex == slotIndex) {
|
||||||
names.push_back(i.key()._name);
|
names.add(i.key()._name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ namespace Spine {
|
|||||||
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.key()._slotIndex == slotIndex) {
|
if (i.key()._slotIndex == slotIndex) {
|
||||||
attachments.push_back(i.value());
|
attachments.add(i.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,11 +47,11 @@ namespace Spine {
|
|||||||
_translateMix(data.getTranslateMix()),
|
_translateMix(data.getTranslateMix()),
|
||||||
_scaleMix(data.getScaleMix()),
|
_scaleMix(data.getScaleMix()),
|
||||||
_shearMix(data.getShearMix()) {
|
_shearMix(data.getShearMix()) {
|
||||||
_bones.reserve(_data.getBones().size());
|
_bones.ensureCapacity(_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* boneData = (*i);
|
BoneData* boneData = (*i);
|
||||||
|
|
||||||
_bones.push_back(skeleton.findBone(boneData->getName()));
|
_bones.add(skeleton.findBone(boneData->getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,7 +55,7 @@ namespace Spine {
|
|||||||
const int TransformConstraintTimeline::SHEAR = 4;
|
const int TransformConstraintTimeline::SHEAR = 4;
|
||||||
|
|
||||||
TransformConstraintTimeline::TransformConstraintTimeline(int frameCount) : CurveTimeline(frameCount), _transformConstraintIndex(0) {
|
TransformConstraintTimeline::TransformConstraintTimeline(int frameCount) : CurveTimeline(frameCount), _transformConstraintIndex(0) {
|
||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ namespace Spine {
|
|||||||
const int TranslateTimeline::Y = 2;
|
const int TranslateTimeline::Y = 2;
|
||||||
|
|
||||||
TranslateTimeline::TranslateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
TranslateTimeline::TranslateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,14 +38,14 @@ namespace Spine {
|
|||||||
|
|
||||||
Vector<int>& indices = _indices;
|
Vector<int>& indices = _indices;
|
||||||
indices.clear();
|
indices.clear();
|
||||||
indices.reserve(vertexCount);
|
indices.ensureCapacity(vertexCount);
|
||||||
indices.setSize(vertexCount);
|
indices.setSize(vertexCount);
|
||||||
for (int i = 0; i < vertexCount; ++i) {
|
for (int i = 0; i < vertexCount; ++i) {
|
||||||
indices[i] = i;
|
indices[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<bool>& isConcaveArray = _isConcaveArray;
|
Vector<bool>& isConcaveArray = _isConcaveArray;
|
||||||
isConcaveArray.reserve(vertexCount);
|
isConcaveArray.ensureCapacity(vertexCount);
|
||||||
isConcaveArray.setSize(vertexCount);
|
isConcaveArray.setSize(vertexCount);
|
||||||
for (int i = 0, n = vertexCount; i < n; ++i) {
|
for (int i = 0, n = vertexCount; i < n; ++i) {
|
||||||
isConcaveArray[i] = isConcave(i, vertexCount, vertices, indices);
|
isConcaveArray[i] = isConcave(i, vertexCount, vertices, indices);
|
||||||
@ -53,7 +53,7 @@ namespace Spine {
|
|||||||
|
|
||||||
Vector<int>& triangles = _triangles;
|
Vector<int>& triangles = _triangles;
|
||||||
triangles.clear();
|
triangles.clear();
|
||||||
triangles.reserve(MAX(0, vertexCount - 2) << 2);
|
triangles.ensureCapacity(MAX(0, vertexCount - 2) << 2);
|
||||||
|
|
||||||
while (vertexCount > 3) {
|
while (vertexCount > 3) {
|
||||||
// Find ear tip.
|
// Find ear tip.
|
||||||
@ -101,11 +101,11 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cut ear tip.
|
// Cut ear tip.
|
||||||
triangles.push_back(indices[(vertexCount + i - 1) % vertexCount]);
|
triangles.add(indices[(vertexCount + i - 1) % vertexCount]);
|
||||||
triangles.push_back(indices[i]);
|
triangles.add(indices[i]);
|
||||||
triangles.push_back(indices[(i + 1) % vertexCount]);
|
triangles.add(indices[(i + 1) % vertexCount]);
|
||||||
indices.erase(i);
|
indices.removeAt(i);
|
||||||
isConcaveArray.erase(i);
|
isConcaveArray.removeAt(i);
|
||||||
vertexCount--;
|
vertexCount--;
|
||||||
|
|
||||||
int previousIndex = (vertexCount + i - 1) % vertexCount;
|
int previousIndex = (vertexCount + i - 1) % vertexCount;
|
||||||
@ -115,9 +115,9 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vertexCount == 3) {
|
if (vertexCount == 3) {
|
||||||
triangles.push_back(indices[2]);
|
triangles.add(indices[2]);
|
||||||
triangles.push_back(indices[0]);
|
triangles.add(indices[0]);
|
||||||
triangles.push_back(indices[1]);
|
triangles.add(indices[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return triangles;
|
return triangles;
|
||||||
@ -160,9 +160,9 @@ namespace Spine {
|
|||||||
int winding1 = winding(p[o], p[o + 1], p[o + 2], p[o + 3], x3, y3);
|
int winding1 = winding(p[o], p[o + 1], p[o + 2], p[o + 3], x3, y3);
|
||||||
int winding2 = winding(x3, y3, p[0], p[1], p[2], p[3]);
|
int winding2 = winding(x3, y3, p[0], p[1], p[2], p[3]);
|
||||||
if (winding1 == lastwinding && winding2 == lastwinding) {
|
if (winding1 == lastwinding && winding2 == lastwinding) {
|
||||||
polygon.push_back(x3);
|
polygon.add(x3);
|
||||||
polygon.push_back(y3);
|
polygon.add(y3);
|
||||||
polygonIndices.push_back(t3);
|
polygonIndices.add(t3);
|
||||||
merged = true;
|
merged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,8 +170,8 @@ namespace Spine {
|
|||||||
// Otherwise make this triangle the new base.
|
// Otherwise make this triangle the new base.
|
||||||
if (!merged) {
|
if (!merged) {
|
||||||
if (polygon.size() > 0) {
|
if (polygon.size() > 0) {
|
||||||
convexPolygons.push_back(&polygon);
|
convexPolygons.add(&polygon);
|
||||||
convexPolygonsIndices.push_back(&polygonIndices);
|
convexPolygonsIndices.add(&polygonIndices);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_polygonPool.free(&polygon);
|
_polygonPool.free(&polygon);
|
||||||
@ -180,25 +180,25 @@ namespace Spine {
|
|||||||
|
|
||||||
polygon = *_polygonPool.obtain();
|
polygon = *_polygonPool.obtain();
|
||||||
polygon.clear();
|
polygon.clear();
|
||||||
polygon.push_back(x1);
|
polygon.add(x1);
|
||||||
polygon.push_back(y1);
|
polygon.add(y1);
|
||||||
polygon.push_back(x2);
|
polygon.add(x2);
|
||||||
polygon.push_back(y2);
|
polygon.add(y2);
|
||||||
polygon.push_back(x3);
|
polygon.add(x3);
|
||||||
polygon.push_back(y3);
|
polygon.add(y3);
|
||||||
polygonIndices = *_polygonIndicesPool.obtain();
|
polygonIndices = *_polygonIndicesPool.obtain();
|
||||||
polygonIndices.clear();
|
polygonIndices.clear();
|
||||||
polygonIndices.push_back(t1);
|
polygonIndices.add(t1);
|
||||||
polygonIndices.push_back(t2);
|
polygonIndices.add(t2);
|
||||||
polygonIndices.push_back(t3);
|
polygonIndices.add(t3);
|
||||||
lastwinding = winding(x1, y1, x2, y2, x3, y3);
|
lastwinding = winding(x1, y1, x2, y2, x3, y3);
|
||||||
fanBaseIndex = t1;
|
fanBaseIndex = t1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (polygon.size() > 0) {
|
if (polygon.size() > 0) {
|
||||||
convexPolygons.push_back(&polygon);
|
convexPolygons.add(&polygon);
|
||||||
convexPolygonsIndices.push_back(&polygonIndices);
|
convexPolygonsIndices.add(&polygonIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go through the list of polygons and try to merge the remaining triangles with the found triangle fans.
|
// Go through the list of polygons and try to merge the remaining triangles with the found triangle fans.
|
||||||
@ -249,9 +249,9 @@ namespace Spine {
|
|||||||
if (winding1 == winding0 && winding2 == winding0) {
|
if (winding1 == winding0 && winding2 == winding0) {
|
||||||
otherPoly.clear();
|
otherPoly.clear();
|
||||||
otherIndices.clear();
|
otherIndices.clear();
|
||||||
polygon.push_back(x3);
|
polygon.add(x3);
|
||||||
polygon.push_back(y3);
|
polygon.add(y3);
|
||||||
polygonIndices.push_back(otherLastIndex);
|
polygonIndices.add(otherLastIndex);
|
||||||
prevPrevX = prevX;
|
prevPrevX = prevX;
|
||||||
prevPrevY = prevY;
|
prevPrevY = prevY;
|
||||||
prevX = x3;
|
prevX = x3;
|
||||||
@ -265,10 +265,10 @@ namespace Spine {
|
|||||||
for (int i = static_cast<int>(convexPolygons.size()) - 1; i >= 0; --i) {
|
for (int i = static_cast<int>(convexPolygons.size()) - 1; i >= 0; --i) {
|
||||||
polygon = *convexPolygons[i];
|
polygon = *convexPolygons[i];
|
||||||
if (polygon.size() == 0) {
|
if (polygon.size() == 0) {
|
||||||
convexPolygons.erase(i);
|
convexPolygons.removeAt(i);
|
||||||
_polygonPool.free(&polygon);
|
_polygonPool.free(&polygon);
|
||||||
polygonIndices = *convexPolygonsIndices[i];
|
polygonIndices = *convexPolygonsIndices[i];
|
||||||
convexPolygonsIndices.erase(i);
|
convexPolygonsIndices.removeAt(i);
|
||||||
_polygonIndicesPool.free(&polygonIndices);
|
_polygonIndicesPool.free(&polygonIndices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,7 +59,7 @@ namespace Spine {
|
|||||||
const int TwoColorTimeline::B2 = 7;
|
const int TwoColorTimeline::B2 = 7;
|
||||||
|
|
||||||
TwoColorTimeline::TwoColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) {
|
TwoColorTimeline::TwoColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) {
|
||||||
_frames.reserve(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user