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) {
|
||||
for (ii = 0; ii < timelineCount; 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);
|
||||
} else {
|
||||
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)
|
||||
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, mix, timelineBlend,
|
||||
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);
|
||||
else
|
||||
spTimeline_apply(timeline, skeleton, animationLast, applyTime, applyEvents, &internal->eventsCount,
|
||||
@ -536,7 +536,7 @@ float _spAnimationState_applyMixingFrom(spAnimationState *self, spTrackEntry *to
|
||||
|
||||
switch (timelineMode->items[i]) {
|
||||
case SUBSEQUENT:
|
||||
if (!drawOrder && timeline->propertyIds[0] == SP_PROPERTY_DRAWORDER) continue;
|
||||
if (!drawOrder && timeline->type == SP_TIMELINE_DRAWORDER) continue;
|
||||
timelineBlend = blend;
|
||||
alpha = alphaMix;
|
||||
break;
|
||||
@ -559,14 +559,14 @@ float _spAnimationState_applyMixingFrom(spAnimationState *self, spTrackEntry *to
|
||||
break;
|
||||
}
|
||||
from->totalAlpha += alpha;
|
||||
if (timeline->propertyIds[0] == SP_PROPERTY_ROTATE)
|
||||
if (timeline->type == SP_TIMELINE_ROTATE)
|
||||
_spAnimationState_applyRotateTimeline(self, timeline, skeleton, applyTime, alpha, timelineBlend,
|
||||
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,
|
||||
attachments);
|
||||
else {
|
||||
if (drawOrder && timeline->propertyIds[0] == SP_PROPERTY_DRAWORDER &&
|
||||
if (drawOrder && timeline->type == SP_TIMELINE_DRAWORDER &&
|
||||
timelineBlend == SP_MIX_BLEND_SETUP)
|
||||
direction = SP_MIX_DIRECTION_IN;
|
||||
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. */
|
||||
static int binarySearch1(float *values, int valuesLength, float target) {
|
||||
int low = 0, current;
|
||||
int high = valuesLength - 2;
|
||||
if (high == 0) return 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;
|
||||
int i;
|
||||
for (i = 1; i < valuesLength; i++) {
|
||||
if (values[i] > target) return (int) (i - 1);
|
||||
}
|
||||
return 0;
|
||||
return (int) valuesLength - 1;
|
||||
}
|
||||
|
||||
void _spAnimationState_applyAttachmentTimeline(spAnimationState *self, spTimeline *timeline, spSkeleton *skeleton,
|
||||
@ -1079,9 +1071,9 @@ continue_outer:
|
||||
int numIds = timeline->propertyIdsCount;
|
||||
if (!_spAnimationState_addPropertyIDs(state, ids, numIds))
|
||||
timelineMode[i] = SUBSEQUENT;
|
||||
else if (to == 0 || timeline->propertyIds[0] == SP_PROPERTY_ATTACHMENT ||
|
||||
timeline->propertyIds[0] == SP_PROPERTY_DRAWORDER ||
|
||||
timeline->propertyIds[0] == SP_PROPERTY_EVENT ||
|
||||
else if (to == 0 || timeline->type == SP_TIMELINE_ATTACHMENT ||
|
||||
timeline->type == SP_TIMELINE_DRAWORDER ||
|
||||
timeline->type == SP_TIMELINE_EVENT ||
|
||||
!spAnimation_hasTimeline(to->animation, ids, numIds)) {
|
||||
timelineMode[i] = FIRST;
|
||||
} else {
|
||||
|
||||
@ -101,19 +101,19 @@ static int readBoolean(_dataInput *input) {
|
||||
}
|
||||
|
||||
static int readInt(_dataInput *input) {
|
||||
int result = readByte(input);
|
||||
uint32_t result = readByte(input);
|
||||
result <<= 8;
|
||||
result |= readByte(input);
|
||||
result <<= 8;
|
||||
result |= readByte(input);
|
||||
result <<= 8;
|
||||
result |= readByte(input);
|
||||
return result;
|
||||
return (int) result;
|
||||
}
|
||||
|
||||
static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
||||
unsigned char b = readByte(input);
|
||||
int value = b & 0x7F;
|
||||
uint32_t value = b & 0x7F;
|
||||
if (b & 0x80) {
|
||||
b = readByte(input);
|
||||
value |= (b & 0x7F) << 7;
|
||||
@ -123,12 +123,13 @@ static int readVarint(_dataInput *input, int /*bool*/ optimizePositive) {
|
||||
if (b & 0x80) {
|
||||
b = readByte(input);
|
||||
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));
|
||||
return value;
|
||||
if (!optimizePositive)
|
||||
value = ((unsigned int) value >> 1) ^ (~(value & 1));
|
||||
return (int) value;
|
||||
}
|
||||
|
||||
float readFloat(_dataInput *input) {
|
||||
|
||||
@ -282,7 +282,7 @@ static spAnimation *_spSkeletonJson_readAnimation(spSkeletonJson *self, Json *ro
|
||||
spAttachmentTimeline *timeline = spAttachmentTimeline_create(frames, slotIndex);
|
||||
for (keyMap = timelineMap->child, frame = 0; keyMap; keyMap = keyMap->next, ++frame) {
|
||||
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));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user