mirror of https://github.com/axmolengine/axmol.git
Update spine to 4.1-fc05ecf
This commit is contained in:
parent
e1c64d8e4c
commit
d347a454a7
|
@ -71,7 +71,6 @@ namespace spine {
|
||||||
Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_AFTER_DRAW_RESET_POSITION, [this](EventCustom *eventCustom) {
|
Director::getInstance()->getEventDispatcher()->addCustomEventListener(EVENT_AFTER_DRAW_RESET_POSITION, [this](EventCustom *eventCustom) {
|
||||||
this->update(0);
|
this->update(0);
|
||||||
});
|
});
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SkeletonBatch::~SkeletonBatch() {
|
SkeletonBatch::~SkeletonBatch() {
|
||||||
|
|
|
@ -269,7 +269,7 @@ namespace spine {
|
||||||
Color darkColor;
|
Color darkColor;
|
||||||
const float darkPremultipliedAlpha = _premultipliedAlpha ? 1.f : 0;
|
const float darkPremultipliedAlpha = _premultipliedAlpha ? 1.f : 0;
|
||||||
TwoColorTrianglesCommand *lastTwoColorTrianglesCommand = nullptr;
|
TwoColorTrianglesCommand *lastTwoColorTrianglesCommand = nullptr;
|
||||||
for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
|
for (int i = 0, n = (int)_skeleton->getSlots().size(); i < n; ++i) {
|
||||||
Slot *slot = _skeleton->getDrawOrder()[i];
|
Slot *slot = _skeleton->getDrawOrder()[i];
|
||||||
|
|
||||||
if (nothingToDraw(*slot, _startSlotIndex, _endSlotIndex)) {
|
if (nothingToDraw(*slot, _startSlotIndex, _endSlotIndex)) {
|
||||||
|
@ -284,7 +284,7 @@ namespace spine {
|
||||||
|
|
||||||
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
|
if (slot->getAttachment()->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
RegionAttachment *attachment = static_cast<RegionAttachment *>(slot->getAttachment());
|
RegionAttachment *attachment = static_cast<RegionAttachment *>(slot->getAttachment());
|
||||||
texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->getRendererObject();
|
texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->texture;
|
||||||
|
|
||||||
float *dstTriangleVertices = nullptr;
|
float *dstTriangleVertices = nullptr;
|
||||||
int dstStride = 0;// in floats
|
int dstStride = 0;// in floats
|
||||||
|
@ -322,7 +322,7 @@ namespace spine {
|
||||||
color = attachment->getColor();
|
color = attachment->getColor();
|
||||||
} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
|
} else if (slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||||
MeshAttachment *attachment = (MeshAttachment *) slot->getAttachment();
|
MeshAttachment *attachment = (MeshAttachment *) slot->getAttachment();
|
||||||
texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->getRendererObject();
|
texture = (Texture2D*)((AtlasRegion*)attachment->getRegion())->page->texture;
|
||||||
|
|
||||||
float *dstTriangleVertices = nullptr;
|
float *dstTriangleVertices = nullptr;
|
||||||
int dstStride = 0;// in floats
|
int dstStride = 0;// in floats
|
||||||
|
@ -330,8 +330,8 @@ namespace spine {
|
||||||
if (hasSingleTint) {
|
if (hasSingleTint) {
|
||||||
triangles.indices = attachment->getTriangles().buffer();
|
triangles.indices = attachment->getTriangles().buffer();
|
||||||
triangles.indexCount = (unsigned short)attachment->getTriangles().size();
|
triangles.indexCount = (unsigned short)attachment->getTriangles().size();
|
||||||
triangles.verts = batch->allocateVertices(attachment->getWorldVerticesLength() / 2);
|
triangles.verts = batch->allocateVertices((int)attachment->getWorldVerticesLength() / 2);
|
||||||
triangles.vertCount = attachment->getWorldVerticesLength() / 2;
|
triangles.vertCount = (int)attachment->getWorldVerticesLength() / 2;
|
||||||
for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) {
|
for (int v = 0, i = 0; v < triangles.vertCount; v++, i += 2) {
|
||||||
auto &texCoords = triangles.verts[v].texCoords;
|
auto &texCoords = triangles.verts[v].texCoords;
|
||||||
texCoords.u = attachment->getUVs()[i];
|
texCoords.u = attachment->getUVs()[i];
|
||||||
|
@ -343,8 +343,8 @@ namespace spine {
|
||||||
} else {
|
} else {
|
||||||
trianglesTwoColor.indices = attachment->getTriangles().buffer();
|
trianglesTwoColor.indices = attachment->getTriangles().buffer();
|
||||||
trianglesTwoColor.indexCount = (unsigned short)attachment->getTriangles().size();
|
trianglesTwoColor.indexCount = (unsigned short)attachment->getTriangles().size();
|
||||||
trianglesTwoColor.verts = twoColorBatch->allocateVertices(attachment->getWorldVerticesLength() / 2);
|
trianglesTwoColor.verts = twoColorBatch->allocateVertices((int)attachment->getWorldVerticesLength() / 2);
|
||||||
trianglesTwoColor.vertCount = attachment->getWorldVerticesLength() / 2;
|
trianglesTwoColor.vertCount = (int)attachment->getWorldVerticesLength() / 2;
|
||||||
for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) {
|
for (int v = 0, i = 0; v < trianglesTwoColor.vertCount; v++, i += 2) {
|
||||||
auto &texCoords = trianglesTwoColor.verts[v].texCoords;
|
auto &texCoords = trianglesTwoColor.verts[v].texCoords;
|
||||||
texCoords.u = attachment->getUVs()[i];
|
texCoords.u = attachment->getUVs()[i];
|
||||||
|
@ -408,9 +408,9 @@ namespace spine {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
triangles.vertCount = _clipper->getClippedVertices().size() / 2;
|
triangles.vertCount = (int)_clipper->getClippedVertices().size() / 2;
|
||||||
triangles.verts = batch->allocateVertices(triangles.vertCount);
|
triangles.verts = batch->allocateVertices(triangles.vertCount);
|
||||||
triangles.indexCount = _clipper->getClippedTriangles().size();
|
triangles.indexCount = (int)_clipper->getClippedTriangles().size();
|
||||||
triangles.indices = batch->allocateIndices(triangles.indexCount);
|
triangles.indices = batch->allocateIndices(triangles.indexCount);
|
||||||
memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
|
memcpy(triangles.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
|
||||||
|
|
||||||
|
@ -454,9 +454,9 @@ namespace spine {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
trianglesTwoColor.vertCount = _clipper->getClippedVertices().size() / 2;
|
trianglesTwoColor.vertCount = (int)_clipper->getClippedVertices().size() / 2;
|
||||||
trianglesTwoColor.verts = twoColorBatch->allocateVertices(trianglesTwoColor.vertCount);
|
trianglesTwoColor.verts = twoColorBatch->allocateVertices(trianglesTwoColor.vertCount);
|
||||||
trianglesTwoColor.indexCount = _clipper->getClippedTriangles().size();
|
trianglesTwoColor.indexCount = (int)_clipper->getClippedTriangles().size();
|
||||||
trianglesTwoColor.indices = twoColorBatch->allocateIndices(trianglesTwoColor.indexCount);
|
trianglesTwoColor.indices = twoColorBatch->allocateIndices(trianglesTwoColor.indexCount);
|
||||||
memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
|
memcpy(trianglesTwoColor.indices, _clipper->getClippedTriangles().buffer(), sizeof(unsigned short) * _clipper->getClippedTriangles().size());
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ namespace spine {
|
||||||
drawNode->setLineWidth(2.0f);
|
drawNode->setLineWidth(2.0f);
|
||||||
#endif
|
#endif
|
||||||
V3F_C4B_T2F_Quad quad;
|
V3F_C4B_T2F_Quad quad;
|
||||||
for (int i = 0, n = _skeleton->getSlots().size(); i < n; i++) {
|
for (int i = 0, n = (int)_skeleton->getSlots().size(); i < n; i++) {
|
||||||
Slot *slot = _skeleton->getDrawOrder()[i];
|
Slot *slot = _skeleton->getDrawOrder()[i];
|
||||||
|
|
||||||
if (!slot->getBone().isActive()) continue;
|
if (!slot->getBone().isActive()) continue;
|
||||||
|
@ -606,7 +606,7 @@ namespace spine {
|
||||||
#else
|
#else
|
||||||
drawNode->setLineWidth(2.0f);
|
drawNode->setLineWidth(2.0f);
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0, n = _skeleton->getBones().size(); i < n; i++) {
|
for (int i = 0, n = (int)_skeleton->getBones().size(); i < n; i++) {
|
||||||
Bone *bone = _skeleton->getBones()[i];
|
Bone *bone = _skeleton->getBones()[i];
|
||||||
if (!bone->isActive()) continue;
|
if (!bone->isActive()) continue;
|
||||||
float x = bone->getData().getLength() * bone->getA() + bone->getWorldX();
|
float x = bone->getData().getLength() * bone->getA() + bone->getWorldX();
|
||||||
|
@ -615,7 +615,7 @@ namespace spine {
|
||||||
}
|
}
|
||||||
// Bone origins.
|
// Bone origins.
|
||||||
auto color = Color4F::BLUE;// Root bone is blue.
|
auto color = Color4F::BLUE;// Root bone is blue.
|
||||||
for (int i = 0, n = _skeleton->getBones().size(); i < n; i++) {
|
for (int i = 0, n = (int)_skeleton->getBones().size(); i < n; i++) {
|
||||||
Bone *bone = _skeleton->getBones()[i];
|
Bone *bone = _skeleton->getBones()[i];
|
||||||
if (!bone->isActive()) continue;
|
if (!bone->isActive()) continue;
|
||||||
drawNode->drawPoint(Vec2(bone->getWorldX(), bone->getWorldY()), 4, color);
|
drawNode->drawPoint(Vec2(bone->getWorldX(), bone->getWorldY()), 4, color);
|
||||||
|
@ -630,7 +630,7 @@ namespace spine {
|
||||||
#else
|
#else
|
||||||
drawNode->setLineWidth(2.0f);
|
drawNode->setLineWidth(2.0f);
|
||||||
#endif
|
#endif
|
||||||
for (int i = 0, n = _skeleton->getSlots().size(); i < n; ++i) {
|
for (int i = 0, n = (int)_skeleton->getSlots().size(); i < n; ++i) {
|
||||||
Slot *slot = _skeleton->getDrawOrder()[i];
|
Slot *slot = _skeleton->getDrawOrder()[i];
|
||||||
if (!slot->getBone().isActive()) continue;
|
if (!slot->getBone().isActive()) continue;
|
||||||
if (!slot->getAttachment() || !slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) continue;
|
if (!slot->getAttachment() || !slot->getAttachment()->getRTTI().isExactly(MeshAttachment::rtti)) continue;
|
||||||
|
|
|
@ -35,8 +35,6 @@
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
// class AttachmentVertices;
|
|
||||||
|
|
||||||
/* Draws a skeleton. */
|
/* Draws a skeleton. */
|
||||||
class SP_API SkeletonRenderer : public cocos2d::Node, public cocos2d::BlendProtocol {
|
class SP_API SkeletonRenderer : public cocos2d::Node, public cocos2d::BlendProtocol {
|
||||||
public:
|
public:
|
||||||
|
@ -153,8 +151,6 @@ namespace spine {
|
||||||
int _startSlotIndex;
|
int _startSlotIndex;
|
||||||
int _endSlotIndex;
|
int _endSlotIndex;
|
||||||
bool _twoColorTint;
|
bool _twoColorTint;
|
||||||
|
|
||||||
//Pool<AttachmentVertices*> _verticesPool;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}// namespace spine
|
}// namespace spine
|
||||||
|
|
|
@ -319,7 +319,7 @@ namespace spine {
|
||||||
unsigned short *SkeletonTwoColorBatch::allocateIndices(uint32_t numIndices) {
|
unsigned short *SkeletonTwoColorBatch::allocateIndices(uint32_t numIndices) {
|
||||||
if (_indices.getCapacity() - _indices.size() < numIndices) {
|
if (_indices.getCapacity() - _indices.size() < numIndices) {
|
||||||
unsigned short *oldData = _indices.buffer();
|
unsigned short *oldData = _indices.buffer();
|
||||||
int oldSize = _indices.size();
|
int oldSize = (int)_indices.size();
|
||||||
_indices.ensureCapacity(_indices.size() + numIndices);
|
_indices.ensureCapacity(_indices.size() + numIndices);
|
||||||
unsigned short *newData = _indices.buffer();
|
unsigned short *newData = _indices.buffer();
|
||||||
for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
|
for (uint32_t i = 0; i < this->_nextFreeCommand; i++) {
|
||||||
|
@ -404,8 +404,8 @@ namespace spine {
|
||||||
|
|
||||||
TwoColorTrianglesCommand *SkeletonTwoColorBatch::nextFreeCommand() {
|
TwoColorTrianglesCommand *SkeletonTwoColorBatch::nextFreeCommand() {
|
||||||
if (_commandsPool.size() <= _nextFreeCommand) {
|
if (_commandsPool.size() <= _nextFreeCommand) {
|
||||||
unsigned int newSize = _commandsPool.size() * 2 + 1;
|
unsigned int newSize = (int)_commandsPool.size() * 2 + 1;
|
||||||
for (int i = _commandsPool.size(); i < newSize; i++) {
|
for (int i = (int)_commandsPool.size(); i < newSize; i++) {
|
||||||
_commandsPool.push_back(new TwoColorTrianglesCommand());
|
_commandsPool.push_back(new TwoColorTrianglesCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
enum EventType {
|
enum EventType {
|
||||||
EventType_Start,
|
EventType_Start = 0,
|
||||||
EventType_Interrupt,
|
EventType_Interrupt,
|
||||||
EventType_End,
|
EventType_End,
|
||||||
EventType_Complete,
|
EventType_Complete,
|
||||||
|
@ -311,14 +311,13 @@ namespace spine {
|
||||||
private:
|
private:
|
||||||
Vector<EventQueueEntry> _eventQueueEntries;
|
Vector<EventQueueEntry> _eventQueueEntries;
|
||||||
AnimationState &_state;
|
AnimationState &_state;
|
||||||
Pool<TrackEntry> &_trackEntryPool;
|
|
||||||
bool _drainDisabled;
|
bool _drainDisabled;
|
||||||
|
|
||||||
static EventQueue *newEventQueue(AnimationState &state, Pool<TrackEntry> &trackEntryPool);
|
static EventQueue *newEventQueue(AnimationState &state);
|
||||||
|
|
||||||
static EventQueueEntry newEventQueueEntry(EventType eventType, TrackEntry *entry, Event *event = NULL);
|
static EventQueueEntry newEventQueueEntry(EventType eventType, TrackEntry *entry, Event *event = NULL);
|
||||||
|
|
||||||
EventQueue(AnimationState &state, Pool<TrackEntry> &trackEntryPool);
|
EventQueue(AnimationState &state);
|
||||||
|
|
||||||
~EventQueue();
|
~EventQueue();
|
||||||
|
|
||||||
|
@ -429,6 +428,12 @@ namespace spine {
|
||||||
|
|
||||||
void enableQueue();
|
void enableQueue();
|
||||||
|
|
||||||
|
void setManualTrackEntryDisposal(bool inValue);
|
||||||
|
|
||||||
|
bool getManualTrackEntryDisposal();
|
||||||
|
|
||||||
|
void disposeTrackEntry(TrackEntry *entry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int Subsequent = 0;
|
static const int Subsequent = 0;
|
||||||
static const int First = 1;
|
static const int First = 1;
|
||||||
|
@ -456,6 +461,8 @@ namespace spine {
|
||||||
|
|
||||||
float _timeScale;
|
float _timeScale;
|
||||||
|
|
||||||
|
bool _manualTrackEntryDisposal;
|
||||||
|
|
||||||
static Animation *getEmptyAnimation();
|
static Animation *getEmptyAnimation();
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace spine {
|
||||||
TextureWrap_Repeat
|
TextureWrap_Repeat
|
||||||
};
|
};
|
||||||
|
|
||||||
class SP_API AtlasPage : public SpineObject, public HasRendererObject {
|
class SP_API AtlasPage : public SpineObject {
|
||||||
public:
|
public:
|
||||||
String name;
|
String name;
|
||||||
String texturePath;
|
String texturePath;
|
||||||
|
@ -84,11 +84,13 @@ namespace spine {
|
||||||
TextureWrap vWrap;
|
TextureWrap vWrap;
|
||||||
int width, height;
|
int width, height;
|
||||||
bool pma;
|
bool pma;
|
||||||
|
int index;
|
||||||
|
void *texture;
|
||||||
|
|
||||||
explicit AtlasPage(const String &inName) : name(inName), format(Format_RGBA8888),
|
explicit AtlasPage(const String &inName) : name(inName), format(Format_RGBA8888),
|
||||||
minFilter(TextureFilter_Nearest),
|
minFilter(TextureFilter_Nearest),
|
||||||
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
|
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
|
||||||
vWrap(TextureWrap_ClampToEdge), width(0), height(0), pma(false) {
|
vWrap(TextureWrap_ClampToEdge), width(0), height(0), pma(false), index(0), texture(NULL) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,12 @@ namespace spine {
|
||||||
void
|
void
|
||||||
updateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY);
|
updateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY);
|
||||||
|
|
||||||
|
/// Computes the individual applied transform values from the world transform. This can be useful to perform processing using
|
||||||
|
/// the applied transform after the world transform has been modified directly (eg, by a constraint)..
|
||||||
|
///
|
||||||
|
/// Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation.
|
||||||
|
void updateAppliedTransform();
|
||||||
|
|
||||||
void setToSetupPose();
|
void setToSetupPose();
|
||||||
|
|
||||||
void worldToLocal(float worldX, float worldY, float &outLocalX, float &outLocalY);
|
void worldToLocal(float worldX, float worldY, float &outLocalX, float &outLocalY);
|
||||||
|
@ -260,12 +266,6 @@ namespace spine {
|
||||||
float _c, _d, _worldY;
|
float _c, _d, _worldY;
|
||||||
bool _sorted;
|
bool _sorted;
|
||||||
bool _active;
|
bool _active;
|
||||||
|
|
||||||
/// Computes the individual applied transform values from the world transform. This can be useful to perform processing using
|
|
||||||
/// the applied transform after the world transform has been modified directly (eg, by a constraint)..
|
|
||||||
///
|
|
||||||
/// Some information is ambiguous in the world transform, such as -1,-1 scale versus 180 rotation.
|
|
||||||
void updateAppliedTransform();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,11 @@
|
||||||
#include <spine/SpineString.h>
|
#include <spine/SpineString.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
/// The interface for all constraints.
|
/// The interface for all constraints.
|
||||||
class SP_API ConstraintData : public SpineObject {
|
class SP_API ConstraintData : public SpineObject {
|
||||||
|
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConstraintData(const String &name);
|
ConstraintData(const String &name);
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class DebugExtension : public SpineExtension {
|
class SP_API DebugExtension : public SpineExtension {
|
||||||
struct Allocation {
|
struct Allocation {
|
||||||
void *address;
|
void *address;
|
||||||
size_t size;
|
size_t size;
|
||||||
|
@ -62,7 +62,7 @@ namespace spine {
|
||||||
it->second.address);
|
it->second.address);
|
||||||
}
|
}
|
||||||
printf("allocations: %zu, reallocations: %zu, frees: %zu\n", _allocations, _reallocations, _frees);
|
printf("allocations: %zu, reallocations: %zu, frees: %zu\n", _allocations, _reallocations, _frees);
|
||||||
if (_allocated.empty()) printf("No leaks detected");
|
if (_allocated.empty()) printf("No leaks detected\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAllocations() {
|
void clearAllocations() {
|
||||||
|
|
|
@ -64,9 +64,6 @@ namespace spine {
|
||||||
|
|
||||||
IkConstraint(IkConstraintData &data, Skeleton &skeleton);
|
IkConstraint(IkConstraintData &data, Skeleton &skeleton);
|
||||||
|
|
||||||
/// Applies the constraint to the constrained bones.
|
|
||||||
void apply();
|
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
virtual int getOrder();
|
virtual int getOrder();
|
||||||
|
|
|
@ -50,6 +50,8 @@ namespace spine {
|
||||||
friend class IkConstraintTimeline;
|
friend class IkConstraintTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
explicit IkConstraintData(const String &name);
|
explicit IkConstraintData(const String &name);
|
||||||
|
|
||||||
/// The bones that are constrained by this IK Constraint.
|
/// The bones that are constrained by this IK Constraint.
|
||||||
|
|
|
@ -33,6 +33,9 @@
|
||||||
#include <spine/SpineObject.h>
|
#include <spine/SpineObject.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
// Needed for older MSVC versions
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
/// Attachment that displays a texture region using a mesh.
|
/// Attachment that displays a texture region using a mesh.
|
||||||
class SP_API MeshAttachment : public VertexAttachment, public HasRendererObject {
|
class SP_API MeshAttachment : public VertexAttachment {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
|
@ -59,13 +59,18 @@ namespace spine {
|
||||||
public:
|
public:
|
||||||
PathConstraint(PathConstraintData &data, Skeleton &skeleton);
|
PathConstraint(PathConstraintData &data, Skeleton &skeleton);
|
||||||
|
|
||||||
/// Applies the constraint to the constrained bones.
|
|
||||||
void apply();
|
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
virtual int getOrder();
|
virtual int getOrder();
|
||||||
|
|
||||||
|
PathConstraintData &getData();
|
||||||
|
|
||||||
|
Vector<Bone *> &getBones();
|
||||||
|
|
||||||
|
Slot *getTarget();
|
||||||
|
|
||||||
|
void setTarget(Slot *inValue);
|
||||||
|
|
||||||
float getPosition();
|
float getPosition();
|
||||||
|
|
||||||
void setPosition(float inValue);
|
void setPosition(float inValue);
|
||||||
|
@ -86,14 +91,6 @@ namespace spine {
|
||||||
|
|
||||||
void setMixY(float inValue);
|
void setMixY(float inValue);
|
||||||
|
|
||||||
Vector<Bone *> &getBones();
|
|
||||||
|
|
||||||
Slot *getTarget();
|
|
||||||
|
|
||||||
void setTarget(Slot *inValue);
|
|
||||||
|
|
||||||
PathConstraintData &getData();
|
|
||||||
|
|
||||||
bool isActive();
|
bool isActive();
|
||||||
|
|
||||||
void setActive(bool inValue);
|
void setActive(bool inValue);
|
||||||
|
|
|
@ -57,8 +57,9 @@ namespace spine {
|
||||||
friend class PathConstraintPositionTimeline;
|
friend class PathConstraintPositionTimeline;
|
||||||
|
|
||||||
friend class PathConstraintSpacingTimeline;
|
friend class PathConstraintSpacingTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
explicit PathConstraintData(const String &name);
|
explicit PathConstraintData(const String &name);
|
||||||
|
|
||||||
Vector<BoneData *> &getBones();
|
Vector<BoneData *> &getBones();
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace spine {
|
||||||
class Bone;
|
class Bone;
|
||||||
|
|
||||||
/// Attachment that displays a texture region.
|
/// Attachment that displays a texture region.
|
||||||
class SP_API RegionAttachment : public Attachment, public HasRendererObject {
|
class SP_API RegionAttachment : public Attachment {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
|
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
@ -61,7 +61,7 @@ namespace spine {
|
||||||
void updateRegion();
|
void updateRegion();
|
||||||
|
|
||||||
/// Transforms the attachment's four vertices to world coordinates.
|
/// Transforms the attachment's four vertices to world coordinates.
|
||||||
/// @param bone The parent bone.
|
/// @param slot The parent slot.
|
||||||
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
|
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
|
||||||
/// @param offset The worldVertices index to begin writing values.
|
/// @param offset The worldVertices index to begin writing values.
|
||||||
/// @param stride The number of worldVertices entries between the value pairs written.
|
/// @param stride The number of worldVertices entries between the value pairs written.
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace spine {
|
||||||
Attachment *readAttachment(DataInput *input, Skin *skin, int slotIndex, const String &attachmentName,
|
Attachment *readAttachment(DataInput *input, Skin *skin, int slotIndex, const String &attachmentName,
|
||||||
SkeletonData *skeletonData, bool nonessential);
|
SkeletonData *skeletonData, bool nonessential);
|
||||||
|
|
||||||
void readVertices(DataInput *input, Vector<float> &vertices, Vector<size_t> &bones, int vertexCount);
|
void readVertices(DataInput *input, Vector<float> &vertices, Vector<int> &bones, int vertexCount);
|
||||||
|
|
||||||
void readFloatArray(DataInput *input, int n, float scale, Vector<float> &array);
|
void readFloatArray(DataInput *input, int n, float scale, Vector<float> &array);
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,19 @@ namespace spine {
|
||||||
/// Returns true if the polygon contains the line segment.
|
/// Returns true if the polygon contains the line segment.
|
||||||
bool intersectsSegment(Polygon *polygon, float x1, float y1, float x2, float y2);
|
bool intersectsSegment(Polygon *polygon, float x1, float y1, float x2, float y2);
|
||||||
|
|
||||||
|
/// Returns the polygon for the given bounding box attachment or null if no
|
||||||
|
/// polygon can be found for the attachment. Requires a call to update() first.
|
||||||
Polygon *getPolygon(BoundingBoxAttachment *attachment);
|
Polygon *getPolygon(BoundingBoxAttachment *attachment);
|
||||||
|
|
||||||
|
/// Returns the bounding box for the given polygon or null. Requires a call to update() first.
|
||||||
|
BoundingBoxAttachment * getBoundingBox(Polygon *polygon);
|
||||||
|
|
||||||
|
/// Returns all polygons or an empty vector. Requires a call to update() first.
|
||||||
|
Vector<Polygon *> &getPolygons();
|
||||||
|
|
||||||
|
/// Returns all bounding boxes. Requires a call to update() first.
|
||||||
|
Vector<BoundingBoxAttachment *> &getBoundingBoxes();
|
||||||
|
|
||||||
float getWidth();
|
float getWidth();
|
||||||
|
|
||||||
float getHeight();
|
float getHeight();
|
||||||
|
|
|
@ -36,11 +36,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
// Required for sprintf on MSVC
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable:4996)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API String : public SpineObject {
|
class SP_API String : public SpineObject {
|
||||||
public:
|
public:
|
||||||
|
@ -170,14 +165,14 @@ namespace spine {
|
||||||
|
|
||||||
String &append(int other) {
|
String &append(int other) {
|
||||||
char str[100];
|
char str[100];
|
||||||
sprintf(str, "%i", other);
|
snprintf(str, 100, "%i", other);
|
||||||
append(str);
|
append(str);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
String &append(float other) {
|
String &append(float other) {
|
||||||
char str[100];
|
char str[100];
|
||||||
sprintf(str, "%f", other);
|
snprintf(str, 100, "%f", other);
|
||||||
append(str);
|
append(str);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,40 +50,72 @@ namespace spine {
|
||||||
friend class TransformConstraintTimeline;
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
RTTI_DECL
|
||||||
|
|
||||||
explicit TransformConstraintData(const String &name);
|
explicit TransformConstraintData(const String &name);
|
||||||
|
|
||||||
Vector<BoneData *> &getBones();
|
Vector<BoneData *> &getBones();
|
||||||
|
|
||||||
BoneData *getTarget();
|
BoneData *getTarget();
|
||||||
|
|
||||||
|
void setTarget(BoneData *target);
|
||||||
|
|
||||||
float getMixRotate();
|
float getMixRotate();
|
||||||
|
|
||||||
|
void setMixRotate(float mixRotate);
|
||||||
|
|
||||||
float getMixX();
|
float getMixX();
|
||||||
|
|
||||||
|
void setMixX(float mixX);
|
||||||
|
|
||||||
float getMixY();
|
float getMixY();
|
||||||
|
|
||||||
|
void setMixY(float mixY);
|
||||||
|
|
||||||
float getMixScaleX();
|
float getMixScaleX();
|
||||||
|
|
||||||
|
void setMixScaleX(float mixScaleX);
|
||||||
|
|
||||||
float getMixScaleY();
|
float getMixScaleY();
|
||||||
|
|
||||||
|
void setMixScaleY(float mixScaleY);
|
||||||
|
|
||||||
float getMixShearY();
|
float getMixShearY();
|
||||||
|
|
||||||
|
void setMixShearY(float mixShearY);
|
||||||
|
|
||||||
float getOffsetRotation();
|
float getOffsetRotation();
|
||||||
|
|
||||||
|
void setOffsetRotation(float offsetRotation);
|
||||||
|
|
||||||
float getOffsetX();
|
float getOffsetX();
|
||||||
|
|
||||||
|
void setOffsetX(float offsetX);
|
||||||
|
|
||||||
float getOffsetY();
|
float getOffsetY();
|
||||||
|
|
||||||
|
void setOffsetY(float offsetY);
|
||||||
|
|
||||||
float getOffsetScaleX();
|
float getOffsetScaleX();
|
||||||
|
|
||||||
|
void setOffsetScaleX(float offsetScaleX);
|
||||||
|
|
||||||
float getOffsetScaleY();
|
float getOffsetScaleY();
|
||||||
|
|
||||||
|
void setOffsetScaleY(float offsetScaleY);
|
||||||
|
|
||||||
float getOffsetShearY();
|
float getOffsetShearY();
|
||||||
|
|
||||||
|
void setOffsetShearY(float offsetShearY);
|
||||||
|
|
||||||
bool isRelative();
|
bool isRelative();
|
||||||
|
|
||||||
|
void setRelative(bool isRelative);
|
||||||
|
|
||||||
bool isLocal();
|
bool isLocal();
|
||||||
|
|
||||||
|
void setLocal(bool isLocal);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<BoneData *> _bones;
|
Vector<BoneData *> _bones;
|
||||||
BoneData *_target;
|
BoneData *_target;
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace spine {
|
||||||
/// Gets a unique ID for this attachment.
|
/// Gets a unique ID for this attachment.
|
||||||
int getId();
|
int getId();
|
||||||
|
|
||||||
Vector <size_t> &getBones();
|
Vector<int> &getBones();
|
||||||
|
|
||||||
Vector<float> &getVertices();
|
Vector<float> &getVertices();
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ namespace spine {
|
||||||
void copyTo(VertexAttachment *other);
|
void copyTo(VertexAttachment *other);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Vector <size_t> _bones;
|
Vector <int> _bones;
|
||||||
Vector<float> _vertices;
|
Vector<float> _vertices;
|
||||||
size_t _worldVerticesLength;
|
size_t _worldVerticesLength;
|
||||||
Attachment *_timelineAttachment;
|
Attachment *_timelineAttachment;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API Vertices : public SpineObject {
|
class SP_API Vertices : public SpineObject {
|
||||||
public:
|
public:
|
||||||
Vector <size_t> _bones;
|
Vector <int> _bones;
|
||||||
Vector<float> _vertices;
|
Vector<float> _vertices;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,17 +211,16 @@ EventQueueEntry::EventQueueEntry(EventType eventType, TrackEntry *trackEntry, Ev
|
||||||
_event(event) {
|
_event(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EventQueue *EventQueue::newEventQueue(AnimationState &state, Pool<TrackEntry> &trackEntryPool) {
|
EventQueue *EventQueue::newEventQueue(AnimationState &state) {
|
||||||
return new (__FILE__, __LINE__) EventQueue(state, trackEntryPool);
|
return new (__FILE__, __LINE__) EventQueue(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventQueueEntry EventQueue::newEventQueueEntry(EventType eventType, TrackEntry *entry, Event *event) {
|
EventQueueEntry EventQueue::newEventQueueEntry(EventType eventType, TrackEntry *entry, Event *event) {
|
||||||
return EventQueueEntry(eventType, entry, event);
|
return EventQueueEntry(eventType, entry, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventQueue::EventQueue(AnimationState &state, Pool<TrackEntry> &trackEntryPool) : _state(state),
|
EventQueue::EventQueue(AnimationState &state) : _state(state),
|
||||||
_trackEntryPool(trackEntryPool),
|
_drainDisabled(false) {
|
||||||
_drainDisabled(false) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EventQueue::~EventQueue() {
|
EventQueue::~EventQueue() {
|
||||||
|
@ -295,8 +294,7 @@ void EventQueue::drain() {
|
||||||
else
|
else
|
||||||
state._listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
state._listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
|
|
||||||
trackEntry->reset();
|
if (!_state.getManualTrackEntryDisposal()) _state.disposeTrackEntry(trackEntry);
|
||||||
_trackEntryPool.free(trackEntry);
|
|
||||||
break;
|
break;
|
||||||
case EventType_Event:
|
case EventType_Event:
|
||||||
if (!trackEntry->_listenerObject)
|
if (!trackEntry->_listenerObject)
|
||||||
|
@ -315,12 +313,13 @@ void EventQueue::drain() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationState::AnimationState(AnimationStateData *data) : _data(data),
|
AnimationState::AnimationState(AnimationStateData *data) : _data(data),
|
||||||
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
|
_queue(EventQueue::newEventQueue(*this)),
|
||||||
_animationsChanged(false),
|
_animationsChanged(false),
|
||||||
_listener(dummyOnAnimationEventFunc),
|
_listener(dummyOnAnimationEventFunc),
|
||||||
_listenerObject(NULL),
|
_listenerObject(NULL),
|
||||||
_unkeyedState(0),
|
_unkeyedState(0),
|
||||||
_timeScale(1) {
|
_timeScale(1),
|
||||||
|
_manualTrackEntryDisposal(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationState::~AnimationState() {
|
AnimationState::~AnimationState() {
|
||||||
|
@ -666,6 +665,19 @@ void AnimationState::enableQueue() {
|
||||||
_queue->_drainDisabled = false;
|
_queue->_drainDisabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnimationState::setManualTrackEntryDisposal(bool inValue) {
|
||||||
|
_manualTrackEntryDisposal = inValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AnimationState::getManualTrackEntryDisposal() {
|
||||||
|
return _manualTrackEntryDisposal;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AnimationState::disposeTrackEntry(TrackEntry *entry) {
|
||||||
|
entry->reset();
|
||||||
|
_trackEntryPool.free(entry);
|
||||||
|
}
|
||||||
|
|
||||||
Animation *AnimationState::getEmptyAnimation() {
|
Animation *AnimationState::getEmptyAnimation() {
|
||||||
static Vector<Timeline *> timelines;
|
static Vector<Timeline *> timelines;
|
||||||
static Animation ret(String("<empty>"), timelines, 0);
|
static Animation ret(String("<empty>"), timelines, 0);
|
||||||
|
|
|
@ -69,7 +69,7 @@ Atlas::Atlas(const char *data, int length, const char *dir, TextureLoader *textu
|
||||||
Atlas::~Atlas() {
|
Atlas::~Atlas() {
|
||||||
if (_textureLoader) {
|
if (_textureLoader) {
|
||||||
for (size_t i = 0, n = _pages.size(); i < n; ++i) {
|
for (size_t i = 0, n = _pages.size(); i < n; ++i) {
|
||||||
_textureLoader->unload(_pages[i]->getRendererObject());
|
_textureLoader->unload(_pages[i]->texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ContainerUtil::cleanUpVectorOfPointers(_pages);
|
ContainerUtil::cleanUpVectorOfPointers(_pages);
|
||||||
|
@ -108,21 +108,21 @@ struct SimpleString {
|
||||||
while (isspace((unsigned char) *start) && start < end)
|
while (isspace((unsigned char) *start) && start < end)
|
||||||
start++;
|
start++;
|
||||||
if (start == end) {
|
if (start == end) {
|
||||||
length = end - start;
|
length = (int) (end - start);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
end--;
|
end--;
|
||||||
while (((unsigned char) *end == '\r') && end >= start)
|
while (((unsigned char) *end == '\r') && end >= start)
|
||||||
end--;
|
end--;
|
||||||
end++;
|
end++;
|
||||||
length = end - start;
|
length = (int) (end - start);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int indexOf(char needle) {
|
int indexOf(char needle) {
|
||||||
char *c = start;
|
char *c = start;
|
||||||
while (c < end) {
|
while (c < end) {
|
||||||
if (*c == needle) return c - start;
|
if (*c == needle) return (int) (c - start);
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -131,7 +131,7 @@ struct SimpleString {
|
||||||
int indexOf(char needle, int at) {
|
int indexOf(char needle, int at) {
|
||||||
char *c = start + at;
|
char *c = start + at;
|
||||||
while (c < end) {
|
while (c < end) {
|
||||||
if (*c == needle) return c - start;
|
if (*c == needle) return (int) (c - start);
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -150,7 +150,7 @@ struct SimpleString {
|
||||||
SimpleString result;
|
SimpleString result;
|
||||||
result.start = start + s;
|
result.start = start + s;
|
||||||
result.end = end;
|
result.end = end;
|
||||||
result.length = result.end - result.start;
|
result.length = (int) (result.end - result.start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,10 +286,12 @@ void Atlas::load(const char *begin, int length, const char *dir, bool createText
|
||||||
} else {
|
} else {
|
||||||
page->texturePath = String(path, true);
|
page->texturePath = String(path, true);
|
||||||
}
|
}
|
||||||
|
page->index = (int) _pages.size();
|
||||||
_pages.add(page);
|
_pages.add(page);
|
||||||
} else {
|
} else {
|
||||||
AtlasRegion *region = new (__FILE__, __LINE__) AtlasRegion();
|
AtlasRegion *region = new (__FILE__, __LINE__) AtlasRegion();
|
||||||
region->page = page;
|
region->page = page;
|
||||||
|
region->rendererObject = page->texture;
|
||||||
region->name = String(line->copy(), true);
|
region->name = String(line->copy(), true);
|
||||||
while (true) {
|
while (true) {
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
|
|
|
@ -63,7 +63,6 @@ namespace spine {
|
||||||
} else {
|
} else {
|
||||||
AtlasRegion *region = findRegion(path);
|
AtlasRegion *region = findRegion(path);
|
||||||
if (!region) return NULL;
|
if (!region) return NULL;
|
||||||
attachment->setRendererObject(region);
|
|
||||||
attachment->setRegion(region);
|
attachment->setRegion(region);
|
||||||
}
|
}
|
||||||
return attachment;
|
return attachment;
|
||||||
|
@ -78,7 +77,6 @@ namespace spine {
|
||||||
} else {
|
} else {
|
||||||
AtlasRegion *region = findRegion(path);
|
AtlasRegion *region = findRegion(path);
|
||||||
if (!region) return NULL;
|
if (!region) return NULL;
|
||||||
attachment->setRendererObject(region);
|
|
||||||
attachment->setRegion(region);
|
attachment->setRegion(region);
|
||||||
}
|
}
|
||||||
return attachment;
|
return attachment;
|
||||||
|
|
|
@ -192,7 +192,6 @@ void Bone::updateWorldTransform(float x, float y, float rotation, float scaleX,
|
||||||
_b = za * lb + zb * ld;
|
_b = za * lb + zb * ld;
|
||||||
_c = zc * la + zd * lc;
|
_c = zc * la + zd * lc;
|
||||||
_d = zc * lb + zd * ld;
|
_d = zc * lb + zd * ld;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_a *= _skeleton.getScaleX();
|
_a *= _skeleton.getScaleX();
|
||||||
|
@ -496,33 +495,75 @@ void Bone::updateAppliedTransform() {
|
||||||
_ascaleY = MathUtil::sqrt(_b * _b + _d * _d);
|
_ascaleY = MathUtil::sqrt(_b * _b + _d * _d);
|
||||||
_ashearX = 0;
|
_ashearX = 0;
|
||||||
_ashearY = MathUtil::atan2(_a * _b + _c * _d, _a * _d - _b * _c) * MathUtil::Rad_Deg;
|
_ashearY = MathUtil::atan2(_a * _b + _c * _d, _a * _d - _b * _c) * MathUtil::Rad_Deg;
|
||||||
|
}
|
||||||
|
float pa = parent->_a, pb = parent->_b, pc = parent->_c, pd = parent->_d;
|
||||||
|
float pid = 1 / (pa * pd - pb * pc);
|
||||||
|
float ia = pd * pid, ib = pb * pid, ic = pc * pid, id = pa * pid;
|
||||||
|
float dx = _worldX - parent->_worldX, dy = _worldY - parent->_worldY;
|
||||||
|
_ax = (dx * ia - dy * ib);
|
||||||
|
_ay = (dy * id - dx * ic);
|
||||||
|
|
||||||
|
float ra, rb, rc, rd;
|
||||||
|
if (_data.getTransformMode() == TransformMode_OnlyTranslation) {
|
||||||
|
ra = _a;
|
||||||
|
rb = _b;
|
||||||
|
rc = _c;
|
||||||
|
rd = _d;
|
||||||
} else {
|
} else {
|
||||||
float pa = parent->_a, pb = parent->_b, pc = parent->_c, pd = parent->_d;
|
switch (_data.getTransformMode()) {
|
||||||
float pid = 1 / (pa * pd - pb * pc);
|
case TransformMode_NoRotationOrReflection: {
|
||||||
float dx = _worldX - parent->_worldX, dy = _worldY - parent->_worldY;
|
float s = MathUtil::abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
||||||
float ia = pid * pd;
|
float sa = pa / _skeleton.getScaleX();
|
||||||
float id = pid * pa;
|
float sc = pc / _skeleton.getScaleY();
|
||||||
float ib = pid * pb;
|
pb = -sc * s * _skeleton.getScaleX();
|
||||||
float ic = pid * pc;
|
pd = sa * s * _skeleton.getScaleY();
|
||||||
float ra = ia * _a - ib * _c;
|
pid = 1 / (pa * pd - pb * pc);
|
||||||
float rb = ia * _b - ib * _d;
|
ia = pd * pid;
|
||||||
float rc = id * _c - ic * _a;
|
ib = pb * pid;
|
||||||
float rd = id * _d - ic * _b;
|
break;
|
||||||
_ax = (dx * pd * pid - dy * pb * pid);
|
}
|
||||||
_ay = (dy * pa * pid - dx * pc * pid);
|
case TransformMode_NoScale:
|
||||||
_ashearX = 0;
|
case TransformMode_NoScaleOrReflection: {
|
||||||
_ascaleX = MathUtil::sqrt(ra * ra + rc * rc);
|
float cos = MathUtil::cosDeg(_rotation), sin = MathUtil::sinDeg(_rotation);
|
||||||
if (_ascaleX > 0.0001f) {
|
pa = (pa * cos + pb * sin) / _skeleton.getScaleX();
|
||||||
float det = ra * rd - rb * rc;
|
pc = (pc * cos + pd * sin) / _skeleton.getScaleY();
|
||||||
_ascaleY = det / _ascaleX;
|
float s = MathUtil::sqrt(pa * pa + pc * pc);
|
||||||
_ashearY = MathUtil::atan2(ra * rb + rc * rd, det) * MathUtil::Rad_Deg;
|
if (s > 0.00001f) s = 1 / s;
|
||||||
_arotation = MathUtil::atan2(rc, ra) * MathUtil::Rad_Deg;
|
pa *= s;
|
||||||
} else {
|
pc *= s;
|
||||||
_ascaleX = 0;
|
s = MathUtil::sqrt(pa * pa + pc * pc);
|
||||||
_ascaleY = MathUtil::sqrt(rb * rb + rd * rd);
|
if (_data.getTransformMode() == TransformMode_NoScale && pid < 0 != (_skeleton.getScaleX() < 0 != _skeleton.getScaleY() < 0)) s = -s;
|
||||||
_ashearY = 0;
|
float r = MathUtil::Pi / 2 + MathUtil::atan2(pc, pa);
|
||||||
_arotation = 90 - MathUtil::atan2(rd, rb) * MathUtil::Rad_Deg;
|
pb = MathUtil::cos(r) * s;
|
||||||
|
pd = MathUtil::sin(r) * s;
|
||||||
|
pid = 1 / (pa * pd - pb * pc);
|
||||||
|
ia = pd * pid;
|
||||||
|
ib = pb * pid;
|
||||||
|
ic = pc * pid;
|
||||||
|
id = pa * pid;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
ra = ia * _a - ib * _c;
|
||||||
|
rb = ia * _b - ib * _d;
|
||||||
|
rc = id * _c - ic * _a;
|
||||||
|
rd = id * _d - ic * _b;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ashearX = 0;
|
||||||
|
_ascaleX = MathUtil::sqrt(ra * ra + rc * rc);
|
||||||
|
if (_ascaleX > 0.0001f) {
|
||||||
|
float det = ra * rd - rb * rc;
|
||||||
|
_ascaleY = det / _ascaleX;
|
||||||
|
_ashearY = -MathUtil::atan2(ra * rb + rc * rd, det) * MathUtil::Rad_Deg;
|
||||||
|
_arotation = MathUtil::atan2(rc, ra) * MathUtil::Rad_Deg;
|
||||||
|
} else {
|
||||||
|
_ascaleX = 0;
|
||||||
|
_ascaleY = MathUtil::sqrt(rb * rb + rd * rd);
|
||||||
|
_ashearY = 0;
|
||||||
|
_arotation = 90 - MathUtil::atan2(rd, rb) * MathUtil::Rad_Deg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
|
RTTI_IMPL_NOPARENT(ConstraintData)
|
||||||
|
|
||||||
ConstraintData::ConstraintData(const String &name) : _name(name), _order(0), _skinRequired(false) {
|
ConstraintData::ConstraintData(const String &name) : _name(name), _order(0), _skinRequired(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ void DefaultSpineExtension::_free(void *mem, const char *file, int line) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *DefaultSpineExtension::_readFile(const String &path, int *length) {
|
char *DefaultSpineExtension::_readFile(const String &path, int *length) {
|
||||||
|
#ifndef __EMSCRIPTEN__
|
||||||
char *data;
|
char *data;
|
||||||
FILE *file = fopen(path.buffer(), "rb");
|
FILE *file = fopen(path.buffer(), "rb");
|
||||||
if (!file) return 0;
|
if (!file) return 0;
|
||||||
|
@ -117,6 +118,9 @@ char *DefaultSpineExtension::_readFile(const String &path, int *length) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultSpineExtension::DefaultSpineExtension() : SpineExtension() {
|
DefaultSpineExtension::DefaultSpineExtension() : SpineExtension() {
|
||||||
|
|
|
@ -51,7 +51,7 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress
|
||||||
ty = targetY - bone._worldY;
|
ty = targetY - bone._worldY;
|
||||||
break;
|
break;
|
||||||
case TransformMode_NoRotationOrReflection: {
|
case TransformMode_NoRotationOrReflection: {
|
||||||
float s = MathUtil::abs(pa * pd - pb * pc) / (pa * pa + pc * pc);
|
float s = MathUtil::abs(pa * pd - pb * pc) / MathUtil::max(0.0001f, pa * pa + pc * pc);
|
||||||
float sa = pa / bone._skeleton.getScaleX();
|
float sa = pa / bone._skeleton.getScaleX();
|
||||||
float sc = pc / bone._skeleton.getScaleY();
|
float sc = pc / bone._skeleton.getScaleY();
|
||||||
pb = -sc * s * bone._skeleton.getScaleX();
|
pb = -sc * s * bone._skeleton.getScaleX();
|
||||||
|
@ -61,8 +61,13 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress
|
||||||
default:
|
default:
|
||||||
float x = targetX - p->_worldX, y = targetY - p->_worldY;
|
float x = targetX - p->_worldX, y = targetY - p->_worldY;
|
||||||
float d = pa * pd - pb * pc;
|
float d = pa * pd - pb * pc;
|
||||||
tx = (x * pd - y * pb) / d - bone._ax;
|
if (MathUtil::abs(d) <= 0.0001f) {
|
||||||
ty = (y * pa - x * pc) / d - bone._ay;
|
tx = 0;
|
||||||
|
ty = 0;
|
||||||
|
} else {
|
||||||
|
tx = (x * pd - y * pb) / d - bone._ax;
|
||||||
|
ty = (y * pa - x * pc) / d - bone._ay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rotationIK += MathUtil::atan2(ty, tx) * MathUtil::Rad_Deg;
|
rotationIK += MathUtil::atan2(ty, tx) * MathUtil::Rad_Deg;
|
||||||
if (bone._ascaleX < 0) rotationIK += 180;
|
if (bone._ascaleX < 0) rotationIK += 180;
|
||||||
|
@ -140,7 +145,8 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
||||||
b = pp->_b;
|
b = pp->_b;
|
||||||
c = pp->_c;
|
c = pp->_c;
|
||||||
d = pp->_d;
|
d = pp->_d;
|
||||||
id = 1 / (a * d - b * c);
|
id = a * d - b * c;
|
||||||
|
id = MathUtil::abs(id) <= 0.0001f ? 0 : 1 / id;
|
||||||
x = cwx - pp->_worldX;
|
x = cwx - pp->_worldX;
|
||||||
y = cwy - pp->_worldY;
|
y = cwy - pp->_worldY;
|
||||||
dx = (x * d - y * b) * id - px;
|
dx = (x * d - y * b) * id - px;
|
||||||
|
@ -154,11 +160,13 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
||||||
}
|
}
|
||||||
x = targetX - pp->_worldX;
|
x = targetX - pp->_worldX;
|
||||||
y = targetY - pp->_worldY;
|
y = targetY - pp->_worldY;
|
||||||
tx = (x * d - y * b) * id - px, ty = (y * a - x * c) * id - py;
|
tx = (x * d - y * b) * id - px;
|
||||||
|
ty = (y * a - x * c) * id - py;
|
||||||
dd = tx * tx + ty * ty;
|
dd = tx * tx + ty * ty;
|
||||||
if (softness != 0) {
|
if (softness != 0) {
|
||||||
softness *= psx * (csx + 1) * 0.5f;
|
softness *= psx * (csx + 1) * 0.5f;
|
||||||
td = MathUtil::sqrt(dd), sd = td - l1 - l2 * psx + softness;
|
td = MathUtil::sqrt(dd);
|
||||||
|
sd = td - l1 - l2 * psx + softness;
|
||||||
if (sd > 0) {
|
if (sd > 0) {
|
||||||
p = MathUtil::min(1.0f, sd / (softness * 2)) - 1;
|
p = MathUtil::min(1.0f, sd / (softness * 2)) - 1;
|
||||||
p = (sd - softness * (1 - p * p)) / td;
|
p = (sd - softness * (1 - p * p)) / td;
|
||||||
|
@ -188,7 +196,8 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
||||||
b = l2 * MathUtil::sin(a2);
|
b = l2 * MathUtil::sin(a2);
|
||||||
a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b);
|
a1 = MathUtil::atan2(ty * a - tx * b, tx * a + ty * b);
|
||||||
} else {
|
} else {
|
||||||
a = psx * l2, b = psy * l2;
|
a = psx * l2;
|
||||||
|
b = psy * l2;
|
||||||
float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx);
|
float aa = a * a, bb = b * b, ll = l1 * l1, ta = MathUtil::atan2(ty, tx);
|
||||||
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
|
float c0 = bb * ll + aa * dd - aa * bb, c1 = -2 * bb * l1, c2 = bb - aa;
|
||||||
d = c1 * c1 - 4 * c2 * c0;
|
d = c1 * c1 - 4 * c2 * c0;
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
|
RTTI_IMPL(IkConstraintData, ConstraintData)
|
||||||
|
|
||||||
IkConstraintData::IkConstraintData(const String &name) : ConstraintData(name),
|
IkConstraintData::IkConstraintData(const String &name) : ConstraintData(name),
|
||||||
_target(NULL),
|
_target(NULL),
|
||||||
_bendDirection(1),
|
_bendDirection(1),
|
||||||
|
|
|
@ -28,13 +28,12 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include <spine/MeshAttachment.h>
|
#include <spine/MeshAttachment.h>
|
||||||
#include <spine/HasRendererObject.h>
|
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
RTTI_IMPL(MeshAttachment, VertexAttachment)
|
RTTI_IMPL(MeshAttachment, VertexAttachment)
|
||||||
|
|
||||||
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), HasRendererObject(),
|
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name),
|
||||||
_parentMesh(NULL),
|
_parentMesh(NULL),
|
||||||
_path(),
|
_path(),
|
||||||
_color(1, 1, 1, 1),
|
_color(1, 1, 1, 1),
|
||||||
|
@ -53,10 +52,13 @@ void MeshAttachment::updateRegion() {
|
||||||
_uvs.setSize(_regionUVs.size(), 0);
|
_uvs.setSize(_regionUVs.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_region == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0, n = (int) _regionUVs.size();
|
int i = 0, n = (int) _regionUVs.size();
|
||||||
float u = _region->u, v = _region->v;
|
float u = _region->u, v = _region->v;
|
||||||
float width = 0, height = 0;
|
float width = 0, height = 0;
|
||||||
|
|
||||||
switch (_region->degrees) {
|
switch (_region->degrees) {
|
||||||
case 90: {
|
case 90: {
|
||||||
float textureWidth = _region->height / (_region->u2 - _region->u);
|
float textureWidth = _region->height / (_region->u2 - _region->u);
|
||||||
|
@ -203,7 +205,6 @@ Attachment *MeshAttachment::copy() {
|
||||||
if (_parentMesh) return newLinkedMesh();
|
if (_parentMesh) return newLinkedMesh();
|
||||||
|
|
||||||
MeshAttachment *copy = new (__FILE__, __LINE__) MeshAttachment(getName());
|
MeshAttachment *copy = new (__FILE__, __LINE__) MeshAttachment(getName());
|
||||||
copy->setRendererObject(getRendererObject());
|
|
||||||
copy->setRegion(_region);
|
copy->setRegion(_region);
|
||||||
copy->setSequence(_sequence != NULL ? _sequence->copy() : NULL);
|
copy->setSequence(_sequence != NULL ? _sequence->copy() : NULL);
|
||||||
copy->_path = _path;
|
copy->_path = _path;
|
||||||
|
@ -224,7 +225,6 @@ Attachment *MeshAttachment::copy() {
|
||||||
|
|
||||||
MeshAttachment *MeshAttachment::newLinkedMesh() {
|
MeshAttachment *MeshAttachment::newLinkedMesh() {
|
||||||
MeshAttachment *copy = new (__FILE__, __LINE__) MeshAttachment(getName());
|
MeshAttachment *copy = new (__FILE__, __LINE__) MeshAttachment(getName());
|
||||||
copy->setRendererObject(getRendererObject());
|
|
||||||
copy->setRegion(_region);
|
copy->setRegion(_region);
|
||||||
copy->_path = _path;
|
copy->_path = _path;
|
||||||
copy->_color.set(_color);
|
copy->_color.set(_color);
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
|
RTTI_IMPL(PathConstraintData, ConstraintData)
|
||||||
|
|
||||||
PathConstraintData::PathConstraintData(const String &name) : ConstraintData(name),
|
PathConstraintData::PathConstraintData(const String &name) : ConstraintData(name),
|
||||||
_target(NULL),
|
_target(NULL),
|
||||||
_positionMode(PositionMode_Fixed),
|
_positionMode(PositionMode_Fixed),
|
||||||
|
|
|
@ -47,7 +47,7 @@ const int RegionAttachment::URY = 5;
|
||||||
const int RegionAttachment::BRX = 6;
|
const int RegionAttachment::BRX = 6;
|
||||||
const int RegionAttachment::BRY = 7;
|
const int RegionAttachment::BRY = 7;
|
||||||
|
|
||||||
RegionAttachment::RegionAttachment(const String &name) : Attachment(name), HasRendererObject(),
|
RegionAttachment::RegionAttachment(const String &name) : Attachment(name),
|
||||||
_x(0),
|
_x(0),
|
||||||
_y(0),
|
_y(0),
|
||||||
_rotation(0),
|
_rotation(0),
|
||||||
|
@ -259,7 +259,6 @@ spine::Color &RegionAttachment::getColor() {
|
||||||
Attachment *RegionAttachment::copy() {
|
Attachment *RegionAttachment::copy() {
|
||||||
RegionAttachment *copy = new (__FILE__, __LINE__) RegionAttachment(getName());
|
RegionAttachment *copy = new (__FILE__, __LINE__) RegionAttachment(getName());
|
||||||
copy->_region = _region;
|
copy->_region = _region;
|
||||||
copy->setRendererObject(getRendererObject());
|
|
||||||
copy->_path = _path;
|
copy->_path = _path;
|
||||||
copy->_x = _x;
|
copy->_x = _x;
|
||||||
copy->_y = _y;
|
copy->_y = _y;
|
||||||
|
|
|
@ -66,7 +66,6 @@ void Sequence::apply(Slot *slot, Attachment *attachment) {
|
||||||
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
|
||||||
RegionAttachment *regionAttachment = static_cast<RegionAttachment *>(attachment);
|
RegionAttachment *regionAttachment = static_cast<RegionAttachment *>(attachment);
|
||||||
if (regionAttachment->getRegion() != region) {
|
if (regionAttachment->getRegion() != region) {
|
||||||
regionAttachment->setRendererObject(region);
|
|
||||||
regionAttachment->setRegion(region);
|
regionAttachment->setRegion(region);
|
||||||
regionAttachment->updateRegion();
|
regionAttachment->updateRegion();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +74,6 @@ void Sequence::apply(Slot *slot, Attachment *attachment) {
|
||||||
if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
|
||||||
MeshAttachment *meshAttachment = static_cast<MeshAttachment *>(attachment);
|
MeshAttachment *meshAttachment = static_cast<MeshAttachment *>(attachment);
|
||||||
if (meshAttachment->getRegion() != region) {
|
if (meshAttachment->getRegion() != region) {
|
||||||
meshAttachment->setRendererObject(region);
|
|
||||||
meshAttachment->setRegion(region);
|
meshAttachment->setRegion(region);
|
||||||
meshAttachment->updateRegion();
|
meshAttachment->updateRegion();
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,8 +425,8 @@ PathConstraint *Skeleton::findPathConstraint(const String &constraintName) {
|
||||||
void Skeleton::getBounds(float &outX, float &outY, float &outWidth, float &outHeight, Vector<float> &outVertexBuffer) {
|
void Skeleton::getBounds(float &outX, float &outY, float &outWidth, float &outHeight, Vector<float> &outVertexBuffer) {
|
||||||
float minX = FLT_MAX;
|
float minX = FLT_MAX;
|
||||||
float minY = FLT_MAX;
|
float minY = FLT_MAX;
|
||||||
float maxX = FLT_MIN;
|
float maxX = -FLT_MAX;
|
||||||
float maxY = FLT_MIN;
|
float maxY = -FLT_MAX;
|
||||||
|
|
||||||
for (size_t i = 0; i < _drawOrder.size(); ++i) {
|
for (size_t i = 0; i < _drawOrder.size(); ++i) {
|
||||||
Slot *slot = _drawOrder[i];
|
Slot *slot = _drawOrder[i];
|
||||||
|
@ -653,7 +653,7 @@ void Skeleton::sortPathConstraintAttachment(Skin *skin, size_t slotIndex, Bone &
|
||||||
|
|
||||||
void Skeleton::sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone) {
|
void Skeleton::sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone) {
|
||||||
if (attachment == NULL || !attachment->getRTTI().instanceOf(PathAttachment::rtti)) return;
|
if (attachment == NULL || !attachment->getRTTI().instanceOf(PathAttachment::rtti)) return;
|
||||||
Vector<size_t> &pathBones = static_cast<PathAttachment *>(attachment)->getBones();
|
Vector<int> &pathBones = static_cast<PathAttachment *>(attachment)->getBones();
|
||||||
if (pathBones.size() == 0)
|
if (pathBones.size() == 0)
|
||||||
sortBone(&slotBone);
|
sortBone(&slotBone);
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -109,9 +109,9 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||||
int lowHash = readInt(input);
|
int lowHash = readInt(input);
|
||||||
int hightHash = readInt(input);
|
int hightHash = readInt(input);
|
||||||
String hashString;
|
String hashString;
|
||||||
sprintf(buffer, "%x", hightHash);
|
snprintf(buffer, 16, "%x", hightHash);
|
||||||
hashString.append(buffer);
|
hashString.append(buffer);
|
||||||
sprintf(buffer, "%x", lowHash);
|
snprintf(buffer, 16, "%x", lowHash);
|
||||||
hashString.append(buffer);
|
hashString.append(buffer);
|
||||||
skeletonData->_hash = hashString;
|
skeletonData->_hash = hashString;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ SkeletonData *SkeletonBinary::readSkeletonData(const unsigned char *binary, cons
|
||||||
|
|
||||||
if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) {
|
if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) {
|
||||||
char errorMsg[255];
|
char errorMsg[255];
|
||||||
sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING);
|
snprintf(errorMsg, 255, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING);
|
||||||
setError(errorMsg, "");
|
setError(errorMsg, "");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +564,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||||
Vector<float> uvs;
|
Vector<float> uvs;
|
||||||
Vector<unsigned short> triangles;
|
Vector<unsigned short> triangles;
|
||||||
Vector<float> vertices;
|
Vector<float> vertices;
|
||||||
Vector<size_t> bones;
|
Vector<int> bones;
|
||||||
int hullLength;
|
int hullLength;
|
||||||
Sequence *sequence;
|
Sequence *sequence;
|
||||||
float width = 0;
|
float width = 0;
|
||||||
|
@ -702,7 +702,7 @@ Attachment *SkeletonBinary::readAttachment(DataInput *input, Skin *skin, int slo
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vector<size_t> &bones, int vertexCount) {
|
void SkeletonBinary::readVertices(DataInput *input, Vector<float> &vertices, Vector<int> &bones, int vertexCount) {
|
||||||
float scale = _scale;
|
float scale = _scale;
|
||||||
int verticesLength = vertexCount << 1;
|
int verticesLength = vertexCount << 1;
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||||
timeline->setFrame(frame, time, a);
|
timeline->setFrame(frame, time, a);
|
||||||
if (frame == frameLast) break;
|
if (frame == frameLast) break;
|
||||||
float time2 = readFloat(input);
|
float time2 = readFloat(input);
|
||||||
float a2 = readByte(input) / 255;
|
float a2 = readByte(input) / 255.0;
|
||||||
switch (readSByte(input)) {
|
switch (readSByte(input)) {
|
||||||
case CURVE_STEPPED:
|
case CURVE_STEPPED:
|
||||||
timeline->setStepped(frame);
|
timeline->setStepped(frame);
|
||||||
|
@ -1249,13 +1249,13 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||||
setError("Attachment not found: ", attachmentName);
|
setError("Attachment not found: ", attachmentName);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
VertexAttachment *attachment = static_cast<VertexAttachment *>(baseAttachment);
|
|
||||||
unsigned int timelineType = readByte(input);
|
unsigned int timelineType = readByte(input);
|
||||||
int frameCount = readVarint(input, true);
|
int frameCount = readVarint(input, true);
|
||||||
int frameLast = frameCount - 1;
|
int frameLast = frameCount - 1;
|
||||||
|
|
||||||
switch (timelineType) {
|
switch (timelineType) {
|
||||||
case ATTACHMENT_DEFORM: {
|
case ATTACHMENT_DEFORM: {
|
||||||
|
VertexAttachment *attachment = static_cast<VertexAttachment *>(baseAttachment);
|
||||||
bool weighted = attachment->_bones.size() > 0;
|
bool weighted = attachment->_bones.size() > 0;
|
||||||
Vector<float> &vertices = attachment->_vertices;
|
Vector<float> &vertices = attachment->_vertices;
|
||||||
int deformLength = weighted ? (int) vertices.size() / 3 * 2 : (int) vertices.size();
|
int deformLength = weighted ? (int) vertices.size() / 3 * 2 : (int) vertices.size();
|
||||||
|
@ -1311,7 +1311,7 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ATTACHMENT_SEQUENCE: {
|
case ATTACHMENT_SEQUENCE: {
|
||||||
SequenceTimeline *timeline = new (__FILE__, __LINE__) SequenceTimeline(frameCount, slotIndex, attachment);
|
SequenceTimeline *timeline = new (__FILE__, __LINE__) SequenceTimeline(frameCount, slotIndex, baseAttachment);
|
||||||
for (int frame = 0; frame < frameCount; frame++) {
|
for (int frame = 0; frame < frameCount; frame++) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
int modeAndIndex = readInt(input);
|
int modeAndIndex = readInt(input);
|
||||||
|
|
|
@ -185,6 +185,19 @@ spine::Polygon *SkeletonBounds::getPolygon(BoundingBoxAttachment *attachment) {
|
||||||
return index == -1 ? NULL : _polygons[index];
|
return index == -1 ? NULL : _polygons[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoundingBoxAttachment *SkeletonBounds::getBoundingBox(Polygon *polygon) {
|
||||||
|
int index = _polygons.indexOf(polygon);
|
||||||
|
return index == -1 ? NULL : _boundingBoxes[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<Polygon *> &SkeletonBounds::getPolygons() {
|
||||||
|
return _polygons;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<BoundingBoxAttachment *> &SkeletonBounds::getBoundingBoxes() {
|
||||||
|
return _boundingBoxes;
|
||||||
|
}
|
||||||
|
|
||||||
float SkeletonBounds::getWidth() {
|
float SkeletonBounds::getWidth() {
|
||||||
return _maxX - _minX;
|
return _maxX - _minX;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
||||||
skeletonData->_version = Json::getString(skeleton, "spine", 0);
|
skeletonData->_version = Json::getString(skeleton, "spine", 0);
|
||||||
if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) {
|
if (!skeletonData->_version.startsWith(SPINE_VERSION_STRING)) {
|
||||||
char errorMsg[255];
|
char errorMsg[255];
|
||||||
sprintf(errorMsg, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING);
|
snprintf(errorMsg, 255, "Skeleton version %s does not match runtime version %s", skeletonData->_version.buffer(), SPINE_VERSION_STRING);
|
||||||
setError(NULL, errorMsg, "");
|
setError(NULL, errorMsg, "");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ TransformConstraint::TransformConstraint(TransformConstraintData &data, Skeleton
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransformConstraint::update() {
|
void TransformConstraint::update() {
|
||||||
if (_mixRotate == 0 && _mixX == 0 && _mixY == 0 && _mixScaleX == 0 && _mixScaleX == 0 && _mixShearY == 0) return;
|
if (_mixRotate == 0 && _mixX == 0 && _mixY == 0 && _mixScaleX == 0 && _mixScaleY == 0 && _mixShearY == 0) return;
|
||||||
|
|
||||||
if (_data.isLocal()) {
|
if (_data.isLocal()) {
|
||||||
if (_data.isRelative())
|
if (_data.isRelative())
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
|
|
||||||
using namespace spine;
|
using namespace spine;
|
||||||
|
|
||||||
|
RTTI_IMPL(TransformConstraintData, ConstraintData)
|
||||||
|
|
||||||
TransformConstraintData::TransformConstraintData(const String &name) : ConstraintData(name),
|
TransformConstraintData::TransformConstraintData(const String &name) : ConstraintData(name),
|
||||||
_target(NULL),
|
_target(NULL),
|
||||||
_mixRotate(0),
|
_mixRotate(0),
|
||||||
|
@ -116,3 +118,63 @@ bool TransformConstraintData::isRelative() {
|
||||||
bool TransformConstraintData::isLocal() {
|
bool TransformConstraintData::isLocal() {
|
||||||
return _local;
|
return _local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setTarget(BoneData *target) {
|
||||||
|
_target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setMixRotate(float mixRotate) {
|
||||||
|
_mixRotate = mixRotate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setMixX(float mixX) {
|
||||||
|
_mixX = mixX;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setMixY(float mixY) {
|
||||||
|
_mixY = mixY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setMixScaleX(float mixScaleX) {
|
||||||
|
_mixScaleX = mixScaleX;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setMixScaleY(float mixScaleY) {
|
||||||
|
_mixScaleY = mixScaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setMixShearY(float mixShearY) {
|
||||||
|
_mixShearY = mixShearY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setOffsetRotation(float offsetRotation) {
|
||||||
|
_offsetRotation = offsetRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setOffsetX(float offsetX) {
|
||||||
|
_offsetX = offsetX;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setOffsetY(float offsetY) {
|
||||||
|
_offsetY = offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setOffsetScaleX(float offsetScaleX) {
|
||||||
|
_offsetScaleX = offsetScaleX;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setOffsetScaleY(float offsetScaleY) {
|
||||||
|
_offsetScaleY = offsetScaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setOffsetShearY(float offsetShearY) {
|
||||||
|
_offsetShearY = offsetShearY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setRelative(bool isRelative) {
|
||||||
|
_relative = isRelative;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransformConstraintData::setLocal(bool isLocal) {
|
||||||
|
_local = isLocal;
|
||||||
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ void VertexAttachment::computeWorldVertices(Slot &slot, size_t start, size_t cou
|
||||||
Skeleton &skeleton = slot._bone._skeleton;
|
Skeleton &skeleton = slot._bone._skeleton;
|
||||||
Vector<float> *deformArray = &slot.getDeform();
|
Vector<float> *deformArray = &slot.getDeform();
|
||||||
Vector<float> *vertices = &_vertices;
|
Vector<float> *vertices = &_vertices;
|
||||||
Vector<size_t> &bones = _bones;
|
Vector<int> &bones = _bones;
|
||||||
if (bones.size() == 0) {
|
if (bones.size() == 0) {
|
||||||
if (deformArray->size() > 0) vertices = deformArray;
|
if (deformArray->size() > 0) vertices = deformArray;
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ int VertexAttachment::getId() {
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<size_t> &VertexAttachment::getBones() {
|
Vector<int> &VertexAttachment::getBones() {
|
||||||
return _bones;
|
return _bones;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ void Cocos2dTextureLoader::load(AtlasPage &page, const spine::String &path) {
|
||||||
#endif
|
#endif
|
||||||
texture->setTexParameters(textureParams);
|
texture->setTexParameters(textureParams);
|
||||||
|
|
||||||
page.setRendererObject(texture);
|
page.texture = texture;
|
||||||
page.width = texture->getPixelsWide();
|
page.width = texture->getPixelsWide();
|
||||||
page.height = texture->getPixelsHigh();
|
page.height = texture->getPixelsHigh();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue