Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-10-21 04:57:50 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-21 05:03:53 +0300
commita80c1fc011795f4e8461210535e4fd0526b39044 (patch)
tree8988593d16f6aaac7e8d6a7f8bc8680c41bf41f8
parent4e90dff60f465af5f0ed565d4b8946b9fd466b73 (diff)
Cleanup: simplify lasso transform from 17cb2a6da0c88
Access as 2D array, loop forwards over the pointer since it's more common and simpler to read.
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index 72657ca83e2..8357d4c2331 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -690,26 +690,23 @@ int WM_gesture_lasso_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
{
- int x, y;
- short *lasso = gesture->customdata;
+ short(*lasso)[2] = gesture->customdata;
- lasso += (2 * gesture->points - 2);
- x = (event->x - gesture->winrct.xmin - lasso[0]);
- y = (event->y - gesture->winrct.ymin - lasso[1]);
+ const int x = ((event->x - gesture->winrct.xmin) - lasso[gesture->points - 1][0]);
+ const int y = ((event->y - gesture->winrct.ymin) - lasso[gesture->points - 1][1]);
/* move the lasso */
if (gesture->move) {
for (int i = 0; i < gesture->points; i++) {
- lasso[0 - (i * 2)] += x;
- lasso[1 - (i * 2)] += y;
+ lasso[i][0] += x;
+ lasso[i][1] += y;
}
}
- /* make a simple distance check to get a smoother lasso
- * add only when at least 2 pixels between this and previous location */
+ /* Make a simple distance check to get a smoother lasso
+ * add only when at least 2 pixels between this and previous location. */
else if ((x * x + y * y) > pow2f(2.0f * UI_DPI_FAC)) {
- lasso += 2;
- lasso[0] = event->x - gesture->winrct.xmin;
- lasso[1] = event->y - gesture->winrct.ymin;
+ lasso[gesture->points][0] = event->x - gesture->winrct.xmin;
+ lasso[gesture->points][1] = event->y - gesture->winrct.ymin;
gesture->points++;
}
}