osu-framework icon indicating copy to clipboard operation
osu-framework copied to clipboard

Using `Loop` to create a loop in the past doesn't work as expected

Open peppy opened this issue 1 year ago • 0 comments

Failing test:

diff --git a/osu.Framework.Tests/Visual/Drawables/TestSceneTransformRewinding.cs b/osu.Framework.Tests/Visual/Drawables/TestSceneTransformRewinding.cs
index 868aa4a69..9de3b6b84 100644
--- a/osu.Framework.Tests/Visual/Drawables/TestSceneTransformRewinding.cs
+++ b/osu.Framework.Tests/Visual/Drawables/TestSceneTransformRewinding.cs
@@ -240,6 +240,34 @@ public void StartInMiddleOfSequence()
             AddAssert("check transform count", () => box.Transforms.Count() == 3);
         }
 
+        [Test]
+        public void RewindWithLoop()
+        {
+            boxTest(box => box.Alpha = 0);
+
+            // move forward to future point in time before adding transforms.
+            checkAtTime(interval * 4, _ => true);
+
+            AddStep("add transforms", () =>
+            {
+                using (box.BeginAbsoluteSequence(0))
+                {
+                    box.ClearTransforms();
+
+                    box.FadeOutFromOne(interval)
+                       .Then()
+                       .FadeIn(interval)
+                       .Loop();
+                }
+            });
+
+            checkAtTime(0, box => Precision.AlmostEquals(box.Alpha, 1));
+            checkAtTime(interval * 1, box => Precision.AlmostEquals(box.Alpha, 0));
+            checkAtTime(interval * 2, box => Precision.AlmostEquals(box.Alpha, 1));
+            checkAtTime(interval * 3, box => Precision.AlmostEquals(box.Alpha, 0));
+            checkAtTime(interval * 4, box => Precision.AlmostEquals(box.Alpha, 1));
+        }
+
         [Test]
         public void RewindBetweenDisparateValues()
         {

We do this in osu! hitobjects (reverse arrows as one example) and expect it to work, at least when RemoveCompletedTransforms is disabled (to allow rewinding).

peppy avatar Jan 02 '25 08:01 peppy