Browse Source

[c] Fixes completion event firing for 0 duration animations. See #1112.

badlogic 7 years ago
parent
commit
1833f4211a
1 changed files with 6 additions and 5 deletions
  1. 6 5
      spine-c/spine-c/src/spine/AnimationState.c

+ 6 - 5
spine-c/spine-c/src/spine/AnimationState.c

@@ -576,7 +576,7 @@ void _spAnimationState_queueEvents (spAnimationState* self, spTrackEntry* entry,
 	spEvent** events;
 	spEvent** events;
 	spEvent* event;
 	spEvent* event;
 	_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
 	_spAnimationState* internal = SUB_CAST(_spAnimationState, self);
-	int i, n;
+	int i, n, complete;
 	float animationStart = entry->animationStart, animationEnd = entry->animationEnd;
 	float animationStart = entry->animationStart, animationEnd = entry->animationEnd;
 	float duration = animationEnd - animationStart;
 	float duration = animationEnd - animationStart;
 	float trackLastWrapped = FMOD(entry->trackLast, duration);
 	float trackLastWrapped = FMOD(entry->trackLast, duration);
@@ -591,10 +591,11 @@ void _spAnimationState_queueEvents (spAnimationState* self, spTrackEntry* entry,
 	}
 	}
 
 
 	/* Queue complete if completed a loop iteration or the animation. */
 	/* Queue complete if completed a loop iteration or the animation. */
-	if (entry->loop ? (trackLastWrapped > FMOD(entry->trackTime, duration))
-				   : (animationTime >= animationEnd && entry->animationLast < animationEnd)) {
-		_spEventQueue_complete(internal->queue, entry);
-	}
+	if (entry->loop)
+		complete = duration == 0 || (trackLastWrapped > FMOD(entry->trackTime, duration));
+	else
+		complete = (animationTime >= animationEnd && entry->animationLast < animationEnd);
+	if (complete) _spEventQueue_complete(internal->queue, entry);
 
 
 	/* Queue events after complete. */
 	/* Queue events after complete. */
 	for (; i < n; i++) {
 	for (; i < n; i++) {