Nux

Merge lp:~nick-dedekind/nux/remove-animation-on-tick into lp:nux

Proposed by Nick Dedekind on 2012-11-25
Status: Merged
Approved by: Francis Ginther on 2012-12-11
Approved revision: 710
Merged at revision: 736
Proposed branch: lp:~nick-dedekind/nux/remove-animation-on-tick
Merge into: lp:nux
Diff against target: 82 lines (+39/-1)
2 files modified
NuxCore/AnimationController.cpp (+11/-1)
tests/gtest-nuxcore-animation.cpp (+28/-0)
To merge this branch: bzr merge lp:~nick-dedekind/nux/remove-animation-on-tick
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2012-12-11
Brandon Schaefer (community) 2012-12-04 Approve on 2012-12-10
Tim Penhey 2012-11-25 Pending
Review via email: mp+136069@code.launchpad.net

Commit Message

Added support for removal of animations during tick.

Description of the Change

= Problem description =

Nux animation framework does not support deleting an animation during a tick cycle.
This is required for chaining animations for LP: #1060948

= The fix =

Do not tick items which have been marked for removal in the animation controller

= Test coverage =

Unit test for removal of animation during tick.

To post a comment you must log in.
Brandon Schaefer (brandontschaefer) wrote :

Looks good to me.

review: Approve
Francis Ginther (fginther) wrote :

Re-approving. I updated the job to use a better test and result collection hook script, but I used the wrong one. The job should be configured to use the correct one now. I'll monitor this MP in case there is another failure.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NuxCore/AnimationController.cpp'
2--- NuxCore/AnimationController.cpp 2012-11-05 21:31:06 +0000
3+++ NuxCore/AnimationController.cpp 2012-11-25 22:22:21 +0000
4@@ -115,7 +115,12 @@
5 for (Animations::iterator i = animations_.begin(),
6 end = animations_.end(); i != end; ++i)
7 {
8- (*i)->Advance(ms_since_last_tick);
9+ // only if it isn't pending.
10+ if (do_not_tick_.empty() ||
11+ do_not_tick_.find((*i)) == do_not_tick_.end())
12+ {
13+ (*i)->Advance(ms_since_last_tick);
14+ }
15 }
16
17 ticking_ = false;
18@@ -129,6 +134,7 @@
19 Remove(i->first);
20 }
21 pending_.clear();
22+ do_not_tick_.clear();
23 }
24
25 long long last_tick_;
26@@ -137,6 +143,9 @@
27 typedef std::vector<std::pair<Animation*, bool>> AnimationActions;
28 AnimationActions pending_;
29 bool ticking_;
30+
31+ typedef std::set<Animation*> DoNotTickActions;
32+ DoNotTickActions do_not_tick_;
33 };
34
35 na::AnimationController::AnimationController(na::TickSource& tick_source)
36@@ -173,6 +182,7 @@
37 if (pimpl->ticking_)
38 {
39 pimpl->pending_.push_back(std::make_pair(animation, false));
40+ pimpl->do_not_tick_.insert(animation);
41 }
42 else
43 {
44
45=== modified file 'tests/gtest-nuxcore-animation.cpp'
46--- tests/gtest-nuxcore-animation.cpp 2012-11-09 01:49:53 +0000
47+++ tests/gtest-nuxcore-animation.cpp 2012-11-25 22:22:21 +0000
48@@ -158,6 +158,34 @@
49 ASSERT_FALSE(controller.HasRunningAnimations());
50 }
51
52+TEST(TestAnimationController, RemoveValueInTick)
53+{
54+ na::TickSource source;
55+ na::AnimationController controller(source);
56+
57+ std::shared_ptr<na::AnimateValue<int>> animation1(new na::AnimateValue<int>(0,100,1000));
58+ std::shared_ptr<na::AnimateValue<int>> animation2(new na::AnimateValue<int>(0,100,1000));
59+
60+ int i = 0;
61+ animation1->updated.connect([&](int)
62+ {
63+ if (++i == 2)
64+ {
65+ animation2.reset();
66+ }
67+ });
68+
69+ animation1->Start();
70+ animation2->Start();
71+ source.tick.emit(10);
72+
73+ ASSERT_THAT(animation1->CurrentState(), Eq(na::Animation::Running));
74+ ASSERT_TRUE(animation2.get() == nullptr);
75+
76+ animation1.reset();
77+ animation2.reset();
78+}
79+
80 TEST(TestAnimation, TestInitialState)
81 {
82 MockAnimation animation;

Subscribers

People subscribed via source and target branches