mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
[all] Source clean up, formatting, and tabs for indentation.
This commit is contained in:
parent
2fa85fc1c6
commit
842dffbd83
@ -504,9 +504,9 @@ package spine.animation {
|
|||||||
var duration : Number = last.animationEnd - last.animationStart;
|
var duration : Number = last.animationEnd - last.animationStart;
|
||||||
if (duration != 0) {
|
if (duration != 0) {
|
||||||
if (last.loop)
|
if (last.loop)
|
||||||
delay += duration * (1 + (int)(last.trackTime / duration));
|
delay += duration * (1 + (int)(last.trackTime / duration));
|
||||||
else
|
else
|
||||||
delay += Math.max(duration, last.trackTime);
|
delay += Math.max(duration, last.trackTime);
|
||||||
} else
|
} else
|
||||||
delay = last.trackTime;
|
delay = last.trackTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,8 +81,8 @@ extern "C" {
|
|||||||
} \
|
} \
|
||||||
void name##_add(name* self, itemType value) { \
|
void name##_add(name* self, itemType value) { \
|
||||||
if (self->size == self->capacity) { \
|
if (self->size == self->capacity) { \
|
||||||
self->capacity = MAX(8, (int)(self->size * 1.75f)); \
|
self->capacity = MAX(8, (int)(self->size * 1.75f)); \
|
||||||
self->items = REALLOC(self->items, itemType, self->capacity); \
|
self->items = REALLOC(self->items, itemType, self->capacity); \
|
||||||
} \
|
} \
|
||||||
self->items[self->size++] = value; \
|
self->items[self->size++] = value; \
|
||||||
} \
|
} \
|
||||||
|
|||||||
@ -45,9 +45,9 @@ typedef struct spAttachmentLoader {
|
|||||||
const void* const vtable;
|
const void* const vtable;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
spAttachmentLoader () :
|
spAttachmentLoader () :
|
||||||
error1(0),
|
error1(0),
|
||||||
error2(0),
|
error2(0),
|
||||||
vtable(0) {
|
vtable(0) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} spAttachmentLoader;
|
} spAttachmentLoader;
|
||||||
|
|||||||
@ -89,7 +89,7 @@ struct _SkinHashTableEntry {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
spSkin super;
|
spSkin super;
|
||||||
_Entry* entries; /* entries list stored for getting attachment name by attachment index */
|
_Entry* entries; /* entries list stored for getting attachment name by attachment index */
|
||||||
_SkinHashTableEntry* entriesHashTable[SKIN_ENTRIES_HASH_TABLE_SIZE]; /* hashtable for fast attachment lookup */
|
_SkinHashTableEntry* entriesHashTable[SKIN_ENTRIES_HASH_TABLE_SIZE]; /* hashtable for fast attachment lookup */
|
||||||
} _spSkin;
|
} _spSkin;
|
||||||
|
|
||||||
SP_API spSkin* spSkin_create (const char* name);
|
SP_API spSkin* spSkin_create (const char* name);
|
||||||
|
|||||||
@ -43,7 +43,7 @@ struct spVertexEffect;
|
|||||||
typedef void (*spVertexEffectBegin)(struct spVertexEffect *self, spSkeleton *skeleton);
|
typedef void (*spVertexEffectBegin)(struct spVertexEffect *self, spSkeleton *skeleton);
|
||||||
|
|
||||||
typedef void (*spVertexEffectTransform)(struct spVertexEffect *self, float *x, float *y, float *u, float *v,
|
typedef void (*spVertexEffectTransform)(struct spVertexEffect *self, float *x, float *y, float *u, float *v,
|
||||||
spColor *light, spColor *dark);
|
spColor *light, spColor *dark);
|
||||||
|
|
||||||
typedef void (*spVertexEffectEnd)(struct spVertexEffect *self);
|
typedef void (*spVertexEffectEnd)(struct spVertexEffect *self);
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,8 @@ void spAnimation_dispose (spAnimation* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void spAnimation_apply (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events,
|
void spAnimation_apply (const spAnimation* self, spSkeleton* skeleton, float lastTime, float time, int loop, spEvent** events,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int i, n = self->timelinesCount;
|
int i, n = self->timelinesCount;
|
||||||
|
|
||||||
if (loop && self->duration) {
|
if (loop && self->duration) {
|
||||||
@ -66,15 +67,17 @@ void spAnimation_apply (const spAnimation* self, spSkeleton* skeleton, float las
|
|||||||
|
|
||||||
typedef struct _spTimelineVtable {
|
typedef struct _spTimelineVtable {
|
||||||
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction);
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction);
|
||||||
int (*getPropertyId) (const spTimeline* self);
|
int (*getPropertyId) (const spTimeline* self);
|
||||||
void (*dispose) (spTimeline* self);
|
void (*dispose) (spTimeline* self);
|
||||||
} _spTimelineVtable;
|
} _spTimelineVtable;
|
||||||
|
|
||||||
void _spTimeline_init (spTimeline* self, spTimelineType type, /**/
|
void _spTimeline_init (spTimeline* self, spTimelineType type, /**/
|
||||||
void (*dispose) (spTimeline* self), /**/
|
void (*dispose) (spTimeline* self), /**/
|
||||||
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction),
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int (*getPropertyId) (const spTimeline* self)) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction),
|
||||||
|
int (*getPropertyId) (const spTimeline* self)
|
||||||
|
) {
|
||||||
CONST_CAST(spTimelineType, self->type) = type;
|
CONST_CAST(spTimelineType, self->type) = type;
|
||||||
CONST_CAST(_spTimelineVtable*, self->vtable) = NEW(_spTimelineVtable);
|
CONST_CAST(_spTimelineVtable*, self->vtable) = NEW(_spTimelineVtable);
|
||||||
VTABLE(spTimeline, self)->dispose = dispose;
|
VTABLE(spTimeline, self)->dispose = dispose;
|
||||||
@ -105,9 +108,11 @@ static const float CURVE_LINEAR = 0, CURVE_STEPPED = 1, CURVE_BEZIER = 2;
|
|||||||
static const int BEZIER_SIZE = 10 * 2 - 1;
|
static const int BEZIER_SIZE = 10 * 2 - 1;
|
||||||
|
|
||||||
void _spCurveTimeline_init (spCurveTimeline* self, spTimelineType type, int framesCount, /**/
|
void _spCurveTimeline_init (spCurveTimeline* self, spTimelineType type, int framesCount, /**/
|
||||||
void (*dispose) (spTimeline* self), /**/
|
void (*dispose) (spTimeline* self), /**/
|
||||||
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction),
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int (*getPropertyId)(const spTimeline* self)) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction),
|
||||||
|
int (*getPropertyId)(const spTimeline* self)
|
||||||
|
) {
|
||||||
_spTimeline_init(SUPER(self), type, dispose, apply, getPropertyId);
|
_spTimeline_init(SUPER(self), type, dispose, apply, getPropertyId);
|
||||||
self->curves = CALLOC(float, (framesCount - 1) * BEZIER_SIZE);
|
self->curves = CALLOC(float, (framesCount - 1) * BEZIER_SIZE);
|
||||||
}
|
}
|
||||||
@ -223,9 +228,10 @@ void _spBaseTimeline_dispose (spTimeline* timeline) {
|
|||||||
|
|
||||||
/* Many timelines have structure identical to struct spBaseTimeline and extend spCurveTimeline. **/
|
/* Many timelines have structure identical to struct spBaseTimeline and extend spCurveTimeline. **/
|
||||||
struct spBaseTimeline* _spBaseTimeline_create (int framesCount, spTimelineType type, int frameSize, /**/
|
struct spBaseTimeline* _spBaseTimeline_create (int framesCount, spTimelineType type, int frameSize, /**/
|
||||||
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void (*apply) (const spTimeline* self, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction),
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction),
|
||||||
int (*getPropertyId) (const spTimeline* self)) {
|
int (*getPropertyId) (const spTimeline* self)
|
||||||
|
) {
|
||||||
struct spBaseTimeline* self = NEW(struct spBaseTimeline);
|
struct spBaseTimeline* self = NEW(struct spBaseTimeline);
|
||||||
_spCurveTimeline_init(SUPER(self), type, framesCount, _spBaseTimeline_dispose, apply, getPropertyId);
|
_spCurveTimeline_init(SUPER(self), type, framesCount, _spBaseTimeline_dispose, apply, getPropertyId);
|
||||||
|
|
||||||
@ -238,7 +244,8 @@ struct spBaseTimeline* _spBaseTimeline_create (int framesCount, spTimelineType t
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
spBone *bone;
|
spBone *bone;
|
||||||
int frame;
|
int frame;
|
||||||
float prevRotation, frameTime, percent, r;
|
float prevRotation, frameTime, percent, r;
|
||||||
@ -248,16 +255,16 @@ void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton,
|
|||||||
if (!bone->active) return;
|
if (!bone->active) return;
|
||||||
if (time < self->frames[0]) {
|
if (time < self->frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->rotation = bone->data->rotation;
|
bone->rotation = bone->data->rotation;
|
||||||
return;
|
return;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
r = bone->data->rotation - bone->rotation;
|
r = bone->data->rotation - bone->rotation;
|
||||||
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360;
|
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360;
|
||||||
bone->rotation += r * alpha;
|
bone->rotation += r * alpha;
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
; /* to appease compiler */
|
; /* to appease compiler */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -265,15 +272,15 @@ void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton,
|
|||||||
if (time >= self->frames[self->framesCount - ROTATE_ENTRIES]) { /* Time is after last frame. */
|
if (time >= self->frames[self->framesCount - ROTATE_ENTRIES]) { /* Time is after last frame. */
|
||||||
r = self->frames[self->framesCount + ROTATE_PREV_ROTATION];
|
r = self->frames[self->framesCount + ROTATE_PREV_ROTATION];
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->rotation = bone->data->rotation + r * alpha;
|
bone->rotation = bone->data->rotation + r * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
r += bone->data->rotation - bone->rotation;
|
r += bone->data->rotation - bone->rotation;
|
||||||
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; /* Wrap within -180 and 180. */
|
r -= (16384 - (int)(16384.499999999996 - r / 360)) * 360; /* Wrap within -180 and 180. */
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
bone->rotation += r * alpha;
|
bone->rotation += r * alpha;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -287,14 +294,14 @@ void _spRotateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton,
|
|||||||
r = self->frames[frame + ROTATE_ROTATION] - prevRotation;
|
r = self->frames[frame + ROTATE_ROTATION] - prevRotation;
|
||||||
r = prevRotation + (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * percent;
|
r = prevRotation + (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * percent;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->rotation = bone->data->rotation + (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * alpha;
|
bone->rotation = bone->data->rotation + (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
r += bone->data->rotation - bone->rotation;
|
r += bone->data->rotation - bone->rotation;
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
bone->rotation += (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * alpha;
|
bone->rotation += (r - (16384 - (int)(16384.499999999996 - r / 360)) * 360) * alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNUSED(lastTime);
|
UNUSED(lastTime);
|
||||||
@ -323,7 +330,8 @@ static const int TRANSLATE_PREV_TIME = -3, TRANSLATE_PREV_X = -2, TRANSLATE_PREV
|
|||||||
static const int TRANSLATE_X = 1, TRANSLATE_Y = 2;
|
static const int TRANSLATE_X = 1, TRANSLATE_Y = 2;
|
||||||
|
|
||||||
void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
spBone *bone;
|
spBone *bone;
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent;
|
float frameTime, percent;
|
||||||
@ -337,16 +345,16 @@ void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleto
|
|||||||
if (!bone->active) return;
|
if (!bone->active) return;
|
||||||
if (time < self->frames[0]) {
|
if (time < self->frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->x = bone->data->x;
|
bone->x = bone->data->x;
|
||||||
bone->y = bone->data->y;
|
bone->y = bone->data->y;
|
||||||
return;
|
return;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
bone->x += (bone->data->x - bone->x) * alpha;
|
bone->x += (bone->data->x - bone->x) * alpha;
|
||||||
bone->y += (bone->data->y - bone->y) * alpha;
|
bone->y += (bone->data->y - bone->y) * alpha;
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
; /* to appease compiler */
|
; /* to appease compiler */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -363,24 +371,24 @@ void _spTranslateTimeline_apply (const spTimeline* timeline, spSkeleton* skeleto
|
|||||||
y = frames[frame + TRANSLATE_PREV_Y];
|
y = frames[frame + TRANSLATE_PREV_Y];
|
||||||
frameTime = frames[frame];
|
frameTime = frames[frame];
|
||||||
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1,
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1,
|
||||||
1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime));
|
1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime));
|
||||||
|
|
||||||
x += (frames[frame + TRANSLATE_X] - x) * percent;
|
x += (frames[frame + TRANSLATE_X] - x) * percent;
|
||||||
y += (frames[frame + TRANSLATE_Y] - y) * percent;
|
y += (frames[frame + TRANSLATE_Y] - y) * percent;
|
||||||
}
|
}
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->x = bone->data->x + x * alpha;
|
bone->x = bone->data->x + x * alpha;
|
||||||
bone->y = bone->data->y + y * alpha;
|
bone->y = bone->data->y + y * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
bone->x += (bone->data->x + x - bone->x) * alpha;
|
bone->x += (bone->data->x + x - bone->x) * alpha;
|
||||||
bone->y += (bone->data->y + y - bone->y) * alpha;
|
bone->y += (bone->data->y + y - bone->y) * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
bone->x += x * alpha;
|
bone->x += x * alpha;
|
||||||
bone->y += y * alpha;
|
bone->y += y * alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNUSED(lastTime);
|
UNUSED(lastTime);
|
||||||
@ -407,7 +415,8 @@ void spTranslateTimeline_setFrame (spTranslateTimeline* self, int frameIndex, fl
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
spBone *bone;
|
spBone *bone;
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent, x, y;
|
float frameTime, percent, x, y;
|
||||||
@ -420,16 +429,16 @@ void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
if (!bone->active) return;
|
if (!bone->active) return;
|
||||||
if (time < self->frames[0]) {
|
if (time < self->frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->scaleX = bone->data->scaleX;
|
bone->scaleX = bone->data->scaleX;
|
||||||
bone->scaleY = bone->data->scaleY;
|
bone->scaleY = bone->data->scaleY;
|
||||||
return;
|
return;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
bone->scaleX += (bone->data->scaleX - bone->scaleX) * alpha;
|
bone->scaleX += (bone->data->scaleX - bone->scaleX) * alpha;
|
||||||
bone->scaleY += (bone->data->scaleY - bone->scaleY) * alpha;
|
bone->scaleY += (bone->data->scaleY - bone->scaleY) * alpha;
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
; /* to appease compiler */
|
; /* to appease compiler */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -446,7 +455,7 @@ void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
y = frames[frame + TRANSLATE_PREV_Y];
|
y = frames[frame + TRANSLATE_PREV_Y];
|
||||||
frameTime = frames[frame];
|
frameTime = frames[frame];
|
||||||
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1,
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1,
|
||||||
1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime));
|
1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime));
|
||||||
|
|
||||||
x = (x + (frames[frame + TRANSLATE_X] - x) * percent) * bone->data->scaleX;
|
x = (x + (frames[frame + TRANSLATE_X] - x) * percent) * bone->data->scaleX;
|
||||||
y = (y + (frames[frame + TRANSLATE_Y] - y) * percent) * bone->data->scaleY;
|
y = (y + (frames[frame + TRANSLATE_Y] - y) * percent) * bone->data->scaleY;
|
||||||
@ -463,45 +472,45 @@ void _spScaleTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
float bx, by;
|
float bx, by;
|
||||||
if (direction == SP_MIX_DIRECTION_OUT) {
|
if (direction == SP_MIX_DIRECTION_OUT) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bx = bone->data->scaleX;
|
bx = bone->data->scaleX;
|
||||||
by = bone->data->scaleY;
|
by = bone->data->scaleY;
|
||||||
bone->scaleX = bx + (ABS(x) * SIGNUM(bx) - bx) * alpha;
|
bone->scaleX = bx + (ABS(x) * SIGNUM(bx) - bx) * alpha;
|
||||||
bone->scaleY = by + (ABS(y) * SIGNUM(by) - by) * alpha;
|
bone->scaleY = by + (ABS(y) * SIGNUM(by) - by) * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
bx = bone->scaleX;
|
bx = bone->scaleX;
|
||||||
by = bone->scaleY;
|
by = bone->scaleY;
|
||||||
bone->scaleX = bx + (ABS(x) * SIGNUM(bx) - bx) * alpha;
|
bone->scaleX = bx + (ABS(x) * SIGNUM(bx) - bx) * alpha;
|
||||||
bone->scaleY = by + (ABS(y) * SIGNUM(by) - by) * alpha;
|
bone->scaleY = by + (ABS(y) * SIGNUM(by) - by) * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
bx = bone->scaleX;
|
bx = bone->scaleX;
|
||||||
by = bone->scaleY;
|
by = bone->scaleY;
|
||||||
bone->scaleX = bx + (ABS(x) * SIGNUM(bx) - bone->data->scaleX) * alpha;
|
bone->scaleX = bx + (ABS(x) * SIGNUM(bx) - bone->data->scaleX) * alpha;
|
||||||
bone->scaleY = by + (ABS(y) * SIGNUM(by) - bone->data->scaleY) * alpha;
|
bone->scaleY = by + (ABS(y) * SIGNUM(by) - bone->data->scaleY) * alpha;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bx = ABS(bone->data->scaleX) * SIGNUM(x);
|
bx = ABS(bone->data->scaleX) * SIGNUM(x);
|
||||||
by = ABS(bone->data->scaleY) * SIGNUM(y);
|
by = ABS(bone->data->scaleY) * SIGNUM(y);
|
||||||
bone->scaleX = bx + (x - bx) * alpha;
|
bone->scaleX = bx + (x - bx) * alpha;
|
||||||
bone->scaleY = by + (y - by) * alpha;
|
bone->scaleY = by + (y - by) * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
bx = ABS(bone->scaleX) * SIGNUM(x);
|
bx = ABS(bone->scaleX) * SIGNUM(x);
|
||||||
by = ABS(bone->scaleY) * SIGNUM(y);
|
by = ABS(bone->scaleY) * SIGNUM(y);
|
||||||
bone->scaleX = bx + (x - bx) * alpha;
|
bone->scaleX = bx + (x - bx) * alpha;
|
||||||
bone->scaleY = by + (y - by) * alpha;
|
bone->scaleY = by + (y - by) * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
bx = SIGNUM(x);
|
bx = SIGNUM(x);
|
||||||
by = SIGNUM(y);
|
by = SIGNUM(y);
|
||||||
bone->scaleX = ABS(bone->scaleX) * bx + (x - ABS(bone->data->scaleX) * bx) * alpha;
|
bone->scaleX = ABS(bone->scaleX) * bx + (x - ABS(bone->data->scaleX) * bx) * alpha;
|
||||||
bone->scaleY = ABS(bone->scaleY) * by + (y - ABS(bone->data->scaleY) * by) * alpha;
|
bone->scaleY = ABS(bone->scaleY) * by + (y - ABS(bone->data->scaleY) * by) * alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -526,7 +535,8 @@ void spScaleTimeline_setFrame (spScaleTimeline* self, int frameIndex, float time
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _spShearTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spShearTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
spBone *bone;
|
spBone *bone;
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent, x, y;
|
float frameTime, percent, x, y;
|
||||||
@ -541,16 +551,16 @@ void _spShearTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
framesCount = self->framesCount;
|
framesCount = self->framesCount;
|
||||||
if (time < self->frames[0]) {
|
if (time < self->frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->shearX = bone->data->shearX;
|
bone->shearX = bone->data->shearX;
|
||||||
bone->shearY = bone->data->shearY;
|
bone->shearY = bone->data->shearY;
|
||||||
return;
|
return;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
bone->shearX += (bone->data->shearX - bone->shearX) * alpha;
|
bone->shearX += (bone->data->shearX - bone->shearX) * alpha;
|
||||||
bone->shearY += (bone->data->shearY - bone->shearY) * alpha;
|
bone->shearY += (bone->data->shearY - bone->shearY) * alpha;
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
; /* to appease compiler */
|
; /* to appease compiler */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -565,24 +575,24 @@ void _spShearTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
y = frames[frame + TRANSLATE_PREV_Y];
|
y = frames[frame + TRANSLATE_PREV_Y];
|
||||||
frameTime = frames[frame];
|
frameTime = frames[frame];
|
||||||
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1,
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TRANSLATE_ENTRIES - 1,
|
||||||
1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime));
|
1 - (time - frameTime) / (frames[frame + TRANSLATE_PREV_TIME] - frameTime));
|
||||||
|
|
||||||
x = x + (frames[frame + TRANSLATE_X] - x) * percent;
|
x = x + (frames[frame + TRANSLATE_X] - x) * percent;
|
||||||
y = y + (frames[frame + TRANSLATE_Y] - y) * percent;
|
y = y + (frames[frame + TRANSLATE_Y] - y) * percent;
|
||||||
}
|
}
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
bone->shearX = bone->data->shearX + x * alpha;
|
bone->shearX = bone->data->shearX + x * alpha;
|
||||||
bone->shearY = bone->data->shearY + y * alpha;
|
bone->shearY = bone->data->shearY + y * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
bone->shearX += (bone->data->shearX + x - bone->shearX) * alpha;
|
bone->shearX += (bone->data->shearX + x - bone->shearX) * alpha;
|
||||||
bone->shearY += (bone->data->shearY + y - bone->shearY) * alpha;
|
bone->shearY += (bone->data->shearY + y - bone->shearY) * alpha;
|
||||||
break;
|
break;
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
bone->shearX += x * alpha;
|
bone->shearX += x * alpha;
|
||||||
bone->shearY += y * alpha;
|
bone->shearY += y * alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
UNUSED(lastTime);
|
UNUSED(lastTime);
|
||||||
@ -609,7 +619,8 @@ static const int COLOR_PREV_TIME = -5, COLOR_PREV_R = -4, COLOR_PREV_G = -3, COL
|
|||||||
static const int COLOR_R = 1, COLOR_G = 2, COLOR_B = 3, COLOR_A = 4;
|
static const int COLOR_R = 1, COLOR_G = 2, COLOR_B = 3, COLOR_A = 4;
|
||||||
|
|
||||||
void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
spSlot *slot;
|
spSlot *slot;
|
||||||
int frame;
|
int frame;
|
||||||
float percent, frameTime;
|
float percent, frameTime;
|
||||||
@ -622,17 +633,17 @@ void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
|
|
||||||
if (time < self->frames[0]) {
|
if (time < self->frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
spColor_setFromColor(&slot->color, &slot->data->color);
|
spColor_setFromColor(&slot->color, &slot->data->color);
|
||||||
return;
|
return;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
color = &slot->color;
|
color = &slot->color;
|
||||||
setup = &slot->data->color;
|
setup = &slot->data->color;
|
||||||
spColor_addFloats(color, (setup->r - color->r) * alpha, (setup->g - color->g) * alpha, (setup->b - color->b) * alpha,
|
spColor_addFloats(color, (setup->r - color->r) * alpha, (setup->g - color->g) * alpha, (setup->b - color->b) * alpha,
|
||||||
(setup->a - color->a) * alpha);
|
(setup->a - color->a) * alpha);
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
; /* to appease compiler */
|
; /* to appease compiler */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -664,9 +675,7 @@ void _spColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, f
|
|||||||
if (alpha == 1) {
|
if (alpha == 1) {
|
||||||
spColor_setFromFloats(&slot->color, r, g, b, a);
|
spColor_setFromFloats(&slot->color, r, g, b, a);
|
||||||
} else {
|
} else {
|
||||||
if (blend == SP_MIX_BLEND_SETUP) {
|
if (blend == SP_MIX_BLEND_SETUP) spColor_setFromColor(&slot->color, &slot->data->color);
|
||||||
spColor_setFromColor(&slot->color, &slot->data->color);
|
|
||||||
}
|
|
||||||
spColor_addFloats(&slot->color, (r - slot->color.r) * alpha, (g - slot->color.g) * alpha, (b - slot->color.b) * alpha, (a - slot->color.a) * alpha);
|
spColor_addFloats(&slot->color, (r - slot->color.r) * alpha, (g - slot->color.g) * alpha, (b - slot->color.b) * alpha, (a - slot->color.a) * alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,7 +709,8 @@ static const int TWOCOLOR_PREV_R2 = -3, TWOCOLOR_PREV_G2 = -2, TWOCOLOR_PREV_B2
|
|||||||
static const int TWOCOLOR_R = 1, TWOCOLOR_G = 2, TWOCOLOR_B = 3, TWOCOLOR_A = 4, TWOCOLOR_R2 = 5, TWOCOLOR_G2 = 6, TWOCOLOR_B2 = 7;
|
static const int TWOCOLOR_R = 1, TWOCOLOR_G = 2, TWOCOLOR_B = 3, TWOCOLOR_A = 4, TWOCOLOR_R2 = 5, TWOCOLOR_G2 = 6, TWOCOLOR_B2 = 7;
|
||||||
|
|
||||||
void _spTwoColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spTwoColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
spSlot *slot;
|
spSlot *slot;
|
||||||
int frame;
|
int frame;
|
||||||
float percent, frameTime;
|
float percent, frameTime;
|
||||||
@ -715,21 +725,21 @@ void _spTwoColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton
|
|||||||
|
|
||||||
if (time < self->frames[0]) {
|
if (time < self->frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
spColor_setFromColor(&slot->color, &slot->data->color);
|
spColor_setFromColor(&slot->color, &slot->data->color);
|
||||||
spColor_setFromColor(slot->darkColor, slot->data->darkColor);
|
spColor_setFromColor(slot->darkColor, slot->data->darkColor);
|
||||||
return;
|
return;
|
||||||
case SP_MIX_BLEND_FIRST:
|
case SP_MIX_BLEND_FIRST:
|
||||||
light = &slot->color;
|
light = &slot->color;
|
||||||
dark = slot->darkColor;
|
dark = slot->darkColor;
|
||||||
setupLight = &slot->data->color;
|
setupLight = &slot->data->color;
|
||||||
setupDark = slot->data->darkColor;
|
setupDark = slot->data->darkColor;
|
||||||
spColor_addFloats(light, (setupLight->r - light->r) * alpha, (setupLight->g - light->g) * alpha, (setupLight->b - light->b) * alpha,
|
spColor_addFloats(light, (setupLight->r - light->r) * alpha, (setupLight->g - light->g) * alpha, (setupLight->b - light->b) * alpha,
|
||||||
(setupLight->a - light->a) * alpha);
|
(setupLight->a - light->a) * alpha);
|
||||||
spColor_addFloats(dark, (setupDark->r - dark->r) * alpha, (setupDark->g - dark->g) * alpha, (setupDark->b - dark->b) * alpha, 0);
|
spColor_addFloats(dark, (setupDark->r - dark->r) * alpha, (setupDark->g - dark->g) * alpha, (setupDark->b - dark->b) * alpha, 0);
|
||||||
case SP_MIX_BLEND_REPLACE:
|
case SP_MIX_BLEND_REPLACE:
|
||||||
case SP_MIX_BLEND_ADD:
|
case SP_MIX_BLEND_ADD:
|
||||||
; /* to appease compiler */
|
; /* to appease compiler */
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -757,7 +767,7 @@ void _spTwoColorTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton
|
|||||||
|
|
||||||
frameTime = self->frames[frame];
|
frameTime = self->frames[frame];
|
||||||
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TWOCOLOR_ENTRIES - 1,
|
percent = spCurveTimeline_getCurvePercent(SUPER(self), frame / TWOCOLOR_ENTRIES - 1,
|
||||||
1 - (time - frameTime) / (self->frames[frame + TWOCOLOR_PREV_TIME] - frameTime));
|
1 - (time - frameTime) / (self->frames[frame + TWOCOLOR_PREV_TIME] - frameTime));
|
||||||
|
|
||||||
r += (self->frames[frame + TWOCOLOR_R] - r) * percent;
|
r += (self->frames[frame + TWOCOLOR_R] - r) * percent;
|
||||||
g += (self->frames[frame + TWOCOLOR_G] - g) * percent;
|
g += (self->frames[frame + TWOCOLOR_G] - g) * percent;
|
||||||
@ -819,7 +829,7 @@ void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skelet
|
|||||||
|
|
||||||
if (direction == SP_MIX_DIRECTION_OUT && blend == SP_MIX_BLEND_SETUP) {
|
if (direction == SP_MIX_DIRECTION_OUT && blend == SP_MIX_BLEND_SETUP) {
|
||||||
attachmentName = slot->data->attachmentName;
|
attachmentName = slot->data->attachmentName;
|
||||||
spSlot_setAttachment(slot, attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
spSlot_setAttachment(slot, attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,7 +837,7 @@ void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skelet
|
|||||||
if (blend == SP_MIX_BLEND_SETUP || blend == SP_MIX_BLEND_FIRST) {
|
if (blend == SP_MIX_BLEND_SETUP || blend == SP_MIX_BLEND_FIRST) {
|
||||||
attachmentName = slot->data->attachmentName;
|
attachmentName = slot->data->attachmentName;
|
||||||
spSlot_setAttachment(skeleton->slots[self->slotIndex],
|
spSlot_setAttachment(skeleton->slots[self->slotIndex],
|
||||||
attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -839,7 +849,7 @@ void _spAttachmentTimeline_apply (const spTimeline* timeline, spSkeleton* skelet
|
|||||||
|
|
||||||
attachmentName = self->attachmentNames[frameIndex];
|
attachmentName = self->attachmentNames[frameIndex];
|
||||||
spSlot_setAttachment(skeleton->slots[self->slotIndex],
|
spSlot_setAttachment(skeleton->slots[self->slotIndex],
|
||||||
attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
attachmentName ? spSkeleton_getAttachmentForSlotIndex(skeleton, self->slotIndex, attachmentName) : 0);
|
||||||
|
|
||||||
UNUSED(lastTime);
|
UNUSED(lastTime);
|
||||||
UNUSED(firedEvents);
|
UNUSED(firedEvents);
|
||||||
@ -888,7 +898,8 @@ void spAttachmentTimeline_setFrame (spAttachmentTimeline* self, int frameIndex,
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _spDeformTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spDeformTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int frame, i, vertexCount;
|
int frame, i, vertexCount;
|
||||||
float percent, frameTime;
|
float percent, frameTime;
|
||||||
const float* prevVertices;
|
const float* prevVertices;
|
||||||
@ -1053,42 +1064,42 @@ void _spDeformTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton,
|
|||||||
} else {
|
} else {
|
||||||
spVertexAttachment* vertexAttachment;
|
spVertexAttachment* vertexAttachment;
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case SP_MIX_BLEND_SETUP:
|
case SP_MIX_BLEND_SETUP:
|
||||||
vertexAttachment = SUB_CAST(spVertexAttachment, slot->attachment);
|
vertexAttachment = SUB_CAST(spVertexAttachment, slot->attachment);
|
||||||
if (!vertexAttachment->bones) {
|
if (!vertexAttachment->bones) {
|
||||||
float *setupVertices = vertexAttachment->vertices;
|
float *setupVertices = vertexAttachment->vertices;
|
||||||
for (i = 0; i < vertexCount; i++) {
|
for (i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i], setup = setupVertices[i];
|
float prev = prevVertices[i], setup = setupVertices[i];
|
||||||
deformArray[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
deformArray[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < vertexCount; i++) {
|
|
||||||
float prev = prevVertices[i];
|
|
||||||
deformArray[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
case SP_MIX_BLEND_FIRST:
|
|
||||||
case SP_MIX_BLEND_REPLACE:
|
|
||||||
for (i = 0; i < vertexCount; i++) {
|
for (i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
deformArray[i] += (prev + (nextVertices[i] - prev) * percent - deformArray[i]) * alpha;
|
deformArray[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case SP_MIX_BLEND_ADD:
|
break;
|
||||||
vertexAttachment = SUB_CAST(spVertexAttachment, slot->attachment);
|
case SP_MIX_BLEND_FIRST:
|
||||||
if (!vertexAttachment->bones) {
|
case SP_MIX_BLEND_REPLACE:
|
||||||
float *setupVertices = vertexAttachment->vertices;
|
for (i = 0; i < vertexCount; i++) {
|
||||||
for (i = 0; i < vertexCount; i++) {
|
float prev = prevVertices[i];
|
||||||
float prev = prevVertices[i];
|
deformArray[i] += (prev + (nextVertices[i] - prev) * percent - deformArray[i]) * alpha;
|
||||||
deformArray[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
|
}
|
||||||
}
|
break;
|
||||||
} else {
|
case SP_MIX_BLEND_ADD:
|
||||||
for (i = 0; i < vertexCount; i++) {
|
vertexAttachment = SUB_CAST(spVertexAttachment, slot->attachment);
|
||||||
float prev = prevVertices[i];
|
if (!vertexAttachment->bones) {
|
||||||
deformArray[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
|
float *setupVertices = vertexAttachment->vertices;
|
||||||
}
|
for (i = 0; i < vertexCount; i++) {
|
||||||
|
float prev = prevVertices[i];
|
||||||
|
deformArray[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < vertexCount; i++) {
|
||||||
|
float prev = prevVertices[i];
|
||||||
|
deformArray[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1142,7 +1153,8 @@ void spDeformTimeline_setFrame (spDeformTimeline* self, int frameIndex, float ti
|
|||||||
|
|
||||||
/** Fires events for frames > lastTime and <= time. */
|
/** Fires events for frames > lastTime and <= time. */
|
||||||
void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
void _spEventTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time, spEvent** firedEvents,
|
||||||
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
spEventTimeline* self = (spEventTimeline*)timeline;
|
spEventTimeline* self = (spEventTimeline*)timeline;
|
||||||
int frame;
|
int frame;
|
||||||
if (!firedEvents) return;
|
if (!firedEvents) return;
|
||||||
@ -1211,7 +1223,8 @@ void spEventTimeline_setFrame (spEventTimeline* self, int frameIndex, spEvent* e
|
|||||||
/**/
|
/**/
|
||||||
|
|
||||||
void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
void _spDrawOrderTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int i;
|
int i;
|
||||||
int frame;
|
int frame;
|
||||||
const int* drawOrderToSetupIndex;
|
const int* drawOrderToSetupIndex;
|
||||||
@ -1294,7 +1307,8 @@ static const int IKCONSTRAINT_PREV_TIME = -6, IKCONSTRAINT_PREV_MIX = -5, IKCONS
|
|||||||
static const int IKCONSTRAINT_MIX = 1, IKCONSTRAINT_SOFTNESS = 2, IKCONSTRAINT_BEND_DIRECTION = 3, IKCONSTRAINT_COMPRESS = 4, IKCONSTRAINT_STRETCH = 5;
|
static const int IKCONSTRAINT_MIX = 1, IKCONSTRAINT_SOFTNESS = 2, IKCONSTRAINT_BEND_DIRECTION = 3, IKCONSTRAINT_COMPRESS = 4, IKCONSTRAINT_STRETCH = 5;
|
||||||
|
|
||||||
void _spIkConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
void _spIkConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent, mix, softness;
|
float frameTime, percent, mix, softness;
|
||||||
float *frames;
|
float *frames;
|
||||||
@ -1333,7 +1347,7 @@ void _spIkConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skel
|
|||||||
if (blend == SP_MIX_BLEND_SETUP) {
|
if (blend == SP_MIX_BLEND_SETUP) {
|
||||||
constraint->mix = constraint->data->mix + (frames[framesCount + IKCONSTRAINT_PREV_MIX] - constraint->data->mix) * alpha;
|
constraint->mix = constraint->data->mix + (frames[framesCount + IKCONSTRAINT_PREV_MIX] - constraint->data->mix) * alpha;
|
||||||
constraint->softness = constraint->data->softness
|
constraint->softness = constraint->data->softness
|
||||||
+ (frames[framesCount + IKCONSTRAINT_PREV_SOFTNESS] - constraint->data->softness) * alpha;
|
+ (frames[framesCount + IKCONSTRAINT_PREV_SOFTNESS] - constraint->data->softness) * alpha;
|
||||||
if (direction == SP_MIX_DIRECTION_OUT) {
|
if (direction == SP_MIX_DIRECTION_OUT) {
|
||||||
constraint->bendDirection = constraint->data->bendDirection;
|
constraint->bendDirection = constraint->data->bendDirection;
|
||||||
constraint->compress = constraint->data->compress;
|
constraint->compress = constraint->data->compress;
|
||||||
@ -1365,7 +1379,7 @@ void _spIkConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skel
|
|||||||
if (blend == SP_MIX_BLEND_SETUP) {
|
if (blend == SP_MIX_BLEND_SETUP) {
|
||||||
constraint->mix = constraint->data->mix + (mix + (frames[frame + IKCONSTRAINT_MIX] - mix) * percent - constraint->data->mix) * alpha;
|
constraint->mix = constraint->data->mix + (mix + (frames[frame + IKCONSTRAINT_MIX] - mix) * percent - constraint->data->mix) * alpha;
|
||||||
constraint->softness = constraint->data->softness
|
constraint->softness = constraint->data->softness
|
||||||
+ (softness + (frames[frame + IKCONSTRAINT_SOFTNESS] - softness) * percent - constraint->data->softness) * alpha;
|
+ (softness + (frames[frame + IKCONSTRAINT_SOFTNESS] - softness) * percent - constraint->data->softness) * alpha;
|
||||||
if (direction == SP_MIX_DIRECTION_OUT) {
|
if (direction == SP_MIX_DIRECTION_OUT) {
|
||||||
constraint->bendDirection = constraint->data->bendDirection;
|
constraint->bendDirection = constraint->data->bendDirection;
|
||||||
constraint->compress = constraint->data->compress;
|
constraint->compress = constraint->data->compress;
|
||||||
@ -1398,7 +1412,9 @@ spIkConstraintTimeline* spIkConstraintTimeline_create (int framesCount) {
|
|||||||
return (spIkConstraintTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_IKCONSTRAINT, IKCONSTRAINT_ENTRIES, _spIkConstraintTimeline_apply, _spIkConstraintTimeline_getPropertyId);
|
return (spIkConstraintTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_IKCONSTRAINT, IKCONSTRAINT_ENTRIES, _spIkConstraintTimeline_apply, _spIkConstraintTimeline_getPropertyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spIkConstraintTimeline_setFrame (spIkConstraintTimeline* self, int frameIndex, float time, float mix, float softness, int bendDirection, int /*boolean*/ compress, int /*boolean*/ stretch) {
|
void spIkConstraintTimeline_setFrame (spIkConstraintTimeline* self, int frameIndex, float time, float mix, float softness,
|
||||||
|
int bendDirection, int /*boolean*/ compress, int /*boolean*/ stretch
|
||||||
|
) {
|
||||||
frameIndex *= IKCONSTRAINT_ENTRIES;
|
frameIndex *= IKCONSTRAINT_ENTRIES;
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
self->frames[frameIndex + IKCONSTRAINT_MIX] = mix;
|
self->frames[frameIndex + IKCONSTRAINT_MIX] = mix;
|
||||||
@ -1420,7 +1436,8 @@ static const int TRANSFORMCONSTRAINT_SCALE = 3;
|
|||||||
static const int TRANSFORMCONSTRAINT_SHEAR = 4;
|
static const int TRANSFORMCONSTRAINT_SHEAR = 4;
|
||||||
|
|
||||||
void _spTransformConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
void _spTransformConstraintTimeline_apply (const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent, rotate, translate, scale, shear;
|
float frameTime, percent, rotate, translate, scale, shear;
|
||||||
spTransformConstraint* constraint;
|
spTransformConstraint* constraint;
|
||||||
@ -1501,10 +1518,13 @@ int _spTransformConstraintTimeline_getPropertyId (const spTimeline* timeline) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spTransformConstraintTimeline* spTransformConstraintTimeline_create (int framesCount) {
|
spTransformConstraintTimeline* spTransformConstraintTimeline_create (int framesCount) {
|
||||||
return (spTransformConstraintTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_TRANSFORMCONSTRAINT, TRANSFORMCONSTRAINT_ENTRIES, _spTransformConstraintTimeline_apply, _spTransformConstraintTimeline_getPropertyId);
|
return (spTransformConstraintTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_TRANSFORMCONSTRAINT,
|
||||||
|
TRANSFORMCONSTRAINT_ENTRIES, _spTransformConstraintTimeline_apply, _spTransformConstraintTimeline_getPropertyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spTransformConstraintTimeline_setFrame (spTransformConstraintTimeline* self, int frameIndex, float time, float rotateMix, float translateMix, float scaleMix, float shearMix) {
|
void spTransformConstraintTimeline_setFrame (spTransformConstraintTimeline* self, int frameIndex, float time, float rotateMix,
|
||||||
|
float translateMix, float scaleMix, float shearMix
|
||||||
|
) {
|
||||||
frameIndex *= TRANSFORMCONSTRAINT_ENTRIES;
|
frameIndex *= TRANSFORMCONSTRAINT_ENTRIES;
|
||||||
self->frames[frameIndex] = time;
|
self->frames[frameIndex] = time;
|
||||||
self->frames[frameIndex + TRANSFORMCONSTRAINT_ROTATE] = rotateMix;
|
self->frames[frameIndex + TRANSFORMCONSTRAINT_ROTATE] = rotateMix;
|
||||||
@ -1520,7 +1540,8 @@ static const int PATHCONSTRAINTPOSITION_PREV_VALUE = -1;
|
|||||||
static const int PATHCONSTRAINTPOSITION_VALUE = 1;
|
static const int PATHCONSTRAINTPOSITION_VALUE = 1;
|
||||||
|
|
||||||
void _spPathConstraintPositionTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
void _spPathConstraintPositionTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent, position;
|
float frameTime, percent, position;
|
||||||
spPathConstraint* constraint;
|
spPathConstraint* constraint;
|
||||||
@ -1575,7 +1596,8 @@ int _spPathConstraintPositionTimeline_getPropertyId (const spTimeline* timeline)
|
|||||||
}
|
}
|
||||||
|
|
||||||
spPathConstraintPositionTimeline* spPathConstraintPositionTimeline_create (int framesCount) {
|
spPathConstraintPositionTimeline* spPathConstraintPositionTimeline_create (int framesCount) {
|
||||||
return (spPathConstraintPositionTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTPOSITION, PATHCONSTRAINTPOSITION_ENTRIES, _spPathConstraintPositionTimeline_apply, _spPathConstraintPositionTimeline_getPropertyId);
|
return (spPathConstraintPositionTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTPOSITION,
|
||||||
|
PATHCONSTRAINTPOSITION_ENTRIES, _spPathConstraintPositionTimeline_apply, _spPathConstraintPositionTimeline_getPropertyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spPathConstraintPositionTimeline_setFrame (spPathConstraintPositionTimeline* self, int frameIndex, float time, float value) {
|
void spPathConstraintPositionTimeline_setFrame (spPathConstraintPositionTimeline* self, int frameIndex, float time, float value) {
|
||||||
@ -1590,7 +1612,8 @@ static const int PATHCONSTRAINTSPACING_PREV_VALUE = -1;
|
|||||||
static const int PATHCONSTRAINTSPACING_VALUE = 1;
|
static const int PATHCONSTRAINTSPACING_VALUE = 1;
|
||||||
|
|
||||||
void _spPathConstraintSpacingTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
void _spPathConstraintSpacingTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent, spacing;
|
float frameTime, percent, spacing;
|
||||||
spPathConstraint* constraint;
|
spPathConstraint* constraint;
|
||||||
@ -1646,7 +1669,8 @@ int _spPathConstraintSpacingTimeline_getPropertyId (const spTimeline* timeline)
|
|||||||
}
|
}
|
||||||
|
|
||||||
spPathConstraintSpacingTimeline* spPathConstraintSpacingTimeline_create (int framesCount) {
|
spPathConstraintSpacingTimeline* spPathConstraintSpacingTimeline_create (int framesCount) {
|
||||||
return (spPathConstraintSpacingTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTSPACING, PATHCONSTRAINTSPACING_ENTRIES, _spPathConstraintSpacingTimeline_apply, _spPathConstraintSpacingTimeline_getPropertyId);
|
return (spPathConstraintSpacingTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTSPACING,
|
||||||
|
PATHCONSTRAINTSPACING_ENTRIES, _spPathConstraintSpacingTimeline_apply, _spPathConstraintSpacingTimeline_getPropertyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spPathConstraintSpacingTimeline_setFrame (spPathConstraintSpacingTimeline* self, int frameIndex, float time, float value) {
|
void spPathConstraintSpacingTimeline_setFrame (spPathConstraintSpacingTimeline* self, int frameIndex, float time, float value) {
|
||||||
@ -1664,7 +1688,8 @@ static const int PATHCONSTRAINTMIX_ROTATE = 1;
|
|||||||
static const int PATHCONSTRAINTMIX_TRANSLATE = 2;
|
static const int PATHCONSTRAINTMIX_TRANSLATE = 2;
|
||||||
|
|
||||||
void _spPathConstraintMixTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
void _spPathConstraintMixTimeline_apply(const spTimeline* timeline, spSkeleton* skeleton, float lastTime, float time,
|
||||||
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction) {
|
spEvent** firedEvents, int* eventsCount, float alpha, spMixBlend blend, spMixDirection direction
|
||||||
|
) {
|
||||||
int frame;
|
int frame;
|
||||||
float frameTime, percent, rotate, translate;
|
float frameTime, percent, rotate, translate;
|
||||||
spPathConstraint* constraint;
|
spPathConstraint* constraint;
|
||||||
@ -1728,7 +1753,8 @@ int _spPathConstraintMixTimeline_getPropertyId (const spTimeline* timeline) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spPathConstraintMixTimeline* spPathConstraintMixTimeline_create (int framesCount) {
|
spPathConstraintMixTimeline* spPathConstraintMixTimeline_create (int framesCount) {
|
||||||
return (spPathConstraintMixTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTMIX, PATHCONSTRAINTMIX_ENTRIES, _spPathConstraintMixTimeline_apply, _spPathConstraintMixTimeline_getPropertyId);
|
return (spPathConstraintMixTimeline*)_spBaseTimeline_create(framesCount, SP_TIMELINE_PATHCONSTRAINTMIX,
|
||||||
|
PATHCONSTRAINTMIX_ENTRIES, _spPathConstraintMixTimeline_apply, _spPathConstraintMixTimeline_getPropertyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spPathConstraintMixTimeline_setFrame (spPathConstraintMixTimeline* self, int frameIndex, float time, float rotateMix, float translateMix) {
|
void spPathConstraintMixTimeline_setFrame (spPathConstraintMixTimeline* self, int frameIndex, float time, float rotateMix, float translateMix) {
|
||||||
|
|||||||
@ -46,7 +46,7 @@ void spAnimationState_disposeStatics () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Forward declaration of some "private" functions so we can keep
|
/* Forward declaration of some "private" functions so we can keep
|
||||||
the same function order in C as we have method order in Java */
|
the same function order in C as we have method order in Java. */
|
||||||
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry);
|
void _spAnimationState_disposeTrackEntry (spTrackEntry* entry);
|
||||||
void _spAnimationState_disposeTrackEntries (spAnimationState* state, spTrackEntry* entry);
|
void _spAnimationState_disposeTrackEntries (spAnimationState* state, spTrackEntry* entry);
|
||||||
int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTrackEntry* entry, float delta);
|
int /*boolean*/ _spAnimationState_updateMixingFrom (spAnimationState* self, spTrackEntry* entry, float delta);
|
||||||
@ -65,7 +65,6 @@ int _spAnimationState_addPropertyID(spAnimationState* self, int id);
|
|||||||
void _spTrackEntry_computeHold(spTrackEntry* self, spAnimationState* state);
|
void _spTrackEntry_computeHold(spTrackEntry* self, spAnimationState* state);
|
||||||
void _spTrackEntry_computeNotLast(spTrackEntry* self, spAnimationState* state);
|
void _spTrackEntry_computeNotLast(spTrackEntry* self, spAnimationState* state);
|
||||||
|
|
||||||
|
|
||||||
_spEventQueue* _spEventQueue_create (_spAnimationState* state) {
|
_spEventQueue* _spEventQueue_create (_spAnimationState* state) {
|
||||||
_spEventQueue *self = CALLOC(_spEventQueue, 1);
|
_spEventQueue *self = CALLOC(_spEventQueue, 1);
|
||||||
self->state = state;
|
self->state = state;
|
||||||
@ -78,7 +77,7 @@ _spEventQueue* _spEventQueue_create (_spAnimationState* state) {
|
|||||||
|
|
||||||
void _spEventQueue_free (_spEventQueue* self) {
|
void _spEventQueue_free (_spEventQueue* self) {
|
||||||
FREE(self->objects);
|
FREE(self->objects);
|
||||||
FREE(self);
|
FREE(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _spEventQueue_ensureCapacity (_spEventQueue* self, int newElements) {
|
void _spEventQueue_ensureCapacity (_spEventQueue* self, int newElements) {
|
||||||
@ -250,7 +249,7 @@ void spAnimationState_dispose (spAnimationState* self) {
|
|||||||
_spEventQueue_free(internal->queue);
|
_spEventQueue_free(internal->queue);
|
||||||
FREE(internal->events);
|
FREE(internal->events);
|
||||||
FREE(internal->propertyIDs);
|
FREE(internal->propertyIDs);
|
||||||
FREE(internal);
|
FREE(internal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void spAnimationState_update (spAnimationState* self, float delta) {
|
void spAnimationState_update (spAnimationState* self, float delta) {
|
||||||
@ -370,9 +369,9 @@ int spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
|
|||||||
/* Apply mixing from entries first. */
|
/* Apply mixing from entries first. */
|
||||||
mix = current->alpha;
|
mix = current->alpha;
|
||||||
if (current->mixingFrom)
|
if (current->mixingFrom)
|
||||||
mix *= _spAnimationState_applyMixingFrom(self, current, skeleton, blend);
|
mix *= _spAnimationState_applyMixingFrom(self, current, skeleton, blend);
|
||||||
else if (current->trackTime >= current->trackEnd && current->next == 0)
|
else if (current->trackTime >= current->trackEnd && current->next == 0)
|
||||||
mix = 0;
|
mix = 0;
|
||||||
|
|
||||||
/* Apply current entry. */
|
/* Apply current entry. */
|
||||||
animationLast = current->animationLast; animationTime = spTrackEntry_getAnimationTime(current);
|
animationLast = current->animationLast; animationTime = spTrackEntry_getAnimationTime(current);
|
||||||
@ -493,7 +492,7 @@ float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* t
|
|||||||
from->totalAlpha += alpha;
|
from->totalAlpha += alpha;
|
||||||
if (timeline->type == SP_TIMELINE_ROTATE)
|
if (timeline->type == SP_TIMELINE_ROTATE)
|
||||||
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, alpha, timelineBlend,
|
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, animationTime, alpha, timelineBlend,
|
||||||
timelinesRotation, i << 1, firstFrame);
|
timelinesRotation, i << 1, firstFrame);
|
||||||
else {
|
else {
|
||||||
if (timelineBlend == SP_MIX_BLEND_SETUP) {
|
if (timelineBlend == SP_MIX_BLEND_SETUP) {
|
||||||
if (timeline->type == SP_TIMELINE_ATTACHMENT) {
|
if (timeline->type == SP_TIMELINE_ATTACHMENT) {
|
||||||
@ -504,7 +503,7 @@ float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* t
|
|||||||
}
|
}
|
||||||
|
|
||||||
spTimeline_apply(timeline, skeleton, animationLast, animationTime, events, &internal->eventsCount,
|
spTimeline_apply(timeline, skeleton, animationLast, animationTime, events, &internal->eventsCount,
|
||||||
alpha, timelineBlend, direction);
|
alpha, timelineBlend, direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,7 +517,9 @@ float _spAnimationState_applyMixingFrom (spAnimationState* self, spTrackEntry* t
|
|||||||
return mix;
|
return mix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline* timeline, spSkeleton* skeleton, float time, float alpha, spMixBlend blend, float* timelinesRotation, int i, int /*boolean*/ firstFrame) {
|
void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline* timeline, spSkeleton* skeleton, float time,
|
||||||
|
float alpha, spMixBlend blend, float* timelinesRotation, int i, int /*boolean*/ firstFrame
|
||||||
|
) {
|
||||||
spRotateTimeline *rotateTimeline;
|
spRotateTimeline *rotateTimeline;
|
||||||
float *frames;
|
float *frames;
|
||||||
spBone* bone;
|
spBone* bone;
|
||||||
@ -562,8 +563,7 @@ void _spAnimationState_applyRotateTimeline (spAnimationState* self, spTimeline*
|
|||||||
prevRotation = frames[frame + ROTATE_PREV_ROTATION];
|
prevRotation = frames[frame + ROTATE_PREV_ROTATION];
|
||||||
frameTime = frames[frame];
|
frameTime = frames[frame];
|
||||||
percent = spCurveTimeline_getCurvePercent(SUPER(rotateTimeline), (frame >> 1) - 1,
|
percent = spCurveTimeline_getCurvePercent(SUPER(rotateTimeline), (frame >> 1) - 1,
|
||||||
1 - (time - frameTime) /
|
1 - (time - frameTime) / (frames[frame + ROTATE_PREV_TIME] - frameTime));
|
||||||
(frames[frame + ROTATE_PREV_TIME] - frameTime));
|
|
||||||
|
|
||||||
r2 = frames[frame + ROTATE_ROTATION] - prevRotation;
|
r2 = frames[frame + ROTATE_ROTATION] - prevRotation;
|
||||||
r2 -= (16384 - (int) (16384.499999999996 - r2 / 360)) * 360;
|
r2 -= (16384 - (int) (16384.499999999996 - r2 / 360)) * 360;
|
||||||
@ -698,8 +698,7 @@ void _spAnimationState_setCurrent (spAnimationState* self, int index, spTrackEnt
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Set the current animation. Any queued animations are cleared. */
|
/** Set the current animation. Any queued animations are cleared. */
|
||||||
spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
|
spTrackEntry* spAnimationState_setAnimationByName (spAnimationState* self, int trackIndex, const char* animationName, int/*bool*/loop) {
|
||||||
int/*bool*/loop) {
|
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
||||||
return spAnimationState_setAnimation(self, trackIndex, animation, loop);
|
return spAnimationState_setAnimation(self, trackIndex, animation, loop);
|
||||||
}
|
}
|
||||||
@ -730,13 +729,13 @@ spTrackEntry* spAnimationState_setAnimation (spAnimationState* self, int trackIn
|
|||||||
/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix
|
/** Adds an animation to be played delay seconds after the current or last queued animation, taking into account any mix
|
||||||
* duration. */
|
* duration. */
|
||||||
spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
|
spTrackEntry* spAnimationState_addAnimationByName (spAnimationState* self, int trackIndex, const char* animationName,
|
||||||
int/*bool*/loop, float delay) {
|
int/*bool*/loop, float delay
|
||||||
|
) {
|
||||||
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
spAnimation* animation = spSkeletonData_findAnimation(self->data->skeletonData, animationName);
|
||||||
return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay);
|
return spAnimationState_addAnimation(self, trackIndex, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop,
|
spTrackEntry* spAnimationState_addAnimation (spAnimationState* self, int trackIndex, spAnimation* animation, int/*bool*/loop, float delay) {
|
||||||
float delay) {
|
|
||||||
spTrackEntry* entry;
|
spTrackEntry* entry;
|
||||||
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
|
||||||
spTrackEntry* last = _spAnimationState_expandToIndex(self, trackIndex);
|
spTrackEntry* last = _spAnimationState_expandToIndex(self, trackIndex);
|
||||||
|
|||||||
@ -181,9 +181,8 @@ spAtlas* spAtlas_create(const char* begin, int length, const char* dir, void* re
|
|||||||
self->rendererObject = rendererObject;
|
self->rendererObject = rendererObject;
|
||||||
|
|
||||||
while (readLine(&begin, end, &str)) {
|
while (readLine(&begin, end, &str)) {
|
||||||
if (str.end - str.begin == 0) {
|
if (str.end - str.begin == 0)
|
||||||
page = 0;
|
page = 0;
|
||||||
}
|
|
||||||
else if (!page) {
|
else if (!page) {
|
||||||
char* name = mallocString(&str);
|
char* name = mallocString(&str);
|
||||||
char* path = MALLOC(char, dirLength + needsSlash + strlen(name) + 1);
|
char* path = MALLOC(char, dirLength + needsSlash + strlen(name) + 1);
|
||||||
@ -232,8 +231,7 @@ spAtlas* spAtlas_create(const char* begin, int length, const char* dir, void* re
|
|||||||
|
|
||||||
_spAtlasPage_createTexture(page, path);
|
_spAtlasPage_createTexture(page, path);
|
||||||
FREE(path);
|
FREE(path);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
spAtlasRegion *region = spAtlasRegion_create();
|
spAtlasRegion *region = spAtlasRegion_create();
|
||||||
if (lastRegion)
|
if (lastRegion)
|
||||||
lastRegion->next = region;
|
lastRegion->next = region;
|
||||||
@ -245,13 +243,12 @@ spAtlas* spAtlas_create(const char* begin, int length, const char* dir, void* re
|
|||||||
region->name = mallocString(&str);
|
region->name = mallocString(&str);
|
||||||
|
|
||||||
if (!readValue(&begin, end, &str)) return abortAtlas(self);
|
if (!readValue(&begin, end, &str)) return abortAtlas(self);
|
||||||
if (equals(&str, "true")) {
|
if (equals(&str, "true"))
|
||||||
region->degrees = 90;
|
region->degrees = 90;
|
||||||
} else if (equals(&str, "false")) {
|
else if (equals(&str, "false"))
|
||||||
region->degrees = 0;
|
region->degrees = 0;
|
||||||
} else {
|
else
|
||||||
region->degrees = toInt(&str);
|
region->degrees = toInt(&str);
|
||||||
}
|
|
||||||
region->rotate = region->degrees == 90;
|
region->rotate = region->degrees == 90;
|
||||||
|
|
||||||
if (readTuple(&begin, end, tuple) != 2) return abortAtlas(self);
|
if (readTuple(&begin, end, tuple) != 2) return abortAtlas(self);
|
||||||
@ -267,8 +264,7 @@ spAtlas* spAtlas_create(const char* begin, int length, const char* dir, void* re
|
|||||||
if (region->rotate) {
|
if (region->rotate) {
|
||||||
region->u2 = (region->x + region->height) / (float)page->width;
|
region->u2 = (region->x + region->height) / (float)page->width;
|
||||||
region->v2 = (region->y + region->width) / (float)page->height;
|
region->v2 = (region->y + region->width) / (float)page->height;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
region->u2 = (region->x + region->width) / (float)page->width;
|
region->u2 = (region->x + region->width) / (float)page->width;
|
||||||
region->v2 = (region->y + region->height) / (float)page->height;
|
region->v2 = (region->y + region->height) / (float)page->height;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,7 @@
|
|||||||
#include <spine/extension.h>
|
#include <spine/extension.h>
|
||||||
|
|
||||||
typedef struct _spAttachmentLoaderVtable {
|
typedef struct _spAttachmentLoaderVtable {
|
||||||
spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name,
|
spAttachment* (*createAttachment) (spAttachmentLoader* self, spSkin* skin, spAttachmentType type, const char* name, const char* path);
|
||||||
const char* path);
|
|
||||||
void (*configureAttachment) (spAttachmentLoader* self, spAttachment*);
|
void (*configureAttachment) (spAttachmentLoader* self, spAttachment*);
|
||||||
void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*);
|
void (*disposeAttachment) (spAttachmentLoader* self, spAttachment*);
|
||||||
void (*dispose) (spAttachmentLoader* self);
|
void (*dispose) (spAttachmentLoader* self);
|
||||||
|
|||||||
@ -96,78 +96,78 @@ void spBone_updateWorldTransformWith (spBone* self, float x, float y, float rota
|
|||||||
CONST_CAST(float, self->worldY) = pc * x + pd * y + parent->worldY;
|
CONST_CAST(float, self->worldY) = pc * x + pd * y + parent->worldY;
|
||||||
|
|
||||||
switch (self->data->transformMode) {
|
switch (self->data->transformMode) {
|
||||||
case SP_TRANSFORMMODE_NORMAL: {
|
case SP_TRANSFORMMODE_NORMAL: {
|
||||||
float rotationY = rotation + 90 + shearY;
|
float rotationY = rotation + 90 + shearY;
|
||||||
float la = COS_DEG(rotation + shearX) * scaleX;
|
float la = COS_DEG(rotation + shearX) * scaleX;
|
||||||
float lb = COS_DEG(rotationY) * scaleY;
|
float lb = COS_DEG(rotationY) * scaleY;
|
||||||
float lc = SIN_DEG(rotation + shearX) * scaleX;
|
float lc = SIN_DEG(rotation + shearX) * scaleX;
|
||||||
float ld = SIN_DEG(rotationY) * scaleY;
|
float ld = SIN_DEG(rotationY) * scaleY;
|
||||||
CONST_CAST(float, self->a) = pa * la + pb * lc;
|
CONST_CAST(float, self->a) = pa * la + pb * lc;
|
||||||
CONST_CAST(float, self->b) = pa * lb + pb * ld;
|
CONST_CAST(float, self->b) = pa * lb + pb * ld;
|
||||||
CONST_CAST(float, self->c) = pc * la + pd * lc;
|
CONST_CAST(float, self->c) = pc * la + pd * lc;
|
||||||
CONST_CAST(float, self->d) = pc * lb + pd * ld;
|
CONST_CAST(float, self->d) = pc * lb + pd * ld;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case SP_TRANSFORMMODE_ONLYTRANSLATION: {
|
case SP_TRANSFORMMODE_ONLYTRANSLATION: {
|
||||||
float rotationY = rotation + 90 + shearY;
|
float rotationY = rotation + 90 + shearY;
|
||||||
CONST_CAST(float, self->a) = COS_DEG(rotation + shearX) * scaleX;
|
CONST_CAST(float, self->a) = COS_DEG(rotation + shearX) * scaleX;
|
||||||
CONST_CAST(float, self->b) = COS_DEG(rotationY) * scaleY;
|
CONST_CAST(float, self->b) = COS_DEG(rotationY) * scaleY;
|
||||||
CONST_CAST(float, self->c) = SIN_DEG(rotation + shearX) * scaleX;
|
CONST_CAST(float, self->c) = SIN_DEG(rotation + shearX) * scaleX;
|
||||||
CONST_CAST(float, self->d) = SIN_DEG(rotationY) * scaleY;
|
CONST_CAST(float, self->d) = SIN_DEG(rotationY) * scaleY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: {
|
case SP_TRANSFORMMODE_NOROTATIONORREFLECTION: {
|
||||||
float s = pa * pa + pc * pc;
|
float s = pa * pa + pc * pc;
|
||||||
float prx, rx, ry, la, lb, lc, ld;
|
float prx, rx, ry, la, lb, lc, ld;
|
||||||
if (s > 0.0001f) {
|
if (s > 0.0001f) {
|
||||||
s = ABS(pa * pd - pb * pc) / s;
|
s = ABS(pa * pd - pb * pc) / s;
|
||||||
pb = pc * s;
|
pb = pc * s;
|
||||||
pd = pa * s;
|
pd = pa * s;
|
||||||
prx = ATAN2(pc, pa) * RAD_DEG;
|
prx = ATAN2(pc, pa) * RAD_DEG;
|
||||||
} else {
|
} else {
|
||||||
pa = 0;
|
pa = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
prx = 90 - ATAN2(pd, pb) * RAD_DEG;
|
prx = 90 - ATAN2(pd, pb) * RAD_DEG;
|
||||||
}
|
|
||||||
rx = rotation + shearX - prx;
|
|
||||||
ry = rotation + shearY - prx + 90;
|
|
||||||
la = COS_DEG(rx) * scaleX;
|
|
||||||
lb = COS_DEG(ry) * scaleY;
|
|
||||||
lc = SIN_DEG(rx) * scaleX;
|
|
||||||
ld = SIN_DEG(ry) * scaleY;
|
|
||||||
CONST_CAST(float, self->a) = pa * la - pb * lc;
|
|
||||||
CONST_CAST(float, self->b) = pa * lb - pb * ld;
|
|
||||||
CONST_CAST(float, self->c) = pc * la + pd * lc;
|
|
||||||
CONST_CAST(float, self->d) = pc * lb + pd * ld;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SP_TRANSFORMMODE_NOSCALE:
|
|
||||||
case SP_TRANSFORMMODE_NOSCALEORREFLECTION: {
|
|
||||||
float za, zc, s;
|
|
||||||
float r, zb, zd, la, lb, lc, ld;
|
|
||||||
cosine = COS_DEG(rotation); sine = SIN_DEG(rotation);
|
|
||||||
za = (pa * cosine + pb * sine) / sx;
|
|
||||||
zc = (pc * cosine + pd * sine) / sy;
|
|
||||||
s = SQRT(za * za + zc * zc);
|
|
||||||
if (s > 0.00001f) s = 1 / s;
|
|
||||||
za *= s;
|
|
||||||
zc *= s;
|
|
||||||
s = SQRT(za * za + zc * zc);
|
|
||||||
if (self->data->transformMode == SP_TRANSFORMMODE_NOSCALE && (pa * pd - pb * pc < 0) != (sx < 0 != sy < 0))
|
|
||||||
s = -s;
|
|
||||||
r = PI / 2 + ATAN2(zc, za);
|
|
||||||
zb = COS(r) * s;
|
|
||||||
zd = SIN(r) * s;
|
|
||||||
la = COS_DEG(shearX) * scaleX;
|
|
||||||
lb = COS_DEG(90 + shearY) * scaleY;
|
|
||||||
lc = SIN_DEG(shearX) * scaleX;
|
|
||||||
ld = SIN_DEG(90 + shearY) * scaleY;
|
|
||||||
CONST_CAST(float, self->a) = za * la + zb * lc;
|
|
||||||
CONST_CAST(float, self->b) = za * lb + zb * ld;
|
|
||||||
CONST_CAST(float, self->c) = zc * la + zd * lc;
|
|
||||||
CONST_CAST(float, self->d) = zc * lb + zd * ld;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
rx = rotation + shearX - prx;
|
||||||
|
ry = rotation + shearY - prx + 90;
|
||||||
|
la = COS_DEG(rx) * scaleX;
|
||||||
|
lb = COS_DEG(ry) * scaleY;
|
||||||
|
lc = SIN_DEG(rx) * scaleX;
|
||||||
|
ld = SIN_DEG(ry) * scaleY;
|
||||||
|
CONST_CAST(float, self->a) = pa * la - pb * lc;
|
||||||
|
CONST_CAST(float, self->b) = pa * lb - pb * ld;
|
||||||
|
CONST_CAST(float, self->c) = pc * la + pd * lc;
|
||||||
|
CONST_CAST(float, self->d) = pc * lb + pd * ld;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SP_TRANSFORMMODE_NOSCALE:
|
||||||
|
case SP_TRANSFORMMODE_NOSCALEORREFLECTION: {
|
||||||
|
float za, zc, s;
|
||||||
|
float r, zb, zd, la, lb, lc, ld;
|
||||||
|
cosine = COS_DEG(rotation); sine = SIN_DEG(rotation);
|
||||||
|
za = (pa * cosine + pb * sine) / sx;
|
||||||
|
zc = (pc * cosine + pd * sine) / sy;
|
||||||
|
s = SQRT(za * za + zc * zc);
|
||||||
|
if (s > 0.00001f) s = 1 / s;
|
||||||
|
za *= s;
|
||||||
|
zc *= s;
|
||||||
|
s = SQRT(za * za + zc * zc);
|
||||||
|
if (self->data->transformMode == SP_TRANSFORMMODE_NOSCALE && (pa * pd - pb * pc < 0) != (sx < 0 != sy < 0))
|
||||||
|
s = -s;
|
||||||
|
r = PI / 2 + ATAN2(zc, za);
|
||||||
|
zb = COS(r) * s;
|
||||||
|
zd = SIN(r) * s;
|
||||||
|
la = COS_DEG(shearX) * scaleX;
|
||||||
|
lb = COS_DEG(90 + shearY) * scaleY;
|
||||||
|
lc = SIN_DEG(shearX) * scaleX;
|
||||||
|
ld = SIN_DEG(90 + shearY) * scaleY;
|
||||||
|
CONST_CAST(float, self->a) = za * la + zb * lc;
|
||||||
|
CONST_CAST(float, self->b) = za * lb + zb * ld;
|
||||||
|
CONST_CAST(float, self->c) = zc * la + zd * lc;
|
||||||
|
CONST_CAST(float, self->d) = zc * lb + zd * ld;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CONST_CAST(float, self->a) *= sx;
|
CONST_CAST(float, self->a) *= sx;
|
||||||
|
|||||||
@ -59,12 +59,12 @@ void spIkConstraint_dispose(spIkConstraint *self) {
|
|||||||
|
|
||||||
void spIkConstraint_apply(spIkConstraint *self) {
|
void spIkConstraint_apply(spIkConstraint *self) {
|
||||||
switch (self->bonesCount) {
|
switch (self->bonesCount) {
|
||||||
case 1:
|
case 1:
|
||||||
spIkConstraint_apply1(self->bones[0], self->target->worldX, self->target->worldY, self->compress, self->stretch, self->data->uniform, self->mix);
|
spIkConstraint_apply1(self->bones[0], self->target->worldX, self->target->worldY, self->compress, self->stretch, self->data->uniform, self->mix);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
spIkConstraint_apply2(self->bones[0], self->bones[1], self->target->worldX, self->target->worldY, self->bendDirection, self->stretch, self->softness, self->mix);
|
spIkConstraint_apply2(self->bones[0], self->bones[1], self->target->worldX, self->target->worldY, self->bendDirection, self->stretch, self->softness, self->mix);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2009, Dave Gamble
|
Copyright (c) 2009, Dave Gamble
|
||||||
Copyright (c) 2013, Esoteric Software
|
Copyright (c) 2013, Esoteric Software
|
||||||
|
|
||||||
Permission is hereby granted, dispose of charge, to any person obtaining a copy
|
Permission is hereby granted, dispose of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Json */
|
/* Json */
|
||||||
/* JSON parser in C. */
|
/* JSON parser in C. */
|
||||||
@ -54,8 +54,7 @@ const char* Json_getError (void) {
|
|||||||
|
|
||||||
static int Json_strcasecmp (const char* s1, const char* s2) {
|
static int Json_strcasecmp (const char* s1, const char* s2) {
|
||||||
/* TODO we may be able to elide these NULL checks if we can prove
|
/* TODO we may be able to elide these NULL checks if we can prove
|
||||||
* the graph and input (only callsite is Json_getItem) should not have NULLs
|
the graph and input (only callsite is Json_getItem) should not have NULLs */
|
||||||
*/
|
|
||||||
if (s1 && s2) {
|
if (s1 && s2) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return _stricmp(s1, s2);
|
return _stricmp(s1, s2);
|
||||||
|
|||||||
@ -187,7 +187,6 @@ void spMeshAttachment_updateUVs (spMeshAttachment* self) {
|
|||||||
void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh) {
|
void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh) {
|
||||||
CONST_CAST(spMeshAttachment*, self->parentMesh) = parentMesh;
|
CONST_CAST(spMeshAttachment*, self->parentMesh) = parentMesh;
|
||||||
if (parentMesh) {
|
if (parentMesh) {
|
||||||
|
|
||||||
self->super.bones = parentMesh->super.bones;
|
self->super.bones = parentMesh->super.bones;
|
||||||
self->super.bonesCount = parentMesh->super.bonesCount;
|
self->super.bonesCount = parentMesh->super.bonesCount;
|
||||||
|
|
||||||
|
|||||||
@ -214,7 +214,7 @@ static void _addAfterPosition (float p, float* temp, int i, float* out, int o) {
|
|||||||
|
|
||||||
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
|
/* Need to pass 0 as an argument, so VC++ doesn't error with C2124 */
|
||||||
static int _isNan(float value, float zero) {
|
static int _isNan(float value, float zero) {
|
||||||
float _nan = (float)0.0 / zero;
|
float _nan = (float)0.0 / zero;
|
||||||
return 0 == memcmp((void*)&value, (void*)&_nan, sizeof(value));
|
return 0 == memcmp((void*)&value, (void*)&_nan, sizeof(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,11 +235,10 @@ static void _addCurvePosition (float p, float x1, float y1, float cx1, float cy1
|
|||||||
out[o] = x;
|
out[o] = x;
|
||||||
out[o + 1] = y;
|
out[o + 1] = y;
|
||||||
if (tangents) {
|
if (tangents) {
|
||||||
if (p < 0.001) {
|
if (p < 0.001)
|
||||||
out[o + 2] = ATAN2(cy1 - y1, cx1 - x1);
|
out[o + 2] = ATAN2(cy1 - y1, cx1 - x1);
|
||||||
} else {
|
else
|
||||||
out[o + 2] = ATAN2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
|
out[o + 2] = ATAN2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -251,8 +251,7 @@ static void _sortIkConstraint (_spSkeleton* const internal, spIkConstraint* cons
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!contains)
|
if (!contains) _addToUpdateCacheReset(internal, child);
|
||||||
_addToUpdateCacheReset(internal, child);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_addToUpdateCache(internal, SP_UPDATE_IK_CONSTRAINT, constraint);
|
_addToUpdateCache(internal, SP_UPDATE_IK_CONSTRAINT, constraint);
|
||||||
|
|||||||
@ -118,13 +118,13 @@ static int readVarint (_dataInput* input, int/*bool*/optimizePositive) {
|
|||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 7;
|
value |= (b & 0x7F) << 7;
|
||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
|
b = readByte(input);
|
||||||
|
value |= (b & 0x7F) << 14;
|
||||||
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 14;
|
value |= (b & 0x7F) << 21;
|
||||||
if (b & 0x80) {
|
if (b & 0x80) value |= (readByte(input) & 0x7F) << 28;
|
||||||
b = readByte(input);
|
}
|
||||||
value |= (b & 0x7F) << 21;
|
|
||||||
if (b & 0x80) value |= (readByte(input) & 0x7F) << 28;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!optimizePositive) value = (((unsigned int)value >> 1) ^ -(value & 1));
|
if (!optimizePositive) value = (((unsigned int)value >> 1) ^ -(value & 1));
|
||||||
@ -206,18 +206,18 @@ static void readColor (_dataInput* input, float *r, float *g, float *b, float *a
|
|||||||
|
|
||||||
static void readCurve (_dataInput* input, spCurveTimeline* timeline, int frameIndex) {
|
static void readCurve (_dataInput* input, spCurveTimeline* timeline, int frameIndex) {
|
||||||
switch (readByte(input)) {
|
switch (readByte(input)) {
|
||||||
case CURVE_STEPPED: {
|
case CURVE_STEPPED: {
|
||||||
spCurveTimeline_setStepped(timeline, frameIndex);
|
spCurveTimeline_setStepped(timeline, frameIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CURVE_BEZIER: {
|
case CURVE_BEZIER: {
|
||||||
float cx1 = readFloat(input);
|
float cx1 = readFloat(input);
|
||||||
float cy1 = readFloat(input);
|
float cy1 = readFloat(input);
|
||||||
float cx2 = readFloat(input);
|
float cx2 = readFloat(input);
|
||||||
float cy2 = readFloat(input);
|
float cy2 = readFloat(input);
|
||||||
spCurveTimeline_setCurve(timeline, frameIndex, cx1, cy1, cx2, cy2);
|
spCurveTimeline_setCurve(timeline, frameIndex, cx1, cy1, cx2, cy2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,56 +264,56 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
|
|||||||
unsigned char timelineType = readByte(input);
|
unsigned char timelineType = readByte(input);
|
||||||
int frameCount = readVarint(input, 1);
|
int frameCount = readVarint(input, 1);
|
||||||
switch (timelineType) {
|
switch (timelineType) {
|
||||||
case SLOT_ATTACHMENT: {
|
case SLOT_ATTACHMENT: {
|
||||||
spAttachmentTimeline* timeline = spAttachmentTimeline_create(frameCount);
|
spAttachmentTimeline* timeline = spAttachmentTimeline_create(frameCount);
|
||||||
timeline->slotIndex = slotIndex;
|
timeline->slotIndex = slotIndex;
|
||||||
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
const char* attachmentName = readStringRef(input, skeletonData);
|
const char* attachmentName = readStringRef(input, skeletonData);
|
||||||
/* TODO Avoid copying of attachmentName inside */
|
/* TODO Avoid copying of attachmentName inside */
|
||||||
spAttachmentTimeline_setFrame(timeline, frameIndex, time, attachmentName);
|
spAttachmentTimeline_setFrame(timeline, frameIndex, time, attachmentName);
|
||||||
}
|
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
|
||||||
duration = MAX(duration, timeline->frames[frameCount - 1]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case SLOT_COLOR: {
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
spColorTimeline* timeline = spColorTimeline_create(frameCount);
|
duration = MAX(duration, timeline->frames[frameCount - 1]);
|
||||||
timeline->slotIndex = slotIndex;
|
break;
|
||||||
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
}
|
||||||
float time = readFloat(input);
|
case SLOT_COLOR: {
|
||||||
float r, g, b, a;
|
spColorTimeline* timeline = spColorTimeline_create(frameCount);
|
||||||
readColor(input, &r, &g, &b, &a);
|
timeline->slotIndex = slotIndex;
|
||||||
spColorTimeline_setFrame(timeline, frameIndex, time, r, g, b, a);
|
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
float time = readFloat(input);
|
||||||
}
|
float r, g, b, a;
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
readColor(input, &r, &g, &b, &a);
|
||||||
duration = MAX(duration, timeline->frames[(frameCount - 1) * COLOR_ENTRIES]);
|
spColorTimeline_setFrame(timeline, frameIndex, time, r, g, b, a);
|
||||||
break;
|
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
||||||
}
|
}
|
||||||
case SLOT_TWO_COLOR: {
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
spTwoColorTimeline* timeline = spTwoColorTimeline_create(frameCount);
|
duration = MAX(duration, timeline->frames[(frameCount - 1) * COLOR_ENTRIES]);
|
||||||
timeline->slotIndex = slotIndex;
|
break;
|
||||||
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
}
|
||||||
float time = readFloat(input);
|
case SLOT_TWO_COLOR: {
|
||||||
float r, g, b, a;
|
spTwoColorTimeline* timeline = spTwoColorTimeline_create(frameCount);
|
||||||
float r2, g2, b2, a2;
|
timeline->slotIndex = slotIndex;
|
||||||
readColor(input, &r, &g, &b, &a);
|
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
readColor(input, &a2, &r2, &g2, &b2);
|
float time = readFloat(input);
|
||||||
spTwoColorTimeline_setFrame(timeline, frameIndex, time, r, g, b, a, r2, g2, b2);
|
float r, g, b, a;
|
||||||
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
float r2, g2, b2, a2;
|
||||||
}
|
readColor(input, &r, &g, &b, &a);
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
readColor(input, &a2, &r2, &g2, &b2);
|
||||||
duration = MAX(duration, timeline->frames[(frameCount - 1) * TWOCOLOR_ENTRIES]);
|
spTwoColorTimeline_setFrame(timeline, frameIndex, time, r, g, b, a, r2, g2, b2);
|
||||||
break;
|
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
||||||
}
|
|
||||||
default: {
|
|
||||||
for (iii = 0; iii < timelines->size; ++iii)
|
|
||||||
spTimeline_dispose(timelines->items[iii]);
|
|
||||||
spTimelineArray_dispose(timelines);
|
|
||||||
_spSkeletonBinary_setError(self, "Invalid timeline type for a slot: ", skeletonData->slots[slotIndex]->name);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
|
duration = MAX(duration, timeline->frames[(frameCount - 1) * TWOCOLOR_ENTRIES]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
for (iii = 0; iii < timelines->size; ++iii)
|
||||||
|
spTimeline_dispose(timelines->items[iii]);
|
||||||
|
spTimelineArray_dispose(timelines);
|
||||||
|
_spSkeletonBinary_setError(self, "Invalid timeline type for a slot: ", skeletonData->slots[slotIndex]->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,57 +325,57 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
|
|||||||
unsigned char timelineType = readByte(input);
|
unsigned char timelineType = readByte(input);
|
||||||
int frameCount = readVarint(input, 1);
|
int frameCount = readVarint(input, 1);
|
||||||
switch (timelineType) {
|
switch (timelineType) {
|
||||||
case BONE_ROTATE: {
|
case BONE_ROTATE: {
|
||||||
spRotateTimeline *timeline = spRotateTimeline_create(frameCount);
|
spRotateTimeline *timeline = spRotateTimeline_create(frameCount);
|
||||||
timeline->boneIndex = boneIndex;
|
timeline->boneIndex = boneIndex;
|
||||||
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
float time = readFloat(input);
|
float time = readFloat(input);
|
||||||
float degrees = readFloat(input);
|
float degrees = readFloat(input);
|
||||||
spRotateTimeline_setFrame(timeline, frameIndex, time, degrees);
|
spRotateTimeline_setFrame(timeline, frameIndex, time, degrees);
|
||||||
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
||||||
}
|
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
|
||||||
duration = MAX(duration, timeline->frames[(frameCount - 1) * ROTATE_ENTRIES]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case BONE_TRANSLATE:
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
case BONE_SCALE:
|
duration = MAX(duration, timeline->frames[(frameCount - 1) * ROTATE_ENTRIES]);
|
||||||
case BONE_SHEAR: {
|
break;
|
||||||
float timelineScale = 1;
|
}
|
||||||
spTranslateTimeline *timeline = 0;
|
case BONE_TRANSLATE:
|
||||||
switch (timelineType) {
|
case BONE_SCALE:
|
||||||
case BONE_SCALE:
|
case BONE_SHEAR: {
|
||||||
timeline = spScaleTimeline_create(frameCount);
|
float timelineScale = 1;
|
||||||
break;
|
spTranslateTimeline *timeline = 0;
|
||||||
case BONE_SHEAR:
|
switch (timelineType) {
|
||||||
timeline = spShearTimeline_create(frameCount);
|
case BONE_SCALE:
|
||||||
break;
|
timeline = spScaleTimeline_create(frameCount);
|
||||||
case BONE_TRANSLATE:
|
break;
|
||||||
timeline = spTranslateTimeline_create(frameCount);
|
case BONE_SHEAR:
|
||||||
timelineScale = self->scale;
|
timeline = spShearTimeline_create(frameCount);
|
||||||
break;
|
break;
|
||||||
default:
|
case BONE_TRANSLATE:
|
||||||
break;
|
timeline = spTranslateTimeline_create(frameCount);
|
||||||
}
|
timelineScale = self->scale;
|
||||||
timeline->boneIndex = boneIndex;
|
break;
|
||||||
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
default:
|
||||||
float time = readFloat(input);
|
break;
|
||||||
float x = readFloat(input) * timelineScale;
|
|
||||||
float y = readFloat(input) * timelineScale;
|
|
||||||
spTranslateTimeline_setFrame(timeline, frameIndex, time, x, y);
|
|
||||||
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
|
||||||
}
|
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
|
||||||
duration = MAX(duration, timeline->frames[(frameCount - 1) * TRANSLATE_ENTRIES]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default: {
|
timeline->boneIndex = boneIndex;
|
||||||
for (iii = 0; iii < timelines->size; ++iii)
|
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
spTimeline_dispose(timelines->items[iii]);
|
float time = readFloat(input);
|
||||||
spTimelineArray_dispose(timelines);
|
float x = readFloat(input) * timelineScale;
|
||||||
_spSkeletonBinary_setError(self, "Invalid timeline type for a bone: ", skeletonData->bones[boneIndex]->name);
|
float y = readFloat(input) * timelineScale;
|
||||||
return 0;
|
spTranslateTimeline_setFrame(timeline, frameIndex, time, x, y);
|
||||||
|
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
||||||
}
|
}
|
||||||
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
|
duration = MAX(duration, timeline->frames[(frameCount - 1) * TRANSLATE_ENTRIES]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
for (iii = 0; iii < timelines->size; ++iii)
|
||||||
|
spTimeline_dispose(timelines->items[iii]);
|
||||||
|
spTimelineArray_dispose(timelines);
|
||||||
|
_spSkeletonBinary_setError(self, "Invalid timeline type for a bone: ", skeletonData->bones[boneIndex]->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,7 +413,7 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
|
|||||||
float scaleMix = readFloat(input);
|
float scaleMix = readFloat(input);
|
||||||
float shearMix = readFloat(input);
|
float shearMix = readFloat(input);
|
||||||
spTransformConstraintTimeline_setFrame(timeline, frameIndex, time, rotateMix, translateMix,
|
spTransformConstraintTimeline_setFrame(timeline, frameIndex, time, rotateMix, translateMix,
|
||||||
scaleMix, shearMix);
|
scaleMix, shearMix);
|
||||||
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
||||||
}
|
}
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
@ -428,43 +428,43 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
|
|||||||
unsigned char timelineType = readByte(input);
|
unsigned char timelineType = readByte(input);
|
||||||
int frameCount = readVarint(input, 1);
|
int frameCount = readVarint(input, 1);
|
||||||
switch (timelineType) {
|
switch (timelineType) {
|
||||||
case PATH_POSITION:
|
case PATH_POSITION:
|
||||||
case PATH_SPACING: {
|
case PATH_SPACING: {
|
||||||
spPathConstraintPositionTimeline* timeline = 0;
|
spPathConstraintPositionTimeline* timeline = 0;
|
||||||
float timelineScale = 1;
|
float timelineScale = 1;
|
||||||
if (timelineType == PATH_SPACING) {
|
if (timelineType == PATH_SPACING) {
|
||||||
timeline = (spPathConstraintPositionTimeline*)spPathConstraintSpacingTimeline_create(frameCount);
|
timeline = (spPathConstraintPositionTimeline*)spPathConstraintSpacingTimeline_create(frameCount);
|
||||||
if (data->spacingMode == SP_SPACING_MODE_LENGTH || data->spacingMode == SP_SPACING_MODE_FIXED)
|
if (data->spacingMode == SP_SPACING_MODE_LENGTH || data->spacingMode == SP_SPACING_MODE_FIXED)
|
||||||
timelineScale = self->scale;
|
timelineScale = self->scale;
|
||||||
} else {
|
} else {
|
||||||
timeline = spPathConstraintPositionTimeline_create(frameCount);
|
timeline = spPathConstraintPositionTimeline_create(frameCount);
|
||||||
if (data->positionMode == SP_POSITION_MODE_FIXED)
|
if (data->positionMode == SP_POSITION_MODE_FIXED)
|
||||||
timelineScale = self->scale;
|
timelineScale = self->scale;
|
||||||
}
|
|
||||||
timeline->pathConstraintIndex = index;
|
|
||||||
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
|
||||||
float time = readFloat(input);
|
|
||||||
float value = readFloat(input) * timelineScale;
|
|
||||||
spPathConstraintPositionTimeline_setFrame(timeline, frameIndex, time, value);
|
|
||||||
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
|
||||||
}
|
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
|
||||||
duration = MAX(duration, timeline->frames[(frameCount - 1) * PATHCONSTRAINTPOSITION_ENTRIES]);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case PATH_MIX: {
|
timeline->pathConstraintIndex = index;
|
||||||
spPathConstraintMixTimeline* timeline = spPathConstraintMixTimeline_create(frameCount);
|
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
timeline->pathConstraintIndex = index;
|
float time = readFloat(input);
|
||||||
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
float value = readFloat(input) * timelineScale;
|
||||||
float time = readFloat(input);
|
spPathConstraintPositionTimeline_setFrame(timeline, frameIndex, time, value);
|
||||||
float rotateMix = readFloat(input);
|
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
||||||
float translateMix = readFloat(input);
|
|
||||||
spPathConstraintMixTimeline_setFrame(timeline, frameIndex, time, rotateMix, translateMix);
|
|
||||||
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
|
||||||
}
|
|
||||||
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
|
||||||
duration = MAX(duration, timeline->frames[(frameCount - 1) * PATHCONSTRAINTMIX_ENTRIES]);
|
|
||||||
}
|
}
|
||||||
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
|
duration = MAX(duration, timeline->frames[(frameCount - 1) * PATHCONSTRAINTPOSITION_ENTRIES]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PATH_MIX: {
|
||||||
|
spPathConstraintMixTimeline* timeline = spPathConstraintMixTimeline_create(frameCount);
|
||||||
|
timeline->pathConstraintIndex = index;
|
||||||
|
for (frameIndex = 0; frameIndex < frameCount; ++frameIndex) {
|
||||||
|
float time = readFloat(input);
|
||||||
|
float rotateMix = readFloat(input);
|
||||||
|
float translateMix = readFloat(input);
|
||||||
|
spPathConstraintMixTimeline_setFrame(timeline, frameIndex, time, rotateMix, translateMix);
|
||||||
|
if (frameIndex < frameCount - 1) readCurve(input, SUPER(timeline), frameIndex);
|
||||||
|
}
|
||||||
|
spTimelineArray_add(timelines, (spTimeline*)timeline);
|
||||||
|
duration = MAX(duration, timeline->frames[(frameCount - 1) * PATHCONSTRAINTMIX_ENTRIES]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,7 +482,7 @@ static spAnimation* _spSkeletonBinary_readAnimation (spSkeletonBinary* self, con
|
|||||||
int frameCount;
|
int frameCount;
|
||||||
|
|
||||||
spVertexAttachment* attachment = SUB_CAST(spVertexAttachment,
|
spVertexAttachment* attachment = SUB_CAST(spVertexAttachment,
|
||||||
spSkin_getAttachment(skin, slotIndex, attachmentName));
|
spSkin_getAttachment(skin, slotIndex, attachmentName));
|
||||||
if (!attachment) {
|
if (!attachment) {
|
||||||
for (i = 0; i < timelines->size; ++i)
|
for (i = 0; i < timelines->size; ++i)
|
||||||
spTimeline_dispose(timelines->items[i]);
|
spTimeline_dispose(timelines->items[i]);
|
||||||
@ -684,140 +684,140 @@ spAttachment* spSkeletonBinary_readAttachment(spSkeletonBinary* self, _dataInput
|
|||||||
type = (spAttachmentType)readByte(input);
|
type = (spAttachmentType)readByte(input);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SP_ATTACHMENT_REGION: {
|
case SP_ATTACHMENT_REGION: {
|
||||||
const char* path = readStringRef(input, skeletonData);
|
const char* path = readStringRef(input, skeletonData);
|
||||||
spAttachment* attachment;
|
spAttachment* attachment;
|
||||||
spRegionAttachment* region;
|
spRegionAttachment* region;
|
||||||
if (!path) MALLOC_STR(path, name);
|
if (!path) MALLOC_STR(path, name);
|
||||||
else {
|
else {
|
||||||
const char* tmp = 0;
|
const char* tmp = 0;
|
||||||
MALLOC_STR(tmp, path);
|
MALLOC_STR(tmp, path);
|
||||||
path = tmp;
|
path = tmp;
|
||||||
}
|
|
||||||
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path);
|
|
||||||
region = SUB_CAST(spRegionAttachment, attachment);
|
|
||||||
region->path = path;
|
|
||||||
region->rotation = readFloat(input);
|
|
||||||
region->x = readFloat(input) * self->scale;
|
|
||||||
region->y = readFloat(input) * self->scale;
|
|
||||||
region->scaleX = readFloat(input);
|
|
||||||
region->scaleY = readFloat(input);
|
|
||||||
region->width = readFloat(input) * self->scale;
|
|
||||||
region->height = readFloat(input) * self->scale;
|
|
||||||
readColor(input, ®ion->color.r, ®ion->color.g, ®ion->color.b, ®ion->color.a);
|
|
||||||
spRegionAttachment_updateOffset(region);
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
return attachment;
|
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_BOUNDING_BOX: {
|
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path);
|
||||||
int vertexCount = readVarint(input, 1);
|
region = SUB_CAST(spRegionAttachment, attachment);
|
||||||
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
region->path = path;
|
||||||
_readVertices(self, input, SUB_CAST(spVertexAttachment, attachment), vertexCount);
|
region->rotation = readFloat(input);
|
||||||
if (nonessential) readInt(input); /* Skip color. */
|
region->x = readFloat(input) * self->scale;
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
region->y = readFloat(input) * self->scale;
|
||||||
return attachment;
|
region->scaleX = readFloat(input);
|
||||||
|
region->scaleY = readFloat(input);
|
||||||
|
region->width = readFloat(input) * self->scale;
|
||||||
|
region->height = readFloat(input) * self->scale;
|
||||||
|
readColor(input, ®ion->color.r, ®ion->color.g, ®ion->color.b, ®ion->color.a);
|
||||||
|
spRegionAttachment_updateOffset(region);
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_BOUNDING_BOX: {
|
||||||
|
int vertexCount = readVarint(input, 1);
|
||||||
|
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
||||||
|
_readVertices(self, input, SUB_CAST(spVertexAttachment, attachment), vertexCount);
|
||||||
|
if (nonessential) readInt(input); /* Skip color. */
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_MESH: {
|
||||||
|
int vertexCount;
|
||||||
|
spAttachment* attachment;
|
||||||
|
spMeshAttachment* mesh;
|
||||||
|
const char* path = readStringRef(input, skeletonData);
|
||||||
|
if (!path) MALLOC_STR(path, name);
|
||||||
|
else {
|
||||||
|
const char* tmp = 0;
|
||||||
|
MALLOC_STR(tmp, path);
|
||||||
|
path = tmp;
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_MESH: {
|
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path);
|
||||||
int vertexCount;
|
mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||||
spAttachment* attachment;
|
mesh->path = path;
|
||||||
spMeshAttachment* mesh;
|
readColor(input, &mesh->color.r, &mesh->color.g, &mesh->color.b, &mesh->color.a);
|
||||||
const char* path = readStringRef(input, skeletonData);
|
vertexCount = readVarint(input, 1);
|
||||||
if (!path) MALLOC_STR(path, name);
|
mesh->regionUVs = _readFloatArray(input, vertexCount << 1, 1);
|
||||||
else {
|
mesh->triangles = (unsigned short*)_readShortArray(input, &mesh->trianglesCount);
|
||||||
const char* tmp = 0;
|
_readVertices(self, input, SUPER(mesh), vertexCount);
|
||||||
MALLOC_STR(tmp, path);
|
spMeshAttachment_updateUVs(mesh);
|
||||||
path = tmp;
|
mesh->hullLength = readVarint(input, 1) << 1;
|
||||||
}
|
if (nonessential) {
|
||||||
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path);
|
mesh->edges = (int*)_readShortArray(input, &mesh->edgesCount);
|
||||||
mesh = SUB_CAST(spMeshAttachment, attachment);
|
mesh->width = readFloat(input) * self->scale;
|
||||||
mesh->path = path;
|
mesh->height = readFloat(input) * self->scale;
|
||||||
readColor(input, &mesh->color.r, &mesh->color.g, &mesh->color.b, &mesh->color.a);
|
} else {
|
||||||
vertexCount = readVarint(input, 1);
|
mesh->edges = 0;
|
||||||
mesh->regionUVs = _readFloatArray(input, vertexCount << 1, 1);
|
mesh->width = 0;
|
||||||
mesh->triangles = (unsigned short*)_readShortArray(input, &mesh->trianglesCount);
|
mesh->height = 0;
|
||||||
_readVertices(self, input, SUPER(mesh), vertexCount);
|
|
||||||
spMeshAttachment_updateUVs(mesh);
|
|
||||||
mesh->hullLength = readVarint(input, 1) << 1;
|
|
||||||
if (nonessential) {
|
|
||||||
mesh->edges = (int*)_readShortArray(input, &mesh->edgesCount);
|
|
||||||
mesh->width = readFloat(input) * self->scale;
|
|
||||||
mesh->height = readFloat(input) * self->scale;
|
|
||||||
} else {
|
|
||||||
mesh->edges = 0;
|
|
||||||
mesh->width = 0;
|
|
||||||
mesh->height = 0;
|
|
||||||
}
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
return attachment;
|
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_LINKED_MESH: {
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
const char* skinName;
|
return attachment;
|
||||||
const char* parent;
|
}
|
||||||
spAttachment* attachment;
|
case SP_ATTACHMENT_LINKED_MESH: {
|
||||||
spMeshAttachment* mesh;
|
const char* skinName;
|
||||||
int inheritDeform;
|
const char* parent;
|
||||||
const char* path = readStringRef(input, skeletonData);
|
spAttachment* attachment;
|
||||||
if (!path) MALLOC_STR(path, name);
|
spMeshAttachment* mesh;
|
||||||
else {
|
int inheritDeform;
|
||||||
const char* tmp = 0;
|
const char* path = readStringRef(input, skeletonData);
|
||||||
MALLOC_STR(tmp, path);
|
if (!path) MALLOC_STR(path, name);
|
||||||
path = tmp;
|
else {
|
||||||
}
|
const char* tmp = 0;
|
||||||
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path);
|
MALLOC_STR(tmp, path);
|
||||||
mesh = SUB_CAST(spMeshAttachment, attachment);
|
path = tmp;
|
||||||
mesh->path = path;
|
|
||||||
readColor(input, &mesh->color.r, &mesh->color.g, &mesh->color.b, &mesh->color.a);
|
|
||||||
skinName = readStringRef(input, skeletonData);
|
|
||||||
parent = readStringRef(input, skeletonData);
|
|
||||||
inheritDeform = readBoolean(input);
|
|
||||||
if (nonessential) {
|
|
||||||
mesh->width = readFloat(input) * self->scale;
|
|
||||||
mesh->height = readFloat(input) * self->scale;
|
|
||||||
}
|
|
||||||
_spSkeletonBinary_addLinkedMesh(self, mesh, skinName, slotIndex, parent, inheritDeform);
|
|
||||||
return attachment;
|
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_PATH: {
|
attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, path);
|
||||||
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
mesh = SUB_CAST(spMeshAttachment, attachment);
|
||||||
spPathAttachment* path = SUB_CAST(spPathAttachment, attachment);
|
mesh->path = path;
|
||||||
int vertexCount = 0;
|
readColor(input, &mesh->color.r, &mesh->color.g, &mesh->color.b, &mesh->color.a);
|
||||||
path->closed = readBoolean(input);
|
skinName = readStringRef(input, skeletonData);
|
||||||
path->constantSpeed = readBoolean(input);
|
parent = readStringRef(input, skeletonData);
|
||||||
vertexCount = readVarint(input, 1);
|
inheritDeform = readBoolean(input);
|
||||||
_readVertices(self, input, SUPER(path), vertexCount);
|
if (nonessential) {
|
||||||
path->lengthsLength = vertexCount / 3;
|
mesh->width = readFloat(input) * self->scale;
|
||||||
path->lengths = MALLOC(float, path->lengthsLength);
|
mesh->height = readFloat(input) * self->scale;
|
||||||
for (i = 0; i < path->lengthsLength; ++i) {
|
|
||||||
path->lengths[i] = readFloat(input) * self->scale;
|
|
||||||
}
|
|
||||||
if (nonessential) readInt(input); /* Skip color. */
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
return attachment;
|
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_POINT: {
|
_spSkeletonBinary_addLinkedMesh(self, mesh, skinName, slotIndex, parent, inheritDeform);
|
||||||
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
return attachment;
|
||||||
spPointAttachment* point = SUB_CAST(spPointAttachment, attachment);
|
}
|
||||||
point->rotation = readFloat(input);
|
case SP_ATTACHMENT_PATH: {
|
||||||
point->x = readFloat(input) * self->scale;
|
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
||||||
point->y = readFloat(input) * self->scale;
|
spPathAttachment* path = SUB_CAST(spPathAttachment, attachment);
|
||||||
|
int vertexCount = 0;
|
||||||
|
path->closed = readBoolean(input);
|
||||||
|
path->constantSpeed = readBoolean(input);
|
||||||
|
vertexCount = readVarint(input, 1);
|
||||||
|
_readVertices(self, input, SUPER(path), vertexCount);
|
||||||
|
path->lengthsLength = vertexCount / 3;
|
||||||
|
path->lengths = MALLOC(float, path->lengthsLength);
|
||||||
|
for (i = 0; i < path->lengthsLength; ++i) {
|
||||||
|
path->lengths[i] = readFloat(input) * self->scale;
|
||||||
|
}
|
||||||
|
if (nonessential) readInt(input); /* Skip color. */
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_POINT: {
|
||||||
|
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
||||||
|
spPointAttachment* point = SUB_CAST(spPointAttachment, attachment);
|
||||||
|
point->rotation = readFloat(input);
|
||||||
|
point->x = readFloat(input) * self->scale;
|
||||||
|
point->y = readFloat(input) * self->scale;
|
||||||
|
|
||||||
if (nonessential) {
|
if (nonessential) {
|
||||||
readColor(input, &point->color.r, &point->color.g, &point->color.b, &point->color.a);
|
readColor(input, &point->color.r, &point->color.g, &point->color.b, &point->color.a);
|
||||||
}
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
return attachment;
|
|
||||||
}
|
|
||||||
case SP_ATTACHMENT_CLIPPING: {
|
|
||||||
int endSlotIndex = readVarint(input, 1);
|
|
||||||
int vertexCount = readVarint(input, 1);
|
|
||||||
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
|
||||||
spClippingAttachment* clip = SUB_CAST(spClippingAttachment, attachment);
|
|
||||||
_readVertices(self, input, SUB_CAST(spVertexAttachment, attachment), vertexCount);
|
|
||||||
if (nonessential) readInt(input); /* Skip color. */
|
|
||||||
clip->endSlot = skeletonData->slots[endSlotIndex];
|
|
||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
|
||||||
return attachment;
|
|
||||||
}
|
}
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
case SP_ATTACHMENT_CLIPPING: {
|
||||||
|
int endSlotIndex = readVarint(input, 1);
|
||||||
|
int vertexCount = readVarint(input, 1);
|
||||||
|
spAttachment* attachment = spAttachmentLoader_createAttachment(self->attachmentLoader, skin, type, name, 0);
|
||||||
|
spClippingAttachment* clip = SUB_CAST(spClippingAttachment, attachment);
|
||||||
|
_readVertices(self, input, SUB_CAST(spVertexAttachment, attachment), vertexCount);
|
||||||
|
if (nonessential) readInt(input); /* Skip color. */
|
||||||
|
clip->endSlot = skeletonData->slots[endSlotIndex];
|
||||||
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -942,11 +942,11 @@ spSkeletonData* spSkeletonBinary_readSkeletonData (spSkeletonBinary* self, const
|
|||||||
data->length = readFloat(input) * self->scale;
|
data->length = readFloat(input) * self->scale;
|
||||||
mode = readVarint(input, 1);
|
mode = readVarint(input, 1);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0: data->transformMode = SP_TRANSFORMMODE_NORMAL; break;
|
case 0: data->transformMode = SP_TRANSFORMMODE_NORMAL; break;
|
||||||
case 1: data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION; break;
|
case 1: data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION; break;
|
||||||
case 2: data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION; break;
|
case 2: data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION; break;
|
||||||
case 3: data->transformMode = SP_TRANSFORMMODE_NOSCALE; break;
|
case 3: data->transformMode = SP_TRANSFORMMODE_NOSCALE; break;
|
||||||
case 4: data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION; break;
|
case 4: data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION; break;
|
||||||
}
|
}
|
||||||
data->skinRequired = readBoolean(input);
|
data->skinRequired = readBoolean(input);
|
||||||
if (nonessential) readInt(input); /* Skip bone color. */
|
if (nonessential) readInt(input); /* Skip bone color. */
|
||||||
|
|||||||
@ -166,8 +166,11 @@ int/*bool*/spSkeletonBounds_aabbContainsPoint (spSkeletonBounds* self, float x,
|
|||||||
|
|
||||||
int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) {
|
int/*bool*/spSkeletonBounds_aabbIntersectsSegment (spSkeletonBounds* self, float x1, float y1, float x2, float y2) {
|
||||||
float m, x, y;
|
float m, x, y;
|
||||||
if ((x1 <= self->minX && x2 <= self->minX) || (y1 <= self->minY && y2 <= self->minY) || (x1 >= self->maxX && x2 >= self->maxX)
|
if ((x1 <= self->minX && x2 <= self->minX)
|
||||||
|| (y1 >= self->maxY && y2 >= self->maxY)) return 0;
|
|| (y1 <= self->minY && y2 <= self->minY)
|
||||||
|
|| (x1 >= self->maxX && x2 >= self->maxX)
|
||||||
|
|| (y1 >= self->maxY && y2 >= self->maxY)
|
||||||
|
) return 0;
|
||||||
m = (y2 - y1) / (x2 - x1);
|
m = (y2 - y1) / (x2 - x1);
|
||||||
y = m * (self->minX - x1) + y1;
|
y = m * (self->minX - x1) + y1;
|
||||||
if (y > self->minY && y < self->maxY) return 1;
|
if (y > self->minY && y < self->maxY) return 1;
|
||||||
|
|||||||
@ -93,8 +93,7 @@ static float toColor (const char* value, int index) {
|
|||||||
char *error;
|
char *error;
|
||||||
int color;
|
int color;
|
||||||
|
|
||||||
if ((size_t)index >= strlen(value) / 2)
|
if ((size_t)index >= strlen(value) / 2) return -1;
|
||||||
return -1;
|
|
||||||
value += index * 2;
|
value += index * 2;
|
||||||
|
|
||||||
digits[0] = *value;
|
digits[0] = *value;
|
||||||
@ -120,7 +119,8 @@ static void readCurve (Json* frame, spCurveTimeline* timeline, int frameIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _spSkeletonJson_addLinkedMesh (spSkeletonJson* self, spMeshAttachment* mesh, const char* skin, int slotIndex,
|
static void _spSkeletonJson_addLinkedMesh (spSkeletonJson* self, spMeshAttachment* mesh, const char* skin, int slotIndex,
|
||||||
const char* parent, int inheritDeform) {
|
const char* parent, int inheritDeform
|
||||||
|
) {
|
||||||
_spLinkedMesh* linkedMesh;
|
_spLinkedMesh* linkedMesh;
|
||||||
_spSkeletonJson* internal = SUB_CAST(_spSkeletonJson, self);
|
_spSkeletonJson* internal = SUB_CAST(_spSkeletonJson, self);
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
|
|||||||
for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
|
for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
|
||||||
Json* name = Json_getItem(valueMap, "name");
|
Json* name = Json_getItem(valueMap, "name");
|
||||||
spAttachmentTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0),
|
spAttachmentTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0),
|
||||||
name->type == Json_NULL ? 0 : name->valueString);
|
name->type == Json_NULL ? 0 : name->valueString);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
||||||
animation->duration = MAX(animation->duration, timeline->frames[timelineMap->size - 1]);
|
animation->duration = MAX(animation->duration, timeline->frames[timelineMap->size - 1]);
|
||||||
@ -206,8 +206,8 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
|
|||||||
|
|
||||||
for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
|
for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
|
||||||
const char* s = Json_getString(valueMap, "color", 0);
|
const char* s = Json_getString(valueMap, "color", 0);
|
||||||
spColorTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2),
|
spColorTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), toColor(s, 0), toColor(s, 1),
|
||||||
toColor(s, 3));
|
toColor(s, 2), toColor(s, 3));
|
||||||
readCurve(valueMap, SUPER(timeline), frameIndex);
|
readCurve(valueMap, SUPER(timeline), frameIndex);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
||||||
@ -221,7 +221,7 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
|
|||||||
const char* s = Json_getString(valueMap, "light", 0);
|
const char* s = Json_getString(valueMap, "light", 0);
|
||||||
const char* ds = Json_getString(valueMap, "dark", 0);
|
const char* ds = Json_getString(valueMap, "dark", 0);
|
||||||
spTwoColorTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2),
|
spTwoColorTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), toColor(s, 0), toColor(s, 1), toColor(s, 2),
|
||||||
toColor(s, 3), toColor(ds, 0), toColor(ds, 1), toColor(ds, 2));
|
toColor(s, 3), toColor(ds, 0), toColor(ds, 1), toColor(ds, 2));
|
||||||
readCurve(valueMap, SUPER(timeline), frameIndex);
|
readCurve(valueMap, SUPER(timeline), frameIndex);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
||||||
@ -275,8 +275,9 @@ static spAnimation* _spSkeletonJson_readAnimation (spSkeletonJson* self, Json* r
|
|||||||
timeline->boneIndex = boneIndex;
|
timeline->boneIndex = boneIndex;
|
||||||
|
|
||||||
for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
|
for (valueMap = timelineMap->child, frameIndex = 0; valueMap; valueMap = valueMap->next, ++frameIndex) {
|
||||||
spTranslateTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0), Json_getFloat(valueMap, "x", defaultValue) * timelineScale,
|
spTranslateTimeline_setFrame(timeline, frameIndex, Json_getFloat(valueMap, "time", 0),
|
||||||
Json_getFloat(valueMap, "y", defaultValue) * timelineScale);
|
Json_getFloat(valueMap, "x", defaultValue) * timelineScale,
|
||||||
|
Json_getFloat(valueMap, "y", defaultValue) * timelineScale);
|
||||||
readCurve(valueMap, SUPER(timeline), frameIndex);
|
readCurve(valueMap, SUPER(timeline), frameIndex);
|
||||||
}
|
}
|
||||||
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
animation->timelines[animation->timelinesCount++] = SUPER_CAST(spTimeline, timeline);
|
||||||
@ -641,16 +642,11 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
data->shearY = Json_getFloat(boneMap, "shearY", 0);
|
data->shearY = Json_getFloat(boneMap, "shearY", 0);
|
||||||
transformMode = Json_getString(boneMap, "transform", "normal");
|
transformMode = Json_getString(boneMap, "transform", "normal");
|
||||||
data->transformMode = SP_TRANSFORMMODE_NORMAL;
|
data->transformMode = SP_TRANSFORMMODE_NORMAL;
|
||||||
if (strcmp(transformMode, "normal") == 0)
|
if (strcmp(transformMode, "normal") == 0) data->transformMode = SP_TRANSFORMMODE_NORMAL;
|
||||||
data->transformMode = SP_TRANSFORMMODE_NORMAL;
|
else if (strcmp(transformMode, "onlyTranslation") == 0) data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION;
|
||||||
if (strcmp(transformMode, "onlyTranslation") == 0)
|
else if (strcmp(transformMode, "noRotationOrReflection") == 0) data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION;
|
||||||
data->transformMode = SP_TRANSFORMMODE_ONLYTRANSLATION;
|
else if (strcmp(transformMode, "noScale") == 0) data->transformMode = SP_TRANSFORMMODE_NOSCALE;
|
||||||
if (strcmp(transformMode, "noRotationOrReflection") == 0)
|
else if (strcmp(transformMode, "noScaleOrReflection") == 0) data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION;
|
||||||
data->transformMode = SP_TRANSFORMMODE_NOROTATIONORREFLECTION;
|
|
||||||
if (strcmp(transformMode, "noScale") == 0)
|
|
||||||
data->transformMode = SP_TRANSFORMMODE_NOSCALE;
|
|
||||||
if (strcmp(transformMode, "noScaleOrReflection") == 0)
|
|
||||||
data->transformMode = SP_TRANSFORMMODE_NOSCALEORREFLECTION;
|
|
||||||
data->skinRequired = Json_getInt(boneMap, "skin", 0) ? 1 : 0;
|
data->skinRequired = Json_getInt(boneMap, "skin", 0) ? 1 : 0;
|
||||||
|
|
||||||
skeletonData->bones[i] = data;
|
skeletonData->bones[i] = data;
|
||||||
@ -682,20 +678,20 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
color = Json_getString(slotMap, "color", 0);
|
color = Json_getString(slotMap, "color", 0);
|
||||||
if (color) {
|
if (color) {
|
||||||
spColor_setFromFloats(&data->color,
|
spColor_setFromFloats(&data->color,
|
||||||
toColor(color, 0),
|
toColor(color, 0),
|
||||||
toColor(color, 1),
|
toColor(color, 1),
|
||||||
toColor(color, 2),
|
toColor(color, 2),
|
||||||
toColor(color, 3));
|
toColor(color, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
dark = Json_getString(slotMap, "dark", 0);
|
dark = Json_getString(slotMap, "dark", 0);
|
||||||
if (dark) {
|
if (dark) {
|
||||||
data->darkColor = spColor_create();
|
data->darkColor = spColor_create();
|
||||||
spColor_setFromFloats(data->darkColor,
|
spColor_setFromFloats(data->darkColor,
|
||||||
toColor(dark, 0),
|
toColor(dark, 0),
|
||||||
toColor(dark, 1),
|
toColor(dark, 1),
|
||||||
toColor(dark, 2),
|
toColor(dark, 2),
|
||||||
toColor(dark, 3));
|
toColor(dark, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
item = Json_getItem(slotMap, "attachment");
|
item = Json_getItem(slotMap, "attachment");
|
||||||
@ -950,20 +946,13 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
|
|
||||||
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
const char* typeString = Json_getString(attachmentMap, "type", "region");
|
||||||
spAttachmentType type;
|
spAttachmentType type;
|
||||||
if (strcmp(typeString, "region") == 0)
|
if (strcmp(typeString, "region") == 0) type = SP_ATTACHMENT_REGION;
|
||||||
type = SP_ATTACHMENT_REGION;
|
else if (strcmp(typeString, "mesh") == 0) type = SP_ATTACHMENT_MESH;
|
||||||
else if (strcmp(typeString, "mesh") == 0)
|
else if (strcmp(typeString, "linkedmesh") == 0) type = SP_ATTACHMENT_LINKED_MESH;
|
||||||
type = SP_ATTACHMENT_MESH;
|
else if (strcmp(typeString, "boundingbox") == 0) type = SP_ATTACHMENT_BOUNDING_BOX;
|
||||||
else if (strcmp(typeString, "linkedmesh") == 0)
|
else if (strcmp(typeString, "path") == 0) type = SP_ATTACHMENT_PATH;
|
||||||
type = SP_ATTACHMENT_LINKED_MESH;
|
else if (strcmp(typeString, "clipping") == 0) type = SP_ATTACHMENT_CLIPPING;
|
||||||
else if (strcmp(typeString, "boundingbox") == 0)
|
else if (strcmp(typeString, "point") == 0) type = SP_ATTACHMENT_POINT;
|
||||||
type = SP_ATTACHMENT_BOUNDING_BOX;
|
|
||||||
else if (strcmp(typeString, "path") == 0)
|
|
||||||
type = SP_ATTACHMENT_PATH;
|
|
||||||
else if (strcmp(typeString, "clipping") == 0)
|
|
||||||
type = SP_ATTACHMENT_CLIPPING;
|
|
||||||
else if (strcmp(typeString, "point") == 0)
|
|
||||||
type = SP_ATTACHMENT_POINT;
|
|
||||||
else {
|
else {
|
||||||
spSkeletonData_dispose(skeletonData);
|
spSkeletonData_dispose(skeletonData);
|
||||||
_spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
_spSkeletonJson_setError(self, root, "Unknown attachment type: ", typeString);
|
||||||
@ -995,10 +984,10 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
color = Json_getString(attachmentMap, "color", 0);
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
if (color) {
|
if (color) {
|
||||||
spColor_setFromFloats(®ion->color,
|
spColor_setFromFloats(®ion->color,
|
||||||
toColor(color, 0),
|
toColor(color, 0),
|
||||||
toColor(color, 1),
|
toColor(color, 1),
|
||||||
toColor(color, 2),
|
toColor(color, 2),
|
||||||
toColor(color, 3));
|
toColor(color, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
spRegionAttachment_updateOffset(region);
|
spRegionAttachment_updateOffset(region);
|
||||||
@ -1015,10 +1004,10 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
color = Json_getString(attachmentMap, "color", 0);
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
if (color) {
|
if (color) {
|
||||||
spColor_setFromFloats(&mesh->color,
|
spColor_setFromFloats(&mesh->color,
|
||||||
toColor(color, 0),
|
toColor(color, 0),
|
||||||
toColor(color, 1),
|
toColor(color, 1),
|
||||||
toColor(color, 2),
|
toColor(color, 2),
|
||||||
toColor(color, 3));
|
toColor(color, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
mesh->width = Json_getFloat(attachmentMap, "width", 32) * self->scale;
|
||||||
@ -1056,8 +1045,8 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
spAttachmentLoader_configureAttachment(self->attachmentLoader, attachment);
|
||||||
} else {
|
} else {
|
||||||
int inheritDeform = Json_getInt(attachmentMap, "deform", 1);
|
int inheritDeform = Json_getInt(attachmentMap, "deform", 1);
|
||||||
_spSkeletonJson_addLinkedMesh(self, SUB_CAST(spMeshAttachment, attachment), Json_getString(attachmentMap, "skin", 0), slot->index,
|
_spSkeletonJson_addLinkedMesh(self, SUB_CAST(spMeshAttachment, attachment),
|
||||||
entry->valueString, inheritDeform);
|
Json_getString(attachmentMap, "skin", 0), slot->index, entry->valueString, inheritDeform);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1081,9 +1070,8 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
pathAttachment->lengths = MALLOC(float, pathAttachment->lengthsLength);
|
pathAttachment->lengths = MALLOC(float, pathAttachment->lengthsLength);
|
||||||
|
|
||||||
curves = Json_getItem(attachmentMap, "lengths");
|
curves = Json_getItem(attachmentMap, "lengths");
|
||||||
for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii) {
|
for (curves = curves->child, ii = 0; curves; curves = curves->next, ++ii)
|
||||||
pathAttachment->lengths[ii] = curves->valueFloat * self->scale;
|
pathAttachment->lengths[ii] = curves->valueFloat * self->scale;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SP_ATTACHMENT_POINT: {
|
case SP_ATTACHMENT_POINT: {
|
||||||
@ -1095,10 +1083,10 @@ spSkeletonData* spSkeletonJson_readSkeletonData (spSkeletonJson* self, const cha
|
|||||||
color = Json_getString(attachmentMap, "color", 0);
|
color = Json_getString(attachmentMap, "color", 0);
|
||||||
if (color) {
|
if (color) {
|
||||||
spColor_setFromFloats(&point->color,
|
spColor_setFromFloats(&point->color,
|
||||||
toColor(color, 0),
|
toColor(color, 0),
|
||||||
toColor(color, 1),
|
toColor(color, 1),
|
||||||
toColor(color, 2),
|
toColor(color, 2),
|
||||||
toColor(color, 3));
|
toColor(color, 3));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -226,7 +226,7 @@ void spSkin_copySkin(spSkin* self, const spSkin* other) {
|
|||||||
|
|
||||||
entry = spSkin_getAttachments(other);
|
entry = spSkin_getAttachments(other);
|
||||||
while (entry) {
|
while (entry) {
|
||||||
if (entry->attachment->type == SP_ATTACHMENT_MESH) {
|
if (entry->attachment->type == SP_ATTACHMENT_MESH) {
|
||||||
spMeshAttachment* attachment = spMeshAttachment_newLinkedMesh(SUB_CAST(spMeshAttachment, entry->attachment));
|
spMeshAttachment* attachment = spMeshAttachment_newLinkedMesh(SUB_CAST(spMeshAttachment, entry->attachment));
|
||||||
spSkin_setAttachment(self, entry->slotIndex, entry->name, SUPER(SUPER(attachment)));
|
spSkin_setAttachment(self, entry->slotIndex, entry->name, SUPER(SUPER(attachment)));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -74,7 +74,7 @@ void spSlot_setToSetupPose (spSlot* self) {
|
|||||||
spSlot_setAttachment(self, 0);
|
spSlot_setAttachment(self, 0);
|
||||||
else {
|
else {
|
||||||
spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex(
|
spAttachment* attachment = spSkeleton_getAttachmentForSlotIndex(
|
||||||
self->bone->skeleton, self->data->index, self->data->attachmentName);
|
self->bone->skeleton, self->data->index, self->data->attachmentName);
|
||||||
CONST_CAST(spAttachment*, self->attachment) = 0;
|
CONST_CAST(spAttachment*, self->attachment) = 0;
|
||||||
spSlot_setAttachment(self, attachment);
|
spSlot_setAttachment(self, attachment);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,9 +115,9 @@ static int _isConcave(int index, int vertexCount, float* vertices, short* indice
|
|||||||
int previous = indices[(vertexCount + index - 1) % vertexCount] << 1;
|
int previous = indices[(vertexCount + index - 1) % vertexCount] << 1;
|
||||||
int current = indices[index] << 1;
|
int current = indices[index] << 1;
|
||||||
int next = indices[(index + 1) % vertexCount] << 1;
|
int next = indices[(index + 1) % vertexCount] << 1;
|
||||||
return !_positiveArea(vertices[previous], vertices[previous + 1], vertices[current], vertices[current + 1],
|
return !_positiveArea(vertices[previous], vertices[previous + 1],
|
||||||
vertices[next],
|
vertices[current], vertices[current + 1],
|
||||||
vertices[next + 1]);
|
vertices[next], vertices[next + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _winding (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) {
|
static int _winding (float p1x, float p1y, float p2x, float p2y, float p3x, float p3y) {
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define STRINGIFY(A) #A
|
#define STRINGIFY(A) #A
|
||||||
#define MAX_VERTICES 64000
|
#define MAX_VERTICES 64000
|
||||||
#define MAX_INDICES 64000
|
#define MAX_INDICES 64000
|
||||||
|
|
||||||
@ -84,10 +84,10 @@ varying vec4 v_dark;
|
|||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 texColor = texture2D(texture, v_texCoord);
|
vec4 texColor = texture2D(texture, v_texCoord);
|
||||||
float alpha = texColor.a * v_light.a;
|
float alpha = texColor.a * v_light.a;
|
||||||
gl_FragColor.a = alpha;
|
gl_FragColor.a = alpha;
|
||||||
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
gl_FragColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -48,9 +48,9 @@ typedef void(^spEventListener)(spTrackEntry* entry, spEvent* event);
|
|||||||
float _timeScale;
|
float _timeScale;
|
||||||
|
|
||||||
spStartListener _startListener;
|
spStartListener _startListener;
|
||||||
spInterruptListener _interruptListener;
|
spInterruptListener _interruptListener;
|
||||||
spEndListener _endListener;
|
spEndListener _endListener;
|
||||||
spDisposeListener _disposeListener;
|
spDisposeListener _disposeListener;
|
||||||
spCompleteListener _completeListener;
|
spCompleteListener _completeListener;
|
||||||
spEventListener _eventListener;
|
spEventListener _eventListener;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
bool _debugBones;
|
bool _debugBones;
|
||||||
bool _premultipliedAlpha;
|
bool _premultipliedAlpha;
|
||||||
bool _twoColorTint;
|
bool _twoColorTint;
|
||||||
bool _skipVisibilityCheck;
|
bool _skipVisibilityCheck;
|
||||||
ccBlendFunc _blendFunc;
|
ccBlendFunc _blendFunc;
|
||||||
CCDrawNode* _drawNode;
|
CCDrawNode* _drawNode;
|
||||||
bool _ownsSkeletonData;
|
bool _ownsSkeletonData;
|
||||||
|
|||||||
@ -40,12 +40,12 @@ using std::vector;
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
typedef struct _TrackEntryListeners {
|
typedef struct _TrackEntryListeners {
|
||||||
StartListener startListener;
|
StartListener startListener;
|
||||||
InterruptListener interruptListener;
|
InterruptListener interruptListener;
|
||||||
EndListener endListener;
|
EndListener endListener;
|
||||||
DisposeListener disposeListener;
|
DisposeListener disposeListener;
|
||||||
CompleteListener completeListener;
|
CompleteListener completeListener;
|
||||||
EventListener eventListener;
|
EventListener eventListener;
|
||||||
} _TrackEntryListeners;
|
} _TrackEntryListeners;
|
||||||
|
|
||||||
void animationCallback (AnimationState* state, EventType type, TrackEntry* entry, Event* event) {
|
void animationCallback (AnimationState* state, EventType type, TrackEntry* entry, Event* event) {
|
||||||
@ -54,11 +54,12 @@ void animationCallback (AnimationState* state, EventType type, TrackEntry* entry
|
|||||||
|
|
||||||
void trackEntryCallback (AnimationState* state, EventType type, TrackEntry* entry, Event* event) {
|
void trackEntryCallback (AnimationState* state, EventType type, TrackEntry* entry, Event* event) {
|
||||||
((SkeletonAnimation*)state->getRendererObject())->onTrackEntryEvent(entry, type, event);
|
((SkeletonAnimation*)state->getRendererObject())->onTrackEntryEvent(entry, type, event);
|
||||||
if (type == EventType_Dispose)
|
if (type == EventType_Dispose) {
|
||||||
if (entry->getRendererObject()) {
|
if (entry->getRendererObject()) {
|
||||||
delete (spine::_TrackEntryListeners*)entry->getRendererObject();
|
delete (spine::_TrackEntryListeners*)entry->getRendererObject();
|
||||||
entry->setRendererObject(NULL);
|
entry->setRendererObject(NULL);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static _TrackEntryListeners* getListeners (TrackEntry* entry) {
|
static _TrackEntryListeners* getListeners (TrackEntry* entry) {
|
||||||
@ -150,7 +151,7 @@ void SkeletonAnimation::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &t
|
|||||||
void SkeletonAnimation::setAnimationStateData (AnimationStateData* stateData) {
|
void SkeletonAnimation::setAnimationStateData (AnimationStateData* stateData) {
|
||||||
CCASSERT(stateData, "stateData cannot be null.");
|
CCASSERT(stateData, "stateData cannot be null.");
|
||||||
|
|
||||||
if (_ownsAnimationStateData) delete _state->getData();
|
if (_ownsAnimationStateData) delete _state->getData();
|
||||||
delete _state;
|
delete _state;
|
||||||
|
|
||||||
_ownsAnimationStateData = false;
|
_ownsAnimationStateData = false;
|
||||||
@ -214,15 +215,15 @@ void SkeletonAnimation::onAnimationStateEvent (TrackEntry* entry, EventType type
|
|||||||
case EventType_Start:
|
case EventType_Start:
|
||||||
if (_startListener) _startListener(entry);
|
if (_startListener) _startListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_Interrupt:
|
case EventType_Interrupt:
|
||||||
if (_interruptListener) _interruptListener(entry);
|
if (_interruptListener) _interruptListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_End:
|
case EventType_End:
|
||||||
if (_endListener) _endListener(entry);
|
if (_endListener) _endListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_Dispose:
|
case EventType_Dispose:
|
||||||
if (_disposeListener) _disposeListener(entry);
|
if (_disposeListener) _disposeListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_Complete:
|
case EventType_Complete:
|
||||||
if (_completeListener) _completeListener(entry);
|
if (_completeListener) _completeListener(entry);
|
||||||
break;
|
break;
|
||||||
@ -239,15 +240,15 @@ void SkeletonAnimation::onTrackEntryEvent (TrackEntry* entry, EventType type, Ev
|
|||||||
case EventType_Start:
|
case EventType_Start:
|
||||||
if (listeners->startListener) listeners->startListener(entry);
|
if (listeners->startListener) listeners->startListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_Interrupt:
|
case EventType_Interrupt:
|
||||||
if (listeners->interruptListener) listeners->interruptListener(entry);
|
if (listeners->interruptListener) listeners->interruptListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_End:
|
case EventType_End:
|
||||||
if (listeners->endListener) listeners->endListener(entry);
|
if (listeners->endListener) listeners->endListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_Dispose:
|
case EventType_Dispose:
|
||||||
if (listeners->disposeListener) listeners->disposeListener(entry);
|
if (listeners->disposeListener) listeners->disposeListener(entry);
|
||||||
break;
|
break;
|
||||||
case EventType_Complete:
|
case EventType_Complete:
|
||||||
if (listeners->completeListener) listeners->completeListener(entry);
|
if (listeners->completeListener) listeners->completeListener(entry);
|
||||||
break;
|
break;
|
||||||
@ -262,7 +263,7 @@ void SkeletonAnimation::setStartListener (const StartListener& listener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setInterruptListener (const InterruptListener& listener) {
|
void SkeletonAnimation::setInterruptListener (const InterruptListener& listener) {
|
||||||
_interruptListener = listener;
|
_interruptListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setEndListener (const EndListener& listener) {
|
void SkeletonAnimation::setEndListener (const EndListener& listener) {
|
||||||
@ -270,7 +271,7 @@ void SkeletonAnimation::setEndListener (const EndListener& listener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setDisposeListener (const DisposeListener& listener) {
|
void SkeletonAnimation::setDisposeListener (const DisposeListener& listener) {
|
||||||
_disposeListener = listener;
|
_disposeListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setCompleteListener (const CompleteListener& listener) {
|
void SkeletonAnimation::setCompleteListener (const CompleteListener& listener) {
|
||||||
@ -286,7 +287,7 @@ void SkeletonAnimation::setTrackStartListener (TrackEntry* entry, const StartLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setTrackInterruptListener (TrackEntry* entry, const InterruptListener& listener) {
|
void SkeletonAnimation::setTrackInterruptListener (TrackEntry* entry, const InterruptListener& listener) {
|
||||||
getListeners(entry)->interruptListener = listener;
|
getListeners(entry)->interruptListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setTrackEndListener (TrackEntry* entry, const EndListener& listener) {
|
void SkeletonAnimation::setTrackEndListener (TrackEntry* entry, const EndListener& listener) {
|
||||||
@ -294,7 +295,7 @@ void SkeletonAnimation::setTrackEndListener (TrackEntry* entry, const EndListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setTrackDisposeListener (TrackEntry* entry, const DisposeListener& listener) {
|
void SkeletonAnimation::setTrackDisposeListener (TrackEntry* entry, const DisposeListener& listener) {
|
||||||
getListeners(entry)->disposeListener = listener;
|
getListeners(entry)->disposeListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonAnimation::setTrackCompleteListener (TrackEntry* entry, const CompleteListener& listener) {
|
void SkeletonAnimation::setTrackCompleteListener (TrackEntry* entry, const CompleteListener& listener) {
|
||||||
|
|||||||
@ -82,16 +82,16 @@ public:
|
|||||||
void clearTrack (int trackIndex = 0);
|
void clearTrack (int trackIndex = 0);
|
||||||
|
|
||||||
void setStartListener (const StartListener& listener);
|
void setStartListener (const StartListener& listener);
|
||||||
void setInterruptListener (const InterruptListener& listener);
|
void setInterruptListener (const InterruptListener& listener);
|
||||||
void setEndListener (const EndListener& listener);
|
void setEndListener (const EndListener& listener);
|
||||||
void setDisposeListener (const DisposeListener& listener);
|
void setDisposeListener (const DisposeListener& listener);
|
||||||
void setCompleteListener (const CompleteListener& listener);
|
void setCompleteListener (const CompleteListener& listener);
|
||||||
void setEventListener (const EventListener& listener);
|
void setEventListener (const EventListener& listener);
|
||||||
|
|
||||||
void setTrackStartListener (TrackEntry* entry, const StartListener& listener);
|
void setTrackStartListener (TrackEntry* entry, const StartListener& listener);
|
||||||
void setTrackInterruptListener (TrackEntry* entry, const InterruptListener& listener);
|
void setTrackInterruptListener (TrackEntry* entry, const InterruptListener& listener);
|
||||||
void setTrackEndListener (TrackEntry* entry, const EndListener& listener);
|
void setTrackEndListener (TrackEntry* entry, const EndListener& listener);
|
||||||
void setTrackDisposeListener (TrackEntry* entry, const DisposeListener& listener);
|
void setTrackDisposeListener (TrackEntry* entry, const DisposeListener& listener);
|
||||||
void setTrackCompleteListener (TrackEntry* entry, const CompleteListener& listener);
|
void setTrackCompleteListener (TrackEntry* entry, const CompleteListener& listener);
|
||||||
void setTrackEventListener (TrackEntry* entry, const EventListener& listener);
|
void setTrackEventListener (TrackEntry* entry, const EventListener& listener);
|
||||||
|
|
||||||
@ -114,9 +114,9 @@ protected:
|
|||||||
bool _firstDraw;
|
bool _firstDraw;
|
||||||
|
|
||||||
StartListener _startListener;
|
StartListener _startListener;
|
||||||
InterruptListener _interruptListener;
|
InterruptListener _interruptListener;
|
||||||
EndListener _endListener;
|
EndListener _endListener;
|
||||||
DisposeListener _disposeListener;
|
DisposeListener _disposeListener;
|
||||||
CompleteListener _completeListener;
|
CompleteListener _completeListener;
|
||||||
EventListener _eventListener;
|
EventListener _eventListener;
|
||||||
|
|
||||||
|
|||||||
@ -142,7 +142,7 @@ void SkeletonBatch::reset() {
|
|||||||
cocos2d::TrianglesCommand* SkeletonBatch::nextFreeCommand() {
|
cocos2d::TrianglesCommand* SkeletonBatch::nextFreeCommand() {
|
||||||
if (_commandsPool.size() <= _nextFreeCommand) {
|
if (_commandsPool.size() <= _nextFreeCommand) {
|
||||||
unsigned int newSize = _commandsPool.size() * 2 + 1;
|
unsigned int newSize = _commandsPool.size() * 2 + 1;
|
||||||
for (int i = _commandsPool.size(); i < newSize; i++) {
|
for (int i = _commandsPool.size(); i < newSize; i++) {
|
||||||
_commandsPool.push_back(new TrianglesCommand());
|
_commandsPool.push_back(new TrianglesCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,13 +36,13 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class SkeletonBatch {
|
class SkeletonBatch {
|
||||||
public:
|
public:
|
||||||
static SkeletonBatch* getInstance ();
|
static SkeletonBatch* getInstance ();
|
||||||
|
|
||||||
static void destroyInstance ();
|
static void destroyInstance ();
|
||||||
|
|
||||||
void update (float delta);
|
void update (float delta);
|
||||||
|
|
||||||
cocos2d::V3F_C4B_T2F* allocateVertices(uint32_t numVertices);
|
cocos2d::V3F_C4B_T2F* allocateVertices(uint32_t numVertices);
|
||||||
void deallocateVertices(uint32_t numVertices);
|
void deallocateVertices(uint32_t numVertices);
|
||||||
@ -50,9 +50,9 @@ namespace spine {
|
|||||||
void deallocateIndices(uint32_t numVertices);
|
void deallocateIndices(uint32_t numVertices);
|
||||||
cocos2d::TrianglesCommand* addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::GLProgramState* glProgramState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
|
cocos2d::TrianglesCommand* addCommand(cocos2d::Renderer* renderer, float globalOrder, cocos2d::Texture2D* texture, cocos2d::GLProgramState* glProgramState, cocos2d::BlendFunc blendType, const cocos2d::TrianglesCommand::Triangles& triangles, const cocos2d::Mat4& mv, uint32_t flags);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkeletonBatch ();
|
SkeletonBatch ();
|
||||||
virtual ~SkeletonBatch ();
|
virtual ~SkeletonBatch ();
|
||||||
|
|
||||||
void reset ();
|
void reset ();
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ namespace spine {
|
|||||||
|
|
||||||
// pool of indices
|
// pool of indices
|
||||||
Vector<unsigned short> _indices;
|
Vector<unsigned short> _indices;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -98,13 +98,13 @@ namespace spine {
|
|||||||
bool _forceFlush;
|
bool _forceFlush;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkeletonTwoColorBatch {
|
class SkeletonTwoColorBatch {
|
||||||
public:
|
public:
|
||||||
static SkeletonTwoColorBatch* getInstance ();
|
static SkeletonTwoColorBatch* getInstance ();
|
||||||
|
|
||||||
static void destroyInstance ();
|
static void destroyInstance ();
|
||||||
|
|
||||||
void update (float delta);
|
void update (float delta);
|
||||||
|
|
||||||
V3F_C4B_C4B_T2F* allocateVertices(uint32_t numVertices);
|
V3F_C4B_C4B_T2F* allocateVertices(uint32_t numVertices);
|
||||||
void deallocateVertices(uint32_t numVertices);
|
void deallocateVertices(uint32_t numVertices);
|
||||||
@ -122,9 +122,9 @@ namespace spine {
|
|||||||
|
|
||||||
uint32_t getNumBatches () { return _numBatches; };
|
uint32_t getNumBatches () { return _numBatches; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SkeletonTwoColorBatch ();
|
SkeletonTwoColorBatch ();
|
||||||
virtual ~SkeletonTwoColorBatch ();
|
virtual ~SkeletonTwoColorBatch ();
|
||||||
|
|
||||||
void reset ();
|
void reset ();
|
||||||
|
|
||||||
|
|||||||
@ -162,69 +162,69 @@ function spine.Skeleton:updateWorldTransform()
|
|||||||
local numVertices = 0
|
local numVertices = 0
|
||||||
local indices = nil
|
local indices = nil
|
||||||
|
|
||||||
if slot.bone.active then
|
if slot.bone.active then
|
||||||
|
|
||||||
if attachment then
|
if attachment then
|
||||||
if attachment.type == spine.AttachmentType.region then
|
if attachment.type == spine.AttachmentType.region then
|
||||||
numVertices = 4
|
numVertices = 4
|
||||||
vertices = worldVertices
|
vertices = worldVertices
|
||||||
attachment:computeWorldVertices(slot.bone, vertices, 0, 2)
|
attachment:computeWorldVertices(slot.bone, vertices, 0, 2)
|
||||||
uvs = attachment.uvs
|
uvs = attachment.uvs
|
||||||
indices = QUAD_TRIANGLES
|
indices = QUAD_TRIANGLES
|
||||||
texture = attachment.region.renderObject.texture
|
texture = attachment.region.renderObject.texture
|
||||||
blendMode = toCoronaBlendMode(slot.data.blendMode)
|
blendMode = toCoronaBlendMode(slot.data.blendMode)
|
||||||
elseif attachment.type == spine.AttachmentType.mesh then
|
elseif attachment.type == spine.AttachmentType.mesh then
|
||||||
numVertices = attachment.worldVerticesLength / 2
|
numVertices = attachment.worldVerticesLength / 2
|
||||||
vertices = worldVertices
|
vertices = worldVertices
|
||||||
attachment:computeWorldVertices(slot, 0, attachment.worldVerticesLength, vertices, 0, 2)
|
attachment:computeWorldVertices(slot, 0, attachment.worldVerticesLength, vertices, 0, 2)
|
||||||
uvs = attachment.uvs
|
uvs = attachment.uvs
|
||||||
indices = attachment.triangles
|
indices = attachment.triangles
|
||||||
texture = attachment.region.renderObject.texture
|
texture = attachment.region.renderObject.texture
|
||||||
blendMode = toCoronaBlendMode(slot.data.blendMode)
|
blendMode = toCoronaBlendMode(slot.data.blendMode)
|
||||||
elseif attachment.type == spine.AttachmentType.clipping then
|
elseif attachment.type == spine.AttachmentType.clipping then
|
||||||
self.clipper:clipStart(slot, attachment)
|
self.clipper:clipStart(slot, attachment)
|
||||||
end
|
end
|
||||||
|
|
||||||
if texture and vertices and indices then
|
if texture and vertices and indices then
|
||||||
local skeleton = slot.bone.skeleton
|
local skeleton = slot.bone.skeleton
|
||||||
local skeletonColor = skeleton.color
|
local skeletonColor = skeleton.color
|
||||||
local slotColor = slot.color
|
local slotColor = slot.color
|
||||||
local attachmentColor = attachment.color
|
local attachmentColor = attachment.color
|
||||||
local alpha = skeletonColor.a * slotColor.a * attachmentColor.a
|
local alpha = skeletonColor.a * slotColor.a * attachmentColor.a
|
||||||
local multiplier = alpha
|
local multiplier = alpha
|
||||||
if premultipliedAlpha then multiplier = 1 end
|
if premultipliedAlpha then multiplier = 1 end
|
||||||
color:set(skeletonColor.r * slotColor.r * attachmentColor.r * multiplier,
|
color:set(skeletonColor.r * slotColor.r * attachmentColor.r * multiplier,
|
||||||
skeletonColor.g * slotColor.g * attachmentColor.g * multiplier,
|
skeletonColor.g * slotColor.g * attachmentColor.g * multiplier,
|
||||||
skeletonColor.b * slotColor.b * attachmentColor.b * multiplier,
|
skeletonColor.b * slotColor.b * attachmentColor.b * multiplier,
|
||||||
alpha)
|
alpha)
|
||||||
|
|
||||||
if not lastTexture then lastTexture = texture end
|
if not lastTexture then lastTexture = texture end
|
||||||
if lastColor.r == -1 then lastColor:setFrom(color) end
|
if lastColor.r == -1 then lastColor:setFrom(color) end
|
||||||
if not lastBlendMode then lastBlendMode = blendMode end
|
if not lastBlendMode then lastBlendMode = blendMode end
|
||||||
|
|
||||||
if (texture ~= lastTexture or not colorEquals(color, lastColor) or blendMode ~= lastBlendMode) then
|
if (texture ~= lastTexture or not colorEquals(color, lastColor) or blendMode ~= lastBlendMode) then
|
||||||
self:flush(groupVertices, groupUvs, groupIndices, lastTexture, lastColor, lastBlendMode, drawingGroup)
|
self:flush(groupVertices, groupUvs, groupIndices, lastTexture, lastColor, lastBlendMode, drawingGroup)
|
||||||
lastTexture = texture
|
lastTexture = texture
|
||||||
lastColor:setFrom(color)
|
lastColor:setFrom(color)
|
||||||
lastBlendMode = blendMode
|
lastBlendMode = blendMode
|
||||||
groupVertices = {}
|
groupVertices = {}
|
||||||
groupUvs = {}
|
groupUvs = {}
|
||||||
groupIndices = {}
|
groupIndices = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.clipper:isClipping() then
|
if self.clipper:isClipping() then
|
||||||
self.clipper:clipTriangles(vertices, uvs, indices, #indices)
|
self.clipper:clipTriangles(vertices, uvs, indices, #indices)
|
||||||
vertices = self.clipper.clippedVertices
|
vertices = self.clipper.clippedVertices
|
||||||
numVertices = #vertices / 2
|
numVertices = #vertices / 2
|
||||||
uvs = self.clipper.clippedUVs
|
uvs = self.clipper.clippedUVs
|
||||||
indices = self.clipper.clippedTriangles
|
indices = self.clipper.clippedTriangles
|
||||||
end
|
end
|
||||||
|
|
||||||
self:batch(vertices, uvs, numVertices, indices, groupVertices, groupUvs, groupIndices)
|
self:batch(vertices, uvs, numVertices, indices, groupVertices, groupUvs, groupIndices)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.clipper:clipEnd(slot)
|
self.clipper:clipEnd(slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -238,10 +238,10 @@ end
|
|||||||
|
|
||||||
function spine.Skeleton:flush(groupVertices, groupUvs, groupIndices, texture, color, blendMode, drawingGroup)
|
function spine.Skeleton:flush(groupVertices, groupUvs, groupIndices, texture, color, blendMode, drawingGroup)
|
||||||
local mesh = display.newMesh(drawingGroup, 0, 0, {
|
local mesh = display.newMesh(drawingGroup, 0, 0, {
|
||||||
mode = "indexed",
|
mode = "indexed",
|
||||||
vertices = groupVertices,
|
vertices = groupVertices,
|
||||||
uvs = groupUvs,
|
uvs = groupUvs,
|
||||||
indices = groupIndices
|
indices = groupIndices
|
||||||
})
|
})
|
||||||
mesh.fill = texture
|
mesh.fill = texture
|
||||||
mesh:setFillColor(color.r, color.g, color.b)
|
mesh:setFillColor(color.r, color.g, color.b)
|
||||||
|
|||||||
@ -88,7 +88,7 @@ public:
|
|||||||
/// Applies all the animation's timelines to the specified skeleton.
|
/// Applies all the animation's timelines to the specified skeleton.
|
||||||
/// See also Timeline::apply(Skeleton&, float, float, Vector, float, MixPose, MixDirection)
|
/// See also Timeline::apply(Skeleton&, float, float, Vector, float, MixPose, MixDirection)
|
||||||
void apply(Skeleton &skeleton, float lastTime, float time, bool loop, Vector<Event *> *pEvents, float alpha,
|
void apply(Skeleton &skeleton, float lastTime, float time, bool loop, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction);
|
MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
const String &getName();
|
const String &getName();
|
||||||
|
|
||||||
|
|||||||
@ -42,23 +42,23 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
enum EventType {
|
enum EventType {
|
||||||
EventType_Start,
|
EventType_Start,
|
||||||
EventType_Interrupt,
|
EventType_Interrupt,
|
||||||
EventType_End,
|
EventType_End,
|
||||||
EventType_Complete,
|
EventType_Complete,
|
||||||
EventType_Dispose,
|
EventType_Dispose,
|
||||||
EventType_Event
|
EventType_Event
|
||||||
};
|
};
|
||||||
|
|
||||||
class AnimationState;
|
class AnimationState;
|
||||||
class TrackEntry;
|
class TrackEntry;
|
||||||
|
|
||||||
class Animation;
|
class Animation;
|
||||||
class Event;
|
class Event;
|
||||||
class AnimationStateData;
|
class AnimationStateData;
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
class RotateTimeline;
|
class RotateTimeline;
|
||||||
|
|
||||||
#ifdef SPINE_USE_STD_FUNCTION
|
#ifdef SPINE_USE_STD_FUNCTION
|
||||||
typedef std::function<void (AnimationState* state, EventType type, TrackEntry* entry, Event* event)> AnimationStateListener;
|
typedef std::function<void (AnimationState* state, EventType type, TrackEntry* entry, Event* event)> AnimationStateListener;
|
||||||
@ -76,399 +76,362 @@ namespace spine {
|
|||||||
virtual void callback(AnimationState* state, EventType type, TrackEntry* entry, Event* event) = 0;
|
virtual void callback(AnimationState* state, EventType type, TrackEntry* entry, Event* event) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// State for the playback of an animation
|
/// State for the playback of an animation
|
||||||
class SP_API TrackEntry : public SpineObject, public HasRendererObject {
|
class SP_API TrackEntry : public SpineObject, public HasRendererObject {
|
||||||
friend class EventQueue;
|
friend class EventQueue;
|
||||||
friend class AnimationState;
|
friend class AnimationState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackEntry();
|
TrackEntry();
|
||||||
|
|
||||||
virtual ~TrackEntry();
|
virtual ~TrackEntry();
|
||||||
|
|
||||||
/// The index of the track where this entry is either current or queued.
|
/// The index of the track where this entry is either current or queued.
|
||||||
int getTrackIndex();
|
int getTrackIndex();
|
||||||
|
|
||||||
/// The animation to apply for this track entry.
|
/// The animation to apply for this track entry.
|
||||||
Animation* getAnimation();
|
Animation* getAnimation();
|
||||||
|
|
||||||
///
|
/// If true, the animation will repeat. If false, it will not, instead its last frame is applied if played beyond its duration.
|
||||||
/// If true, the animation will repeat. If false, it will not, instead its last frame is applied if played beyond its duration.
|
bool getLoop();
|
||||||
bool getLoop();
|
void setLoop(bool inValue);
|
||||||
void setLoop(bool inValue);
|
|
||||||
|
|
||||||
///
|
/// If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead
|
||||||
/// If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead
|
/// of being mixed out.
|
||||||
/// of being mixed out.
|
///
|
||||||
///
|
/// When mixing between animations that key the same property, if a lower track also keys that property then the value will
|
||||||
/// When mixing between animations that key the same property, if a lower track also keys that property then the value will
|
/// briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0%
|
||||||
/// briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0%
|
/// while the second animation mixes from 0% to 100%. Setting holdPrevious to true applies the first animation
|
||||||
/// while the second animation mixes from 0% to 100%. Setting holdPrevious to true applies the first animation
|
/// at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which
|
||||||
/// at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which
|
/// keys the property, only when a higher track also keys the property.
|
||||||
/// keys the property, only when a higher track also keys the property.
|
///
|
||||||
///
|
/// Snapping will occur if holdPrevious is true and this animation does not key all the same properties as the
|
||||||
/// Snapping will occur if holdPrevious is true and this animation does not key all the same properties as the
|
/// previous animation.
|
||||||
/// previous animation.
|
bool getHoldPrevious();
|
||||||
bool getHoldPrevious();
|
void setHoldPrevious(bool inValue);
|
||||||
void setHoldPrevious(bool inValue);
|
|
||||||
|
|
||||||
///
|
/// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing
|
||||||
/// Seconds to postpone playing the animation. When a track entry is the current track entry, delay postpones incrementing
|
/// the track time. When a track entry is queued, delay is the time from the start of the previous animation to when the
|
||||||
/// the track time. When a track entry is queued, delay is the time from the start of the previous animation to when the
|
/// track entry will become the current track entry.
|
||||||
/// track entry will become the current track entry.
|
float getDelay();
|
||||||
float getDelay();
|
void setDelay(float inValue);
|
||||||
void setDelay(float inValue);
|
|
||||||
|
|
||||||
///
|
/// Current time in seconds this track entry has been the current track entry. The track time determines
|
||||||
/// Current time in seconds this track entry has been the current track entry. The track time determines
|
/// TrackEntry.AnimationTime. The track time can be set to start the animation at a time other than 0, without affecting looping.
|
||||||
/// TrackEntry.AnimationTime. The track time can be set to start the animation at a time other than 0, without affecting looping.
|
float getTrackTime();
|
||||||
float getTrackTime();
|
void setTrackTime(float inValue);
|
||||||
void setTrackTime(float inValue);
|
|
||||||
|
|
||||||
///
|
/// The track time in seconds when this animation will be removed from the track. Defaults to the animation duration for
|
||||||
/// The track time in seconds when this animation will be removed from the track. Defaults to the animation duration for
|
/// non-looping animations and to int.MaxValue for looping animations. If the track end time is reached and no
|
||||||
/// non-looping animations and to int.MaxValue for looping animations. If the track end time is reached and no
|
/// other animations are queued for playback, and mixing from any previous animations is complete, properties keyed by the animation,
|
||||||
/// other animations are queued for playback, and mixing from any previous animations is complete, properties keyed by the animation,
|
/// are set to the setup pose and the track is cleared.
|
||||||
/// are set to the setup pose and the track is cleared.
|
///
|
||||||
///
|
/// It may be desired to use AnimationState.addEmptyAnimation(int, float, float) to mix the properties back to the
|
||||||
/// It may be desired to use AnimationState.addEmptyAnimation(int, float, float) to mix the properties back to the
|
/// setup pose over time, rather than have it happen instantly.
|
||||||
/// setup pose over time, rather than have it happen instantly.
|
float getTrackEnd();
|
||||||
///
|
void setTrackEnd(float inValue);
|
||||||
float getTrackEnd();
|
|
||||||
void setTrackEnd(float inValue);
|
|
||||||
|
|
||||||
///
|
/// Seconds when this animation starts, both initially and after looping. Defaults to 0.
|
||||||
/// Seconds when this animation starts, both initially and after looping. Defaults to 0.
|
///
|
||||||
///
|
/// When changing the animation start time, it often makes sense to set TrackEntry.AnimationLast to the same value to
|
||||||
/// When changing the animation start time, it often makes sense to set TrackEntry.AnimationLast to the same value to
|
/// prevent timeline keys before the start time from triggering.
|
||||||
/// prevent timeline keys before the start time from triggering.
|
float getAnimationStart();
|
||||||
///
|
void setAnimationStart(float inValue);
|
||||||
float getAnimationStart();
|
|
||||||
void setAnimationStart(float inValue);
|
|
||||||
|
|
||||||
///
|
/// Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will
|
||||||
/// Seconds for the last frame of this animation. Non-looping animations won't play past this time. Looping animations will
|
/// loop back to TrackEntry.AnimationStart at this time. Defaults to the animation duration.
|
||||||
/// loop back to TrackEntry.AnimationStart at this time. Defaults to the animation duration.
|
float getAnimationEnd();
|
||||||
float getAnimationEnd();
|
void setAnimationEnd(float inValue);
|
||||||
void setAnimationEnd(float inValue);
|
|
||||||
|
|
||||||
///
|
/// The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this
|
||||||
/// The time in seconds this animation was last applied. Some timelines use this for one-time triggers. Eg, when this
|
/// animation is applied, event timelines will fire all events between the animation last time (exclusive) and animation time
|
||||||
/// animation is applied, event timelines will fire all events between the animation last time (exclusive) and animation time
|
/// (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation is applied.
|
||||||
/// (inclusive). Defaults to -1 to ensure triggers on frame 0 happen the first time this animation is applied.
|
float getAnimationLast();
|
||||||
float getAnimationLast();
|
void setAnimationLast(float inValue);
|
||||||
void setAnimationLast(float inValue);
|
|
||||||
|
|
||||||
///
|
/// Uses TrackEntry.TrackTime to compute the animation time between TrackEntry.AnimationStart. and
|
||||||
/// Uses TrackEntry.TrackTime to compute the animation time between TrackEntry.AnimationStart. and
|
/// TrackEntry.AnimationEnd. When the track time is 0, the animation time is equal to the animation start time.
|
||||||
/// TrackEntry.AnimationEnd. When the track time is 0, the animation time is equal to the animation start time.
|
float getAnimationTime();
|
||||||
///
|
|
||||||
float getAnimationTime();
|
|
||||||
|
|
||||||
///
|
/// Multiplier for the delta time when the animation state is updated, causing time for this animation to play slower or
|
||||||
/// Multiplier for the delta time when the animation state is updated, causing time for this animation to play slower or
|
/// faster. Defaults to 1.
|
||||||
/// faster. Defaults to 1.
|
float getTimeScale();
|
||||||
///
|
void setTimeScale(float inValue);
|
||||||
float getTimeScale();
|
|
||||||
void setTimeScale(float inValue);
|
|
||||||
|
|
||||||
///
|
/// Values less than 1 mix this animation with the last skeleton pose. Defaults to 1, which overwrites the last skeleton pose with
|
||||||
/// Values less than 1 mix this animation with the last skeleton pose. Defaults to 1, which overwrites the last skeleton pose with
|
/// this animation.
|
||||||
/// this animation.
|
///
|
||||||
///
|
/// Typically track 0 is used to completely pose the skeleton, then alpha can be used on higher tracks. It doesn't make sense
|
||||||
/// Typically track 0 is used to completely pose the skeleton, then alpha can be used on higher tracks. It doesn't make sense
|
/// to use alpha on track 0 if the skeleton pose is from the last frame render.
|
||||||
/// to use alpha on track 0 if the skeleton pose is from the last frame render.
|
float getAlpha();
|
||||||
///
|
void setAlpha(float inValue);
|
||||||
float getAlpha();
|
|
||||||
void setAlpha(float inValue);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// When the mix percentage (mix time / mix duration) is less than the event threshold, event timelines for the animation
|
/// When the mix percentage (mix time / mix duration) is less than the event threshold, event timelines for the animation
|
||||||
/// being mixed out will be applied. Defaults to 0, so event timelines are not applied for an animation being mixed out.
|
/// being mixed out will be applied. Defaults to 0, so event timelines are not applied for an animation being mixed out.
|
||||||
float getEventThreshold();
|
float getEventThreshold();
|
||||||
void setEventThreshold(float inValue);
|
void setEventThreshold(float inValue);
|
||||||
|
|
||||||
///
|
/// When the mix percentage (mix time / mix duration) is less than the attachment threshold, attachment timelines for the
|
||||||
/// When the mix percentage (mix time / mix duration) is less than the attachment threshold, attachment timelines for the
|
/// animation being mixed out will be applied. Defaults to 0, so attachment timelines are not applied for an animation being
|
||||||
/// animation being mixed out will be applied. Defaults to 0, so attachment timelines are not applied for an animation being
|
/// mixed out.
|
||||||
/// mixed out.
|
float getAttachmentThreshold();
|
||||||
float getAttachmentThreshold();
|
void setAttachmentThreshold(float inValue);
|
||||||
void setAttachmentThreshold(float inValue);
|
|
||||||
|
|
||||||
///
|
/// When the mix percentage (mix time / mix duration) is less than the draw order threshold, draw order timelines for the
|
||||||
/// When the mix percentage (mix time / mix duration) is less than the draw order threshold, draw order timelines for the
|
/// animation being mixed out will be applied. Defaults to 0, so draw order timelines are not applied for an animation being
|
||||||
/// animation being mixed out will be applied. Defaults to 0, so draw order timelines are not applied for an animation being
|
/// mixed out.
|
||||||
/// mixed out.
|
float getDrawOrderThreshold();
|
||||||
///
|
void setDrawOrderThreshold(float inValue);
|
||||||
float getDrawOrderThreshold();
|
|
||||||
void setDrawOrderThreshold(float inValue);
|
|
||||||
|
|
||||||
///
|
/// The animation queued to start after this animation, or NULL.
|
||||||
/// The animation queued to start after this animation, or NULL.
|
TrackEntry* getNext();
|
||||||
TrackEntry* getNext();
|
|
||||||
|
|
||||||
///
|
/// Returns true if at least one loop has been completed.
|
||||||
/// Returns true if at least one loop has been completed.
|
bool isComplete();
|
||||||
bool isComplete();
|
|
||||||
|
|
||||||
///
|
/// Seconds from 0 to the mix duration when mixing from the previous animation to this animation. May be slightly more than
|
||||||
/// Seconds from 0 to the mix duration when mixing from the previous animation to this animation. May be slightly more than
|
/// TrackEntry.MixDuration when the mix is complete.
|
||||||
/// TrackEntry.MixDuration when the mix is complete.
|
float getMixTime();
|
||||||
float getMixTime();
|
void setMixTime(float inValue);
|
||||||
void setMixTime(float inValue);
|
|
||||||
|
|
||||||
///
|
/// Seconds for mixing from the previous animation to this animation. Defaults to the value provided by
|
||||||
/// Seconds for mixing from the previous animation to this animation. Defaults to the value provided by
|
/// AnimationStateData based on the animation before this animation (if any).
|
||||||
/// AnimationStateData based on the animation before this animation (if any).
|
///
|
||||||
///
|
/// The mix duration can be set manually rather than use the value from AnimationStateData.GetMix.
|
||||||
/// The mix duration can be set manually rather than use the value from AnimationStateData.GetMix.
|
/// In that case, the mixDuration must be set before AnimationState.update(float) is next called.
|
||||||
/// In that case, the mixDuration must be set before AnimationState.update(float) is next called.
|
///
|
||||||
///
|
/// When using AnimationState::addAnimation(int, Animation, bool, float) with a delay
|
||||||
/// When using AnimationState::addAnimation(int, Animation, bool, float) with a delay
|
/// less than or equal to 0, note the Delay is set using the mix duration from the AnimationStateData
|
||||||
/// less than or equal to 0, note the Delay is set using the mix duration from the AnimationStateData
|
float getMixDuration();
|
||||||
///
|
void setMixDuration(float inValue);
|
||||||
///
|
|
||||||
///
|
|
||||||
float getMixDuration();
|
|
||||||
void setMixDuration(float inValue);
|
|
||||||
|
|
||||||
|
MixBlend getMixBlend();
|
||||||
|
void setMixBlend(MixBlend blend);
|
||||||
|
|
||||||
MixBlend getMixBlend();
|
/// The track entry for the previous animation when mixing from the previous animation to this animation, or NULL if no
|
||||||
void setMixBlend(MixBlend blend);
|
/// mixing is currently occuring. When mixing from multiple animations, MixingFrom makes up a double linked list with MixingTo.
|
||||||
|
TrackEntry* getMixingFrom();
|
||||||
|
|
||||||
///
|
/// The track entry for the next animation when mixing from this animation, or NULL if no mixing is currently occuring.
|
||||||
/// The track entry for the previous animation when mixing from the previous animation to this animation, or NULL if no
|
/// When mixing from multiple animations, MixingTo makes up a double linked list with MixingFrom.
|
||||||
/// mixing is currently occuring. When mixing from multiple animations, MixingFrom makes up a double linked list with MixingTo.
|
TrackEntry* getMixingTo();
|
||||||
TrackEntry* getMixingFrom();
|
|
||||||
|
|
||||||
///
|
/// Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the
|
||||||
/// The track entry for the next animation when mixing from this animation, or NULL if no mixing is currently occuring.
|
/// long way around when using alpha and starting animations on other tracks.
|
||||||
/// When mixing from multiple animations, MixingTo makes up a double linked list with MixingFrom.
|
///
|
||||||
TrackEntry* getMixingTo();
|
/// Mixing involves finding a rotation between two others, which has two possible solutions: the short way or the long way around.
|
||||||
|
/// The two rotations likely change over time, so which direction is the short or long way also changes.
|
||||||
|
/// If the short way was always chosen, bones would flip to the other side when that direction became the long way.
|
||||||
|
/// TrackEntry chooses the short way the first time it is applied and remembers that direction.
|
||||||
|
void resetRotationDirections();
|
||||||
|
|
||||||
///
|
void setListener(AnimationStateListener listener);
|
||||||
/// Resets the rotation directions for mixing this entry's rotate timelines. This can be useful to avoid bones rotating the
|
|
||||||
/// long way around when using alpha and starting animations on other tracks.
|
|
||||||
///
|
|
||||||
/// Mixing involves finding a rotation between two others, which has two possible solutions: the short way or the long way around.
|
|
||||||
/// The two rotations likely change over time, so which direction is the short or long way also changes.
|
|
||||||
/// If the short way was always chosen, bones would flip to the other side when that direction became the long way.
|
|
||||||
/// TrackEntry chooses the short way the first time it is applied and remembers that direction.
|
|
||||||
void resetRotationDirections();
|
|
||||||
|
|
||||||
void setListener(AnimationStateListener listener);
|
|
||||||
|
|
||||||
void setListener(AnimationStateListenerObject* listener);
|
void setListener(AnimationStateListenerObject* listener);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Animation* _animation;
|
Animation* _animation;
|
||||||
|
|
||||||
TrackEntry* _next;
|
TrackEntry* _next;
|
||||||
TrackEntry* _mixingFrom;
|
TrackEntry* _mixingFrom;
|
||||||
TrackEntry* _mixingTo;
|
TrackEntry* _mixingTo;
|
||||||
int _trackIndex;
|
int _trackIndex;
|
||||||
|
|
||||||
bool _loop, _holdPrevious;
|
bool _loop, _holdPrevious;
|
||||||
float _eventThreshold, _attachmentThreshold, _drawOrderThreshold;
|
float _eventThreshold, _attachmentThreshold, _drawOrderThreshold;
|
||||||
float _animationStart, _animationEnd, _animationLast, _nextAnimationLast;
|
float _animationStart, _animationEnd, _animationLast, _nextAnimationLast;
|
||||||
float _delay, _trackTime, _trackLast, _nextTrackLast, _trackEnd, _timeScale;
|
float _delay, _trackTime, _trackLast, _nextTrackLast, _trackEnd, _timeScale;
|
||||||
float _alpha, _mixTime, _mixDuration, _interruptAlpha, _totalAlpha;
|
float _alpha, _mixTime, _mixDuration, _interruptAlpha, _totalAlpha;
|
||||||
MixBlend _mixBlend;
|
MixBlend _mixBlend;
|
||||||
Vector<int> _timelineMode;
|
Vector<int> _timelineMode;
|
||||||
Vector<TrackEntry*> _timelineHoldMix;
|
Vector<TrackEntry*> _timelineHoldMix;
|
||||||
Vector<float> _timelinesRotation;
|
Vector<float> _timelinesRotation;
|
||||||
AnimationStateListener _listener;
|
AnimationStateListener _listener;
|
||||||
AnimationStateListenerObject* _listenerObject;
|
AnimationStateListenerObject* _listenerObject;
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SP_API EventQueueEntry : public SpineObject {
|
class SP_API EventQueueEntry : public SpineObject {
|
||||||
friend class EventQueue;
|
friend class EventQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EventType _type;
|
EventType _type;
|
||||||
TrackEntry* _entry;
|
TrackEntry* _entry;
|
||||||
Event* _event;
|
Event* _event;
|
||||||
|
|
||||||
EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event = NULL);
|
EventQueueEntry(EventType eventType, TrackEntry* trackEntry, Event* event = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SP_API EventQueue : public SpineObject {
|
class SP_API EventQueue : public SpineObject {
|
||||||
friend class AnimationState;
|
friend class AnimationState;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<EventQueueEntry> _eventQueueEntries;
|
Vector<EventQueueEntry> _eventQueueEntries;
|
||||||
AnimationState& _state;
|
AnimationState& _state;
|
||||||
Pool<TrackEntry>& _trackEntryPool;
|
Pool<TrackEntry>& _trackEntryPool;
|
||||||
bool _drainDisabled;
|
bool _drainDisabled;
|
||||||
|
|
||||||
static EventQueue* newEventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool);
|
static EventQueue* newEventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool);
|
||||||
|
|
||||||
static EventQueueEntry newEventQueueEntry(EventType eventType, TrackEntry* entry, Event* event = NULL);
|
static EventQueueEntry newEventQueueEntry(EventType eventType, TrackEntry* entry, Event* event = NULL);
|
||||||
|
|
||||||
EventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool);
|
EventQueue(AnimationState& state, Pool<TrackEntry>& trackEntryPool);
|
||||||
|
|
||||||
~EventQueue();
|
~EventQueue();
|
||||||
|
|
||||||
void start(TrackEntry* entry);
|
void start(TrackEntry* entry);
|
||||||
|
|
||||||
void interrupt(TrackEntry* entry);
|
void interrupt(TrackEntry* entry);
|
||||||
|
|
||||||
void end(TrackEntry* entry);
|
void end(TrackEntry* entry);
|
||||||
|
|
||||||
void dispose(TrackEntry* entry);
|
void dispose(TrackEntry* entry);
|
||||||
|
|
||||||
void complete(TrackEntry* entry);
|
void complete(TrackEntry* entry);
|
||||||
|
|
||||||
void event(TrackEntry* entry, Event* event);
|
void event(TrackEntry* entry, Event* event);
|
||||||
|
|
||||||
/// Raises all events in the queue and drains the queue.
|
/// Raises all events in the queue and drains the queue.
|
||||||
void drain();
|
void drain();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SP_API AnimationState : public SpineObject, public HasRendererObject {
|
class SP_API AnimationState : public SpineObject, public HasRendererObject {
|
||||||
friend class TrackEntry;
|
friend class TrackEntry;
|
||||||
friend class EventQueue;
|
friend class EventQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AnimationState(AnimationStateData* data);
|
explicit AnimationState(AnimationStateData* data);
|
||||||
|
|
||||||
~AnimationState();
|
~AnimationState();
|
||||||
|
|
||||||
///
|
/// Increments the track entry times, setting queued animations as current if needed
|
||||||
/// Increments the track entry times, setting queued animations as current if needed
|
/// @param delta delta time
|
||||||
/// @param delta delta time
|
void update(float delta);
|
||||||
void update(float delta);
|
|
||||||
|
|
||||||
///
|
/// Poses the skeleton using the track entry animations. There are no side effects other than invoking listeners, so the
|
||||||
/// Poses the skeleton using the track entry animations. There are no side effects other than invoking listeners, so the
|
/// animation state can be applied to multiple skeletons to pose them identically.
|
||||||
/// animation state can be applied to multiple skeletons to pose them identically.
|
bool apply(Skeleton& skeleton);
|
||||||
bool apply(Skeleton& skeleton);
|
|
||||||
|
|
||||||
///
|
/// Removes all animations from all tracks, leaving skeletons in their previous pose.
|
||||||
/// Removes all animations from all tracks, leaving skeletons in their previous pose.
|
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
|
||||||
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
|
/// rather than leaving them in their previous pose.
|
||||||
/// rather than leaving them in their previous pose.
|
void clearTracks();
|
||||||
void clearTracks();
|
|
||||||
|
|
||||||
///
|
/// Removes all animations from the tracks, leaving skeletons in their previous pose.
|
||||||
/// Removes all animations from the tracks, leaving skeletons in their previous pose.
|
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
|
||||||
/// It may be desired to use AnimationState.setEmptyAnimations(float) to mix the skeletons back to the setup pose,
|
/// rather than leaving them in their previous pose.
|
||||||
/// rather than leaving them in their previous pose.
|
void clearTrack(size_t trackIndex);
|
||||||
void clearTrack(size_t trackIndex);
|
|
||||||
|
|
||||||
/// Sets an animation by name. setAnimation(int, Animation, bool)
|
/// Sets an animation by name. setAnimation(int, Animation, bool)
|
||||||
TrackEntry* setAnimation(size_t trackIndex, const String& animationName, bool loop);
|
TrackEntry* setAnimation(size_t trackIndex, const String& animationName, bool loop);
|
||||||
|
|
||||||
/// Sets the current animation for a track, discarding any queued animations.
|
/// Sets the current animation for a track, discarding any queued animations.
|
||||||
/// @param loop If true, the animation will repeat.
|
/// @param loop If true, the animation will repeat.
|
||||||
/// If false, it will not, instead its last frame is applied if played beyond its duration.
|
/// If false, it will not, instead its last frame is applied if played beyond its duration.
|
||||||
/// In either case TrackEntry.TrackEnd determines when the track is cleared.
|
/// In either case TrackEntry.TrackEnd determines when the track is cleared.
|
||||||
/// @return
|
/// @return
|
||||||
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||||
/// after AnimationState.Dispose.
|
/// after AnimationState.Dispose.
|
||||||
TrackEntry* setAnimation(size_t trackIndex, Animation* animation, bool loop);
|
TrackEntry* setAnimation(size_t trackIndex, Animation* animation, bool loop);
|
||||||
|
|
||||||
/// Queues an animation by name.
|
/// Queues an animation by name.
|
||||||
/// addAnimation(int, Animation, bool, float)
|
/// addAnimation(int, Animation, bool, float)
|
||||||
TrackEntry* addAnimation(size_t trackIndex, const String& animationName, bool loop, float delay);
|
TrackEntry* addAnimation(size_t trackIndex, const String& animationName, bool loop, float delay);
|
||||||
|
|
||||||
/// Adds an animation to be played delay seconds after the current or last queued animation
|
/// Adds an animation to be played delay seconds after the current or last queued animation
|
||||||
/// for a track. If the track is empty, it is equivalent to calling setAnimation.
|
/// for a track. If the track is empty, it is equivalent to calling setAnimation.
|
||||||
/// @param delay
|
/// @param delay
|
||||||
/// Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation
|
/// Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation
|
||||||
/// duration of the previous track minus any mix duration plus the negative delay.
|
/// duration of the previous track minus any mix duration plus the negative delay.
|
||||||
///
|
///
|
||||||
/// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
/// @return A track entry to allow further customization of animation playback. References to the track entry must not be kept
|
||||||
/// after AnimationState.Dispose
|
/// after AnimationState.Dispose
|
||||||
TrackEntry* addAnimation(size_t trackIndex, Animation* animation, bool loop, float delay);
|
TrackEntry* addAnimation(size_t trackIndex, Animation* animation, bool loop, float delay);
|
||||||
|
|
||||||
///
|
/// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration.
|
||||||
/// Sets an empty animation for a track, discarding any queued animations, and mixes to it over the specified mix duration.
|
TrackEntry* setEmptyAnimation(size_t trackIndex, float mixDuration);
|
||||||
TrackEntry* setEmptyAnimation(size_t trackIndex, float mixDuration);
|
|
||||||
|
|
||||||
///
|
/// Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the
|
||||||
/// Adds an empty animation to be played after the current or last queued animation for a track, and mixes to it over the
|
/// specified mix duration.
|
||||||
/// specified mix duration.
|
/// @return
|
||||||
/// @return
|
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept after AnimationState.Dispose.
|
||||||
/// A track entry to allow further customization of animation playback. References to the track entry must not be kept after AnimationState.Dispose.
|
///
|
||||||
///
|
/// @param trackIndex Track number.
|
||||||
/// @param trackIndex Track number.
|
/// @param mixDuration Mix duration.
|
||||||
/// @param mixDuration Mix duration.
|
/// @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation
|
||||||
/// @param delay Seconds to begin this animation after the start of the previous animation. May be <= 0 to use the animation
|
/// duration of the previous track minus any mix duration plus the negative delay.
|
||||||
/// duration of the previous track minus any mix duration plus the negative delay.
|
TrackEntry* addEmptyAnimation(size_t trackIndex, float mixDuration, float delay);
|
||||||
TrackEntry* addEmptyAnimation(size_t trackIndex, float mixDuration, float delay);
|
|
||||||
|
|
||||||
///
|
/// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.
|
||||||
/// Sets an empty animation for every track, discarding any queued animations, and mixes to it over the specified mix duration.
|
void setEmptyAnimations(float mixDuration);
|
||||||
void setEmptyAnimations(float mixDuration);
|
|
||||||
|
|
||||||
/// @return The track entry for the animation currently playing on the track, or NULL if no animation is currently playing.
|
/// @return The track entry for the animation currently playing on the track, or NULL if no animation is currently playing.
|
||||||
TrackEntry* getCurrent(size_t trackIndex);
|
TrackEntry* getCurrent(size_t trackIndex);
|
||||||
|
|
||||||
AnimationStateData* getData();
|
AnimationStateData* getData();
|
||||||
|
|
||||||
/// A list of tracks that have animations, which may contain NULLs.
|
/// A list of tracks that have animations, which may contain NULLs.
|
||||||
Vector<TrackEntry*> &getTracks();
|
Vector<TrackEntry*> &getTracks();
|
||||||
|
|
||||||
float getTimeScale();
|
float getTimeScale();
|
||||||
void setTimeScale(float inValue);
|
void setTimeScale(float inValue);
|
||||||
|
|
||||||
void setListener(AnimationStateListener listener);
|
void setListener(AnimationStateListener listener);
|
||||||
void setListener(AnimationStateListenerObject* listener);
|
void setListener(AnimationStateListenerObject* listener);
|
||||||
|
|
||||||
void disableQueue();
|
void disableQueue();
|
||||||
void enableQueue();
|
void enableQueue();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AnimationStateData* _data;
|
AnimationStateData* _data;
|
||||||
|
|
||||||
Pool<TrackEntry> _trackEntryPool;
|
Pool<TrackEntry> _trackEntryPool;
|
||||||
Vector<TrackEntry*> _tracks;
|
Vector<TrackEntry*> _tracks;
|
||||||
Vector<Event*> _events;
|
Vector<Event*> _events;
|
||||||
EventQueue* _queue;
|
EventQueue* _queue;
|
||||||
|
|
||||||
Vector<int> _propertyIDs;
|
Vector<int> _propertyIDs;
|
||||||
bool _animationsChanged;
|
bool _animationsChanged;
|
||||||
|
|
||||||
AnimationStateListener _listener;
|
AnimationStateListener _listener;
|
||||||
AnimationStateListenerObject* _listenerObject;
|
AnimationStateListenerObject* _listenerObject;
|
||||||
|
|
||||||
float _timeScale;
|
float _timeScale;
|
||||||
|
|
||||||
static Animation* getEmptyAnimation();
|
static Animation* getEmptyAnimation();
|
||||||
|
|
||||||
static void applyRotateTimeline(RotateTimeline* rotateTimeline, Skeleton& skeleton, float time, float alpha, MixBlend pose, Vector<float>& timelinesRotation, size_t i, bool firstFrame);
|
static void applyRotateTimeline(RotateTimeline* rotateTimeline, Skeleton& skeleton, float time, float alpha, MixBlend pose, Vector<float>& timelinesRotation, size_t i, bool firstFrame);
|
||||||
|
|
||||||
/// Returns true when all mixing from entries are complete.
|
/// Returns true when all mixing from entries are complete.
|
||||||
bool updateMixingFrom(TrackEntry* to, float delta);
|
bool updateMixingFrom(TrackEntry* to, float delta);
|
||||||
|
|
||||||
float applyMixingFrom(TrackEntry* to, Skeleton& skeleton, MixBlend currentPose);
|
float applyMixingFrom(TrackEntry* to, Skeleton& skeleton, MixBlend currentPose);
|
||||||
|
|
||||||
void queueEvents(TrackEntry* entry, float animationTime);
|
void queueEvents(TrackEntry* entry, float animationTime);
|
||||||
|
|
||||||
/// Sets the active TrackEntry for a given track number.
|
/// Sets the active TrackEntry for a given track number.
|
||||||
void setCurrent(size_t index, TrackEntry *current, bool interrupt);
|
void setCurrent(size_t index, TrackEntry *current, bool interrupt);
|
||||||
|
|
||||||
TrackEntry* expandToIndex(size_t index);
|
TrackEntry* expandToIndex(size_t index);
|
||||||
|
|
||||||
/// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values.
|
/// Object-pooling version of new TrackEntry. Obtain an unused TrackEntry from the pool and clear/initialize its values.
|
||||||
/// @param last May be NULL.
|
/// @param last May be NULL.
|
||||||
TrackEntry* newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last);
|
TrackEntry* newTrackEntry(size_t trackIndex, Animation *animation, bool loop, TrackEntry *last);
|
||||||
|
|
||||||
/// Dispose all track entries queued after the given TrackEntry.
|
/// Dispose all track entries queued after the given TrackEntry.
|
||||||
void disposeNext(TrackEntry* entry);
|
void disposeNext(TrackEntry* entry);
|
||||||
|
|
||||||
void animationsChanged();
|
void animationsChanged();
|
||||||
|
|
||||||
void computeHold(TrackEntry *entry);
|
void computeHold(TrackEntry *entry);
|
||||||
|
|
||||||
void computeNotLast(TrackEntry *entry);
|
void computeNotLast(TrackEntry *entry);
|
||||||
|
|
||||||
bool hasTimeline(TrackEntry *entry, int inId);
|
bool hasTimeline(TrackEntry *entry, int inId);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_AnimationState_h */
|
#endif /* Spine_AnimationState_h */
|
||||||
|
|||||||
@ -37,51 +37,49 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SkeletonData;
|
class SkeletonData;
|
||||||
class Animation;
|
class Animation;
|
||||||
|
|
||||||
/// Stores mix (crossfade) durations to be applied when AnimationState animations are changed.
|
/// Stores mix (crossfade) durations to be applied when AnimationState animations are changed.
|
||||||
class SP_API AnimationStateData : public SpineObject {
|
class SP_API AnimationStateData : public SpineObject {
|
||||||
friend class AnimationState;
|
friend class AnimationState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AnimationStateData(SkeletonData* skeletonData);
|
explicit AnimationStateData(SkeletonData* skeletonData);
|
||||||
|
|
||||||
/// The SkeletonData to look up animations when they are specified by name.
|
/// The SkeletonData to look up animations when they are specified by name.
|
||||||
SkeletonData* getSkeletonData();
|
SkeletonData* getSkeletonData();
|
||||||
|
|
||||||
/// The mix duration to use when no mix duration has been specifically defined between two animations.
|
/// The mix duration to use when no mix duration has been specifically defined between two animations.
|
||||||
float getDefaultMix();
|
float getDefaultMix();
|
||||||
void setDefaultMix(float inValue);
|
void setDefaultMix(float inValue);
|
||||||
|
|
||||||
/// Sets a mix duration by animation names.
|
/// Sets a mix duration by animation names.
|
||||||
void setMix(const String& fromName, const String& toName, float duration);
|
void setMix(const String& fromName, const String& toName, float duration);
|
||||||
|
|
||||||
/// Sets a mix duration when changing from the specified animation to the other.
|
/// Sets a mix duration when changing from the specified animation to the other.
|
||||||
/// See TrackEntry.MixDuration.
|
/// See TrackEntry.MixDuration.
|
||||||
void setMix(Animation* from, Animation* to, float duration);
|
void setMix(Animation* from, Animation* to, float duration);
|
||||||
|
|
||||||
///
|
/// The mix duration to use when changing from the specified animation to the other,
|
||||||
/// The mix duration to use when changing from the specified animation to the other,
|
/// or the DefaultMix if no mix duration has been set.
|
||||||
/// or the DefaultMix if no mix duration has been set.
|
float getMix(Animation* from, Animation* to);
|
||||||
///
|
|
||||||
float getMix(Animation* from, Animation* to);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class AnimationPair : public SpineObject {
|
class AnimationPair : public SpineObject {
|
||||||
public:
|
public:
|
||||||
Animation* _a1;
|
Animation* _a1;
|
||||||
Animation* _a2;
|
Animation* _a2;
|
||||||
|
|
||||||
explicit AnimationPair(Animation* a1 = NULL, Animation* a2 = NULL);
|
explicit AnimationPair(Animation* a1 = NULL, Animation* a2 = NULL);
|
||||||
|
|
||||||
bool operator==(const AnimationPair &other) const;
|
bool operator==(const AnimationPair &other) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
SkeletonData* _skeletonData;
|
SkeletonData* _skeletonData;
|
||||||
float _defaultMix;
|
float _defaultMix;
|
||||||
HashMap<AnimationPair, float> _animationToMixTime;
|
HashMap<AnimationPair, float> _animationToMixTime;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_AnimationStateData_h */
|
#endif /* Spine_AnimationStateData_h */
|
||||||
|
|||||||
@ -76,8 +76,8 @@ public:
|
|||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
explicit AtlasPage(const String &inName) : name(inName), format(Format_RGBA8888), minFilter(TextureFilter_Nearest),
|
explicit AtlasPage(const String &inName) : name(inName), format(Format_RGBA8888), minFilter(TextureFilter_Nearest),
|
||||||
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
|
magFilter(TextureFilter_Nearest), uWrap(TextureWrap_ClampToEdge),
|
||||||
vWrap(TextureWrap_ClampToEdge), width(0), height(0) {
|
vWrap(TextureWrap_ClampToEdge), width(0), height(0) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -36,38 +36,36 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Atlas;
|
class Atlas;
|
||||||
class AtlasRegion;
|
class AtlasRegion;
|
||||||
|
|
||||||
///
|
/// An AttachmentLoader that configures attachments using texture regions from an Atlas.
|
||||||
/// An AttachmentLoader that configures attachments using texture regions from an Atlas.
|
/// See http://esotericsoftware.com/spine-loading-skeleton-data#JSON-and-binary-data about Loading Skeleton Data in the Spine Runtimes Guide.
|
||||||
/// See http://esotericsoftware.com/spine-loading-skeleton-data#JSON-and-binary-data about Loading Skeleton Data in the Spine Runtimes Guide.
|
|
||||||
///
|
|
||||||
class SP_API AtlasAttachmentLoader : public AttachmentLoader {
|
class SP_API AtlasAttachmentLoader : public AttachmentLoader {
|
||||||
public:
|
public:
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
explicit AtlasAttachmentLoader(Atlas* atlas);
|
explicit AtlasAttachmentLoader(Atlas* atlas);
|
||||||
|
|
||||||
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path);
|
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path);
|
||||||
|
|
||||||
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path);
|
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path);
|
||||||
|
|
||||||
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name);
|
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name);
|
||||||
|
|
||||||
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name);
|
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name);
|
||||||
|
|
||||||
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name);
|
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name);
|
||||||
|
|
||||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
|
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name);
|
||||||
|
|
||||||
virtual void configureAttachment(Attachment* attachment);
|
virtual void configureAttachment(Attachment* attachment);
|
||||||
|
|
||||||
AtlasRegion* findRegion(const String& name);
|
AtlasRegion* findRegion(const String& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Atlas* _atlas;
|
Atlas* _atlas;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_AtlasAttachmentLoader_h */
|
#endif /* Spine_AtlasAttachmentLoader_h */
|
||||||
|
|||||||
@ -35,41 +35,41 @@
|
|||||||
#include <spine/SpineString.h>
|
#include <spine/SpineString.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Skin;
|
class Skin;
|
||||||
class Attachment;
|
class Attachment;
|
||||||
class RegionAttachment;
|
class RegionAttachment;
|
||||||
class MeshAttachment;
|
class MeshAttachment;
|
||||||
class BoundingBoxAttachment;
|
class BoundingBoxAttachment;
|
||||||
class PathAttachment;
|
class PathAttachment;
|
||||||
class PointAttachment;
|
class PointAttachment;
|
||||||
class ClippingAttachment;
|
class ClippingAttachment;
|
||||||
|
|
||||||
class SP_API AttachmentLoader : public SpineObject {
|
class SP_API AttachmentLoader : public SpineObject {
|
||||||
public:
|
public:
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
AttachmentLoader();
|
AttachmentLoader();
|
||||||
|
|
||||||
virtual ~AttachmentLoader();
|
virtual ~AttachmentLoader();
|
||||||
|
|
||||||
/// @return May be NULL to not load any attachment.
|
/// @return May be NULL to not load any attachment.
|
||||||
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path) = 0;
|
virtual RegionAttachment* newRegionAttachment(Skin& skin, const String& name, const String& path) = 0;
|
||||||
|
|
||||||
/// @return May be NULL to not load any attachment.
|
/// @return May be NULL to not load any attachment.
|
||||||
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path) = 0;
|
virtual MeshAttachment* newMeshAttachment(Skin& skin, const String& name, const String& path) = 0;
|
||||||
|
|
||||||
/// @return May be NULL to not load any attachment.
|
/// @return May be NULL to not load any attachment.
|
||||||
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name) = 0;
|
virtual BoundingBoxAttachment* newBoundingBoxAttachment(Skin& skin, const String& name) = 0;
|
||||||
|
|
||||||
/// @return May be NULL to not load any attachment
|
/// @return May be NULL to not load any attachment
|
||||||
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name) = 0;
|
virtual PathAttachment* newPathAttachment(Skin& skin, const String& name) = 0;
|
||||||
|
|
||||||
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name) = 0;
|
virtual PointAttachment* newPointAttachment(Skin& skin, const String& name) = 0;
|
||||||
|
|
||||||
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name) = 0;
|
virtual ClippingAttachment* newClippingAttachment(Skin& skin, const String& name) = 0;
|
||||||
|
|
||||||
virtual void configureAttachment(Attachment* attachment) = 0;
|
virtual void configureAttachment(Attachment* attachment) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_AttachmentLoader_h */
|
#endif /* Spine_AttachmentLoader_h */
|
||||||
|
|||||||
@ -39,35 +39,35 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
class Event;
|
class Event;
|
||||||
|
|
||||||
class SP_API AttachmentTimeline : public Timeline {
|
class SP_API AttachmentTimeline : public Timeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AttachmentTimeline(int frameCount);
|
explicit AttachmentTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
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, float time, const String& attachmentName);
|
void setFrame(int frameIndex, float time, const String& attachmentName);
|
||||||
|
|
||||||
size_t getSlotIndex();
|
size_t getSlotIndex();
|
||||||
void setSlotIndex(size_t inValue);
|
void setSlotIndex(size_t inValue);
|
||||||
const Vector<float>& getFrames();
|
const Vector<float>& getFrames();
|
||||||
const Vector<String>& getAttachmentNames();
|
const Vector<String>& getAttachmentNames();
|
||||||
size_t getFrameCount();
|
size_t getFrameCount();
|
||||||
private:
|
private:
|
||||||
size_t _slotIndex;
|
size_t _slotIndex;
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
Vector<String> _attachmentNames;
|
Vector<String> _attachmentNames;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_AttachmentTimeline_h */
|
#endif /* Spine_AttachmentTimeline_h */
|
||||||
|
|||||||
@ -31,15 +31,15 @@
|
|||||||
#define Spine_AttachmentType_h
|
#define Spine_AttachmentType_h
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
enum AttachmentType {
|
enum AttachmentType {
|
||||||
AttachmentType_Region,
|
AttachmentType_Region,
|
||||||
AttachmentType_Boundingbox,
|
AttachmentType_Boundingbox,
|
||||||
AttachmentType_Mesh,
|
AttachmentType_Mesh,
|
||||||
AttachmentType_Linkedmesh,
|
AttachmentType_Linkedmesh,
|
||||||
AttachmentType_Path,
|
AttachmentType_Path,
|
||||||
AttachmentType_Point,
|
AttachmentType_Point,
|
||||||
AttachmentType_Clipping
|
AttachmentType_Clipping
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_AttachmentType_h */
|
#endif /* Spine_AttachmentType_h */
|
||||||
|
|||||||
@ -98,9 +98,7 @@ public:
|
|||||||
|
|
||||||
float localToWorldRotation(float localRotation);
|
float localToWorldRotation(float localRotation);
|
||||||
|
|
||||||
///
|
|
||||||
/// Rotates the world transform the specified amount and sets isAppliedValid to false.
|
/// Rotates the world transform the specified amount and sets isAppliedValid to false.
|
||||||
///
|
|
||||||
/// @param degrees Degrees.
|
/// @param degrees Degrees.
|
||||||
void rotateWorld(float degrees);
|
void rotateWorld(float degrees);
|
||||||
|
|
||||||
|
|||||||
@ -34,14 +34,14 @@
|
|||||||
#include <spine/SpineObject.h>
|
#include <spine/SpineObject.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
/// Attachment that has a polygon for bounds checking.
|
/// Attachment that has a polygon for bounds checking.
|
||||||
class SP_API BoundingBoxAttachment : public VertexAttachment {
|
class SP_API BoundingBoxAttachment : public VertexAttachment {
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
explicit BoundingBoxAttachment(const String& name);
|
explicit BoundingBoxAttachment(const String& name);
|
||||||
|
|
||||||
virtual Attachment* copy();
|
virtual Attachment* copy();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_BoundingBoxAttachment_h */
|
#endif /* Spine_BoundingBoxAttachment_h */
|
||||||
|
|||||||
@ -33,27 +33,27 @@
|
|||||||
#include <spine/VertexAttachment.h>
|
#include <spine/VertexAttachment.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SlotData;
|
class SlotData;
|
||||||
|
|
||||||
class SP_API ClippingAttachment : public VertexAttachment {
|
class SP_API ClippingAttachment : public VertexAttachment {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
friend class SkeletonClipping;
|
friend class SkeletonClipping;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ClippingAttachment(const String& name);
|
explicit ClippingAttachment(const String& name);
|
||||||
|
|
||||||
SlotData* getEndSlot();
|
SlotData* getEndSlot();
|
||||||
void setEndSlot(SlotData* inValue);
|
void setEndSlot(SlotData* inValue);
|
||||||
|
|
||||||
virtual Attachment* copy();
|
virtual Attachment* copy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SlotData* _endSlot;
|
SlotData* _endSlot;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_ClippingAttachment_h */
|
#endif /* Spine_ClippingAttachment_h */
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public:
|
|||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
MixDirection direction);
|
MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
|
|
||||||
|
|||||||
@ -39,89 +39,89 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API ContainerUtil : public SpineObject {
|
class SP_API ContainerUtil : public SpineObject {
|
||||||
public:
|
public:
|
||||||
/// Finds an item by comparing each item's name.
|
/// Finds an item by comparing each item's name.
|
||||||
/// It is more efficient to cache the results of this method than to call it multiple times.
|
/// It is more efficient to cache the results of this method than to call it multiple times.
|
||||||
/// @return May be NULL.
|
/// @return May be NULL.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T* findWithName(Vector<T*>& items, const String& name) {
|
static T* findWithName(Vector<T*>& items, const String& name) {
|
||||||
assert(name.length() > 0);
|
assert(name.length() > 0);
|
||||||
|
|
||||||
for (size_t i = 0; i < items.size(); ++i) {
|
for (size_t i = 0; i < items.size(); ++i) {
|
||||||
T* item = items[i];
|
T* item = items[i];
|
||||||
if (item->getName() == name) {
|
if (item->getName() == name) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return -1 if the item was not found.
|
/// @return -1 if the item was not found.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static int findIndexWithName(Vector<T*>& items, const String& name) {
|
static int findIndexWithName(Vector<T*>& items, const String& name) {
|
||||||
assert(name.length() > 0);
|
assert(name.length() > 0);
|
||||||
|
|
||||||
for (size_t i = 0, len = items.size(); i < len; ++i) {
|
for (size_t i = 0, len = items.size(); i < len; ++i) {
|
||||||
T* item = items[i];
|
T* item = items[i];
|
||||||
if (item->getName() == name) {
|
if (item->getName() == name) {
|
||||||
return static_cast<int>(i);
|
return static_cast<int>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finds an item by comparing each item's name.
|
/// Finds an item by comparing each item's name.
|
||||||
/// It is more efficient to cache the results of this method than to call it multiple times.
|
/// It is more efficient to cache the results of this method than to call it multiple times.
|
||||||
/// @return May be NULL.
|
/// @return May be NULL.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T* findWithDataName(Vector<T*>& items, const String& name) {
|
static T* findWithDataName(Vector<T*>& items, const String& name) {
|
||||||
assert(name.length() > 0);
|
assert(name.length() > 0);
|
||||||
|
|
||||||
for (size_t i = 0; i < items.size(); ++i) {
|
for (size_t i = 0; i < items.size(); ++i) {
|
||||||
T* item = items[i];
|
T* item = items[i];
|
||||||
if (item->getData().getName() == name) {
|
if (item->getData().getName() == name) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return -1 if the item was not found.
|
/// @return -1 if the item was not found.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static int findIndexWithDataName(Vector<T*>& items, const String& name) {
|
static int findIndexWithDataName(Vector<T*>& items, const String& name) {
|
||||||
assert(name.length() > 0);
|
assert(name.length() > 0);
|
||||||
|
|
||||||
for (size_t i = 0, len = items.size(); i < len; ++i) {
|
for (size_t i = 0, len = items.size(); i < len; ++i) {
|
||||||
T* item = items[i];
|
T* item = items[i];
|
||||||
if (item->getData().getName() == name) {
|
if (item->getData().getName() == name) {
|
||||||
return static_cast<int>(i);
|
return static_cast<int>(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void cleanUpVectorOfPointers(Vector<T*>& items) {
|
static void cleanUpVectorOfPointers(Vector<T*>& items) {
|
||||||
for (int i = (int)items.size() - 1; i >= 0; i--) {
|
for (int i = (int)items.size() - 1; i >= 0; i--) {
|
||||||
T* item = items[i];
|
T* item = items[i];
|
||||||
|
|
||||||
delete item;
|
delete item;
|
||||||
|
|
||||||
items.removeAt(i);
|
items.removeAt(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// ctor, copy ctor, and assignment should be private in a Singleton
|
// ctor, copy ctor, and assignment should be private in a Singleton
|
||||||
ContainerUtil();
|
ContainerUtil();
|
||||||
ContainerUtil(const ContainerUtil&);
|
ContainerUtil(const ContainerUtil&);
|
||||||
ContainerUtil& operator=(const ContainerUtil&);
|
ContainerUtil& operator=(const ContainerUtil&);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_ContainerUtil_h */
|
#endif /* Spine_ContainerUtil_h */
|
||||||
|
|||||||
@ -34,43 +34,43 @@
|
|||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
/// Base class for frames that use an interpolation bezier curve.
|
/// Base class for frames that use an interpolation bezier curve.
|
||||||
class SP_API CurveTimeline : public Timeline {
|
class SP_API CurveTimeline : public Timeline {
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CurveTimeline(int frameCount);
|
explicit CurveTimeline(int frameCount);
|
||||||
|
|
||||||
virtual ~CurveTimeline();
|
virtual ~CurveTimeline();
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction) = 0;
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction) = 0;
|
||||||
|
|
||||||
virtual int getPropertyId() = 0;
|
virtual int getPropertyId() = 0;
|
||||||
|
|
||||||
size_t getFrameCount();
|
size_t getFrameCount();
|
||||||
|
|
||||||
void setLinear(size_t frameIndex);
|
void setLinear(size_t frameIndex);
|
||||||
|
|
||||||
void setStepped(size_t 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(size_t frameIndex, float cx1, float cy1, float cx2, float cy2);
|
void setCurve(size_t frameIndex, float cx1, float cy1, float cx2, float cy2);
|
||||||
|
|
||||||
float getCurvePercent(size_t frameIndex, float percent);
|
float getCurvePercent(size_t frameIndex, float percent);
|
||||||
|
|
||||||
float getCurveType(size_t frameIndex);
|
float getCurveType(size_t frameIndex);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const float LINEAR;
|
static const float LINEAR;
|
||||||
static const float STEPPED;
|
static const float STEPPED;
|
||||||
static const float BEZIER;
|
static const float BEZIER;
|
||||||
static const int BEZIER_SIZE;
|
static const int BEZIER_SIZE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<float> _curves; // type, x, y, ...
|
Vector<float> _curves; // type, x, y, ...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_CurveTimeline_h */
|
#endif /* Spine_CurveTimeline_h */
|
||||||
|
|||||||
@ -33,37 +33,37 @@
|
|||||||
#include <spine/CurveTimeline.h>
|
#include <spine/CurveTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class VertexAttachment;
|
class VertexAttachment;
|
||||||
|
|
||||||
class SP_API DeformTimeline : public CurveTimeline {
|
class SP_API DeformTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DeformTimeline(int frameCount);
|
explicit DeformTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
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, float time, Vector<float>& vertices);
|
void setFrame(int frameIndex, float time, Vector<float>& vertices);
|
||||||
|
|
||||||
int getSlotIndex();
|
int getSlotIndex();
|
||||||
void setSlotIndex(int inValue);
|
void setSlotIndex(int inValue);
|
||||||
Vector<float>& getFrames();
|
Vector<float>& getFrames();
|
||||||
Vector< Vector<float> >& getVertices();
|
Vector< Vector<float> >& getVertices();
|
||||||
VertexAttachment* getAttachment();
|
VertexAttachment* getAttachment();
|
||||||
void setAttachment(VertexAttachment* inValue);
|
void setAttachment(VertexAttachment* inValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _slotIndex;
|
int _slotIndex;
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
Vector< Vector<float> > _frameVertices;
|
Vector< Vector<float> > _frameVertices;
|
||||||
VertexAttachment* _attachment;
|
VertexAttachment* _attachment;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_DeformTimeline_h */
|
#endif /* Spine_DeformTimeline_h */
|
||||||
|
|||||||
@ -33,31 +33,31 @@
|
|||||||
#include <spine/Timeline.h>
|
#include <spine/Timeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API DrawOrderTimeline : public Timeline {
|
class SP_API DrawOrderTimeline : public Timeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DrawOrderTimeline(int frameCount);
|
explicit DrawOrderTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
|
|
||||||
/// 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(size_t 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();
|
||||||
size_t getFrameCount();
|
size_t getFrameCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
Vector< Vector<int> > _drawOrders;
|
Vector< Vector<int> > _drawOrders;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_DrawOrderTimeline_h */
|
#endif /* Spine_DrawOrderTimeline_h */
|
||||||
|
|||||||
@ -33,32 +33,32 @@
|
|||||||
#include <spine/Timeline.h>
|
#include <spine/Timeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API EventTimeline : public Timeline {
|
class SP_API EventTimeline : public Timeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EventTimeline(int frameCount);
|
explicit EventTimeline(int frameCount);
|
||||||
|
|
||||||
~EventTimeline();
|
~EventTimeline();
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
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(size_t frameIndex, Event* event);
|
void setFrame(size_t frameIndex, Event* event);
|
||||||
|
|
||||||
Vector<float> getFrames();
|
Vector<float> getFrames();
|
||||||
Vector<Event*>& getEvents();
|
Vector<Event*>& getEvents();
|
||||||
size_t getFrameCount();
|
size_t getFrameCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
Vector<Event*> _events;
|
Vector<Event*> _events;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_EventTimeline_h */
|
#endif /* Spine_EventTimeline_h */
|
||||||
|
|||||||
@ -34,7 +34,7 @@
|
|||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
#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
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable:4291)
|
#pragma warning(disable:4291)
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -36,54 +36,54 @@
|
|||||||
#include <spine/ConstraintData.h>
|
#include <spine/ConstraintData.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
|
|
||||||
class SP_API IkConstraintData : public ConstraintData {
|
class SP_API IkConstraintData : public ConstraintData {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class IkConstraint;
|
friend class IkConstraint;
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class IkConstraintTimeline;
|
friend class IkConstraintTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit IkConstraintData(const String& name);
|
explicit IkConstraintData(const String& name);
|
||||||
|
|
||||||
/// The bones that are constrained by this IK Constraint.
|
/// The bones that are constrained by this IK Constraint.
|
||||||
Vector<BoneData*>& getBones();
|
Vector<BoneData*>& getBones();
|
||||||
|
|
||||||
/// The bone that is the IK target.
|
/// The bone that is the IK target.
|
||||||
BoneData* getTarget();
|
BoneData* getTarget();
|
||||||
void setTarget(BoneData* inValue);
|
void setTarget(BoneData* inValue);
|
||||||
|
|
||||||
/// Controls the bend direction of the IK bones, either 1 or -1.
|
/// Controls the bend direction of the IK bones, either 1 or -1.
|
||||||
int getBendDirection();
|
int getBendDirection();
|
||||||
void setBendDirection(int inValue);
|
void setBendDirection(int inValue);
|
||||||
|
|
||||||
bool getCompress();
|
bool getCompress();
|
||||||
void setCompress(bool inValue);
|
void setCompress(bool inValue);
|
||||||
|
|
||||||
bool getStretch();
|
bool getStretch();
|
||||||
void setStretch(bool inValue);
|
void setStretch(bool inValue);
|
||||||
|
|
||||||
bool getUniform();
|
bool getUniform();
|
||||||
void setUniform(bool inValue);
|
void setUniform(bool inValue);
|
||||||
|
|
||||||
float getMix();
|
float getMix();
|
||||||
void setMix(float inValue);
|
void setMix(float inValue);
|
||||||
|
|
||||||
float getSoftness();
|
float getSoftness();
|
||||||
void setSoftness(float inValue);
|
void setSoftness(float inValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<BoneData*> _bones;
|
Vector<BoneData*> _bones;
|
||||||
BoneData* _target;
|
BoneData* _target;
|
||||||
int _bendDirection;
|
int _bendDirection;
|
||||||
bool _compress;
|
bool _compress;
|
||||||
bool _stretch;
|
bool _stretch;
|
||||||
bool _uniform;
|
bool _uniform;
|
||||||
float _mix;
|
float _mix;
|
||||||
float _softness;
|
float _softness;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_IkConstraintData_h */
|
#endif /* Spine_IkConstraintData_h */
|
||||||
|
|||||||
@ -34,25 +34,25 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class SP_API IkConstraintTimeline : public CurveTimeline {
|
class SP_API IkConstraintTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
explicit IkConstraintTimeline(int frameCount);
|
explicit IkConstraintTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
|
|
||||||
/// Sets the time, mix and bend direction of the specified keyframe.
|
/// Sets the time, mix and bend direction of the specified keyframe.
|
||||||
void setFrame (int frameIndex, float time, float mix, float softness, int bendDirection, bool compress, bool stretch);
|
void setFrame (int frameIndex, float time, float mix, float softness, int bendDirection, bool compress, bool stretch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int PREV_TIME;
|
static const int PREV_TIME;
|
||||||
static const int PREV_MIX;
|
static const int PREV_MIX;
|
||||||
static const int PREV_SOFTNESS;
|
static const int PREV_SOFTNESS;
|
||||||
@ -65,9 +65,9 @@ namespace spine {
|
|||||||
static const int COMPRESS;
|
static const int COMPRESS;
|
||||||
static const int STRETCH;
|
static const int STRETCH;
|
||||||
|
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
int _ikConstraintIndex;
|
int _ikConstraintIndex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_IkConstraintTimeline_h */
|
#endif /* Spine_IkConstraintTimeline_h */
|
||||||
|
|||||||
@ -36,105 +36,105 @@
|
|||||||
#include <spine/HasRendererObject.h>
|
#include <spine/HasRendererObject.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
/// Attachment that displays a texture region using a mesh.
|
/// Attachment that displays a texture region using a mesh.
|
||||||
class SP_API MeshAttachment : public VertexAttachment, public HasRendererObject {
|
class SP_API MeshAttachment : public VertexAttachment, public HasRendererObject {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class AtlasAttachmentLoader;
|
friend class AtlasAttachmentLoader;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MeshAttachment(const String& name);
|
explicit MeshAttachment(const String& name);
|
||||||
|
|
||||||
virtual ~MeshAttachment();
|
virtual ~MeshAttachment();
|
||||||
|
|
||||||
void updateUVs();
|
void updateUVs();
|
||||||
|
|
||||||
int getHullLength();
|
int getHullLength();
|
||||||
void setHullLength(int inValue);
|
void setHullLength(int inValue);
|
||||||
|
|
||||||
Vector<float>& getRegionUVs();
|
Vector<float>& getRegionUVs();
|
||||||
|
|
||||||
/// The UV pair for each vertex, normalized within the entire texture. See also MeshAttachment::updateUVs
|
/// The UV pair for each vertex, normalized within the entire texture. See also MeshAttachment::updateUVs
|
||||||
Vector<float>& getUVs();
|
Vector<float>& getUVs();
|
||||||
|
|
||||||
Vector<unsigned short>& getTriangles();
|
Vector<unsigned short>& getTriangles();
|
||||||
|
|
||||||
Color& getColor();
|
Color& getColor();
|
||||||
|
|
||||||
const String& getPath();
|
const String& getPath();
|
||||||
void setPath(const String& inValue);
|
void setPath(const String& inValue);
|
||||||
|
|
||||||
float getRegionU();
|
float getRegionU();
|
||||||
void setRegionU(float inValue);
|
void setRegionU(float inValue);
|
||||||
|
|
||||||
float getRegionV();
|
float getRegionV();
|
||||||
void setRegionV(float inValue);
|
void setRegionV(float inValue);
|
||||||
|
|
||||||
float getRegionU2();
|
float getRegionU2();
|
||||||
void setRegionU2(float inValue);
|
void setRegionU2(float inValue);
|
||||||
|
|
||||||
float getRegionV2();
|
float getRegionV2();
|
||||||
void setRegionV2(float inValue);
|
void setRegionV2(float inValue);
|
||||||
|
|
||||||
bool getRegionRotate();
|
bool getRegionRotate();
|
||||||
void setRegionRotate(bool inValue);
|
void setRegionRotate(bool inValue);
|
||||||
|
|
||||||
float getRegionOffsetX();
|
float getRegionOffsetX();
|
||||||
void setRegionOffsetX(float inValue);
|
void setRegionOffsetX(float inValue);
|
||||||
|
|
||||||
// Pixels stripped from the bottom left, unrotated.
|
// Pixels stripped from the bottom left, unrotated.
|
||||||
float getRegionOffsetY();
|
float getRegionOffsetY();
|
||||||
void setRegionOffsetY(float inValue);
|
void setRegionOffsetY(float inValue);
|
||||||
|
|
||||||
float getRegionWidth();
|
float getRegionWidth();
|
||||||
void setRegionWidth(float inValue);
|
void setRegionWidth(float inValue);
|
||||||
|
|
||||||
// Unrotated, stripped size.
|
// Unrotated, stripped size.
|
||||||
float getRegionHeight();
|
float getRegionHeight();
|
||||||
void setRegionHeight(float inValue);
|
void setRegionHeight(float inValue);
|
||||||
|
|
||||||
float getRegionOriginalWidth();
|
float getRegionOriginalWidth();
|
||||||
void setRegionOriginalWidth(float inValue);
|
void setRegionOriginalWidth(float inValue);
|
||||||
|
|
||||||
// Unrotated, unstripped size.
|
// Unrotated, unstripped size.
|
||||||
float getRegionOriginalHeight();
|
float getRegionOriginalHeight();
|
||||||
void setRegionOriginalHeight(float inValue);
|
void setRegionOriginalHeight(float inValue);
|
||||||
|
|
||||||
MeshAttachment* getParentMesh();
|
MeshAttachment* getParentMesh();
|
||||||
void setParentMesh(MeshAttachment* inValue);
|
void setParentMesh(MeshAttachment* inValue);
|
||||||
|
|
||||||
// Nonessential.
|
// Nonessential.
|
||||||
Vector<unsigned short>& getEdges();
|
Vector<unsigned short>& getEdges();
|
||||||
float getWidth();
|
float getWidth();
|
||||||
void setWidth(float inValue);
|
void setWidth(float inValue);
|
||||||
float getHeight();
|
float getHeight();
|
||||||
void setHeight(float inValue);
|
void setHeight(float inValue);
|
||||||
|
|
||||||
virtual Attachment* copy();
|
virtual Attachment* copy();
|
||||||
|
|
||||||
MeshAttachment* newLinkedMesh();
|
MeshAttachment* newLinkedMesh();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
||||||
MeshAttachment* _parentMesh;
|
MeshAttachment* _parentMesh;
|
||||||
Vector<float> _uvs;
|
Vector<float> _uvs;
|
||||||
Vector<float> _regionUVs;
|
Vector<float> _regionUVs;
|
||||||
Vector<unsigned short> _triangles;
|
Vector<unsigned short> _triangles;
|
||||||
Vector<unsigned short> _edges;
|
Vector<unsigned short> _edges;
|
||||||
String _path;
|
String _path;
|
||||||
float _regionU;
|
float _regionU;
|
||||||
float _regionV;
|
float _regionV;
|
||||||
float _regionU2;
|
float _regionU2;
|
||||||
float _regionV2;
|
float _regionV2;
|
||||||
float _width;
|
float _width;
|
||||||
float _height;
|
float _height;
|
||||||
Color _color;
|
Color _color;
|
||||||
int _hullLength;
|
int _hullLength;
|
||||||
bool _regionRotate;
|
bool _regionRotate;
|
||||||
int _regionDegrees;
|
int _regionDegrees;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_MeshAttachment_h */
|
#endif /* Spine_MeshAttachment_h */
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
#define Spine_MixPose_h
|
#define Spine_MixPose_h
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
///
|
|
||||||
/// Controls how a timeline is mixed with the setup or current pose.
|
/// Controls how a timeline is mixed with the setup or current pose.
|
||||||
/// See also Timeline::apply(Skeleton&, float, float, Vector&, float, Blend, MixDirection)
|
/// See also Timeline::apply(Skeleton&, float, float, Vector&, float, Blend, MixDirection)
|
||||||
enum MixBlend {
|
enum MixBlend {
|
||||||
|
|||||||
@ -31,13 +31,14 @@
|
|||||||
#define Spine_MixDirection_h
|
#define Spine_MixDirection_h
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
///
|
|
||||||
/// Indicates whether a timeline's alpha is mixing out over time toward 0 (the setup or current pose) or mixing in toward 1 (the timeline's pose).
|
/// Indicates whether a timeline's alpha is mixing out over time toward 0 (the setup or current pose) or mixing in toward 1 (the timeline's pose).
|
||||||
/// See also Timeline::apply(Skeleton&, float, float, Vector&, float, MixPose, MixDirection)
|
/// See also Timeline::apply(Skeleton&, float, float, Vector&, float, MixPose, MixDirection)
|
||||||
enum MixDirection {
|
enum MixDirection {
|
||||||
MixDirection_In = 0,
|
MixDirection_In = 0,
|
||||||
MixDirection_Out
|
MixDirection_Out
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_MixDirection_h */
|
#endif /* Spine_MixDirection_h */
|
||||||
|
|||||||
@ -33,28 +33,28 @@
|
|||||||
#include <spine/VertexAttachment.h>
|
#include <spine/VertexAttachment.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API PathAttachment : public VertexAttachment {
|
class SP_API PathAttachment : public VertexAttachment {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PathAttachment(const String& name);
|
explicit PathAttachment(const String& name);
|
||||||
|
|
||||||
/// The length in the setup pose from the start of the path to the end of each curve.
|
/// The length in the setup pose from the start of the path to the end of each curve.
|
||||||
Vector<float>& getLengths();
|
Vector<float>& getLengths();
|
||||||
bool isClosed();
|
bool isClosed();
|
||||||
void setClosed(bool inValue);
|
void setClosed(bool inValue);
|
||||||
bool isConstantSpeed();
|
bool isConstantSpeed();
|
||||||
void setConstantSpeed(bool inValue);
|
void setConstantSpeed(bool inValue);
|
||||||
|
|
||||||
virtual Attachment* copy();
|
virtual Attachment* copy();
|
||||||
private:
|
private:
|
||||||
Vector<float> _lengths;
|
Vector<float> _lengths;
|
||||||
bool _closed;
|
bool _closed;
|
||||||
bool _constantSpeed;
|
bool _constantSpeed;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PathAttachment_h */
|
#endif /* Spine_PathAttachment_h */
|
||||||
|
|||||||
@ -35,81 +35,81 @@
|
|||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class PathConstraintData;
|
class PathConstraintData;
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
class PathAttachment;
|
class PathAttachment;
|
||||||
class Bone;
|
class Bone;
|
||||||
class Slot;
|
class Slot;
|
||||||
|
|
||||||
class SP_API PathConstraint : public Updatable {
|
class SP_API PathConstraint : public Updatable {
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class PathConstraintMixTimeline;
|
friend class PathConstraintMixTimeline;
|
||||||
friend class PathConstraintPositionTimeline;
|
friend class PathConstraintPositionTimeline;
|
||||||
friend class PathConstraintSpacingTimeline;
|
friend class PathConstraintSpacingTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PathConstraint(PathConstraintData& data, Skeleton& skeleton);
|
PathConstraint(PathConstraintData& data, Skeleton& skeleton);
|
||||||
|
|
||||||
/// Applies the constraint to the constrained bones.
|
/// Applies the constraint to the constrained bones.
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
virtual int getOrder();
|
virtual int getOrder();
|
||||||
|
|
||||||
float getPosition();
|
float getPosition();
|
||||||
void setPosition(float inValue);
|
void setPosition(float inValue);
|
||||||
|
|
||||||
float getSpacing();
|
float getSpacing();
|
||||||
void setSpacing(float inValue);
|
void setSpacing(float inValue);
|
||||||
|
|
||||||
float getRotateMix();
|
float getRotateMix();
|
||||||
void setRotateMix(float inValue);
|
void setRotateMix(float inValue);
|
||||||
|
|
||||||
float getTranslateMix();
|
float getTranslateMix();
|
||||||
void setTranslateMix(float inValue);
|
void setTranslateMix(float inValue);
|
||||||
|
|
||||||
Vector<Bone*>& getBones();
|
Vector<Bone*>& getBones();
|
||||||
|
|
||||||
Slot* getTarget();
|
Slot* getTarget();
|
||||||
void setTarget(Slot* inValue);
|
void setTarget(Slot* inValue);
|
||||||
|
|
||||||
PathConstraintData& getData();
|
PathConstraintData& getData();
|
||||||
|
|
||||||
bool isActive();
|
bool isActive();
|
||||||
|
|
||||||
void setActive(bool inValue);
|
void setActive(bool inValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const float EPSILON;
|
static const float EPSILON;
|
||||||
static const int NONE;
|
static const int NONE;
|
||||||
static const int BEFORE;
|
static const int BEFORE;
|
||||||
static const int AFTER;
|
static const int AFTER;
|
||||||
|
|
||||||
PathConstraintData& _data;
|
PathConstraintData& _data;
|
||||||
Vector<Bone*> _bones;
|
Vector<Bone*> _bones;
|
||||||
Slot* _target;
|
Slot* _target;
|
||||||
float _position, _spacing, _rotateMix, _translateMix;
|
float _position, _spacing, _rotateMix, _translateMix;
|
||||||
|
|
||||||
Vector<float> _spaces;
|
Vector<float> _spaces;
|
||||||
Vector<float> _positions;
|
Vector<float> _positions;
|
||||||
Vector<float> _world;
|
Vector<float> _world;
|
||||||
Vector<float> _curves;
|
Vector<float> _curves;
|
||||||
Vector<float> _lengths;
|
Vector<float> _lengths;
|
||||||
Vector<float> _segments;
|
Vector<float> _segments;
|
||||||
|
|
||||||
bool _active;
|
bool _active;
|
||||||
|
|
||||||
Vector<float>& computeWorldPositions(PathAttachment& path, int spacesCount, bool tangents, bool percentPosition, bool percentSpacing);
|
Vector<float>& computeWorldPositions(PathAttachment& path, int spacesCount, bool tangents, bool percentPosition, bool percentSpacing);
|
||||||
|
|
||||||
static void addBeforePosition(float p, Vector<float>& temp, int i, Vector<float>& output, int o);
|
static void addBeforePosition(float p, Vector<float>& temp, int i, Vector<float>& output, int o);
|
||||||
|
|
||||||
static void addAfterPosition(float p, Vector<float>& temp, int i, Vector<float>& output, int o);
|
static void addAfterPosition(float p, Vector<float>& temp, int i, Vector<float>& output, int o);
|
||||||
|
|
||||||
static void addCurvePosition(float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2, Vector<float>& output, int o, bool tangents);
|
static void addCurvePosition(float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2, float y2, Vector<float>& output, int o, bool tangents);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PathConstraint_h */
|
#endif /* Spine_PathConstraint_h */
|
||||||
|
|||||||
@ -39,60 +39,60 @@
|
|||||||
#include <spine/ConstraintData.h>
|
#include <spine/ConstraintData.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
class SlotData;
|
class SlotData;
|
||||||
|
|
||||||
class SP_API PathConstraintData : public ConstraintData {
|
class SP_API PathConstraintData : public ConstraintData {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
friend class PathConstraint;
|
friend class PathConstraint;
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class PathConstraintMixTimeline;
|
friend class PathConstraintMixTimeline;
|
||||||
friend class PathConstraintPositionTimeline;
|
friend class PathConstraintPositionTimeline;
|
||||||
friend class PathConstraintSpacingTimeline;
|
friend class PathConstraintSpacingTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PathConstraintData(const String& name);
|
explicit PathConstraintData(const String& name);
|
||||||
|
|
||||||
Vector<BoneData*>& getBones();
|
Vector<BoneData*>& getBones();
|
||||||
|
|
||||||
SlotData* getTarget();
|
SlotData* getTarget();
|
||||||
void setTarget(SlotData* inValue);
|
void setTarget(SlotData* inValue);
|
||||||
|
|
||||||
PositionMode getPositionMode();
|
PositionMode getPositionMode();
|
||||||
void setPositionMode(PositionMode inValue);
|
void setPositionMode(PositionMode inValue);
|
||||||
|
|
||||||
SpacingMode getSpacingMode();
|
SpacingMode getSpacingMode();
|
||||||
void setSpacingMode(SpacingMode inValue);
|
void setSpacingMode(SpacingMode inValue);
|
||||||
|
|
||||||
RotateMode getRotateMode();
|
RotateMode getRotateMode();
|
||||||
void setRotateMode(RotateMode inValue);
|
void setRotateMode(RotateMode inValue);
|
||||||
|
|
||||||
float getOffsetRotation();
|
float getOffsetRotation();
|
||||||
void setOffsetRotation(float inValue);
|
void setOffsetRotation(float inValue);
|
||||||
|
|
||||||
float getPosition();
|
float getPosition();
|
||||||
void setPosition(float inValue);
|
void setPosition(float inValue);
|
||||||
|
|
||||||
float getSpacing();
|
float getSpacing();
|
||||||
void setSpacing(float inValue);
|
void setSpacing(float inValue);
|
||||||
|
|
||||||
float getRotateMix();
|
float getRotateMix();
|
||||||
void setRotateMix(float inValue);
|
void setRotateMix(float inValue);
|
||||||
|
|
||||||
float getTranslateMix();
|
float getTranslateMix();
|
||||||
void setTranslateMix(float inValue);
|
void setTranslateMix(float inValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<BoneData*> _bones;
|
Vector<BoneData*> _bones;
|
||||||
SlotData* _target;
|
SlotData* _target;
|
||||||
PositionMode _positionMode;
|
PositionMode _positionMode;
|
||||||
SpacingMode _spacingMode;
|
SpacingMode _spacingMode;
|
||||||
RotateMode _rotateMode;
|
RotateMode _rotateMode;
|
||||||
float _offsetRotation;
|
float _offsetRotation;
|
||||||
float _position, _spacing, _rotateMix, _translateMix;
|
float _position, _spacing, _rotateMix, _translateMix;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PathConstraintData_h */
|
#endif /* Spine_PathConstraintData_h */
|
||||||
|
|||||||
@ -35,34 +35,34 @@
|
|||||||
namespace spine {
|
namespace spine {
|
||||||
#define SP_PATHCONSTRAINTMIXTIMELINE_ENTRIES 5
|
#define SP_PATHCONSTRAINTMIXTIMELINE_ENTRIES 5
|
||||||
|
|
||||||
class SP_API PathConstraintMixTimeline : public CurveTimeline {
|
class SP_API PathConstraintMixTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
explicit PathConstraintMixTimeline(int frameCount);
|
explicit PathConstraintMixTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int PREV_TIME;
|
static const int PREV_TIME;
|
||||||
static const int PREV_ROTATE;
|
static const int PREV_ROTATE;
|
||||||
static const int PREV_TRANSLATE;
|
static const int PREV_TRANSLATE;
|
||||||
static const int ROTATE;
|
static const int ROTATE;
|
||||||
static const int TRANSLATE;
|
static const int TRANSLATE;
|
||||||
|
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
int _pathConstraintIndex;
|
int _pathConstraintIndex;
|
||||||
|
|
||||||
/// Sets the time and mixes of the specified keyframe.
|
/// Sets the time and mixes of the specified keyframe.
|
||||||
void setFrame(int frameIndex, float time, float rotateMix, float translateMix);
|
void setFrame(int frameIndex, float time, float rotateMix, float translateMix);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PathConstraintMixTimeline_h */
|
#endif /* Spine_PathConstraintMixTimeline_h */
|
||||||
|
|||||||
@ -34,34 +34,34 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class SP_API PathConstraintPositionTimeline : public CurveTimeline {
|
class SP_API PathConstraintPositionTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
explicit PathConstraintPositionTimeline(int frameCount);
|
explicit PathConstraintPositionTimeline(int frameCount);
|
||||||
|
|
||||||
virtual ~PathConstraintPositionTimeline();
|
virtual ~PathConstraintPositionTimeline();
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
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, float time, float value);
|
void setFrame(int frameIndex, float time, float value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const int PREV_TIME;
|
static const int PREV_TIME;
|
||||||
static const int PREV_VALUE;
|
static const int PREV_VALUE;
|
||||||
static const int VALUE;
|
static const int VALUE;
|
||||||
|
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
int _pathConstraintIndex;
|
int _pathConstraintIndex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PathConstraintPositionTimeline_h */
|
#endif /* Spine_PathConstraintPositionTimeline_h */
|
||||||
|
|||||||
@ -33,19 +33,19 @@
|
|||||||
#include <spine/PathConstraintPositionTimeline.h>
|
#include <spine/PathConstraintPositionTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API PathConstraintSpacingTimeline : public PathConstraintPositionTimeline {
|
class SP_API PathConstraintSpacingTimeline : public PathConstraintPositionTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PathConstraintSpacingTimeline(int frameCount);
|
explicit PathConstraintSpacingTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PathConstraintSpacingTimeline_h */
|
#endif /* Spine_PathConstraintSpacingTimeline_h */
|
||||||
|
|||||||
@ -33,42 +33,41 @@
|
|||||||
#include <spine/Attachment.h>
|
#include <spine/Attachment.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Bone;
|
class Bone;
|
||||||
|
|
||||||
///
|
/// An attachment which is a single point and a rotation. This can be used to spawn projectiles, particles, etc. A bone can be
|
||||||
/// An attachment which is a single point and a rotation. This can be used to spawn projectiles, particles, etc. A bone can be
|
/// used in similar ways, but a PointAttachment is slightly less expensive to compute and can be hidden, shown, and placed in a
|
||||||
/// used in similar ways, but a PointAttachment is slightly less expensive to compute and can be hidden, shown, and placed in a
|
/// skin.
|
||||||
/// skin.
|
///
|
||||||
///
|
/// See http://esotericsoftware.com/spine-point-attachments for Point Attachments in the Spine User Guide.
|
||||||
/// See http://esotericsoftware.com/spine-point-attachments for Point Attachments in the Spine User Guide.
|
///
|
||||||
///
|
class SP_API PointAttachment : public Attachment {
|
||||||
class SP_API PointAttachment : public Attachment {
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonJson;
|
||||||
friend class SkeletonJson;
|
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PointAttachment(const String& name);
|
explicit PointAttachment(const String& name);
|
||||||
|
|
||||||
void computeWorldPosition(Bone& bone, float& ox, float& oy);
|
void computeWorldPosition(Bone& bone, float& ox, float& oy);
|
||||||
|
|
||||||
float computeWorldRotation(Bone& bone);
|
float computeWorldRotation(Bone& bone);
|
||||||
|
|
||||||
float getX();
|
float getX();
|
||||||
void setX(float inValue);
|
void setX(float inValue);
|
||||||
|
|
||||||
float getY();
|
float getY();
|
||||||
void setY(float inValue);
|
void setY(float inValue);
|
||||||
|
|
||||||
float getRotation();
|
float getRotation();
|
||||||
void setRotation(float inValue);
|
void setRotation(float inValue);
|
||||||
|
|
||||||
virtual Attachment* copy();
|
virtual Attachment* copy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _x, _y, _rotation;
|
float _x, _y, _rotation;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_PointAttachment_h */
|
#endif /* Spine_PointAttachment_h */
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
T *ret = new(__FILE__, __LINE__) T();
|
T *ret = new(__FILE__, __LINE__) T();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,95 +40,95 @@
|
|||||||
#define NUM_UVS 8
|
#define NUM_UVS 8
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Bone;
|
class Bone;
|
||||||
|
|
||||||
/// Attachment that displays a texture region.
|
/// Attachment that displays a texture region.
|
||||||
class SP_API RegionAttachment : public Attachment, public HasRendererObject {
|
class SP_API RegionAttachment : public Attachment, public HasRendererObject {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class AtlasAttachmentLoader;
|
friend class AtlasAttachmentLoader;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RegionAttachment(const String& name);
|
explicit RegionAttachment(const String& name);
|
||||||
|
|
||||||
void updateOffset();
|
void updateOffset();
|
||||||
|
|
||||||
void setUVs(float u, float v, float u2, float v2, bool rotate);
|
void setUVs(float u, float v, float u2, float v2, bool rotate);
|
||||||
|
|
||||||
/// Transforms the attachment's four vertices to world coordinates.
|
/// Transforms the attachment's four vertices to world coordinates.
|
||||||
/// @param bone The parent bone.
|
/// @param bone The parent bone.
|
||||||
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
|
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + 8.
|
||||||
/// @param offset The worldVertices index to begin writing values.
|
/// @param offset The worldVertices index to begin writing values.
|
||||||
/// @param stride The number of worldVertices entries between the value pairs written.
|
/// @param stride The number of worldVertices entries between the value pairs written.
|
||||||
void computeWorldVertices(Bone& bone, float *worldVertices, size_t offset, size_t stride = 2);
|
void computeWorldVertices(Bone& bone, float *worldVertices, size_t offset, size_t stride = 2);
|
||||||
void computeWorldVertices(Bone& bone, Vector<float>& worldVertices, size_t offset, size_t stride = 2);
|
void computeWorldVertices(Bone& bone, Vector<float>& worldVertices, size_t offset, size_t stride = 2);
|
||||||
|
|
||||||
float getX();
|
float getX();
|
||||||
void setX(float inValue);
|
void setX(float inValue);
|
||||||
float getY();
|
float getY();
|
||||||
void setY(float inValue);
|
void setY(float inValue);
|
||||||
float getRotation();
|
float getRotation();
|
||||||
void setRotation(float inValue);
|
void setRotation(float inValue);
|
||||||
float getScaleX();
|
float getScaleX();
|
||||||
void setScaleX(float inValue);
|
void setScaleX(float inValue);
|
||||||
float getScaleY();
|
float getScaleY();
|
||||||
void setScaleY(float inValue);
|
void setScaleY(float inValue);
|
||||||
float getWidth();
|
float getWidth();
|
||||||
void setWidth(float inValue);
|
void setWidth(float inValue);
|
||||||
float getHeight();
|
float getHeight();
|
||||||
void setHeight(float inValue);
|
void setHeight(float inValue);
|
||||||
|
|
||||||
Color& getColor();
|
Color& getColor();
|
||||||
|
|
||||||
const String& getPath();
|
const String& getPath();
|
||||||
void setPath(const String& inValue);
|
void setPath(const String& inValue);
|
||||||
|
|
||||||
float getRegionOffsetX();
|
float getRegionOffsetX();
|
||||||
void setRegionOffsetX(float inValue);
|
void setRegionOffsetX(float inValue);
|
||||||
|
|
||||||
float getRegionOffsetY();
|
float getRegionOffsetY();
|
||||||
void setRegionOffsetY(float inValue);
|
void setRegionOffsetY(float inValue);
|
||||||
|
|
||||||
float getRegionWidth();
|
float getRegionWidth();
|
||||||
void setRegionWidth(float inValue);
|
void setRegionWidth(float inValue);
|
||||||
|
|
||||||
float getRegionHeight();
|
float getRegionHeight();
|
||||||
void setRegionHeight(float inValue);
|
void setRegionHeight(float inValue);
|
||||||
|
|
||||||
float getRegionOriginalWidth();
|
float getRegionOriginalWidth();
|
||||||
void setRegionOriginalWidth(float inValue);
|
void setRegionOriginalWidth(float inValue);
|
||||||
|
|
||||||
float getRegionOriginalHeight();
|
float getRegionOriginalHeight();
|
||||||
void setRegionOriginalHeight(float inValue);
|
void setRegionOriginalHeight(float inValue);
|
||||||
|
|
||||||
Vector<float>& getOffset();
|
Vector<float>& getOffset();
|
||||||
Vector<float>& getUVs();
|
Vector<float>& getUVs();
|
||||||
|
|
||||||
virtual Attachment* copy();
|
virtual Attachment* copy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int BLX;
|
static const int BLX;
|
||||||
static const int BLY;
|
static const int BLY;
|
||||||
static const int ULX;
|
static const int ULX;
|
||||||
static const int ULY;
|
static const int ULY;
|
||||||
static const int URX;
|
static const int URX;
|
||||||
static const int URY;
|
static const int URY;
|
||||||
static const int BRX;
|
static const int BRX;
|
||||||
static const int BRY;
|
static const int BRY;
|
||||||
|
|
||||||
float _x, _y, _rotation, _scaleX, _scaleY, _width, _height;
|
float _x, _y, _rotation, _scaleX, _scaleY, _width, _height;
|
||||||
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
float _regionOffsetX, _regionOffsetY, _regionWidth, _regionHeight, _regionOriginalWidth, _regionOriginalHeight;
|
||||||
Vector<float> _vertexOffset;
|
Vector<float> _vertexOffset;
|
||||||
Vector<float> _uvs;
|
Vector<float> _uvs;
|
||||||
String _path;
|
String _path;
|
||||||
float _regionU;
|
float _regionU;
|
||||||
float _regionV;
|
float _regionV;
|
||||||
float _regionU2;
|
float _regionU2;
|
||||||
float _regionV2;
|
float _regionV2;
|
||||||
Color _color;
|
Color _color;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_RegionAttachment_h */
|
#endif /* Spine_RegionAttachment_h */
|
||||||
|
|||||||
@ -33,38 +33,38 @@
|
|||||||
#include <spine/CurveTimeline.h>
|
#include <spine/CurveTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API RotateTimeline : public CurveTimeline {
|
class SP_API RotateTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class AnimationState;
|
friend class AnimationState;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int ENTRIES = 2;
|
static const int ENTRIES = 2;
|
||||||
|
|
||||||
explicit RotateTimeline(int frameCount);
|
explicit RotateTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
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, float time, float degrees);
|
void setFrame(int frameIndex, float time, float degrees);
|
||||||
|
|
||||||
int getBoneIndex();
|
int getBoneIndex();
|
||||||
void setBoneIndex(int inValue);
|
void setBoneIndex(int inValue);
|
||||||
|
|
||||||
Vector<float>& getFrames();
|
Vector<float>& getFrames();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int PREV_TIME = -2;
|
static const int PREV_TIME = -2;
|
||||||
static const int PREV_ROTATION = -1;
|
static const int PREV_ROTATION = -1;
|
||||||
static const int ROTATION = 1;
|
static const int ROTATION = 1;
|
||||||
|
|
||||||
int _boneIndex;
|
int _boneIndex;
|
||||||
Vector<float> _frames; // time, angle, ...
|
Vector<float> _frames; // time, angle, ...
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_RotateTimeline_h */
|
#endif /* Spine_RotateTimeline_h */
|
||||||
|
|||||||
@ -33,19 +33,19 @@
|
|||||||
#include <spine/TranslateTimeline.h>
|
#include <spine/TranslateTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API ScaleTimeline : public TranslateTimeline {
|
class SP_API ScaleTimeline : public TranslateTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ScaleTimeline(int frameCount);
|
explicit ScaleTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_ScaleTimeline_h */
|
#endif /* Spine_ScaleTimeline_h */
|
||||||
|
|||||||
@ -33,19 +33,19 @@
|
|||||||
#include <spine/TranslateTimeline.h>
|
#include <spine/TranslateTimeline.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SP_API ShearTimeline : public TranslateTimeline {
|
class SP_API ShearTimeline : public TranslateTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ShearTimeline(int frameCount);
|
explicit ShearTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_ShearTimeline_h */
|
#endif /* Spine_ShearTimeline_h */
|
||||||
|
|||||||
@ -135,7 +135,6 @@ public:
|
|||||||
/// See Skeleton::setSlotsToSetupPose()
|
/// See Skeleton::setSlotsToSetupPose()
|
||||||
/// Also, often AnimationState::apply(Skeleton&) is called before the next time the
|
/// Also, often AnimationState::apply(Skeleton&) is called before the next time the
|
||||||
/// skeleton is rendered to allow any attachment keys in the current animation(s) to hide or show attachments from the new skin.
|
/// skeleton is rendered to allow any attachment keys in the current animation(s) to hide or show attachments from the new skin.
|
||||||
///
|
|
||||||
/// @param newSkin May be NULL.
|
/// @param newSkin May be NULL.
|
||||||
void setSkin(Skin *newSkin);
|
void setSkin(Skin *newSkin);
|
||||||
|
|
||||||
|
|||||||
@ -37,95 +37,95 @@
|
|||||||
#include <spine/Color.h>
|
#include <spine/Color.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class SkeletonData;
|
class SkeletonData;
|
||||||
class Atlas;
|
class Atlas;
|
||||||
class AttachmentLoader;
|
class AttachmentLoader;
|
||||||
class LinkedMesh;
|
class LinkedMesh;
|
||||||
class Skin;
|
class Skin;
|
||||||
class Attachment;
|
class Attachment;
|
||||||
class VertexAttachment;
|
class VertexAttachment;
|
||||||
class Animation;
|
class Animation;
|
||||||
class CurveTimeline;
|
class CurveTimeline;
|
||||||
|
|
||||||
class SP_API SkeletonBinary : public SpineObject {
|
class SP_API SkeletonBinary : public SpineObject {
|
||||||
public:
|
public:
|
||||||
static const int BONE_ROTATE;
|
static const int BONE_ROTATE;
|
||||||
static const int BONE_TRANSLATE;
|
static const int BONE_TRANSLATE;
|
||||||
static const int BONE_SCALE;
|
static const int BONE_SCALE;
|
||||||
static const int BONE_SHEAR;
|
static const int BONE_SHEAR;
|
||||||
|
|
||||||
static const int SLOT_ATTACHMENT;
|
static const int SLOT_ATTACHMENT;
|
||||||
static const int SLOT_COLOR;
|
static const int SLOT_COLOR;
|
||||||
static const int SLOT_TWO_COLOR;
|
static const int SLOT_TWO_COLOR;
|
||||||
|
|
||||||
static const int PATH_POSITION;
|
static const int PATH_POSITION;
|
||||||
static const int PATH_SPACING;
|
static const int PATH_SPACING;
|
||||||
static const int PATH_MIX;
|
static const int PATH_MIX;
|
||||||
|
|
||||||
static const int CURVE_LINEAR;
|
static const int CURVE_LINEAR;
|
||||||
static const int CURVE_STEPPED;
|
static const int CURVE_STEPPED;
|
||||||
static const int CURVE_BEZIER;
|
static const int CURVE_BEZIER;
|
||||||
|
|
||||||
explicit SkeletonBinary(Atlas* atlasArray);
|
explicit SkeletonBinary(Atlas* atlasArray);
|
||||||
|
|
||||||
explicit SkeletonBinary(AttachmentLoader* attachmentLoader);
|
explicit SkeletonBinary(AttachmentLoader* attachmentLoader);
|
||||||
|
|
||||||
~SkeletonBinary();
|
~SkeletonBinary();
|
||||||
|
|
||||||
SkeletonData* readSkeletonData(const unsigned char* binary, int length);
|
SkeletonData* readSkeletonData(const unsigned char* binary, int length);
|
||||||
|
|
||||||
SkeletonData* readSkeletonDataFile(const String& path);
|
SkeletonData* readSkeletonDataFile(const String& path);
|
||||||
|
|
||||||
void setScale(float scale) { _scale = scale; }
|
void setScale(float scale) { _scale = scale; }
|
||||||
|
|
||||||
String& getError() { return _error; }
|
String& getError() { return _error; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct DataInput : public SpineObject {
|
struct DataInput : public SpineObject {
|
||||||
const unsigned char* cursor;
|
const unsigned char* cursor;
|
||||||
const unsigned char* end;
|
const unsigned char* end;
|
||||||
};
|
};
|
||||||
|
|
||||||
AttachmentLoader* _attachmentLoader;
|
AttachmentLoader* _attachmentLoader;
|
||||||
Vector<LinkedMesh*> _linkedMeshes;
|
Vector<LinkedMesh*> _linkedMeshes;
|
||||||
String _error;
|
String _error;
|
||||||
float _scale;
|
float _scale;
|
||||||
const bool _ownsLoader;
|
const bool _ownsLoader;
|
||||||
|
|
||||||
void setError(const char* value1, const char* value2);
|
void setError(const char* value1, const char* value2);
|
||||||
|
|
||||||
char* readString(DataInput* input);
|
char* readString(DataInput* input);
|
||||||
|
|
||||||
char* readStringRef(DataInput* input, SkeletonData* skeletonData);
|
char* readStringRef(DataInput* input, SkeletonData* skeletonData);
|
||||||
|
|
||||||
float readFloat(DataInput* input);
|
float readFloat(DataInput* input);
|
||||||
|
|
||||||
unsigned char readByte(DataInput* input);
|
unsigned char readByte(DataInput* input);
|
||||||
|
|
||||||
signed char readSByte(DataInput* input);
|
signed char readSByte(DataInput* input);
|
||||||
|
|
||||||
bool readBoolean(DataInput* input);
|
bool readBoolean(DataInput* input);
|
||||||
|
|
||||||
int readInt(DataInput* input);
|
int readInt(DataInput* input);
|
||||||
|
|
||||||
void readColor(DataInput* input, Color& color);
|
void readColor(DataInput* input, Color& color);
|
||||||
|
|
||||||
int readVarint(DataInput* input, bool optimizePositive);
|
int readVarint(DataInput* input, bool optimizePositive);
|
||||||
|
|
||||||
Skin* readSkin(DataInput* input, bool defaultSkin, SkeletonData* skeletonData, bool nonessential);
|
Skin* readSkin(DataInput* input, bool defaultSkin, SkeletonData* skeletonData, bool nonessential);
|
||||||
|
|
||||||
Attachment* readAttachment(DataInput* input, Skin* skin, int slotIndex, const String& attachmentName, SkeletonData* skeletonData, bool nonessential);
|
Attachment* readAttachment(DataInput* input, Skin* skin, int slotIndex, const String& attachmentName, SkeletonData* skeletonData, bool nonessential);
|
||||||
|
|
||||||
void readVertices(DataInput* input, VertexAttachment* attachment, int vertexCount);
|
void readVertices(DataInput* input, VertexAttachment* attachment, int vertexCount);
|
||||||
|
|
||||||
void readFloatArray(DataInput *input, int n, float scale, Vector<float>& array);
|
void readFloatArray(DataInput *input, int n, float scale, Vector<float>& array);
|
||||||
|
|
||||||
void readShortArray(DataInput *input, Vector<unsigned short>& array);
|
void readShortArray(DataInput *input, Vector<unsigned short>& array);
|
||||||
|
|
||||||
Animation* readAnimation(const String& name, DataInput* input, SkeletonData *skeletonData);
|
Animation* readAnimation(const String& name, DataInput* input, SkeletonData *skeletonData);
|
||||||
|
|
||||||
void readCurve(DataInput* input, int frameIndex, CurveTimeline* timeline);
|
void readCurve(DataInput* input, int frameIndex, CurveTimeline* timeline);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_SkeletonBinary_h */
|
#endif /* Spine_SkeletonBinary_h */
|
||||||
|
|||||||
@ -34,74 +34,71 @@
|
|||||||
#include <spine/SpineObject.h>
|
#include <spine/SpineObject.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
class BoundingBoxAttachment;
|
class BoundingBoxAttachment;
|
||||||
class Polygon;
|
class Polygon;
|
||||||
|
|
||||||
///
|
/// Collects each BoundingBoxAttachment that is visible and computes the world vertices for its polygon.
|
||||||
/// Collects each BoundingBoxAttachment that is visible and computes the world vertices for its polygon.
|
/// The polygon vertices are provided along with convenience methods for doing hit detection.
|
||||||
/// The polygon vertices are provided along with convenience methods for doing hit detection.
|
class SP_API SkeletonBounds : public SpineObject {
|
||||||
///
|
public:
|
||||||
class SP_API SkeletonBounds : public SpineObject {
|
SkeletonBounds();
|
||||||
public:
|
|
||||||
SkeletonBounds();
|
|
||||||
|
|
||||||
///
|
/// Clears any previous polygons, finds all visible bounding box attachments,
|
||||||
/// Clears any previous polygons, finds all visible bounding box attachments,
|
/// and computes the world vertices for each bounding box's polygon.
|
||||||
/// and computes the world vertices for each bounding box's polygon.
|
/// @param skeleton The skeleton.
|
||||||
/// @param skeleton The skeleton.
|
/// @param updateAabb
|
||||||
/// @param updateAabb
|
/// If true, the axis aligned bounding box containing all the polygons is computed.
|
||||||
/// If true, the axis aligned bounding box containing all the polygons is computed.
|
/// If false, the SkeletonBounds AABB methods will always return true.
|
||||||
/// If false, the SkeletonBounds AABB methods will always return true.
|
///
|
||||||
///
|
void update(Skeleton& skeleton, bool updateAabb);
|
||||||
void update(Skeleton& skeleton, bool updateAabb);
|
|
||||||
|
|
||||||
/// Returns true if the axis aligned bounding box contains the point.
|
/// Returns true if the axis aligned bounding box contains the point.
|
||||||
bool aabbcontainsPoint(float x, float y);
|
bool aabbcontainsPoint(float x, float y);
|
||||||
|
|
||||||
/// Returns true if the axis aligned bounding box intersects the line segment.
|
/// Returns true if the axis aligned bounding box intersects the line segment.
|
||||||
bool aabbintersectsSegment(float x1, float y1, float x2, float y2);
|
bool aabbintersectsSegment(float x1, float y1, float x2, float y2);
|
||||||
|
|
||||||
/// Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds.
|
/// Returns true if the axis aligned bounding box intersects the axis aligned bounding box of the specified bounds.
|
||||||
bool aabbIntersectsSkeleton(SkeletonBounds bounds);
|
bool aabbIntersectsSkeleton(SkeletonBounds bounds);
|
||||||
|
|
||||||
/// Returns true if the polygon contains the point.
|
/// Returns true if the polygon contains the point.
|
||||||
bool containsPoint(Polygon* polygon, float x, float y);
|
bool containsPoint(Polygon* polygon, float x, float y);
|
||||||
|
|
||||||
/// Returns the first bounding box attachment that contains the point, or NULL. When doing many checks, it is usually more
|
/// Returns the first bounding box attachment that contains the point, or NULL. When doing many checks, it is usually more
|
||||||
/// efficient to only call this method if {@link #aabbcontainsPoint(float, float)} returns true.
|
/// efficient to only call this method if {@link #aabbcontainsPoint(float, float)} returns true.
|
||||||
BoundingBoxAttachment* containsPoint(float x, float y);
|
BoundingBoxAttachment* containsPoint(float x, float y);
|
||||||
|
|
||||||
/// Returns the first bounding box attachment that contains the line segment, or NULL. When doing many checks, it is usually
|
/// Returns the first bounding box attachment that contains the line segment, or NULL. When doing many checks, it is usually
|
||||||
/// more efficient to only call this method if {@link #aabbintersectsSegment(float, float, float, float)} returns true.
|
/// more efficient to only call this method if {@link #aabbintersectsSegment(float, float, float, float)} returns true.
|
||||||
BoundingBoxAttachment* intersectsSegment(float x1, float y1, float x2, float y2);
|
BoundingBoxAttachment* intersectsSegment(float x1, float y1, float x2, float y2);
|
||||||
|
|
||||||
/// Returns true if the polygon contains the line segment.
|
/// Returns true if the polygon contains the line segment.
|
||||||
bool intersectsSegment(Polygon* polygon, float x1, float y1, float x2, float y2);
|
bool intersectsSegment(Polygon* polygon, float x1, float y1, float x2, float y2);
|
||||||
|
|
||||||
Polygon* getPolygon(BoundingBoxAttachment* attachment);
|
Polygon* getPolygon(BoundingBoxAttachment* attachment);
|
||||||
|
|
||||||
float getWidth();
|
float getWidth();
|
||||||
float getHeight();
|
float getHeight();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<Polygon*> _polygonPool;
|
Vector<Polygon*> _polygonPool;
|
||||||
Vector<BoundingBoxAttachment*> _boundingBoxes;
|
Vector<BoundingBoxAttachment*> _boundingBoxes;
|
||||||
Vector<Polygon*> _polygons;
|
Vector<Polygon*> _polygons;
|
||||||
float _minX, _minY, _maxX, _maxY;
|
float _minX, _minY, _maxX, _maxY;
|
||||||
|
|
||||||
void aabbCompute();
|
void aabbCompute();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Polygon : public SpineObject {
|
class Polygon : public SpineObject {
|
||||||
public:
|
public:
|
||||||
Vector<float> _vertices;
|
Vector<float> _vertices;
|
||||||
int _count;
|
int _count;
|
||||||
|
|
||||||
Polygon() : _count(0) {
|
Polygon() : _count(0) {
|
||||||
_vertices.ensureCapacity(16);
|
_vertices.ensureCapacity(16);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_SkeletonBounds_h */
|
#endif /* Spine_SkeletonBounds_h */
|
||||||
|
|||||||
@ -34,46 +34,46 @@
|
|||||||
#include <spine/Triangulator.h>
|
#include <spine/Triangulator.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Slot;
|
class Slot;
|
||||||
class ClippingAttachment;
|
class ClippingAttachment;
|
||||||
|
|
||||||
class SP_API SkeletonClipping : public SpineObject {
|
class SP_API SkeletonClipping : public SpineObject {
|
||||||
public:
|
public:
|
||||||
SkeletonClipping();
|
SkeletonClipping();
|
||||||
|
|
||||||
size_t 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(float* vertices, unsigned short* triangles, size_t trianglesLength, float* uvs, size_t stride);
|
void clipTriangles(float* vertices, unsigned short* triangles, size_t trianglesLength, float* uvs, size_t stride);
|
||||||
|
|
||||||
void clipTriangles(Vector<float>& vertices, Vector<unsigned short>& triangles, Vector<float>& uvs, size_t stride);
|
void clipTriangles(Vector<float>& vertices, Vector<unsigned short>& triangles, Vector<float>& uvs, size_t stride);
|
||||||
|
|
||||||
bool isClipping();
|
bool isClipping();
|
||||||
|
|
||||||
Vector<float>& getClippedVertices();
|
Vector<float>& getClippedVertices();
|
||||||
Vector<unsigned short>& getClippedTriangles();
|
Vector<unsigned short>& getClippedTriangles();
|
||||||
Vector<float>& getClippedUVs();
|
Vector<float>& getClippedUVs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Triangulator _triangulator;
|
Triangulator _triangulator;
|
||||||
Vector<float> _clippingPolygon;
|
Vector<float> _clippingPolygon;
|
||||||
Vector<float> _clipOutput;
|
Vector<float> _clipOutput;
|
||||||
Vector<float> _clippedVertices;
|
Vector<float> _clippedVertices;
|
||||||
Vector<unsigned short> _clippedTriangles;
|
Vector<unsigned short> _clippedTriangles;
|
||||||
Vector<float> _clippedUVs;
|
Vector<float> _clippedUVs;
|
||||||
Vector<float> _scratch;
|
Vector<float> _scratch;
|
||||||
ClippingAttachment* _clipAttachment;
|
ClippingAttachment* _clipAttachment;
|
||||||
Vector< Vector<float>* > *_clippingPolygons;
|
Vector< Vector<float>* > *_clippingPolygons;
|
||||||
|
|
||||||
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
|
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
|
||||||
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
|
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
|
||||||
bool clip(float x1, float y1, float x2, float y2, float x3, float y3, Vector<float>* clippingArea, Vector<float>* output);
|
bool clip(float x1, float y1, float x2, float y2, float x3, float y3, Vector<float>* clippingArea, Vector<float>* output);
|
||||||
|
|
||||||
static void makeClockwise(Vector<float>& polygon);
|
static void makeClockwise(Vector<float>& polygon);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_SkeletonClipping_h */
|
#endif /* Spine_SkeletonClipping_h */
|
||||||
|
|||||||
@ -112,7 +112,6 @@ public:
|
|||||||
|
|
||||||
/// The skeleton's default skin.
|
/// The skeleton's default skin.
|
||||||
/// By default this skin contains all attachments that were not in a skin in Spine.
|
/// By default this skin contains all attachments that were not in a skin in Spine.
|
||||||
///
|
|
||||||
/// @return May be NULL.
|
/// @return May be NULL.
|
||||||
Skin *getDefaultSkin();
|
Skin *getDefaultSkin();
|
||||||
|
|
||||||
|
|||||||
@ -34,18 +34,18 @@
|
|||||||
#include <spine/SpineString.h>
|
#include <spine/SpineString.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class AtlasPage;
|
class AtlasPage;
|
||||||
|
|
||||||
class SP_API TextureLoader : public SpineObject {
|
class SP_API TextureLoader : public SpineObject {
|
||||||
public:
|
public:
|
||||||
TextureLoader();
|
TextureLoader();
|
||||||
|
|
||||||
virtual ~TextureLoader();
|
virtual ~TextureLoader();
|
||||||
|
|
||||||
virtual void load(AtlasPage& page, const String& path) = 0;
|
virtual void load(AtlasPage& page, const String& path) = 0;
|
||||||
|
|
||||||
virtual void unload(void* texture) = 0;
|
virtual void unload(void* texture) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TextureLoader_h */
|
#endif /* Spine_TextureLoader_h */
|
||||||
|
|||||||
@ -55,14 +55,13 @@ public:
|
|||||||
/// @param time The time within the animation. Most timelines find the key before and the key after this time so they can interpolate between the keys.
|
/// @param time The time within the animation. Most timelines find the key before and the key after this time so they can interpolate between the keys.
|
||||||
/// @param pEvents If any events are fired, they are added to this array. Can be NULL to ignore firing events or if the timeline does not fire events. May be NULL.
|
/// @param pEvents If any events are fired, they are added to this array. Can be NULL to ignore firing events or if the timeline does not fire events. May be NULL.
|
||||||
/// @param alpha alpha 0 applies the current or setup pose value (depending on pose parameter). 1 applies the timeline
|
/// @param alpha alpha 0 applies the current or setup pose value (depending on pose parameter). 1 applies the timeline
|
||||||
/// value. Between 0 and 1 applies a value between the current or setup pose and the timeline value. By adjusting
|
/// value. Between 0 and 1 applies a value between the current or setup pose and the timeline value. By adjusting alpha over
|
||||||
/// alpha over time, an animation can be mixed in or out. alpha can also be useful to
|
/// time, an animation can be mixed in or out. alpha can also be useful to apply animations on top of each other (layered).
|
||||||
/// apply animations on top of each other (layered).
|
|
||||||
/// @param blend Controls how mixing is applied when alpha is than 1.
|
/// @param blend Controls how mixing is applied when alpha is than 1.
|
||||||
/// @param direction Indicates whether the timeline is mixing in or out. Used by timelines which perform instant transitions such as DrawOrderTimeline and AttachmentTimeline.
|
/// @param direction Indicates whether the timeline is mixing in or out. Used by timelines which perform instant transitions such as DrawOrderTimeline and AttachmentTimeline.
|
||||||
virtual void
|
virtual void
|
||||||
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha, MixBlend blend,
|
||||||
MixDirection direction) = 0;
|
MixDirection direction) = 0;
|
||||||
|
|
||||||
virtual int getPropertyId() = 0;
|
virtual int getPropertyId() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -35,63 +35,63 @@
|
|||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class TransformConstraintData;
|
class TransformConstraintData;
|
||||||
class Skeleton;
|
class Skeleton;
|
||||||
class Bone;
|
class Bone;
|
||||||
|
|
||||||
class SP_API TransformConstraint : public Updatable {
|
class SP_API TransformConstraint : public Updatable {
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class TransformConstraintTimeline;
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransformConstraint(TransformConstraintData& data, Skeleton& skeleton);
|
TransformConstraint(TransformConstraintData& data, Skeleton& skeleton);
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
|
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
|
||||||
virtual int getOrder();
|
virtual int getOrder();
|
||||||
|
|
||||||
TransformConstraintData& getData();
|
TransformConstraintData& getData();
|
||||||
|
|
||||||
Vector<Bone*>& getBones();
|
Vector<Bone*>& getBones();
|
||||||
|
|
||||||
Bone* getTarget();
|
Bone* getTarget();
|
||||||
void setTarget(Bone* inValue);
|
void setTarget(Bone* inValue);
|
||||||
|
|
||||||
float getRotateMix();
|
float getRotateMix();
|
||||||
void setRotateMix(float inValue);
|
void setRotateMix(float inValue);
|
||||||
|
|
||||||
float getTranslateMix();
|
float getTranslateMix();
|
||||||
void setTranslateMix(float inValue);
|
void setTranslateMix(float inValue);
|
||||||
|
|
||||||
float getScaleMix();
|
float getScaleMix();
|
||||||
void setScaleMix(float inValue);
|
void setScaleMix(float inValue);
|
||||||
|
|
||||||
float getShearMix();
|
float getShearMix();
|
||||||
void setShearMix(float inValue);
|
void setShearMix(float inValue);
|
||||||
|
|
||||||
bool isActive();
|
bool isActive();
|
||||||
|
|
||||||
void setActive(bool inValue);
|
void setActive(bool inValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TransformConstraintData& _data;
|
TransformConstraintData& _data;
|
||||||
Vector<Bone*> _bones;
|
Vector<Bone*> _bones;
|
||||||
Bone* _target;
|
Bone* _target;
|
||||||
float _rotateMix, _translateMix, _scaleMix, _shearMix;
|
float _rotateMix, _translateMix, _scaleMix, _shearMix;
|
||||||
bool _active;
|
bool _active;
|
||||||
|
|
||||||
void applyAbsoluteWorld();
|
void applyAbsoluteWorld();
|
||||||
|
|
||||||
void applyRelativeWorld();
|
void applyRelativeWorld();
|
||||||
|
|
||||||
void applyAbsoluteLocal();
|
void applyAbsoluteLocal();
|
||||||
|
|
||||||
void applyRelativeLocal();
|
void applyRelativeLocal();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TransformConstraint_h */
|
#endif /* Spine_TransformConstraint_h */
|
||||||
|
|||||||
@ -36,43 +36,43 @@
|
|||||||
#include <spine/ConstraintData.h>
|
#include <spine/ConstraintData.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class BoneData;
|
class BoneData;
|
||||||
|
|
||||||
class SP_API TransformConstraintData : public ConstraintData {
|
class SP_API TransformConstraintData : public ConstraintData {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
friend class TransformConstraint;
|
friend class TransformConstraint;
|
||||||
friend class Skeleton;
|
friend class Skeleton;
|
||||||
friend class TransformConstraintTimeline;
|
friend class TransformConstraintTimeline;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TransformConstraintData(const String& name);
|
explicit TransformConstraintData(const String& name);
|
||||||
|
|
||||||
Vector<BoneData*>& getBones();
|
Vector<BoneData*>& getBones();
|
||||||
BoneData* getTarget();
|
BoneData* getTarget();
|
||||||
float getRotateMix();
|
float getRotateMix();
|
||||||
float getTranslateMix();
|
float getTranslateMix();
|
||||||
float getScaleMix();
|
float getScaleMix();
|
||||||
float getShearMix();
|
float getShearMix();
|
||||||
|
|
||||||
float getOffsetRotation();
|
float getOffsetRotation();
|
||||||
float getOffsetX();
|
float getOffsetX();
|
||||||
float getOffsetY();
|
float getOffsetY();
|
||||||
float getOffsetScaleX();
|
float getOffsetScaleX();
|
||||||
float getOffsetScaleY();
|
float getOffsetScaleY();
|
||||||
float getOffsetShearY();
|
float getOffsetShearY();
|
||||||
|
|
||||||
bool isRelative();
|
bool isRelative();
|
||||||
bool isLocal();
|
bool isLocal();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<BoneData*> _bones;
|
Vector<BoneData*> _bones;
|
||||||
BoneData* _target;
|
BoneData* _target;
|
||||||
float _rotateMix, _translateMix, _scaleMix, _shearMix;
|
float _rotateMix, _translateMix, _scaleMix, _shearMix;
|
||||||
float _offsetRotation, _offsetX, _offsetY, _offsetScaleX, _offsetScaleY, _offsetShearY;
|
float _offsetRotation, _offsetX, _offsetY, _offsetScaleX, _offsetScaleY, _offsetShearY;
|
||||||
bool _relative, _local;
|
bool _relative, _local;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TransformConstraintData_h */
|
#endif /* Spine_TransformConstraintData_h */
|
||||||
|
|||||||
@ -34,24 +34,24 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class SP_API TransformConstraintTimeline : public CurveTimeline {
|
class SP_API TransformConstraintTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
explicit TransformConstraintTimeline(int frameCount);
|
explicit TransformConstraintTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
virtual int getPropertyId();
|
virtual int getPropertyId();
|
||||||
|
|
||||||
void setFrame(size_t 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;
|
static const int PREV_TIME;
|
||||||
static const int PREV_ROTATE;
|
static const int PREV_ROTATE;
|
||||||
static const int PREV_TRANSLATE;
|
static const int PREV_TRANSLATE;
|
||||||
@ -62,9 +62,9 @@ namespace spine {
|
|||||||
static const int SCALE;
|
static const int SCALE;
|
||||||
static const int SHEAR;
|
static const int SHEAR;
|
||||||
|
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
int _transformConstraintIndex;
|
int _transformConstraintIndex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TransformConstraintTimeline_h */
|
#endif /* Spine_TransformConstraintTimeline_h */
|
||||||
|
|||||||
@ -31,13 +31,13 @@
|
|||||||
#define Spine_TransformMode_h
|
#define Spine_TransformMode_h
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
enum TransformMode {
|
enum TransformMode {
|
||||||
TransformMode_Normal = 0,
|
TransformMode_Normal = 0,
|
||||||
TransformMode_OnlyTranslation,
|
TransformMode_OnlyTranslation,
|
||||||
TransformMode_NoRotationOrReflection,
|
TransformMode_NoRotationOrReflection,
|
||||||
TransformMode_NoScale,
|
TransformMode_NoScale,
|
||||||
TransformMode_NoScaleOrReflection
|
TransformMode_NoScaleOrReflection
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TransformMode_h */
|
#endif /* Spine_TransformMode_h */
|
||||||
|
|||||||
@ -37,36 +37,36 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class SP_API TranslateTimeline : public CurveTimeline {
|
class SP_API TranslateTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
explicit TranslateTimeline(int frameCount);
|
explicit TranslateTimeline(int frameCount);
|
||||||
|
|
||||||
virtual ~TranslateTimeline();
|
virtual ~TranslateTimeline();
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
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, float time, float x, float y);
|
void setFrame(int frameIndex, float time, float x, float y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const int PREV_TIME;
|
static const int PREV_TIME;
|
||||||
static const int PREV_X;
|
static const int PREV_X;
|
||||||
static const int PREV_Y;
|
static const int PREV_Y;
|
||||||
static const int X;
|
static const int X;
|
||||||
static const int Y;
|
static const int Y;
|
||||||
|
|
||||||
Vector<float> _frames;
|
Vector<float> _frames;
|
||||||
int _boneIndex;
|
int _boneIndex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TranslateTimeline_h */
|
#endif /* Spine_TranslateTimeline_h */
|
||||||
|
|||||||
@ -34,28 +34,28 @@
|
|||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
|
|
||||||
class SP_API TwoColorTimeline : public CurveTimeline {
|
class SP_API TwoColorTimeline : public CurveTimeline {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int ENTRIES;
|
static const int ENTRIES;
|
||||||
|
|
||||||
explicit TwoColorTimeline(int frameCount);
|
explicit TwoColorTimeline(int frameCount);
|
||||||
|
|
||||||
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
virtual void apply(Skeleton& skeleton, float lastTime, float time, Vector<Event*>* pEvents, float alpha, MixBlend blend, MixDirection direction);
|
||||||
|
|
||||||
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, float time, float r, float g, float b, float a, float r2, float g2, float b2);
|
void setFrame(int frameIndex, float time, float r, float g, float b, float a, float r2, float g2, float b2);
|
||||||
|
|
||||||
int getSlotIndex();
|
int getSlotIndex();
|
||||||
void setSlotIndex(int inValue);
|
void setSlotIndex(int inValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int PREV_TIME;
|
static const int PREV_TIME;
|
||||||
static const int PREV_R;
|
static const int PREV_R;
|
||||||
static const int PREV_G;
|
static const int PREV_G;
|
||||||
@ -72,9 +72,9 @@ namespace spine {
|
|||||||
static const int G2;
|
static const int G2;
|
||||||
static const int B2;
|
static const int B2;
|
||||||
|
|
||||||
Vector<float> _frames; // time, r, g, b, a, r2, g2, b2, ...
|
Vector<float> _frames; // time, r, g, b, a, r2, g2, b2, ...
|
||||||
int _slotIndex;
|
int _slotIndex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_TwoColorTimeline_h */
|
#endif /* Spine_TwoColorTimeline_h */
|
||||||
|
|||||||
@ -35,59 +35,59 @@
|
|||||||
#include <spine/Vector.h>
|
#include <spine/Vector.h>
|
||||||
|
|
||||||
namespace spine {
|
namespace spine {
|
||||||
class Slot;
|
class Slot;
|
||||||
|
|
||||||
/// An attachment with vertices that are transformed by one or more bones and can be deformed by a slot's vertices.
|
/// An attachment with vertices that are transformed by one or more bones and can be deformed by a slot's vertices.
|
||||||
class SP_API VertexAttachment : public Attachment {
|
class SP_API VertexAttachment : public Attachment {
|
||||||
friend class SkeletonBinary;
|
friend class SkeletonBinary;
|
||||||
friend class SkeletonJson;
|
friend class SkeletonJson;
|
||||||
friend class DeformTimeline;
|
friend class DeformTimeline;
|
||||||
|
|
||||||
RTTI_DECL
|
RTTI_DECL
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit VertexAttachment(const String& name);
|
explicit VertexAttachment(const String& name);
|
||||||
|
|
||||||
virtual ~VertexAttachment();
|
virtual ~VertexAttachment();
|
||||||
|
|
||||||
void computeWorldVertices(Slot& slot, float* worldVertices);
|
void computeWorldVertices(Slot& slot, float* worldVertices);
|
||||||
void computeWorldVertices(Slot& slot, Vector<float>& worldVertices);
|
void computeWorldVertices(Slot& slot, Vector<float>& worldVertices);
|
||||||
|
|
||||||
/// Transforms local vertices to world coordinates.
|
/// Transforms local vertices to world coordinates.
|
||||||
/// @param start The index of the first Vertices value to transform. Each vertex has 2 values, x and y.
|
/// @param start The index of the first Vertices value to transform. Each vertex has 2 values, x and y.
|
||||||
/// @param count The number of world vertex values to output. Must be less than or equal to WorldVerticesLength - start.
|
/// @param count The number of world vertex values to output. Must be less than or equal to WorldVerticesLength - start.
|
||||||
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + count.
|
/// @param worldVertices The output world vertices. Must have a length greater than or equal to offset + count.
|
||||||
/// @param offset The worldVertices index to begin writing values.
|
/// @param offset The worldVertices index to begin writing values.
|
||||||
/// @param stride The number of worldVertices entries between the value pairs written.
|
/// @param stride The number of worldVertices entries between the value pairs written.
|
||||||
void computeWorldVertices(Slot& slot, size_t start, size_t count, float* worldVertices, size_t offset, size_t stride = 2);
|
void computeWorldVertices(Slot& slot, size_t start, size_t count, float* worldVertices, size_t offset, size_t stride = 2);
|
||||||
void computeWorldVertices(Slot& slot, size_t start, size_t count, Vector<float>& worldVertices, size_t offset, size_t stride = 2);
|
void computeWorldVertices(Slot& slot, size_t start, size_t count, Vector<float>& worldVertices, size_t offset, size_t stride = 2);
|
||||||
|
|
||||||
/// Gets a unique ID for this attachment.
|
/// Gets a unique ID for this attachment.
|
||||||
int getId();
|
int getId();
|
||||||
|
|
||||||
Vector<size_t>& getBones();
|
Vector<size_t>& getBones();
|
||||||
|
|
||||||
Vector<float>& getVertices();
|
Vector<float>& getVertices();
|
||||||
|
|
||||||
size_t getWorldVerticesLength();
|
size_t getWorldVerticesLength();
|
||||||
void setWorldVerticesLength(size_t inValue);
|
void setWorldVerticesLength(size_t inValue);
|
||||||
|
|
||||||
VertexAttachment* getDeformAttachment();
|
VertexAttachment* getDeformAttachment();
|
||||||
void setDeformAttachment(VertexAttachment* attachment);
|
void setDeformAttachment(VertexAttachment* attachment);
|
||||||
|
|
||||||
void copyTo(VertexAttachment* other);
|
void copyTo(VertexAttachment* other);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Vector<size_t> _bones;
|
Vector<size_t> _bones;
|
||||||
Vector<float> _vertices;
|
Vector<float> _vertices;
|
||||||
size_t _worldVerticesLength;
|
size_t _worldVerticesLength;
|
||||||
VertexAttachment* _deformAttachment;
|
VertexAttachment* _deformAttachment;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int _id;
|
const int _id;
|
||||||
|
|
||||||
static int getNextID();
|
static int getNextID();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Spine_VertexAttachment_h */
|
#endif /* Spine_VertexAttachment_h */
|
||||||
|
|||||||
@ -52,7 +52,8 @@ Animation::~Animation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Animation::apply(Skeleton &skeleton, float lastTime, float time, bool loop, Vector<Event *> *pEvents, float alpha,
|
void Animation::apply(Skeleton &skeleton, float lastTime, float time, bool loop, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction
|
||||||
|
) {
|
||||||
if (loop && _duration != 0) {
|
if (loop && _duration != 0) {
|
||||||
time = MathUtil::fmod(time, _duration);
|
time = MathUtil::fmod(time, _duration);
|
||||||
if (lastTime > 0) {
|
if (lastTime > 0) {
|
||||||
@ -91,15 +92,12 @@ int Animation::binarySearch(Vector<float> &values, float target, int step) {
|
|||||||
|
|
||||||
int current = (int) (static_cast<uint32_t>(high) >> 1);
|
int current = (int) (static_cast<uint32_t>(high) >> 1);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (values[(current + 1) * step] <= target) {
|
if (values[(current + 1) * step] <= target)
|
||||||
low = current + 1;
|
low = current + 1;
|
||||||
} else {
|
else
|
||||||
high = current;
|
high = current;
|
||||||
}
|
|
||||||
|
|
||||||
if (low == high) {
|
if (low == high) return (low + 1) * step;
|
||||||
return (low + 1) * step;
|
|
||||||
}
|
|
||||||
|
|
||||||
current = (int) (static_cast<uint32_t>(low + high) >> 1);
|
current = (int) (static_cast<uint32_t>(low + high) >> 1);
|
||||||
}
|
}
|
||||||
@ -109,21 +107,16 @@ int Animation::binarySearch(Vector<float> &values, float target) {
|
|||||||
int low = 0;
|
int low = 0;
|
||||||
int size = (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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int current = (int) (static_cast<uint32_t>(high) >> 1);
|
int current = (int) (static_cast<uint32_t>(high) >> 1);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (values[(current + 1)] <= target) {
|
if (values[(current + 1)] <= target)
|
||||||
low = current + 1;
|
low = current + 1;
|
||||||
} else {
|
else
|
||||||
high = current;
|
high = current;
|
||||||
}
|
|
||||||
|
|
||||||
if (low == high) {
|
if (low == high) return (low + 1);
|
||||||
return (low + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
current = (int) (static_cast<uint32_t>(low + high) >> 1);
|
current = (int) (static_cast<uint32_t>(low + high) >> 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,11 +54,11 @@ void dummyOnAnimationEventFunc(AnimationState *state, spine::EventType type, Tra
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry::TrackEntry() : _animation(NULL), _next(NULL), _mixingFrom(NULL), _mixingTo(0), _trackIndex(0), _loop(false), _holdPrevious(false),
|
TrackEntry::TrackEntry() : _animation(NULL), _next(NULL), _mixingFrom(NULL), _mixingTo(0), _trackIndex(0), _loop(false), _holdPrevious(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), _interruptAlpha(0), _totalAlpha(0), _mixBlend(MixBlend_Replace),
|
_mixDuration(0), _interruptAlpha(0), _totalAlpha(0), _mixBlend(MixBlend_Replace),
|
||||||
_listener(dummyOnAnimationEventFunc), _listenerObject(NULL) {
|
_listener(dummyOnAnimationEventFunc), _listenerObject(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry::~TrackEntry() { }
|
TrackEntry::~TrackEntry() { }
|
||||||
@ -105,10 +105,7 @@ void TrackEntry::setAnimationLast(float inValue) {
|
|||||||
float TrackEntry::getAnimationTime() {
|
float TrackEntry::getAnimationTime() {
|
||||||
if (_loop) {
|
if (_loop) {
|
||||||
float duration = _animationEnd - _animationStart;
|
float duration = _animationEnd - _animationStart;
|
||||||
if (duration == 0) {
|
if (duration == 0) return _animationStart;
|
||||||
return _animationStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MathUtil::fmod(_trackTime, duration) + _animationStart;
|
return MathUtil::fmod(_trackTime, duration) + _animationStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,8 +199,8 @@ EventQueueEntry EventQueue::newEventQueueEntry(EventType eventType, TrackEntry *
|
|||||||
}
|
}
|
||||||
|
|
||||||
EventQueue::EventQueue(AnimationState &state, Pool<TrackEntry> &trackEntryPool) : _state(state),
|
EventQueue::EventQueue(AnimationState &state, Pool<TrackEntry> &trackEntryPool) : _state(state),
|
||||||
_trackEntryPool(trackEntryPool),
|
_trackEntryPool(trackEntryPool),
|
||||||
_drainDisabled(false) {
|
_drainDisabled(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
EventQueue::~EventQueue() {
|
EventQueue::~EventQueue() {
|
||||||
@ -251,36 +248,35 @@ void EventQueue::drain() {
|
|||||||
TrackEntry *trackEntry = queueEntry->_entry;
|
TrackEntry *trackEntry = queueEntry->_entry;
|
||||||
|
|
||||||
switch (queueEntry->_type) {
|
switch (queueEntry->_type) {
|
||||||
case EventType_Start:
|
case EventType_Start:
|
||||||
case EventType_Interrupt:
|
case EventType_Interrupt:
|
||||||
case EventType_Complete:
|
case EventType_Complete:
|
||||||
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
if(!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
if(!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
break;
|
break;
|
||||||
case EventType_End:
|
case EventType_End:
|
||||||
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
if (!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
if (!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, NULL);
|
||||||
/* Yes, we want to fall through here */
|
/* Fall through. */
|
||||||
case EventType_Dispose:
|
case EventType_Dispose:
|
||||||
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
|
else trackEntry->_listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
|
if (!state._listenerObject) state._listener(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
|
else state._listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
||||||
|
|
||||||
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, EventType_Dispose, trackEntry, NULL);
|
trackEntry->reset();
|
||||||
else trackEntry->_listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
_trackEntryPool.free(trackEntry);
|
||||||
if (!state._listenerObject) state._listener(&state, EventType_Dispose, trackEntry, NULL);
|
break;
|
||||||
else state._listenerObject->callback(&state, EventType_Dispose, trackEntry, NULL);
|
case EventType_Event:
|
||||||
|
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
trackEntry->reset();
|
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
_trackEntryPool.free(trackEntry);
|
if (!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
break;
|
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
||||||
case EventType_Event:
|
break;
|
||||||
if (!trackEntry->_listenerObject) trackEntry->_listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
|
||||||
else trackEntry->_listenerObject->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
|
||||||
if (!state._listenerObject) state._listener(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
|
||||||
else state._listenerObject->callback(&state, queueEntry->_type, trackEntry, queueEntry->_event);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_eventQueueEntries.clear();
|
_eventQueueEntries.clear();
|
||||||
@ -420,17 +416,13 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
size_t timelineCount = current._animation->_timelines.size();
|
size_t timelineCount = current._animation->_timelines.size();
|
||||||
Vector<Timeline *> &timelines = current._animation->_timelines;
|
Vector<Timeline *> &timelines = current._animation->_timelines;
|
||||||
if ((i == 0 && mix == 1) || blend == MixBlend_Add) {
|
if ((i == 0 && mix == 1) || blend == MixBlend_Add) {
|
||||||
for (size_t 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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Vector<int> &timelineMode = current._timelineMode;
|
Vector<int> &timelineMode = current._timelineMode;
|
||||||
|
|
||||||
bool firstFrame = current._timelinesRotation.size() == 0;
|
bool firstFrame = current._timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) current._timelinesRotation.setSize(timelines.size() << 1, 0);
|
||||||
current._timelinesRotation.setSize(timelines.size() << 1, 0);
|
|
||||||
}
|
|
||||||
Vector<float> &timelinesRotation = current._timelinesRotation;
|
Vector<float> &timelinesRotation = current._timelinesRotation;
|
||||||
|
|
||||||
for (size_t ii = 0; ii < timelineCount; ++ii) {
|
for (size_t ii = 0; ii < timelineCount; ++ii) {
|
||||||
@ -440,16 +432,12 @@ bool AnimationState::apply(Skeleton &skeleton) {
|
|||||||
MixBlend timelineBlend = (timelineMode[ii] & (NotLast - 1)) == Subsequent ? blend : MixBlend_Setup;
|
MixBlend timelineBlend = (timelineMode[ii] & (NotLast - 1)) == Subsequent ? blend : MixBlend_Setup;
|
||||||
|
|
||||||
RotateTimeline *rotateTimeline = NULL;
|
RotateTimeline *rotateTimeline = NULL;
|
||||||
if (timeline->getRTTI().isExactly(RotateTimeline::rtti)) {
|
if (timeline->getRTTI().isExactly(RotateTimeline::rtti)) rotateTimeline = static_cast<RotateTimeline *>(timeline);
|
||||||
rotateTimeline = static_cast<RotateTimeline *>(timeline);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rotateTimeline != NULL) {
|
if (rotateTimeline != NULL)
|
||||||
applyRotateTimeline(rotateTimeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1,
|
applyRotateTimeline(rotateTimeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ii << 1, firstFrame);
|
||||||
firstFrame);
|
else
|
||||||
} else {
|
|
||||||
timeline->apply(skeleton, animationLast, animationTime, &_events, mix, timelineBlend, MixDirection_In);
|
timeline->apply(skeleton, animationLast, animationTime, &_events, mix, timelineBlend, MixDirection_In);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,23 +454,18 @@ 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 (size_t i = 0, n = _tracks.size(); i < n; ++i) {
|
for (size_t i = 0, n = _tracks.size(); i < n; ++i)
|
||||||
clearTrack(i);
|
clearTrack(i);
|
||||||
}
|
|
||||||
_tracks.clear();
|
_tracks.clear();
|
||||||
_queue->_drainDisabled = oldDrainDisabled;
|
_queue->_drainDisabled = oldDrainDisabled;
|
||||||
_queue->drain();
|
_queue->drain();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState::clearTrack(size_t trackIndex) {
|
void AnimationState::clearTrack(size_t trackIndex) {
|
||||||
if (trackIndex >= _tracks.size()) {
|
if (trackIndex >= _tracks.size()) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackEntry *current = _tracks[trackIndex];
|
TrackEntry *current = _tracks[trackIndex];
|
||||||
if (current == NULL) {
|
if (current == NULL) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_queue->end(current);
|
_queue->end(current);
|
||||||
|
|
||||||
@ -491,9 +474,7 @@ void AnimationState::clearTrack(size_t trackIndex) {
|
|||||||
TrackEntry *entry = current;
|
TrackEntry *entry = current;
|
||||||
while (true) {
|
while (true) {
|
||||||
TrackEntry *from = entry->_mixingFrom;
|
TrackEntry *from = entry->_mixingFrom;
|
||||||
if (from == NULL) {
|
if (from == NULL) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_queue->end(from);
|
_queue->end(from);
|
||||||
entry->_mixingFrom = NULL;
|
entry->_mixingFrom = NULL;
|
||||||
@ -509,7 +490,6 @@ void AnimationState::clearTrack(size_t trackIndex) {
|
|||||||
TrackEntry *AnimationState::setAnimation(size_t trackIndex, const String &animationName, bool loop) {
|
TrackEntry *AnimationState::setAnimation(size_t trackIndex, const String &animationName, bool loop) {
|
||||||
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
||||||
assert(animation != NULL);
|
assert(animation != NULL);
|
||||||
|
|
||||||
return setAnimation(trackIndex, animation, loop);
|
return setAnimation(trackIndex, animation, loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,7 +522,6 @@ TrackEntry *AnimationState::setAnimation(size_t trackIndex, Animation *animation
|
|||||||
TrackEntry *AnimationState::addAnimation(size_t trackIndex, const String &animationName, bool loop, float delay) {
|
TrackEntry *AnimationState::addAnimation(size_t trackIndex, const String &animationName, bool loop, float delay) {
|
||||||
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
Animation *animation = _data->_skeletonData->findAnimation(animationName);
|
||||||
assert(animation != NULL);
|
assert(animation != NULL);
|
||||||
|
|
||||||
return addAnimation(trackIndex, animation, loop, delay);
|
return addAnimation(trackIndex, animation, loop, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,9 +530,8 @@ TrackEntry *AnimationState::addAnimation(size_t trackIndex, Animation *animation
|
|||||||
|
|
||||||
TrackEntry *last = expandToIndex(trackIndex);
|
TrackEntry *last = expandToIndex(trackIndex);
|
||||||
if (last != NULL) {
|
if (last != NULL) {
|
||||||
while (last->_next != NULL) {
|
while (last->_next != NULL)
|
||||||
last = last->_next;
|
last = last->_next;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *entry = newTrackEntry(trackIndex, animation, loop, last);
|
TrackEntry *entry = newTrackEntry(trackIndex, animation, loop, last);
|
||||||
@ -657,10 +635,9 @@ Animation *AnimationState::getEmptyAnimation() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleton &skeleton, float time, float alpha,
|
void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleton &skeleton, float time, float alpha,
|
||||||
MixBlend blend, Vector<float> &timelinesRotation, size_t i, bool firstFrame) {
|
MixBlend blend, Vector<float> &timelinesRotation, size_t i, bool firstFrame
|
||||||
if (firstFrame) {
|
) {
|
||||||
timelinesRotation[i] = 0;
|
if (firstFrame) timelinesRotation[i] = 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (alpha == 1) {
|
if (alpha == 1) {
|
||||||
rotateTimeline->apply(skeleton, 0, time, NULL, 1, blend, MixDirection_In);
|
rotateTimeline->apply(skeleton, 0, time, NULL, 1, blend, MixDirection_In);
|
||||||
@ -673,13 +650,13 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto
|
|||||||
float r1, r2;
|
float r1, r2;
|
||||||
if (time < frames[0]) {
|
if (time < frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
bone->_rotation = bone->_data._rotation;
|
bone->_rotation = bone->_data._rotation;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
r1 = bone->_rotation;
|
r1 = bone->_rotation;
|
||||||
r2 = bone->_data._rotation;
|
r2 = bone->_data._rotation;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
r1 = blend == MixBlend_Setup ? bone->_data._rotation : bone->_rotation;
|
r1 = blend == MixBlend_Setup ? bone->_data._rotation : bone->_rotation;
|
||||||
@ -692,9 +669,7 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto
|
|||||||
float prevRotation = frames[frame + RotateTimeline::PREV_ROTATION];
|
float prevRotation = frames[frame + RotateTimeline::PREV_ROTATION];
|
||||||
float frameTime = frames[frame];
|
float frameTime = frames[frame];
|
||||||
float percent = rotateTimeline->getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame +
|
float percent = rotateTimeline->getCurvePercent((frame >> 1) - 1, 1 - (time - frameTime) / (frames[frame +
|
||||||
RotateTimeline::PREV_TIME] -
|
RotateTimeline::PREV_TIME] - frameTime));
|
||||||
frameTime));
|
|
||||||
|
|
||||||
r2 = frames[frame + RotateTimeline::ROTATION] - prevRotation;
|
r2 = frames[frame + RotateTimeline::ROTATION] - prevRotation;
|
||||||
r2 -= (16384 - (int) (16384.499999999996 - r2 / 360)) * 360;
|
r2 -= (16384 - (int) (16384.499999999996 - r2 / 360)) * 360;
|
||||||
r2 = prevRotation + r2 * percent + bone->_data._rotation;
|
r2 = prevRotation + r2 * percent + bone->_data._rotation;
|
||||||
@ -721,9 +696,7 @@ void AnimationState::applyRotateTimeline(RotateTimeline *rotateTimeline, Skeleto
|
|||||||
// Detect cross at 0 (not 180).
|
// Detect cross at 0 (not 180).
|
||||||
if (MathUtil::sign(lastDiff) != MathUtil::sign(diff) && MathUtil::abs(lastDiff) <= 90) {
|
if (MathUtil::sign(lastDiff) != MathUtil::sign(diff) && MathUtil::abs(lastDiff) <= 90) {
|
||||||
// A cross after a 360 rotation is a loop.
|
// A cross after a 360 rotation is a loop.
|
||||||
if (MathUtil::abs(lastTotal) > 180) {
|
if (MathUtil::abs(lastTotal) > 180) lastTotal += 360 * MathUtil::sign(lastTotal);
|
||||||
lastTotal += 360 * MathUtil::sign(lastTotal);
|
|
||||||
}
|
|
||||||
dir = current;
|
dir = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,9 +742,7 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) {
|
|||||||
|
|
||||||
float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBlend blend) {
|
float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBlend blend) {
|
||||||
TrackEntry *from = to->_mixingFrom;
|
TrackEntry *from = to->_mixingFrom;
|
||||||
if (from->_mixingFrom != NULL) {
|
if (from->_mixingFrom != NULL) applyMixingFrom(from, skeleton, blend);
|
||||||
applyMixingFrom(from, skeleton, blend);
|
|
||||||
}
|
|
||||||
|
|
||||||
float mix;
|
float mix;
|
||||||
if (to->_mixDuration == 0) {
|
if (to->_mixDuration == 0) {
|
||||||
@ -801,9 +772,7 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
Vector<TrackEntry *> &timelineHoldMix = from->_timelineHoldMix;
|
Vector<TrackEntry *> &timelineHoldMix = from->_timelineHoldMix;
|
||||||
|
|
||||||
bool firstFrame = from->_timelinesRotation.size() == 0;
|
bool firstFrame = from->_timelinesRotation.size() == 0;
|
||||||
if (firstFrame) {
|
if (firstFrame) from->_timelinesRotation.setSize(timelines.size() << 1, 0);
|
||||||
from->_timelinesRotation.setSize(timelines.size() << 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<float> &timelinesRotation = from->_timelinesRotation;
|
Vector<float> &timelinesRotation = from->_timelinesRotation;
|
||||||
|
|
||||||
@ -839,8 +808,7 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
}
|
}
|
||||||
from->_totalAlpha += alpha;
|
from->_totalAlpha += alpha;
|
||||||
if ((timeline->getRTTI().isExactly(RotateTimeline::rtti))) {
|
if ((timeline->getRTTI().isExactly(RotateTimeline::rtti))) {
|
||||||
applyRotateTimeline((RotateTimeline*)timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1,
|
applyRotateTimeline((RotateTimeline*)timeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, i << 1, firstFrame);
|
||||||
firstFrame);
|
|
||||||
} else {
|
} else {
|
||||||
if (timelineBlend == MixBlend_Setup) {
|
if (timelineBlend == MixBlend_Setup) {
|
||||||
if (timeline->getRTTI().isExactly(AttachmentTimeline::rtti)) {
|
if (timeline->getRTTI().isExactly(AttachmentTimeline::rtti)) {
|
||||||
@ -849,8 +817,7 @@ float AnimationState::applyMixingFrom(TrackEntry *to, Skeleton &skeleton, MixBle
|
|||||||
if (drawOrder) direction = MixDirection_In;
|
if (drawOrder) direction = MixDirection_In;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeline->apply(skeleton, animationLast, animationTime, eventBuffer, alpha, timelineBlend,
|
timeline->apply(skeleton, animationLast, animationTime, eventBuffer, alpha, timelineBlend, direction);
|
||||||
direction);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -875,13 +842,8 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
|
|||||||
size_t i = 0, n = _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) break;
|
||||||
break;
|
if (e->_time > animationEnd) continue; // Discard events outside animation start/end.
|
||||||
}
|
|
||||||
if (e->_time > animationEnd) {
|
|
||||||
// Discard events outside animation start/end.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_queue->event(entry, e);
|
_queue->event(entry, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,10 +858,7 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
|
|||||||
// Queue events after complete.
|
// Queue events after complete.
|
||||||
for (; i < n; ++i) {
|
for (; i < n; ++i) {
|
||||||
Event *e = _events[i];
|
Event *e = _events[i];
|
||||||
if (e->_time < animationStart) {
|
if (e->_time < animationStart) continue; // Discard events outside animation start/end.
|
||||||
// Discard events outside animation start/end.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_queue->event(entry, _events[i]);
|
_queue->event(entry, _events[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -909,9 +868,7 @@ void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrup
|
|||||||
_tracks[index] = current;
|
_tracks[index] = current;
|
||||||
|
|
||||||
if (from != NULL) {
|
if (from != NULL) {
|
||||||
if (interrupt) {
|
if (interrupt) _queue->interrupt(from);
|
||||||
_queue->interrupt(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
current->_mixingFrom = from;
|
current->_mixingFrom = from;
|
||||||
from->_mixingTo = current;
|
from->_mixingTo = current;
|
||||||
@ -929,14 +886,9 @@ void AnimationState::setCurrent(size_t index, TrackEntry *current, bool interrup
|
|||||||
}
|
}
|
||||||
|
|
||||||
TrackEntry *AnimationState::expandToIndex(size_t index) {
|
TrackEntry *AnimationState::expandToIndex(size_t index) {
|
||||||
if (index < _tracks.size()) {
|
if (index < _tracks.size()) return _tracks[index];
|
||||||
return _tracks[index];
|
while (index >= _tracks.size())
|
||||||
}
|
|
||||||
|
|
||||||
while (index >= _tracks.size()) {
|
|
||||||
_tracks.add(NULL);
|
_tracks.add(NULL);
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -989,7 +941,6 @@ void AnimationState::animationsChanged() {
|
|||||||
|
|
||||||
for (size_t i = 0, n = _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) continue;
|
if (!entry) continue;
|
||||||
|
|
||||||
while (entry->_mixingFrom != NULL)
|
while (entry->_mixingFrom != NULL)
|
||||||
@ -1069,21 +1020,17 @@ void AnimationState::computeNotLast(TrackEntry *entry) {
|
|||||||
for (size_t i = 0; i < timelinesCount; i++) {
|
for (size_t i = 0; i < timelinesCount; i++) {
|
||||||
if (timelines[i]->getRTTI().isExactly(AttachmentTimeline::rtti)) {
|
if (timelines[i]->getRTTI().isExactly(AttachmentTimeline::rtti)) {
|
||||||
AttachmentTimeline *timeline = static_cast<AttachmentTimeline *>(timelines[i]);
|
AttachmentTimeline *timeline = static_cast<AttachmentTimeline *>(timelines[i]);
|
||||||
if (!_propertyIDs.contains(timeline->getSlotIndex())) {
|
if (!_propertyIDs.contains(timeline->getSlotIndex()))
|
||||||
_propertyIDs.add(timeline->getSlotIndex());
|
_propertyIDs.add(timeline->getSlotIndex());
|
||||||
} else {
|
else
|
||||||
timelineMode[i] |= NotLast;
|
timelineMode[i] |= NotLast;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnimationState::hasTimeline(TrackEntry* entry, int inId) {
|
bool AnimationState::hasTimeline(TrackEntry* entry, int inId) {
|
||||||
Vector<Timeline *> &timelines = entry->_animation->_timelines;
|
Vector<Timeline *> &timelines = entry->_animation->_timelines;
|
||||||
for (size_t i = 0, n = 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,12 +89,8 @@ void Atlas::flipV() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AtlasRegion *Atlas::findRegion(const String &name) {
|
AtlasRegion *Atlas::findRegion(const String &name) {
|
||||||
for (size_t i = 0, n = _regions.size(); i < n; ++i) {
|
for (size_t i = 0, n = _regions.size(); i < n; ++i)
|
||||||
if (_regions[i]->name == name) {
|
if (_regions[i]->name == name) return _regions[i];
|
||||||
return _regions[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +99,9 @@ Vector<AtlasPage*> &Atlas::getPages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Atlas::load(const char *begin, int length, const char *dir, bool createTexture) {
|
void Atlas::load(const char *begin, int length, const char *dir, bool createTexture) {
|
||||||
static const char *formatNames[] = {"", "Alpha", "Intensity", "LuminanceAlpha", "RGB565", "RGBA4444", "RGB888",
|
static const char *formatNames[] = {"", "Alpha", "Intensity", "LuminanceAlpha", "RGB565", "RGBA4444", "RGB888", "RGBA8888"};
|
||||||
"RGBA8888"};
|
static const char *textureFilterNames[] = {"", "Nearest", "Linear", "MipMap", "MipMapNearestNearest", "MipMapLinearNearest",
|
||||||
static const char *textureFilterNames[] = {"", "Nearest", "Linear", "MipMap", "MipMapNearestNearest",
|
"MipMapNearestLinear", "MipMapLinearLinear"};
|
||||||
"MipMapLinearNearest",
|
|
||||||
"MipMapNearestLinear", "MipMapLinearLinear"};
|
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
const char *end = begin + length;
|
const char *end = begin + length;
|
||||||
@ -125,9 +119,7 @@ void Atlas::load(const char *begin, int length, const char *dir, bool createText
|
|||||||
char *name = mallocString(&str);
|
char *name = mallocString(&str);
|
||||||
char *path = SpineExtension::calloc<char>(dirLength + needsSlash + strlen(name) + 1, __FILE__, __LINE__);
|
char *path = SpineExtension::calloc<char>(dirLength + needsSlash + strlen(name) + 1, __FILE__, __LINE__);
|
||||||
memcpy(path, dir, dirLength);
|
memcpy(path, dir, dirLength);
|
||||||
if (needsSlash) {
|
if (needsSlash) path[dirLength] = '/';
|
||||||
path[dirLength] = '/';
|
|
||||||
}
|
|
||||||
strcpy(path + dirLength + needsSlash, name);
|
strcpy(path + dirLength + needsSlash, name);
|
||||||
|
|
||||||
page = new(__FILE__, __LINE__) AtlasPage(String(name, true));
|
page = new(__FILE__, __LINE__) AtlasPage(String(name, true));
|
||||||
@ -163,15 +155,11 @@ void Atlas::load(const char *begin, int length, const char *dir, bool createText
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (createTexture)
|
if (createTexture) {
|
||||||
{
|
|
||||||
if (_textureLoader) _textureLoader->load(*page, String(path));
|
if (_textureLoader) _textureLoader->load(*page, String(path));
|
||||||
SpineExtension::free(path, __FILE__, __LINE__);
|
SpineExtension::free(path, __FILE__, __LINE__);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
|
||||||
page->texturePath = String(path, true);
|
page->texturePath = String(path, true);
|
||||||
}
|
|
||||||
|
|
||||||
_pages.add(page);
|
_pages.add(page);
|
||||||
} else {
|
} else {
|
||||||
@ -181,13 +169,9 @@ void Atlas::load(const char *begin, int length, const char *dir, bool createText
|
|||||||
region->name = String(mallocString(&str), true);
|
region->name = String(mallocString(&str), true);
|
||||||
|
|
||||||
readValue(&begin, end, &str);
|
readValue(&begin, end, &str);
|
||||||
if (equals(&str, "true")) {
|
if (equals(&str, "true")) region->degrees = 90;
|
||||||
region->degrees = 90;
|
else if (equals(&str, "false")) region->degrees = 0;
|
||||||
} else if (equals(&str, "false")) {
|
else region->degrees = toInt(&str);
|
||||||
region->degrees = 0;
|
|
||||||
} else {
|
|
||||||
region->degrees = toInt(&str);
|
|
||||||
}
|
|
||||||
region->rotate = region->degrees == 90;
|
region->rotate = region->degrees == 90;
|
||||||
|
|
||||||
readTuple(&begin, end, tuple);
|
readTuple(&begin, end, tuple);
|
||||||
@ -251,41 +235,32 @@ void Atlas::load(const char *begin, int length, const char *dir, bool createText
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Atlas::trim(Str *str) {
|
void Atlas::trim(Str *str) {
|
||||||
while (isspace((unsigned char) *str->begin) && str->begin < str->end) {
|
while (isspace((unsigned char) *str->begin) && str->begin < str->end)
|
||||||
(str->begin)++;
|
(str->begin)++;
|
||||||
}
|
|
||||||
|
|
||||||
if (str->begin == str->end) {
|
if (str->begin == str->end) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
str->end--;
|
str->end--;
|
||||||
|
|
||||||
while (((unsigned char)*str->end == '\r') && str->end >= str->begin) {
|
while (((unsigned char)*str->end == '\r') && str->end >= str->begin)
|
||||||
str->end--;
|
str->end--;
|
||||||
}
|
|
||||||
|
|
||||||
str->end++;
|
str->end++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Atlas::readLine(const char **begin, const char *end, Str *str) {
|
int Atlas::readLine(const char **begin, const char *end, Str *str) {
|
||||||
if (*begin == end) {
|
if (*begin == end) return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
str->begin = *begin;
|
str->begin = *begin;
|
||||||
|
|
||||||
/* Find next delimiter. */
|
/* Find next delimiter. */
|
||||||
while (*begin != end && **begin != '\n') {
|
while (*begin != end && **begin != '\n')
|
||||||
(*begin)++;
|
(*begin)++;
|
||||||
}
|
|
||||||
|
|
||||||
str->end = *begin;
|
str->end = *begin;
|
||||||
trim(str);
|
trim(str);
|
||||||
|
|
||||||
if (*begin != end) {
|
if (*begin != end) (*begin)++;
|
||||||
(*begin)++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -294,13 +269,9 @@ int Atlas::beginPast(Str *str, char c) {
|
|||||||
const char *begin = str->begin;
|
const char *begin = str->begin;
|
||||||
while (true) {
|
while (true) {
|
||||||
char lastSkippedChar = *begin;
|
char lastSkippedChar = *begin;
|
||||||
if (begin == str->end) {
|
if (begin == str->end) return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
begin++;
|
begin++;
|
||||||
if (lastSkippedChar == c) {
|
if (lastSkippedChar == c) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
str->begin = begin;
|
str->begin = begin;
|
||||||
return 1;
|
return 1;
|
||||||
@ -308,10 +279,7 @@ int Atlas::beginPast(Str *str, char c) {
|
|||||||
|
|
||||||
int Atlas::readValue(const char **begin, const char *end, Str *str) {
|
int Atlas::readValue(const char **begin, const char *end, Str *str) {
|
||||||
readLine(begin, end, str);
|
readLine(begin, end, str);
|
||||||
if (!beginPast(str, ':')) {
|
if (!beginPast(str, ':')) return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
trim(str);
|
trim(str);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -320,16 +288,11 @@ int Atlas::readTuple(const char **begin, const char *end, Str tuple[]) {
|
|||||||
int i;
|
int i;
|
||||||
Str str = {NULL, NULL};
|
Str str = {NULL, NULL};
|
||||||
readLine(begin, end, &str);
|
readLine(begin, end, &str);
|
||||||
if (!beginPast(&str, ':')) {
|
if (!beginPast(&str, ':')) return 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
tuple[i].begin = str.begin;
|
tuple[i].begin = str.begin;
|
||||||
if (!beginPast(&str, ',')) {
|
if (!beginPast(&str, ',')) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tuple[i].end = str.begin - 2;
|
tuple[i].end = str.begin - 2;
|
||||||
trim(&tuple[i]);
|
trim(&tuple[i]);
|
||||||
}
|
}
|
||||||
@ -352,11 +315,8 @@ char *Atlas::mallocString(Str *str) {
|
|||||||
int Atlas::indexOf(const char **array, int count, Str *str) {
|
int Atlas::indexOf(const char **array, int count, Str *str) {
|
||||||
int length = (int) (str->end - str->begin);
|
int length = (int) (str->end - str->begin);
|
||||||
int i;
|
int i;
|
||||||
for (i = count - 1; i >= 0; i--) {
|
for (i = count - 1; i >= 0; i--)
|
||||||
if (strncmp(array[i], str->begin, length) == 0) {
|
if (strncmp(array[i], str->begin, length) == 0) return i;
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ 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);
|
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) {
|
||||||
|
|||||||
@ -58,7 +58,8 @@ 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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(alpha);
|
SP_UNUSED(alpha);
|
||||||
|
|||||||
@ -51,32 +51,33 @@ bool Bone::isYDown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bone::Bone(BoneData &data, Skeleton &skeleton, Bone *parent) : Updatable(),
|
Bone::Bone(BoneData &data, Skeleton &skeleton, Bone *parent) : Updatable(),
|
||||||
_data(data),
|
_data(data),
|
||||||
_skeleton(skeleton),
|
_skeleton(skeleton),
|
||||||
_parent(parent),
|
_parent(parent),
|
||||||
_x(0),
|
_x(0),
|
||||||
_y(0),
|
_y(0),
|
||||||
_rotation(0),
|
_rotation(0),
|
||||||
_scaleX(0),
|
_scaleX(0),
|
||||||
_scaleY(0),
|
_scaleY(0),
|
||||||
_shearX(0),
|
_shearX(0),
|
||||||
_shearY(0),
|
_shearY(0),
|
||||||
_ax(0),
|
_ax(0),
|
||||||
_ay(0),
|
_ay(0),
|
||||||
_arotation(0),
|
_arotation(0),
|
||||||
_ascaleX(0),
|
_ascaleX(0),
|
||||||
_ascaleY(0),
|
_ascaleY(0),
|
||||||
_ashearX(0),
|
_ashearX(0),
|
||||||
_ashearY(0),
|
_ashearY(0),
|
||||||
_appliedValid(false),
|
_appliedValid(false),
|
||||||
_a(1),
|
_a(1),
|
||||||
_b(0),
|
_b(0),
|
||||||
_worldX(0),
|
_worldX(0),
|
||||||
_c(0),
|
_c(0),
|
||||||
_d(1),
|
_d(1),
|
||||||
_worldY(0),
|
_worldY(0),
|
||||||
_sorted(false),
|
_sorted(false),
|
||||||
_active(false) {
|
_active(false)
|
||||||
|
{
|
||||||
setToSetupPose();
|
setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +89,7 @@ void Bone::updateWorldTransform() {
|
|||||||
updateWorldTransform(_x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY);
|
updateWorldTransform(_x, _y, _rotation, _scaleX, _scaleY, _shearX, _shearY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void Bone::updateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) {
|
||||||
Bone::updateWorldTransform(float x, float y, float rotation, float scaleX, float scaleY, float shearX, float shearY) {
|
|
||||||
float cosine, sine;
|
float cosine, sine;
|
||||||
float pa, pb, pc, pd;
|
float pa, pb, pc, pd;
|
||||||
Bone *parent = _parent;
|
Bone *parent = _parent;
|
||||||
@ -125,80 +125,80 @@ Bone::updateWorldTransform(float x, float y, float rotation, float scaleX, float
|
|||||||
_worldY = pc * x + pd * y + parent->_worldY;
|
_worldY = pc * x + pd * y + parent->_worldY;
|
||||||
|
|
||||||
switch (_data.getTransformMode()) {
|
switch (_data.getTransformMode()) {
|
||||||
case TransformMode_Normal: {
|
case TransformMode_Normal: {
|
||||||
float rotationY = rotation + 90 + shearY;
|
float rotationY = rotation + 90 + shearY;
|
||||||
float la = MathUtil::cosDeg(rotation + shearX) * scaleX;
|
float la = MathUtil::cosDeg(rotation + shearX) * scaleX;
|
||||||
float lb = MathUtil::cosDeg(rotationY) * scaleY;
|
float lb = MathUtil::cosDeg(rotationY) * scaleY;
|
||||||
float lc = MathUtil::sinDeg(rotation + shearX) * scaleX;
|
float lc = MathUtil::sinDeg(rotation + shearX) * scaleX;
|
||||||
float ld = MathUtil::sinDeg(rotationY) * scaleY;
|
float ld = MathUtil::sinDeg(rotationY) * scaleY;
|
||||||
_a = pa * la + pb * lc;
|
_a = pa * la + pb * lc;
|
||||||
_b = pa * lb + pb * ld;
|
_b = pa * lb + pb * ld;
|
||||||
_c = pc * la + pd * lc;
|
_c = pc * la + pd * lc;
|
||||||
_d = pc * lb + pd * ld;
|
_d = pc * lb + pd * ld;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case TransformMode_OnlyTranslation: {
|
case TransformMode_OnlyTranslation: {
|
||||||
float rotationY = rotation + 90 + shearY;
|
float rotationY = rotation + 90 + shearY;
|
||||||
_a = MathUtil::cosDeg(rotation + shearX) * scaleX;
|
_a = MathUtil::cosDeg(rotation + shearX) * scaleX;
|
||||||
_b = MathUtil::cosDeg(rotationY) * scaleY;
|
_b = MathUtil::cosDeg(rotationY) * scaleY;
|
||||||
_c = MathUtil::sinDeg(rotation + shearX) * scaleX;
|
_c = MathUtil::sinDeg(rotation + shearX) * scaleX;
|
||||||
_d = MathUtil::sinDeg(rotationY) * scaleY;
|
_d = MathUtil::sinDeg(rotationY) * scaleY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TransformMode_NoRotationOrReflection: {
|
case TransformMode_NoRotationOrReflection: {
|
||||||
float s = pa * pa + pc * pc;
|
float s = pa * pa + pc * pc;
|
||||||
float prx, rx, ry, la, lb, lc, ld;
|
float prx, rx, ry, la, lb, lc, ld;
|
||||||
if (s > 0.0001f) {
|
if (s > 0.0001f) {
|
||||||
s = MathUtil::abs(pa * pd - pb * pc) / s;
|
s = MathUtil::abs(pa * pd - pb * pc) / s;
|
||||||
pb = pc * s;
|
pb = pc * s;
|
||||||
pd = pa * s;
|
pd = pa * s;
|
||||||
prx = MathUtil::atan2(pc, pa) * MathUtil::Rad_Deg;
|
prx = MathUtil::atan2(pc, pa) * MathUtil::Rad_Deg;
|
||||||
} else {
|
} else {
|
||||||
pa = 0;
|
pa = 0;
|
||||||
pc = 0;
|
pc = 0;
|
||||||
prx = 90 - MathUtil::atan2(pd, pb) * MathUtil::Rad_Deg;
|
prx = 90 - MathUtil::atan2(pd, pb) * MathUtil::Rad_Deg;
|
||||||
}
|
|
||||||
rx = rotation + shearX - prx;
|
|
||||||
ry = rotation + shearY - prx + 90;
|
|
||||||
la = MathUtil::cosDeg(rx) * scaleX;
|
|
||||||
lb = MathUtil::cosDeg(ry) * scaleY;
|
|
||||||
lc = MathUtil::sinDeg(rx) * scaleX;
|
|
||||||
ld = MathUtil::sinDeg(ry) * scaleY;
|
|
||||||
_a = pa * la - pb * lc;
|
|
||||||
_b = pa * lb - pb * ld;
|
|
||||||
_c = pc * la + pd * lc;
|
|
||||||
_d = pc * lb + pd * ld;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TransformMode_NoScale:
|
|
||||||
case TransformMode_NoScaleOrReflection: {
|
|
||||||
float za, zc, s;
|
|
||||||
float r, zb, zd, la, lb, lc, ld;
|
|
||||||
cosine = MathUtil::cosDeg(rotation);
|
|
||||||
sine = MathUtil::sinDeg(rotation);
|
|
||||||
za = (pa * cosine + pb * sine) / _skeleton.getScaleX();
|
|
||||||
zc = (pc * cosine + pd * sine) / _skeleton.getScaleY();
|
|
||||||
s = MathUtil::sqrt(za * za + zc * zc);
|
|
||||||
if (s > 0.00001f) s = 1 / s;
|
|
||||||
za *= s;
|
|
||||||
zc *= s;
|
|
||||||
s = MathUtil::sqrt(za * za + zc * zc);
|
|
||||||
if (_data.getTransformMode() == TransformMode_NoScale
|
|
||||||
&& (pa * pd - pb * pc < 0) != (_skeleton.getScaleX() < 0 != _skeleton.getScaleY() < 0))
|
|
||||||
s = -s;
|
|
||||||
r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za);
|
|
||||||
zb = MathUtil::cos(r) * s;
|
|
||||||
zd = MathUtil::sin(r) * s;
|
|
||||||
la = MathUtil::cosDeg(shearX) * scaleX;
|
|
||||||
lb = MathUtil::cosDeg(90 + shearY) * scaleY;
|
|
||||||
lc = MathUtil::sinDeg(shearX) * scaleX;
|
|
||||||
ld = MathUtil::sinDeg(90 + shearY) * scaleY;
|
|
||||||
_a = za * la + zb * lc;
|
|
||||||
_b = za * lb + zb * ld;
|
|
||||||
_c = zc * la + zd * lc;
|
|
||||||
_d = zc * lb + zd * ld;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
rx = rotation + shearX - prx;
|
||||||
|
ry = rotation + shearY - prx + 90;
|
||||||
|
la = MathUtil::cosDeg(rx) * scaleX;
|
||||||
|
lb = MathUtil::cosDeg(ry) * scaleY;
|
||||||
|
lc = MathUtil::sinDeg(rx) * scaleX;
|
||||||
|
ld = MathUtil::sinDeg(ry) * scaleY;
|
||||||
|
_a = pa * la - pb * lc;
|
||||||
|
_b = pa * lb - pb * ld;
|
||||||
|
_c = pc * la + pd * lc;
|
||||||
|
_d = pc * lb + pd * ld;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TransformMode_NoScale:
|
||||||
|
case TransformMode_NoScaleOrReflection: {
|
||||||
|
float za, zc, s;
|
||||||
|
float r, zb, zd, la, lb, lc, ld;
|
||||||
|
cosine = MathUtil::cosDeg(rotation);
|
||||||
|
sine = MathUtil::sinDeg(rotation);
|
||||||
|
za = (pa * cosine + pb * sine) / _skeleton.getScaleX();
|
||||||
|
zc = (pc * cosine + pd * sine) / _skeleton.getScaleY();
|
||||||
|
s = MathUtil::sqrt(za * za + zc * zc);
|
||||||
|
if (s > 0.00001f) s = 1 / s;
|
||||||
|
za *= s;
|
||||||
|
zc *= s;
|
||||||
|
s = MathUtil::sqrt(za * za + zc * zc);
|
||||||
|
if (_data.getTransformMode() == TransformMode_NoScale
|
||||||
|
&& (pa * pd - pb * pc < 0) != (_skeleton.getScaleX() < 0 != _skeleton.getScaleY() < 0))
|
||||||
|
s = -s;
|
||||||
|
r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za);
|
||||||
|
zb = MathUtil::cos(r) * s;
|
||||||
|
zd = MathUtil::sin(r) * s;
|
||||||
|
la = MathUtil::cosDeg(shearX) * scaleX;
|
||||||
|
lb = MathUtil::cosDeg(90 + shearY) * scaleY;
|
||||||
|
lc = MathUtil::sinDeg(shearX) * scaleX;
|
||||||
|
ld = MathUtil::sinDeg(90 + shearY) * scaleY;
|
||||||
|
_a = za * la + zb * lc;
|
||||||
|
_b = za * lb + zb * ld;
|
||||||
|
_c = zc * la + zd * lc;
|
||||||
|
_d = zc * lb + zd * ld;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_a *= _skeleton.getScaleX();
|
_a *= _skeleton.getScaleX();
|
||||||
_b *= _skeleton.getScaleX();
|
_b *= _skeleton.getScaleX();
|
||||||
|
|||||||
@ -62,7 +62,8 @@ 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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
@ -72,15 +73,15 @@ void ColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
if (!slot._bone.isActive()) return;
|
if (!slot._bone.isActive()) return;
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
slot._color.set(slot._data._color);
|
slot._color.set(slot._data._color);
|
||||||
return;
|
return;
|
||||||
case MixBlend_First: {
|
case MixBlend_First: {
|
||||||
Color &color = slot._color, setup = slot._data._color;
|
Color &color = slot._color, setup = slot._data._color;
|
||||||
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha,
|
color.add((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha,
|
||||||
(setup.a - color.a) * alpha);
|
(setup.a - color.a) * alpha);
|
||||||
}
|
}
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -101,8 +102,7 @@ void ColorTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
b = _frames[frame + PREV_B];
|
b = _frames[frame + PREV_B];
|
||||||
a = _frames[frame + PREV_A];
|
a = _frames[frame + PREV_A];
|
||||||
float frameTime = _frames[frame];
|
float frameTime = _frames[frame];
|
||||||
float percent = getCurvePercent(frame / ENTRIES - 1,
|
float percent = getCurvePercent(frame / ENTRIES - 1, 1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
||||||
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
|
||||||
|
|
||||||
r += (_frames[frame + R] - r) * percent;
|
r += (_frames[frame + R] - r) * percent;
|
||||||
g += (_frames[frame + G] - g) * percent;
|
g += (_frames[frame + G] - g) * percent;
|
||||||
|
|||||||
@ -113,7 +113,6 @@ float CurveTimeline::getCurvePercent(size_t frameIndex, float percent) {
|
|||||||
prevX = _curves[i - 2];
|
prevX = _curves[i - 2];
|
||||||
prevY = _curves[i - 1];
|
prevY = _curves[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return prevY + (_curves[i + 1] - prevY) * (percent - prevX) / (x - prevX);
|
return prevY + (_curves[i + 1] - prevY) * (percent - prevX) / (x - prevX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,8 @@ 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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
@ -143,40 +144,40 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup: {
|
case MixBlend_Setup: {
|
||||||
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
||||||
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 (size_t i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float setup = setupVertices[i];
|
float setup = setupVertices[i];
|
||||||
deform[i] = setup + (lastVertices[i] - setup) * alpha;
|
deform[i] = setup + (lastVertices[i] - setup) * alpha;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Weighted deform offsets, with alpha.
|
|
||||||
for (size_t i = 0; i < vertexCount; i++)
|
|
||||||
deform[i] = lastVertices[i] * alpha;
|
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
}
|
// Weighted deform offsets, with alpha.
|
||||||
case MixBlend_First:
|
|
||||||
case MixBlend_Replace:
|
|
||||||
// Vertex positions or deform offsets, with alpha.
|
|
||||||
for (size_t i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
deform[i] += (lastVertices[i] - deform[i]) * alpha;
|
deform[i] = lastVertices[i] * alpha;
|
||||||
break;
|
}
|
||||||
case MixBlend_Add:
|
break;
|
||||||
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
}
|
||||||
if (vertexAttachment->getBones().size() == 0) {
|
case MixBlend_First:
|
||||||
// Unweighted vertex positions, no alpha.
|
case MixBlend_Replace:
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
// Vertex positions or deform offsets, with alpha.
|
||||||
for (size_t i = 0; i < vertexCount; i++)
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
deform[i] += (lastVertices[i] - setupVertices[i]) * alpha;
|
deform[i] += (lastVertices[i] - deform[i]) * alpha;
|
||||||
} else {
|
break;
|
||||||
// Weighted deform offsets, alpha.
|
case MixBlend_Add:
|
||||||
for (size_t i = 0; i < vertexCount; i++)
|
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
||||||
deform[i] += lastVertices[i] * alpha;
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
}
|
// Unweighted vertex positions, no alpha.
|
||||||
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
|
deform[i] += (lastVertices[i] - setupVertices[i]) * alpha;
|
||||||
|
} else {
|
||||||
|
// Weighted deform offsets, alpha.
|
||||||
|
for (size_t i = 0; i < vertexCount; i++)
|
||||||
|
deform[i] += lastVertices[i] * alpha;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -184,8 +185,8 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
|
|
||||||
// Interpolate between the previous frame and the current frame.
|
// Interpolate between the previous frame and the current frame.
|
||||||
int frame = Animation::binarySearch(frames, time);
|
int frame = Animation::binarySearch(frames, time);
|
||||||
Vector<float> &prevVertices = frameVertices[frame - 1];
|
Vector<float> &prevVertices = frameVertices[frame - 1];
|
||||||
Vector<float> &nextVertices = frameVertices[frame];
|
Vector<float> &nextVertices = frameVertices[frame];
|
||||||
float frameTime = frames[frame];
|
float frameTime = frames[frame];
|
||||||
float percent = getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
|
float percent = getCurvePercent(frame - 1, 1 - (time - frameTime) / (frames[frame - 1] - frameTime));
|
||||||
|
|
||||||
@ -215,55 +216,54 @@ void DeformTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vecto
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup: {
|
case MixBlend_Setup: {
|
||||||
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
||||||
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 (size_t 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];
|
||||||
deform[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
deform[i] = setup + (prev + (nextVertices[i] - prev) * percent - setup) * alpha;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Weighted deform offsets, with alpha.
|
|
||||||
for (size_t i = 0; i < vertexCount; i++) {
|
|
||||||
float prev = prevVertices[i];
|
|
||||||
deform[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
}
|
// Weighted deform offsets, with alpha.
|
||||||
case MixBlend_First:
|
|
||||||
case MixBlend_Replace:
|
|
||||||
// Vertex positions or deform offsets, with alpha.
|
|
||||||
for (size_t i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
deform[i] += (prev + (nextVertices[i] - prev) * percent - deform[i]) * alpha;
|
deform[i] = (prev + (nextVertices[i] - prev) * percent) * alpha;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case MixBlend_Add:
|
break;
|
||||||
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
}
|
||||||
if (vertexAttachment->getBones().size() == 0) {
|
case MixBlend_First:
|
||||||
// Unweighted vertex positions, with alpha.
|
case MixBlend_Replace:
|
||||||
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
// Vertex positions or deform offsets, with alpha.
|
||||||
for (size_t i = 0; i < vertexCount; i++) {
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
float prev = prevVertices[i];
|
float prev = prevVertices[i];
|
||||||
deform[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
|
deform[i] += (prev + (nextVertices[i] - prev) * percent - deform[i]) * alpha;
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
// Weighted deform offsets, with alpha.
|
case MixBlend_Add:
|
||||||
for (size_t i = 0; i < vertexCount; i++) {
|
VertexAttachment *vertexAttachment = static_cast<VertexAttachment *>(slotAttachment);
|
||||||
float prev = prevVertices[i];
|
if (vertexAttachment->getBones().size() == 0) {
|
||||||
deform[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
|
// Unweighted vertex positions, with alpha.
|
||||||
}
|
Vector<float> &setupVertices = vertexAttachment->getVertices();
|
||||||
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
|
float prev = prevVertices[i];
|
||||||
|
deform[i] += (prev + (nextVertices[i] - prev) * percent - setupVertices[i]) * alpha;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Weighted deform offsets, with alpha.
|
||||||
|
for (size_t i = 0; i < vertexCount; i++) {
|
||||||
|
float prev = prevVertices[i];
|
||||||
|
deform[i] += (prev + (nextVertices[i] - prev) * percent) * alpha;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DeformTimeline::getPropertyId() {
|
int DeformTimeline::getPropertyId() {
|
||||||
assert(_attachment != NULL);
|
assert(_attachment != NULL);
|
||||||
|
|
||||||
return ((int) TimelineType_Deform << 24) + _attachment->_id + _slotIndex;
|
return ((int) TimelineType_Deform << 24) + _attachment->_id + _slotIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,8 @@ 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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(alpha);
|
SP_UNUSED(alpha);
|
||||||
@ -67,9 +68,8 @@ void DrawOrderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Ve
|
|||||||
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 (size_t i = 0, n = 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +77,8 @@ 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 (size_t i = 0, n = 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;
|
||||||
}
|
}
|
||||||
@ -88,20 +87,17 @@ void DrawOrderTimeline::apply(Skeleton &skeleton, float lastTime, float time, Ve
|
|||||||
if (time >= _frames[_frames.size() - 1]) {
|
if (time >= _frames[_frames.size() - 1]) {
|
||||||
// Time is after last frame.
|
// Time is after last frame.
|
||||||
frame = _frames.size() - 1;
|
frame = _frames.size() - 1;
|
||||||
} else {
|
} else
|
||||||
frame = (size_t)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 (size_t i = 0, n = 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 (size_t i = 0, n = 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]];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,10 +57,9 @@ EventTimeline::~EventTimeline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector<Event *> *pEvents, float alpha,
|
||||||
MixBlend blend, MixDirection direction) {
|
MixBlend blend, MixDirection direction
|
||||||
if (pEvents == NULL) {
|
) {
|
||||||
return;
|
if (pEvents == NULL) return;
|
||||||
}
|
|
||||||
|
|
||||||
Vector<Event *> &events = *pEvents;
|
Vector<Event *> &events = *pEvents;
|
||||||
|
|
||||||
@ -75,9 +74,7 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) return; // Time is before first frame.
|
||||||
return; // Time is before first frame.
|
|
||||||
}
|
|
||||||
|
|
||||||
int frame;
|
int frame;
|
||||||
if (lastTime < _frames[0]) {
|
if (lastTime < _frames[0]) {
|
||||||
@ -87,16 +84,13 @@ void EventTimeline::apply(Skeleton &skeleton, float lastTime, float time, Vector
|
|||||||
float frameTime = _frames[frame];
|
float frameTime = _frames[frame];
|
||||||
while (frame > 0) {
|
while (frame > 0) {
|
||||||
// Fire multiple events with the same frame.
|
// Fire multiple events with the same frame.
|
||||||
if (_frames[frame - 1] != frameTime) {
|
if (_frames[frame - 1] != frameTime) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
frame--;
|
frame--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; (size_t)frame < frameCount && time >= _frames[frame]; ++frame) {
|
for (; (size_t)frame < frameCount && time >= _frames[frame]; ++frame)
|
||||||
events.add(_events[frame]);
|
events.add(_events[frame]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int EventTimeline::getPropertyId() {
|
int EventTimeline::getPropertyId() {
|
||||||
|
|||||||
@ -65,8 +65,7 @@ void IkConstraint::apply(Bone &bone, float targetX, float targetY, bool compress
|
|||||||
if (uniform) sy *= s;
|
if (uniform) sy *= s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bone.updateWorldTransform(bone._ax, bone._ay, bone._arotation + rotationIK * alpha, sx,
|
bone.updateWorldTransform(bone._ax, bone._ay, bone._arotation + rotationIK * alpha, sx, sy, bone._ashearX, bone._ashearY);
|
||||||
sy, bone._ashearX, bone._ashearY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, float softness, float alpha) {
|
void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY, int bendDir, bool stretch, float softness, float alpha) {
|
||||||
@ -222,21 +221,21 @@ void IkConstraint::apply(Bone &parent, Bone &child, float targetX, float targetY
|
|||||||
a2 = ((a2 + os) * MathUtil::Rad_Deg - child._ashearX) * s2 + o2 - child._arotation;
|
a2 = ((a2 + os) * MathUtil::Rad_Deg - child._ashearX) * s2 + o2 - child._arotation;
|
||||||
if (a2 > 180) a2 -= 360;
|
if (a2 > 180) a2 -= 360;
|
||||||
else if (a2 < -180) a2 += 360;
|
else if (a2 < -180) a2 += 360;
|
||||||
child.updateWorldTransform(cx, cy, child._arotation + a2 * alpha, child._ascaleX, child._ascaleY,
|
child.updateWorldTransform(cx, cy, child._arotation + a2 * alpha, child._ascaleX, child._ascaleY, child._ashearX, child._ashearY);
|
||||||
child._ashearX, child._ashearY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IkConstraint::IkConstraint(IkConstraintData &data, Skeleton &skeleton) : Updatable(),
|
IkConstraint::IkConstraint(IkConstraintData &data, Skeleton &skeleton) : Updatable(),
|
||||||
_data(data),
|
_data(data),
|
||||||
_bendDirection(data.getBendDirection()),
|
_bendDirection(data.getBendDirection()),
|
||||||
_compress(data.getCompress()),
|
_compress(data.getCompress()),
|
||||||
_stretch(data.getStretch()),
|
_stretch(data.getStretch()),
|
||||||
_mix(data.getMix()),
|
_mix(data.getMix()),
|
||||||
_softness(data.getSoftness()),
|
_softness(data.getSoftness()),
|
||||||
_target(skeleton.findBone(
|
_target(skeleton.findBone(
|
||||||
data.getTarget()->getName())),
|
data.getTarget()->getName())),
|
||||||
_active(false) {
|
_active(false)
|
||||||
|
{
|
||||||
_bones.ensureCapacity(_data.getBones().size());
|
_bones.ensureCapacity(_data.getBones().size());
|
||||||
for (size_t i = 0; i < _data.getBones().size(); i++) {
|
for (size_t i = 0; i < _data.getBones().size(); i++) {
|
||||||
BoneData *boneData = _data.getBones()[i];
|
BoneData *boneData = _data.getBones()[i];
|
||||||
@ -251,17 +250,17 @@ void IkConstraint::apply() {
|
|||||||
|
|
||||||
void IkConstraint::update() {
|
void IkConstraint::update() {
|
||||||
switch (_bones.size()) {
|
switch (_bones.size()) {
|
||||||
case 1: {
|
case 1: {
|
||||||
Bone *bone0 = _bones[0];
|
Bone *bone0 = _bones[0];
|
||||||
apply(*bone0, _target->getWorldX(), _target->getWorldY(), _compress, _stretch, _data._uniform, _mix);
|
apply(*bone0, _target->getWorldX(), _target->getWorldY(), _compress, _stretch, _data._uniform, _mix);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2: {
|
case 2: {
|
||||||
Bone *bone0 = _bones[0];
|
Bone *bone0 = _bones[0];
|
||||||
Bone *bone1 = _bones[1];
|
Bone *bone1 = _bones[1];
|
||||||
apply(*bone0, *bone1, _target->getWorldX(), _target->getWorldY(), _bendDirection, _stretch, _softness, _mix);
|
apply(*bone0, *bone1, _target->getWorldX(), _target->getWorldY(), _bendDirection, _stretch, _softness, _mix);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,10 +325,10 @@ void IkConstraint::setActive(bool inValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float IkConstraint::getSoftness() {
|
float IkConstraint::getSoftness() {
|
||||||
return _softness;
|
return _softness;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IkConstraint::setSoftness(float inValue) {
|
void IkConstraint::setSoftness(float inValue) {
|
||||||
_softness = inValue;
|
_softness = inValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
|||||||
constraint._mix =
|
constraint._mix =
|
||||||
constraint._data._mix + (_frames[_frames.size() + PREV_MIX] - constraint._data._mix) * alpha;
|
constraint._data._mix + (_frames[_frames.size() + PREV_MIX] - constraint._data._mix) * alpha;
|
||||||
constraint._softness = constraint._data._softness
|
constraint._softness = constraint._data._softness
|
||||||
+ (_frames[_frames.size() + PREV_SOFTNESS] - constraint._data._softness) * alpha;
|
+ (_frames[_frames.size() + PREV_SOFTNESS] - constraint._data._softness) * alpha;
|
||||||
if (direction == MixDirection_Out) {
|
if (direction == MixDirection_Out) {
|
||||||
constraint._bendDirection = constraint._data._bendDirection;
|
constraint._bendDirection = constraint._data._bendDirection;
|
||||||
constraint._compress = constraint._data._compress;
|
constraint._compress = constraint._data._compress;
|
||||||
@ -134,7 +134,7 @@ void IkConstraintTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
|||||||
constraint._mix =
|
constraint._mix =
|
||||||
constraint._data._mix + (mix + (_frames[frame + MIX] - mix) * percent - constraint._data._mix) * alpha;
|
constraint._data._mix + (mix + (_frames[frame + MIX] - mix) * percent - constraint._data._mix) * alpha;
|
||||||
constraint._softness = constraint._data._softness
|
constraint._softness = constraint._data._softness
|
||||||
+ (softness + (_frames[frame + SOFTNESS] - softness) * percent - constraint._data._softness) * alpha;
|
+ (softness + (_frames[frame + SOFTNESS] - softness) * percent - constraint._data._softness) * alpha;
|
||||||
if (direction == MixDirection_Out) {
|
if (direction == MixDirection_Out) {
|
||||||
constraint._bendDirection = constraint._data._bendDirection;
|
constraint._bendDirection = constraint._data._bendDirection;
|
||||||
constraint._compress = constraint._data._compress;
|
constraint._compress = constraint._data._compress;
|
||||||
|
|||||||
@ -1,38 +1,32 @@
|
|||||||
/******************************************************************************
|
/*
|
||||||
* Spine Runtimes License Agreement
|
Copyright (c) 2009, Dave Gamble
|
||||||
* Last updated May 1, 2019. Replaces all prior versions.
|
Copyright (c) 2013, Esoteric Software
|
||||||
*
|
|
||||||
* Copyright (c) 2013-2019, Esoteric Software LLC
|
Permission is hereby granted, dispose of charge, to any person obtaining a copy
|
||||||
*
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* Integration of the Spine Runtimes into software or otherwise creating
|
in the Software without restriction, including without limitation the rights
|
||||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* http://esotericsoftware.com/spine-editor-license
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
The above copyright notice and this permission notice shall be included in
|
||||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
all copies or substantial portions of the Software.
|
||||||
* "Products"), provided that each user of the Products must obtain their own
|
|
||||||
* Spine Editor license and redistribution of the Products in any form must
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* include this license and copyright notice.
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
*
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
|
THE SOFTWARE.
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
*/
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
|
|
||||||
* INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
|
|
||||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
||||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef SPINE_UE4
|
#ifdef SPINE_UE4
|
||||||
#include "SpinePluginPrivatePCH.h"
|
#include "SpinePluginPrivatePCH.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Json */
|
/* Json */
|
||||||
/* JSON parser in CPP, shamelessly ripped from json.c in the spine-c runtime */
|
/* JSON parser in CPP, from json.c in the spine-c runtime */
|
||||||
|
|
||||||
#ifndef _DEFAULT_SOURCE
|
#ifndef _DEFAULT_SOURCE
|
||||||
/* Bring strings.h definitions into string.h, where appropriate */
|
/* Bring strings.h definitions into string.h, where appropriate */
|
||||||
@ -163,49 +157,49 @@ const char *Json::parseValue(Json *item, const char *value) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (*value) {
|
switch (*value) {
|
||||||
case 'n': {
|
case 'n': {
|
||||||
if (!strncmp(value + 1, "ull", 3)) {
|
if (!strncmp(value + 1, "ull", 3)) {
|
||||||
item->_type = JSON_NULL;
|
item->_type = JSON_NULL;
|
||||||
return value + 4;
|
return value + 4;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case 'f': {
|
break;
|
||||||
if (!strncmp(value + 1, "alse", 4)) {
|
}
|
||||||
item->_type = JSON_FALSE;
|
case 'f': {
|
||||||
/* calloc prevents us needing item->_type = JSON_FALSE or valueInt = 0 here */
|
if (!strncmp(value + 1, "alse", 4)) {
|
||||||
return value + 5;
|
item->_type = JSON_FALSE;
|
||||||
}
|
/* calloc prevents us needing item->_type = JSON_FALSE or valueInt = 0 here */
|
||||||
break;
|
return value + 5;
|
||||||
}
|
}
|
||||||
case 't': {
|
break;
|
||||||
if (!strncmp(value + 1, "rue", 3)) {
|
}
|
||||||
item->_type = JSON_TRUE;
|
case 't': {
|
||||||
item->_valueInt = 1;
|
if (!strncmp(value + 1, "rue", 3)) {
|
||||||
return value + 4;
|
item->_type = JSON_TRUE;
|
||||||
}
|
item->_valueInt = 1;
|
||||||
break;
|
return value + 4;
|
||||||
}
|
}
|
||||||
case '\"':
|
break;
|
||||||
return parseString(item, value);
|
}
|
||||||
case '[':
|
case '\"':
|
||||||
return parseArray(item, value);
|
return parseString(item, value);
|
||||||
case '{':
|
case '[':
|
||||||
return parseObject(item, value);
|
return parseArray(item, value);
|
||||||
case '-': /* fallthrough */
|
case '{':
|
||||||
case '0': /* fallthrough */
|
return parseObject(item, value);
|
||||||
case '1': /* fallthrough */
|
case '-': /* fallthrough */
|
||||||
case '2': /* fallthrough */
|
case '0': /* fallthrough */
|
||||||
case '3': /* fallthrough */
|
case '1': /* fallthrough */
|
||||||
case '4': /* fallthrough */
|
case '2': /* fallthrough */
|
||||||
case '5': /* fallthrough */
|
case '3': /* fallthrough */
|
||||||
case '6': /* fallthrough */
|
case '4': /* fallthrough */
|
||||||
case '7': /* fallthrough */
|
case '5': /* fallthrough */
|
||||||
case '8': /* fallthrough */
|
case '6': /* fallthrough */
|
||||||
case '9':
|
case '7': /* fallthrough */
|
||||||
return parseNumber(item, value);
|
case '8': /* fallthrough */
|
||||||
default:
|
case '9':
|
||||||
break;
|
return parseNumber(item, value);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_error = value;
|
_error = value;
|
||||||
@ -266,18 +260,18 @@ const char *Json::parseString(Json *item, const char *str) {
|
|||||||
ptr += 4; /* get the unicode char. */
|
ptr += 4; /* get the unicode char. */
|
||||||
|
|
||||||
if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) {
|
if ((uc >= 0xDC00 && uc <= 0xDFFF) || uc == 0) {
|
||||||
break; /* check for invalid. */
|
break; /* check for invalid. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO provide an option to ignore surrogates, use unicode replacement character? */
|
/* TODO provide an option to ignore surrogates, use unicode replacement character? */
|
||||||
if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */ {
|
if (uc >= 0xD800 && uc <= 0xDBFF) /* UTF16 surrogate pairs. */ {
|
||||||
if (ptr[1] != '\\' || ptr[2] != 'u') {
|
if (ptr[1] != '\\' || ptr[2] != 'u') {
|
||||||
break; /* missing second-half of surrogate. */
|
break; /* missing second-half of surrogate. */
|
||||||
}
|
}
|
||||||
sscanf(ptr + 3, "%4x", &uc2);
|
sscanf(ptr + 3, "%4x", &uc2);
|
||||||
ptr += 6;
|
ptr += 6;
|
||||||
if (uc2 < 0xDC00 || uc2 > 0xDFFF) {
|
if (uc2 < 0xDC00 || uc2 > 0xDFFF) {
|
||||||
break; /* invalid second-half of surrogate. */
|
break; /* invalid second-half of surrogate. */
|
||||||
}
|
}
|
||||||
uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF));
|
uc = 0x10000 + (((uc & 0x3FF) << 10) | (uc2 & 0x3FF));
|
||||||
}
|
}
|
||||||
@ -549,7 +543,7 @@ int Json::json_strcasecmp(const char *s1, const char *s2) {
|
|||||||
} else if (s1 == s2) {
|
} else if (s1 == s2) {
|
||||||
return 0; /* both are null */
|
return 0; /* both are null */
|
||||||
} else {
|
} else {
|
||||||
return 1; /* s2 is nul s1 is not */
|
return 1; /* s2 is nul s1 is not */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,25 +39,25 @@ using namespace spine;
|
|||||||
RTTI_IMPL(MeshAttachment, VertexAttachment)
|
RTTI_IMPL(MeshAttachment, VertexAttachment)
|
||||||
|
|
||||||
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), HasRendererObject(),
|
MeshAttachment::MeshAttachment(const String &name) : VertexAttachment(name), HasRendererObject(),
|
||||||
_regionOffsetX(0),
|
_regionOffsetX(0),
|
||||||
_regionOffsetY(0),
|
_regionOffsetY(0),
|
||||||
_regionWidth(0),
|
_regionWidth(0),
|
||||||
_regionHeight(0),
|
_regionHeight(0),
|
||||||
_regionOriginalWidth(0),
|
_regionOriginalWidth(0),
|
||||||
_regionOriginalHeight(0),
|
_regionOriginalHeight(0),
|
||||||
_parentMesh(NULL),
|
_parentMesh(NULL),
|
||||||
_path(),
|
_path(),
|
||||||
_regionU(0),
|
_regionU(0),
|
||||||
_regionV(0),
|
_regionV(0),
|
||||||
_regionU2(0),
|
_regionU2(0),
|
||||||
_regionV2(0),
|
_regionV2(0),
|
||||||
_width(0),
|
_width(0),
|
||||||
_height(0),
|
_height(0),
|
||||||
_color(1, 1, 1, 1),
|
_color(1, 1, 1, 1),
|
||||||
_hullLength(0),
|
_hullLength(0),
|
||||||
_regionRotate(false),
|
_regionRotate(false),
|
||||||
_regionDegrees(0) {
|
_regionDegrees(0)
|
||||||
}
|
{}
|
||||||
|
|
||||||
MeshAttachment::~MeshAttachment() {}
|
MeshAttachment::~MeshAttachment() {}
|
||||||
|
|
||||||
@ -71,58 +71,58 @@ void MeshAttachment::updateUVs() {
|
|||||||
float width = 0, height = 0;
|
float width = 0, height = 0;
|
||||||
|
|
||||||
switch (_regionDegrees) {
|
switch (_regionDegrees) {
|
||||||
case 90: {
|
case 90: {
|
||||||
float textureWidth = _regionHeight / (_regionU2 - _regionU);
|
float textureWidth = _regionHeight / (_regionU2 - _regionU);
|
||||||
float textureHeight = _regionWidth / (_regionV2 - _regionV);
|
float textureHeight = _regionWidth / (_regionV2 - _regionV);
|
||||||
u -= (_regionOriginalHeight - _regionOffsetY - _regionHeight) / textureWidth;
|
u -= (_regionOriginalHeight - _regionOffsetY - _regionHeight) / textureWidth;
|
||||||
v -= (_regionOriginalWidth - _regionOffsetX - _regionWidth) / textureHeight;
|
v -= (_regionOriginalWidth - _regionOffsetX - _regionWidth) / textureHeight;
|
||||||
width = _regionOriginalHeight / textureWidth;
|
width = _regionOriginalHeight / textureWidth;
|
||||||
height = _regionOriginalWidth / textureHeight;
|
height = _regionOriginalWidth / textureHeight;
|
||||||
for (i = 0; i < n; i += 2) {
|
for (i = 0; i < n; i += 2) {
|
||||||
_uvs[i] = u + _regionUVs[i + 1] * width;
|
_uvs[i] = u + _regionUVs[i + 1] * width;
|
||||||
_uvs[i + 1] = v + (1 - _regionUVs[i]) * height;
|
_uvs[i + 1] = v + (1 - _regionUVs[i]) * height;
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
case 180: {
|
return;
|
||||||
float textureWidth = _regionWidth / (_regionU2 - _regionU);
|
}
|
||||||
float textureHeight = _regionHeight / (_regionV2 - _regionV);
|
case 180: {
|
||||||
u -= (_regionOriginalWidth - _regionOffsetX - _regionWidth) / textureWidth;
|
float textureWidth = _regionWidth / (_regionU2 - _regionU);
|
||||||
v -= _regionOffsetY / textureHeight;
|
float textureHeight = _regionHeight / (_regionV2 - _regionV);
|
||||||
width = _regionOriginalWidth / textureWidth;
|
u -= (_regionOriginalWidth - _regionOffsetX - _regionWidth) / textureWidth;
|
||||||
height = _regionOriginalHeight / textureHeight;
|
v -= _regionOffsetY / textureHeight;
|
||||||
for (i = 0; i < n; i += 2) {
|
width = _regionOriginalWidth / textureWidth;
|
||||||
_uvs[i] = u + (1 - _regionUVs[i]) * width;
|
height = _regionOriginalHeight / textureHeight;
|
||||||
_uvs[i + 1] = v + (1 - _regionUVs[i + 1]) * height;
|
for (i = 0; i < n; i += 2) {
|
||||||
}
|
_uvs[i] = u + (1 - _regionUVs[i]) * width;
|
||||||
return;
|
_uvs[i + 1] = v + (1 - _regionUVs[i + 1]) * height;
|
||||||
}
|
}
|
||||||
case 270: {
|
return;
|
||||||
float textureHeight = _regionHeight / (_regionV2 - _regionV);
|
}
|
||||||
float textureWidth = _regionWidth / (_regionU2 - _regionU);
|
case 270: {
|
||||||
u -= _regionOffsetY / textureWidth;
|
float textureHeight = _regionHeight / (_regionV2 - _regionV);
|
||||||
v -= _regionOffsetX / textureHeight;
|
float textureWidth = _regionWidth / (_regionU2 - _regionU);
|
||||||
width = _regionOriginalHeight / textureWidth;
|
u -= _regionOffsetY / textureWidth;
|
||||||
height = _regionOriginalWidth / textureHeight;
|
v -= _regionOffsetX / textureHeight;
|
||||||
for (i = 0; i < n; i += 2) {
|
width = _regionOriginalHeight / textureWidth;
|
||||||
_uvs[i] = u + (1 - _regionUVs[i + 1]) * width;
|
height = _regionOriginalWidth / textureHeight;
|
||||||
_uvs[i + 1] = v + _regionUVs[i] * height;
|
for (i = 0; i < n; i += 2) {
|
||||||
}
|
_uvs[i] = u + (1 - _regionUVs[i + 1]) * width;
|
||||||
return;
|
_uvs[i + 1] = v + _regionUVs[i] * height;
|
||||||
}
|
}
|
||||||
default: {
|
return;
|
||||||
float textureWidth = _regionWidth / (_regionU2 - _regionU);
|
}
|
||||||
float textureHeight = _regionHeight / (_regionV2 - _regionV);
|
default: {
|
||||||
u -= _regionOffsetX / textureWidth;
|
float textureWidth = _regionWidth / (_regionU2 - _regionU);
|
||||||
v -= (_regionOriginalHeight - _regionOffsetY - _regionHeight) / textureHeight;
|
float textureHeight = _regionHeight / (_regionV2 - _regionV);
|
||||||
width = _regionOriginalWidth / textureWidth;
|
u -= _regionOffsetX / textureWidth;
|
||||||
height = _regionOriginalHeight / textureHeight;
|
v -= (_regionOriginalHeight - _regionOffsetY - _regionHeight) / textureHeight;
|
||||||
for (i = 0; i < n; i += 2) {
|
width = _regionOriginalWidth / textureWidth;
|
||||||
_uvs[i] = u + _regionUVs[i] * width;
|
height = _regionOriginalHeight / textureHeight;
|
||||||
_uvs[i + 1] = v + _regionUVs[i + 1] * height;
|
for (i = 0; i < n; i += 2) {
|
||||||
}
|
_uvs[i] = u + _regionUVs[i] * width;
|
||||||
|
_uvs[i + 1] = v + _regionUVs[i + 1] * height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MeshAttachment::getHullLength() {
|
int MeshAttachment::getHullLength() {
|
||||||
@ -295,7 +295,7 @@ Attachment* MeshAttachment::copy() {
|
|||||||
copy->_regionV2 = _regionV2;
|
copy->_regionV2 = _regionV2;
|
||||||
copy->_regionRotate = _regionRotate;
|
copy->_regionRotate = _regionRotate;
|
||||||
copy->_regionDegrees = _regionDegrees;
|
copy->_regionDegrees = _regionDegrees;
|
||||||
copy->_regionOffsetX = _regionOffsetX;
|
copy->_regionOffsetX = _regionOffsetX;
|
||||||
copy->_regionOffsetY = _regionOffsetY;
|
copy->_regionOffsetY = _regionOffsetY;
|
||||||
copy->_regionWidth = _regionWidth;
|
copy->_regionWidth = _regionWidth;
|
||||||
copy->_regionHeight = _regionHeight;
|
copy->_regionHeight = _regionHeight;
|
||||||
@ -326,7 +326,7 @@ MeshAttachment* MeshAttachment::newLinkedMesh() {
|
|||||||
copy->_regionV2 = _regionV2;
|
copy->_regionV2 = _regionV2;
|
||||||
copy->_regionRotate = _regionRotate;
|
copy->_regionRotate = _regionRotate;
|
||||||
copy->_regionDegrees = _regionDegrees;
|
copy->_regionDegrees = _regionDegrees;
|
||||||
copy->_regionOffsetX = _regionOffsetX;
|
copy->_regionOffsetX = _regionOffsetX;
|
||||||
copy->_regionOffsetY = _regionOffsetY;
|
copy->_regionOffsetY = _regionOffsetY;
|
||||||
copy->_regionWidth = _regionWidth;
|
copy->_regionWidth = _regionWidth;
|
||||||
copy->_regionHeight = _regionHeight;
|
copy->_regionHeight = _regionHeight;
|
||||||
|
|||||||
@ -52,14 +52,15 @@ const int PathConstraint::BEFORE = -2;
|
|||||||
const int PathConstraint::AFTER = -3;
|
const int PathConstraint::AFTER = -3;
|
||||||
|
|
||||||
PathConstraint::PathConstraint(PathConstraintData &data, Skeleton &skeleton) : Updatable(),
|
PathConstraint::PathConstraint(PathConstraintData &data, Skeleton &skeleton) : Updatable(),
|
||||||
_data(data),
|
_data(data),
|
||||||
_target(skeleton.findSlot(
|
_target(skeleton.findSlot(
|
||||||
data.getTarget()->getName())),
|
data.getTarget()->getName())),
|
||||||
_position(data.getPosition()),
|
_position(data.getPosition()),
|
||||||
_spacing(data.getSpacing()),
|
_spacing(data.getSpacing()),
|
||||||
_rotateMix(data.getRotateMix()),
|
_rotateMix(data.getRotateMix()),
|
||||||
_translateMix(data.getTranslateMix()),
|
_translateMix(data.getTranslateMix()),
|
||||||
_active(false) {
|
_active(false)
|
||||||
|
{
|
||||||
_bones.ensureCapacity(_data.getBones().size());
|
_bones.ensureCapacity(_data.getBones().size());
|
||||||
for (size_t i = 0; i < _data.getBones().size(); i++) {
|
for (size_t i = 0; i < _data.getBones().size(); i++) {
|
||||||
BoneData *boneData = _data.getBones()[i];
|
BoneData *boneData = _data.getBones()[i];
|
||||||
@ -98,9 +99,7 @@ void PathConstraint::update() {
|
|||||||
_spaces.setSize(spacesCount, 0);
|
_spaces.setSize(spacesCount, 0);
|
||||||
float spacing = _spacing;
|
float spacing = _spacing;
|
||||||
if (scale || !percentSpacing) {
|
if (scale || !percentSpacing) {
|
||||||
if (scale) {
|
if (scale) _lengths.setSize(boneCount, 0);
|
||||||
_lengths.setSize(boneCount, 0);
|
|
||||||
}
|
|
||||||
bool lengthSpacing = data._spacingMode == SpacingMode_Length;
|
bool lengthSpacing = data._spacingMode == SpacingMode_Length;
|
||||||
|
|
||||||
for (size_t i = 0, n = spacesCount - 1; i < n;) {
|
for (size_t i = 0, n = spacesCount - 1; i < n;) {
|
||||||
@ -108,9 +107,7 @@ void PathConstraint::update() {
|
|||||||
Bone &bone = *boneP;
|
Bone &bone = *boneP;
|
||||||
float setupLength = bone._data.getLength();
|
float setupLength = bone._data.getLength();
|
||||||
if (setupLength < PathConstraint::EPSILON) {
|
if (setupLength < PathConstraint::EPSILON) {
|
||||||
if (scale) {
|
if (scale) _lengths[i] = 0;
|
||||||
_lengths[i] = 0;
|
|
||||||
}
|
|
||||||
_spaces[++i] = 0;
|
_spaces[++i] = 0;
|
||||||
} else if (percentSpacing) {
|
} else if (percentSpacing) {
|
||||||
if (scale) {
|
if (scale) {
|
||||||
@ -137,8 +134,7 @@ void PathConstraint::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>& positions = computeWorldPositions(*attachment, spacesCount, tangents,
|
Vector<float>& positions = computeWorldPositions(*attachment, spacesCount, tangents,
|
||||||
data.getPositionMode() == PositionMode_Percent,
|
data.getPositionMode() == PositionMode_Percent, percentSpacing);
|
||||||
percentSpacing);
|
|
||||||
float boneX = positions[0];
|
float boneX = positions[0];
|
||||||
float boneY = positions[1];
|
float boneY = positions[1];
|
||||||
float offsetRotation = data.getOffsetRotation();
|
float offsetRotation = data.getOffsetRotation();
|
||||||
@ -174,13 +170,12 @@ void PathConstraint::update() {
|
|||||||
|
|
||||||
if (rotate) {
|
if (rotate) {
|
||||||
float a = bone._a, b = bone._b, c = bone._c, d = bone._d, r, cos, sin;
|
float a = bone._a, b = bone._b, c = bone._c, d = bone._d, r, cos, sin;
|
||||||
if (tangents) {
|
if (tangents)
|
||||||
r = positions[p - 1];
|
r = positions[p - 1];
|
||||||
} else if (_spaces[i + 1] < PathConstraint::EPSILON) {
|
else if (_spaces[i + 1] < PathConstraint::EPSILON)
|
||||||
r = positions[p + 2];
|
r = positions[p + 2];
|
||||||
} else {
|
else
|
||||||
r = MathUtil::atan2(dy, dx);
|
r = MathUtil::atan2(dy, dx);
|
||||||
}
|
|
||||||
|
|
||||||
r -= MathUtil::atan2(c, a);
|
r -= MathUtil::atan2(c, a);
|
||||||
|
|
||||||
@ -190,15 +185,13 @@ void PathConstraint::update() {
|
|||||||
float length = bone._data.getLength();
|
float length = bone._data.getLength();
|
||||||
boneX += (length * (cos * a - sin * c) - dx) * rotateMix;
|
boneX += (length * (cos * a - sin * c) - dx) * rotateMix;
|
||||||
boneY += (length * (sin * a + cos * c) - dy) * rotateMix;
|
boneY += (length * (sin * a + cos * c) - dy) * rotateMix;
|
||||||
} else {
|
} else
|
||||||
r += offsetRotation;
|
r += offsetRotation;
|
||||||
}
|
|
||||||
|
|
||||||
if (r > MathUtil::Pi) {
|
if (r > MathUtil::Pi)
|
||||||
r -= MathUtil::Pi_2;
|
r -= MathUtil::Pi_2;
|
||||||
} else if (r < -MathUtil::Pi) {
|
else if (r < -MathUtil::Pi)
|
||||||
r += MathUtil::Pi_2;
|
r += MathUtil::Pi_2;
|
||||||
}
|
|
||||||
|
|
||||||
r *= rotateMix;
|
r *= rotateMix;
|
||||||
cos = MathUtil::cos(r);
|
cos = MathUtil::cos(r);
|
||||||
@ -266,8 +259,7 @@ PathConstraintData &PathConstraint::getData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vector<float>&
|
Vector<float>&
|
||||||
PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, bool tangents, bool percentPosition,
|
PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, bool tangents, bool percentPosition, bool percentSpacing) {
|
||||||
bool percentSpacing) {
|
|
||||||
Slot &target = *_target;
|
Slot &target = *_target;
|
||||||
float position = _position;
|
float position = _position;
|
||||||
_positions.setSize(spacesCount * 3 + 2, 0);
|
_positions.setSize(spacesCount * 3 + 2, 0);
|
||||||
@ -283,14 +275,11 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
Vector<float> &lengths = path.getLengths();
|
Vector<float> &lengths = path.getLengths();
|
||||||
curveCount -= closed ? 1 : 2;
|
curveCount -= closed ? 1 : 2;
|
||||||
pathLength = lengths[curveCount];
|
pathLength = lengths[curveCount];
|
||||||
if (percentPosition) {
|
if (percentPosition) position *= pathLength;
|
||||||
position *= pathLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (percentSpacing) {
|
if (percentSpacing) {
|
||||||
for (int i = 1; i < spacesCount; ++i) {
|
for (int i = 1; i < spacesCount; ++i)
|
||||||
_spaces[i] *= pathLength;
|
_spaces[i] *= pathLength;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
world.setSize(8, 0);
|
world.setSize(8, 0);
|
||||||
@ -301,10 +290,7 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
|
|
||||||
if (closed) {
|
if (closed) {
|
||||||
p = MathUtil::fmod(p, pathLength);
|
p = MathUtil::fmod(p, pathLength);
|
||||||
|
if (p < 0) p += pathLength;
|
||||||
if (p < 0) {
|
|
||||||
p += pathLength;
|
|
||||||
}
|
|
||||||
curve = 0;
|
curve = 0;
|
||||||
} else if (p < 0) {
|
} else if (p < 0) {
|
||||||
if (prevCurve != BEFORE) {
|
if (prevCurve != BEFORE) {
|
||||||
@ -329,13 +315,11 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
// Determine curve containing position.
|
// Determine curve containing position.
|
||||||
for (;; curve++) {
|
for (;; curve++) {
|
||||||
float length = lengths[curve];
|
float length = lengths[curve];
|
||||||
if (p > length) {
|
if (p > length) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (curve == 0) {
|
if (curve == 0)
|
||||||
p /= length;
|
p /= length;
|
||||||
} else {
|
else {
|
||||||
float prev = lengths[curve - 1];
|
float prev = lengths[curve - 1];
|
||||||
p = (p - prev) / (length - prev);
|
p = (p - prev) / (length - prev);
|
||||||
}
|
}
|
||||||
@ -347,13 +331,12 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
if (closed && curve == curveCount) {
|
if (closed && curve == curveCount) {
|
||||||
path.computeWorldVertices(target, verticesLength - 4, 4, world, 0);
|
path.computeWorldVertices(target, verticesLength - 4, 4, world, 0);
|
||||||
path.computeWorldVertices(target, 0, 4, world, 4);
|
path.computeWorldVertices(target, 0, 4, world, 4);
|
||||||
} else {
|
} else
|
||||||
path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0);
|
path.computeWorldVertices(target, curve * 6 + 2, 8, world, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7],
|
addCurvePosition(p, world[0], world[1], world[2], world[3], world[4], world[5], world[6], world[7],
|
||||||
out, o, tangents || (i > 0 && space < EPSILON));
|
out, o, tangents || (i > 0 && space < EPSILON));
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@ -410,16 +393,14 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
y1 = y2;
|
y1 = y2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (percentPosition) {
|
if (percentPosition)
|
||||||
position *= pathLength;
|
position *= pathLength;
|
||||||
} else {
|
else
|
||||||
position *= pathLength / path.getLengths()[curveCount - 1];
|
position *= pathLength / path.getLengths()[curveCount - 1];
|
||||||
}
|
|
||||||
|
|
||||||
if (percentSpacing) {
|
if (percentSpacing) {
|
||||||
for (int i = 1; i < spacesCount; ++i) {
|
for (int i = 1; i < spacesCount; ++i)
|
||||||
_spaces[i] *= pathLength;
|
_spaces[i] *= pathLength;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float curveLength = 0;
|
float curveLength = 0;
|
||||||
@ -430,10 +411,7 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
|
|
||||||
if (closed) {
|
if (closed) {
|
||||||
p = MathUtil::fmod(p, pathLength);
|
p = MathUtil::fmod(p, pathLength);
|
||||||
|
if (p < 0) p += pathLength;
|
||||||
if (p < 0) {
|
|
||||||
p += pathLength;
|
|
||||||
}
|
|
||||||
curve = 0;
|
curve = 0;
|
||||||
} else if (p < 0) {
|
} else if (p < 0) {
|
||||||
addBeforePosition(p, world, 0, out, o);
|
addBeforePosition(p, world, 0, out, o);
|
||||||
@ -446,13 +424,10 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
// Determine curve containing position.
|
// Determine curve containing position.
|
||||||
for (;; curve++) {
|
for (;; curve++) {
|
||||||
float length = _curves[curve];
|
float length = _curves[curve];
|
||||||
if (p > length) {
|
if (p > length) continue;
|
||||||
continue;
|
if (curve == 0)
|
||||||
}
|
|
||||||
|
|
||||||
if (curve == 0) {
|
|
||||||
p /= length;
|
p /= length;
|
||||||
} else {
|
else {
|
||||||
float prev = _curves[curve - 1];
|
float prev = _curves[curve - 1];
|
||||||
p = (p - prev) / (length - prev);
|
p = (p - prev) / (length - prev);
|
||||||
}
|
}
|
||||||
@ -504,20 +479,17 @@ PathConstraint::computeWorldPositions(PathAttachment &path, int spacesCount, boo
|
|||||||
p *= curveLength;
|
p *= curveLength;
|
||||||
for (;; segment++) {
|
for (;; segment++) {
|
||||||
float length = _segments[segment];
|
float length = _segments[segment];
|
||||||
if (p > length) {
|
if (p > length) continue;
|
||||||
continue;
|
if (segment == 0)
|
||||||
}
|
|
||||||
|
|
||||||
if (segment == 0) {
|
|
||||||
p /= length;
|
p /= length;
|
||||||
} else {
|
else {
|
||||||
float prev = _segments[segment - 1];
|
float prev = _segments[segment - 1];
|
||||||
p = segment + (p - prev) / (length - prev);
|
p = segment + (p - prev) / (length - prev);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
addCurvePosition(p * 0.1f, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o,
|
addCurvePosition(p * 0.1f, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o,
|
||||||
tangents || (i > 0 && space < EPSILON));
|
tangents || (i > 0 && space < EPSILON));
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@ -529,7 +501,6 @@ void PathConstraint::addBeforePosition(float p, Vector<float> &temp, int i, Vect
|
|||||||
float dx = temp[i + 2] - x1;
|
float dx = temp[i + 2] - x1;
|
||||||
float dy = temp[i + 3] - y1;
|
float dy = temp[i + 3] - y1;
|
||||||
float r = MathUtil::atan2(dy, dx);
|
float r = MathUtil::atan2(dy, dx);
|
||||||
|
|
||||||
output[o] = x1 + p * MathUtil::cos(r);
|
output[o] = x1 + p * MathUtil::cos(r);
|
||||||
output[o + 1] = y1 + p * MathUtil::sin(r);
|
output[o + 1] = y1 + p * MathUtil::sin(r);
|
||||||
output[o + 2] = r;
|
output[o + 2] = r;
|
||||||
@ -547,7 +518,8 @@ void PathConstraint::addAfterPosition(float p, Vector<float> &temp, int i, Vecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PathConstraint::addCurvePosition(float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2,
|
void PathConstraint::addCurvePosition(float p, float x1, float y1, float cx1, float cy1, float cx2, float cy2, float x2,
|
||||||
float y2, Vector<float> &output, int o, bool tangents) {
|
float y2, Vector<float> &output, int o, bool tangents
|
||||||
|
) {
|
||||||
if (p < EPSILON || MathUtil::isNan(p)) {
|
if (p < EPSILON || MathUtil::isNan(p)) {
|
||||||
output[o] = x1;
|
output[o] = x1;
|
||||||
output[o + 1] = y1;
|
output[o + 1] = y1;
|
||||||
@ -561,12 +533,10 @@ void PathConstraint::addCurvePosition(float p, float x1, float y1, float cx1, fl
|
|||||||
output[o] = x;
|
output[o] = x;
|
||||||
output[o + 1] = y;
|
output[o + 1] = y;
|
||||||
if (tangents) {
|
if (tangents) {
|
||||||
if (p < 0.001) {
|
if (p < 0.001)
|
||||||
output[o + 2] = MathUtil::atan2(cy1 - y1, cx1 - x1);
|
output[o + 2] = MathUtil::atan2(cy1 - y1, cx1 - x1);
|
||||||
} else {
|
else
|
||||||
output[o + 2] = MathUtil::atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt),
|
output[o + 2] = MathUtil::atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
|
||||||
x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,13 +55,14 @@ const int PathConstraintMixTimeline::ROTATE = 1;
|
|||||||
const int PathConstraintMixTimeline::TRANSLATE = 2;
|
const int PathConstraintMixTimeline::TRANSLATE = 2;
|
||||||
|
|
||||||
PathConstraintMixTimeline::PathConstraintMixTimeline(int frameCount) : CurveTimeline(frameCount),
|
PathConstraintMixTimeline::PathConstraintMixTimeline(int frameCount) : CurveTimeline(frameCount),
|
||||||
_pathConstraintIndex(0) {
|
_pathConstraintIndex(0)
|
||||||
|
{
|
||||||
_frames.setSize(frameCount * ENTRIES, 0);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
@ -72,16 +73,16 @@ PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
|||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
constraint._rotateMix = constraint._data._rotateMix;
|
constraint._rotateMix = constraint._data._rotateMix;
|
||||||
constraint._translateMix = constraint._data._translateMix;
|
constraint._translateMix = constraint._data._translateMix;
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
constraint._rotateMix += (constraint._data._rotateMix - constraint._rotateMix) * alpha;
|
constraint._rotateMix += (constraint._data._rotateMix - constraint._rotateMix) * alpha;
|
||||||
constraint._translateMix += (constraint._data._translateMix - constraint._translateMix) * alpha;
|
constraint._translateMix += (constraint._data._translateMix - constraint._translateMix) * alpha;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
|||||||
translate = _frames[frame + PREV_TRANSLATE];
|
translate = _frames[frame + PREV_TRANSLATE];
|
||||||
float frameTime = _frames[frame];
|
float frameTime = _frames[frame];
|
||||||
float percent = getCurvePercent(frame / ENTRIES - 1,
|
float percent = getCurvePercent(frame / ENTRIES - 1,
|
||||||
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
||||||
|
|
||||||
rotate += (_frames[frame + ROTATE] - rotate) * percent;
|
rotate += (_frames[frame + ROTATE] - rotate) * percent;
|
||||||
translate += (_frames[frame + TRANSLATE] - translate) * percent;
|
translate += (_frames[frame + TRANSLATE] - translate) * percent;
|
||||||
@ -106,7 +107,7 @@ PathConstraintMixTimeline::apply(Skeleton &skeleton, float lastTime, float time,
|
|||||||
if (blend == MixBlend_Setup) {
|
if (blend == MixBlend_Setup) {
|
||||||
constraint._rotateMix = constraint._data._rotateMix + (rotate - constraint._data._rotateMix) * alpha;
|
constraint._rotateMix = constraint._data._rotateMix + (rotate - constraint._data._rotateMix) * alpha;
|
||||||
constraint._translateMix =
|
constraint._translateMix =
|
||||||
constraint._data._translateMix + (translate - constraint._data._translateMix) * alpha;
|
constraint._data._translateMix + (translate - constraint._data._translateMix) * alpha;
|
||||||
} else {
|
} else {
|
||||||
constraint._rotateMix += (rotate - constraint._rotateMix) * alpha;
|
constraint._rotateMix += (rotate - constraint._rotateMix) * alpha;
|
||||||
constraint._translateMix += (translate - constraint._translateMix) * alpha;
|
constraint._translateMix += (translate - constraint._translateMix) * alpha;
|
||||||
|
|||||||
@ -53,7 +53,8 @@ const int PathConstraintPositionTimeline::PREV_VALUE = -1;
|
|||||||
const int PathConstraintPositionTimeline::VALUE = 1;
|
const int PathConstraintPositionTimeline::VALUE = 1;
|
||||||
|
|
||||||
PathConstraintPositionTimeline::PathConstraintPositionTimeline(int frameCount) : CurveTimeline(frameCount),
|
PathConstraintPositionTimeline::PathConstraintPositionTimeline(int frameCount) : CurveTimeline(frameCount),
|
||||||
_pathConstraintIndex(0) {
|
_pathConstraintIndex(0)
|
||||||
|
{
|
||||||
_frames.setSize(frameCount * ENTRIES, 0);
|
_frames.setSize(frameCount * ENTRIES, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +62,8 @@ 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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
@ -72,14 +74,14 @@ void PathConstraintPositionTimeline::apply(Skeleton &skeleton, float lastTime, f
|
|||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
constraint._position = constraint._data._position;
|
constraint._position = constraint._data._position;
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
constraint._position += (constraint._data._position - constraint._position) * alpha;
|
constraint._position += (constraint._data._position - constraint._position) * alpha;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,15 +95,14 @@ void PathConstraintPositionTimeline::apply(Skeleton &skeleton, float lastTime, f
|
|||||||
position = _frames[frame + PREV_VALUE];
|
position = _frames[frame + PREV_VALUE];
|
||||||
float frameTime = _frames[frame];
|
float frameTime = _frames[frame];
|
||||||
float percent = getCurvePercent(frame / ENTRIES - 1,
|
float percent = getCurvePercent(frame / ENTRIES - 1,
|
||||||
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
||||||
|
|
||||||
position += (_frames[frame + VALUE] - position) * percent;
|
position += (_frames[frame + VALUE] - position) * percent;
|
||||||
}
|
}
|
||||||
if (blend == MixBlend_Setup) {
|
if (blend == MixBlend_Setup)
|
||||||
constraint._position = constraint._data._position + (position - constraint._data._position) * alpha;
|
constraint._position = constraint._data._position + (position - constraint._data._position) * alpha;
|
||||||
} else {
|
else
|
||||||
constraint._position += (position - constraint._position) * alpha;
|
constraint._position += (position - constraint._position) * alpha;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int PathConstraintPositionTimeline::getPropertyId() {
|
int PathConstraintPositionTimeline::getPropertyId() {
|
||||||
|
|||||||
@ -52,7 +52,8 @@ 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(lastTime);
|
||||||
SP_UNUSED(pEvents);
|
SP_UNUSED(pEvents);
|
||||||
SP_UNUSED(direction);
|
SP_UNUSED(direction);
|
||||||
@ -63,14 +64,14 @@ void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, fl
|
|||||||
|
|
||||||
if (time < _frames[0]) {
|
if (time < _frames[0]) {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
case MixBlend_Setup:
|
case MixBlend_Setup:
|
||||||
constraint._spacing = constraint._data._spacing;
|
constraint._spacing = constraint._data._spacing;
|
||||||
return;
|
return;
|
||||||
case MixBlend_First:
|
case MixBlend_First:
|
||||||
constraint._spacing += (constraint._data._spacing - constraint._spacing) * alpha;
|
constraint._spacing += (constraint._data._spacing - constraint._spacing) * alpha;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,16 +85,15 @@ void PathConstraintSpacingTimeline::apply(Skeleton &skeleton, float lastTime, fl
|
|||||||
spacing = _frames[frame + PREV_VALUE];
|
spacing = _frames[frame + PREV_VALUE];
|
||||||
float frameTime = _frames[frame];
|
float frameTime = _frames[frame];
|
||||||
float percent = getCurvePercent(frame / ENTRIES - 1,
|
float percent = getCurvePercent(frame / ENTRIES - 1,
|
||||||
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
1 - (time - frameTime) / (_frames[frame + PREV_TIME] - frameTime));
|
||||||
|
|
||||||
spacing += (_frames[frame + VALUE] - spacing) * percent;
|
spacing += (_frames[frame + VALUE] - spacing) * percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blend == MixBlend_Setup) {
|
if (blend == MixBlend_Setup)
|
||||||
constraint._spacing = constraint._data._spacing + (spacing - constraint._data._spacing) * alpha;
|
constraint._spacing = constraint._data._spacing + (spacing - constraint._data._spacing) * alpha;
|
||||||
} else {
|
else
|
||||||
constraint._spacing += (spacing - constraint._spacing) * alpha;
|
constraint._spacing += (spacing - constraint._spacing) * alpha;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int PathConstraintSpacingTimeline::getPropertyId() {
|
int PathConstraintSpacingTimeline::getPropertyId() {
|
||||||
|
|||||||
@ -52,14 +52,9 @@ bool RTTI::isExactly(const RTTI &rtti) const {
|
|||||||
|
|
||||||
bool RTTI::instanceOf(const RTTI &rtti) const {
|
bool RTTI::instanceOf(const RTTI &rtti) const {
|
||||||
const RTTI *pCompare = this;
|
const RTTI *pCompare = this;
|
||||||
|
|
||||||
while (pCompare) {
|
while (pCompare) {
|
||||||
if (pCompare->_className == rtti._className) {
|
if (pCompare->_className == rtti._className) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
pCompare = pCompare->_pBaseRTTI;
|
pCompare = pCompare->_pBaseRTTI;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,25 +51,26 @@ const int RegionAttachment::BRX = 6;
|
|||||||
const int RegionAttachment::BRY = 7;
|
const int RegionAttachment::BRY = 7;
|
||||||
|
|
||||||
RegionAttachment::RegionAttachment(const String &name) : Attachment(name), HasRendererObject(),
|
RegionAttachment::RegionAttachment(const String &name) : Attachment(name), HasRendererObject(),
|
||||||
_x(0),
|
_x(0),
|
||||||
_y(0),
|
_y(0),
|
||||||
_rotation(0),
|
_rotation(0),
|
||||||
_scaleX(1),
|
_scaleX(1),
|
||||||
_scaleY(1),
|
_scaleY(1),
|
||||||
_width(0),
|
_width(0),
|
||||||
_height(0),
|
_height(0),
|
||||||
_regionOffsetX(0),
|
_regionOffsetX(0),
|
||||||
_regionOffsetY(0),
|
_regionOffsetY(0),
|
||||||
_regionWidth(0),
|
_regionWidth(0),
|
||||||
_regionHeight(0),
|
_regionHeight(0),
|
||||||
_regionOriginalWidth(0),
|
_regionOriginalWidth(0),
|
||||||
_regionOriginalHeight(0),
|
_regionOriginalHeight(0),
|
||||||
_path(),
|
_path(),
|
||||||
_regionU(0),
|
_regionU(0),
|
||||||
_regionV(0),
|
_regionV(0),
|
||||||
_regionU2(0),
|
_regionU2(0),
|
||||||
_regionV2(0),
|
_regionV2(0),
|
||||||
_color(1, 1, 1, 1) {
|
_color(1, 1, 1, 1)
|
||||||
|
{
|
||||||
_vertexOffset.setSize(NUM_UVS, 0);
|
_vertexOffset.setSize(NUM_UVS, 0);
|
||||||
_uvs.setSize(NUM_UVS, 0);
|
_uvs.setSize(NUM_UVS, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user