mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
Clean up Clang warnings, refactor more size_t related code.
This commit is contained in:
parent
8259b44bdd
commit
2bd8dc7326
@ -3,8 +3,8 @@ project(spine)
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
message("MSCV detected")
|
message("MSCV detected")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
else()
|
else()
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c89")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c89")
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti")
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
message("MSCV detected")
|
message("MSCV detected")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
|
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
else()
|
else()
|
||||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c89")
|
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c89")
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti")
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti")
|
||||||
|
|||||||
@ -48,20 +48,20 @@ namespace Spine {
|
|||||||
|
|
||||||
virtual int getPropertyId() = 0;
|
virtual int getPropertyId() = 0;
|
||||||
|
|
||||||
int getFrameCount();
|
size_t getFrameCount();
|
||||||
|
|
||||||
void setLinear(int frameIndex);
|
void setLinear(size_t frameIndex);
|
||||||
|
|
||||||
void setStepped(int frameIndex);
|
void setStepped(size_t frameIndex);
|
||||||
|
|
||||||
/// Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
|
/// Sets the control handle positions for an interpolation bezier curve used to transition from this keyframe to the next.
|
||||||
/// cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
|
/// cx1 and cx2 are from 0 to 1, representing the percent of time between the two keyframes. cy1 and cy2 are the percent of
|
||||||
/// the difference between the keyframe's values.
|
/// the difference between the keyframe's values.
|
||||||
void setCurve(int frameIndex, float cx1, float cy1, float cx2, float cy2);
|
void setCurve(size_t frameIndex, float cx1, float cy1, float cx2, float cy2);
|
||||||
|
|
||||||
float getCurvePercent(int frameIndex, float percent);
|
float getCurvePercent(size_t frameIndex, float percent);
|
||||||
|
|
||||||
float getCurveType(int frameIndex);
|
float getCurveType(size_t frameIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const float LINEAR;
|
static const float LINEAR;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reportLeaks() {
|
void reportLeaks() {
|
||||||
for (auto it = _allocated.begin(); it != _allocated.end(); it++) {
|
for (std::map<void*, Allocation>::iterator it = _allocated.begin(); it != _allocated.end(); it++) {
|
||||||
printf("\"%s:%i (%zu bytes at %p)\n", it->second.fileName, it->second.line, it->second.size, it->second.address);
|
printf("\"%s:%i (%zu bytes at %p)\n", it->second.fileName, it->second.line, it->second.size, it->second.address);
|
||||||
}
|
}
|
||||||
printf("allocations: %lu, reallocations: %lu, frees: %lu\n", _allocations, _reallocations, _frees);
|
printf("allocations: %lu, reallocations: %lu, frees: %lu\n", _allocations, _reallocations, _frees);
|
||||||
|
|||||||
@ -49,11 +49,11 @@ namespace Spine {
|
|||||||
|
|
||||||
/// Sets the time and value of the specified keyframe.
|
/// Sets the time and value of the specified keyframe.
|
||||||
/// @param drawOrder May be NULL to use bind pose draw order
|
/// @param drawOrder May be NULL to use bind pose draw order
|
||||||
void setFrame(int frameIndex, float time, Vector<int>& drawOrder);
|
void setFrame(size_t frameIndex, float time, Vector<int>& drawOrder);
|
||||||
|
|
||||||
Vector<float>& getFrames();
|
Vector<float>& getFrames();
|
||||||
Vector< Vector<int> >& getDrawOrders();
|
Vector< Vector<int> >& getDrawOrders();
|
||||||
int getFrameCount();
|
size_t getFrameCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
|
|||||||
@ -50,11 +50,11 @@ namespace Spine {
|
|||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
|
|
||||||
/// Sets the time and value of the specified keyframe.
|
/// Sets the time and value of the specified keyframe.
|
||||||
void setFrame(int frameIndex, Event* event);
|
void setFrame(size_t frameIndex, Event* event);
|
||||||
|
|
||||||
Vector<float> getFrames();
|
Vector<float> getFrames();
|
||||||
Vector<Event*>& getEvents();
|
Vector<Event*>& getEvents();
|
||||||
int getFrameCount();
|
size_t getFrameCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
|
|||||||
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define SP_UNUSED(x) (void)(x)
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
class String;
|
class String;
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,9 @@
|
|||||||
#include <spine/SpineObject.h>
|
#include <spine/SpineObject.h>
|
||||||
|
|
||||||
// Required for new with line number and file name in MSVC
|
// Required for new with line number and file name in MSVC
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable:4291)
|
#pragma warning(disable:4291)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
template<typename K, typename V>
|
template<typename K, typename V>
|
||||||
|
|||||||
@ -51,8 +51,8 @@ namespace Spine {
|
|||||||
/// The IK constraint's name, which is unique within the skeleton.
|
/// The IK constraint's name, which is unique within the skeleton.
|
||||||
const String& getName();
|
const String& getName();
|
||||||
|
|
||||||
int getOrder();
|
size_t getOrder();
|
||||||
void setOrder(int inValue);
|
void setOrder(size_t inValue);
|
||||||
|
|
||||||
/// The bones that are constrained by this IK Constraint.
|
/// The bones that are constrained by this IK Constraint.
|
||||||
Vector<BoneData*>& getBones();
|
Vector<BoneData*>& getBones();
|
||||||
@ -70,7 +70,7 @@ namespace Spine {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const String _name;
|
const String _name;
|
||||||
int _order;
|
size_t _order;
|
||||||
Vector<BoneData*> _bones;
|
Vector<BoneData*> _bones;
|
||||||
BoneData* _target;
|
BoneData* _target;
|
||||||
int _bendDirection;
|
int _bendDirection;
|
||||||
|
|||||||
@ -234,7 +234,7 @@ private:
|
|||||||
|
|
||||||
void sortTransformConstraint(TransformConstraint *constraint);
|
void sortTransformConstraint(TransformConstraint *constraint);
|
||||||
|
|
||||||
void sortPathConstraintAttachment(Skin *skin, int slotIndex, Bone &slotBone);
|
void sortPathConstraintAttachment(Skin *skin, size_t slotIndex, Bone &slotBone);
|
||||||
|
|
||||||
void sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone);
|
void sortPathConstraintAttachment(Attachment *attachment, Bone &slotBone);
|
||||||
|
|
||||||
|
|||||||
@ -42,13 +42,13 @@ namespace Spine {
|
|||||||
public:
|
public:
|
||||||
SkeletonClipping();
|
SkeletonClipping();
|
||||||
|
|
||||||
int clipStart(Slot& slot, ClippingAttachment* clip);
|
size_t clipStart(Slot& slot, ClippingAttachment* clip);
|
||||||
|
|
||||||
void clipEnd(Slot& slot);
|
void clipEnd(Slot& slot);
|
||||||
|
|
||||||
void clipEnd();
|
void clipEnd();
|
||||||
|
|
||||||
void clipTriangles(Vector<float>& vertices, int verticesLength, Vector<unsigned short>& triangles, int trianglesLength, Vector<float>& uvs);
|
void clipTriangles(Vector<float>& vertices, size_t verticesLength, Vector<unsigned short>& triangles, size_t trianglesLength, Vector<float>& uvs);
|
||||||
|
|
||||||
bool isClipping();
|
bool isClipping();
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
// Required for sprintf on MSVC
|
// Required for sprintf on MSVC
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable:4996)
|
#pragma warning(disable:4996)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
class String : public SpineObject {
|
class String : public SpineObject {
|
||||||
|
|||||||
@ -49,7 +49,7 @@ namespace Spine {
|
|||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
|
|
||||||
void setFrame(int frameIndex, float time, float rotateMix, float translateMix, float scaleMix, float shearMix);
|
void setFrame(size_t frameIndex, float time, float rotateMix, float translateMix, float scaleMix, float shearMix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int PREV_TIME, PREV_ROTATE, PREV_TRANSLATE, PREV_SCALE, PREV_SHEAR;
|
static const int PREV_TIME, PREV_ROTATE, PREV_TRANSLATE, PREV_SCALE, PREV_SHEAR;
|
||||||
|
|||||||
@ -141,7 +141,7 @@ public:
|
|||||||
inline int indexOf(const T &inValue) {
|
inline int indexOf(const T &inValue) {
|
||||||
for (size_t i = 0; i < _size; ++i) {
|
for (size_t i = 0; i < _size; ++i) {
|
||||||
if (_buffer[i] == inValue) {
|
if (_buffer[i] == inValue) {
|
||||||
return static_cast<int>(i);
|
return (int)i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(lhs.size()); i < n; ++i) {
|
for (size_t i = 0, n = lhs.size(); i < n; ++i) {
|
||||||
if (lhs[i] != rhs[i]) {
|
if (lhs[i] != rhs[i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,7 +58,7 @@ void Animation::apply(Skeleton &skeleton, float lastTime, float time, bool loop,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_timelines.size()); i < n; ++i) {
|
for (size_t i = 0, n = _timelines.size(); i < n; ++i) {
|
||||||
_timelines[i]->apply(skeleton, lastTime, time, pEvents, alpha, blend, direction);
|
_timelines[i]->apply(skeleton, lastTime, time, pEvents, alpha, blend, direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void Animation::setDuration(float inValue) {
|
|||||||
|
|
||||||
int Animation::binarySearch(Vector<float> &values, float target, int step) {
|
int Animation::binarySearch(Vector<float> &values, float target, int step) {
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int size = static_cast<int>(values.size());
|
int size = (int)values.size();
|
||||||
int high = size / step - 2;
|
int high = size / step - 2;
|
||||||
if (high == 0) {
|
if (high == 0) {
|
||||||
return step;
|
return step;
|
||||||
@ -105,7 +105,7 @@ int Animation::binarySearch(Vector<float> &values, float target, int step) {
|
|||||||
|
|
||||||
int Animation::binarySearch(Vector<float> &values, float target) {
|
int Animation::binarySearch(Vector<float> &values, float target) {
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int size = static_cast<int>(values.size());
|
int size = (int)values.size();
|
||||||
int high = size - 2;
|
int high = size - 2;
|
||||||
if (high == 0) {
|
if (high == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -128,7 +128,7 @@ int Animation::binarySearch(Vector<float> &values, float target) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Animation::linearSearch(Vector<float> &values, float target, int step) {
|
int Animation::linearSearch(Vector<float> &values, float target, int step) {
|
||||||
for (int i = 0, last = static_cast<int>(values.size()) - step; i <= last; i += step) {
|
for (int i = 0, last = (int)values.size() - step; i <= last; i += step) {
|
||||||
if (values[i] > target) {
|
if (values[i] > target) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,13 +45,17 @@
|
|||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
void dummyOnAnimationEventFunc(AnimationState *state, EventType type, TrackEntry *entry, Event *event = NULL) {
|
void dummyOnAnimationEventFunc(AnimationState *state, EventType type, TrackEntry *entry, Event *event = NULL) {
|
||||||
|
SP_UNUSED(state);
|
||||||
|
SP_UNUSED(type);
|
||||||
|
SP_UNUSED(entry);
|
||||||
|
SP_UNUSED(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry::TrackEntry() : _animation(NULL), _next(NULL), _mixingFrom(NULL), _trackIndex(0), _loop(false),
|
TrackEntry::TrackEntry() : _animation(NULL), _next(NULL), _mixingFrom(NULL), _trackIndex(0), _loop(false),
|
||||||
_eventThreshold(0), _attachmentThreshold(0), _drawOrderThreshold(0), _animationStart(0),
|
_eventThreshold(0), _attachmentThreshold(0), _drawOrderThreshold(0), _animationStart(0),
|
||||||
_animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(0),
|
_animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(0),
|
||||||
_trackLast(0), _nextTrackLast(0), _trackEnd(0), _timeScale(1.0f), _alpha(0), _mixTime(0),
|
_trackLast(0), _nextTrackLast(0), _trackEnd(0), _timeScale(1.0f), _alpha(0), _mixTime(0),
|
||||||
_mixDuration(0), _mixBlend(MixBlend_Replace), _interruptAlpha(0), _totalAlpha(0),
|
_mixDuration(0), _interruptAlpha(0), _totalAlpha(0), _mixBlend(MixBlend_Replace),
|
||||||
_onAnimationEventFunc(dummyOnAnimationEventFunc) {
|
_onAnimationEventFunc(dummyOnAnimationEventFunc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,14 +160,14 @@ TrackEntry *TrackEntry::setTimelineData(TrackEntry *to, Vector<TrackEntry *> &mi
|
|||||||
TrackEntry *lastEntry = _mixingFrom != NULL ? _mixingFrom->setTimelineData(this, mixingToArray, propertyIDs) : this;
|
TrackEntry *lastEntry = _mixingFrom != NULL ? _mixingFrom->setTimelineData(this, mixingToArray, propertyIDs) : this;
|
||||||
if (to != NULL) mixingToArray.removeAt(mixingToArray.size() - 1);
|
if (to != NULL) mixingToArray.removeAt(mixingToArray.size() - 1);
|
||||||
|
|
||||||
int mixingToLast = static_cast<int>(mixingToArray.size()) - 1;
|
size_t mixingToLast = mixingToArray.size() - 1;
|
||||||
Vector<Timeline *> &timelines = _animation->_timelines;
|
Vector<Timeline *> &timelines = _animation->_timelines;
|
||||||
int timelinesCount = static_cast<int>(timelines.size());
|
size_t timelinesCount = timelines.size();
|
||||||
_timelineData.setSize(timelinesCount, 0);
|
_timelineData.setSize(timelinesCount, 0);
|
||||||
_timelineDipMix.setSize(timelinesCount, 0);
|
_timelineDipMix.setSize(timelinesCount, 0);
|
||||||
|
|
||||||
// outer:
|
// outer:
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
continue_outer:
|
continue_outer:
|
||||||
for (; i < timelinesCount; ++i) {
|
for (; i < timelinesCount; ++i) {
|
||||||
int id = timelines[i]->getPropertyId();
|
int id = timelines[i]->getPropertyId();
|
||||||
@ -197,7 +201,7 @@ TrackEntry *TrackEntry::setTimelineData(TrackEntry *to, Vector<TrackEntry *> &mi
|
|||||||
|
|
||||||
bool TrackEntry::hasTimeline(int inId) {
|
bool TrackEntry::hasTimeline(int inId) {
|
||||||
Vector<Timeline *> &timelines = _animation->_timelines;
|
Vector<Timeline *> &timelines = _animation->_timelines;
|
||||||
for (int i = 0, n = static_cast<int>(timelines.size()); i < n; ++i) {
|
for (size_t i = 0, n = timelines.size(); i < n; ++i) {
|
||||||
if (timelines[i]->getPropertyId() == inId) {
|
if (timelines[i]->getPropertyId() == inId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -317,9 +321,9 @@ AnimationState::AnimationState(AnimationStateData *data) :
|
|||||||
_data(data),
|
_data(data),
|
||||||
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
|
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
|
||||||
_animationsChanged(false),
|
_animationsChanged(false),
|
||||||
|
_rendererObject(NULL),
|
||||||
_onAnimationEventFunc(dummyOnAnimationEventFunc),
|
_onAnimationEventFunc(dummyOnAnimationEventFunc),
|
||||||
_timeScale(1),
|
_timeScale(1) {
|
||||||
_rendererObject(NULL) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimationState::~AnimationState() {
|
AnimationState::~AnimationState() {
|
||||||
@ -346,7 +350,7 @@ AnimationState::~AnimationState() {
|
|||||||
|
|
||||||
void AnimationState::update(float delta) {
|
void AnimationState::update(float delta) {
|
||||||
delta *= _timeScale;
|
delta *= _timeScale;
|
||||||
for (int i = 0, n = static_cast<int>(_tracks.size()); i < n; ++i) {
|
for (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
||||||
TrackEntry *currentP = _tracks[i];
|
TrackEntry *currentP = _tracks[i];
|
||||||
if (currentP == NULL) {
|
if (currentP == NULL) {
|
||||||
continue;
|
continue;
|
||||||
@ -414,7 +418,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool applied = false;
|
bool applied = false;
|
||||||
for (int i = 0, n = static_cast<int>(_tracks.size()); i < n; ++i) {
|
for (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
||||||
TrackEntry *currentP = _tracks[i];
|
TrackEntry *currentP = _tracks[i];
|
||||||
if (currentP == NULL || currentP->_delay > 0) {
|
if (currentP == NULL || currentP->_delay > 0) {
|
||||||
continue;
|
continue;
|
||||||
@ -435,10 +439,10 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
|
|
||||||
// apply current entry.
|
// apply current entry.
|
||||||
float animationLast = current._animationLast, animationTime = current.getAnimationTime();
|
float animationLast = current._animationLast, animationTime = current.getAnimationTime();
|
||||||
int timelineCount = static_cast<int>(current._animation->_timelines.size());
|
size_t timelineCount = current._animation->_timelines.size();
|
||||||
Vector<Timeline *> &timelines = current._animation->_timelines;
|
Vector<Timeline *> &timelines = current._animation->_timelines;
|
||||||
if (mix == 1 || blend == MixBlend_Add) {
|
if (mix == 1 || blend == MixBlend_Add) {
|
||||||
for (int ii = 0; ii < timelineCount; ++ii) {
|
for (size_t ii = 0; ii < timelineCount; ++ii) {
|
||||||
timelines[ii]->apply(skeleton, animationLast, animationTime, &_events, mix, blend,
|
timelines[ii]->apply(skeleton, animationLast, animationTime, &_events, mix, blend,
|
||||||
MixDirection_In);
|
MixDirection_In);
|
||||||
}
|
}
|
||||||
@ -451,7 +455,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
}
|
}
|
||||||
Vector<float> &timelinesRotation = current._timelinesRotation;
|
Vector<float> &timelinesRotation = current._timelinesRotation;
|
||||||
|
|
||||||
for (int ii = 0; ii < timelineCount; ++ii) {
|
for (size_t ii = 0; ii < timelineCount; ++ii) {
|
||||||
Timeline *timeline = timelines[ii];
|
Timeline *timeline = timelines[ii];
|
||||||
assert(timeline);
|
assert(timeline);
|
||||||
|
|
||||||
@ -484,7 +488,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
void AnimationState::clearTracks() {
|
void AnimationState::clearTracks() {
|
||||||
bool oldDrainDisabled = _queue->_drainDisabled;
|
bool oldDrainDisabled = _queue->_drainDisabled;
|
||||||
_queue->_drainDisabled = true;
|
_queue->_drainDisabled = true;
|
||||||
for (int i = 0, n = static_cast<int>(_tracks.size()); i < n; ++i) {
|
for (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
||||||
clearTrack(i);
|
clearTrack(i);
|
||||||
}
|
}
|
||||||
_tracks.clear();
|
_tracks.clear();
|
||||||
@ -620,7 +624,7 @@ TrackEntry *AnimationState::addEmptyAnimation(size_t trackIndex, float mixDurati
|
|||||||
void AnimationState::setEmptyAnimations(float mixDuration) {
|
void AnimationState::setEmptyAnimations(float mixDuration) {
|
||||||
bool oldDrainDisabled = _queue->_drainDisabled;
|
bool oldDrainDisabled = _queue->_drainDisabled;
|
||||||
_queue->_drainDisabled = true;
|
_queue->_drainDisabled = true;
|
||||||
for (int i = 0, n = static_cast<int>(_tracks.size()); i < n; ++i) {
|
for (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
||||||
TrackEntry *current = _tracks[i];
|
TrackEntry *current = _tracks[i];
|
||||||
if (current != NULL) {
|
if (current != NULL) {
|
||||||
setEmptyAnimation(i, mixDuration);
|
setEmptyAnimation(i, mixDuration);
|
||||||
@ -794,11 +798,11 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
bool attachments = mix < from->_attachmentThreshold, drawOrder = mix < from->_drawOrderThreshold;
|
bool attachments = mix < from->_attachmentThreshold, drawOrder = mix < from->_drawOrderThreshold;
|
||||||
float animationLast = from->_animationLast, animationTime = from->getAnimationTime();
|
float animationLast = from->_animationLast, animationTime = from->getAnimationTime();
|
||||||
Vector<Timeline *> &timelines = from->_animation->_timelines;
|
Vector<Timeline *> &timelines = from->_animation->_timelines;
|
||||||
int timelineCount = static_cast<int>(timelines.size());
|
size_t timelineCount = timelines.size();
|
||||||
float alphaDip = from->_alpha * to->_interruptAlpha, alphaMix = alphaDip * (1 - mix);
|
float alphaDip = from->_alpha * to->_interruptAlpha, alphaMix = alphaDip * (1 - mix);
|
||||||
|
|
||||||
if (blend == MixBlend_Add) {
|
if (blend == MixBlend_Add) {
|
||||||
for (int i = 0; i < timelineCount; i++)
|
for (size_t i = 0; i < timelineCount; i++)
|
||||||
timelines[i]->apply(skeleton, animationLast, animationTime, eventBuffer, alphaMix, blend, MixDirection_Out);
|
timelines[i]->apply(skeleton, animationLast, animationTime, eventBuffer, alphaMix, blend, MixDirection_Out);
|
||||||
} else {
|
} else {
|
||||||
Vector<int> &timelineData = from->_timelineData;
|
Vector<int> &timelineData = from->_timelineData;
|
||||||
@ -812,7 +816,7 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
Vector<float> &timelinesRotation = from->_timelinesRotation;
|
Vector<float> &timelinesRotation = from->_timelinesRotation;
|
||||||
|
|
||||||
from->_totalAlpha = 0;
|
from->_totalAlpha = 0;
|
||||||
for (int i = 0; i < timelineCount; i++) {
|
for (size_t i = 0; i < timelineCount; i++) {
|
||||||
Timeline *timeline = timelines[i];
|
Timeline *timeline = timelines[i];
|
||||||
MixBlend timelineBlend;
|
MixBlend timelineBlend;
|
||||||
float alpha;
|
float alpha;
|
||||||
@ -865,7 +869,7 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
|
|||||||
float trackLastWrapped = MathUtil::fmod(entry->_trackLast, duration);
|
float trackLastWrapped = MathUtil::fmod(entry->_trackLast, duration);
|
||||||
|
|
||||||
// Queue events before complete.
|
// Queue events before complete.
|
||||||
int i = 0, n = static_cast<int>(_events.size());
|
size_t i = 0, n = _events.size();
|
||||||
for (; i < n; ++i) {
|
for (; i < n; ++i) {
|
||||||
Event *e = _events[i];
|
Event *e = _events[i];
|
||||||
if (e->_time < trackLastWrapped) {
|
if (e->_time < trackLastWrapped) {
|
||||||
@ -978,7 +982,7 @@ void AnimationState::animationsChanged() {
|
|||||||
|
|
||||||
_propertyIDs.clear();
|
_propertyIDs.clear();
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_tracks.size()); i < n; ++i) {
|
for (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
||||||
TrackEntry *entry = _tracks[i];
|
TrackEntry *entry = _tracks[i];
|
||||||
if (entry != NULL && (i == 0 ||entry->_mixBlend != MixBlend_Add)) {
|
if (entry != NULL && (i == 0 ||entry->_mixBlend != MixBlend_Add)) {
|
||||||
entry->setTimelineData(NULL, _mixingTo, _propertyIDs);
|
entry->setTimelineData(NULL, _mixingTo, _propertyIDs);
|
||||||
|
|||||||
@ -41,12 +41,14 @@
|
|||||||
#include <spine/Atlas.h>
|
#include <spine/Atlas.h>
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader);
|
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader)
|
||||||
|
|
||||||
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas *atlas) : AttachmentLoader(), _atlas(atlas) {
|
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas *atlas) : AttachmentLoader(), _atlas(atlas) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const String &name, const String &path) {
|
RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const String &name, const String &path) {
|
||||||
|
SP_UNUSED(skin);
|
||||||
|
|
||||||
AtlasRegion *regionP = findRegion(path);
|
AtlasRegion *regionP = findRegion(path);
|
||||||
assert(regionP != NULL);
|
assert(regionP != NULL);
|
||||||
|
|
||||||
@ -67,6 +69,8 @@ RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const S
|
|||||||
}
|
}
|
||||||
|
|
||||||
MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const String &name, const String &path) {
|
MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const String &name, const String &path) {
|
||||||
|
SP_UNUSED(skin);
|
||||||
|
|
||||||
AtlasRegion *regionP = findRegion(path);
|
AtlasRegion *regionP = findRegion(path);
|
||||||
assert(regionP != NULL);
|
assert(regionP != NULL);
|
||||||
|
|
||||||
@ -92,18 +96,22 @@ MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const Strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxAttachment *AtlasAttachmentLoader::newBoundingBoxAttachment(Skin &skin, const String &name) {
|
BoundingBoxAttachment *AtlasAttachmentLoader::newBoundingBoxAttachment(Skin &skin, const String &name) {
|
||||||
|
SP_UNUSED(skin);
|
||||||
return new(__FILE__, __LINE__) BoundingBoxAttachment(name);
|
return new(__FILE__, __LINE__) BoundingBoxAttachment(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathAttachment *AtlasAttachmentLoader::newPathAttachment(Skin &skin, const String &name) {
|
PathAttachment *AtlasAttachmentLoader::newPathAttachment(Skin &skin, const String &name) {
|
||||||
|
SP_UNUSED(skin);
|
||||||
return new(__FILE__, __LINE__) PathAttachment(name);
|
return new(__FILE__, __LINE__) PathAttachment(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
PointAttachment *AtlasAttachmentLoader::newPointAttachment(Skin &skin, const String &name) {
|
PointAttachment *AtlasAttachmentLoader::newPointAttachment(Skin &skin, const String &name) {
|
||||||
|
SP_UNUSED(skin);
|
||||||
return new(__FILE__, __LINE__) PointAttachment(name);
|
return new(__FILE__, __LINE__) PointAttachment(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, const String &name) {
|
ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, const String &name) {
|
||||||
|
SP_UNUSED(skin);
|
||||||
return new(__FILE__, __LINE__) ClippingAttachment(name);
|
return new(__FILE__, __LINE__) ClippingAttachment(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
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) {
|
||||||
assert(_name.length() > 0);
|
assert(_name.length() > 0);
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(AttachmentLoader);
|
RTTI_IMPL_NOPARENT(AttachmentLoader)
|
||||||
|
|
||||||
AttachmentLoader::AttachmentLoader() {
|
AttachmentLoader::AttachmentLoader() {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(AttachmentTimeline, Timeline);
|
RTTI_IMPL(AttachmentTimeline, Timeline)
|
||||||
|
|
||||||
AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(0) {
|
AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(0) {
|
||||||
_frames.ensureCapacity(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
@ -55,6 +55,10 @@ AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(
|
|||||||
|
|
||||||
void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(alpha);
|
||||||
|
|
||||||
assert(_slotIndex < skeleton._slots.size());
|
assert(_slotIndex < skeleton._slots.size());
|
||||||
|
|
||||||
String *attachmentName;
|
String *attachmentName;
|
||||||
@ -76,10 +80,10 @@ void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, V
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int frameIndex;
|
size_t frameIndex;
|
||||||
if (time >= _frames[_frames.size() - 1]) {
|
if (time >= _frames[_frames.size() - 1]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
frameIndex = static_cast<int>(_frames.size()) - 1;
|
frameIndex = _frames.size() - 1;
|
||||||
} else {
|
} else {
|
||||||
frameIndex = Animation::binarySearch(_frames, time, 1) - 1;
|
frameIndex = Animation::binarySearch(_frames, time, 1) - 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(Bone, Updatable);
|
RTTI_IMPL(Bone, Updatable)
|
||||||
|
|
||||||
bool Bone::yDown = false;
|
bool Bone::yDown = false;
|
||||||
|
|
||||||
@ -68,9 +68,9 @@ Bone::Bone(BoneData &data, Skeleton &skeleton, Bone *parent) : Updatable(),
|
|||||||
_appliedValid(false),
|
_appliedValid(false),
|
||||||
_a(1),
|
_a(1),
|
||||||
_b(0),
|
_b(0),
|
||||||
|
_worldX(0),
|
||||||
_c(0),
|
_c(0),
|
||||||
_d(1),
|
_d(1),
|
||||||
_worldX(0),
|
|
||||||
_worldY(0),
|
_worldY(0),
|
||||||
_sorted(false) {
|
_sorted(false) {
|
||||||
setToSetupPose();
|
setToSetupPose();
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(BoundingBoxAttachment, VertexAttachment);
|
RTTI_IMPL(BoundingBoxAttachment, VertexAttachment)
|
||||||
|
|
||||||
BoundingBoxAttachment::BoundingBoxAttachment(const String &name) : VertexAttachment(name) {
|
BoundingBoxAttachment::BoundingBoxAttachment(const String &name) : VertexAttachment(name) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(ClippingAttachment, VertexAttachment);
|
RTTI_IMPL(ClippingAttachment, VertexAttachment)
|
||||||
|
|
||||||
ClippingAttachment::ClippingAttachment(const String &name) : VertexAttachment(name), _endSlot(NULL) {
|
ClippingAttachment::ClippingAttachment(const String &name) : VertexAttachment(name), _endSlot(NULL) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(ColorTimeline, CurveTimeline);
|
RTTI_IMPL(ColorTimeline, CurveTimeline)
|
||||||
|
|
||||||
const int ColorTimeline::ENTRIES = 5;
|
const int ColorTimeline::ENTRIES = 5;
|
||||||
const int ColorTimeline::PREV_TIME = -5;
|
const int ColorTimeline::PREV_TIME = -5;
|
||||||
@ -59,10 +59,13 @@ ColorTimeline::ColorTimeline(int frameCount) : CurveTimeline(frameCount), _slotI
|
|||||||
|
|
||||||
void ColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void ColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
Slot *slotP = skeleton._slots[_slotIndex];
|
Slot *slotP = skeleton._slots[_slotIndex];
|
||||||
Slot &slot = *slotP;
|
Slot &slot = *slotP;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
SlotData &slotData = slot._data;
|
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
slot._color.set(slot._data._color);
|
slot._color.set(slot._data._color);
|
||||||
@ -80,14 +83,14 @@ void ColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
float r, g, b, a;
|
float r, g, b, a;
|
||||||
if (time >= _frames[_frames.size() - ENTRIES]) {
|
if (time >= _frames[_frames.size() - ENTRIES]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
int i = static_cast<int>(_frames.size());
|
size_t i = _frames.size();
|
||||||
r = _frames[i + PREV_R];
|
r = _frames[i + PREV_R];
|
||||||
g = _frames[i + PREV_G];
|
g = _frames[i + PREV_G];
|
||||||
b = _frames[i + PREV_B];
|
b = _frames[i + PREV_B];
|
||||||
a = _frames[i + PREV_A];
|
a = _frames[i + PREV_A];
|
||||||
} else {
|
} else {
|
||||||
// Interpolate between the previous frame and the current frame.
|
// Interpolate between the previous frame and the current frame.
|
||||||
int frame = Animation::binarySearch(_frames, time, ENTRIES);
|
size_t frame = (size_t)Animation::binarySearch(_frames, time, ENTRIES);
|
||||||
r = _frames[frame + PREV_R];
|
r = _frames[frame + PREV_R];
|
||||||
g = _frames[frame + PREV_G];
|
g = _frames[frame + PREV_G];
|
||||||
b = _frames[frame + PREV_B];
|
b = _frames[frame + PREV_B];
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(Constraint, Updatable);
|
RTTI_IMPL(Constraint, Updatable)
|
||||||
|
|
||||||
Constraint::Constraint() {
|
Constraint::Constraint() {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(CurveTimeline, Timeline);
|
RTTI_IMPL(CurveTimeline, Timeline)
|
||||||
|
|
||||||
const float CurveTimeline::LINEAR = 0;
|
const float CurveTimeline::LINEAR = 0;
|
||||||
const float CurveTimeline::STEPPED = 1;
|
const float CurveTimeline::STEPPED = 1;
|
||||||
@ -50,29 +50,29 @@ CurveTimeline::CurveTimeline(int frameCount) {
|
|||||||
CurveTimeline::~CurveTimeline() {
|
CurveTimeline::~CurveTimeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CurveTimeline::getFrameCount() {
|
size_t CurveTimeline::getFrameCount() {
|
||||||
return static_cast<int>(_curves.size() / BEZIER_SIZE + 1);
|
return _curves.size() / BEZIER_SIZE + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveTimeline::setLinear(int frameIndex) {
|
void CurveTimeline::setLinear(size_t frameIndex) {
|
||||||
_curves[frameIndex * BEZIER_SIZE] = LINEAR;
|
_curves[frameIndex * BEZIER_SIZE] = LINEAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveTimeline::setStepped(int frameIndex) {
|
void CurveTimeline::setStepped(size_t frameIndex) {
|
||||||
_curves[frameIndex * BEZIER_SIZE] = STEPPED;
|
_curves[frameIndex * BEZIER_SIZE] = STEPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CurveTimeline::setCurve(int frameIndex, float cx1, float cy1, float cx2, float cy2) {
|
void CurveTimeline::setCurve(size_t frameIndex, float cx1, float cy1, float cx2, float cy2) {
|
||||||
float tmpx = (-cx1 * 2 + cx2) * 0.03f, tmpy = (-cy1 * 2 + cy2) * 0.03f;
|
float tmpx = (-cx1 * 2 + cx2) * 0.03f, tmpy = (-cy1 * 2 + cy2) * 0.03f;
|
||||||
float dddfx = ((cx1 - cx2) * 3 + 1) * 0.006f, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006f;
|
float dddfx = ((cx1 - cx2) * 3 + 1) * 0.006f, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006f;
|
||||||
float ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy;
|
float ddfx = tmpx * 2 + dddfx, ddfy = tmpy * 2 + dddfy;
|
||||||
float dfx = cx1 * 0.3f + tmpx + dddfx * 0.16666667f, dfy = cy1 * 0.3f + tmpy + dddfy * 0.16666667f;
|
float dfx = cx1 * 0.3f + tmpx + dddfx * 0.16666667f, dfy = cy1 * 0.3f + tmpy + dddfy * 0.16666667f;
|
||||||
|
|
||||||
int i = frameIndex * BEZIER_SIZE;
|
size_t i = frameIndex * BEZIER_SIZE;
|
||||||
_curves[i++] = BEZIER;
|
_curves[i++] = BEZIER;
|
||||||
|
|
||||||
float x = dfx, y = dfy;
|
float x = dfx, y = dfy;
|
||||||
for (int n = i + BEZIER_SIZE - 1; i < n; i += 2) {
|
for (size_t n = i + BEZIER_SIZE - 1; i < n; i += 2) {
|
||||||
_curves[i] = x;
|
_curves[i] = x;
|
||||||
_curves[i + 1] = y;
|
_curves[i + 1] = y;
|
||||||
dfx += ddfx;
|
dfx += ddfx;
|
||||||
@ -84,9 +84,9 @@ void CurveTimeline::setCurve(int frameIndex, float cx1, float cy1, float cx2, fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float CurveTimeline::getCurvePercent(int frameIndex, float percent) {
|
float CurveTimeline::getCurvePercent(size_t frameIndex, float percent) {
|
||||||
percent = MathUtil::clamp(percent, 0, 1);
|
percent = MathUtil::clamp(percent, 0, 1);
|
||||||
int i = frameIndex * BEZIER_SIZE;
|
size_t i = frameIndex * BEZIER_SIZE;
|
||||||
float type = _curves[i];
|
float type = _curves[i];
|
||||||
|
|
||||||
if (type == LINEAR) {
|
if (type == LINEAR) {
|
||||||
@ -99,7 +99,7 @@ float CurveTimeline::getCurvePercent(int frameIndex, float percent) {
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
float x = 0;
|
float x = 0;
|
||||||
for (int start = i, n = i + BEZIER_SIZE - 1; i < n; i += 2) {
|
for (size_t start = i, n = i + BEZIER_SIZE - 1; i < n; i += 2) {
|
||||||
x = _curves[i];
|
x = _curves[i];
|
||||||
if (x >= percent) {
|
if (x >= percent) {
|
||||||
float prevX, prevY;
|
float prevX, prevY;
|
||||||
@ -120,6 +120,6 @@ float CurveTimeline::getCurvePercent(int frameIndex, float percent) {
|
|||||||
return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1.
|
return y + (1 - y) * (percent - x) / (1 - x); // Last point is 1,1.
|
||||||
}
|
}
|
||||||
|
|
||||||
float CurveTimeline::getCurveType(int frameIndex) {
|
float CurveTimeline::getCurveType(size_t frameIndex) {
|
||||||
return _curves[frameIndex * BEZIER_SIZE];
|
return _curves[frameIndex * BEZIER_SIZE];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(DeformTimeline, CurveTimeline);
|
RTTI_IMPL(DeformTimeline, CurveTimeline)
|
||||||
|
|
||||||
DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0), _attachment(NULL) {
|
DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0), _attachment(NULL) {
|
||||||
_frames.ensureCapacity(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
@ -58,6 +58,10 @@ DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slo
|
|||||||
|
|
||||||
void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
Slot *slotP = skeleton._slots[_slotIndex];
|
Slot *slotP = skeleton._slots[_slotIndex];
|
||||||
Slot &slot = *slotP;
|
Slot &slot = *slotP;
|
||||||
|
|
||||||
@ -77,7 +81,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector< Vector<float> > &frameVertices = _frameVertices;
|
Vector< Vector<float> > &frameVertices = _frameVertices;
|
||||||
int vertexCount = static_cast<int>(frameVertices[0].size());
|
size_t vertexCount = frameVertices[0].size();
|
||||||
|
|
||||||
Vector<float> &frames = _frames;
|
Vector<float> &frames = _frames;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
@ -85,7 +89,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
verticesArray.clear();
|
verticesArray.clear();
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First: {
|
||||||
if (alpha == 1) {
|
if (alpha == 1) {
|
||||||
verticesArray.clear();
|
verticesArray.clear();
|
||||||
return;
|
return;
|
||||||
@ -95,17 +99,20 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
if (vertexAttachment->getBones().size() == 0) {
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions.
|
// Unweighted vertex positions.
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
|
vertices[i] += (setupVertices[i] - vertices[i]) * alpha;
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets.
|
// Weighted deform offsets.
|
||||||
alpha = 1 - alpha;
|
alpha = 1 - alpha;
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] *= alpha;
|
vertices[i] *= alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case MixBlend_Replace:
|
||||||
|
case MixBlend_Add:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
verticesArray.setSize(vertexCount, 0);
|
verticesArray.setSize(vertexCount, 0);
|
||||||
Vector<float> &vertices = verticesArray;
|
Vector<float> &vertices = verticesArray;
|
||||||
@ -118,11 +125,11 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
if (vertexAttachment->getBones().size() == 0) {
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions, no alpha.
|
// Unweighted vertex positions, no alpha.
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] += lastVertices[i] - setupVertices[i];
|
vertices[i] += lastVertices[i] - setupVertices[i];
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets, no alpha.
|
// Weighted deform offsets, no alpha.
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] += lastVertices[i];
|
vertices[i] += lastVertices[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -136,13 +143,13 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
if (vertexAttachment->getBones().size() == 0) {
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions, with alpha.
|
// Unweighted vertex positions, with alpha.
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float setup = setupVertices[i];
|
float setup = setupVertices[i];
|
||||||
vertices[i] = setup + (lastVertices[i] - setup) * alpha;
|
vertices[i] = setup + (lastVertices[i] - setup) * alpha;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets, with alpha.
|
// Weighted deform offsets, with alpha.
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] = lastVertices[i] * alpha;
|
vertices[i] = lastVertices[i] * alpha;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -150,7 +157,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
case MixBlend_Replace:
|
case MixBlend_Replace:
|
||||||
// Vertex positions or deform offsets, with alpha.
|
// Vertex positions or deform offsets, with alpha.
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] += (lastVertices[i] - vertices[i]) * alpha;
|
vertices[i] += (lastVertices[i] - vertices[i]) * alpha;
|
||||||
break;
|
break;
|
||||||
case MixBlend_Add:
|
case MixBlend_Add:
|
||||||
@ -158,11 +165,11 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
if (vertexAttachment->getBones().size() == 0) {
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions, no alpha.
|
// Unweighted vertex positions, no alpha.
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] += (lastVertices[i] - setupVertices[i]) * alpha;
|
vertices[i] += (lastVertices[i] - setupVertices[i]) * alpha;
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets, alpha.
|
// Weighted deform offsets, alpha.
|
||||||
for (int i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
vertices[i] += lastVertices[i] * alpha;
|
vertices[i] += lastVertices[i] * alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,20 +190,20 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
if (vertexAttachment->getBones().size() == 0) {
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions, no alpha.
|
// Unweighted vertex positions, no alpha.
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
vertices[i] += prev + (nextVertices[i] - prev) * percent - setupVertices[i];
|
vertices[i] += prev + (nextVertices[i] - prev) * percent - setupVertices[i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets, no alpha.
|
// Weighted deform offsets, no alpha.
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
vertices[i] += prev + (nextVertices[i] - prev) * percent;
|
vertices[i] += prev + (nextVertices[i] - prev) * percent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Vertex positions or deform offsets, no alpha.
|
// Vertex positions or deform offsets, no alpha.
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
vertices[i] = prev + (nextVertices[i] - prev) * percent;
|
||||||
}
|
}
|
||||||
@ -208,13 +215,13 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
if (vertexAttachment->getBones().size() == 0) {
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions, with alpha.
|
// Unweighted vertex positions, with alpha.
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i], setup = setupVertices[i];
|
float prev = prevVertices[i], setup = setupVertices[i];
|
||||||
vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets, with alpha.
|
// Weighted deform offsets, with alpha.
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
vertices[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
||||||
}
|
}
|
||||||
@ -224,7 +231,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
case MixBlend_Replace:
|
case MixBlend_Replace:
|
||||||
// Vertex positions or deform offsets, with alpha.
|
// Vertex positions or deform offsets, with alpha.
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha;
|
vertices[i] += (prev + (nextVertices[i] - prev) * percent - vertices[i]) * alpha;
|
||||||
}
|
}
|
||||||
@ -234,13 +241,13 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
if (vertexAttachment->getBones().size() == 0) {
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
// Unweighted vertex positions, with alpha.
|
// Unweighted vertex positions, with alpha.
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
vertices[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
|
vertices[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Weighted deform offsets, with alpha.
|
// Weighted deform offsets, with alpha.
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
vertices[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
|
vertices[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(DrawOrderTimeline, Timeline);
|
RTTI_IMPL(DrawOrderTimeline, Timeline)
|
||||||
|
|
||||||
DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline() {
|
DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline() {
|
||||||
_frames.ensureCapacity(frameCount);
|
_frames.ensureCapacity(frameCount);
|
||||||
@ -56,12 +56,16 @@ DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline() {
|
|||||||
|
|
||||||
void DrawOrderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void DrawOrderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(alpha);
|
||||||
|
|
||||||
Vector<Slot *> &drawOrder = skeleton._drawOrder;
|
Vector<Slot *> &drawOrder = skeleton._drawOrder;
|
||||||
Vector<Slot *> &slots = skeleton._slots;
|
Vector<Slot *> &slots = skeleton._slots;
|
||||||
if (direction == MixDirection_Out && blend == MixBlend_Setup) {
|
if (direction == MixDirection_Out && blend == MixBlend_Setup) {
|
||||||
drawOrder.clear();
|
drawOrder.clear();
|
||||||
drawOrder.ensureCapacity(slots.size());
|
drawOrder.ensureCapacity(slots.size());
|
||||||
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
for (size_t i = 0, n = slots.size(); i < n; ++i) {
|
||||||
drawOrder.add(slots[i]);
|
drawOrder.add(slots[i]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -71,29 +75,29 @@ void DrawOrderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Ve
|
|||||||
if (blend == MixBlend_Setup || blend == MixBlend_First) {
|
if (blend == MixBlend_Setup || blend == MixBlend_First) {
|
||||||
drawOrder.clear();
|
drawOrder.clear();
|
||||||
drawOrder.ensureCapacity(slots.size());
|
drawOrder.ensureCapacity(slots.size());
|
||||||
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
for (size_t i = 0, n = slots.size(); i < n; ++i) {
|
||||||
drawOrder.add(slots[i]);
|
drawOrder.add(slots[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int frame;
|
size_t frame;
|
||||||
if (time >= _frames[_frames.size() - 1]) {
|
if (time >= _frames[_frames.size() - 1]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
frame = static_cast<int>(_frames.size()) - 1;
|
frame = _frames.size() - 1;
|
||||||
} else {
|
} else {
|
||||||
frame = Animation::binarySearch(_frames, time) - 1;
|
frame = (size_t)Animation::binarySearch(_frames, time) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<int> &drawOrderToSetupIndex = _drawOrders[frame];
|
Vector<int> &drawOrderToSetupIndex = _drawOrders[frame];
|
||||||
if (drawOrderToSetupIndex.size() == 0) {
|
if (drawOrderToSetupIndex.size() == 0) {
|
||||||
drawOrder.clear();
|
drawOrder.clear();
|
||||||
for (int i = 0, n = static_cast<int>(slots.size()); i < n; ++i) {
|
for (size_t i = 0, n = slots.size(); i < n; ++i) {
|
||||||
drawOrder.add(slots[i]);
|
drawOrder.add(slots[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0, n = static_cast<int>(drawOrderToSetupIndex.size()); i < n; ++i) {
|
for (size_t i = 0, n = drawOrderToSetupIndex.size(); i < n; ++i) {
|
||||||
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
drawOrder[i] = slots[drawOrderToSetupIndex[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +107,7 @@ int DrawOrderTimeline::getPropertyId() {
|
|||||||
return ((int) TimelineType_DrawOrder << 24);
|
return ((int) TimelineType_DrawOrder << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawOrderTimeline::setFrame(int frameIndex, float time, Vector<int> &drawOrder) {
|
void DrawOrderTimeline::setFrame(size_t frameIndex, float time, Vector<int> &drawOrder) {
|
||||||
_frames[frameIndex] = time;
|
_frames[frameIndex] = time;
|
||||||
_drawOrders[frameIndex].clear();
|
_drawOrders[frameIndex].clear();
|
||||||
_drawOrders[frameIndex].addAll(drawOrder);
|
_drawOrders[frameIndex].addAll(drawOrder);
|
||||||
@ -117,6 +121,6 @@ Vector<Vector<int> > &DrawOrderTimeline::getDrawOrders() {
|
|||||||
return _drawOrders;
|
return _drawOrders;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrawOrderTimeline::getFrameCount() {
|
size_t DrawOrderTimeline::getFrameCount() {
|
||||||
return static_cast<int>(_frames.size());
|
return _frames.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(EventTimeline, Timeline);
|
RTTI_IMPL(EventTimeline, Timeline)
|
||||||
|
|
||||||
EventTimeline::EventTimeline(int frameCount) : Timeline() {
|
EventTimeline::EventTimeline(int frameCount) : Timeline() {
|
||||||
_frames.setSize(frameCount, 0);
|
_frames.setSize(frameCount, 0);
|
||||||
@ -65,7 +65,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int frameCount = static_cast<int>(_frames.size());
|
size_t frameCount = _frames.size();
|
||||||
|
|
||||||
if (lastTime > time) {
|
if (lastTime > time) {
|
||||||
// Fire events after last time for looped animations.
|
// Fire events after last time for looped animations.
|
||||||
@ -95,7 +95,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; frame < frameCount && time >= _frames[frame]; ++frame) {
|
for (; (size_t)frame < frameCount && time >= _frames[frame]; ++frame) {
|
||||||
events.add(_events[frame]);
|
events.add(_events[frame]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ int EventTimeline::getPropertyId() {
|
|||||||
return ((int) TimelineType_Event << 24);
|
return ((int) TimelineType_Event << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTimeline::setFrame(int frameIndex, Event *event) {
|
void EventTimeline::setFrame(size_t frameIndex, Event *event) {
|
||||||
_frames[frameIndex] = event->getTime();
|
_frames[frameIndex] = event->getTime();
|
||||||
_events[frameIndex] = event;
|
_events[frameIndex] = event;
|
||||||
}
|
}
|
||||||
@ -113,4 +113,4 @@ Vector<float> EventTimeline::getFrames() { return _frames; }
|
|||||||
|
|
||||||
Vector<Event *> &EventTimeline::getEvents() { return _events; }
|
Vector<Event *> &EventTimeline::getEvents() { return _events; }
|
||||||
|
|
||||||
int EventTimeline::getFrameCount() { return static_cast<int>(_frames.size()); }
|
size_t EventTimeline::getFrameCount() { return _frames.size(); }
|
||||||
|
|||||||
@ -60,6 +60,9 @@ DefaultSpineExtension::~DefaultSpineExtension() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *DefaultSpineExtension::_alloc(size_t size, const char *file, int line) {
|
void *DefaultSpineExtension::_alloc(size_t size, const char *file, int line) {
|
||||||
|
SP_UNUSED(file);
|
||||||
|
SP_UNUSED(line);
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
void *ptr = ::malloc(size);
|
void *ptr = ::malloc(size);
|
||||||
@ -67,6 +70,9 @@ void *DefaultSpineExtension::_alloc(size_t size, const char *file, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *DefaultSpineExtension::_calloc(size_t size, const char *file, int line) {
|
void *DefaultSpineExtension::_calloc(size_t size, const char *file, int line) {
|
||||||
|
SP_UNUSED(file);
|
||||||
|
SP_UNUSED(line);
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -78,6 +84,9 @@ void *DefaultSpineExtension::_calloc(size_t size, const char *file, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *DefaultSpineExtension::_realloc(void *ptr, size_t size, const char *file, int line) {
|
void *DefaultSpineExtension::_realloc(void *ptr, size_t size, const char *file, int line) {
|
||||||
|
SP_UNUSED(file);
|
||||||
|
SP_UNUSED(line);
|
||||||
|
|
||||||
void *mem = NULL;
|
void *mem = NULL;
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -89,6 +98,9 @@ void *DefaultSpineExtension::_realloc(void *ptr, size_t size, const char *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DefaultSpineExtension::_free(void *mem, const char *file, int line) {
|
void DefaultSpineExtension::_free(void *mem, const char *file, int line) {
|
||||||
|
SP_UNUSED(file);
|
||||||
|
SP_UNUSED(line);
|
||||||
|
|
||||||
::free(mem);
|
::free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(IkConstraint, Constraint);
|
RTTI_IMPL(IkConstraint, Constraint)
|
||||||
|
|
||||||
void IkConstraint::apply(Bone &bone, float targetX, float targetY, float alpha) {
|
void IkConstraint::apply(Bone &bone, float targetX, float targetY, float alpha) {
|
||||||
Bone *p = bone.getParent();
|
Bone *p = bone.getParent();
|
||||||
|
|||||||
@ -46,11 +46,11 @@ const String &IkConstraintData::getName() {
|
|||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int IkConstraintData::getOrder() {
|
size_t IkConstraintData::getOrder() {
|
||||||
return _order;
|
return _order;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IkConstraintData::setOrder(int inValue) {
|
void IkConstraintData::setOrder(size_t inValue) {
|
||||||
_order = inValue;
|
_order = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(IkConstraintTimeline, CurveTimeline);
|
RTTI_IMPL(IkConstraintTimeline, CurveTimeline)
|
||||||
|
|
||||||
const int IkConstraintTimeline::ENTRIES = 3;
|
const int IkConstraintTimeline::ENTRIES = 3;
|
||||||
const int IkConstraintTimeline::PREV_TIME = -3;
|
const int IkConstraintTimeline::PREV_TIME = -3;
|
||||||
@ -57,6 +57,9 @@ IkConstraintTimeline::IkConstraintTimeline(int frameCount) : CurveTimeline(frame
|
|||||||
|
|
||||||
void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
|
||||||
IkConstraint *constraintP = skeleton._ikConstraints[_ikConstraintIndex];
|
IkConstraint *constraintP = skeleton._ikConstraints[_ikConstraintIndex];
|
||||||
IkConstraint &constraint = *constraintP;
|
IkConstraint &constraint = *constraintP;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
|||||||
@ -377,7 +377,7 @@ const char *Json::parseNumber(Json *item, const char *num) {
|
|||||||
if (ptr != num) {
|
if (ptr != num) {
|
||||||
/* Parse success, number found. */
|
/* Parse success, number found. */
|
||||||
item->_valueFloat = (float)result;
|
item->_valueFloat = (float)result;
|
||||||
item->_valueInt = static_cast<int>(result);
|
item->_valueInt = (int)result;
|
||||||
item->_type = JSON_NUMBER;
|
item->_type = JSON_NUMBER;
|
||||||
return ptr;
|
return ptr;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(MeshAttachment, VertexAttachment);
|
RTTI_IMPL(MeshAttachment, VertexAttachment)
|
||||||
|
|
||||||
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name),
|
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name),
|
||||||
_regionOffsetX(0),
|
_regionOffsetX(0),
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(PathAttachment, VertexAttachment);
|
RTTI_IMPL(PathAttachment, VertexAttachment)
|
||||||
|
|
||||||
PathAttachment::PathAttachment(const String &name) : VertexAttachment(name), _closed(false), _constantSpeed(false) {
|
PathAttachment::PathAttachment(const String &name) : VertexAttachment(name), _closed(false), _constantSpeed(false) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(PathConstraint, Constraint);
|
RTTI_IMPL(PathConstraint, Constraint)
|
||||||
|
|
||||||
const float PathConstraint::EPSILON = 0.00001f;
|
const float PathConstraint::EPSILON = 0.00001f;
|
||||||
const int PathConstraint::NONE = -1;
|
const int PathConstraint::NONE = -1;
|
||||||
@ -90,7 +90,7 @@ void PathConstraint::update() {
|
|||||||
RotateMode rotateMode = data._rotateMode;
|
RotateMode rotateMode = data._rotateMode;
|
||||||
bool tangents = rotateMode == RotateMode_Tangent, scale = rotateMode == RotateMode_ChainScale;
|
bool tangents = rotateMode == RotateMode_Tangent, scale = rotateMode == RotateMode_ChainScale;
|
||||||
size_t boneCount = _bones.size();
|
size_t boneCount = _bones.size();
|
||||||
int spacesCount = static_cast<int>(tangents ? boneCount : boneCount + 1);
|
size_t spacesCount = tangents ? boneCount : boneCount + 1;
|
||||||
_spaces.setSize(spacesCount, 0);
|
_spaces.setSize(spacesCount, 0);
|
||||||
float spacing = _spacing;
|
float spacing = _spacing;
|
||||||
if (scale || !percentSpacing) {
|
if (scale || !percentSpacing) {
|
||||||
@ -99,7 +99,7 @@ void PathConstraint::update() {
|
|||||||
}
|
}
|
||||||
bool lengthSpacing = data._spacingMode == SpacingMode_Length;
|
bool lengthSpacing = data._spacingMode == SpacingMode_Length;
|
||||||
|
|
||||||
for (int i = 0, n = spacesCount - 1; i < n;) {
|
for (size_t i = 0, n = spacesCount - 1; i < n;) {
|
||||||
Bone *boneP = _bones[i];
|
Bone *boneP = _bones[i];
|
||||||
Bone &bone = *boneP;
|
Bone &bone = *boneP;
|
||||||
float setupLength = bone._data.getLength();
|
float setupLength = bone._data.getLength();
|
||||||
@ -127,7 +127,7 @@ void PathConstraint::update() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = 1; i < spacesCount; ++i) {
|
for (size_t i = 1; i < spacesCount; ++i) {
|
||||||
_spaces[i] = spacing;
|
_spaces[i] = spacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline);
|
RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline)
|
||||||
|
|
||||||
const int PathConstraintMixTimeline::ENTRIES = 3;
|
const int PathConstraintMixTimeline::ENTRIES = 3;
|
||||||
const int PathConstraintMixTimeline::PREV_TIME = -3;
|
const int PathConstraintMixTimeline::PREV_TIME = -3;
|
||||||
@ -59,6 +59,10 @@ PathConstraintMixTimeline::PathConstraintMixTimeline(int frameCount) : CurveTime
|
|||||||
void
|
void
|
||||||
PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
||||||
PathConstraint &constraint = *constraintP;
|
PathConstraint &constraint = *constraintP;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline);
|
RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline)
|
||||||
|
|
||||||
const int PathConstraintPositionTimeline::ENTRIES = 2;
|
const int PathConstraintPositionTimeline::ENTRIES = 2;
|
||||||
const int PathConstraintPositionTimeline::PREV_TIME = -2;
|
const int PathConstraintPositionTimeline::PREV_TIME = -2;
|
||||||
@ -59,6 +59,10 @@ PathConstraintPositionTimeline::~PathConstraintPositionTimeline() {
|
|||||||
|
|
||||||
void PathConstraintPositionTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
void PathConstraintPositionTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||||
float alpha, MixBlend blend, MixDirection direction) {
|
float alpha, MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
||||||
PathConstraint &constraint = *constraintP;
|
PathConstraint &constraint = *constraintP;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline);
|
RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline)
|
||||||
|
|
||||||
PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(int frameCount) : PathConstraintPositionTimeline(
|
PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(int frameCount) : PathConstraintPositionTimeline(
|
||||||
frameCount) {
|
frameCount) {
|
||||||
@ -50,6 +50,10 @@ PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(int frameCount) : P
|
|||||||
|
|
||||||
void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||||
float alpha, MixBlend blend, MixDirection direction) {
|
float alpha, MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
|
||||||
PathConstraint &constraint = *constraintP;
|
PathConstraint &constraint = *constraintP;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(PointAttachment, Attachment);
|
RTTI_IMPL(PointAttachment, Attachment)
|
||||||
|
|
||||||
PointAttachment::PointAttachment(const String &name) : Attachment(name), _x(0), _y(0), _rotation(0) {
|
PointAttachment::PointAttachment(const String &name) : Attachment(name), _x(0), _y(0), _rotation(0) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(RegionAttachment, Attachment);
|
RTTI_IMPL(RegionAttachment, Attachment)
|
||||||
|
|
||||||
const int RegionAttachment::BLX = 0;
|
const int RegionAttachment::BLX = 0;
|
||||||
const int RegionAttachment::BLY = 1;
|
const int RegionAttachment::BLY = 1;
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(RotateTimeline, CurveTimeline);
|
RTTI_IMPL(RotateTimeline, CurveTimeline)
|
||||||
|
|
||||||
RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(0) {
|
||||||
_frames.setSize(frameCount << 1, 0);
|
_frames.setSize(frameCount << 1, 0);
|
||||||
@ -48,6 +48,10 @@ RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _bon
|
|||||||
|
|
||||||
void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void RotateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
Bone *bone = skeleton.getBones()[_boneIndex];
|
Bone *bone = skeleton.getBones()[_boneIndex];
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
|
|||||||
@ -40,13 +40,16 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(ScaleTimeline, TranslateTimeline);
|
RTTI_IMPL(ScaleTimeline, TranslateTimeline)
|
||||||
|
|
||||||
ScaleTimeline::ScaleTimeline(int frameCount) : TranslateTimeline(frameCount) {
|
ScaleTimeline::ScaleTimeline(int frameCount) : TranslateTimeline(frameCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScaleTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void ScaleTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
|
||||||
Bone *boneP = skeleton._bones[_boneIndex];
|
Bone *boneP = skeleton._bones[_boneIndex];
|
||||||
Bone &bone = *boneP;
|
Bone &bone = *boneP;
|
||||||
|
|
||||||
|
|||||||
@ -40,13 +40,17 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(ShearTimeline, TranslateTimeline);
|
RTTI_IMPL(ShearTimeline, TranslateTimeline)
|
||||||
|
|
||||||
ShearTimeline::ShearTimeline(int frameCount) : TranslateTimeline(frameCount) {
|
ShearTimeline::ShearTimeline(int frameCount) : TranslateTimeline(frameCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShearTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void ShearTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
Bone *boneP = skeleton._bones[_boneIndex];
|
Bone *boneP = skeleton._bones[_boneIndex];
|
||||||
Bone &bone = *boneP;
|
Bone &bone = *boneP;
|
||||||
|
|
||||||
|
|||||||
@ -131,20 +131,20 @@ void Skeleton::updateCache() {
|
|||||||
_updateCache.clear();
|
_updateCache.clear();
|
||||||
_updateCacheReset.clear();
|
_updateCacheReset.clear();
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_bones.size()); i < n; ++i) {
|
for (size_t i = 0, n = _bones.size(); i < n; ++i) {
|
||||||
_bones[i]->_sorted = false;
|
_bones[i]->_sorted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ikCount = static_cast<int>(_ikConstraints.size());
|
size_t ikCount = _ikConstraints.size();
|
||||||
int transformCount = static_cast<int>(_transformConstraints.size());
|
size_t transformCount = _transformConstraints.size();
|
||||||
int pathCount = static_cast<int>(_pathConstraints.size());
|
size_t pathCount = _pathConstraints.size();
|
||||||
|
|
||||||
int constraintCount = ikCount + transformCount + pathCount;
|
size_t constraintCount = ikCount + transformCount + pathCount;
|
||||||
|
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
continue_outer:
|
continue_outer:
|
||||||
for (; i < constraintCount; ++i) {
|
for (; i < constraintCount; ++i) {
|
||||||
for (int ii = 0; ii < ikCount; ++ii) {
|
for (size_t ii = 0; ii < ikCount; ++ii) {
|
||||||
IkConstraint *constraint = _ikConstraints[ii];
|
IkConstraint *constraint = _ikConstraints[ii];
|
||||||
if (constraint->getData().getOrder() == i) {
|
if (constraint->getData().getOrder() == i) {
|
||||||
sortIkConstraint(constraint);
|
sortIkConstraint(constraint);
|
||||||
@ -153,18 +153,18 @@ void Skeleton::updateCache() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ii = 0; ii < transformCount; ++ii) {
|
for (size_t ii = 0; ii < transformCount; ++ii) {
|
||||||
TransformConstraint *constraint = _transformConstraints[ii];
|
TransformConstraint *constraint = _transformConstraints[ii];
|
||||||
if (constraint->getData().getOrder() == i) {
|
if (constraint->getData().getOrder() == (int)i) {
|
||||||
sortTransformConstraint(constraint);
|
sortTransformConstraint(constraint);
|
||||||
i++;
|
i++;
|
||||||
goto continue_outer;
|
goto continue_outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ii = 0; ii < pathCount; ++ii) {
|
for (size_t ii = 0; ii < pathCount; ++ii) {
|
||||||
PathConstraint *constraint = _pathConstraints[ii];
|
PathConstraint *constraint = _pathConstraints[ii];
|
||||||
if (constraint->getData().getOrder() == i) {
|
if (constraint->getData().getOrder() == (int)i) {
|
||||||
sortPathConstraint(constraint);
|
sortPathConstraint(constraint);
|
||||||
i++;
|
i++;
|
||||||
goto continue_outer;
|
goto continue_outer;
|
||||||
@ -172,7 +172,7 @@ void Skeleton::updateCache() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_bones.size()); i < n; ++i) {
|
for (size_t i = 0, n = _bones.size(); i < n; ++i) {
|
||||||
sortBone(_bones[i]);
|
sortBone(_bones[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ void Skeleton::printUpdateCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::updateWorldTransform() {
|
void Skeleton::updateWorldTransform() {
|
||||||
for (int i = 0, n = static_cast<int>(_updateCacheReset.size()); i < n; ++i) {
|
for (size_t i = 0, n = _updateCacheReset.size(); i < n; ++i) {
|
||||||
Bone *boneP = _updateCacheReset[i];
|
Bone *boneP = _updateCacheReset[i];
|
||||||
Bone &bone = *boneP;
|
Bone &bone = *boneP;
|
||||||
bone._ax = bone._x;
|
bone._ax = bone._x;
|
||||||
@ -206,7 +206,7 @@ void Skeleton::updateWorldTransform() {
|
|||||||
bone._appliedValid = true;
|
bone._appliedValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_updateCache.size()); i < n; ++i) {
|
for (size_t i = 0, n = _updateCache.size(); i < n; ++i) {
|
||||||
_updateCache[i]->update();
|
_updateCache[i]->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,11 +217,11 @@ void Skeleton::setToSetupPose() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::setBonesToSetupPose() {
|
void Skeleton::setBonesToSetupPose() {
|
||||||
for (int i = 0, n = static_cast<int>(_bones.size()); i < n; ++i) {
|
for (size_t i = 0, n = _bones.size(); i < n; ++i) {
|
||||||
_bones[i]->setToSetupPose();
|
_bones[i]->setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_ikConstraints.size()); i < n; ++i) {
|
for (size_t i = 0, n = _ikConstraints.size(); i < n; ++i) {
|
||||||
IkConstraint *constraintP = _ikConstraints[i];
|
IkConstraint *constraintP = _ikConstraints[i];
|
||||||
IkConstraint &constraint = *constraintP;
|
IkConstraint &constraint = *constraintP;
|
||||||
|
|
||||||
@ -229,7 +229,7 @@ void Skeleton::setBonesToSetupPose() {
|
|||||||
constraint._mix = constraint._data._mix;
|
constraint._mix = constraint._data._mix;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_transformConstraints.size()); i < n; ++i) {
|
for (size_t i = 0, n = _transformConstraints.size(); i < n; ++i) {
|
||||||
TransformConstraint *constraintP = _transformConstraints[i];
|
TransformConstraint *constraintP = _transformConstraints[i];
|
||||||
TransformConstraint &constraint = *constraintP;
|
TransformConstraint &constraint = *constraintP;
|
||||||
TransformConstraintData &constraintData = constraint._data;
|
TransformConstraintData &constraintData = constraint._data;
|
||||||
@ -240,7 +240,7 @@ void Skeleton::setBonesToSetupPose() {
|
|||||||
constraint._shearMix = constraintData._shearMix;
|
constraint._shearMix = constraintData._shearMix;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_pathConstraints.size()); i < n; ++i) {
|
for (size_t i = 0, n = _pathConstraints.size(); i < n; ++i) {
|
||||||
PathConstraint *constraintP = _pathConstraints[i];
|
PathConstraint *constraintP = _pathConstraints[i];
|
||||||
PathConstraint &constraint = *constraintP;
|
PathConstraint &constraint = *constraintP;
|
||||||
PathConstraintData &constraintData = constraint._data;
|
PathConstraintData &constraintData = constraint._data;
|
||||||
@ -254,11 +254,11 @@ void Skeleton::setBonesToSetupPose() {
|
|||||||
|
|
||||||
void Skeleton::setSlotsToSetupPose() {
|
void Skeleton::setSlotsToSetupPose() {
|
||||||
_drawOrder.clear();
|
_drawOrder.clear();
|
||||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
for (size_t i = 0, n = _slots.size(); i < n; ++i) {
|
||||||
_drawOrder.add(_slots[i]);
|
_drawOrder.add(_slots[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
for (size_t i = 0, n = _slots.size(); i < n; ++i) {
|
||||||
_slots[i]->setToSetupPose();
|
_slots[i]->setToSetupPose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ void Skeleton::setSkin(Skin *newSkin) {
|
|||||||
Skeleton &thisRef = *this;
|
Skeleton &thisRef = *this;
|
||||||
newSkin->attachAll(thisRef, *_skin);
|
newSkin->attachAll(thisRef, *_skin);
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
for (size_t i = 0, n = _slots.size(); i < n; ++i) {
|
||||||
Slot *slotP = _slots[i];
|
Slot *slotP = _slots[i];
|
||||||
Slot &slot = *slotP;
|
Slot &slot = *slotP;
|
||||||
const String &name = slot._data.getAttachmentName();
|
const String &name = slot._data.getAttachmentName();
|
||||||
@ -330,7 +330,7 @@ Attachment *Skeleton::getAttachment(int slotIndex, const String &attachmentName)
|
|||||||
void Skeleton::setAttachment(const String &slotName, const String &attachmentName) {
|
void Skeleton::setAttachment(const String &slotName, const String &attachmentName) {
|
||||||
assert(slotName.length() > 0);
|
assert(slotName.length() > 0);
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_slots.size()); i < n; ++i) {
|
for (size_t i = 0, n = _slots.size(); i < n; ++i) {
|
||||||
Slot *slot = _slots[i];
|
Slot *slot = _slots[i];
|
||||||
if (slot->_data.getName() == slotName) {
|
if (slot->_data.getName() == slotName) {
|
||||||
Attachment *attachment = NULL;
|
Attachment *attachment = NULL;
|
||||||
@ -354,7 +354,7 @@ void Skeleton::setAttachment(const String &slotName, const String &attachmentNam
|
|||||||
IkConstraint *Skeleton::findIkConstraint(const String &constraintName) {
|
IkConstraint *Skeleton::findIkConstraint(const String &constraintName) {
|
||||||
assert(constraintName.length() > 0);
|
assert(constraintName.length() > 0);
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_ikConstraints.size()); i < n; ++i) {
|
for (size_t i = 0, n = _ikConstraints.size(); i < n; ++i) {
|
||||||
IkConstraint *ikConstraint = _ikConstraints[i];
|
IkConstraint *ikConstraint = _ikConstraints[i];
|
||||||
if (ikConstraint->_data.getName() == constraintName) {
|
if (ikConstraint->_data.getName() == constraintName) {
|
||||||
return ikConstraint;
|
return ikConstraint;
|
||||||
@ -366,7 +366,7 @@ IkConstraint *Skeleton::findIkConstraint(const String &constraintName) {
|
|||||||
TransformConstraint *Skeleton::findTransformConstraint(const String &constraintName) {
|
TransformConstraint *Skeleton::findTransformConstraint(const String &constraintName) {
|
||||||
assert(constraintName.length() > 0);
|
assert(constraintName.length() > 0);
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_transformConstraints.size()); i < n; ++i) {
|
for (size_t i = 0, n = _transformConstraints.size(); i < n; ++i) {
|
||||||
TransformConstraint *transformConstraint = _transformConstraints[i];
|
TransformConstraint *transformConstraint = _transformConstraints[i];
|
||||||
if (transformConstraint->_data.getName() == constraintName) {
|
if (transformConstraint->_data.getName() == constraintName) {
|
||||||
return transformConstraint;
|
return transformConstraint;
|
||||||
@ -379,7 +379,7 @@ TransformConstraint *Skeleton::findTransformConstraint(const String &constraintN
|
|||||||
PathConstraint *Skeleton::findPathConstraint(const String &constraintName) {
|
PathConstraint *Skeleton::findPathConstraint(const String &constraintName) {
|
||||||
assert(constraintName.length() > 0);
|
assert(constraintName.length() > 0);
|
||||||
|
|
||||||
for (int i = 0, n = static_cast<int>(_pathConstraints.size()); i < n; ++i) {
|
for (size_t i = 0, n = _pathConstraints.size(); i < n; ++i) {
|
||||||
PathConstraint *constraint = _pathConstraints[i];
|
PathConstraint *constraint = _pathConstraints[i];
|
||||||
if (constraint->_data.getName() == constraintName) {
|
if (constraint->_data.getName() == constraintName) {
|
||||||
return constraint;
|
return constraint;
|
||||||
@ -601,7 +601,7 @@ void Skeleton::sortTransformConstraint(TransformConstraint *constraint) {
|
|||||||
constrained[i]->_sorted = true;
|
constrained[i]->_sorted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Skeleton::sortPathConstraintAttachment(Skin *skin, int slotIndex, Bone &slotBone) {
|
void Skeleton::sortPathConstraintAttachment(Skin *skin, size_t slotIndex, Bone &slotBone) {
|
||||||
Skin::AttachmentMap::Entries attachments = skin->getAttachments();
|
Skin::AttachmentMap::Entries attachments = skin->getAttachments();
|
||||||
|
|
||||||
while (attachments.hasNext()) {
|
while (attachments.hasNext()) {
|
||||||
|
|||||||
@ -880,24 +880,24 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|||||||
|
|
||||||
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 ? static_cast<int>(vertices.size()) / 3 * 2
|
size_t deformLength = weighted ? vertices.size() / 3 * 2
|
||||||
: static_cast<int>(vertices.size());
|
: vertices.size();
|
||||||
|
|
||||||
int frameCount = readVarint(input, true);
|
size_t frameCount = (size_t)readVarint(input, true);
|
||||||
|
|
||||||
DeformTimeline *timeline = new(__FILE__, __LINE__) DeformTimeline(frameCount);
|
DeformTimeline *timeline = new(__FILE__, __LINE__) DeformTimeline(frameCount);
|
||||||
|
|
||||||
timeline->_slotIndex = slotIndex;
|
timeline->_slotIndex = slotIndex;
|
||||||
timeline->_attachment = attachment;
|
timeline->_attachment = attachment;
|
||||||
|
|
||||||
for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
for (size_t frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
Vector<float> deform;
|
Vector<float> deform;
|
||||||
int end = readVarint(input, true);
|
size_t end = (size_t)readVarint(input, true);
|
||||||
if (end == 0) {
|
if (end == 0) {
|
||||||
if (weighted) {
|
if (weighted) {
|
||||||
deform.setSize(deformLength, 0);
|
deform.setSize(deformLength, 0);
|
||||||
for (int i = 0; i < deformLength; ++i) {
|
for (size_t i = 0; i < deformLength; ++i) {
|
||||||
deform[i] = 0;
|
deform[i] = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -905,20 +905,20 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deform.setSize(deformLength, 0);
|
deform.setSize(deformLength, 0);
|
||||||
int start = readVarint(input, true);
|
size_t start = (size_t)readVarint(input, true);
|
||||||
end += start;
|
end += start;
|
||||||
if (scale == 1) {
|
if (scale == 1) {
|
||||||
for (int v = start; v < end; ++v) {
|
for (size_t v = start; v < end; ++v) {
|
||||||
deform[v] = readFloat(input);
|
deform[v] = readFloat(input);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int v = start; v < end; ++v) {
|
for (size_t v = start; v < end; ++v) {
|
||||||
deform[v] = readFloat(input) * scale;
|
deform[v] = readFloat(input) * scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!weighted) {
|
if (!weighted) {
|
||||||
for (int v = 0, vn = static_cast<int>(deform.size()); v < vn; ++v) {
|
for (size_t v = 0, vn = deform.size(); v < vn; ++v) {
|
||||||
deform[v] += vertices[v];
|
deform[v] += vertices[v];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -937,33 +937,33 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Draw order timeline.
|
// Draw order timeline.
|
||||||
int drawOrderCount = readVarint(input, true);
|
size_t drawOrderCount = (size_t)readVarint(input, true);
|
||||||
if (drawOrderCount > 0) {
|
if (drawOrderCount > 0) {
|
||||||
DrawOrderTimeline *timeline = new(__FILE__, __LINE__) DrawOrderTimeline(drawOrderCount);
|
DrawOrderTimeline *timeline = new(__FILE__, __LINE__) DrawOrderTimeline(drawOrderCount);
|
||||||
|
|
||||||
int slotCount = static_cast<int>(skeletonData->_slots.size());
|
size_t slotCount = skeletonData->_slots.size();
|
||||||
for (int i = 0; i < drawOrderCount; ++i) {
|
for (size_t i = 0; i < drawOrderCount; ++i) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
int offsetCount = readVarint(input, true);
|
size_t offsetCount = (size_t)readVarint(input, true);
|
||||||
|
|
||||||
Vector<int> drawOrder;
|
Vector<int> drawOrder;
|
||||||
drawOrder.setSize(slotCount, 0);
|
drawOrder.setSize(slotCount, 0);
|
||||||
for (int ii = slotCount - 1; ii >= 0; --ii) {
|
for (int ii = (int)slotCount - 1; ii >= 0; --ii) {
|
||||||
drawOrder[ii] = -1;
|
drawOrder[ii] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<int> unchanged;
|
Vector<int> unchanged;
|
||||||
unchanged.setSize(slotCount - offsetCount, 0);
|
unchanged.setSize(slotCount - offsetCount, 0);
|
||||||
int originalIndex = 0, unchangedIndex = 0;
|
size_t originalIndex = 0, unchangedIndex = 0;
|
||||||
for (int ii = 0; ii < offsetCount; ++ii) {
|
for (size_t ii = 0; ii < offsetCount; ++ii) {
|
||||||
int slotIndex = readVarint(input, true);
|
size_t slotIndex = (size_t)readVarint(input, true);
|
||||||
// Collect unchanged items.
|
// Collect unchanged items.
|
||||||
while (originalIndex != slotIndex) {
|
while (originalIndex != slotIndex) {
|
||||||
unchanged[unchangedIndex++] = originalIndex++;
|
unchanged[unchangedIndex++] = originalIndex++;
|
||||||
}
|
}
|
||||||
// Set changed items.
|
// Set changed items.
|
||||||
int index = originalIndex;
|
size_t index = originalIndex;
|
||||||
drawOrder[index + readVarint(input, true)] = originalIndex++;
|
drawOrder[index + (size_t)readVarint(input, true)] = originalIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect remaining unchanged items.
|
// Collect remaining unchanged items.
|
||||||
@ -972,7 +972,7 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fill in unchanged items.
|
// Fill in unchanged items.
|
||||||
for (int ii = slotCount - 1; ii >= 0; --ii) {
|
for (int ii = (int)slotCount - 1; ii >= 0; --ii) {
|
||||||
if (drawOrder[ii] == -1) {
|
if (drawOrder[ii] == -1) {
|
||||||
drawOrder[ii] = unchanged[--unchangedIndex];
|
drawOrder[ii] = unchanged[--unchangedIndex];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,16 +42,16 @@ SkeletonBounds::SkeletonBounds() : _minX(0), _minY(0), _maxX(0), _maxY(0) {
|
|||||||
|
|
||||||
void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
|
void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
|
||||||
Vector<Slot *> &slots = skeleton._slots;
|
Vector<Slot *> &slots = skeleton._slots;
|
||||||
int slotCount = static_cast<int>(slots.size());
|
size_t slotCount = slots.size();
|
||||||
|
|
||||||
_boundingBoxes.clear();
|
_boundingBoxes.clear();
|
||||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i) {
|
for (size_t i = 0, n = _polygons.size(); i < n; ++i) {
|
||||||
_polygonPool.add(_polygons[i]);
|
_polygonPool.add(_polygons[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
_polygons.clear();
|
_polygons.clear();
|
||||||
|
|
||||||
for (int i = 0; i < slotCount; i++) {
|
for (size_t i = 0; i < slotCount; i++) {
|
||||||
Slot *slot = slots[i];
|
Slot *slot = slots[i];
|
||||||
Attachment *attachment = slot->_attachment;
|
Attachment *attachment = slot->_attachment;
|
||||||
if (attachment == NULL || !attachment->getRTTI().instanceOf(BoundingBoxAttachment::rtti)) {
|
if (attachment == NULL || !attachment->getRTTI().instanceOf(BoundingBoxAttachment::rtti)) {
|
||||||
@ -61,12 +61,12 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
|
|||||||
_boundingBoxes.add(boundingBox);
|
_boundingBoxes.add(boundingBox);
|
||||||
|
|
||||||
Polygon *polygonP = NULL;
|
Polygon *polygonP = NULL;
|
||||||
int poolCount = static_cast<int>(_polygonPool.size());
|
size_t poolCount = _polygonPool.size();
|
||||||
if (poolCount > 0) {
|
if (poolCount > 0) {
|
||||||
polygonP = _polygonPool[poolCount - 1];
|
polygonP = _polygonPool[poolCount - 1];
|
||||||
_polygonPool.removeAt(poolCount - 1);
|
_polygonPool.removeAt(poolCount - 1);
|
||||||
} else {
|
} else {
|
||||||
Polygon *polygonP = new(__FILE__, __LINE__) Polygon();
|
polygonP = new(__FILE__, __LINE__) Polygon();
|
||||||
}
|
}
|
||||||
|
|
||||||
_polygons.add(polygonP);
|
_polygons.add(polygonP);
|
||||||
@ -151,7 +151,7 @@ bool SkeletonBounds::containsPoint(Polygon *polygon, float x, float y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxAttachment *SkeletonBounds::containsPoint(float x, float y) {
|
BoundingBoxAttachment *SkeletonBounds::containsPoint(float x, float y) {
|
||||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i) {
|
for (size_t i = 0, n = _polygons.size(); i < n; ++i) {
|
||||||
if (containsPoint(_polygons[i], x, y)) {
|
if (containsPoint(_polygons[i], x, y)) {
|
||||||
return _boundingBoxes[i];
|
return _boundingBoxes[i];
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ BoundingBoxAttachment *SkeletonBounds::containsPoint(float x, float y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxAttachment *SkeletonBounds::intersectsSegment(float x1, float y1, float x2, float y2) {
|
BoundingBoxAttachment *SkeletonBounds::intersectsSegment(float x1, float y1, float x2, float y2) {
|
||||||
for (int i = 0, n = static_cast<int>(_polygons.size()); i < n; ++i) {
|
for (size_t i = 0, n = _polygons.size(); i < n; ++i) {
|
||||||
if (intersectsSegment(_polygons[i], x1, y1, x2, y2)) {
|
if (intersectsSegment(_polygons[i], x1, y1, x2, y2)) {
|
||||||
return _boundingBoxes[i];
|
return _boundingBoxes[i];
|
||||||
}
|
}
|
||||||
@ -171,12 +171,12 @@ BoundingBoxAttachment *SkeletonBounds::intersectsSegment(float x1, float y1, flo
|
|||||||
|
|
||||||
bool SkeletonBounds::intersectsSegment(Polygon *polygon, float x1, float y1, float x2, float y2) {
|
bool SkeletonBounds::intersectsSegment(Polygon *polygon, float x1, float y1, float x2, float y2) {
|
||||||
Vector<float> &vertices = polygon->_vertices;
|
Vector<float> &vertices = polygon->_vertices;
|
||||||
int nn = polygon->_count;
|
size_t nn = polygon->_count;
|
||||||
|
|
||||||
float width12 = x1 - x2, height12 = y1 - y2;
|
float width12 = x1 - x2, height12 = y1 - y2;
|
||||||
float det1 = x1 * y2 - y1 * x2;
|
float det1 = x1 * y2 - y1 * x2;
|
||||||
float x3 = vertices[nn - 2], y3 = vertices[nn - 1];
|
float x3 = vertices[nn - 2], y3 = vertices[nn - 1];
|
||||||
for (int ii = 0; ii < nn; ii += 2) {
|
for (size_t ii = 0; ii < nn; ii += 2) {
|
||||||
float x4 = vertices[ii], y4 = vertices[ii + 1];
|
float x4 = vertices[ii], y4 = vertices[ii + 1];
|
||||||
float det2 = x3 * y4 - y3 * x4;
|
float det2 = x3 * y4 - y3 * x4;
|
||||||
float width34 = x3 - x4, height34 = y3 - y4;
|
float width34 = x3 - x4, height34 = y3 - y4;
|
||||||
|
|||||||
@ -42,7 +42,7 @@ SkeletonClipping::SkeletonClipping() : _clipAttachment(NULL) {
|
|||||||
_clippedUVs.ensureCapacity(128);
|
_clippedUVs.ensureCapacity(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SkeletonClipping::clipStart(Slot &slot, ClippingAttachment *clip) {
|
size_t SkeletonClipping::clipStart(Slot &slot, ClippingAttachment *clip) {
|
||||||
if (_clipAttachment != NULL) {
|
if (_clipAttachment != NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ int SkeletonClipping::clipStart(Slot &slot, ClippingAttachment *clip) {
|
|||||||
polygon.add(polygon[1]);
|
polygon.add(polygon[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<int>((*_clippingPolygons).size());
|
return (*_clippingPolygons).size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonClipping::clipEnd(Slot &slot) {
|
void SkeletonClipping::clipEnd(Slot &slot) {
|
||||||
@ -85,20 +85,22 @@ void SkeletonClipping::clipEnd() {
|
|||||||
_clippingPolygon.clear();
|
_clippingPolygon.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonClipping::clipTriangles(Vector<float> &vertices, int verticesLength, Vector<unsigned short> &triangles,
|
void SkeletonClipping::clipTriangles(Vector<float> &vertices, size_t verticesLength, Vector<unsigned short> &triangles,
|
||||||
int trianglesLength, Vector<float> &uvs) {
|
size_t trianglesLength, Vector<float> &uvs) {
|
||||||
|
SP_UNUSED(verticesLength);
|
||||||
|
|
||||||
Vector<float> &clipOutput = _clipOutput;
|
Vector<float> &clipOutput = _clipOutput;
|
||||||
Vector<float> &clippedVertices = _clippedVertices;
|
Vector<float> &clippedVertices = _clippedVertices;
|
||||||
Vector<unsigned short> &clippedTriangles = _clippedTriangles;
|
Vector<unsigned short> &clippedTriangles = _clippedTriangles;
|
||||||
Vector<Vector<float> *> &polygons = *_clippingPolygons;
|
Vector<Vector<float> *> &polygons = *_clippingPolygons;
|
||||||
int polygonsCount = static_cast<int>((*_clippingPolygons).size());
|
size_t polygonsCount = (*_clippingPolygons).size();
|
||||||
|
|
||||||
int index = 0;
|
size_t index = 0;
|
||||||
clippedVertices.clear();
|
clippedVertices.clear();
|
||||||
_clippedUVs.clear();
|
_clippedUVs.clear();
|
||||||
clippedTriangles.clear();
|
clippedTriangles.clear();
|
||||||
|
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
continue_outer:
|
continue_outer:
|
||||||
for (; i < trianglesLength; i += 3) {
|
for (; i < trianglesLength; i += 3) {
|
||||||
int vertexOffset = triangles[i] << 1;
|
int vertexOffset = triangles[i] << 1;
|
||||||
@ -113,20 +115,20 @@ void SkeletonClipping::clipTriangles(Vector<float> &vertices, int verticesLength
|
|||||||
float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
|
float x3 = vertices[vertexOffset], y3 = vertices[vertexOffset + 1];
|
||||||
float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
|
float u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
|
||||||
|
|
||||||
for (int p = 0; p < polygonsCount; p++) {
|
for (size_t p = 0; p < polygonsCount; p++) {
|
||||||
int s = static_cast<int>(clippedVertices.size());
|
size_t s = clippedVertices.size();
|
||||||
if (clip(x1, y1, x2, y2, x3, y3, &(*polygons[p]), &clipOutput)) {
|
if (clip(x1, y1, x2, y2, x3, y3, &(*polygons[p]), &clipOutput)) {
|
||||||
int clipOutputLength = static_cast<int>(clipOutput.size());
|
size_t clipOutputLength = clipOutput.size();
|
||||||
if (clipOutputLength == 0) {
|
if (clipOutputLength == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
float d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
|
float d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
|
||||||
float d = 1 / (d0 * d2 + d1 * (y1 - y3));
|
float d = 1 / (d0 * d2 + d1 * (y1 - y3));
|
||||||
|
|
||||||
int clipOutputCount = clipOutputLength >> 1;
|
size_t clipOutputCount = clipOutputLength >> 1;
|
||||||
clippedVertices.setSize(s + clipOutputCount * 2, 0);
|
clippedVertices.setSize(s + clipOutputCount * 2, 0);
|
||||||
_clippedUVs.setSize(s + clipOutputCount * 2, 0);
|
_clippedUVs.setSize(s + clipOutputCount * 2, 0);
|
||||||
for (int ii = 0; ii < clipOutputLength; ii += 2) {
|
for (size_t ii = 0; ii < clipOutputLength; ii += 2) {
|
||||||
float x = clipOutput[ii], y = clipOutput[ii + 1];
|
float x = clipOutput[ii], y = clipOutput[ii + 1];
|
||||||
clippedVertices[s] = x;
|
clippedVertices[s] = x;
|
||||||
clippedVertices[s + 1] = y;
|
clippedVertices[s + 1] = y;
|
||||||
@ -139,10 +141,10 @@ void SkeletonClipping::clipTriangles(Vector<float> &vertices, int verticesLength
|
|||||||
s += 2;
|
s += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = static_cast<int>(clippedTriangles.size());
|
s = clippedTriangles.size();
|
||||||
clippedTriangles.setSize(s + 3 * (clipOutputCount - 2), 0);
|
clippedTriangles.setSize(s + 3 * (clipOutputCount - 2), 0);
|
||||||
clipOutputCount--;
|
clipOutputCount--;
|
||||||
for (int ii = 1; ii < clipOutputCount; ii++) {
|
for (size_t ii = 1; ii < clipOutputCount; ii++) {
|
||||||
clippedTriangles[s] = index;
|
clippedTriangles[s] = index;
|
||||||
clippedTriangles[s + 1] = index + ii;
|
clippedTriangles[s + 1] = index + ii;
|
||||||
clippedTriangles[s + 2] = index + ii + 1;
|
clippedTriangles[s + 2] = index + ii + 1;
|
||||||
@ -166,7 +168,7 @@ void SkeletonClipping::clipTriangles(Vector<float> &vertices, int verticesLength
|
|||||||
_clippedUVs[s + 4] = u3;
|
_clippedUVs[s + 4] = u3;
|
||||||
_clippedUVs[s + 5] = v3;
|
_clippedUVs[s + 5] = v3;
|
||||||
|
|
||||||
s = static_cast<int>(clippedTriangles.size());
|
s = clippedTriangles.size();
|
||||||
clippedTriangles.setSize(s + 3, 0);
|
clippedTriangles.setSize(s + 3, 0);
|
||||||
clippedTriangles[s] = index;
|
clippedTriangles[s] = index;
|
||||||
clippedTriangles[s + 1] = index + 1;
|
clippedTriangles[s + 1] = index + 1;
|
||||||
@ -221,15 +223,15 @@ bool SkeletonClipping::clip(float x1, float y1, float x2, float y2, float x3, fl
|
|||||||
output->clear();
|
output->clear();
|
||||||
|
|
||||||
Vector<float> &clippingVertices = *clippingArea;
|
Vector<float> &clippingVertices = *clippingArea;
|
||||||
int clippingVerticesLast = static_cast<int>(clippingArea->size()) - 4;
|
size_t clippingVerticesLast = clippingArea->size() - 4;
|
||||||
for (int i = 0;; i += 2) {
|
for (size_t i = 0;; i += 2) {
|
||||||
float edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];
|
float edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];
|
||||||
float edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];
|
float edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];
|
||||||
float deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
|
float deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
|
||||||
|
|
||||||
Vector<float> &inputVertices = *input;
|
Vector<float> &inputVertices = *input;
|
||||||
int inputVerticesLength = static_cast<int>(input->size()) - 2, outputStart = static_cast<int>(output->size());
|
size_t inputVerticesLength = input->size() - 2, outputStart = output->size();
|
||||||
for (int ii = 0; ii < inputVerticesLength; ii += 2) {
|
for (size_t ii = 0; ii < inputVerticesLength; ii += 2) {
|
||||||
float inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
|
float inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
|
||||||
float inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
|
float inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
|
||||||
bool side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;
|
bool side2 = deltaX * (inputY2 - edgeY2) - deltaY * (inputX2 - edgeX2) > 0;
|
||||||
@ -279,7 +281,7 @@ bool SkeletonClipping::clip(float x1, float y1, float x2, float y2, float x3, fl
|
|||||||
|
|
||||||
if (originalOutput != output) {
|
if (originalOutput != output) {
|
||||||
originalOutput->clear();
|
originalOutput->clear();
|
||||||
for (int i = 0, n = static_cast<int>(output->size()) - 2; i < n; ++i) {
|
for (size_t i = 0, n = output->size() - 2; i < n; ++i) {
|
||||||
originalOutput->add((*output)[i]);
|
originalOutput->add((*output)[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -290,12 +292,12 @@ bool SkeletonClipping::clip(float x1, float y1, float x2, float y2, float x3, fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonClipping::makeClockwise(Vector<float> &polygon) {
|
void SkeletonClipping::makeClockwise(Vector<float> &polygon) {
|
||||||
int verticeslength = static_cast<int>(polygon.size());
|
size_t verticeslength = polygon.size();
|
||||||
|
|
||||||
float area =
|
float area =
|
||||||
polygon[verticeslength - 2] * polygon[1] - polygon[0] * polygon[verticeslength - 1], p1x, p1y, p2x, p2y;
|
polygon[verticeslength - 2] * polygon[1] - polygon[0] * polygon[verticeslength - 1], p1x, p1y, p2x, p2y;
|
||||||
|
|
||||||
for (int i = 0, n = verticeslength - 3; i < n; i += 2) {
|
for (size_t i = 0, n = verticeslength - 3; i < n; i += 2) {
|
||||||
p1x = polygon[i];
|
p1x = polygon[i];
|
||||||
p1y = polygon[i + 1];
|
p1y = polygon[i + 1];
|
||||||
p2x = polygon[i + 2];
|
p2x = polygon[i + 2];
|
||||||
@ -307,7 +309,7 @@ void SkeletonClipping::makeClockwise(Vector<float> &polygon) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {
|
for (size_t i = 0, lastX = verticeslength - 2, n = verticeslength >> 1; i < n; i += 2) {
|
||||||
float x = polygon[i], y = polygon[i + 1];
|
float x = polygon[i], y = polygon[i + 1];
|
||||||
int other = lastX - i;
|
int other = lastX - i;
|
||||||
polygon[i] = polygon[other];
|
polygon[i] = polygon[other];
|
||||||
|
|||||||
@ -623,7 +623,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Linked meshes. */
|
/* Linked meshes. */
|
||||||
for (int i = 0, n = static_cast<int>(_linkedMeshes.size()); i < n; ++i) {
|
for (int i = 0, n = _linkedMeshes.size(); i < n; ++i) {
|
||||||
LinkedMesh *linkedMesh = _linkedMeshes[i];
|
LinkedMesh *linkedMesh = _linkedMeshes[i];
|
||||||
Skin *skin = linkedMesh->_skin.length() == 0 ? skeletonData->getDefaultSkin() : skeletonData->findSkin(
|
Skin *skin = linkedMesh->_skin.length() == 0 ? skeletonData->getDefaultSkin() : skeletonData->findSkin(
|
||||||
linkedMesh->_skin);
|
linkedMesh->_skin);
|
||||||
@ -907,7 +907,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
IkConstraintData *constraint = skeletonData->findIkConstraint(constraintMap->_name);
|
IkConstraintData *constraint = skeletonData->findIkConstraint(constraintMap->_name);
|
||||||
IkConstraintTimeline *timeline = new(__FILE__, __LINE__) IkConstraintTimeline(constraintMap->_size);
|
IkConstraintTimeline *timeline = new(__FILE__, __LINE__) IkConstraintTimeline(constraintMap->_size);
|
||||||
|
|
||||||
for (frameIndex = 0; frameIndex < static_cast<int>(skeletonData->_ikConstraints.size()); ++frameIndex) {
|
for (frameIndex = 0; frameIndex < skeletonData->_ikConstraints.size(); ++frameIndex) {
|
||||||
if (constraint == skeletonData->_ikConstraints[frameIndex]) {
|
if (constraint == skeletonData->_ikConstraints[frameIndex]) {
|
||||||
timeline->_ikConstraintIndex = frameIndex;
|
timeline->_ikConstraintIndex = frameIndex;
|
||||||
break;
|
break;
|
||||||
@ -1036,7 +1036,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
|
|
||||||
weighted = attachment->_bones.size() != 0;
|
weighted = attachment->_bones.size() != 0;
|
||||||
Vector<float> &vertices = attachment->_vertices;
|
Vector<float> &vertices = attachment->_vertices;
|
||||||
deformLength = weighted ? static_cast<int>(vertices.size()) / 3 * 2 : static_cast<int>(vertices.size());
|
deformLength = weighted ? vertices.size() / 3 * 2 : vertices.size();
|
||||||
|
|
||||||
timeline = new(__FILE__, __LINE__) DeformTimeline(timelineMap->_size);
|
timeline = new(__FILE__, __LINE__) DeformTimeline(timelineMap->_size);
|
||||||
|
|
||||||
@ -1100,7 +1100,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
|
|
||||||
drawOrder2.ensureCapacity(skeletonData->_slots.size());
|
drawOrder2.ensureCapacity(skeletonData->_slots.size());
|
||||||
drawOrder2.setSize(skeletonData->_slots.size(), 0);
|
drawOrder2.setSize(skeletonData->_slots.size(), 0);
|
||||||
for (ii = static_cast<int>(skeletonData->_slots.size()) - 1; ii >= 0; --ii) {
|
for (ii = (int)skeletonData->_slots.size() - 1; ii >= 0; --ii) {
|
||||||
drawOrder2[ii] = -1;
|
drawOrder2[ii] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1112,7 +1112,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Collect unchanged items. */
|
/* Collect unchanged items. */
|
||||||
while (originalIndex != slotIndex) {
|
while (originalIndex != (size_t)slotIndex) {
|
||||||
unchanged[unchangedIndex++] = originalIndex++;
|
unchanged[unchangedIndex++] = originalIndex++;
|
||||||
}
|
}
|
||||||
/* Set changed items. */
|
/* Set changed items. */
|
||||||
@ -1124,7 +1124,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
unchanged[unchangedIndex++] = originalIndex++;
|
unchanged[unchangedIndex++] = originalIndex++;
|
||||||
}
|
}
|
||||||
/* Fill in unchanged items. */
|
/* Fill in unchanged items. */
|
||||||
for (ii = static_cast<int>(skeletonData->_slots.size()) - 1; ii >= 0; ii--) {
|
for (ii = (int)skeletonData->_slots.size() - 1; ii >= 0; ii--) {
|
||||||
if (drawOrder2[ii] == -1) {
|
if (drawOrder2[ii] == -1) {
|
||||||
drawOrder2[ii] = unchanged[--unchangedIndex];
|
drawOrder2[ii] = unchanged[--unchangedIndex];
|
||||||
}
|
}
|
||||||
@ -1166,7 +1166,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
|
|||||||
|
|
||||||
void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength) {
|
void SkeletonJson::readVertices(Json *attachmentMap, VertexAttachment *attachment, size_t verticesLength) {
|
||||||
Json *entry;
|
Json *entry;
|
||||||
int i, n, nn, entrySize;
|
size_t i, n, nn, entrySize;
|
||||||
Vector<float> vertices;
|
Vector<float> vertices;
|
||||||
|
|
||||||
attachment->setWorldVerticesLength(verticesLength);
|
attachment->setWorldVerticesLength(verticesLength);
|
||||||
|
|||||||
@ -38,6 +38,7 @@ void *SpineObject::operator new(size_t sz, const char *file, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void *SpineObject::operator new(size_t sz, void *ptr) {
|
void *SpineObject::operator new(size_t sz, void *ptr) {
|
||||||
|
SP_UNUSED(sz);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ void SpineObject::operator delete(void *p, const char *file, int line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SpineObject::operator delete(void *p, void *mem) {
|
void SpineObject::operator delete(void *p, void *mem) {
|
||||||
|
SP_UNUSED(mem);
|
||||||
SpineExtension::free(p, __FILE__, __LINE__);
|
SpineExtension::free(p, __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include <spine/Event.h>
|
#include <spine/Event.h>
|
||||||
|
|
||||||
namespace Spine {
|
namespace Spine {
|
||||||
RTTI_IMPL_NOPARENT(Timeline);
|
RTTI_IMPL_NOPARENT(Timeline)
|
||||||
|
|
||||||
Timeline::Timeline() {
|
Timeline::Timeline() {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(TransformConstraint, Constraint);
|
RTTI_IMPL(TransformConstraint, Constraint)
|
||||||
|
|
||||||
TransformConstraint::TransformConstraint(TransformConstraintData &data, Skeleton &skeleton) : Constraint(),
|
TransformConstraint::TransformConstraint(TransformConstraintData &data, Skeleton &skeleton) : Constraint(),
|
||||||
_data(data),
|
_data(data),
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(TransformConstraintTimeline, CurveTimeline);
|
RTTI_IMPL(TransformConstraintTimeline, CurveTimeline)
|
||||||
|
|
||||||
const int TransformConstraintTimeline::ENTRIES = 5;
|
const int TransformConstraintTimeline::ENTRIES = 5;
|
||||||
const int TransformConstraintTimeline::PREV_TIME = -5;
|
const int TransformConstraintTimeline::PREV_TIME = -5;
|
||||||
@ -62,6 +62,10 @@ TransformConstraintTimeline::TransformConstraintTimeline(int frameCount) : Curve
|
|||||||
|
|
||||||
void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
|
||||||
float alpha, MixBlend blend, MixDirection direction) {
|
float alpha, MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
TransformConstraint *constraintP = skeleton._transformConstraints[_transformConstraintIndex];
|
TransformConstraint *constraintP = skeleton._transformConstraints[_transformConstraintIndex];
|
||||||
TransformConstraint &constraint = *constraintP;
|
TransformConstraint &constraint = *constraintP;
|
||||||
|
|
||||||
@ -87,7 +91,7 @@ void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, floa
|
|||||||
float rotate, translate, scale, shear;
|
float rotate, translate, scale, shear;
|
||||||
if (time >= _frames[_frames.size() - ENTRIES]) {
|
if (time >= _frames[_frames.size() - ENTRIES]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
int i = static_cast<int>(_frames.size());
|
size_t i = _frames.size();
|
||||||
rotate = _frames[i + PREV_ROTATE];
|
rotate = _frames[i + PREV_ROTATE];
|
||||||
translate = _frames[i + PREV_TRANSLATE];
|
translate = _frames[i + PREV_TRANSLATE];
|
||||||
scale = _frames[i + PREV_SCALE];
|
scale = _frames[i + PREV_SCALE];
|
||||||
@ -128,7 +132,7 @@ int TransformConstraintTimeline::getPropertyId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TransformConstraintTimeline::setFrame(int frameIndex, float time, float rotateMix, float translateMix, float scaleMix,
|
TransformConstraintTimeline::setFrame(size_t frameIndex, float time, float rotateMix, float translateMix, float scaleMix,
|
||||||
float shearMix) {
|
float shearMix) {
|
||||||
frameIndex *= ENTRIES;
|
frameIndex *= ENTRIES;
|
||||||
_frames[frameIndex] = time;
|
_frames[frameIndex] = time;
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(TranslateTimeline, CurveTimeline);
|
RTTI_IMPL(TranslateTimeline, CurveTimeline)
|
||||||
|
|
||||||
const int TranslateTimeline::ENTRIES = 3;
|
const int TranslateTimeline::ENTRIES = 3;
|
||||||
const int TranslateTimeline::PREV_TIME = -3;
|
const int TranslateTimeline::PREV_TIME = -3;
|
||||||
@ -59,6 +59,10 @@ TranslateTimeline::~TranslateTimeline() {
|
|||||||
|
|
||||||
void TranslateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void TranslateTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
Bone *boneP = skeleton._bones[_boneIndex];
|
Bone *boneP = skeleton._bones[_boneIndex];
|
||||||
Bone &bone = *boneP;
|
Bone &bone = *boneP;
|
||||||
|
|
||||||
|
|||||||
@ -40,30 +40,30 @@ Triangulator::~Triangulator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<int> &Triangulator::triangulate(Vector<float> &vertices) {
|
Vector<int> &Triangulator::triangulate(Vector<float> &vertices) {
|
||||||
int vertexCount = static_cast<int>(vertices.size() >> 1);
|
size_t vertexCount = vertices.size() >> 1;
|
||||||
|
|
||||||
Vector<int> &indices = _indices;
|
Vector<int> &indices = _indices;
|
||||||
indices.clear();
|
indices.clear();
|
||||||
indices.ensureCapacity(vertexCount);
|
indices.ensureCapacity(vertexCount);
|
||||||
indices.setSize(vertexCount, 0);
|
indices.setSize(vertexCount, 0);
|
||||||
for (int i = 0; i < vertexCount; ++i) {
|
for (size_t i = 0; i < vertexCount; ++i) {
|
||||||
indices[i] = i;
|
indices[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<bool> &isConcaveArray = _isConcaveArray;
|
Vector<bool> &isConcaveArray = _isConcaveArray;
|
||||||
isConcaveArray.ensureCapacity(vertexCount);
|
isConcaveArray.ensureCapacity(vertexCount);
|
||||||
isConcaveArray.setSize(vertexCount, 0);
|
isConcaveArray.setSize(vertexCount, 0);
|
||||||
for (int i = 0, n = vertexCount; i < n; ++i) {
|
for (size_t i = 0, n = vertexCount; i < n; ++i) {
|
||||||
isConcaveArray[i] = isConcave(i, vertexCount, vertices, indices);
|
isConcaveArray[i] = isConcave(i, vertexCount, vertices, indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<int> &triangles = _triangles;
|
Vector<int> &triangles = _triangles;
|
||||||
triangles.clear();
|
triangles.clear();
|
||||||
triangles.ensureCapacity(MathUtil::max(0, vertexCount - 2) << 2);
|
triangles.ensureCapacity(MathUtil::max((int)0, (int)vertexCount - 2) << 2);
|
||||||
|
|
||||||
while (vertexCount > 3) {
|
while (vertexCount > 3) {
|
||||||
// Find ear tip.
|
// Find ear tip.
|
||||||
int previous = vertexCount - 1, i = 0, next = 1;
|
size_t previous = vertexCount - 1, i = 0, next = 1;
|
||||||
|
|
||||||
// outer:
|
// outer:
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -72,7 +72,7 @@ Vector<int> &Triangulator::triangulate(Vector<float> &vertices) {
|
|||||||
float p1x = vertices[p1], p1y = vertices[p1 + 1];
|
float p1x = vertices[p1], p1y = vertices[p1 + 1];
|
||||||
float p2x = vertices[p2], p2y = vertices[p2 + 1];
|
float p2x = vertices[p2], p2y = vertices[p2 + 1];
|
||||||
float p3x = vertices[p3], p3y = vertices[p3 + 1];
|
float p3x = vertices[p3], p3y = vertices[p3 + 1];
|
||||||
for (int ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) {
|
for (size_t ii = (next + 1) % vertexCount; ii != previous; ii = (ii + 1) % vertexCount) {
|
||||||
if (!isConcaveArray[ii]) {
|
if (!isConcaveArray[ii]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ Vector<Vector<float> *> &Triangulator::decompose(Vector<float> &vertices, Vector
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove empty polygons that resulted from the merge step above.
|
// Remove empty polygons that resulted from the merge step above.
|
||||||
for (int i = static_cast<int>(convexPolygons.size()) - 1; i >= 0; --i) {
|
for (int i = (int)convexPolygons.size() - 1; i >= 0; --i) {
|
||||||
polygon = convexPolygons[i];
|
polygon = convexPolygons[i];
|
||||||
if (polygon->size() == 0) {
|
if (polygon->size() == 0) {
|
||||||
convexPolygons.removeAt(i);
|
convexPolygons.removeAt(i);
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL(TwoColorTimeline, CurveTimeline);
|
RTTI_IMPL(TwoColorTimeline, CurveTimeline)
|
||||||
|
|
||||||
const int TwoColorTimeline::ENTRIES = 8;
|
const int TwoColorTimeline::ENTRIES = 8;
|
||||||
const int TwoColorTimeline::PREV_TIME = -8;
|
const int TwoColorTimeline::PREV_TIME = -8;
|
||||||
@ -66,6 +66,10 @@ TwoColorTimeline::TwoColorTimeline(int frameCount) : CurveTimeline(frameCount),
|
|||||||
|
|
||||||
void TwoColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void TwoColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction) {
|
||||||
|
SP_UNUSED(lastTime);
|
||||||
|
SP_UNUSED(pEvents);
|
||||||
|
SP_UNUSED(direction);
|
||||||
|
|
||||||
Slot *slotP = skeleton._slots[_slotIndex];
|
Slot *slotP = skeleton._slots[_slotIndex];
|
||||||
Slot &slot = *slotP;
|
Slot &slot = *slotP;
|
||||||
|
|
||||||
@ -97,7 +101,7 @@ void TwoColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vec
|
|||||||
float r, g, b, a, r2, g2, b2;
|
float r, g, b, a, r2, g2, b2;
|
||||||
if (time >= _frames[_frames.size() - ENTRIES]) {
|
if (time >= _frames[_frames.size() - ENTRIES]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
int i = static_cast<int>(_frames.size());
|
size_t i = _frames.size();
|
||||||
r = _frames[i + PREV_R];
|
r = _frames[i + PREV_R];
|
||||||
g = _frames[i + PREV_G];
|
g = _frames[i + PREV_G];
|
||||||
b = _frames[i + PREV_B];
|
b = _frames[i + PREV_B];
|
||||||
@ -107,7 +111,7 @@ void TwoColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vec
|
|||||||
b2 = _frames[i + PREV_B2];
|
b2 = _frames[i + PREV_B2];
|
||||||
} else {
|
} else {
|
||||||
// Interpolate between the previous frame and the current frame.
|
// Interpolate between the previous frame and the current frame.
|
||||||
int frame = Animation::binarySearch(_frames, time, ENTRIES);
|
size_t frame = (size_t)Animation::binarySearch(_frames, time, ENTRIES);
|
||||||
r = _frames[frame + PREV_R];
|
r = _frames[frame + PREV_R];
|
||||||
g = _frames[frame + PREV_G];
|
g = _frames[frame + PREV_G];
|
||||||
b = _frames[frame + PREV_B];
|
b = _frames[frame + PREV_B];
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
using namespace Spine;
|
||||||
|
|
||||||
RTTI_IMPL_NOPARENT(Updatable);
|
RTTI_IMPL_NOPARENT(Updatable)
|
||||||
|
|
||||||
Updatable::Updatable() {
|
Updatable::Updatable() {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
using namespace Spine;
|
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), _id(getNextID()) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,9 +38,14 @@ JitterVertexEffect::JitterVertexEffect(float jitterX, float jitterY): _jitterX(j
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JitterVertexEffect::begin(Skeleton &skeleton) {
|
void JitterVertexEffect::begin(Skeleton &skeleton) {
|
||||||
|
SP_UNUSED(skeleton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JitterVertexEffect::transform(float &x, float &y, float &u, float &v, Color &light, Color &dark) {
|
void JitterVertexEffect::transform(float &x, float &y, float &u, float &v, Color &light, Color &dark) {
|
||||||
|
SP_UNUSED(u);
|
||||||
|
SP_UNUSED(v);
|
||||||
|
SP_UNUSED(light);
|
||||||
|
SP_UNUSED(dark);
|
||||||
float jitterX = _jitterX;
|
float jitterX = _jitterX;
|
||||||
float jitterY = _jitterY;
|
float jitterY = _jitterY;
|
||||||
x += MathUtil::randomTriangular(-jitterX, jitterX);
|
x += MathUtil::randomTriangular(-jitterX, jitterX);
|
||||||
@ -67,13 +72,13 @@ float JitterVertexEffect::getJitterY() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwirlVertexEffect::SwirlVertexEffect(float radius, Interpolation &interpolation):
|
SwirlVertexEffect::SwirlVertexEffect(float radius, Interpolation &interpolation):
|
||||||
_radius(radius),
|
|
||||||
_interpolation(interpolation),
|
|
||||||
_centerY(0),
|
|
||||||
_centerX(0),
|
_centerX(0),
|
||||||
|
_centerY(0),
|
||||||
|
_radius(radius),
|
||||||
|
_angle(0),
|
||||||
_worldX(0),
|
_worldX(0),
|
||||||
_worldY(0),
|
_worldY(0),
|
||||||
_angle(0) {
|
_interpolation(interpolation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwirlVertexEffect::begin(Skeleton &skeleton) {
|
void SwirlVertexEffect::begin(Skeleton &skeleton) {
|
||||||
@ -82,6 +87,11 @@ void SwirlVertexEffect::begin(Skeleton &skeleton) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SwirlVertexEffect::transform(float &positionX, float &positionY, float &u, float &v, Color &light, Color &dark) {
|
void SwirlVertexEffect::transform(float &positionX, float &positionY, float &u, float &v, Color &light, Color &dark) {
|
||||||
|
SP_UNUSED(u);
|
||||||
|
SP_UNUSED(v);
|
||||||
|
SP_UNUSED(light);
|
||||||
|
SP_UNUSED(dark);
|
||||||
|
|
||||||
float x = positionX - _worldX;
|
float x = positionX - _worldX;
|
||||||
float y = positionY - _worldY;
|
float y = positionY - _worldY;
|
||||||
float dist = (float)MathUtil::sqrt(x * x + y * y);
|
float dist = (float)MathUtil::sqrt(x * x + y * y);
|
||||||
|
|||||||
@ -53,7 +53,7 @@ namespace Spine {
|
|||||||
SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) :
|
SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) :
|
||||||
timeScale(1),
|
timeScale(1),
|
||||||
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
|
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
|
||||||
worldVertices(), clipper(), vertexEffect(NULL) {
|
vertexEffect(NULL), worldVertices(), clipper() {
|
||||||
Bone::setYDown(true);
|
Bone::setYDown(true);
|
||||||
worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX);
|
worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX);
|
||||||
skeleton = new(__FILE__, __LINE__) Skeleton(skeletonData);
|
skeleton = new(__FILE__, __LINE__) Skeleton(skeletonData);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user