mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[cpp] Ported all skin API changes, see #841.
This commit is contained in:
parent
2eca53763f
commit
64852ddc96
@ -45,8 +45,15 @@ public:
|
||||
|
||||
const String &getName() const;
|
||||
|
||||
virtual Attachment* copy() = 0;
|
||||
|
||||
int getRefCount();
|
||||
void reference();
|
||||
void dereference();
|
||||
|
||||
private:
|
||||
const String _name;
|
||||
int _refCount;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,8 @@ namespace spine {
|
||||
RTTI_DECL
|
||||
|
||||
explicit BoundingBoxAttachment(const String& name);
|
||||
|
||||
virtual Attachment* copy();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -48,6 +48,8 @@ namespace spine {
|
||||
|
||||
SlotData* getEndSlot();
|
||||
void setEndSlot(SlotData* inValue);
|
||||
|
||||
virtual Attachment* copy();
|
||||
|
||||
private:
|
||||
SlotData* _endSlot;
|
||||
|
||||
@ -42,13 +42,14 @@ class SP_API LinkedMesh : public SpineObject {
|
||||
friend class SkeletonJson;
|
||||
|
||||
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:
|
||||
MeshAttachment *_mesh;
|
||||
String _skin;
|
||||
size_t _slotIndex;
|
||||
String _parent;
|
||||
bool _inheritDeform;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -50,8 +50,6 @@ namespace spine {
|
||||
virtual ~MeshAttachment();
|
||||
|
||||
void updateUVs();
|
||||
|
||||
virtual bool applyDeform(VertexAttachment* sourceAttachment);
|
||||
|
||||
int getHullLength();
|
||||
void setHullLength(int inValue);
|
||||
@ -104,9 +102,6 @@ namespace spine {
|
||||
float getRegionOriginalHeight();
|
||||
void setRegionOriginalHeight(float inValue);
|
||||
|
||||
bool getInheritDeform();
|
||||
void setInheritDeform(bool inValue);
|
||||
|
||||
MeshAttachment* getParentMesh();
|
||||
void setParentMesh(MeshAttachment* inValue);
|
||||
|
||||
@ -117,6 +112,10 @@ namespace spine {
|
||||
float getHeight();
|
||||
void setHeight(float inValue);
|
||||
|
||||
virtual Attachment* copy();
|
||||
|
||||
MeshAttachment* newLinkedMesh();
|
||||
|
||||
private:
|
||||
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
||||
MeshAttachment* _parentMesh;
|
||||
@ -133,7 +132,6 @@ namespace spine {
|
||||
float _height;
|
||||
Color _color;
|
||||
int _hullLength;
|
||||
bool _inheritDeform;
|
||||
bool _regionRotate;
|
||||
int _regionDegrees;
|
||||
};
|
||||
|
||||
@ -48,7 +48,8 @@ namespace spine {
|
||||
void setClosed(bool inValue);
|
||||
bool isConstantSpeed();
|
||||
void setConstantSpeed(bool inValue);
|
||||
|
||||
|
||||
virtual Attachment* copy();
|
||||
private:
|
||||
Vector<float> _lengths;
|
||||
bool _closed;
|
||||
|
||||
@ -63,6 +63,8 @@ namespace spine {
|
||||
|
||||
float getRotation();
|
||||
void setRotation(float inValue);
|
||||
|
||||
virtual Attachment* copy();
|
||||
|
||||
private:
|
||||
float _x, _y, _rotation;
|
||||
|
||||
@ -105,6 +105,8 @@ namespace spine {
|
||||
|
||||
Vector<float>& getOffset();
|
||||
Vector<float>& getUVs();
|
||||
|
||||
virtual Attachment* copy();
|
||||
|
||||
private:
|
||||
static const int BLX;
|
||||
|
||||
@ -117,7 +117,7 @@ public:
|
||||
|
||||
/// 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.
|
||||
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.
|
||||
Attachment *getAttachment(size_t slotIndex, const String &name);
|
||||
@ -134,6 +134,12 @@ public:
|
||||
|
||||
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();
|
||||
|
||||
private:
|
||||
|
||||
@ -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, 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.
|
||||
int getId();
|
||||
|
||||
@ -74,11 +71,17 @@ namespace spine {
|
||||
|
||||
size_t getWorldVerticesLength();
|
||||
void setWorldVerticesLength(size_t inValue);
|
||||
|
||||
VertexAttachment* getDeformAttachment();
|
||||
void setDeformAttachment(VertexAttachment* attachment);
|
||||
|
||||
void copyTo(VertexAttachment* other);
|
||||
|
||||
protected:
|
||||
Vector<size_t> _bones;
|
||||
Vector<float> _vertices;
|
||||
size_t _worldVerticesLength;
|
||||
VertexAttachment* _deformAttachment;
|
||||
|
||||
private:
|
||||
const int _id;
|
||||
|
||||
@ -39,7 +39,7 @@ using namespace spine;
|
||||
|
||||
RTTI_IMPL_NOPARENT(Attachment)
|
||||
|
||||
Attachment::Attachment(const String &name) : _name(name) {
|
||||
Attachment::Attachment(const String &name) : _name(name), _refCount(0) {
|
||||
assert(_name.length() > 0);
|
||||
}
|
||||
|
||||
@ -49,3 +49,15 @@ Attachment::~Attachment() {
|
||||
const String &Attachment::getName() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
int Attachment::getRefCount() {
|
||||
return _refCount;
|
||||
}
|
||||
|
||||
void Attachment::reference() {
|
||||
_refCount++;
|
||||
}
|
||||
|
||||
void Attachment::dereference() {
|
||||
_refCount--;
|
||||
}
|
||||
|
||||
@ -39,3 +39,9 @@ RTTI_IMPL(BoundingBoxAttachment, VertexAttachment)
|
||||
|
||||
BoundingBoxAttachment::BoundingBoxAttachment(const String &name) : VertexAttachment(name) {
|
||||
}
|
||||
|
||||
Attachment* BoundingBoxAttachment::copy() {
|
||||
BoundingBoxAttachment* copy = new (__FILE__, __LINE__) BoundingBoxAttachment(getName());
|
||||
copyTo(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
@ -49,3 +49,10 @@ SlotData *ClippingAttachment::getEndSlot() {
|
||||
void ClippingAttachment::setEndSlot(SlotData *inValue) {
|
||||
_endSlot = inValue;
|
||||
}
|
||||
|
||||
Attachment* ClippingAttachment::copy() {
|
||||
ClippingAttachment* copy = new (__FILE__, __LINE__) ClippingAttachment(getName());
|
||||
copyTo(copy);
|
||||
copy->_endSlot = _endSlot;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@ -74,7 +74,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
||||
}
|
||||
|
||||
VertexAttachment *attachment = static_cast<VertexAttachment *>(slotAttachment);
|
||||
if (!attachment->applyDeform(_attachment)) {
|
||||
if (attachment->_deformAttachment != _attachment) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -37,9 +37,10 @@
|
||||
|
||||
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),
|
||||
_skin(skin),
|
||||
_slotIndex(slotIndex),
|
||||
_parent(parent) {
|
||||
_parent(parent),
|
||||
_inheritDeform(inheritDeform) {
|
||||
}
|
||||
|
||||
@ -55,7 +55,6 @@ MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), Has
|
||||
_height(0),
|
||||
_color(1, 1, 1, 1),
|
||||
_hullLength(0),
|
||||
_inheritDeform(false),
|
||||
_regionRotate(false),
|
||||
_regionDegrees(0) {
|
||||
}
|
||||
@ -126,10 +125,6 @@ void MeshAttachment::updateUVs() {
|
||||
}
|
||||
}
|
||||
|
||||
bool MeshAttachment::applyDeform(VertexAttachment *sourceAttachment) {
|
||||
return this == sourceAttachment || (_inheritDeform && _parentMesh == sourceAttachment);
|
||||
}
|
||||
|
||||
int MeshAttachment::getHullLength() {
|
||||
return _hullLength;
|
||||
}
|
||||
@ -246,14 +241,6 @@ void MeshAttachment::setRegionOriginalHeight(float inValue) {
|
||||
_regionOriginalHeight = inValue;
|
||||
}
|
||||
|
||||
bool MeshAttachment::getInheritDeform() {
|
||||
return _inheritDeform;
|
||||
}
|
||||
|
||||
void MeshAttachment::setInheritDeform(bool inValue) {
|
||||
_inheritDeform = inValue;
|
||||
}
|
||||
|
||||
MeshAttachment *MeshAttachment::getParentMesh() {
|
||||
return _parentMesh;
|
||||
}
|
||||
@ -296,3 +283,59 @@ void MeshAttachment::setHeight(float inValue) {
|
||||
spine::Color &MeshAttachment::getColor() {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -58,3 +58,12 @@ bool PathAttachment::isConstantSpeed() {
|
||||
void PathAttachment::setConstantSpeed(bool 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;
|
||||
}
|
||||
|
||||
@ -80,3 +80,11 @@ float PointAttachment::getRotation() {
|
||||
void PointAttachment::setRotation(float inValue) {
|
||||
_rotation = inValue;
|
||||
}
|
||||
|
||||
Attachment* PointAttachment::copy() {
|
||||
PointAttachment* copy = new(__FILE__, __LINE__) PointAttachment(getName());
|
||||
copy->_x = _x;
|
||||
copy->_y = _y;
|
||||
copy->_rotation = _rotation;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@ -281,3 +281,26 @@ Vector<float> &RegionAttachment::getUVs() {
|
||||
spine::Color &RegionAttachment::getColor() {
|
||||
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;
|
||||
}
|
||||
@ -300,6 +300,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||
setError("Parent mesh not found: ", linkedMesh->_parent.buffer());
|
||||
return NULL;
|
||||
}
|
||||
linkedMesh->_mesh->_deformAttachment = linkedMesh->_inheritDeform ? static_cast<VertexAttachment*>(parent) : linkedMesh->_mesh;
|
||||
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
|
||||
linkedMesh->_mesh->updateUVs();
|
||||
_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) {
|
||||
String name(readString(input), true);
|
||||
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;
|
||||
@ -531,14 +532,14 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||
readColor(input, mesh->getColor());
|
||||
String skinName(readString(input), true);
|
||||
String parent(readString(input), true);
|
||||
mesh->_inheritDeform = readBoolean(input);
|
||||
bool inheritDeform = readBoolean(input);
|
||||
if (nonessential) {
|
||||
mesh->_width = readFloat(input) * _scale;
|
||||
mesh->_height = readFloat(input) * _scale;
|
||||
}
|
||||
|
||||
LinkedMesh *linkedMesh = new(__FILE__, __LINE__) LinkedMesh(mesh, String(skinName), slotIndex,
|
||||
String(parent));
|
||||
String(parent), inheritDeform);
|
||||
_linkedMeshes.add(linkedMesh);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
@ -569,13 +569,13 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||
}
|
||||
_attachmentLoader->configureAttachment(mesh);
|
||||
} 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,
|
||||
String(Json::getString(
|
||||
attachmentMap,
|
||||
"skin", 0)),
|
||||
slotIndex,
|
||||
String(entry->_valueString));
|
||||
String(entry->_valueString), inheritDeform);
|
||||
_linkedMeshes.add(linkedMesh);
|
||||
}
|
||||
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());
|
||||
return NULL;
|
||||
}
|
||||
linkedMesh->_mesh->_deformAttachment = linkedMesh->_inheritDeform ? static_cast<VertexAttachment*>(parent) : linkedMesh->_mesh;
|
||||
linkedMesh->_mesh->setParentMesh(static_cast<MeshAttachment *>(parent));
|
||||
linkedMesh->_mesh->updateUVs();
|
||||
_attachmentLoader->configureAttachment(linkedMesh->_mesh);
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
#include <spine/Skin.h>
|
||||
|
||||
#include <spine/Attachment.h>
|
||||
#include <spine/MeshAttachment.h>
|
||||
#include <spine/Skeleton.h>
|
||||
|
||||
#include <spine/Slot.h>
|
||||
@ -44,12 +45,20 @@ using namespace spine;
|
||||
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) {
|
||||
if (slotIndex >= _buckets.size())
|
||||
_buckets.setSize(slotIndex + 1, Vector<Entry>());
|
||||
Vector<Entry> &bucket = _buckets[slotIndex];
|
||||
int existing = findInBucket(bucket, attachmentName);
|
||||
attachment->reference();
|
||||
if (existing >= 0) {
|
||||
disposeAttachment(bucket[existing]._attachment);
|
||||
bucket[existing]._attachment = attachment;
|
||||
} else {
|
||||
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) {
|
||||
if (slotIndex >= _buckets.size()) return;
|
||||
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) {
|
||||
@ -86,11 +98,11 @@ Skin::~Skin() {
|
||||
Skin::AttachmentMap::Entries entries = _attachments.getEntries();
|
||||
while (entries.hasNext()) {
|
||||
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);
|
||||
_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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ using namespace spine;
|
||||
|
||||
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() {
|
||||
@ -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() {
|
||||
return _id;
|
||||
}
|
||||
@ -155,8 +151,23 @@ void VertexAttachment::setWorldVerticesLength(size_t inValue) {
|
||||
_worldVerticesLength = inValue;
|
||||
}
|
||||
|
||||
VertexAttachment* VertexAttachment::getDeformAttachment() {
|
||||
return _deformAttachment;
|
||||
}
|
||||
|
||||
void VertexAttachment::setDeformAttachment(VertexAttachment* attachment) {
|
||||
_deformAttachment = attachment;
|
||||
}
|
||||
|
||||
int VertexAttachment::getNextID() {
|
||||
static int nextID = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -163,7 +163,13 @@ void goblins (SkeletonData* skeletonData, Atlas* atlas) {
|
||||
drawable.setUsePremultipliedAlpha(true);
|
||||
|
||||
Skeleton* skeleton = drawable.skeleton;
|
||||
skeleton->setSkin("goblin");
|
||||
|
||||
Skin* skin = skeleton->getData()->findSkin("goblingirl");
|
||||
Skin copy("test");
|
||||
|
||||
copy.copySkin(skin);
|
||||
|
||||
skeleton->setSkin(©);
|
||||
skeleton->setSlotsToSetupPose();
|
||||
|
||||
skeleton->setPosition(320, 590);
|
||||
@ -466,7 +472,8 @@ int main () {
|
||||
DebugExtension dbgExtension(SpineExtension::getInstance());
|
||||
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(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);
|
||||
@ -474,8 +481,7 @@ int main () {
|
||||
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(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();
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user