浏览代码

Fix premature end of animation playing backwards

(cherry picked from commit 826af5b28ad190345cf4daa076a8c552a101ce51)
Pedro J. Estébanez 4 年之前
父节点
当前提交
a45bf288e8
共有 1 个文件被更改,包括 2 次插入5 次删除
  1. 2 5
      scene/animation/animation_player.cpp

+ 2 - 5
scene/animation/animation_player.cpp

@@ -782,13 +782,10 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
 		else if (next_pos > len)
 			next_pos = len;
 
-		// fix delta
-		delta = next_pos - cd.pos;
+		bool backwards = signbit(delta); // Negative zero means playing backwards too
+		delta = next_pos - cd.pos; // Fix delta (after determination of backwards because negative zero is lost here)
 
 		if (&cd == &playback.current) {
-
-			bool backwards = delta < 0;
-
 			if (!backwards && cd.pos <= len && next_pos == len /*&& playback.blend.empty()*/) {
 				//playback finished
 				end_reached = true;