Clean up Clang warnings, refactor more size_t related code.

This commit is contained in:
badlogic 2018-05-24 17:17:45 +02:00
parent 8259b44bdd
commit 2bd8dc7326
61 changed files with 341 additions and 241 deletions

View File

@ -3,8 +3,8 @@ project(spine)
if(MSVC)
message("MSCV detected")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
else()
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")

View File

@ -1,7 +1,7 @@
if(MSVC)
message("MSCV detected")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
else()
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")

View File

@ -48,20 +48,20 @@ namespace Spine {
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.
/// 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.
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:
static const float LINEAR;

View File

@ -55,7 +55,7 @@ public:
}
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("allocations: %lu, reallocations: %lu, frees: %lu\n", _allocations, _reallocations, _frees);

View File

@ -49,11 +49,11 @@ namespace Spine {
/// Sets the time and value of the specified keyframe.
/// @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< Vector<int> >& getDrawOrders();
int getFrameCount();
size_t getFrameCount();
private:
Vector<float> _frames;

View File

@ -50,11 +50,11 @@ namespace Spine {
virtual int getPropertyId();
/// 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<Event*>& getEvents();
int getFrameCount();
size_t getFrameCount();
private:
Vector<float> _frames;

View File

@ -33,6 +33,8 @@
#include <stdlib.h>
#define SP_UNUSED(x) (void)(x)
namespace Spine {
class String;

View File

@ -36,7 +36,9 @@
#include <spine/SpineObject.h>
// Required for new with line number and file name in MSVC
#ifdef _MSC_VER
#pragma warning(disable:4291)
#endif
namespace Spine {
template<typename K, typename V>

View File

@ -51,8 +51,8 @@ namespace Spine {
/// The IK constraint's name, which is unique within the skeleton.
const String& getName();
int getOrder();
void setOrder(int inValue);
size_t getOrder();
void setOrder(size_t inValue);
/// The bones that are constrained by this IK Constraint.
Vector<BoneData*>& getBones();
@ -70,7 +70,7 @@ namespace Spine {
private:
const String _name;
int _order;
size_t _order;
Vector<BoneData*> _bones;
BoneData* _target;
int _bendDirection;

View File

@ -234,7 +234,7 @@ private:
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);

View File

@ -42,13 +42,13 @@ namespace Spine {
public:
SkeletonClipping();
int clipStart(Slot& slot, ClippingAttachment* clip);
size_t clipStart(Slot& slot, ClippingAttachment* clip);
void clipEnd(Slot& slot);
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();

View File

@ -38,7 +38,9 @@
#include <stdio.h>
// Required for sprintf on MSVC
#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif
namespace Spine {
class String : public SpineObject {

View File

@ -49,7 +49,7 @@ namespace Spine {
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:
static const int PREV_TIME, PREV_ROTATE, PREV_TRANSLATE, PREV_SCALE, PREV_SHEAR;

View File

@ -141,7 +141,7 @@ public:
inline int indexOf(const T &inValue) {
for (size_t i = 0; i < _size; ++i) {
if (_buffer[i] == inValue) {
return static_cast<int>(i);
return (int)i;
}
}
@ -159,7 +159,7 @@ public:
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]) {
return false;
}

View File

@ -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);
}
}
@ -81,7 +81,7 @@ void Animation::setDuration(float inValue) {
int Animation::binarySearch(Vector<float> &values, float target, int step) {
int low = 0;
int size = static_cast<int>(values.size());
int size = (int)values.size();
int high = size / step - 2;
if (high == 0) {
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 low = 0;
int size = static_cast<int>(values.size());
int size = (int)values.size();
int high = size - 2;
if (high == 0) {
return 1;
@ -128,7 +128,7 @@ int Animation::binarySearch(Vector<float> &values, float target) {
}
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) {
return i;
}

View File

@ -45,13 +45,17 @@
using namespace Spine;
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),
_eventThreshold(0), _attachmentThreshold(0), _drawOrderThreshold(0), _animationStart(0),
_animationEnd(0), _animationLast(0), _nextAnimationLast(0), _delay(0), _trackTime(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) {
}
@ -156,14 +160,14 @@ TrackEntry *TrackEntry::setTimelineData(TrackEntry *to, Vector<TrackEntry *> &mi
TrackEntry *lastEntry = _mixingFrom != NULL ? _mixingFrom->setTimelineData(this, mixingToArray, propertyIDs) : this;
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;
int timelinesCount = static_cast<int>(timelines.size());
size_t timelinesCount = timelines.size();
_timelineData.setSize(timelinesCount, 0);
_timelineDipMix.setSize(timelinesCount, 0);
// outer:
int i = 0;
size_t i = 0;
continue_outer:
for (; i < timelinesCount; ++i) {
int id = timelines[i]->getPropertyId();
@ -197,7 +201,7 @@ TrackEntry *TrackEntry::setTimelineData(TrackEntry *to, Vector<TrackEntry *> &mi
bool TrackEntry::hasTimeline(int inId) {
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) {
return true;
}
@ -317,9 +321,9 @@ AnimationState::AnimationState(AnimationStateData *data) :
_data(data),
_queue(EventQueue::newEventQueue(*this, _trackEntryPool)),
_animationsChanged(false),
_rendererObject(NULL),
_onAnimationEventFunc(dummyOnAnimationEventFunc),
_timeScale(1),
_rendererObject(NULL) {
_timeScale(1) {
}
AnimationState::~AnimationState() {
@ -346,7 +350,7 @@ AnimationState::~AnimationState() {
void AnimationState::update(float delta) {
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];
if (currentP == NULL) {
continue;
@ -414,7 +418,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
}
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];
if (currentP == NULL || currentP->_delay > 0) {
continue;
@ -435,10 +439,10 @@ bool AnimationState::apply(Skeleton &skeleton) {
// apply current entry.
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;
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,
MixDirection_In);
}
@ -451,7 +455,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
}
Vector<float> &timelinesRotation = current._timelinesRotation;
for (int ii = 0; ii < timelineCount; ++ii) {
for (size_t ii = 0; ii < timelineCount; ++ii) {
Timeline *timeline = timelines[ii];
assert(timeline);
@ -484,7 +488,7 @@ bool AnimationState::apply(Skeleton &skeleton) {
void AnimationState::clearTracks() {
bool oldDrainDisabled = _queue->_drainDisabled;
_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);
}
_tracks.clear();
@ -620,7 +624,7 @@ TrackEntry *AnimationState::addEmptyAnimation(size_t trackIndex, float mixDurati
void AnimationState::setEmptyAnimations(float mixDuration) {
bool oldDrainDisabled = _queue->_drainDisabled;
_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];
if (current != NULL) {
setEmptyAnimation(i, mixDuration);
@ -794,11 +798,11 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
bool attachments = mix < from->_attachmentThreshold, drawOrder = mix < from->_drawOrderThreshold;
float animationLast = from->_animationLast, animationTime = from->getAnimationTime();
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);
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);
} else {
Vector<int> &timelineData = from->_timelineData;
@ -812,7 +816,7 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
Vector<float> &timelinesRotation = from->_timelinesRotation;
from->_totalAlpha = 0;
for (int i = 0; i < timelineCount; i++) {
for (size_t i = 0; i < timelineCount; i++) {
Timeline *timeline = timelines[i];
MixBlend timelineBlend;
float alpha;
@ -865,7 +869,7 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
float trackLastWrapped = MathUtil::fmod(entry->_trackLast, duration);
// Queue events before complete.
int i = 0, n = static_cast<int>(_events.size());
size_t i = 0, n = _events.size();
for (; i < n; ++i) {
Event *e = _events[i];
if (e->_time < trackLastWrapped) {
@ -978,7 +982,7 @@ void AnimationState::animationsChanged() {
_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];
if (entry != NULL && (i == 0 ||entry->_mixBlend != MixBlend_Add)) {
entry->setTimelineData(NULL, _mixingTo, _propertyIDs);

View File

@ -41,12 +41,14 @@
#include <spine/Atlas.h>
namespace Spine {
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader);
RTTI_IMPL(AtlasAttachmentLoader, AttachmentLoader)
AtlasAttachmentLoader::AtlasAttachmentLoader(Atlas *atlas) : AttachmentLoader(), _atlas(atlas) {
}
RegionAttachment *AtlasAttachmentLoader::newRegionAttachment(Skin &skin, const String &name, const String &path) {
SP_UNUSED(skin);
AtlasRegion *regionP = findRegion(path);
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) {
SP_UNUSED(skin);
AtlasRegion *regionP = findRegion(path);
assert(regionP != NULL);
@ -92,18 +96,22 @@ MeshAttachment *AtlasAttachmentLoader::newMeshAttachment(Skin &skin, const Strin
}
BoundingBoxAttachment *AtlasAttachmentLoader::newBoundingBoxAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) BoundingBoxAttachment(name);
}
PathAttachment *AtlasAttachmentLoader::newPathAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) PathAttachment(name);
}
PointAttachment *AtlasAttachmentLoader::newPointAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) PointAttachment(name);
}
ClippingAttachment *AtlasAttachmentLoader::newClippingAttachment(Skin &skin, const String &name) {
SP_UNUSED(skin);
return new(__FILE__, __LINE__) ClippingAttachment(name);
}

View File

@ -34,7 +34,7 @@
using namespace Spine;
RTTI_IMPL_NOPARENT(Attachment);
RTTI_IMPL_NOPARENT(Attachment)
Attachment::Attachment(const String &name) : _name(name) {
assert(_name.length() > 0);

View File

@ -40,7 +40,7 @@
using namespace Spine;
RTTI_IMPL_NOPARENT(AttachmentLoader);
RTTI_IMPL_NOPARENT(AttachmentLoader)
AttachmentLoader::AttachmentLoader() {
}

View File

@ -40,7 +40,7 @@
using namespace Spine;
RTTI_IMPL(AttachmentTimeline, Timeline);
RTTI_IMPL(AttachmentTimeline, Timeline)
AttachmentTimeline::AttachmentTimeline(int frameCount) : Timeline(), _slotIndex(0) {
_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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(alpha);
assert(_slotIndex < skeleton._slots.size());
String *attachmentName;
@ -76,10 +80,10 @@ void AttachmentTimeline::apply(Skeleton &skeleton, float lastTime, float time, V
return;
}
int frameIndex;
size_t frameIndex;
if (time >= _frames[_frames.size() - 1]) {
// Time is after last frame.
frameIndex = static_cast<int>(_frames.size()) - 1;
frameIndex = _frames.size() - 1;
} else {
frameIndex = Animation::binarySearch(_frames, time, 1) - 1;
}

View File

@ -35,7 +35,7 @@
using namespace Spine;
RTTI_IMPL(Bone, Updatable);
RTTI_IMPL(Bone, Updatable)
bool Bone::yDown = false;
@ -68,9 +68,9 @@ Bone::Bone(BoneData &data, Skeleton &skeleton, Bone *parent) : Updatable(),
_appliedValid(false),
_a(1),
_b(0),
_worldX(0),
_c(0),
_d(1),
_worldX(0),
_worldY(0),
_sorted(false) {
setToSetupPose();

View File

@ -32,7 +32,7 @@
using namespace Spine;
RTTI_IMPL(BoundingBoxAttachment, VertexAttachment);
RTTI_IMPL(BoundingBoxAttachment, VertexAttachment)
BoundingBoxAttachment::BoundingBoxAttachment(const String &name) : VertexAttachment(name) {
}

View File

@ -34,7 +34,7 @@
using namespace Spine;
RTTI_IMPL(ClippingAttachment, VertexAttachment);
RTTI_IMPL(ClippingAttachment, VertexAttachment)
ClippingAttachment::ClippingAttachment(const String &name) : VertexAttachment(name), _endSlot(NULL) {
}

View File

@ -40,7 +40,7 @@
using namespace Spine;
RTTI_IMPL(ColorTimeline, CurveTimeline);
RTTI_IMPL(ColorTimeline, CurveTimeline)
const int ColorTimeline::ENTRIES = 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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Slot *slotP = skeleton._slots[_slotIndex];
Slot &slot = *slotP;
if (time < _frames[0]) {
SlotData &slotData = slot._data;
switch (blend) {
case MixBlend_Setup:
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;
if (time >= _frames[_frames.size() - ENTRIES]) {
// Time is after last frame.
int i = static_cast<int>(_frames.size());
size_t i = _frames.size();
r = _frames[i + PREV_R];
g = _frames[i + PREV_G];
b = _frames[i + PREV_B];
a = _frames[i + PREV_A];
} else {
// 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];
g = _frames[frame + PREV_G];
b = _frames[frame + PREV_B];

View File

@ -32,7 +32,7 @@
using namespace Spine;
RTTI_IMPL(Constraint, Updatable);
RTTI_IMPL(Constraint, Updatable)
Constraint::Constraint() {
}

View File

@ -34,7 +34,7 @@
using namespace Spine;
RTTI_IMPL(CurveTimeline, Timeline);
RTTI_IMPL(CurveTimeline, Timeline)
const float CurveTimeline::LINEAR = 0;
const float CurveTimeline::STEPPED = 1;
@ -50,29 +50,29 @@ CurveTimeline::CurveTimeline(int frameCount) {
CurveTimeline::~CurveTimeline() {
}
int CurveTimeline::getFrameCount() {
return static_cast<int>(_curves.size() / BEZIER_SIZE + 1);
size_t CurveTimeline::getFrameCount() {
return _curves.size() / BEZIER_SIZE + 1;
}
void CurveTimeline::setLinear(int frameIndex) {
void CurveTimeline::setLinear(size_t frameIndex) {
_curves[frameIndex * BEZIER_SIZE] = LINEAR;
}
void CurveTimeline::setStepped(int frameIndex) {
void CurveTimeline::setStepped(size_t frameIndex) {
_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 dddfx = ((cx1 - cx2) * 3 + 1) * 0.006f, dddfy = ((cy1 - cy2) * 3 + 1) * 0.006f;
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;
int i = frameIndex * BEZIER_SIZE;
size_t i = frameIndex * BEZIER_SIZE;
_curves[i++] = BEZIER;
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 + 1] = y;
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);
int i = frameIndex * BEZIER_SIZE;
size_t i = frameIndex * BEZIER_SIZE;
float type = _curves[i];
if (type == LINEAR) {
@ -99,7 +99,7 @@ float CurveTimeline::getCurvePercent(int frameIndex, float percent) {
i++;
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];
if (x >= percent) {
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.
}
float CurveTimeline::getCurveType(int frameIndex) {
float CurveTimeline::getCurveType(size_t frameIndex) {
return _curves[frameIndex * BEZIER_SIZE];
}

View File

@ -42,7 +42,7 @@
using namespace Spine;
RTTI_IMPL(DeformTimeline, CurveTimeline);
RTTI_IMPL(DeformTimeline, CurveTimeline)
DeformTimeline::DeformTimeline(int frameCount) : CurveTimeline(frameCount), _slotIndex(0), _attachment(NULL) {
_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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Slot *slotP = skeleton._slots[_slotIndex];
Slot &slot = *slotP;
@ -77,7 +81,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
}
Vector< Vector<float> > &frameVertices = _frameVertices;
int vertexCount = static_cast<int>(frameVertices[0].size());
size_t vertexCount = frameVertices[0].size();
Vector<float> &frames = _frames;
if (time < _frames[0]) {
@ -85,7 +89,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
case MixBlend_Setup:
verticesArray.clear();
return;
case MixBlend_First:
case MixBlend_First: {
if (alpha == 1) {
verticesArray.clear();
return;
@ -95,17 +99,20 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions.
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;
} else {
// Weighted deform offsets.
alpha = 1 - alpha;
for (int i = 0; i < vertexCount; i++)
for (size_t i = 0; i < vertexCount; i++)
vertices[i] *= alpha;
}
}
case MixBlend_Replace:
case MixBlend_Add:
return;
}
}
verticesArray.setSize(vertexCount, 0);
Vector<float> &vertices = verticesArray;
@ -118,11 +125,11 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, no alpha.
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];
} else {
// Weighted deform offsets, no alpha.
for (int i = 0; i < vertexCount; i++)
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += lastVertices[i];
}
} else {
@ -136,13 +143,13 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, with alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (int i = 0; i < vertexCount; i++) {
for (size_t i = 0; i < vertexCount; i++) {
float setup = setupVertices[i];
vertices[i] = setup + (lastVertices[i] - setup) * alpha;
}
} else {
// 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;
}
break;
@ -150,7 +157,7 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
case MixBlend_First:
case MixBlend_Replace:
// 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;
break;
case MixBlend_Add:
@ -158,11 +165,11 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, no alpha.
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;
} else {
// Weighted deform offsets, alpha.
for (int i = 0; i < vertexCount; i++)
for (size_t i = 0; i < vertexCount; i++)
vertices[i] += lastVertices[i] * alpha;
}
}
@ -183,20 +190,20 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
if (vertexAttachment->getBones().size() == 0) {
// Unweighted vertex positions, no alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (int i = 0; i < vertexCount; i++) {
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += prev + (nextVertices[i] - prev) * percent - setupVertices[i];
}
} else {
// Weighted deform offsets, no alpha.
for (int i = 0; i < vertexCount; i++) {
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += prev + (nextVertices[i] - prev) * percent;
}
}
} else {
// 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];
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) {
// Unweighted vertex positions, with alpha.
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];
vertices[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
}
} else {
// Weighted deform offsets, with alpha.
for (int i = 0; i < vertexCount; i++) {
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
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_Replace:
// 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];
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) {
// Unweighted vertex positions, with alpha.
Vector<float> &setupVertices = vertexAttachment->getVertices();
for (int i = 0; i < vertexCount; i++) {
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
}
} else {
// Weighted deform offsets, with alpha.
for (int i = 0; i < vertexCount; i++) {
for (size_t i = 0; i < vertexCount; i++) {
float prev = prevVertices[i];
vertices[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
}

View File

@ -40,7 +40,7 @@
using namespace Spine;
RTTI_IMPL(DrawOrderTimeline, Timeline);
RTTI_IMPL(DrawOrderTimeline, Timeline)
DrawOrderTimeline::DrawOrderTimeline(int frameCount) : Timeline() {
_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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(alpha);
Vector<Slot *> &drawOrder = skeleton._drawOrder;
Vector<Slot *> &slots = skeleton._slots;
if (direction == MixDirection_Out && blend == MixBlend_Setup) {
drawOrder.clear();
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]);
}
return;
@ -71,29 +75,29 @@ void DrawOrderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Ve
if (blend == MixBlend_Setup || blend == MixBlend_First) {
drawOrder.clear();
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]);
}
}
return;
}
int frame;
size_t frame;
if (time >= _frames[_frames.size() - 1]) {
// Time is after last frame.
frame = static_cast<int>(_frames.size()) - 1;
frame = _frames.size() - 1;
} else {
frame = Animation::binarySearch(_frames, time) - 1;
frame = (size_t)Animation::binarySearch(_frames, time) - 1;
}
Vector<int> &drawOrderToSetupIndex = _drawOrders[frame];
if (drawOrderToSetupIndex.size() == 0) {
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]);
}
} 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]];
}
}
@ -103,7 +107,7 @@ int DrawOrderTimeline::getPropertyId() {
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;
_drawOrders[frameIndex].clear();
_drawOrders[frameIndex].addAll(drawOrder);
@ -117,6 +121,6 @@ Vector<Vector<int> > &DrawOrderTimeline::getDrawOrders() {
return _drawOrders;
}
int DrawOrderTimeline::getFrameCount() {
return static_cast<int>(_frames.size());
size_t DrawOrderTimeline::getFrameCount() {
return _frames.size();
}

View File

@ -42,7 +42,7 @@
using namespace Spine;
RTTI_IMPL(EventTimeline, Timeline);
RTTI_IMPL(EventTimeline, Timeline)
EventTimeline::EventTimeline(int frameCount) : Timeline() {
_frames.setSize(frameCount, 0);
@ -65,7 +65,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
return;
}
int frameCount = static_cast<int>(_frames.size());
size_t frameCount = _frames.size();
if (lastTime > time) {
// 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]);
}
}
@ -104,7 +104,7 @@ int EventTimeline::getPropertyId() {
return ((int) TimelineType_Event << 24);
}
void EventTimeline::setFrame(int frameIndex, Event *event) {
void EventTimeline::setFrame(size_t frameIndex, Event *event) {
_frames[frameIndex] = event->getTime();
_events[frameIndex] = event;
}
@ -113,4 +113,4 @@ Vector<float> EventTimeline::getFrames() { return _frames; }
Vector<Event *> &EventTimeline::getEvents() { return _events; }
int EventTimeline::getFrameCount() { return static_cast<int>(_frames.size()); }
size_t EventTimeline::getFrameCount() { return _frames.size(); }

View File

@ -60,6 +60,9 @@ DefaultSpineExtension::~DefaultSpineExtension() {
}
void *DefaultSpineExtension::_alloc(size_t size, const char *file, int line) {
SP_UNUSED(file);
SP_UNUSED(line);
if (size == 0)
return 0;
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) {
SP_UNUSED(file);
SP_UNUSED(line);
if (size == 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) {
SP_UNUSED(file);
SP_UNUSED(line);
void *mem = NULL;
if (size == 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) {
SP_UNUSED(file);
SP_UNUSED(line);
::free(mem);
}

View File

@ -38,7 +38,7 @@
using namespace Spine;
RTTI_IMPL(IkConstraint, Constraint);
RTTI_IMPL(IkConstraint, Constraint)
void IkConstraint::apply(Bone &bone, float targetX, float targetY, float alpha) {
Bone *p = bone.getParent();

View File

@ -46,11 +46,11 @@ const String &IkConstraintData::getName() {
return _name;
}
int IkConstraintData::getOrder() {
size_t IkConstraintData::getOrder() {
return _order;
}
void IkConstraintData::setOrder(int inValue) {
void IkConstraintData::setOrder(size_t inValue) {
_order = inValue;
}

View File

@ -42,7 +42,7 @@
using namespace Spine;
RTTI_IMPL(IkConstraintTimeline, CurveTimeline);
RTTI_IMPL(IkConstraintTimeline, CurveTimeline)
const int IkConstraintTimeline::ENTRIES = 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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
IkConstraint *constraintP = skeleton._ikConstraints[_ikConstraintIndex];
IkConstraint &constraint = *constraintP;
if (time < _frames[0]) {

View File

@ -377,7 +377,7 @@ const char *Json::parseNumber(Json *item, const char *num) {
if (ptr != num) {
/* Parse success, number found. */
item->_valueFloat = (float)result;
item->_valueInt = static_cast<int>(result);
item->_valueInt = (int)result;
item->_type = JSON_NUMBER;
return ptr;
} else {

View File

@ -32,7 +32,7 @@
using namespace Spine;
RTTI_IMPL(MeshAttachment, VertexAttachment);
RTTI_IMPL(MeshAttachment, VertexAttachment)
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name),
_regionOffsetX(0),

View File

@ -32,7 +32,7 @@
using namespace Spine;
RTTI_IMPL(PathAttachment, VertexAttachment);
RTTI_IMPL(PathAttachment, VertexAttachment)
PathAttachment::PathAttachment(const String &name) : VertexAttachment(name), _closed(false), _constantSpeed(false) {
}

View File

@ -41,7 +41,7 @@
using namespace Spine;
RTTI_IMPL(PathConstraint, Constraint);
RTTI_IMPL(PathConstraint, Constraint)
const float PathConstraint::EPSILON = 0.00001f;
const int PathConstraint::NONE = -1;
@ -90,7 +90,7 @@ void PathConstraint::update() {
RotateMode rotateMode = data._rotateMode;
bool tangents = rotateMode == RotateMode_Tangent, scale = rotateMode == RotateMode_ChainScale;
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);
float spacing = _spacing;
if (scale || !percentSpacing) {
@ -99,7 +99,7 @@ void PathConstraint::update() {
}
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 &bone = *boneP;
float setupLength = bone._data.getLength();
@ -127,7 +127,7 @@ void PathConstraint::update() {
}
}
} else {
for (int i = 1; i < spacesCount; ++i) {
for (size_t i = 1; i < spacesCount; ++i) {
_spaces[i] = spacing;
}
}

View File

@ -42,7 +42,7 @@
using namespace Spine;
RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline);
RTTI_IMPL(PathConstraintMixTimeline, CurveTimeline)
const int PathConstraintMixTimeline::ENTRIES = 3;
const int PathConstraintMixTimeline::PREV_TIME = -3;
@ -59,6 +59,10 @@ PathConstraintMixTimeline::PathConstraintMixTimeline(int frameCount) : CurveTime
void
PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
PathConstraint &constraint = *constraintP;
if (time < _frames[0]) {

View File

@ -42,7 +42,7 @@
using namespace Spine;
RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline);
RTTI_IMPL(PathConstraintPositionTimeline, CurveTimeline)
const int PathConstraintPositionTimeline::ENTRIES = 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,
float alpha, MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
PathConstraint &constraint = *constraintP;
if (time < _frames[0]) {

View File

@ -42,7 +42,7 @@
using namespace Spine;
RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline);
RTTI_IMPL(PathConstraintSpacingTimeline, PathConstraintPositionTimeline)
PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(int frameCount) : PathConstraintPositionTimeline(
frameCount) {
@ -50,6 +50,10 @@ PathConstraintSpacingTimeline::PathConstraintSpacingTimeline(int frameCount) : P
void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents,
float alpha, MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
PathConstraint *constraintP = skeleton._pathConstraints[_pathConstraintIndex];
PathConstraint &constraint = *constraintP;
if (time < _frames[0]) {

View File

@ -36,7 +36,7 @@
using namespace Spine;
RTTI_IMPL(PointAttachment, Attachment);
RTTI_IMPL(PointAttachment, Attachment)
PointAttachment::PointAttachment(const String &name) : Attachment(name), _x(0), _y(0), _rotation(0) {
}

View File

@ -36,7 +36,7 @@
using namespace Spine;
RTTI_IMPL(RegionAttachment, Attachment);
RTTI_IMPL(RegionAttachment, Attachment)
const int RegionAttachment::BLX = 0;
const int RegionAttachment::BLY = 1;

View File

@ -40,7 +40,7 @@
using namespace Spine;
RTTI_IMPL(RotateTimeline, CurveTimeline);
RTTI_IMPL(RotateTimeline, CurveTimeline)
RotateTimeline::RotateTimeline(int frameCount) : CurveTimeline(frameCount), _boneIndex(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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Bone *bone = skeleton.getBones()[_boneIndex];
if (time < _frames[0]) {

View File

@ -40,13 +40,16 @@
using namespace Spine;
RTTI_IMPL(ScaleTimeline, TranslateTimeline);
RTTI_IMPL(ScaleTimeline, TranslateTimeline)
ScaleTimeline::ScaleTimeline(int frameCount) : TranslateTimeline(frameCount) {
}
void ScaleTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
Bone *boneP = skeleton._bones[_boneIndex];
Bone &bone = *boneP;

View File

@ -40,13 +40,17 @@
using namespace Spine;
RTTI_IMPL(ShearTimeline, TranslateTimeline);
RTTI_IMPL(ShearTimeline, TranslateTimeline)
ShearTimeline::ShearTimeline(int frameCount) : TranslateTimeline(frameCount) {
}
void ShearTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Bone *boneP = skeleton._bones[_boneIndex];
Bone &bone = *boneP;

View File

@ -131,20 +131,20 @@ void Skeleton::updateCache() {
_updateCache.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;
}
int ikCount = static_cast<int>(_ikConstraints.size());
int transformCount = static_cast<int>(_transformConstraints.size());
int pathCount = static_cast<int>(_pathConstraints.size());
size_t ikCount = _ikConstraints.size();
size_t transformCount = _transformConstraints.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:
for (; i < constraintCount; ++i) {
for (int ii = 0; ii < ikCount; ++ii) {
for (size_t ii = 0; ii < ikCount; ++ii) {
IkConstraint *constraint = _ikConstraints[ii];
if (constraint->getData().getOrder() == i) {
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];
if (constraint->getData().getOrder() == i) {
if (constraint->getData().getOrder() == (int)i) {
sortTransformConstraint(constraint);
i++;
goto continue_outer;
}
}
for (int ii = 0; ii < pathCount; ++ii) {
for (size_t ii = 0; ii < pathCount; ++ii) {
PathConstraint *constraint = _pathConstraints[ii];
if (constraint->getData().getOrder() == i) {
if (constraint->getData().getOrder() == (int)i) {
sortPathConstraint(constraint);
i++;
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]);
}
}
@ -193,7 +193,7 @@ void Skeleton::printUpdateCache() {
}
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 &bone = *boneP;
bone._ax = bone._x;
@ -206,7 +206,7 @@ void Skeleton::updateWorldTransform() {
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();
}
}
@ -217,11 +217,11 @@ void Skeleton::setToSetupPose() {
}
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();
}
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 &constraint = *constraintP;
@ -229,7 +229,7 @@ void Skeleton::setBonesToSetupPose() {
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 &constraint = *constraintP;
TransformConstraintData &constraintData = constraint._data;
@ -240,7 +240,7 @@ void Skeleton::setBonesToSetupPose() {
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 &constraint = *constraintP;
PathConstraintData &constraintData = constraint._data;
@ -254,11 +254,11 @@ void Skeleton::setBonesToSetupPose() {
void Skeleton::setSlotsToSetupPose() {
_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]);
}
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();
}
}
@ -293,7 +293,7 @@ void Skeleton::setSkin(Skin *newSkin) {
Skeleton &thisRef = *this;
newSkin->attachAll(thisRef, *_skin);
} 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 &slot = *slotP;
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) {
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];
if (slot->_data.getName() == slotName) {
Attachment *attachment = NULL;
@ -354,7 +354,7 @@ void Skeleton::setAttachment(const String &slotName, const String &attachmentNam
IkConstraint *Skeleton::findIkConstraint(const String &constraintName) {
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];
if (ikConstraint->_data.getName() == constraintName) {
return ikConstraint;
@ -366,7 +366,7 @@ IkConstraint *Skeleton::findIkConstraint(const String &constraintName) {
TransformConstraint *Skeleton::findTransformConstraint(const String &constraintName) {
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];
if (transformConstraint->_data.getName() == constraintName) {
return transformConstraint;
@ -379,7 +379,7 @@ TransformConstraint *Skeleton::findTransformConstraint(const String &constraintN
PathConstraint *Skeleton::findPathConstraint(const String &constraintName) {
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];
if (constraint->_data.getName() == constraintName) {
return constraint;
@ -601,7 +601,7 @@ void Skeleton::sortTransformConstraint(TransformConstraint *constraint) {
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();
while (attachments.hasNext()) {

View File

@ -880,24 +880,24 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
bool weighted = attachment->_bones.size() > 0;
Vector<float> &vertices = attachment->_vertices;
int deformLength = weighted ? static_cast<int>(vertices.size()) / 3 * 2
: static_cast<int>(vertices.size());
size_t deformLength = weighted ? vertices.size() / 3 * 2
: vertices.size();
int frameCount = readVarint(input, true);
size_t frameCount = (size_t)readVarint(input, true);
DeformTimeline *timeline = new(__FILE__, __LINE__) DeformTimeline(frameCount);
timeline->_slotIndex = slotIndex;
timeline->_attachment = attachment;
for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
for (size_t frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
float time = readFloat(input);
Vector<float> deform;
int end = readVarint(input, true);
size_t end = (size_t)readVarint(input, true);
if (end == 0) {
if (weighted) {
deform.setSize(deformLength, 0);
for (int i = 0; i < deformLength; ++i) {
for (size_t i = 0; i < deformLength; ++i) {
deform[i] = 0;
}
} else {
@ -905,20 +905,20 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
}
} else {
deform.setSize(deformLength, 0);
int start = readVarint(input, true);
size_t start = (size_t)readVarint(input, true);
end += start;
if (scale == 1) {
for (int v = start; v < end; ++v) {
for (size_t v = start; v < end; ++v) {
deform[v] = readFloat(input);
}
} else {
for (int v = start; v < end; ++v) {
for (size_t v = start; v < end; ++v) {
deform[v] = readFloat(input) * scale;
}
}
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];
}
}
@ -937,33 +937,33 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
}
// Draw order timeline.
int drawOrderCount = readVarint(input, true);
size_t drawOrderCount = (size_t)readVarint(input, true);
if (drawOrderCount > 0) {
DrawOrderTimeline *timeline = new(__FILE__, __LINE__) DrawOrderTimeline(drawOrderCount);
int slotCount = static_cast<int>(skeletonData->_slots.size());
for (int i = 0; i < drawOrderCount; ++i) {
size_t slotCount = skeletonData->_slots.size();
for (size_t i = 0; i < drawOrderCount; ++i) {
float time = readFloat(input);
int offsetCount = readVarint(input, true);
size_t offsetCount = (size_t)readVarint(input, true);
Vector<int> drawOrder;
drawOrder.setSize(slotCount, 0);
for (int ii = slotCount - 1; ii >= 0; --ii) {
for (int ii = (int)slotCount - 1; ii >= 0; --ii) {
drawOrder[ii] = -1;
}
Vector<int> unchanged;
unchanged.setSize(slotCount - offsetCount, 0);
int originalIndex = 0, unchangedIndex = 0;
for (int ii = 0; ii < offsetCount; ++ii) {
int slotIndex = readVarint(input, true);
size_t originalIndex = 0, unchangedIndex = 0;
for (size_t ii = 0; ii < offsetCount; ++ii) {
size_t slotIndex = (size_t)readVarint(input, true);
// Collect unchanged items.
while (originalIndex != slotIndex) {
unchanged[unchangedIndex++] = originalIndex++;
}
// Set changed items.
int index = originalIndex;
drawOrder[index + readVarint(input, true)] = originalIndex++;
size_t index = originalIndex;
drawOrder[index + (size_t)readVarint(input, true)] = originalIndex++;
}
// Collect remaining unchanged items.
@ -972,7 +972,7 @@ Animation *SkeletonBinary::readAnimation(const String &name, DataInput *input, S
}
// 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) {
drawOrder[ii] = unchanged[--unchangedIndex];
}

View File

@ -42,16 +42,16 @@ SkeletonBounds::SkeletonBounds() : _minX(0), _minY(0), _maxX(0), _maxY(0) {
void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
Vector<Slot *> &slots = skeleton._slots;
int slotCount = static_cast<int>(slots.size());
size_t slotCount = slots.size();
_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]);
}
_polygons.clear();
for (int i = 0; i < slotCount; i++) {
for (size_t i = 0; i < slotCount; i++) {
Slot *slot = slots[i];
Attachment *attachment = slot->_attachment;
if (attachment == NULL || !attachment->getRTTI().instanceOf(BoundingBoxAttachment::rtti)) {
@ -61,12 +61,12 @@ void SkeletonBounds::update(Skeleton &skeleton, bool updateAabb) {
_boundingBoxes.add(boundingBox);
Polygon *polygonP = NULL;
int poolCount = static_cast<int>(_polygonPool.size());
size_t poolCount = _polygonPool.size();
if (poolCount > 0) {
polygonP = _polygonPool[poolCount - 1];
_polygonPool.removeAt(poolCount - 1);
} else {
Polygon *polygonP = new(__FILE__, __LINE__) Polygon();
polygonP = new(__FILE__, __LINE__) Polygon();
}
_polygons.add(polygonP);
@ -151,7 +151,7 @@ bool SkeletonBounds::containsPoint(Polygon *polygon, 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)) {
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) {
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)) {
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) {
Vector<float> &vertices = polygon->_vertices;
int nn = polygon->_count;
size_t nn = polygon->_count;
float width12 = x1 - x2, height12 = y1 - y2;
float det1 = x1 * y2 - y1 * x2;
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 det2 = x3 * y4 - y3 * x4;
float width34 = x3 - x4, height34 = y3 - y4;

View File

@ -42,7 +42,7 @@ SkeletonClipping::SkeletonClipping() : _clipAttachment(NULL) {
_clippedUVs.ensureCapacity(128);
}
int SkeletonClipping::clipStart(Slot &slot, ClippingAttachment *clip) {
size_t SkeletonClipping::clipStart(Slot &slot, ClippingAttachment *clip) {
if (_clipAttachment != NULL) {
return 0;
}
@ -63,7 +63,7 @@ int SkeletonClipping::clipStart(Slot &slot, ClippingAttachment *clip) {
polygon.add(polygon[1]);
}
return static_cast<int>((*_clippingPolygons).size());
return (*_clippingPolygons).size();
}
void SkeletonClipping::clipEnd(Slot &slot) {
@ -85,20 +85,22 @@ void SkeletonClipping::clipEnd() {
_clippingPolygon.clear();
}
void SkeletonClipping::clipTriangles(Vector<float> &vertices, int verticesLength, Vector<unsigned short> &triangles,
int trianglesLength, Vector<float> &uvs) {
void SkeletonClipping::clipTriangles(Vector<float> &vertices, size_t verticesLength, Vector<unsigned short> &triangles,
size_t trianglesLength, Vector<float> &uvs) {
SP_UNUSED(verticesLength);
Vector<float> &clipOutput = _clipOutput;
Vector<float> &clippedVertices = _clippedVertices;
Vector<unsigned short> &clippedTriangles = _clippedTriangles;
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();
_clippedUVs.clear();
clippedTriangles.clear();
int i = 0;
size_t i = 0;
continue_outer:
for (; i < trianglesLength; i += 3) {
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 u3 = uvs[vertexOffset], v3 = uvs[vertexOffset + 1];
for (int p = 0; p < polygonsCount; p++) {
int s = static_cast<int>(clippedVertices.size());
for (size_t p = 0; p < polygonsCount; p++) {
size_t s = clippedVertices.size();
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) {
continue;
}
float d0 = y2 - y3, d1 = x3 - x2, d2 = x1 - x3, d4 = y3 - y1;
float d = 1 / (d0 * d2 + d1 * (y1 - y3));
int clipOutputCount = clipOutputLength >> 1;
size_t clipOutputCount = clipOutputLength >> 1;
clippedVertices.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];
clippedVertices[s] = x;
clippedVertices[s + 1] = y;
@ -139,10 +141,10 @@ void SkeletonClipping::clipTriangles(Vector<float> &vertices, int verticesLength
s += 2;
}
s = static_cast<int>(clippedTriangles.size());
s = clippedTriangles.size();
clippedTriangles.setSize(s + 3 * (clipOutputCount - 2), 0);
clipOutputCount--;
for (int ii = 1; ii < clipOutputCount; ii++) {
for (size_t ii = 1; ii < clipOutputCount; ii++) {
clippedTriangles[s] = index;
clippedTriangles[s + 1] = index + ii;
clippedTriangles[s + 2] = index + ii + 1;
@ -166,7 +168,7 @@ void SkeletonClipping::clipTriangles(Vector<float> &vertices, int verticesLength
_clippedUVs[s + 4] = u3;
_clippedUVs[s + 5] = v3;
s = static_cast<int>(clippedTriangles.size());
s = clippedTriangles.size();
clippedTriangles.setSize(s + 3, 0);
clippedTriangles[s] = index;
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();
Vector<float> &clippingVertices = *clippingArea;
int clippingVerticesLast = static_cast<int>(clippingArea->size()) - 4;
for (int i = 0;; i += 2) {
size_t clippingVerticesLast = clippingArea->size() - 4;
for (size_t i = 0;; i += 2) {
float edgeX = clippingVertices[i], edgeY = clippingVertices[i + 1];
float edgeX2 = clippingVertices[i + 2], edgeY2 = clippingVertices[i + 3];
float deltaX = edgeX - edgeX2, deltaY = edgeY - edgeY2;
Vector<float> &inputVertices = *input;
int inputVerticesLength = static_cast<int>(input->size()) - 2, outputStart = static_cast<int>(output->size());
for (int ii = 0; ii < inputVerticesLength; ii += 2) {
size_t inputVerticesLength = input->size() - 2, outputStart = output->size();
for (size_t ii = 0; ii < inputVerticesLength; ii += 2) {
float inputX = inputVertices[ii], inputY = inputVertices[ii + 1];
float inputX2 = inputVertices[ii + 2], inputY2 = inputVertices[ii + 3];
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) {
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]);
}
} 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) {
int verticeslength = static_cast<int>(polygon.size());
size_t verticeslength = polygon.size();
float area =
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];
p1y = polygon[i + 1];
p2x = polygon[i + 2];
@ -307,7 +309,7 @@ void SkeletonClipping::makeClockwise(Vector<float> &polygon) {
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];
int other = lastX - i;
polygon[i] = polygon[other];

View File

@ -623,7 +623,7 @@ SkeletonData *SkeletonJson::readSkeletonData(const char *json) {
}
/* 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];
Skin *skin = linkedMesh->_skin.length() == 0 ? skeletonData->getDefaultSkin() : skeletonData->findSkin(
linkedMesh->_skin);
@ -907,7 +907,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
IkConstraintData *constraint = skeletonData->findIkConstraint(constraintMap->_name);
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]) {
timeline->_ikConstraintIndex = frameIndex;
break;
@ -1036,7 +1036,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
weighted = attachment->_bones.size() != 0;
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);
@ -1100,7 +1100,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
drawOrder2.ensureCapacity(skeletonData->_slots.size());
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;
}
@ -1112,7 +1112,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
return NULL;
}
/* Collect unchanged items. */
while (originalIndex != slotIndex) {
while (originalIndex != (size_t)slotIndex) {
unchanged[unchangedIndex++] = originalIndex++;
}
/* Set changed items. */
@ -1124,7 +1124,7 @@ Animation *SkeletonJson::readAnimation(Json *root, SkeletonData *skeletonData) {
unchanged[unchangedIndex++] = originalIndex++;
}
/* 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) {
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) {
Json *entry;
int i, n, nn, entrySize;
size_t i, n, nn, entrySize;
Vector<float> vertices;
attachment->setWorldVerticesLength(verticesLength);

View File

@ -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) {
SP_UNUSED(sz);
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) {
SP_UNUSED(mem);
SpineExtension::free(p, __FILE__, __LINE__);
}

View File

@ -34,7 +34,7 @@
#include <spine/Event.h>
namespace Spine {
RTTI_IMPL_NOPARENT(Timeline);
RTTI_IMPL_NOPARENT(Timeline)
Timeline::Timeline() {
}

View File

@ -38,7 +38,7 @@
using namespace Spine;
RTTI_IMPL(TransformConstraint, Constraint);
RTTI_IMPL(TransformConstraint, Constraint)
TransformConstraint::TransformConstraint(TransformConstraintData &data, Skeleton &skeleton) : Constraint(),
_data(data),

View File

@ -42,7 +42,7 @@
using namespace Spine;
RTTI_IMPL(TransformConstraintTimeline, CurveTimeline);
RTTI_IMPL(TransformConstraintTimeline, CurveTimeline)
const int TransformConstraintTimeline::ENTRIES = 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,
float alpha, MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
TransformConstraint *constraintP = skeleton._transformConstraints[_transformConstraintIndex];
TransformConstraint &constraint = *constraintP;
@ -87,7 +91,7 @@ void TransformConstraintTimeline::apply(Skeleton &skeleton, float lastTime, floa
float rotate, translate, scale, shear;
if (time >= _frames[_frames.size() - ENTRIES]) {
// Time is after last frame.
int i = static_cast<int>(_frames.size());
size_t i = _frames.size();
rotate = _frames[i + PREV_ROTATE];
translate = _frames[i + PREV_TRANSLATE];
scale = _frames[i + PREV_SCALE];
@ -128,7 +132,7 @@ int TransformConstraintTimeline::getPropertyId() {
}
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) {
frameIndex *= ENTRIES;
_frames[frameIndex] = time;

View File

@ -40,7 +40,7 @@
using namespace Spine;
RTTI_IMPL(TranslateTimeline, CurveTimeline);
RTTI_IMPL(TranslateTimeline, CurveTimeline)
const int TranslateTimeline::ENTRIES = 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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Bone *boneP = skeleton._bones[_boneIndex];
Bone &bone = *boneP;

View File

@ -40,30 +40,30 @@ Triangulator::~Triangulator() {
}
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;
indices.clear();
indices.ensureCapacity(vertexCount);
indices.setSize(vertexCount, 0);
for (int i = 0; i < vertexCount; ++i) {
for (size_t i = 0; i < vertexCount; ++i) {
indices[i] = i;
}
Vector<bool> &isConcaveArray = _isConcaveArray;
isConcaveArray.ensureCapacity(vertexCount);
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);
}
Vector<int> &triangles = _triangles;
triangles.clear();
triangles.ensureCapacity(MathUtil::max(0, vertexCount - 2) << 2);
triangles.ensureCapacity(MathUtil::max((int)0, (int)vertexCount - 2) << 2);
while (vertexCount > 3) {
// Find ear tip.
int previous = vertexCount - 1, i = 0, next = 1;
size_t previous = vertexCount - 1, i = 0, next = 1;
// outer:
while (true) {
@ -72,7 +72,7 @@ Vector<int> &Triangulator::triangulate(Vector<float> &vertices) {
float p1x = vertices[p1], p1y = vertices[p1 + 1];
float p2x = vertices[p2], p2y = vertices[p2 + 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]) {
continue;
}
@ -264,7 +264,7 @@ Vector<Vector<float> *> &Triangulator::decompose(Vector<float> &vertices, Vector
}
// 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];
if (polygon->size() == 0) {
convexPolygons.removeAt(i);

View File

@ -40,7 +40,7 @@
using namespace Spine;
RTTI_IMPL(TwoColorTimeline, CurveTimeline);
RTTI_IMPL(TwoColorTimeline, CurveTimeline)
const int TwoColorTimeline::ENTRIES = 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,
MixBlend blend, MixDirection direction) {
SP_UNUSED(lastTime);
SP_UNUSED(pEvents);
SP_UNUSED(direction);
Slot *slotP = skeleton._slots[_slotIndex];
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;
if (time >= _frames[_frames.size() - ENTRIES]) {
// Time is after last frame.
int i = static_cast<int>(_frames.size());
size_t i = _frames.size();
r = _frames[i + PREV_R];
g = _frames[i + PREV_G];
b = _frames[i + PREV_B];
@ -107,7 +111,7 @@ void TwoColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vec
b2 = _frames[i + PREV_B2];
} else {
// 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];
g = _frames[frame + PREV_G];
b = _frames[frame + PREV_B];

View File

@ -32,7 +32,7 @@
using namespace Spine;
RTTI_IMPL_NOPARENT(Updatable);
RTTI_IMPL_NOPARENT(Updatable)
Updatable::Updatable() {
}

View File

@ -37,7 +37,7 @@
using namespace Spine;
RTTI_IMPL(VertexAttachment, Attachment);
RTTI_IMPL(VertexAttachment, Attachment)
VertexAttachment::VertexAttachment(const String &name) : Attachment(name), _worldVerticesLength(0), _id(getNextID()) {
}

View File

@ -38,9 +38,14 @@ JitterVertexEffect::JitterVertexEffect(float jitterX, float jitterY): _jitterX(j
}
void JitterVertexEffect::begin(Skeleton &skeleton) {
SP_UNUSED(skeleton);
}
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 jitterY = _jitterY;
x += MathUtil::randomTriangular(-jitterX, jitterX);
@ -67,13 +72,13 @@ float JitterVertexEffect::getJitterY() {
}
SwirlVertexEffect::SwirlVertexEffect(float radius, Interpolation &interpolation):
_radius(radius),
_interpolation(interpolation),
_centerY(0),
_centerX(0),
_centerY(0),
_radius(radius),
_angle(0),
_worldX(0),
_worldY(0),
_angle(0) {
_interpolation(interpolation) {
}
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) {
SP_UNUSED(u);
SP_UNUSED(v);
SP_UNUSED(light);
SP_UNUSED(dark);
float x = positionX - _worldX;
float y = positionY - _worldY;
float dist = (float)MathUtil::sqrt(x * x + y * y);

View File

@ -53,7 +53,7 @@ namespace Spine {
SkeletonDrawable::SkeletonDrawable(SkeletonData *skeletonData, AnimationStateData *stateData) :
timeScale(1),
vertexArray(new VertexArray(Triangles, skeletonData->getBones().size() * 4)),
worldVertices(), clipper(), vertexEffect(NULL) {
vertexEffect(NULL), worldVertices(), clipper() {
Bone::setYDown(true);
worldVertices.ensureCapacity(SPINE_MESH_VERTEX_COUNT_MAX);
skeleton = new(__FILE__, __LINE__) Skeleton(skeletonData);