From f0153ae8b12cc68ed6e38a1d93b83bb235b5e501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Casafranca?= Date: Sun, 10 Sep 2017 14:52:46 +0200 Subject: Fix animation local time calculation when changing playbackRate Animation local time was computed in absolute mode, as a scale of the global time that has passed since the start of the animation. Now is computed relative to the last local time, as the last local time + a scale of the elapsed global time. Change-Id: I5c29002602a5184174618ac7755ec94f5c7a328f Reviewed-by: Sean Harmer --- tests/manual/animation-keyframe-blendtree/main.qml | 26 +++++++++++++++++++--- tests/manual/animation-keyframe-simple/main.qml | 22 +++++++++++++++++- 2 files changed, 44 insertions(+), 4 deletions(-) (limited to 'tests/manual') diff --git a/tests/manual/animation-keyframe-blendtree/main.qml b/tests/manual/animation-keyframe-blendtree/main.qml index 23aba4b79..3d7fa47e5 100644 --- a/tests/manual/animation-keyframe-blendtree/main.qml +++ b/tests/manual/animation-keyframe-blendtree/main.qml @@ -75,16 +75,36 @@ DefaultSceneEntity { shininess: 50 }, ObjectPicker { - onClicked: blendedAnimator.running = true + onClicked: { + if (blendedAnimator.running == false) { + blendedAnimator.running = true; + } else { + switch (pick.button) { + case PickEvent.RightButton: + animatorClock.playbackRate *= 2.0; + break; + case PickEvent.LeftButton: + animatorClock.playbackRate /= 2.0; + break; + default: + break; + } + } + } }, BlendedClipAnimator { id: blendedAnimator - loops: 2 + loops: 3 + + clock: Clock { + id: animatorClock + playbackRate: 0.5 + } onRunningChanged: console.log("running = " + running) blendTree: LerpClipBlend { - blendFactor: 0.2 + blendFactor: 0.8 startClip: ClipBlendValue { clip: AnimationClipLoader { source: "sliding-cube.json" } } diff --git a/tests/manual/animation-keyframe-simple/main.qml b/tests/manual/animation-keyframe-simple/main.qml index 79fb75fbd..9246f2467 100644 --- a/tests/manual/animation-keyframe-simple/main.qml +++ b/tests/manual/animation-keyframe-simple/main.qml @@ -75,13 +75,33 @@ DefaultSceneEntity { shininess: 50 }, ObjectPicker { - onClicked: animator.running = true + onClicked: { + if (animator.running == false) { + animator.running = true; + } else { + switch (pick.button) { + case PickEvent.RightButton: + animationClock.playbackRate *= 2.0; + break; + case PickEvent.LeftButton: + animationClock.playbackRate /= 2.0; + break; + default: + break; + } + } + } }, ClipAnimator { id: animator loops: 3 onRunningChanged: console.log("running = " + running) + clock: Clock { + id: animationClock + playbackRate: 1 + } + clip: AnimationClipLoader { source: "cubeanimation.json" onDurationChanged: console.log("duration = " + duration) -- cgit v1.2.3