[cpp] Ported all skin API changes, see #841.

This commit is contained in:
badlogic 2019-06-04 10:30:02 +02:00
parent 2eca53763f
commit 64852ddc96
24 changed files with 231 additions and 47 deletions

View File

@ -45,8 +45,15 @@ public:
const String &getName() const; const String &getName() const;
virtual Attachment* copy() = 0;
int getRefCount();
void reference();
void dereference();
private: private:
const String _name; const String _name;
int _refCount;
}; };
} }

View File

@ -39,6 +39,8 @@ namespace spine {
RTTI_DECL RTTI_DECL
explicit BoundingBoxAttachment(const String& name); explicit BoundingBoxAttachment(const String& name);
virtual Attachment* copy();
}; };
} }

View File

@ -48,6 +48,8 @@ namespace spine {
SlotData* getEndSlot(); SlotData* getEndSlot();
void setEndSlot(SlotData* inValue); void setEndSlot(SlotData* inValue);
virtual Attachment* copy();
private: private:
SlotData* _endSlot; SlotData* _endSlot;

View File

@ -42,13 +42,14 @@ class SP_API LinkedMesh : public SpineObject {
friend class SkeletonJson; friend class SkeletonJson;
public: public:
LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent); LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent, bool inheritDeform);
private: private:
MeshAttachment *_mesh; MeshAttachment *_mesh;
String _skin; String _skin;
size_t _slotIndex; size_t _slotIndex;
String _parent; String _parent;
bool _inheritDeform;
}; };
} }

View File

@ -50,8 +50,6 @@ namespace spine {
virtual ~MeshAttachment(); virtual ~MeshAttachment();
void updateUVs(); void updateUVs();
virtual bool applyDeform(VertexAttachment* sourceAttachment);
int getHullLength(); int getHullLength();
void setHullLength(int inValue); void setHullLength(int inValue);
@ -104,9 +102,6 @@ namespace spine {
float getRegionOriginalHeight(); float getRegionOriginalHeight();
void setRegionOriginalHeight(float inValue); void setRegionOriginalHeight(float inValue);
bool getInheritDeform();
void setInheritDeform(bool inValue);
MeshAttachment* getParentMesh(); MeshAttachment* getParentMesh();
void setParentMesh(MeshAttachment* inValue); void setParentMesh(MeshAttachment* inValue);
@ -117,6 +112,10 @@ namespace spine {
float getHeight(); float getHeight();
void setHeight(float inValue); void setHeight(float inValue);
virtual Attachment* copy();
MeshAttachment* newLinkedMesh();
private: private:
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight; float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
MeshAttachment* _parentMesh; MeshAttachment* _parentMesh;
@ -133,7 +132,6 @@ namespace spine {
float _height; float _height;
Color _color; Color _color;
int _hullLength; int _hullLength;
bool _inheritDeform;
bool _regionRotate; bool _regionRotate;
int _regionDegrees; int _regionDegrees;
}; };

View File

@ -48,7 +48,8 @@ namespace spine {
void setClosed(bool inValue); void setClosed(bool inValue);
bool isConstantSpeed(); bool isConstantSpeed();
void setConstantSpeed(bool inValue); void setConstantSpeed(bool inValue);
virtual Attachment* copy();
private: private:
Vector<float> _lengths; Vector<float> _lengths;
bool _closed; bool _closed;

View File

@ -63,6 +63,8 @@ namespace spine {
float getRotation(); float getRotation();
void setRotation(float inValue); void setRotation(float inValue);
virtual Attachment* copy();
private: private:
float _x, _y, _rotation; float _x, _y, _rotation;

View File

@ -105,6 +105,8 @@ namespace spine {
Vector<float>& getOffset(); Vector<float>& getOffset();
Vector<float>& getUVs(); Vector<float>& getUVs();
virtual Attachment* copy();
private: private:
static const int BLX; static const int BLX;

View File

@ -117,7 +117,7 @@ public:
/// Adds an attachment to the skin for the specified slot index and name. /// Adds an attachment to the skin for the specified slot index and name.
/// If the name already exists for the slot, the previous value is replaced. /// If the name already exists for the slot, the previous value is replaced.
void addAttachment(size_t slotIndex, const String &name, Attachment *attachment); void setAttachment(size_t slotIndex, const String &name, Attachment *attachment);
/// Returns the attachment for the specified slot index and name, or NULL. /// Returns the attachment for the specified slot index and name, or NULL.
Attachment *getAttachment(size_t slotIndex, const String &name); Attachment *getAttachment(size_t slotIndex, const String &name);
@ -134,6 +134,12 @@ public:
const String &getName(); const String &getName();
/// Adds all attachments, bones, and constraints from the specified skin to this skin.
void addSkin(Skin* other);
/// Adds all attachments, bones, and constraints from the specified skin to this skin. Attachments are deep copied.
void copySkin(Skin* other);
AttachmentMap::Entries getAttachments(); AttachmentMap::Entries getAttachments();
private: private:

View File

@ -62,9 +62,6 @@ namespace spine {
void computeWorldVertices(Slot& slot, size_t start, size_t count, float* worldVertices, size_t offset, size_t stride = 2); void computeWorldVertices(Slot& slot, size_t start, size_t count, float* worldVertices, size_t offset, size_t stride = 2);
void computeWorldVertices(Slot& slot, size_t start, size_t count, Vector<float>& worldVertices, size_t offset, size_t stride = 2); void computeWorldVertices(Slot& slot, size_t start, size_t count, Vector<float>& worldVertices, size_t offset, size_t stride = 2);
/// @return true if a deform originally applied to the specified attachment should be applied to this attachment.
virtual bool applyDeform(VertexAttachment* sourceAttachment);
/// Gets a unique ID for this attachment. /// Gets a unique ID for this attachment.
int getId(); int getId();
@ -74,11 +71,17 @@ namespace spine {
size_t getWorldVerticesLength(); size_t getWorldVerticesLength();
void setWorldVerticesLength(size_t inValue); void setWorldVerticesLength(size_t inValue);
VertexAttachment* getDeformAttachment();
void setDeformAttachment(VertexAttachment* attachment);
void copyTo(VertexAttachment* other);
protected: protected:
Vector<size_t> _bones; Vector<size_t> _bones;
Vector<float> _vertices; Vector<float> _vertices;
size_t _worldVerticesLength; size_t _worldVerticesLength;
VertexAttachment* _deformAttachment;
private: private:
const int _id; const int _id;

View File

@ -39,7 +39,7 @@ using namespace spine;
RTTI_IMPL_NOPARENT(Attachment) RTTI_IMPL_NOPARENT(Attachment)
Attachment::Attachment(const String &name) : _name(name) { Attachment::Attachment(const String &name) : _name(name), _refCount(0) {
assert(_name.length() > 0); assert(_name.length() > 0);
} }
@ -49,3 +49,15 @@ Attachment::~Attachment() {
const String &Attachment::getName() const { const String &Attachment::getName() const {
return _name; return _name;
} }
int Attachment::getRefCount() {
return _refCount;
}
void Attachment::reference() {
_refCount++;
}
void Attachment::dereference() {
_refCount--;
}

View File

@ -39,3 +39,9 @@ RTTI_IMPL(BoundingBoxAttachment, VertexAttachment)
BoundingBoxAttachment::BoundingBoxAttachment(const String &name) : VertexAttachment(name) { BoundingBoxAttachment::BoundingBoxAttachment(const String &name) : VertexAttachment(name) {
} }
Attachment* BoundingBoxAttachment::copy() {
BoundingBoxAttachment* copy = new (__FILE__, __LINE__) BoundingBoxAttachment(getName());
copyTo(copy);
return copy;
}

View File

@ -49,3 +49,10 @@ SlotData *ClippingAttachment::getEndSlot() {
void ClippingAttachment::setEndSlot(SlotData *inValue) { void ClippingAttachment::setEndSlot(SlotData *inValue) {
_endSlot = inValue; _endSlot = inValue;
} }
Attachment* ClippingAttachment::copy() {
ClippingAttachment* copy = new (__FILE__, __LINE__) ClippingAttachment(getName());
copyTo(copy);
copy->_endSlot = _endSlot;
return copy;
}

View File

@ -74,7 +74,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
} }
VertexAttachment *attachment = static_cast<VertexAttachment *>(slotAttachment); VertexAttachment *attachment = static_cast<VertexAttachment *>(slotAttachment);
if (!attachment->applyDeform(_attachment)) { if (attachment->_deformAttachment != _attachment) {
return; return;
} }

View File

@ -37,9 +37,10 @@
using namespace spine; using namespace spine;
LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent) : LinkedMesh::LinkedMesh(MeshAttachment *mesh, const String &skin, size_t slotIndex, const String &parent, bool inheritDeform) :
_mesh(mesh), _mesh(mesh),
_skin(skin), _skin(skin),
_slotIndex(slotIndex), _slotIndex(slotIndex),
_parent(parent) { _parent(parent),
_inheritDeform(inheritDeform) {
} }

View File

@ -55,7 +55,6 @@ MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), Has
_height(0), _height(0),
_color(1, 1, 1, 1), _color(1, 1, 1, 1),
_hullLength(0), _hullLength(0),
_inheritDeform(false),
_regionRotate(false), _regionRotate(false),
_regionDegrees(0) { _regionDegrees(0) {
} }
@ -126,10 +125,6 @@ void MeshAttachment::updateUVs() {
} }
} }
bool MeshAttachment::applyDeform(VertexAttachment *sourceAttachment) {
return this == sourceAttachment || (_inheritDeform && _parentMesh == sourceAttachment);
}
int MeshAttachment::getHullLength() { int MeshAttachment::getHullLength() {
return _hullLength; return _hullLength;
} }
@ -246,14 +241,6 @@ void MeshAttachment::setRegionOriginalHeight(float inValue) {
_regionOriginalHeight = inValue; _regionOriginalHeight = inValue;
} }
bool MeshAttachment::getInheritDeform() {
return _inheritDeform;
}
void MeshAttachment::setInheritDeform(bool inValue) {
_inheritDeform = inValue;
}
MeshAttachment *MeshAttachment::getParentMesh() { MeshAttachment *MeshAttachment::getParentMesh() {
return _parentMesh; return _parentMesh;
} }
@ -296,3 +283,59 @@ void MeshAttachment::setHeight(float inValue) {
spine::Color &MeshAttachment::getColor() { spine::Color &MeshAttachment::getColor() {
return _color; return _color;
} }
Attachment* MeshAttachment::copy() {
if (_parentMesh) return newLinkedMesh();
MeshAttachment* copy = new (__FILE__, __LINE__) MeshAttachment(getName());
copy->setRendererObject(getRendererObject());
copy->_regionU = _regionU;
copy->_regionV = _regionV;
copy->_regionU2 = _regionU2;
copy->_regionV2 = _regionV2;
copy->_regionRotate = _regionRotate;
copy->_regionDegrees = _regionDegrees;
copy->_regionOffsetX = _regionOffsetX;
copy->_regionOffsetY = _regionOffsetY;
copy->_regionWidth = _regionWidth;
copy->_regionHeight = _regionHeight;
copy->_regionOriginalWidth = _regionOriginalWidth;
copy->_regionOriginalHeight = _regionOriginalHeight;
copy->_path = _path;
copy->_color.set(_color);
copyTo(copy);
copy->_regionUVs.clearAndAddAll(_regionUVs);
copy->_uvs.clearAndAddAll(_uvs);
copy->_triangles.clearAndAddAll(_triangles);
copy->_hullLength = _hullLength;
// Nonessential.
copy->_edges.clearAndAddAll(copy->_edges);
copy->_width = _width;
copy->_height = _height;
return copy;
}
MeshAttachment* MeshAttachment::newLinkedMesh() {
MeshAttachment* copy = new (__FILE__, __LINE__) MeshAttachment(getName());
copy->setRendererObject(getRendererObject());
copy->_regionU = _regionU;
copy->_regionV = _regionV;
copy->_regionU2 = _regionU2;
copy->_regionV2 = _regionV2;
copy->_regionRotate = _regionRotate;
copy->_regionDegrees = _regionDegrees;
copy->_regionOffsetX = _regionOffsetX;
copy->_regionOffsetY = _regionOffsetY;
copy->_regionWidth = _regionWidth;
copy->_regionHeight = _regionHeight;
copy->_regionOriginalWidth = _regionOriginalWidth;
copy->_regionOriginalHeight = _regionOriginalHeight;
copy->_path = _path;
copy->_color.set(_color);
copy->_deformAttachment = this->_deformAttachment;
copy->setParentMesh(_parentMesh ? _parentMesh : this);
copy->updateUVs();
return copy;
}

View File

@ -58,3 +58,12 @@ bool PathAttachment::isConstantSpeed() {
void PathAttachment::setConstantSpeed(bool inValue) { void PathAttachment::setConstantSpeed(bool inValue) {
_constantSpeed = inValue; _constantSpeed = inValue;
} }
Attachment* PathAttachment::copy() {
PathAttachment* copy = new (__FILE__, __LINE__) PathAttachment(getName());
copyTo(copy);
copy->_lengths.clearAndAddAll(_lengths);
copy->_closed = _closed;
copy->_constantSpeed = _constantSpeed;
return copy;
}

View File

@ -80,3 +80,11 @@ float PointAttachment::getRotation() {
void PointAttachment::setRotation(float inValue) { void PointAttachment::setRotation(float inValue) {
_rotation = inValue; _rotation = inValue;
} }
Attachment* PointAttachment::copy() {
PointAttachment* copy = new(__FILE__, __LINE__) PointAttachment(getName());
copy->_x = _x;
copy->_y = _y;
copy->_rotation = _rotation;
return copy;
}

View File

@ -281,3 +281,26 @@ Vector<float> &RegionAttachment::getUVs() {
spine::Color &RegionAttachment::getColor() { spine::Color &RegionAttachment::getColor() {
return _color; return _color;
} }
Attachment* RegionAttachment::copy() {
RegionAttachment* copy = new (__FILE__, __LINE__) RegionAttachment(getName());
copy->_regionWidth = _regionWidth;
copy->_regionHeight = _regionHeight;
copy->_regionOffsetX = _regionOffsetX;
copy->_regionOffsetY = _regionOffsetY;
copy->_regionOriginalWidth = _regionOriginalWidth;
copy->_regionOriginalHeight = _regionOriginalHeight;
copy->setRendererObject(getRendererObject());
copy->_path = _path;
copy->_x = _x;
copy->_y = _y;
copy->_scaleX = _scaleX;
copy->_scaleY = _scaleY;
copy->_rotation = _rotation;
copy->_width = _width;
copy->_height = _height;
copy->_uvs.clearAndAddAll(_uvs);
copy->_vertexOffset.clearAndAddAll(_vertexOffset);
copy->_color.set(_color);
return copy;
}

View File

@ -300,6 +300,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
setError("Parent mesh not found: ", linkedMesh->_parent.buffer()); setError("Parent mesh not found: ", linkedMesh->_parent.buffer());
return NULL; return NULL;
} }
linkedMesh->_mesh->_deformAttachment = linkedMesh->_inheritDeform ? static_cast<VertexAttachment*>(parent) : linkedMesh->_mesh;
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent)); linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
linkedMesh->_mesh->updateUVs(); linkedMesh->_mesh->updateUVs();
_attachmentLoader->configureAttachment(linkedMesh->_mesh); _attachmentLoader->configureAttachment(linkedMesh->_mesh);
@ -455,7 +456,7 @@ SkeletonBinary::readSkin(DataInput *input, const String &skinName, SkeletonData
for (int ii = 0, nn = readVarint(input, true); ii < nn; ++ii) { for (int ii = 0, nn = readVarint(input, true); ii < nn; ++ii) {
String name(readString(input), true); String name(readString(input), true);
Attachment *attachment = readAttachment(input, skin, slotIndex, name, skeletonData, nonessential); Attachment *attachment = readAttachment(input, skin, slotIndex, name, skeletonData, nonessential);
if (attachment) skin->addAttachment(slotIndex, String(name), attachment); if (attachment) skin->setAttachment(slotIndex, String(name), attachment);
} }
} }
return skin; return skin;
@ -531,14 +532,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
readColor(input, mesh->getColor()); readColor(input, mesh->getColor());
String skinName(readString(input), true); String skinName(readString(input), true);
String parent(readString(input), true); String parent(readString(input), true);
mesh->_inheritDeform = readBoolean(input); bool inheritDeform = readBoolean(input);
if (nonessential) { if (nonessential) {
mesh->_width = readFloat(input) * _scale; mesh->_width = readFloat(input) * _scale;
mesh->_height = readFloat(input) * _scale; mesh->_height = readFloat(input) * _scale;
} }
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh, String(skinName), slotIndex, LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh, String(skinName), slotIndex,
String(parent)); String(parent), inheritDeform);
_linkedMeshes.add(linkedMesh); _linkedMeshes.add(linkedMesh);
return mesh; return mesh;
} }

View File

@ -569,13 +569,13 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
} }
_attachmentLoader->configureAttachment(mesh); _attachmentLoader->configureAttachment(mesh);
} else { } else {
mesh->_inheritDeform = Json::getInt(attachmentMap, "deform", 1) ? true : false; bool inheritDeform = Json::getInt(attachmentMap, "deform", 1) ? true : false;
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh, LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh,
String(Json::getString( String(Json::getString(
attachmentMap, attachmentMap,
"skin", 0)), "skin", 0)),
slotIndex, slotIndex,
String(entry->_valueString)); String(entry->_valueString), inheritDeform);
_linkedMeshes.add(linkedMesh); _linkedMeshes.add(linkedMesh);
} }
break; break;
@ -640,7 +640,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
} }
} }
skin->addAttachment(slotIndex, skinAttachmentName, attachment); skin->setAttachment(slotIndex, skinAttachmentName, attachment);
} }
} }
} }
@ -663,6 +663,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
setError(root, "Parent mesh not found: ", linkedMesh->_parent.buffer()); setError(root, "Parent mesh not found: ", linkedMesh->_parent.buffer());
return NULL; return NULL;
} }
linkedMesh->_mesh->_deformAttachment = linkedMesh->_inheritDeform ? static_cast<VertexAttachment*>(parent) : linkedMesh->_mesh;
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent)); linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
linkedMesh->_mesh->updateUVs(); linkedMesh->_mesh->updateUVs();
_attachmentLoader->configureAttachment(linkedMesh->_mesh); _attachmentLoader->configureAttachment(linkedMesh->_mesh);

View File

@ -33,6 +33,7 @@
#include <spine/Skin.h> #include <spine/Skin.h>
#include <spine/Attachment.h> #include <spine/Attachment.h>
#include <spine/MeshAttachment.h>
#include <spine/Skeleton.h> #include <spine/Skeleton.h>
#include <spine/Slot.h> #include <spine/Slot.h>
@ -44,12 +45,20 @@ using namespace spine;
Skin::AttachmentMap::AttachmentMap() { Skin::AttachmentMap::AttachmentMap() {
} }
static void disposeAttachment(Attachment* attachment) {
if (!attachment) return;
attachment->dereference();
if (attachment->getRefCount() == 0) delete attachment;
}
void Skin::AttachmentMap::put(size_t slotIndex, const String &attachmentName, Attachment *attachment) { void Skin::AttachmentMap::put(size_t slotIndex, const String &attachmentName, Attachment *attachment) {
if (slotIndex >= _buckets.size()) if (slotIndex >= _buckets.size())
_buckets.setSize(slotIndex + 1, Vector<Entry>()); _buckets.setSize(slotIndex + 1, Vector<Entry>());
Vector<Entry> &bucket = _buckets[slotIndex]; Vector<Entry> &bucket = _buckets[slotIndex];
int existing = findInBucket(bucket, attachmentName); int existing = findInBucket(bucket, attachmentName);
attachment->reference();
if (existing >= 0) { if (existing >= 0) {
disposeAttachment(bucket[existing]._attachment);
bucket[existing]._attachment = attachment; bucket[existing]._attachment = attachment;
} else { } else {
bucket.add(Entry(slotIndex, attachmentName, attachment)); bucket.add(Entry(slotIndex, attachmentName, attachment));
@ -65,7 +74,10 @@ Attachment *Skin::AttachmentMap::get(size_t slotIndex, const String &attachmentN
void Skin::AttachmentMap::remove(size_t slotIndex, const String &attachmentName) { void Skin::AttachmentMap::remove(size_t slotIndex, const String &attachmentName) {
if (slotIndex >= _buckets.size()) return; if (slotIndex >= _buckets.size()) return;
int existing = findInBucket(_buckets[slotIndex], attachmentName); int existing = findInBucket(_buckets[slotIndex], attachmentName);
if (existing >= 0) _buckets[slotIndex].removeAt(existing); if (existing >= 0) {
disposeAttachment(_buckets[slotIndex][existing]._attachment);
_buckets[slotIndex].removeAt(existing);
}
} }
int Skin::AttachmentMap::findInBucket(Vector<Entry> &bucket, const String &attachmentName) { int Skin::AttachmentMap::findInBucket(Vector<Entry> &bucket, const String &attachmentName) {
@ -86,11 +98,11 @@ Skin::~Skin() {
Skin::AttachmentMap::Entries entries = _attachments.getEntries(); Skin::AttachmentMap::Entries entries = _attachments.getEntries();
while (entries.hasNext()) { while (entries.hasNext()) {
Skin::AttachmentMap::Entry entry = entries.next(); Skin::AttachmentMap::Entry entry = entries.next();
delete entry._attachment; disposeAttachment(entry._attachment);
} }
} }
void Skin::addAttachment(size_t slotIndex, const String &name, Attachment *attachment) { void Skin::setAttachment(size_t slotIndex, const String &name, Attachment *attachment) {
assert(attachment); assert(attachment);
_attachments.put(slotIndex, name, attachment); _attachments.put(slotIndex, name, attachment);
} }
@ -143,3 +155,23 @@ void Skin::attachAll(Skeleton &skeleton, Skin &oldSkin) {
} }
} }
} }
void Skin::addSkin(Skin* other) {
AttachmentMap::Entries entries = other->getAttachments();
while(entries.hasNext()) {
AttachmentMap::Entry& entry = entries.next();
setAttachment(entry._slotIndex, entry._name, entry._attachment);
}
}
void Skin::copySkin(Skin* other) {
AttachmentMap::Entries entries = other->getAttachments();
while(entries.hasNext()) {
AttachmentMap::Entry& entry = entries.next();
if (entry._attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
setAttachment(entry._slotIndex, entry._name, static_cast<MeshAttachment*>(entry._attachment)->newLinkedMesh());
} else {
setAttachment(entry._slotIndex, entry._name, entry._attachment->copy());
}
}
}

View File

@ -42,7 +42,7 @@ using namespace spine;
RTTI_IMPL(VertexAttachment, Attachment) RTTI_IMPL(VertexAttachment, Attachment)
VertexAttachment::VertexAttachment(const String &name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) { VertexAttachment::VertexAttachment(const String &name) : Attachment(name), _worldVerticesLength(0), _deformAttachment(this), _id(getNextID()) {
} }
VertexAttachment::~VertexAttachment() { VertexAttachment::~VertexAttachment() {
@ -131,10 +131,6 @@ void VertexAttachment::computeWorldVertices(Slot &slot, size_t start, size_t cou
} }
} }
bool VertexAttachment::applyDeform(VertexAttachment *sourceAttachment) {
return this == sourceAttachment;
}
int VertexAttachment::getId() { int VertexAttachment::getId() {
return _id; return _id;
} }
@ -155,8 +151,23 @@ void VertexAttachment::setWorldVerticesLength(size_t inValue) {
_worldVerticesLength = inValue; _worldVerticesLength = inValue;
} }
VertexAttachment* VertexAttachment::getDeformAttachment() {
return _deformAttachment;
}
void VertexAttachment::setDeformAttachment(VertexAttachment* attachment) {
_deformAttachment = attachment;
}
int VertexAttachment::getNextID() { int VertexAttachment::getNextID() {
static int nextID = 0; static int nextID = 0;
return (nextID++ & 65535) << 11; return (nextID++ & 65535) << 11;
} }
void VertexAttachment::copyTo(VertexAttachment* other) {
other->_bones.clearAndAddAll(this->_bones);
other->_vertices.clearAndAddAll(this->_vertices);
other->_worldVerticesLength = this->_worldVerticesLength;
other->_deformAttachment = this->_deformAttachment;
}

View File

@ -163,7 +163,13 @@ void goblins (SkeletonData* skeletonData, Atlas* atlas) {
drawable.setUsePremultipliedAlpha(true); drawable.setUsePremultipliedAlpha(true);
Skeleton* skeleton = drawable.skeleton; Skeleton* skeleton = drawable.skeleton;
skeleton->setSkin("goblin");
Skin* skin = skeleton->getData()->findSkin("goblingirl");
Skin copy("test");
copy.copySkin(skin);
skeleton->setSkin(&copy);
skeleton->setSlotsToSetupPose(); skeleton->setSlotsToSetupPose();
skeleton->setPosition(320, 590); skeleton->setPosition(320, 590);
@ -466,7 +472,8 @@ int main () {
DebugExtension dbgExtension(SpineExtension::getInstance()); DebugExtension dbgExtension(SpineExtension::getInstance());
SpineExtension::setInstance(&dbgExtension); SpineExtension::setInstance(&dbgExtension);
testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl-pma.atlas", 0.5f); testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins-pma.atlas", 1.4f);
/*testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl-pma.atlas", 0.5f);
testcase(spineboy, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f); testcase(spineboy, "data/spineboy-pro.json", "data/spineboy-pro.skel", "data/spineboy-pma.atlas", 0.6f);
testcase(stretchymanStrechyIk, "data/stretchyman-stretchy-ik-pro.json", "data/stretchyman-stretchy-ik-pro.skel", "data/stretchyman-pma.atlas", 0.6f); testcase(stretchymanStrechyIk, "data/stretchyman-stretchy-ik-pro.json", "data/stretchyman-stretchy-ik-pro.skel", "data/stretchyman-pma.atlas", 0.6f);
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f); testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f);
@ -474,8 +481,7 @@ int main () {
testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine-pma.atlas", 0.5f); testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine-pma.atlas", 0.5f);
testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank-pma.atlas", 0.2f); testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank-pma.atlas", 0.2f);
testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f); testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor-pma.atlas", 0.5f);
testcase(goblins, "data/goblins-pro.json", "data/goblins-pro.skel", "data/goblins-pma.atlas", 1.4f); testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman-pma.atlas", 0.6f);*/
testcase(stretchyman, "data/stretchyman-pro.json", "data/stretchyman-pro.skel", "data/stretchyman-pma.atlas", 0.6f);
dbgExtension.reportLeaks(); dbgExtension.reportLeaks();
return 0; return 0;