Commit 47c9a5f1 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Simplify snapping algorithms: removing redundant floor call and unneeded parens

parent fc2f67c4
...@@ -5818,19 +5818,18 @@ static void canvas_snap_to_grid(t_canvas *x, int xwas, int ywas, int xnew, ...@@ -5818,19 +5818,18 @@ static void canvas_snap_to_grid(t_canvas *x, int xwas, int ywas, int xnew,
/* First, get the distance the selection should be displaced /* First, get the distance the selection should be displaced
in order to align the anchor object with a grid line. */ in order to align the anchor object with a grid line. */
snap_dx = floor((obx + (gsize / 2)) / gsize) * gsize - obx; snap_dx = ((obx + gsize / 2) / gsize) * gsize - obx;
snap_dy = ((oby + gsize / 2) / gsize) * gsize - oby;
snap_dy = floor((oby + (gsize / 2)) / gsize) * gsize - oby; obx = obx / gsize * gsize;
obx = floor(obx / gsize) * gsize; oby = oby / gsize * gsize;
oby = floor(oby / gsize) * gsize;
anchor_xoff = xnew - obx; anchor_xoff = xnew - obx;
anchor_yoff = ynew - oby; anchor_yoff = ynew - oby;
snap_got_anchor = 1; snap_got_anchor = 1;
} }
*dx = floor((xnew - anchor_xoff + gsize / 2) / gsize) * gsize - *dx = ((xnew - anchor_xoff + gsize / 2) / gsize) * gsize -
floor((xwas - anchor_xoff + gsize / 2) / gsize) * gsize + snap_dx; ((xwas - anchor_xoff + gsize / 2) / gsize) * gsize + snap_dx;
*dy = floor((ynew - anchor_yoff + gsize / 2) / gsize) * gsize - *dy = ((ynew - anchor_yoff + gsize / 2) / gsize) * gsize -
floor((ywas - anchor_yoff + gsize / 2) / gsize) * gsize + snap_dy; ((ywas - anchor_yoff + gsize / 2) / gsize) * gsize + snap_dy;
} }
static void delay_move(t_canvas *x) static void delay_move(t_canvas *x)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment