Merge lp:~samuel-thibault/compiz/xysync2 into lp:compiz/0.9.13

Proposed by Samuel thibault
Status: Needs review
Proposed branch: lp:~samuel-thibault/compiz/xysync2
Merge into: lp:compiz/0.9.13
Diff against target: 35 lines (+8/-14)
1 file modified
plugins/ezoom/src/ezoom.cpp (+8/-14)
To merge this branch: bzr merge lp:~samuel-thibault/compiz/xysync2
Reviewer Review Type Date Requested Status
Compiz Maintainers Pending
Review via email: mp+349252@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alberts Muktupāvels (muktupavels) wrote :

Code/change looks good to me, but no idea about math part... Does that really produce expected result?

For example xdiff = 2.5 and ydiff = 3.5. With current code xamount = 2.5 and yamount = 3.5, but with your change amount is now 4.301162634. Is that expected?

lp:~samuel-thibault/compiz/xysync2 updated
4145. By Samuel thibault

Normalize combination of xdiff and ydiff

4146. By Samuel thibault

No need to use the double version of sqrt

Revision history for this message
Samuel thibault (samuel-thibault) wrote :

I, right, I missed normalizing by dividing by sqrt(2), I have now done so.

Revision history for this message
Samuel thibault (samuel-thibault) wrote :

Mmm, but then with e.g. xdiff == 0 the value is then not correct, I have to rethink that.

Unmerged revisions

4146. By Samuel thibault

No need to use the double version of sqrt

4145. By Samuel thibault

Normalize combination of xdiff and ydiff

4144. By Samuel thibault

Synchronize X and Y translation capping

Capping X and Y separately brings some discontinuity visual effect: instead of
terminating the translation at the same time, the axis getting capped (e.g. X)
will terminate the translation later, so that at the point when the other axis
(here, Y) is finished translating, there is a discontinuity in the movement: we
suddenly have only X translation, and no Y translation any more. This does not
look very smooth.

This changes it by simply capping both axis at the same time.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/ezoom/src/ezoom.cpp'
2--- plugins/ezoom/src/ezoom.cpp 2017-12-05 14:45:06 +0000
3+++ plugins/ezoom/src/ezoom.cpp 2018-07-14 08:18:26 +0000
4@@ -308,23 +308,17 @@
5
6 float xadjust = xdiff * 0.002f;
7 float yadjust = ydiff * 0.002f;
8- float xamount = fabs (xdiff);
9- float yamount = fabs (ydiff);
10-
11- if (xamount < 1.0f)
12- xamount = 1.0f;
13- else if (xamount > 5.0)
14- xamount = 5.0f;
15-
16- if (yamount < 1.0f)
17- yamount = 1.0f;
18- else if (yamount > 5.0)
19- yamount = 5.0f;
20+ float amount = sqrtf (xdiff * xdiff + ydiff * ydiff) / sqrtf (2.);
21+
22+ if (amount < 1.0f)
23+ amount = 1.0f;
24+ else if (amount > 5.0)
25+ amount = 5.0f;
26
27 zooms.at (out).xVelocity =
28- (xamount * zooms.at (out).xVelocity + xadjust) / (xamount + 1.0f);
29+ (amount * zooms.at (out).xVelocity + xadjust) / (amount + 1.0f);
30 zooms.at (out).yVelocity =
31- (yamount * zooms.at (out).yVelocity + yadjust) / (yamount + 1.0f);
32+ (amount * zooms.at (out).yVelocity + yadjust) / (amount + 1.0f);
33
34 if ((fabs(xdiff) < 0.1f && fabs (zooms.at (out).xVelocity) < 0.005f) &&
35 (fabs(ydiff) < 0.1f && fabs (zooms.at (out).yVelocity) < 0.005f))

Subscribers

People subscribed via source and target branches