Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ebc0fd0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "We might have delta zero when we change segment" into main

parents a3c69498 988ae15e
Loading
Loading
Loading
Loading
+16 −14
Original line number Diff line number Diff line
@@ -495,7 +495,8 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static

                        val delta = afterBreakpoint - beforeBreakpoint
                        val deltaIsFinite = delta.fastIsFinite()
                        if (deltaIsFinite && delta != 0f) {
                        if (deltaIsFinite) {
                            if (delta != 0f) {
                                // There is a discontinuity on this breakpoint, that needs to be
                                // animated. The delta is pushed to the spring, to consume the
                                // discontinuity over time.
@@ -505,11 +506,12 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static
                                        velocityDelta = initialSpringVelocity,
                                    )

                            // When *first* crossing a discontinuity in a given frame, the static
                            // mapped velocity observed during previous frame is added as initial
                            // velocity to the spring. This is done ot most once per frame, and only
                            // if there is an actual discontinuity.
                                // When *first* crossing a discontinuity in a given frame, the
                                // static mapped velocity observed during previous frame is added as
                                // initial velocity to the spring. This is done ot most once per
                                // frame, and only if there is an actual discontinuity.
                                initialSpringVelocity = 0f
                            }
                        } else {
                            // The before and / or after mapping produced an non-finite number,
                            // which is not allowed. This intentionally crashes eng-builds, since
+82 −0
Original line number Diff line number Diff line
{
  "frame_ids": [
    0,
    16,
    32,
    48
  ],
  "features": [
    {
      "name": "input",
      "type": "float",
      "data_points": [
        0,
        0.5,
        1,
        1
      ]
    },
    {
      "name": "gestureDirection",
      "type": "string",
      "data_points": [
        "Max",
        "Max",
        "Max",
        "Max"
      ]
    },
    {
      "name": "output",
      "type": "float",
      "data_points": [
        0,
        0,
        0,
        0
      ]
    },
    {
      "name": "outputTarget",
      "type": "float",
      "data_points": [
        0,
        0,
        0,
        0
      ]
    },
    {
      "name": "outputSpring",
      "type": "springParameters",
      "data_points": [
        {
          "stiffness": 100000,
          "dampingRatio": 1
        },
        {
          "stiffness": 700,
          "dampingRatio": 0.9
        },
        {
          "stiffness": 700,
          "dampingRatio": 0.9
        },
        {
          "stiffness": 700,
          "dampingRatio": 0.9
        }
      ]
    },
    {
      "name": "isStable",
      "type": "boolean",
      "data_points": [
        true,
        true,
        true,
        true
      ]
    }
  ]
}
 No newline at end of file
+7 −9
Original line number Diff line number Diff line
@@ -111,6 +111,13 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
            awaitStable()
        }

    @Test
    fun segmentChange_inMaxDirection_zeroDelta() =
        motion.goldenTest(spec = specBuilder(Mapping.Zero) { fixedValueFromCurrent(0.5f) }) {
            animateValueTo(1f, changePerFrame = 0.5f)
            awaitStable()
        }

    @Test
    fun segmentChange_inMinDirection_animatedWhenReachingBreakpoint() =
        motion.goldenTest(
@@ -198,9 +205,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
        ) {
            animateValueTo(21f, changePerFrame = 3f)
            awaitStable()

            // TODO(b/420622452) This test should not produce a WTF log.
            wtfLog.removeLoggedFailures()
        }

    @Test
@@ -214,9 +218,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
        ) {
            animateValueTo(30f, changePerFrame = 3f)
            awaitStable()

            // TODO(b/420622452) This test should not produce a WTF log.
            wtfLog.removeLoggedFailures()
        }

    @Test
@@ -248,9 +249,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def
            awaitStable()
            animateValueTo(3f)
            awaitStable()

            // TODO(b/420622452) This test should not produce a WTF log.
            wtfLog.removeLoggedFailures()
        }

    @Test