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:
Diffstat (limited to 'source/blender/editors/mask')
-rw-r--r--source/blender/editors/mask/mask_add.c25
-rw-r--r--source/blender/editors/mask/mask_ops.c46
-rw-r--r--source/blender/editors/mask/mask_select.c21
3 files changed, 34 insertions, 58 deletions
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index e43eea35a91..770a53d8691 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -76,8 +76,7 @@ static void setup_vertex_point(Mask *mask,
*/
int point_index = reference_point - spline->points;
int delta = new_point == spline->points ? 1 : -1;
- int i = 0;
- for (i = 0; i < spline->tot_point - 1; i++) {
+ for (int i = 0; i < spline->tot_point - 1; i++) {
MaskSplinePoint *current_point;
point_index += delta;
@@ -199,9 +198,7 @@ static void finSelectedSplinePoint(MaskLayer *mask_layer,
}
while (cur_spline) {
- int i;
-
- for (i = 0; i < cur_spline->tot_point; i++) {
+ for (int i = 0; i < cur_spline->tot_point; i++) {
MaskSplinePoint *cur_point = &cur_spline->points[i];
if (MASKPOINT_ISSEL_ANY(cur_point)) {
@@ -694,19 +691,17 @@ static int create_primitive_from_points(
bContext *C, wmOperator *op, const float (*points)[2], int num_points, char handle_type)
{
ScrArea *area = CTX_wm_area(C);
- Mask *mask;
- MaskLayer *mask_layer;
- MaskSpline *new_spline;
- float scale, location[2], frame_size[2];
- int i, width, height;
int size = RNA_float_get(op->ptr, "size");
+ int width, height;
ED_mask_get_size(area, &width, &height);
- scale = (float)size / max_ii(width, height);
+ float scale = (float)size / max_ii(width, height);
/* Get location in mask space. */
+ float frame_size[2];
frame_size[0] = width;
frame_size[1] = height;
+ float location[2];
RNA_float_get_array(op->ptr, "location", location);
location[0] /= width;
location[1] /= height;
@@ -717,12 +712,12 @@ static int create_primitive_from_points(
location[1] -= 0.5f * scale;
bool added_mask = false;
- mask_layer = ED_mask_layer_ensure(C, &added_mask);
- mask = CTX_data_edit_mask(C);
+ MaskLayer *mask_layer = ED_mask_layer_ensure(C, &added_mask);
+ Mask *mask = CTX_data_edit_mask(C);
ED_mask_select_toggle_all(mask, SEL_DESELECT);
- new_spline = BKE_mask_spline_add(mask_layer);
+ MaskSpline *new_spline = BKE_mask_spline_add(mask_layer);
new_spline->flag = MASK_SPLINE_CYCLIC | SELECT;
new_spline->points = MEM_recallocN(new_spline->points, sizeof(MaskSplinePoint) * num_points);
@@ -731,7 +726,7 @@ static int create_primitive_from_points(
const int spline_index = BKE_mask_layer_shape_spline_to_index(mask_layer, new_spline);
- for (i = 0; i < num_points; i++) {
+ for (int i = 0; i < num_points; i++) {
new_spline->tot_point = i + 1;
MaskSplinePoint *new_point = &new_spline->points[i];
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 51f3a94efde..c9fe03dc599 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -262,15 +262,16 @@ static bool spline_under_mouse_get(const bContext *C,
const float threshold = 19.0f;
ScrArea *area = CTX_wm_area(C);
SpaceClip *sc = CTX_wm_space_clip(C);
- int width, height;
- float pixel_co[2];
float closest_dist_squared = 0.0f;
MaskLayer *closest_layer = NULL;
MaskSpline *closest_spline = NULL;
bool undistort = false;
*r_mask_layer = NULL;
*r_mask_spline = NULL;
+
+ int width, height;
ED_mask_get_size(area, &width, &height);
+ float pixel_co[2];
pixel_co[0] = co[0] * width;
pixel_co[1] = co[1] * height;
if (sc != NULL) {
@@ -285,16 +286,13 @@ static bool spline_under_mouse_get(const bContext *C,
for (MaskSpline *spline = mask_layer->splines.first; spline != NULL; spline = spline->next) {
MaskSplinePoint *points_array;
float min[2], max[2], center[2];
- float dist_squared;
- int i;
- float max_bb_side;
if ((spline->flag & SELECT) == 0) {
continue;
}
points_array = BKE_mask_spline_point_array(spline);
INIT_MINMAX2(min, max);
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point_deform = &points_array[i];
BezTriple *bezt = &point_deform->bezt;
@@ -311,8 +309,8 @@ static bool spline_under_mouse_get(const bContext *C,
center[0] = (min[0] + max[0]) / 2.0f * width;
center[1] = (min[1] + max[1]) / 2.0f * height;
- dist_squared = len_squared_v2v2(pixel_co, center);
- max_bb_side = min_ff((max[0] - min[0]) * width, (max[1] - min[1]) * height);
+ float dist_squared = len_squared_v2v2(pixel_co, center);
+ float max_bb_side = min_ff((max[0] - min[0]) * width, (max[1] - min[1]) * height);
if (dist_squared <= max_bb_side * max_bb_side * 0.5f &&
(closest_spline == NULL || dist_squared < closest_dist_squared)) {
closest_layer = mask_layer;
@@ -350,9 +348,7 @@ static bool spline_under_mouse_get(const bContext *C,
static bool slide_point_check_initial_feather(MaskSpline *spline)
{
- int i;
-
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (point->bezt.weight != 0.0f) {
@@ -569,9 +565,7 @@ static int slide_point_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void slide_point_delta_all_feather(SlidePointData *data, float delta)
{
- int i;
-
- for (i = 0; i < data->spline->tot_point; i++) {
+ for (int i = 0; i < data->spline->tot_point; i++) {
MaskSplinePoint *point = &data->spline->points[i];
MaskSplinePoint *orig_point = &data->orig_spline->points[i];
@@ -584,16 +578,13 @@ static void slide_point_delta_all_feather(SlidePointData *data, float delta)
static void slide_point_restore_spline(SlidePointData *data)
{
- int i;
-
- for (i = 0; i < data->spline->tot_point; i++) {
+ for (int i = 0; i < data->spline->tot_point; i++) {
MaskSplinePoint *point = &data->spline->points[i];
MaskSplinePoint *orig_point = &data->orig_spline->points[i];
- int j;
point->bezt = orig_point->bezt;
- for (j = 0; j < point->tot_uw; j++) {
+ for (int j = 0; j < point->tot_uw; j++) {
point->uw[j] = orig_point->uw[j];
}
}
@@ -818,13 +809,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
else if (data->action == SLIDE_ACTION_SPLINE) {
- int i;
-
if (data->orig_spline == NULL) {
data->orig_spline = BKE_mask_spline_copy(data->spline);
}
- for (i = 0; i < data->spline->tot_point; i++) {
+ for (int i = 0; i < data->spline->tot_point; i++) {
MaskSplinePoint *point = &data->spline->points[i];
add_v2_v2(point->bezt.vec[0], delta);
add_v2_v2(point->bezt.vec[1], delta);
@@ -1330,13 +1319,13 @@ void MASK_OT_cyclic_toggle(wmOperatorType *ot)
static void delete_feather_points(MaskSplinePoint *point)
{
- int i, count = 0;
+ int count = 0;
if (!point->tot_uw) {
return;
}
- for (i = 0; i < point->tot_uw; i++) {
+ for (int i = 0; i < point->tot_uw; i++) {
if ((point->uw[i].flag & SELECT) == 0) {
count++;
}
@@ -1353,7 +1342,7 @@ static void delete_feather_points(MaskSplinePoint *point)
new_uw = MEM_callocN(count * sizeof(MaskSplinePointUW), "new mask uw points");
- for (i = 0; i < point->tot_uw; i++) {
+ for (int i = 0; i < point->tot_uw; i++) {
if ((point->uw[i].flag & SELECT) == 0) {
new_uw[j++] = point->uw[i];
}
@@ -1383,11 +1372,11 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
while (spline) {
const int tot_point_orig = spline->tot_point;
- int i, count = 0;
+ int count = 0;
MaskSpline *next_spline = spline->next;
/* count unselected points */
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (!MASKPOINT_ISSEL_ANY(point)) {
@@ -1409,11 +1398,10 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
}
else {
MaskSplinePoint *new_points;
- int j;
new_points = MEM_callocN(count * sizeof(MaskSplinePoint), "deleteMaskPoints");
- for (i = 0, j = 0; i < tot_point_orig; i++) {
+ for (int i = 0, j = 0; i < tot_point_orig; i++) {
MaskSplinePoint *point = &spline->points[i];
if (!MASKPOINT_ISSEL_ANY(point)) {
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 82d8a1dc85f..cdc6ece1e84 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -55,9 +55,7 @@
/* 'check' select */
bool ED_mask_spline_select_check(const MaskSpline *spline)
{
- int i;
-
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
if (MASKPOINT_ISSEL_ANY(point)) {
@@ -97,8 +95,6 @@ bool ED_mask_select_check(const Mask *mask)
/* 'sel' select */
void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
{
- int i;
-
if (do_select) {
spline->flag |= SELECT;
}
@@ -106,7 +102,7 @@ void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select)
spline->flag &= ~SELECT;
}
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
BKE_mask_point_select_set(point, do_select);
@@ -151,8 +147,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
continue;
}
LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
- int i;
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
BKE_mask_point_select_set(point, !MASKPOINT_ISSEL_ANY(point));
}
@@ -654,7 +649,6 @@ static int circle_select_exec(bContext *C, wmOperator *op)
ARegion *region = CTX_wm_region(C);
Mask *mask = CTX_data_edit_mask(C);
- int i;
float zoomx, zoomy, offset[2], ellipse[2];
int width, height;
@@ -692,7 +686,7 @@ static int circle_select_exec(bContext *C, wmOperator *op)
LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
MaskSplinePoint *point_deform = &points_array[i];
@@ -871,10 +865,9 @@ static int mask_select_more_less(bContext *C, bool more)
LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0;
bool start_sel, end_sel, prev_sel, cur_sel;
- int i;
/* reselect point if any handle is selected to make the result more predictable */
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
BKE_mask_point_select_set(spline->points + i, MASKPOINT_ISSEL_ANY(spline->points + i));
}
@@ -892,7 +885,7 @@ static int mask_select_more_less(bContext *C, bool more)
end_sel = false;
}
- for (i = 0; i < spline->tot_point; i++) {
+ for (int i = 0; i < spline->tot_point; i++) {
if (i == 0 && !cyclic) {
continue;
}
@@ -908,7 +901,7 @@ static int mask_select_more_less(bContext *C, bool more)
}
}
- for (i = spline->tot_point - 1; i >= 0; i--) {
+ for (int i = spline->tot_point - 1; i >= 0; i--) {
if (i == spline->tot_point - 1 && !cyclic) {
continue;
}