mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[c] Backport bugfixes from 4.1
This commit is contained in:
parent
5eeec39224
commit
5b9688b236
@ -417,7 +417,7 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
|
|||||||
if ((i == 0 && mix == 1) || blend == SP_MIX_BLEND_ADD) {
|
if ((i == 0 && mix == 1) || blend == SP_MIX_BLEND_ADD) {
|
||||||
for (ii = 0; ii < timelineCount; ii++) {
|
for (ii = 0; ii < timelineCount; ii++) {
|
||||||
timeline = timelines[ii];
|
timeline = timelines[ii];
|
||||||
if (timeline->propertyIds[0] == SP_PROPERTY_ATTACHMENT) {
|
if (timeline->type == SP_TIMELINE_ATTACHMENT) {
|
||||||
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, blend, -1);
|
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, blend, -1);
|
||||||
} else {
|
} else {
|
||||||
spTimeline_apply(timelines[ii], skeleton, animationLast, applyTime, applyEvents,
|
spTimeline_apply(timelines[ii], skeleton, animationLast, applyTime, applyEvents,
|
||||||
@ -437,7 +437,7 @@ int spAnimationState_apply(spAnimationState *self, spSkeleton *skeleton) {
|
|||||||
if (timeline->propertyIds[0] == SP_PROPERTY_ROTATE)
|
if (timeline->propertyIds[0] == SP_PROPERTY_ROTATE)
|
||||||
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, mix, timelineBlend,
|
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, mix, timelineBlend,
|
||||||
timelinesRotation, ii << 1, firstFrame);
|
timelinesRotation, ii << 1, firstFrame);
|
||||||
else if (timeline->propertyIds[0] == SP_PROPERTY_ATTACHMENT)
|
else if (timeline->type == SP_TIMELINE_ATTACHMENT)
|
||||||
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, timelineBlend, -1);
|
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, timelineBlend, -1);
|
||||||
else
|
else
|
||||||
spTimeline_apply(timeline, skeleton, animationLast, applyTime, applyEvents, &internal->eventsCount,
|
spTimeline_apply(timeline, skeleton, animationLast, applyTime, applyEvents, &internal->eventsCount,
|
||||||
@ -536,7 +536,7 @@ float _spAnimationState_applyMixingFrom(spAnimationState *self, spTrackEntry *to
|
|||||||
|
|
||||||
switch (timelineMode->items[i]) {
|
switch (timelineMode->items[i]) {
|
||||||
case SUBSEQUENT:
|
case SUBSEQUENT:
|
||||||
if (!drawOrder && timeline->propertyIds[0] == SP_PROPERTY_DRAWORDER) continue;
|
if (!drawOrder && timeline->type == SP_TIMELINE_DRAWORDER) continue;
|
||||||
timelineBlend = blend;
|
timelineBlend = blend;
|
||||||
alpha = alphaMix;
|
alpha = alphaMix;
|
||||||
break;
|
break;
|
||||||
@ -559,14 +559,14 @@ float _spAnimationState_applyMixingFrom(spAnimationState *self, spTrackEntry *to
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
from->totalAlpha += alpha;
|
from->totalAlpha += alpha;
|
||||||
if (timeline->propertyIds[0] == SP_PROPERTY_ROTATE)
|
if (timeline->type == SP_TIMELINE_ROTATE)
|
||||||
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, alpha, timelineBlend,
|
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, alpha, timelineBlend,
|
||||||
timelinesRotation, i << 1, firstFrame);
|
timelinesRotation, i << 1, firstFrame);
|
||||||
else if (timeline->propertyIds[0] == SP_PROPERTY_ATTACHMENT)
|
else if (timeline->type == SP_TIMELINE_ATTACHMENT)
|
||||||
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, timelineBlend,
|
_spAnimationState_applyAttachmentTimeline(self, timeline, skeleton, applyTime, timelineBlend,
|
||||||
attachments);
|
attachments);
|
||||||
else {
|
else {
|
||||||
if (drawOrder && timeline->propertyIds[0] == SP_PROPERTY_DRAWORDER &&
|
if (drawOrder && timeline->type == SP_TIMELINE_DRAWORDER &&
|
||||||
timelineBlend == SP_MIX_BLEND_SETUP)
|
timelineBlend == SP_MIX_BLEND_SETUP)
|
||||||
direction = SP_MIX_DIRECTION_IN;
|
direction = SP_MIX_DIRECTION_IN;
|
||||||
spTimeline_apply(timeline, skeleton, animationLast, applyTime, events, &internal->eventsCount,
|
spTimeline_apply(timeline, skeleton, animationLast, applyTime, events, &internal->eventsCount,
|
||||||
@ -593,19 +593,11 @@ _spAnimationState_setAttachment(spAnimationState *self, spSkeleton *skeleton, sp
|
|||||||
|
|
||||||
/* @param target After the first and before the last entry. */
|
/* @param target After the first and before the last entry. */
|
||||||
static int binarySearch1(float *values, int valuesLength, float target) {
|
static int binarySearch1(float *values, int valuesLength, float target) {
|
||||||
int low = 0, current;
|
int i;
|
||||||
int high = valuesLength - 2;
|
for (i = 1; i < valuesLength; i++) {
|
||||||
if (high == 0) return 1;
|
if (values[i] > target) return (int) (i - 1);
|
||||||
current = high >> 1;
|
|
||||||
while (1) {
|
|
||||||
if (values[(current + 1)] <= target)
|
|
||||||
low = current + 1;
|
|
||||||
else
|
|
||||||
high = current;
|
|
||||||
if (low == high) return low + 1;
|
|
||||||
current = (low + high) >> 1;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return (int) valuesLength - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _spAnimationState_applyAttachmentTimeline(spAnimationState *self, spTimeline *timeline, spSkeleton *skeleton,
|
void _spAnimationState_applyAttachmentTimeline(spAnimationState *self, spTimeline *timeline, spSkeleton *skeleton,
|
||||||
@ -1079,9 +1071,9 @@ continue_outer:
|
|||||||
int numIds = timeline->propertyIdsCount;
|
int numIds = timeline->propertyIdsCount;
|
||||||
if (!_spAnimationState_addPropertyIDs(state, ids, numIds))
|
if (!_spAnimationState_addPropertyIDs(state, ids, numIds))
|
||||||
timelineMode[i] = SUBSEQUENT;
|
timelineMode[i] = SUBSEQUENT;
|
||||||
else if (to == 0 || timeline->propertyIds[0] == SP_PROPERTY_ATTACHMENT ||
|
else if (to == 0 || timeline->type == SP_TIMELINE_ATTACHMENT ||
|
||||||
timeline->propertyIds[0] == SP_PROPERTY_DRAWORDER ||
|
timeline->type == SP_TIMELINE_DRAWORDER ||
|
||||||
timeline->propertyIds[0] == SP_PROPERTY_EVENT ||
|
timeline->type == SP_TIMELINE_EVENT ||
|
||||||
!spAnimation_hasTimeline(to->animation, ids, numIds)) {
|
!spAnimation_hasTimeline(to->animation, ids, numIds)) {
|
||||||
timelineMode[i] = FIRST;
|
timelineMode[i] = FIRST;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -101,19 +101,19 @@ static int readBoolean(_dataInput *input) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int readInt(_dataInput *input) {
|
static int readInt(_dataInput *input) {
|
||||||
int result = readByte(input);
|
uint32_t result = readByte(input);
|
||||||
result <<= 8;
|
result <<= 8;
|
||||||
result |= readByte(input);
|
result |= readByte(input);
|
||||||
result <<= 8;
|
result <<= 8;
|
||||||
result |= readByte(input);
|
result |= readByte(input);
|
||||||
result <<= 8;
|
result <<= 8;
|
||||||
result |= readByte(input);
|
result |= readByte(input);
|
||||||
return result;
|
return (int) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
||||||
unsigned char b = readByte(input);
|
unsigned char b = readByte(input);
|
||||||
int value = b & 0x7F;
|
uint32_t value = b & 0x7F;
|
||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 7;
|
value |= (b & 0x7F) << 7;
|
||||||
@ -123,12 +123,13 @@ static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
|||||||
if (b & 0x80) {
|
if (b & 0x80) {
|
||||||
b = readByte(input);
|
b = readByte(input);
|
||||||
value |= (b & 0x7F) << 21;
|
value |= (b & 0x7F) << 21;
|
||||||
if (b & 0x80) value |= (readByte(input) & 0x7F) << 28;
|
if (b & 0x80) value |= (uint32_t) (readByte(input) & 0x7F) << 28;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!optimizePositive) value = (((unsigned int) value >> 1) ^ -(value & 1));
|
if (!optimizePositive)
|
||||||
return value;
|
value = ((unsigned int) value >> 1) ^ (~(value & 1));
|
||||||
|
return (int) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float readFloat(_dataInput *input) {
|
float readFloat(_dataInput *input) {
|
||||||
|
|||||||
@ -282,7 +282,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
|
|||||||
spAttachmentTimeline *timeline = spAttachmentTimeline_create(frames, slotIndex);
|
spAttachmentTimeline *timeline = spAttachmentTimeline_create(frames, slotIndex);
|
||||||
for (keyMap = timelineMap->child, frame = 0; keyMap; keyMap = keyMap->next, ++frame) {
|
for (keyMap = timelineMap->child, frame = 0; keyMap; keyMap = keyMap->next, ++frame) {
|
||||||
spAttachmentTimeline_setFrame(timeline, frame, Json_getFloat(keyMap, "time", 0),
|
spAttachmentTimeline_setFrame(timeline, frame, Json_getFloat(keyMap, "time", 0),
|
||||||
Json_getItem(keyMap, "name")->valueString);
|
Json_getItem(keyMap, "name") ? Json_getItem(keyMap, "name")->valueString : NULL);
|
||||||
}
|
}
|
||||||
spTimelineArray_add(timelines, SUPER(timeline));
|
spTimelineArray_add(timelines, SUPER(timeline));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user