浏览代码

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

badlogic 7 年之前
父节点
当前提交
a3a0648ce7
共有 2 个文件被更改,包括 10 次插入8 次删除
  1. 6 4
      spine-cpp/spine-cpp/src/spine/AnimationState.cpp
  2. 4 4
      spine-sfml/cpp/example/main.cpp

+ 6 - 4
spine-cpp/spine-cpp/src/spine/AnimationState.cpp

@@ -879,10 +879,12 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
 	}
 	}
 
 
 	// Queue complete if completed a loop iteration or the animation.
 	// Queue complete if completed a loop iteration or the animation.
-	if (entry->_loop ? (trackLastWrapped > MathUtil::fmod(entry->_trackTime, duration)) : (
-			animationTime >= animationEnd && entry->_animationLast < animationEnd)) {
-		_queue->complete(entry);
-	}
+	bool complete = false;
+	if (entry->_loop)
+		complete = duration == 0 || (trackLastWrapped > MathUtil::fmod(entry->_trackTime, duration));
+	else
+		complete = animationTime >= animationEnd && entry->_animationLast < animationEnd;
+	if (complete) _queue->complete(entry);
 
 
 	// Queue events after complete.
 	// Queue events after complete.
 	for (; i < n; ++i) {
 	for (; i < n; ++i) {

+ 4 - 4
spine-sfml/cpp/example/main.cpp

@@ -455,10 +455,10 @@ int main () {
 	DebugExtension dbgExtension;
 	DebugExtension dbgExtension;
 	SpineExtension::setInstance(&dbgExtension);
 	SpineExtension::setInstance(&dbgExtension);
 
 
-	// testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
-	// testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f);
-	// testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f);
-	// testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f);
+	testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
+	testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f);
+	testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f);
+	testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f);
 	testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f);
 	testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f);
 	testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine.atlas", 0.5f);
 	testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine.atlas", 0.5f);
 	testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 0.2f);
 	testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 0.2f);