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