mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[cpp] Fixed all the things by calloc'ing instead of allocing...
This commit is contained in:
parent
62ef2ba370
commit
99d3e15a18
@ -19,6 +19,12 @@ cp -f ../spineboy/export/*.json ../../spine-libgdx/spine-libgdx-tests/assets/spi
|
|||||||
cp -r ../spineboy/export/*.skel ../../spine-libgdx/spine-libgdx-tests/assets/spineboy/
|
cp -r ../spineboy/export/*.skel ../../spine-libgdx/spine-libgdx-tests/assets/spineboy/
|
||||||
cp -r ../spineboy/export/*-pma.* ../../spine-libgdx/spine-libgdx-tests/assets/spineboy/
|
cp -r ../spineboy/export/*-pma.* ../../spine-libgdx/spine-libgdx-tests/assets/spineboy/
|
||||||
|
|
||||||
|
rm -rf ../../spine-libgdx/spine-libgdx-tests/assets/coin/*
|
||||||
|
mkdir ../../spine-libgdx/spine-libgdx-tests/assets/coin/
|
||||||
|
cp -f ../coin/export/*.json ../../spine-libgdx/spine-libgdx-tests/assets/coin/
|
||||||
|
cp -f ../coin/export/*.skel ../../spine-libgdx/spine-libgdx-tests/assets/coin/
|
||||||
|
cp -f ../coin/export/*-pma.* ../../spine-libgdx/spine-libgdx-tests/assets/coin/
|
||||||
|
|
||||||
echo "spine-as3"
|
echo "spine-as3"
|
||||||
rm -f ../../spine-as3/spine-as3-example/src/spineboy.*
|
rm -f ../../spine-as3/spine-as3-example/src/spineboy.*
|
||||||
cp -f ../spineboy/export/spineboy-ess.json ../../spine-as3/spine-as3-example/src/
|
cp -f ../spineboy/export/spineboy-ess.json ../../spine-as3/spine-as3-example/src/
|
||||||
|
|||||||
@ -76,7 +76,7 @@ namespace Spine {
|
|||||||
|
|
||||||
Vector<Timeline*> getTimelines();
|
Vector<Timeline*> getTimelines();
|
||||||
|
|
||||||
void setTimelines(Vector<Timeline*> inValue);
|
void setTimelines(Vector<Timeline*>& inValue);
|
||||||
|
|
||||||
float getDuration();
|
float getDuration();
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/// The length in the setup pose from the start of the path to the end of each curve.
|
/// The length in the setup pose from the start of the path to the end of each curve.
|
||||||
Vector<float>& getLengths();
|
Vector<float>& getLengths();
|
||||||
void setLengths(Vector<float> inValue);
|
void setLengths(Vector<float>& inValue);
|
||||||
bool isClosed();
|
bool isClosed();
|
||||||
void setClosed(bool inValue);
|
void setClosed(bool inValue);
|
||||||
bool isConstantSpeed();
|
bool isConstantSpeed();
|
||||||
|
|||||||
@ -121,7 +121,7 @@ namespace Spine {
|
|||||||
|
|
||||||
float _x, _y, _rotation, _scaleX, _scaleY, _width, _height;
|
float _x, _y, _rotation, _scaleX, _scaleY, _width, _height;
|
||||||
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
||||||
Vector<float> _offset;
|
Vector<float> _vertexOffset;
|
||||||
Vector<float> _uvs;
|
Vector<float> _uvs;
|
||||||
void* _rendererObject;
|
void* _rendererObject;
|
||||||
String _path;
|
String _path;
|
||||||
|
|||||||
@ -87,7 +87,7 @@ namespace Spine {
|
|||||||
void setAttachmentTime(float inValue);
|
void setAttachmentTime(float inValue);
|
||||||
|
|
||||||
Vector<float>& getAttachmentVertices();
|
Vector<float>& getAttachmentVertices();
|
||||||
void setAttachmentVertices(Vector<float> inValue);
|
void setAttachmentVertices(Vector<float>& inValue);
|
||||||
|
|
||||||
String toString() const;
|
String toString() const;
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ namespace Spine {
|
|||||||
} else {
|
} else {
|
||||||
_length = strlen(chars);
|
_length = strlen(chars);
|
||||||
if (!own) {
|
if (!own) {
|
||||||
_buffer = SpineExtension::alloc<char>(_length + 1, __FILE__, __LINE__);
|
_buffer = SpineExtension::calloc<char>(_length + 1, __FILE__, __LINE__);
|
||||||
memcpy((void *) _buffer, chars, _length + 1);
|
memcpy((void *) _buffer, chars, _length + 1);
|
||||||
} else {
|
} else {
|
||||||
_buffer = (char*)chars;
|
_buffer = (char*)chars;
|
||||||
@ -64,7 +64,7 @@ namespace Spine {
|
|||||||
_buffer = NULL;
|
_buffer = NULL;
|
||||||
} else {
|
} else {
|
||||||
_length = other._length;
|
_length = other._length;
|
||||||
_buffer = SpineExtension::alloc<char>(other._length + 1, __FILE__, __LINE__);
|
_buffer = SpineExtension::calloc<char>(other._length + 1, __FILE__, __LINE__);
|
||||||
memcpy((void*)_buffer, other._buffer, other._length + 1);
|
memcpy((void*)_buffer, other._buffer, other._length + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ namespace Spine {
|
|||||||
_buffer = NULL;
|
_buffer = NULL;
|
||||||
} else {
|
} else {
|
||||||
_length = other._length;
|
_length = other._length;
|
||||||
_buffer = SpineExtension::alloc<char>(other._length + 1, __FILE__, __LINE__);
|
_buffer = SpineExtension::calloc<char>(other._length + 1, __FILE__, __LINE__);
|
||||||
memcpy((void*)_buffer, other._buffer, other._length + 1);
|
memcpy((void*)_buffer, other._buffer, other._length + 1);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@ -133,7 +133,7 @@ namespace Spine {
|
|||||||
_buffer = NULL;
|
_buffer = NULL;
|
||||||
} else {
|
} else {
|
||||||
_length = strlen(chars);
|
_length = strlen(chars);
|
||||||
_buffer = SpineExtension::alloc<char>(_length + 1, __FILE__, __LINE__);
|
_buffer = SpineExtension::calloc<char>(_length + 1, __FILE__, __LINE__);
|
||||||
memcpy((void*)_buffer, chars, _length + 1);
|
memcpy((void*)_buffer, chars, _length + 1);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@ -54,7 +54,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector& operator=(const Vector& inVector) {
|
/*Vector& operator=(const Vector& inVector) {
|
||||||
if (this != &inVector) {
|
if (this != &inVector) {
|
||||||
clear();
|
clear();
|
||||||
deallocate(_buffer);
|
deallocate(_buffer);
|
||||||
@ -72,7 +72,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
~Vector() {
|
~Vector() {
|
||||||
clear();
|
clear();
|
||||||
@ -91,14 +91,20 @@ namespace Spine {
|
|||||||
return _size;
|
return _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setSize(size_t newSize) {
|
inline void setSize(size_t newSize, const T &defaultValue) {
|
||||||
assert(newSize >= 0);
|
assert(newSize >= 0);
|
||||||
|
size_t oldSize = _size;
|
||||||
_size = newSize;
|
_size = newSize;
|
||||||
if (_capacity < newSize) {
|
if (_capacity < newSize) {
|
||||||
_capacity = (int)(_size * 1.75f);
|
_capacity = (int)(_size * 1.75f);
|
||||||
if (_capacity < 8) _capacity = 8;
|
if (_capacity < 8) _capacity = 8;
|
||||||
_buffer = Spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
|
_buffer = Spine::SpineExtension::realloc<T>(_buffer, _capacity, __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
if (oldSize < _size) {
|
||||||
|
for (size_t i = oldSize; i < _size; i++) {
|
||||||
|
construct(_buffer + i, defaultValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ensureCapacity(size_t newCapacity = 0) {
|
inline void ensureCapacity(size_t newCapacity = 0) {
|
||||||
@ -116,6 +122,18 @@ namespace Spine {
|
|||||||
construct(_buffer + _size++, inValue);
|
construct(_buffer + _size++, inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void addAll(Vector<T> &inValue) {
|
||||||
|
ensureCapacity(this->size() + inValue.size());
|
||||||
|
for (size_t i = 0; i < inValue.size(); i++) {
|
||||||
|
add(inValue[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void clearAndAddAll(Vector<T> &inValue) {
|
||||||
|
this->clear();
|
||||||
|
this->addAll(inValue);
|
||||||
|
}
|
||||||
|
|
||||||
inline void removeAt(size_t inIndex) {
|
inline void removeAt(size_t inIndex) {
|
||||||
assert(inIndex < _size);
|
assert(inIndex < _size);
|
||||||
|
|
||||||
@ -198,7 +216,7 @@ namespace Spine {
|
|||||||
inline T* allocate(size_t n) {
|
inline T* allocate(size_t n) {
|
||||||
assert(n > 0);
|
assert(n > 0);
|
||||||
|
|
||||||
T* ptr = SpineExtension::alloc<T>(n, __FILE__, __LINE__);
|
T* ptr = SpineExtension::calloc<T>(n, __FILE__, __LINE__);
|
||||||
|
|
||||||
assert(ptr);
|
assert(ptr);
|
||||||
|
|
||||||
@ -218,6 +236,8 @@ namespace Spine {
|
|||||||
inline void destroy(T* buffer) {
|
inline void destroy(T* buffer) {
|
||||||
buffer->~T();
|
buffer->~T();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector& operator=(const Vector& inVector) { };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,8 +71,9 @@ namespace Spine {
|
|||||||
return _timelines;
|
return _timelines;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::setTimelines(Vector<Timeline*> inValue) {
|
void Animation::setTimelines(Vector<Timeline*>& inValue) {
|
||||||
_timelines = inValue;
|
_timelines.clear();
|
||||||
|
_timelines.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Animation::getDuration() {
|
float Animation::getDuration() {
|
||||||
|
|||||||
@ -139,8 +139,8 @@ namespace Spine {
|
|||||||
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.setSize(timelinesCount);
|
_timelineData.setSize(timelinesCount, 0);
|
||||||
_timelineDipMix.setSize(timelinesCount);
|
_timelineDipMix.setSize(timelinesCount, 0);
|
||||||
|
|
||||||
// outer:
|
// outer:
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -421,7 +421,7 @@ namespace Spine {
|
|||||||
|
|
||||||
bool firstFrame = current._timelinesRotation.size() == 0;
|
bool firstFrame = current._timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
current._timelinesRotation.setSize(timelines.size() << 1);
|
current._timelinesRotation.setSize(timelines.size() << 1, 0);
|
||||||
}
|
}
|
||||||
Vector<float>& timelinesRotation = current._timelinesRotation;
|
Vector<float>& timelinesRotation = current._timelinesRotation;
|
||||||
|
|
||||||
@ -776,7 +776,7 @@ namespace Spine {
|
|||||||
|
|
||||||
bool firstFrame = from->_timelinesRotation.size() == 0;
|
bool firstFrame = from->_timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) {
|
||||||
from->_timelinesRotation.setSize(timelines.size() << 1);
|
from->_timelinesRotation.setSize(timelines.size() << 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>& timelinesRotation = from->_timelinesRotation;
|
Vector<float>& timelinesRotation = from->_timelinesRotation;
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace Spine {
|
|||||||
const char* lastSlash = lastForwardSlash > lastBackwardSlash ? lastForwardSlash : lastBackwardSlash;
|
const char* lastSlash = lastForwardSlash > lastBackwardSlash ? lastForwardSlash : lastBackwardSlash;
|
||||||
if (lastSlash == path) lastSlash++; /* Never drop starting slash. */
|
if (lastSlash == path) lastSlash++; /* Never drop starting slash. */
|
||||||
dirLength = (int)(lastSlash ? lastSlash - path.buffer() : 0);
|
dirLength = (int)(lastSlash ? lastSlash - path.buffer() : 0);
|
||||||
dir = SpineExtension::alloc<char>(dirLength + 1, __FILE__, __LINE__);
|
dir = SpineExtension::calloc<char>(dirLength + 1, __FILE__, __LINE__);
|
||||||
memcpy(dir, path.buffer(), dirLength);
|
memcpy(dir, path.buffer(), dirLength);
|
||||||
dir[dirLength] = '\0';
|
dir[dirLength] = '\0';
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
else if (!page) {
|
else if (!page) {
|
||||||
char* name = mallocString(&str);
|
char* name = mallocString(&str);
|
||||||
char* path = SpineExtension::alloc<char>(dirLength + needsSlash + strlen(name) + 1, __FILE__, __LINE__);
|
char* path = SpineExtension::calloc<char>(dirLength + needsSlash + strlen(name) + 1, __FILE__, __LINE__);
|
||||||
memcpy(path, dir, dirLength);
|
memcpy(path, dir, dirLength);
|
||||||
if (needsSlash) {
|
if (needsSlash) {
|
||||||
path[dirLength] = '/';
|
path[dirLength] = '/';
|
||||||
@ -198,7 +198,7 @@ namespace Spine {
|
|||||||
|
|
||||||
if (count == 4) {
|
if (count == 4) {
|
||||||
/* split is optional */
|
/* split is optional */
|
||||||
region->splits.setSize(4);
|
region->splits.setSize(4, 0);
|
||||||
region->splits[0] = toInt(tuple);
|
region->splits[0] = toInt(tuple);
|
||||||
region->splits[1] = toInt(tuple + 1);
|
region->splits[1] = toInt(tuple + 1);
|
||||||
region->splits[2] = toInt(tuple + 2);
|
region->splits[2] = toInt(tuple + 2);
|
||||||
@ -209,7 +209,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.setSize(4);
|
region->pads.setSize(4, 0);
|
||||||
region->pads[0] = toInt(tuple);
|
region->pads[0] = toInt(tuple);
|
||||||
region->pads[1] = toInt(tuple + 1);
|
region->pads[1] = toInt(tuple + 1);
|
||||||
region->pads[2] = toInt(tuple + 2);
|
region->pads[2] = toInt(tuple + 2);
|
||||||
@ -328,7 +328,7 @@ namespace Spine {
|
|||||||
|
|
||||||
char* Atlas::mallocString(Str* str) {
|
char* Atlas::mallocString(Str* str) {
|
||||||
int length = (int)(str->end - str->begin);
|
int length = (int)(str->end - str->begin);
|
||||||
char* string = SpineExtension::alloc<char>(length + 1, __FILE__, __LINE__);
|
char* string = SpineExtension::calloc<char>(length + 1, __FILE__, __LINE__);
|
||||||
memcpy(string, str->begin, length);
|
memcpy(string, str->begin, length);
|
||||||
string[length] = '\0';
|
string[length] = '\0';
|
||||||
return string;
|
return string;
|
||||||
|
|||||||
@ -45,7 +45,7 @@ namespace Spine {
|
|||||||
_frames.ensureCapacity(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
_attachmentNames.ensureCapacity(frameCount);
|
_attachmentNames.ensureCapacity(frameCount);
|
||||||
|
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount, 0);
|
||||||
|
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
_attachmentNames.add(String());
|
_attachmentNames.add(String());
|
||||||
@ -108,7 +108,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentTimeline::setFrames(Vector<float>& inValue) {
|
void AttachmentTimeline::setFrames(Vector<float>& inValue) {
|
||||||
_frames = inValue;
|
_frames.clear();
|
||||||
|
_frames.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vector<String>& AttachmentTimeline::getAttachmentNames() {
|
const Vector<String>& AttachmentTimeline::getAttachmentNames() {
|
||||||
@ -116,7 +117,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AttachmentTimeline::setAttachmentNames(Vector<String>& inValue) {
|
void AttachmentTimeline::setAttachmentNames(Vector<String>& inValue) {
|
||||||
_attachmentNames = inValue;
|
_attachmentNames.clear();
|
||||||
|
_attachmentNames.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AttachmentTimeline::getFrameCount() {
|
int AttachmentTimeline::getFrameCount() {
|
||||||
|
|||||||
@ -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.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void ColorTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
@ -139,6 +139,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ColorTimeline::setFrames(Vector<float>& inValue) {
|
void ColorTimeline::setFrames(Vector<float>& inValue) {
|
||||||
_frames = inValue;
|
_frames.clear();
|
||||||
|
_frames.addAll(inValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace Spine {
|
|||||||
CurveTimeline::CurveTimeline(int frameCount) {
|
CurveTimeline::CurveTimeline(int frameCount) {
|
||||||
assert(frameCount > 0);
|
assert(frameCount > 0);
|
||||||
|
|
||||||
_curves.setSize((frameCount - 1) * BEZIER_SIZE);
|
_curves.setSize((frameCount - 1) * BEZIER_SIZE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurveTimeline::~CurveTimeline() {
|
CurveTimeline::~CurveTimeline() {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ namespace Spine {
|
|||||||
_frames.ensureCapacity(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
_frameVertices.ensureCapacity(frameCount);
|
_frameVertices.ensureCapacity(frameCount);
|
||||||
|
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount, 0);
|
||||||
|
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
Vector<float> vec;
|
Vector<float> vec;
|
||||||
@ -87,7 +87,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure size and preemptively set count.
|
// Ensure size and preemptively set count.
|
||||||
vertices.setSize(vertexCount);
|
vertices.setSize(vertexCount, 0);
|
||||||
|
|
||||||
if (vertexAttachment->_bones.size() == 0) {
|
if (vertexAttachment->_bones.size() == 0) {
|
||||||
// Unweighted vertex positions.
|
// Unweighted vertex positions.
|
||||||
@ -110,7 +110,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure size and preemptively set count.
|
// Ensure size and preemptively set count.
|
||||||
vertices.setSize(vertexCount);
|
vertices.setSize(vertexCount, 0);
|
||||||
|
|
||||||
if (time >= _frames[_frames.size() - 1]) {
|
if (time >= _frames[_frames.size() - 1]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
@ -196,7 +196,8 @@ namespace Spine {
|
|||||||
|
|
||||||
void DeformTimeline::setFrame(int frameIndex, float time, Vector<float>& vertices) {
|
void DeformTimeline::setFrame(int frameIndex, float time, Vector<float>& vertices) {
|
||||||
_frames[frameIndex] = time;
|
_frames[frameIndex] = time;
|
||||||
_frameVertices[frameIndex] = vertices;
|
_frameVertices[frameIndex].clear();
|
||||||
|
_frameVertices[frameIndex].addAll(vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DeformTimeline::getSlotIndex() {
|
int DeformTimeline::getSlotIndex() {
|
||||||
@ -212,7 +213,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeformTimeline::setFrames(Vector<float>& inValue) {
|
void DeformTimeline::setFrames(Vector<float>& inValue) {
|
||||||
_frames = inValue;
|
_frames.clear();
|
||||||
|
_frames.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector< Vector<float> >& DeformTimeline::getVertices() {
|
Vector< Vector<float> >& DeformTimeline::getVertices() {
|
||||||
@ -220,7 +222,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeformTimeline::setVertices(Vector< Vector<float> >& inValue) {
|
void DeformTimeline::setVertices(Vector< Vector<float> >& inValue) {
|
||||||
_frameVertices = inValue;
|
_frameVertices.clear();
|
||||||
|
_frameVertices.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexAttachment* DeformTimeline::getAttachment() {
|
VertexAttachment* DeformTimeline::getAttachment() {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ namespace Spine {
|
|||||||
_frames.ensureCapacity(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
_drawOrders.ensureCapacity(frameCount);
|
_drawOrders.ensureCapacity(frameCount);
|
||||||
|
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount, 0);
|
||||||
|
|
||||||
for (int i = 0; i < frameCount; ++i) {
|
for (int i = 0; i < frameCount; ++i) {
|
||||||
Vector<int> vec;
|
Vector<int> vec;
|
||||||
@ -105,7 +105,8 @@ namespace Spine {
|
|||||||
|
|
||||||
void DrawOrderTimeline::setFrame(int frameIndex, float time, Vector<int>& drawOrder) {
|
void DrawOrderTimeline::setFrame(int frameIndex, float time, Vector<int>& drawOrder) {
|
||||||
_frames[frameIndex] = time;
|
_frames[frameIndex] = time;
|
||||||
_drawOrders[frameIndex] = drawOrder;
|
_drawOrders[frameIndex].clear();
|
||||||
|
_drawOrders[frameIndex].addAll(drawOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>& DrawOrderTimeline::getFrames() {
|
Vector<float>& DrawOrderTimeline::getFrames() {
|
||||||
@ -113,7 +114,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DrawOrderTimeline::setFrames(Vector<float>& inValue) {
|
void DrawOrderTimeline::setFrames(Vector<float>& inValue) {
|
||||||
_frames = inValue;
|
_frames.clear();
|
||||||
|
_frames.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector< Vector<int> >& DrawOrderTimeline::getDrawOrders() {
|
Vector< Vector<int> >& DrawOrderTimeline::getDrawOrders() {
|
||||||
@ -121,7 +123,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DrawOrderTimeline::setDrawOrders(Vector< Vector<int> >& inValue) {
|
void DrawOrderTimeline::setDrawOrders(Vector< Vector<int> >& inValue) {
|
||||||
_drawOrders = inValue;
|
_drawOrders.clear();
|
||||||
|
_drawOrders.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrawOrderTimeline::getFrameCount() {
|
int DrawOrderTimeline::getFrameCount() {
|
||||||
|
|||||||
@ -38,14 +38,15 @@
|
|||||||
#include <spine/Slot.h>
|
#include <spine/Slot.h>
|
||||||
#include <spine/SlotData.h>
|
#include <spine/SlotData.h>
|
||||||
#include <spine/Event.h>
|
#include <spine/Event.h>
|
||||||
|
#include <spine/EventData.h>
|
||||||
#include <spine/ContainerUtil.h>
|
#include <spine/ContainerUtil.h>
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
RTTI_IMPL(EventTimeline, Timeline);
|
RTTI_IMPL(EventTimeline, Timeline);
|
||||||
|
|
||||||
EventTimeline::EventTimeline(int frameCount) : Timeline() {
|
EventTimeline::EventTimeline(int frameCount) : Timeline() {
|
||||||
_frames.setSize(frameCount);
|
_frames.setSize(frameCount, 0);
|
||||||
_events.setSize(frameCount);
|
_events.setSize(frameCount, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventTimeline::~EventTimeline() {
|
EventTimeline::~EventTimeline() {
|
||||||
@ -110,8 +111,8 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<float> EventTimeline::getFrames() { return _frames; }
|
Vector<float> EventTimeline::getFrames() { return _frames; }
|
||||||
void EventTimeline::setFrames(Vector<float>& inValue) { _frames = inValue; } // time, ...
|
void EventTimeline::setFrames(Vector<float>& inValue) { _frames.clear(); _frames.addAll(inValue); } // time, ...
|
||||||
Vector<Event*>& EventTimeline::getEvents() { return _events; }
|
Vector<Event*>& EventTimeline::getEvents() { return _events; }
|
||||||
void EventTimeline::setEvents(Vector<Event*>& inValue) { _events = inValue; }
|
void EventTimeline::setEvents(Vector<Event*>& inValue) { _events.clear(); _events.addAll(inValue); }
|
||||||
int EventTimeline::getFrameCount() { return static_cast<int>(_frames.size()); }
|
int EventTimeline::getFrameCount() { return static_cast<int>(_frames.size()); }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IkConstraintTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void IkConstraintTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
|
|||||||
@ -59,7 +59,7 @@
|
|||||||
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.setSize(_regionUVs.size());
|
_uvs.setSize(_regionUVs.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_regionRotate) {
|
if (_regionRotate) {
|
||||||
@ -93,7 +93,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MeshAttachment::setRegionUVs(Vector<float>& inValue) {
|
void MeshAttachment::setRegionUVs(Vector<float>& inValue) {
|
||||||
_regionUVs = inValue;
|
_regionUVs.clear();
|
||||||
|
_regionUVs.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>& MeshAttachment::getUVs() {
|
Vector<float>& MeshAttachment::getUVs() {
|
||||||
@ -101,7 +102,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MeshAttachment::setUVs(Vector<float>& inValue) {
|
void MeshAttachment::setUVs(Vector<float>& inValue) {
|
||||||
_uvs = inValue;
|
_uvs.clear();
|
||||||
|
_uvs.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<unsigned short>& MeshAttachment::getTriangles() {
|
Vector<unsigned short>& MeshAttachment::getTriangles() {
|
||||||
@ -109,7 +111,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MeshAttachment::setTriangles(Vector<unsigned short>& inValue) {
|
void MeshAttachment::setTriangles(Vector<unsigned short>& inValue) {
|
||||||
_triangles = inValue;
|
_triangles.clear();
|
||||||
|
_triangles.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
const String& MeshAttachment::getPath() {
|
const String& MeshAttachment::getPath() {
|
||||||
@ -231,13 +234,13 @@
|
|||||||
void MeshAttachment::setParentMesh(MeshAttachment* inValue) {
|
void MeshAttachment::setParentMesh(MeshAttachment* inValue) {
|
||||||
_parentMesh = inValue;
|
_parentMesh = inValue;
|
||||||
if (inValue != NULL) {
|
if (inValue != NULL) {
|
||||||
_bones = inValue->_bones;
|
_bones.clearAndAddAll(inValue->_bones);
|
||||||
_vertices = inValue->_vertices;
|
_vertices.clearAndAddAll(inValue->_vertices);
|
||||||
_worldVerticesLength = inValue->_worldVerticesLength;
|
_worldVerticesLength = inValue->_worldVerticesLength;
|
||||||
_regionUVs = inValue->_regionUVs;
|
_regionUVs.clearAndAddAll(inValue->_regionUVs);
|
||||||
_triangles = inValue->_triangles;
|
_triangles.clearAndAddAll(inValue->_triangles);
|
||||||
_hullLength = inValue->_hullLength;
|
_hullLength = inValue->_hullLength;
|
||||||
_edges = inValue->_edges;
|
_edges.clearAndAddAll(inValue->_edges);
|
||||||
_width = inValue->_width;
|
_width = inValue->_width;
|
||||||
_height = inValue->_height;
|
_height = inValue->_height;
|
||||||
}
|
}
|
||||||
@ -248,7 +251,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MeshAttachment::setEdges(Vector<unsigned short>& inValue) {
|
void MeshAttachment::setEdges(Vector<unsigned short>& inValue) {
|
||||||
_edges = inValue;
|
_edges.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
float MeshAttachment::getWidth() {
|
float MeshAttachment::getWidth() {
|
||||||
|
|||||||
@ -40,8 +40,9 @@ namespace Spine {
|
|||||||
return _lengths;
|
return _lengths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathAttachment::setLengths(Vector<float> inValue) {
|
void PathAttachment::setLengths(Vector<float>& inValue) {
|
||||||
_lengths = inValue;
|
_lengths.clear();
|
||||||
|
_lengths.addAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathAttachment::isClosed() {
|
bool PathAttachment::isClosed() {
|
||||||
|
|||||||
@ -64,7 +64,7 @@ namespace Spine {
|
|||||||
_bones.add(skeleton.findBone(boneData->getName()));
|
_bones.add(skeleton.findBone(boneData->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
_segments.setSize(10);
|
_segments.setSize(10, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathConstraint::apply() {
|
void PathConstraint::apply() {
|
||||||
@ -94,11 +94,11 @@ 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.setSize(spacesCount);
|
_spaces.setSize(spacesCount, 0);
|
||||||
float spacing = _spacing;
|
float spacing = _spacing;
|
||||||
if (scale || lengthSpacing) {
|
if (scale || lengthSpacing) {
|
||||||
if (scale) {
|
if (scale) {
|
||||||
_lengths.setSize(boneCount);
|
_lengths.setSize(boneCount, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = spacesCount - 1; i < n;) {
|
for (int i = 0, n = spacesCount - 1; i < n;) {
|
||||||
@ -264,7 +264,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.setSize(spacesCount * 3 + 2);
|
_positions.setSize(spacesCount * 3 + 2, 0);
|
||||||
bool closed = path.isClosed();
|
bool closed = path.isClosed();
|
||||||
int verticesLength = path.getWorldVerticesLength();
|
int verticesLength = path.getWorldVerticesLength();
|
||||||
int curveCount = verticesLength / 6;
|
int curveCount = verticesLength / 6;
|
||||||
@ -285,7 +285,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_world.setSize(8);
|
_world.setSize(8, 0);
|
||||||
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];
|
||||||
position += space;
|
position += space;
|
||||||
@ -356,7 +356,7 @@ namespace Spine {
|
|||||||
// World vertices.
|
// World vertices.
|
||||||
if (closed) {
|
if (closed) {
|
||||||
verticesLength += 2;
|
verticesLength += 2;
|
||||||
_world.setSize(verticesLength);
|
_world.setSize(verticesLength, 0);
|
||||||
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);
|
||||||
_world[verticesLength - 2] = _world[0];
|
_world[verticesLength - 2] = _world[0];
|
||||||
@ -365,12 +365,12 @@ namespace Spine {
|
|||||||
else {
|
else {
|
||||||
curveCount--;
|
curveCount--;
|
||||||
verticesLength -= 4;
|
verticesLength -= 4;
|
||||||
_world.setSize(verticesLength);
|
_world.setSize(verticesLength, 0);
|
||||||
path.computeWorldVertices(target, 2, verticesLength, _world, 0);
|
path.computeWorldVertices(target, 2, verticesLength, _world, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Curve lengths.
|
// Curve lengths.
|
||||||
_curves.setSize(curveCount);
|
_curves.setSize(curveCount, 0);
|
||||||
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;
|
||||||
float tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy;
|
float tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy;
|
||||||
|
|||||||
@ -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.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathConstraintMixTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void PathConstraintMixTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
|
|||||||
@ -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.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathConstraintPositionTimeline::~PathConstraintPositionTimeline() {
|
PathConstraintPositionTimeline::~PathConstraintPositionTimeline() {
|
||||||
|
|||||||
@ -70,8 +70,8 @@ namespace Spine {
|
|||||||
_regionU2(0),
|
_regionU2(0),
|
||||||
_regionV2(0),
|
_regionV2(0),
|
||||||
_color(1, 1, 1, 1) {
|
_color(1, 1, 1, 1) {
|
||||||
_offset.setSize(NUM_UVS);
|
_vertexOffset.setSize(NUM_UVS, 0);
|
||||||
_uvs.setSize(NUM_UVS);
|
_uvs.setSize(NUM_UVS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionAttachment::updateOffset() {
|
void RegionAttachment::updateOffset() {
|
||||||
@ -92,14 +92,14 @@ namespace Spine {
|
|||||||
float localY2Cos = localY2 * cos + _y;
|
float localY2Cos = localY2 * cos + _y;
|
||||||
float localY2Sin = localY2 * sin;
|
float localY2Sin = localY2 * sin;
|
||||||
|
|
||||||
_offset[BLX] = localXCos - localYSin;
|
_vertexOffset[BLX] = localXCos - localYSin;
|
||||||
_offset[BLY] = localYCos + localXSin;
|
_vertexOffset[BLY] = localYCos + localXSin;
|
||||||
_offset[ULX] = localXCos - localY2Sin;
|
_vertexOffset[ULX] = localXCos - localY2Sin;
|
||||||
_offset[ULY] = localY2Cos + localXSin;
|
_vertexOffset[ULY] = localY2Cos + localXSin;
|
||||||
_offset[URX] = localX2Cos - localY2Sin;
|
_vertexOffset[URX] = localX2Cos - localY2Sin;
|
||||||
_offset[URY] = localY2Cos + localX2Sin;
|
_vertexOffset[URY] = localY2Cos + localX2Sin;
|
||||||
_offset[BRX] = localX2Cos - localYSin;
|
_vertexOffset[BRX] = localX2Cos - localYSin;
|
||||||
_offset[BRY] = localYCos + localX2Sin;
|
_vertexOffset[BRY] = localYCos + localX2Sin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegionAttachment::setUVs(float u, float v, float u2, float v2, bool rotate) {
|
void RegionAttachment::setUVs(float u, float v, float u2, float v2, bool rotate) {
|
||||||
@ -128,32 +128,32 @@ namespace Spine {
|
|||||||
void RegionAttachment::computeWorldVertices(Bone& bone, Vector<float>& worldVertices, int offset, int stride) {
|
void RegionAttachment::computeWorldVertices(Bone& bone, Vector<float>& worldVertices, int offset, int stride) {
|
||||||
assert(worldVertices.size() >= (offset + 8));
|
assert(worldVertices.size() >= (offset + 8));
|
||||||
|
|
||||||
float bwx = bone._worldX, bwy = bone._worldY;
|
float x = bone.getWorldX(), y = bone.getWorldY();
|
||||||
float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
|
float a = bone.getA(), b = bone.getB(), c = bone.getC(), d = bone.getD();
|
||||||
float offsetX, offsetY;
|
float offsetX, offsetY;
|
||||||
|
|
||||||
offsetX = _offset[BRX]; // 0
|
offsetX = _vertexOffset[BRX];
|
||||||
offsetY = _offset[BRY]; // 1
|
offsetY = _vertexOffset[BRY];
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // bl
|
worldVertices[offset] = offsetX * a + offsetY * b + x; // br
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||||
offset += stride;
|
offset += stride;
|
||||||
|
|
||||||
offsetX = _offset[BLX]; // 2
|
offsetX = _vertexOffset[BLX];
|
||||||
offsetY = _offset[BLY]; // 3
|
offsetY = _vertexOffset[BLY];
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // ul
|
worldVertices[offset] = offsetX * a + offsetY * b + x; // bl
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||||
offset += stride;
|
offset += stride;
|
||||||
|
|
||||||
offsetX = _offset[ULX]; // 4
|
offsetX = _vertexOffset[ULX];
|
||||||
offsetY = _offset[ULY]; // 5
|
offsetY = _vertexOffset[ULY];
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // ur
|
worldVertices[offset] = offsetX * a + offsetY * b + x; // ul
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||||
offset += stride;
|
offset += stride;
|
||||||
|
|
||||||
offsetX = _offset[URX]; // 6
|
offsetX = _vertexOffset[URX];
|
||||||
offsetY = _offset[URY]; // 7
|
offsetY = _vertexOffset[URY];
|
||||||
worldVertices[offset] = offsetX * a + offsetY * b + bwx; // br
|
worldVertices[offset] = offsetX * a + offsetY * b + x; // ur
|
||||||
worldVertices[offset + 1] = offsetX * c + offsetY * d + bwy;
|
worldVertices[offset + 1] = offsetX * c + offsetY * d + y;
|
||||||
}
|
}
|
||||||
|
|
||||||
float RegionAttachment::getX() {
|
float RegionAttachment::getX() {
|
||||||
@ -277,7 +277,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>& RegionAttachment::getOffset() {
|
Vector<float>& RegionAttachment::getOffset() {
|
||||||
return _offset;
|
return _vertexOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>& RegionAttachment::getUVs() {
|
Vector<float>& RegionAttachment::getUVs() {
|
||||||
|
|||||||
@ -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.setSize(frameCount << 1);
|
_frames.setSize(frameCount << 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void RotateTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
@ -127,6 +127,6 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RotateTimeline::setFrames(Vector<float> inValue) {
|
void RotateTimeline::setFrames(Vector<float> inValue) {
|
||||||
_frames = inValue;
|
_frames.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -412,7 +412,7 @@ namespace Spine {
|
|||||||
|
|
||||||
verticesLength = 8;
|
verticesLength = 8;
|
||||||
if (outVertexBuffer.size() < 8) {
|
if (outVertexBuffer.size() < 8) {
|
||||||
outVertexBuffer.setSize(8);
|
outVertexBuffer.setSize(8, 0);
|
||||||
}
|
}
|
||||||
regionAttachment->computeWorldVertices(slot->getBone(), outVertexBuffer, 0);
|
regionAttachment->computeWorldVertices(slot->getBone(), outVertexBuffer, 0);
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ namespace Spine {
|
|||||||
|
|
||||||
verticesLength = mesh->getWorldVerticesLength();
|
verticesLength = mesh->getWorldVerticesLength();
|
||||||
if (outVertexBuffer.size() < verticesLength) {
|
if (outVertexBuffer.size() < verticesLength) {
|
||||||
outVertexBuffer.setSize(verticesLength);
|
outVertexBuffer.setSize(verticesLength, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh->computeWorldVertices(*slot, 0, verticesLength, outVertexBuffer, 0);
|
mesh->computeWorldVertices(*slot, 0, verticesLength, outVertexBuffer, 0);
|
||||||
|
|||||||
@ -147,7 +147,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Bones. */
|
/* Bones. */
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
skeletonData->_bones.setSize(bonesCount);
|
skeletonData->_bones.setSize(bonesCount, 0);
|
||||||
for (int i = 0; i < bonesCount; ++i) {
|
for (int i = 0; i < bonesCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
BoneData* parent = i == 0 ? 0 : skeletonData->_bones[readVarint(input, true)];
|
BoneData* parent = i == 0 ? 0 : skeletonData->_bones[readVarint(input, true)];
|
||||||
@ -170,7 +170,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Slots. */
|
/* Slots. */
|
||||||
int slotsCount = readVarint(input, true);
|
int slotsCount = readVarint(input, true);
|
||||||
skeletonData->_slots.setSize(slotsCount);
|
skeletonData->_slots.setSize(slotsCount, 0);
|
||||||
for (int i = 0; i < slotsCount; ++i) {
|
for (int i = 0; i < slotsCount; ++i) {
|
||||||
const char* slotName = readString(input);
|
const char* slotName = readString(input);
|
||||||
BoneData* boneData = skeletonData->_bones[readVarint(input, true)];
|
BoneData* boneData = skeletonData->_bones[readVarint(input, true)];
|
||||||
@ -192,13 +192,13 @@ namespace Spine {
|
|||||||
|
|
||||||
/* IK constraints. */
|
/* IK constraints. */
|
||||||
int ikConstraintsCount = readVarint(input, true);
|
int ikConstraintsCount = readVarint(input, true);
|
||||||
skeletonData->_ikConstraints.setSize(ikConstraintsCount);
|
skeletonData->_ikConstraints.setSize(ikConstraintsCount, 0);
|
||||||
for (int i = 0; i < ikConstraintsCount; ++i) {
|
for (int i = 0; i < ikConstraintsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(String(name, true));
|
IkConstraintData* data = new (__FILE__, __LINE__) IkConstraintData(String(name, true));
|
||||||
data->_order = readVarint(input, true);
|
data->_order = readVarint(input, true);
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
data->_bones.setSize(bonesCount);
|
data->_bones.setSize(bonesCount, 0);
|
||||||
for (int ii = 0; ii < bonesCount; ++ii) {
|
for (int ii = 0; ii < bonesCount; ++ii) {
|
||||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||||
}
|
}
|
||||||
@ -210,13 +210,13 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Transform constraints. */
|
/* Transform constraints. */
|
||||||
int transformConstraintsCount = readVarint(input, true);
|
int transformConstraintsCount = readVarint(input, true);
|
||||||
skeletonData->_transformConstraints.setSize(transformConstraintsCount);
|
skeletonData->_transformConstraints.setSize(transformConstraintsCount, 0);
|
||||||
for (int i = 0; i < transformConstraintsCount; ++i) {
|
for (int i = 0; i < transformConstraintsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(String(name, true));
|
TransformConstraintData* data = new (__FILE__, __LINE__) TransformConstraintData(String(name, true));
|
||||||
data->_order = readVarint(input, true);
|
data->_order = readVarint(input, true);
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
data->_bones.setSize(bonesCount);
|
data->_bones.setSize(bonesCount, 0);
|
||||||
for (int ii = 0; ii < bonesCount; ++ii) {
|
for (int ii = 0; ii < bonesCount; ++ii) {
|
||||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||||
}
|
}
|
||||||
@ -238,13 +238,13 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Path constraints */
|
/* Path constraints */
|
||||||
int pathConstraintsCount = readVarint(input, true);
|
int pathConstraintsCount = readVarint(input, true);
|
||||||
skeletonData->_pathConstraints.setSize(pathConstraintsCount);
|
skeletonData->_pathConstraints.setSize(pathConstraintsCount, 0);
|
||||||
for (int i = 0; i < pathConstraintsCount; ++i) {
|
for (int i = 0; i < pathConstraintsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(String(name, true));
|
PathConstraintData* data = new (__FILE__, __LINE__) PathConstraintData(String(name, true));
|
||||||
data->_order = readVarint(input, true);
|
data->_order = readVarint(input, true);
|
||||||
int bonesCount = readVarint(input, true);
|
int bonesCount = readVarint(input, true);
|
||||||
data->_bones.setSize(bonesCount);
|
data->_bones.setSize(bonesCount, 0);
|
||||||
for (int ii = 0; ii < bonesCount; ++ii) {
|
for (int ii = 0; ii < bonesCount; ++ii) {
|
||||||
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
data->_bones[ii] = skeletonData->_bones[readVarint(input, true)];
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ namespace Spine {
|
|||||||
if (skeletonData->_defaultSkin) {
|
if (skeletonData->_defaultSkin) {
|
||||||
++skinsCount;
|
++skinsCount;
|
||||||
}
|
}
|
||||||
skeletonData->_skins.setSize(skinsCount);
|
skeletonData->_skins.setSize(skinsCount, 0);
|
||||||
if (skeletonData->_defaultSkin) {
|
if (skeletonData->_defaultSkin) {
|
||||||
skeletonData->_skins[0] = skeletonData->_defaultSkin;
|
skeletonData->_skins[0] = skeletonData->_defaultSkin;
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Events. */
|
/* Events. */
|
||||||
int eventsCount = readVarint(input, true);
|
int eventsCount = readVarint(input, true);
|
||||||
skeletonData->_events.setSize(eventsCount);
|
skeletonData->_events.setSize(eventsCount, 0);
|
||||||
for (int i = 0; i < eventsCount; ++i) {
|
for (int i = 0; i < eventsCount; ++i) {
|
||||||
const char* name = readString(input);
|
const char* name = readString(input);
|
||||||
EventData* eventData = new (__FILE__, __LINE__) EventData(String(name, true));
|
EventData* eventData = new (__FILE__, __LINE__) EventData(String(name, true));
|
||||||
@ -317,7 +317,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Animations. */
|
/* Animations. */
|
||||||
int animationsCount = readVarint(input, true);
|
int animationsCount = readVarint(input, true);
|
||||||
skeletonData->_animations.setSize(animationsCount);
|
skeletonData->_animations.setSize(animationsCount, 0);
|
||||||
for (int i = 0; i < animationsCount; ++i) {
|
for (int i = 0; i < animationsCount; ++i) {
|
||||||
String name(readString(input), true);
|
String name(readString(input), true);
|
||||||
Animation* animation = readAnimation(name, input, skeletonData);
|
Animation* animation = readAnimation(name, input, skeletonData);
|
||||||
@ -534,7 +534,7 @@ namespace Spine {
|
|||||||
int vertexCount = readVarint(input, true);
|
int 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.setSize(lengthsLength);
|
path->_lengths.setSize(lengthsLength, 0);
|
||||||
for (int i = 0; i < lengthsLength; ++i) {
|
for (int i = 0; i < lengthsLength; ++i) {
|
||||||
path->_lengths[i] = readFloat(input) * _scale;
|
path->_lengths[i] = readFloat(input) * _scale;
|
||||||
}
|
}
|
||||||
@ -601,7 +601,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonBinary::readFloatArray(DataInput *input, int n, float scale, Vector<float>& array) {
|
void SkeletonBinary::readFloatArray(DataInput *input, int n, float scale, Vector<float>& array) {
|
||||||
array.setSize(n);
|
array.setSize(n, 0);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
@ -618,7 +618,7 @@ namespace Spine {
|
|||||||
|
|
||||||
void SkeletonBinary::readShortArray(DataInput *input, Vector<unsigned short>& array) {
|
void SkeletonBinary::readShortArray(DataInput *input, Vector<unsigned short>& array) {
|
||||||
int n = readVarint(input, true);
|
int n = readVarint(input, true);
|
||||||
array.setSize(n);
|
array.setSize(n, 0);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < n; ++i) {
|
for (i = 0; i < n; ++i) {
|
||||||
@ -877,17 +877,17 @@ namespace Spine {
|
|||||||
int end = readVarint(input, true);
|
int end = readVarint(input, true);
|
||||||
if (end == 0) {
|
if (end == 0) {
|
||||||
if (weighted) {
|
if (weighted) {
|
||||||
deform.setSize(deformLength);
|
deform.setSize(deformLength, 0);
|
||||||
for (int i = 0; i < deformLength; ++i) {
|
for (int i = 0; i < deformLength; ++i) {
|
||||||
deform[i] = 0;
|
deform[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deform = vertices;
|
deform.clearAndAddAll(vertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deform.setSize(deformLength);
|
deform.setSize(deformLength, 0);
|
||||||
int start = readVarint(input, true);
|
int start = readVarint(input, true);
|
||||||
end += start;
|
end += start;
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
@ -931,13 +931,13 @@ namespace Spine {
|
|||||||
int offsetCount = readVarint(input, true);
|
int offsetCount = readVarint(input, true);
|
||||||
|
|
||||||
Vector<int> drawOrder;
|
Vector<int> drawOrder;
|
||||||
drawOrder.setSize(slotCount);
|
drawOrder.setSize(slotCount, 0);
|
||||||
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.setSize(slotCount - offsetCount);
|
unchanged.setSize(slotCount - offsetCount, 0);
|
||||||
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);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ namespace Spine {
|
|||||||
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.setSize(count);
|
polygon._vertices.setSize(count, 0);
|
||||||
}
|
}
|
||||||
boundingBox->computeWorldVertices(*slot, polygon._vertices);
|
boundingBox->computeWorldVertices(*slot, polygon._vertices);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,12 +49,12 @@ namespace Spine {
|
|||||||
_clipAttachment = clip;
|
_clipAttachment = clip;
|
||||||
|
|
||||||
int n = clip->getWorldVerticesLength();
|
int n = clip->getWorldVerticesLength();
|
||||||
_clippingPolygon.setSize(n);
|
_clippingPolygon.setSize(n, 0);
|
||||||
clip->computeWorldVertices(slot, 0, n, _clippingPolygon, 0, 2);
|
clip->computeWorldVertices(slot, 0, n, _clippingPolygon, 0, 2);
|
||||||
makeClockwise(_clippingPolygon);
|
makeClockwise(_clippingPolygon);
|
||||||
Vector< Vector<float>* > clippingPolygons = _triangulator.decompose(_clippingPolygon, _triangulator.triangulate(_clippingPolygon));
|
Vector< Vector<float>* > clippingPolygons = _triangulator.decompose(_clippingPolygon, _triangulator.triangulate(_clippingPolygon));
|
||||||
|
|
||||||
_clippingPolygons = clippingPolygons;
|
_clippingPolygons.clearAndAddAll(clippingPolygons);
|
||||||
|
|
||||||
for (size_t i = 0; i < _clippingPolygons.size(); ++i) {
|
for (size_t i = 0; i < _clippingPolygons.size(); ++i) {
|
||||||
Vector<float>* polygonP = _clippingPolygons[i];
|
Vector<float>* polygonP = _clippingPolygons[i];
|
||||||
@ -123,8 +123,8 @@ 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.setSize(s + clipOutputCount * 2);
|
clippedVertices.setSize(s + clipOutputCount * 2, 0);
|
||||||
_clippedUVs.setSize(s + clipOutputCount * 2);
|
_clippedUVs.setSize(s + clipOutputCount * 2, 0);
|
||||||
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];
|
||||||
clippedVertices[s] = x;
|
clippedVertices[s] = x;
|
||||||
@ -139,7 +139,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s = static_cast<int>(clippedTriangles.size());
|
s = static_cast<int>(clippedTriangles.size());
|
||||||
clippedTriangles.setSize(s + 3 * (clipOutputCount - 2));
|
clippedTriangles.setSize(s + 3 * (clipOutputCount - 2), 0);
|
||||||
clipOutputCount--;
|
clipOutputCount--;
|
||||||
for (int ii = 1; ii < clipOutputCount; ii++) {
|
for (int ii = 1; ii < clipOutputCount; ii++) {
|
||||||
clippedTriangles[s] = index;
|
clippedTriangles[s] = index;
|
||||||
@ -150,8 +150,8 @@ namespace Spine {
|
|||||||
index += clipOutputCount + 1;
|
index += clipOutputCount + 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clippedVertices.setSize(s + 3 * 2);
|
clippedVertices.setSize(s + 3 * 2, 0);
|
||||||
_clippedUVs.setSize(s + 3 * 2);
|
_clippedUVs.setSize(s + 3 * 2, 0);
|
||||||
clippedVertices[s] = x1;
|
clippedVertices[s] = x1;
|
||||||
clippedVertices[s + 1] = y1;
|
clippedVertices[s + 1] = y1;
|
||||||
clippedVertices[s + 2] = x2;
|
clippedVertices[s + 2] = x2;
|
||||||
@ -167,7 +167,7 @@ namespace Spine {
|
|||||||
_clippedUVs[s + 5] = v3;
|
_clippedUVs[s + 5] = v3;
|
||||||
|
|
||||||
s = static_cast<int>(clippedTriangles.size());
|
s = static_cast<int>(clippedTriangles.size());
|
||||||
clippedTriangles.setSize(s + 3);
|
clippedTriangles.setSize(s + 3, 0);
|
||||||
clippedTriangles[s] = index;
|
clippedTriangles[s] = index;
|
||||||
clippedTriangles[s + 1] = index + 1;
|
clippedTriangles[s + 1] = index + 1;
|
||||||
clippedTriangles[s + 2] = index + 2;
|
clippedTriangles[s + 2] = index + 2;
|
||||||
@ -283,7 +283,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
originalOutput->setSize(originalOutput->size() - 2);
|
originalOutput->setSize(originalOutput->size() - 2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clipped;
|
return clipped;
|
||||||
|
|||||||
@ -134,7 +134,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonData::setSkins(Vector<Skin*>& inValue) {
|
void SkeletonData::setSkins(Vector<Skin*>& inValue) {
|
||||||
_skins = inValue;
|
_skins.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Skin* SkeletonData::getDefaultSkin() {
|
Skin* SkeletonData::getDefaultSkin() {
|
||||||
@ -150,7 +150,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonData::setEvents(Vector<EventData*>& inValue) {
|
void SkeletonData::setEvents(Vector<EventData*>& inValue) {
|
||||||
_events = inValue;
|
_events.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Animation*>& SkeletonData::getAnimations() {
|
Vector<Animation*>& SkeletonData::getAnimations() {
|
||||||
@ -158,7 +158,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonData::setAnimations(Vector<Animation*>& inValue) {
|
void SkeletonData::setAnimations(Vector<Animation*>& inValue) {
|
||||||
_animations = inValue;
|
_animations.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<IkConstraintData*>& SkeletonData::getIkConstraints() {
|
Vector<IkConstraintData*>& SkeletonData::getIkConstraints() {
|
||||||
@ -166,7 +166,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonData::setIkConstraints(Vector<IkConstraintData*>& inValue) {
|
void SkeletonData::setIkConstraints(Vector<IkConstraintData*>& inValue) {
|
||||||
_ikConstraints = inValue;
|
_ikConstraints.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<TransformConstraintData*>& SkeletonData::getTransformConstraints() {
|
Vector<TransformConstraintData*>& SkeletonData::getTransformConstraints() {
|
||||||
@ -174,7 +174,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonData::setTransformConstraints(Vector<TransformConstraintData*>& inValue) {
|
void SkeletonData::setTransformConstraints(Vector<TransformConstraintData*>& inValue) {
|
||||||
_transformConstraints = inValue;
|
_transformConstraints.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<PathConstraintData*>& SkeletonData::getPathConstraints() {
|
Vector<PathConstraintData*>& SkeletonData::getPathConstraints() {
|
||||||
@ -182,7 +182,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonData::setPathConstraints(Vector<PathConstraintData*>& inValue) {
|
void SkeletonData::setPathConstraints(Vector<PathConstraintData*>& inValue) {
|
||||||
_pathConstraints = inValue;
|
_pathConstraints.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SkeletonData::getWidth() {
|
float SkeletonData::getWidth() {
|
||||||
|
|||||||
@ -144,8 +144,7 @@ namespace Spine {
|
|||||||
|
|
||||||
/* Bones. */
|
/* Bones. */
|
||||||
bones = Json::getItem(root, "bones");
|
bones = Json::getItem(root, "bones");
|
||||||
skeletonData->_bones.ensureCapacity(bones->_size);
|
skeletonData->_bones.setSize(bones->_size, 0);
|
||||||
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) {
|
||||||
BoneData* data;
|
BoneData* data;
|
||||||
@ -199,7 +198,7 @@ namespace Spine {
|
|||||||
if (slots) {
|
if (slots) {
|
||||||
Json *slotMap;
|
Json *slotMap;
|
||||||
skeletonData->_slots.ensureCapacity(slots->_size);
|
skeletonData->_slots.ensureCapacity(slots->_size);
|
||||||
skeletonData->_slots.setSize(slots->_size);
|
skeletonData->_slots.setSize(slots->_size, 0);
|
||||||
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;
|
||||||
const char* color;
|
const char* color;
|
||||||
@ -262,7 +261,7 @@ namespace Spine {
|
|||||||
if (ik) {
|
if (ik) {
|
||||||
Json *constraintMap;
|
Json *constraintMap;
|
||||||
skeletonData->_ikConstraints.ensureCapacity(ik->_size);
|
skeletonData->_ikConstraints.ensureCapacity(ik->_size);
|
||||||
skeletonData->_ikConstraints.setSize(ik->_size);
|
skeletonData->_ikConstraints.setSize(ik->_size, 0);
|
||||||
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;
|
||||||
|
|
||||||
@ -272,7 +271,7 @@ namespace Spine {
|
|||||||
|
|
||||||
boneMap = Json::getItem(constraintMap, "bones");
|
boneMap = Json::getItem(constraintMap, "bones");
|
||||||
data->_bones.ensureCapacity(boneMap->_size);
|
data->_bones.ensureCapacity(boneMap->_size);
|
||||||
data->_bones.setSize(boneMap->_size);
|
data->_bones.setSize(boneMap->_size, 0);
|
||||||
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);
|
||||||
if (!data->_bones[ii]) {
|
if (!data->_bones[ii]) {
|
||||||
@ -302,7 +301,7 @@ namespace Spine {
|
|||||||
if (transform) {
|
if (transform) {
|
||||||
Json *constraintMap;
|
Json *constraintMap;
|
||||||
skeletonData->_transformConstraints.ensureCapacity(transform->_size);
|
skeletonData->_transformConstraints.ensureCapacity(transform->_size);
|
||||||
skeletonData->_transformConstraints.setSize(transform->_size);
|
skeletonData->_transformConstraints.setSize(transform->_size, 0);
|
||||||
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;
|
||||||
|
|
||||||
@ -312,7 +311,7 @@ namespace Spine {
|
|||||||
|
|
||||||
boneMap = Json::getItem(constraintMap, "bones");
|
boneMap = Json::getItem(constraintMap, "bones");
|
||||||
data->_bones.ensureCapacity(boneMap->_size);
|
data->_bones.ensureCapacity(boneMap->_size);
|
||||||
data->_bones.setSize(boneMap->_size);
|
data->_bones.setSize(boneMap->_size, 0);
|
||||||
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);
|
||||||
if (!data->_bones[ii]) {
|
if (!data->_bones[ii]) {
|
||||||
@ -353,7 +352,7 @@ namespace Spine {
|
|||||||
if (path) {
|
if (path) {
|
||||||
Json *constraintMap;
|
Json *constraintMap;
|
||||||
skeletonData->_pathConstraints.ensureCapacity(path->_size);
|
skeletonData->_pathConstraints.ensureCapacity(path->_size);
|
||||||
skeletonData->_pathConstraints.setSize(path->_size);
|
skeletonData->_pathConstraints.setSize(path->_size, 0);
|
||||||
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;
|
||||||
const char* item;
|
const char* item;
|
||||||
@ -364,7 +363,7 @@ namespace Spine {
|
|||||||
|
|
||||||
boneMap = Json::getItem(constraintMap, "bones");
|
boneMap = Json::getItem(constraintMap, "bones");
|
||||||
data->_bones.ensureCapacity(boneMap->_size);
|
data->_bones.ensureCapacity(boneMap->_size);
|
||||||
data->_bones.setSize(boneMap->_size);
|
data->_bones.setSize(boneMap->_size, 0);
|
||||||
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);
|
||||||
if (!data->_bones[ii]) {
|
if (!data->_bones[ii]) {
|
||||||
@ -433,7 +432,7 @@ namespace Spine {
|
|||||||
if (skins) {
|
if (skins) {
|
||||||
Json *skinMap;
|
Json *skinMap;
|
||||||
skeletonData->_skins.ensureCapacity(skins->_size);
|
skeletonData->_skins.ensureCapacity(skins->_size);
|
||||||
skeletonData->_skins.setSize(skins->_size);
|
skeletonData->_skins.setSize(skins->_size, 0);
|
||||||
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) {
|
||||||
Json *attachmentsMap;
|
Json *attachmentsMap;
|
||||||
@ -539,7 +538,7 @@ namespace Spine {
|
|||||||
int verticesLength;
|
int verticesLength;
|
||||||
entry = Json::getItem(attachmentMap, "triangles");
|
entry = Json::getItem(attachmentMap, "triangles");
|
||||||
mesh->_triangles.ensureCapacity(entry->_size);
|
mesh->_triangles.ensureCapacity(entry->_size);
|
||||||
mesh->_triangles.setSize(entry->_size);
|
mesh->_triangles.setSize(entry->_size, 0);
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -547,7 +546,7 @@ namespace Spine {
|
|||||||
entry = Json::getItem(attachmentMap, "uvs");
|
entry = Json::getItem(attachmentMap, "uvs");
|
||||||
verticesLength = entry->_size;
|
verticesLength = entry->_size;
|
||||||
mesh->_regionUVs.ensureCapacity(verticesLength);
|
mesh->_regionUVs.ensureCapacity(verticesLength);
|
||||||
mesh->_regionUVs.setSize(verticesLength);
|
mesh->_regionUVs.setSize(verticesLength, 0);
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -561,7 +560,7 @@ namespace Spine {
|
|||||||
entry = Json::getItem(attachmentMap, "edges");
|
entry = Json::getItem(attachmentMap, "edges");
|
||||||
if (entry) {
|
if (entry) {
|
||||||
mesh->_edges.ensureCapacity(entry->_size);
|
mesh->_edges.ensureCapacity(entry->_size);
|
||||||
mesh->_edges.setSize(entry->_size);
|
mesh->_edges.setSize(entry->_size, 0);
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -595,7 +594,7 @@ namespace Spine {
|
|||||||
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
|
readVertices(attachmentMap, pathAttatchment, vertexCount << 1);
|
||||||
|
|
||||||
pathAttatchment->_lengths.ensureCapacity(vertexCount / 3);
|
pathAttatchment->_lengths.ensureCapacity(vertexCount / 3);
|
||||||
pathAttatchment->_lengths.setSize(vertexCount / 3);
|
pathAttatchment->_lengths.setSize(vertexCount / 3, 0);
|
||||||
|
|
||||||
curves = Json::getItem(attachmentMap, "lengths");
|
curves = Json::getItem(attachmentMap, "lengths");
|
||||||
for (curves = curves->_child, ii = 0; curves; curves = curves->_next, ++ii) {
|
for (curves = curves->_child, ii = 0; curves; curves = curves->_next, ++ii) {
|
||||||
@ -662,7 +661,7 @@ namespace Spine {
|
|||||||
if (events) {
|
if (events) {
|
||||||
Json *eventMap;
|
Json *eventMap;
|
||||||
skeletonData->_events.ensureCapacity(events->_size);
|
skeletonData->_events.ensureCapacity(events->_size);
|
||||||
skeletonData->_events.setSize(events->_size);
|
skeletonData->_events.setSize(events->_size, 0);
|
||||||
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));
|
||||||
|
|
||||||
@ -679,7 +678,7 @@ namespace Spine {
|
|||||||
if (animations) {
|
if (animations) {
|
||||||
Json *animationMap;
|
Json *animationMap;
|
||||||
skeletonData->_animations.ensureCapacity(animations->_size);
|
skeletonData->_animations.ensureCapacity(animations->_size);
|
||||||
skeletonData->_animations.setSize(animations->_size);
|
skeletonData->_animations.setSize(animations->_size, 0);
|
||||||
int animationsIndex = 0;
|
int animationsIndex = 0;
|
||||||
for (animationMap = animations->_child; animationMap; animationMap = animationMap->_next) {
|
for (animationMap = animations->_child; animationMap; animationMap = animationMap->_next) {
|
||||||
Animation* animation = readAnimation(animationMap, skeletonData);
|
Animation* animation = readAnimation(animationMap, skeletonData);
|
||||||
@ -1049,19 +1048,16 @@ namespace Spine {
|
|||||||
Vector<float> deform;
|
Vector<float> deform;
|
||||||
if (!vertices) {
|
if (!vertices) {
|
||||||
if (weighted) {
|
if (weighted) {
|
||||||
deform.setSize(deformLength);
|
deform.setSize(deformLength, 0);
|
||||||
for (int i = 0; i < deformLength; ++i) {
|
|
||||||
deform[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deform = attachment->_vertices;
|
deform.clearAndAddAll(attachment->_vertices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int v, start = Json::getInt(valueMap, "offset", 0);
|
int v, start = Json::getInt(valueMap, "offset", 0);
|
||||||
Json* vertex;
|
Json* vertex;
|
||||||
deform.setSize(deformLength);
|
deform.setSize(deformLength, 0);
|
||||||
if (_scale == 1) {
|
if (_scale == 1) {
|
||||||
for (vertex = vertices->_child, v = start; vertex; vertex = vertex->_next, ++v) {
|
for (vertex = vertices->_child, v = start; vertex; vertex = vertex->_next, ++v) {
|
||||||
deform[v] = vertex->_valueFloat;
|
deform[v] = vertex->_valueFloat;
|
||||||
@ -1102,11 +1098,11 @@ namespace Spine {
|
|||||||
Json* offsetMap;
|
Json* offsetMap;
|
||||||
Vector<int> unchanged;
|
Vector<int> unchanged;
|
||||||
unchanged.ensureCapacity(skeletonData->_slots.size() - offsets->_size);
|
unchanged.ensureCapacity(skeletonData->_slots.size() - offsets->_size);
|
||||||
unchanged.setSize(skeletonData->_slots.size() - offsets->_size);
|
unchanged.setSize(skeletonData->_slots.size() - offsets->_size, 0);
|
||||||
int originalIndex = 0, unchangedIndex = 0;
|
int originalIndex = 0, unchangedIndex = 0;
|
||||||
|
|
||||||
drawOrder2.ensureCapacity(skeletonData->_slots.size());
|
drawOrder2.ensureCapacity(skeletonData->_slots.size());
|
||||||
drawOrder2.setSize(skeletonData->_slots.size());
|
drawOrder2.setSize(skeletonData->_slots.size(), 0);
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -1181,7 +1177,7 @@ namespace Spine {
|
|||||||
entry = Json::getItem(attachmentMap, "vertices");
|
entry = Json::getItem(attachmentMap, "vertices");
|
||||||
entrySize = entry->_size;
|
entrySize = entry->_size;
|
||||||
vertices.ensureCapacity(entrySize);
|
vertices.ensureCapacity(entrySize);
|
||||||
vertices.setSize(entrySize);
|
vertices.setSize(entrySize, 0);
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,8 +115,8 @@ namespace Spine {
|
|||||||
return _attachmentVertices;
|
return _attachmentVertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slot::setAttachmentVertices(Vector<float> inValue) {
|
void Slot::setAttachmentVertices(Vector<float>& inValue) {
|
||||||
_attachmentVertices = inValue;
|
_attachmentVertices.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Slot::toString() const {
|
String Slot::toString() const {
|
||||||
|
|||||||
@ -55,8 +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.ensureCapacity(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraintTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void TransformConstraintTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
|
|||||||
@ -52,7 +52,7 @@ namespace Spine {
|
|||||||
|
|
||||||
TranslateTimeline::TranslateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
TranslateTimeline::TranslateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
||||||
_frames.ensureCapacity(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslateTimeline::~TranslateTimeline() {
|
TranslateTimeline::~TranslateTimeline() {
|
||||||
|
|||||||
@ -39,14 +39,14 @@ namespace Spine {
|
|||||||
Vector<int>& indices = _indices;
|
Vector<int>& indices = _indices;
|
||||||
indices.clear();
|
indices.clear();
|
||||||
indices.ensureCapacity(vertexCount);
|
indices.ensureCapacity(vertexCount);
|
||||||
indices.setSize(vertexCount);
|
indices.setSize(vertexCount, 0);
|
||||||
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.ensureCapacity(vertexCount);
|
isConcaveArray.ensureCapacity(vertexCount);
|
||||||
isConcaveArray.setSize(vertexCount);
|
isConcaveArray.setSize(vertexCount, 0);
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -136,13 +136,11 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
convexPolygonsIndices.clear();
|
convexPolygonsIndices.clear();
|
||||||
|
|
||||||
Vector<int>* polygonIndicesP = _polygonIndicesPool.obtain();
|
Vector<int>* polygonIndices = _polygonIndicesPool.obtain();
|
||||||
Vector<int>& polygonIndices = *polygonIndicesP;
|
polygonIndices->clear();
|
||||||
polygonIndices.clear();
|
|
||||||
|
|
||||||
Vector<float>* polygonP = _polygonPool.obtain();
|
Vector<float>* polygon = _polygonPool.obtain();
|
||||||
Vector<float>& polygon = *polygonP;
|
polygon->clear();
|
||||||
polygon.clear();
|
|
||||||
|
|
||||||
// Merge subsequent triangles if they form a triangle fan.
|
// Merge subsequent triangles if they form a triangle fan.
|
||||||
int fanBaseIndex = -1, lastwinding = 0;
|
int fanBaseIndex = -1, lastwinding = 0;
|
||||||
@ -155,64 +153,63 @@ namespace Spine {
|
|||||||
// If the base of the last triangle is the same as this triangle, check if they form a convex polygon (triangle fan).
|
// If the base of the last triangle is the same as this triangle, check if they form a convex polygon (triangle fan).
|
||||||
bool merged = false;
|
bool merged = false;
|
||||||
if (fanBaseIndex == t1) {
|
if (fanBaseIndex == t1) {
|
||||||
size_t o = polygon.size() - 4;
|
size_t o = polygon->size() - 4;
|
||||||
Vector<float>& p = polygon;
|
Vector<float>& p = *polygon;
|
||||||
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.add(x3);
|
polygon->add(x3);
|
||||||
polygon.add(y3);
|
polygon->add(y3);
|
||||||
polygonIndices.add(t3);
|
polygonIndices->add(t3);
|
||||||
merged = true;
|
merged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.add(&polygon);
|
convexPolygons.add(polygon);
|
||||||
convexPolygonsIndices.add(&polygonIndices);
|
convexPolygonsIndices.add(polygonIndices);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_polygonPool.free(&polygon);
|
_polygonPool.free(polygon);
|
||||||
_polygonIndicesPool.free(&polygonIndices);
|
_polygonIndicesPool.free(polygonIndices);
|
||||||
}
|
}
|
||||||
|
|
||||||
polygon = *_polygonPool.obtain();
|
polygon = _polygonPool.obtain();
|
||||||
polygon.clear();
|
polygon->clear();
|
||||||
polygon.add(x1);
|
polygon->add(x1);
|
||||||
polygon.add(y1);
|
polygon->add(y1);
|
||||||
polygon.add(x2);
|
polygon->add(x2);
|
||||||
polygon.add(y2);
|
polygon->add(y2);
|
||||||
polygon.add(x3);
|
polygon->add(x3);
|
||||||
polygon.add(y3);
|
polygon->add(y3);
|
||||||
polygonIndices = *_polygonIndicesPool.obtain();
|
polygonIndices = _polygonIndicesPool.obtain();
|
||||||
polygonIndices.clear();
|
polygonIndices->clear();
|
||||||
polygonIndices.add(t1);
|
polygonIndices->add(t1);
|
||||||
polygonIndices.add(t2);
|
polygonIndices->add(t2);
|
||||||
polygonIndices.add(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.add(&polygon);
|
convexPolygons.add(polygon);
|
||||||
convexPolygonsIndices.add(&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.
|
||||||
for (size_t i = 0, n = convexPolygons.size(); i < n; ++i) {
|
for (size_t i = 0, n = convexPolygons.size(); i < n; ++i) {
|
||||||
polygonIndicesP = convexPolygonsIndices[i];
|
polygonIndices = convexPolygonsIndices[i];
|
||||||
polygonIndices = *polygonIndicesP;
|
|
||||||
|
|
||||||
if (polygonIndices.size() == 0) continue;
|
if (polygonIndices->size() == 0) continue;
|
||||||
int firstIndex = polygonIndices[0];
|
int firstIndex = (*polygonIndices)[0];
|
||||||
int lastIndex = polygonIndices[polygonIndices.size() - 1];
|
int lastIndex = (*polygonIndices)[polygonIndices->size() - 1];
|
||||||
|
|
||||||
polygon = *convexPolygons[i];
|
polygon = convexPolygons[i];
|
||||||
size_t o = polygon.size() - 4;
|
size_t o = polygon->size() - 4;
|
||||||
Vector<float>& p = polygon;
|
Vector<float>& p = *polygon;
|
||||||
float prevPrevX = p[o], prevPrevY = p[o + 1];
|
float prevPrevX = p[o], prevPrevY = p[o + 1];
|
||||||
float prevX = p[o + 2], prevY = p[o + 3];
|
float prevX = p[o + 2], prevY = p[o + 3];
|
||||||
float firstX = p[0], firstY = p[1];
|
float firstX = p[0], firstY = p[1];
|
||||||
@ -249,9 +246,9 @@ namespace Spine {
|
|||||||
if (winding1 == winding0 && winding2 == winding0) {
|
if (winding1 == winding0 && winding2 == winding0) {
|
||||||
otherPoly.clear();
|
otherPoly.clear();
|
||||||
otherIndices.clear();
|
otherIndices.clear();
|
||||||
polygon.add(x3);
|
polygon->add(x3);
|
||||||
polygon.add(y3);
|
polygon->add(y3);
|
||||||
polygonIndices.add(otherLastIndex);
|
polygonIndices->add(otherLastIndex);
|
||||||
prevPrevX = prevX;
|
prevPrevX = prevX;
|
||||||
prevPrevY = prevY;
|
prevPrevY = prevY;
|
||||||
prevX = x3;
|
prevX = x3;
|
||||||
@ -263,13 +260,13 @@ namespace Spine {
|
|||||||
|
|
||||||
// Remove empty polygons that resulted from the merge step above.
|
// Remove empty polygons that resulted from the merge step above.
|
||||||
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.removeAt(i);
|
convexPolygons.removeAt(i);
|
||||||
_polygonPool.free(&polygon);
|
_polygonPool.free(polygon);
|
||||||
polygonIndices = *convexPolygonsIndices[i];
|
polygonIndices = convexPolygonsIndices[i];
|
||||||
convexPolygonsIndices.removeAt(i);
|
convexPolygonsIndices.removeAt(i);
|
||||||
_polygonIndicesPool.free(&polygonIndices);
|
_polygonIndicesPool.free(polygonIndices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ namespace Spine {
|
|||||||
|
|
||||||
TwoColorTimeline::TwoColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) {
|
TwoColorTimeline::TwoColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0) {
|
||||||
_frames.ensureCapacity(frameCount * ENTRIES);
|
_frames.ensureCapacity(frameCount * ENTRIES);
|
||||||
_frames.setSize(frameCount * ENTRIES);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwoColorTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
void TwoColorTimeline::apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixPose pose, MixDirection direction) {
|
||||||
|
|||||||
@ -51,11 +51,11 @@ namespace Spine {
|
|||||||
void VertexAttachment::computeWorldVertices(Slot& slot, int start, int count, Vector<float>& worldVertices, int offset, int stride) {
|
void VertexAttachment::computeWorldVertices(Slot& slot, int start, int count, Vector<float>& worldVertices, int offset, int stride) {
|
||||||
count = offset + (count >> 1) * stride;
|
count = offset + (count >> 1) * stride;
|
||||||
Skeleton& skeleton = slot._bone._skeleton;
|
Skeleton& skeleton = slot._bone._skeleton;
|
||||||
Vector<float>& deformArray = slot.getAttachmentVertices();
|
Vector<float>* deformArray = &slot.getAttachmentVertices();
|
||||||
Vector<float>& vertices = _vertices;
|
Vector<float>* vertices = &_vertices;
|
||||||
Vector<int>& bones = _bones;
|
Vector<int>& bones = _bones;
|
||||||
if (bones.size() == 0) {
|
if (bones.size() == 0) {
|
||||||
if (deformArray.size() > 0) {
|
if (deformArray->size() > 0) {
|
||||||
vertices = deformArray;
|
vertices = deformArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,8 +64,8 @@ namespace Spine {
|
|||||||
float y = bone._worldY;
|
float y = bone._worldY;
|
||||||
float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
|
float a = bone._a, b = bone._b, c = bone._c, d = bone._d;
|
||||||
for (int vv = start, w = offset; w < count; vv += 2, w += stride) {
|
for (int vv = start, w = offset; w < count; vv += 2, w += stride) {
|
||||||
float vx = vertices[vv];
|
float vx = (*vertices)[vv];
|
||||||
float vy = vertices[vv + 1];
|
float vy = (*vertices)[vv + 1];
|
||||||
worldVertices[w] = vx * a + vy * b + x;
|
worldVertices[w] = vx * a + vy * b + x;
|
||||||
worldVertices[w + 1] = vx * c + vy * d + y;
|
worldVertices[w + 1] = vx * c + vy * d + y;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<Bone*>& skeletonBones = skeleton.getBones();
|
Vector<Bone*>& skeletonBones = skeleton.getBones();
|
||||||
if (deformArray.size() == 0) {
|
if (deformArray->size() == 0) {
|
||||||
for (int w = offset, b = skip * 3; w < count; w += stride) {
|
for (int w = offset, b = skip * 3; w < count; w += stride) {
|
||||||
float wx = 0, wy = 0;
|
float wx = 0, wy = 0;
|
||||||
int n = bones[v++];
|
int n = bones[v++];
|
||||||
@ -88,9 +88,9 @@ namespace Spine {
|
|||||||
for (; v < n; v++, b += 3) {
|
for (; v < n; v++, b += 3) {
|
||||||
Bone* boneP = skeletonBones[bones[v]];
|
Bone* boneP = skeletonBones[bones[v]];
|
||||||
Bone& bone = *boneP;
|
Bone& bone = *boneP;
|
||||||
float vx = vertices[b];
|
float vx = (*vertices)[b];
|
||||||
float vy = vertices[b + 1];
|
float vy = (*vertices)[b + 1];
|
||||||
float weight = vertices[b + 2];
|
float weight = (*vertices)[b + 2];
|
||||||
wx += (vx * bone._a + vy * bone._b + bone._worldX) * weight;
|
wx += (vx * bone._a + vy * bone._b + bone._worldX) * weight;
|
||||||
wy += (vx * bone._c + vy * bone._d + bone._worldY) * weight;
|
wy += (vx * bone._c + vy * bone._d + bone._worldY) * weight;
|
||||||
}
|
}
|
||||||
@ -106,9 +106,9 @@ namespace Spine {
|
|||||||
for (; v < n; v++, b += 3, f += 2) {
|
for (; v < n; v++, b += 3, f += 2) {
|
||||||
Bone* boneP = skeletonBones[bones[v]];
|
Bone* boneP = skeletonBones[bones[v]];
|
||||||
Bone& bone = *boneP;
|
Bone& bone = *boneP;
|
||||||
float vx = vertices[b] + deformArray[f];
|
float vx = (*vertices)[b] + (*deformArray)[f];
|
||||||
float vy = vertices[b + 1] + deformArray[f + 1];
|
float vy = (*vertices)[b + 1] + (*deformArray)[f + 1];
|
||||||
float weight = vertices[b + 2];
|
float weight = (*vertices)[b + 2];
|
||||||
wx += (vx * bone._a + vy * bone._b + bone._worldX) * weight;
|
wx += (vx * bone._a + vy * bone._b + bone._worldX) * weight;
|
||||||
wy += (vx * bone._c + vy * bone._d + bone._worldY) * weight;
|
wy += (vx * bone._c + vy * bone._d + bone._worldY) * weight;
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VertexAttachment::setBones(Vector<int> inValue) {
|
void VertexAttachment::setBones(Vector<int> inValue) {
|
||||||
_bones = inValue;
|
_bones.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>& VertexAttachment::getVertices() {
|
Vector<float>& VertexAttachment::getVertices() {
|
||||||
@ -139,7 +139,7 @@ namespace Spine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VertexAttachment::setVertices(Vector<float> inValue) {
|
void VertexAttachment::setVertices(Vector<float> inValue) {
|
||||||
_vertices = inValue;
|
_vertices.clearAndAddAll(inValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
int VertexAttachment::getWorldVerticesLength() {
|
int VertexAttachment::getWorldVerticesLength() {
|
||||||
|
|||||||
@ -205,7 +205,8 @@ public class SkeletonRenderer {
|
|||||||
FloatArray clippedVertices = clipper.getClippedVertices();
|
FloatArray clippedVertices = clipper.getClippedVertices();
|
||||||
ShortArray clippedTriangles = clipper.getClippedTriangles();
|
ShortArray clippedTriangles = clipper.getClippedTriangles();
|
||||||
if (vertexEffect != null) applyVertexEffect(clippedVertices.items, clippedVertices.size, 5, c, 0);
|
if (vertexEffect != null) applyVertexEffect(clippedVertices.items, clippedVertices.size, 5, c, 0);
|
||||||
batch.draw(texture, clippedVertices.items, 0, clippedVertices.size, clippedTriangles.items, 0,
|
printAttachmentVertices(attachment.getName() + " (clipped)", clippedVertices.items, clippedVertices.size, clippedTriangles.items, clippedTriangles.size);
|
||||||
|
batch.draw(texture, clippedVertices.items, 0, clippedVertices.size / 5, clippedTriangles.items, 0,
|
||||||
clippedTriangles.size);
|
clippedTriangles.size);
|
||||||
} else {
|
} else {
|
||||||
if (vertexEffect != null) {
|
if (vertexEffect != null) {
|
||||||
@ -232,6 +233,7 @@ public class SkeletonRenderer {
|
|||||||
vertices[v + 2] = uvs[u + 1];
|
vertices[v + 2] = uvs[u + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printAttachmentVertices(attachment.getName(), vertices, verticesLength / 5, triangles, triangles.length);
|
||||||
batch.draw(texture, vertices, 0, verticesLength, triangles, 0, triangles.length);
|
batch.draw(texture, vertices, 0, verticesLength, triangles, 0, triangles.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,6 +242,22 @@ public class SkeletonRenderer {
|
|||||||
}
|
}
|
||||||
clipper.clipEnd();
|
clipper.clipEnd();
|
||||||
if (vertexEffect != null) vertexEffect.end();
|
if (vertexEffect != null) vertexEffect.end();
|
||||||
|
System.out.println("=====================\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void printAttachmentVertices(String name, float[] vertices, int vertexCount, short[] triangles, int triangleCount) {
|
||||||
|
System.out.println("attachment: " + name);
|
||||||
|
System.out.print("indices (" + triangleCount + "): ");
|
||||||
|
for(int i = 0; i < triangleCount; i++) {
|
||||||
|
System.out.print(triangles[i] + " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print("\nvertices (" + vertexCount + "): ");
|
||||||
|
for(int i = 0; i < triangleCount; i++) {
|
||||||
|
int index = triangles[i] * 5;
|
||||||
|
System.out.print((int)vertices[index] + " " + ((int)vertices[index + 1] + " "));
|
||||||
|
}
|
||||||
|
System.out.println("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("null")
|
@SuppressWarnings("null")
|
||||||
|
|||||||
@ -354,7 +354,7 @@ void coin (SkeletonData* skeletonData, Atlas* atlas) {
|
|||||||
float delta = deltaClock.getElapsedTime().asSeconds();
|
float delta = deltaClock.getElapsedTime().asSeconds();
|
||||||
deltaClock.restart();
|
deltaClock.restart();
|
||||||
|
|
||||||
// drawable->update(delta);
|
drawable->update(delta);
|
||||||
|
|
||||||
window.clear();
|
window.clear();
|
||||||
window.draw(*drawable);
|
window.draw(*drawable);
|
||||||
|
|||||||
@ -78,7 +78,7 @@ SkeletonDrawable::SkeletonDrawable (SkeletonData* skeletonData, AnimationStateDa
|
|||||||
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
|
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
|
||||||
worldVertices(), clipper() {
|
worldVertices(), clipper() {
|
||||||
Bone::setYDown(true);
|
Bone::setYDown(true);
|
||||||
worldVertices.setSize(SPINE_MESH_VERTEX_COUNT_MAX);
|
worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX);
|
||||||
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
|
skeleton = new (__FILE__, __LINE__) Skeleton(skeletonData);
|
||||||
tempUvs.ensureCapacity(16);
|
tempUvs.ensureCapacity(16);
|
||||||
tempColors.ensureCapacity(16);
|
tempColors.ensureCapacity(16);
|
||||||
@ -132,6 +132,7 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const {
|
|||||||
|
|
||||||
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
RegionAttachment* regionAttachment = (RegionAttachment*)attachment;
|
RegionAttachment* regionAttachment = (RegionAttachment*)attachment;
|
||||||
|
worldVertices.setSize(8, 0);
|
||||||
regionAttachment->computeWorldVertices(slot.getBone(), worldVertices, 0, 2);
|
regionAttachment->computeWorldVertices(slot.getBone(), worldVertices, 0, 2);
|
||||||
verticesCount = 4;
|
verticesCount = 4;
|
||||||
uvs = ®ionAttachment->getUVs();
|
uvs = ®ionAttachment->getUVs();
|
||||||
@ -142,7 +143,7 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const {
|
|||||||
|
|
||||||
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
} else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||||
MeshAttachment* mesh = (MeshAttachment*)attachment;
|
MeshAttachment* mesh = (MeshAttachment*)attachment;
|
||||||
if (mesh->getWorldVerticesLength() > worldVertices.size()) worldVertices.setSize(mesh->getWorldVerticesLength());
|
worldVertices.setSize(mesh->getWorldVerticesLength(), 0);
|
||||||
texture = (Texture*)((AtlasRegion*)mesh->getRendererObject())->page->rendererObject;
|
texture = (Texture*)((AtlasRegion*)mesh->getRendererObject())->page->rendererObject;
|
||||||
mesh->computeWorldVertices(slot, 0, mesh->getWorldVerticesLength(), worldVertices, 0, 2);
|
mesh->computeWorldVertices(slot, 0, mesh->getWorldVerticesLength(), worldVertices, 0, 2);
|
||||||
verticesCount = mesh->getWorldVerticesLength() >> 1;
|
verticesCount = mesh->getWorldVerticesLength() >> 1;
|
||||||
@ -262,16 +263,14 @@ void SkeletonDrawable::draw (RenderTarget& target, RenderStates states) const {
|
|||||||
vertexArray->append(vertex);
|
vertexArray->append(vertex);
|
||||||
}
|
}
|
||||||
} else {*/
|
} else {*/
|
||||||
for (int i = 0; i < indicesCount; ++i) {
|
for (int ii = 0; ii < indicesCount; ++ii) {
|
||||||
int index = (*indices)[i] << 1;
|
int index = (*indices)[ii] << 1;
|
||||||
vertex.position.x = (*vertices)[index];
|
vertex.position.x = (*vertices)[index];
|
||||||
vertex.position.y = (*vertices)[index + 1];
|
vertex.position.y = (*vertices)[index + 1];
|
||||||
vertex.texCoords.x = (*uvs)[index] * size.x;
|
vertex.texCoords.x = (*uvs)[index] * size.x;
|
||||||
vertex.texCoords.y = (*uvs)[index + 1] * size.y;
|
vertex.texCoords.y = (*uvs)[index + 1] * size.y;
|
||||||
vertexArray->append(vertex);
|
vertexArray->append(vertex);
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
clipper.clipEnd(slot);
|
clipper.clipEnd(slot);
|
||||||
}
|
}
|
||||||
target.draw(*vertexArray, states);
|
target.draw(*vertexArray, states);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user