code cleanup: pass mouse position as int[2] rather then wmEvent
[blender.git] / source / blender / editors / mask / mask_add.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2012 Blender Foundation.
19  * All rights reserved.
20  *
21  *
22  * Contributor(s): Blender Foundation,
23  *                 Sergey Sharybin
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file blender/editors/mask/mask_add.c
29  *  \ingroup edmask
30  */
31
32 #include "MEM_guardedalloc.h"
33
34 #include "BLI_math.h"
35
36 #include "BKE_context.h"
37 #include "BKE_depsgraph.h"
38 #include "BKE_mask.h"
39
40 #include "DNA_scene_types.h"
41 #include "DNA_screen_types.h"
42 #include "DNA_mask_types.h"
43 #include "DNA_object_types.h"  /* SELECT */
44
45 #include "WM_api.h"
46 #include "WM_types.h"
47
48 #include "ED_mask.h"  /* own include */
49
50 #include "RNA_access.h"
51 #include "RNA_define.h"
52
53 #include "mask_intern.h"  /* own include */
54
55
56 static int find_nearest_diff_point(const bContext *C, Mask *mask, const float normal_co[2], int threshold, int feather,
57                                    MaskLayer **masklay_r, MaskSpline **spline_r, MaskSplinePoint **point_r,
58                                    float *u_r, float tangent[2],
59                                    const short use_deform)
60 {
61         ScrArea *sa = CTX_wm_area(C);
62         ARegion *ar = CTX_wm_region(C);
63
64         MaskLayer *masklay, *point_masklay;
65         MaskSpline *point_spline;
66         MaskSplinePoint *point = NULL;
67         float dist, co[2];
68         int width, height;
69         float u;
70         float scalex, scaley, aspx, aspy;
71
72         ED_mask_get_size(sa, &width, &height);
73         ED_mask_get_aspect(sa, ar, &aspx, &aspy);
74         ED_mask_pixelspace_factor(sa, ar, &scalex, &scaley);
75
76         co[0] = normal_co[0] * scalex;
77         co[1] = normal_co[1] * scaley;
78
79         for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
80                 MaskSpline *spline;
81
82                 if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
83                         continue;
84                 }
85
86                 for (spline = masklay->splines.first; spline; spline = spline->next) {
87                         int i;
88                         MaskSplinePoint *cur_point;
89
90                         for (i = 0, cur_point = use_deform ? spline->points_deform : spline->points;
91                              i < spline->tot_point;
92                              i++, cur_point++)
93                         {
94                                 float *diff_points;
95                                 int tot_diff_point;
96
97                                 diff_points = BKE_mask_point_segment_diff_with_resolution(spline, cur_point, width, height,
98                                                                                           &tot_diff_point);
99
100                                 if (diff_points) {
101                                         int i, tot_feather_point, tot_point;
102                                         float *feather_points = NULL, *points;
103
104                                         if (feather) {
105                                                 feather_points = BKE_mask_point_segment_feather_diff_with_resolution(spline, cur_point,
106                                                                                                                      width, height,
107                                                                                                                      &tot_feather_point);
108
109                                                 points = feather_points;
110                                                 tot_point = tot_feather_point;
111                                         }
112                                         else {
113                                                 points = diff_points;
114                                                 tot_point = tot_diff_point;
115                                         }
116
117                                         for (i = 0; i < tot_point - 1; i++) {
118                                                 float cur_dist, a[2], b[2];
119
120                                                 a[0] = points[2 * i] * scalex;
121                                                 a[1] = points[2 * i + 1] * scaley;
122
123                                                 b[0] = points[2 * i + 2] * scalex;
124                                                 b[1] = points[2 * i + 3] * scaley;
125
126                                                 cur_dist = dist_to_line_segment_v2(co, a, b);
127
128                                                 if (point == NULL || cur_dist < dist) {
129                                                         if (tangent)
130                                                                 sub_v2_v2v2(tangent, &diff_points[2 * i + 2], &diff_points[2 * i]);
131
132                                                         point_masklay = masklay;
133                                                         point_spline = spline;
134                                                         point = use_deform ? &spline->points[(cur_point - spline->points_deform)] : cur_point;
135                                                         dist = cur_dist;
136                                                         u = (float)i / tot_point;
137
138                                                 }
139                                         }
140
141                                         if (feather_points)
142                                                 MEM_freeN(feather_points);
143
144                                         MEM_freeN(diff_points);
145                                 }
146                         }
147                 }
148         }
149
150         if (point && dist < threshold) {
151                 if (masklay_r)
152                         *masklay_r = point_masklay;
153
154                 if (spline_r)
155                         *spline_r = point_spline;
156
157                 if (point_r)
158                         *point_r = point;
159
160                 if (u_r) {
161                         u = BKE_mask_spline_project_co(point_spline, point, u, normal_co, MASK_PROJ_ANY);
162
163                         *u_r = u;
164                 }
165
166                 return TRUE;
167         }
168
169         if (masklay_r)
170                 *masklay_r = NULL;
171
172         if (spline_r)
173                 *spline_r = NULL;
174
175         if (point_r)
176                 *point_r = NULL;
177
178         return FALSE;
179 }
180
181 /******************** add vertex *********************/
182
183 static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline *spline, MaskSplinePoint *new_point,
184                                const float point_co[2], const float tangent[2], const float u,
185                                MaskSplinePoint *reference_point, const short reference_adjacent)
186 {
187         ScrArea *sa = CTX_wm_area(C);
188
189         MaskSplinePoint *prev_point = NULL;
190         MaskSplinePoint *next_point = NULL;
191         BezTriple *bezt;
192         int width, height;
193         float co[3];
194         const float len = 20.0; /* default length of handle in pixel space */
195
196         copy_v2_v2(co, point_co);
197         co[2] = 0.0f;
198
199         ED_mask_get_size(sa, &width, &height);
200
201         /* point coordinate */
202         bezt = &new_point->bezt;
203
204         bezt->h1 = bezt->h2 = HD_ALIGN;
205
206         if (reference_point) {
207                 bezt->h1 = bezt->h2 = MAX2(reference_point->bezt.h2, reference_point->bezt.h1);
208         }
209         else if (reference_adjacent) {
210                 if (spline->tot_point != 1) {
211                         int index = (int)(new_point - spline->points);
212                         prev_point = &spline->points[(index - 1) % spline->tot_point];
213                         next_point = &spline->points[(index + 1) % spline->tot_point];
214
215                         bezt->h1 = bezt->h2 = MAX2(prev_point->bezt.h2, next_point->bezt.h1);
216
217                         /* note, we may want to copy other attributes later, radius? pressure? color? */
218                 }
219         }
220
221         copy_v3_v3(bezt->vec[0], co);
222         copy_v3_v3(bezt->vec[1], co);
223         copy_v3_v3(bezt->vec[2], co);
224
225         /* initial offset for handles */
226         if (spline->tot_point == 1) {
227                 /* first point of splien is aligned horizontally */
228                 bezt->vec[0][0] -= len / width;
229                 bezt->vec[2][0] += len / width;
230         }
231         else if (tangent) {
232                 float vec[2];
233
234                 copy_v2_v2(vec, tangent);
235
236                 vec[0] *= width;
237                 vec[1] *= height;
238
239                 mul_v2_fl(vec, len / len_v2(vec));
240
241                 vec[0] /= width;
242                 vec[1] /= height;
243
244                 sub_v2_v2(bezt->vec[0], vec);
245                 add_v2_v2(bezt->vec[2], vec);
246
247                 if (reference_adjacent) {
248                         BKE_mask_calc_handle_adjacent_interp(spline, new_point, u);
249                 }
250         }
251         else {
252
253                 /* calculating auto handles works much nicer */
254 #if 0
255                 /* next points are aligning in the direction of previous/next point */
256                 MaskSplinePoint *point;
257                 float v1[2], v2[2], vec[2];
258                 float dir = 1.0f;
259
260                 if (new_point == spline->points) {
261                         point = new_point + 1;
262                         dir = -1.0f;
263                 }
264                 else
265                         point = new_point - 1;
266
267                 if (spline->tot_point < 3) {
268                         v1[0] = point->bezt.vec[1][0] * width;
269                         v1[1] = point->bezt.vec[1][1] * height;
270
271                         v2[0] = new_point->bezt.vec[1][0] * width;
272                         v2[1] = new_point->bezt.vec[1][1] * height;
273                 }
274                 else {
275                         if (new_point == spline->points) {
276                                 v1[0] = spline->points[1].bezt.vec[1][0] * width;
277                                 v1[1] = spline->points[1].bezt.vec[1][1] * height;
278
279                                 v2[0] = spline->points[spline->tot_point - 1].bezt.vec[1][0] * width;
280                                 v2[1] = spline->points[spline->tot_point - 1].bezt.vec[1][1] * height;
281                         }
282                         else {
283                                 v1[0] = spline->points[0].bezt.vec[1][0] * width;
284                                 v1[1] = spline->points[0].bezt.vec[1][1] * height;
285
286                                 v2[0] = spline->points[spline->tot_point - 2].bezt.vec[1][0] * width;
287                                 v2[1] = spline->points[spline->tot_point - 2].bezt.vec[1][1] * height;
288                         }
289                 }
290
291                 sub_v2_v2v2(vec, v1, v2);
292                 mul_v2_fl(vec, len * dir / len_v2(vec));
293
294                 vec[0] /= width;
295                 vec[1] /= height;
296
297                 add_v2_v2(bezt->vec[0], vec);
298                 sub_v2_v2(bezt->vec[2], vec);
299 #else
300                 BKE_mask_calc_handle_point_auto(spline, new_point, TRUE);
301                 BKE_mask_calc_handle_adjacent_interp(spline, new_point, u);
302
303 #endif
304         }
305
306         BKE_mask_parent_init(&new_point->parent);
307
308         /* select new point */
309         MASKPOINT_SEL_ALL(new_point);
310         ED_mask_select_flush_all(mask);
311 }
312
313
314 /* **** add extrude vertex **** */
315
316 static void finSelectedSplinePoint(MaskLayer *masklay, MaskSpline **spline, MaskSplinePoint **point, short check_active)
317 {
318         MaskSpline *cur_spline = masklay->splines.first;
319
320         *spline = NULL;
321         *point = NULL;
322
323         if (check_active) {
324                 if (masklay->act_spline && masklay->act_point && MASKPOINT_ISSEL_ANY(masklay->act_point)) {
325                         *spline = masklay->act_spline;
326                         *point = masklay->act_point;
327                         return;
328                 }
329         }
330
331         while (cur_spline) {
332                 int i;
333
334                 for (i = 0; i < cur_spline->tot_point; i++) {
335                         MaskSplinePoint *cur_point = &cur_spline->points[i];
336
337                         if (MASKPOINT_ISSEL_ANY(cur_point)) {
338                                 if (*spline != NULL && *spline != cur_spline) {
339                                         *spline = NULL;
340                                         *point = NULL;
341                                         return;
342                                 }
343                                 else if (*point) {
344                                         *point = NULL;
345                                 }
346                                 else {
347                                         *spline = cur_spline;
348                                         *point = cur_point;
349                                 }
350                         }
351                 }
352
353                 cur_spline = cur_spline->next;
354         }
355 }
356
357 /* **** add subdivide vertex **** */
358
359 static void mask_spline_add_point_at_index(MaskSpline *spline, int point_index)
360 {
361         MaskSplinePoint *new_point_array;
362
363         new_point_array = MEM_callocN(sizeof(MaskSplinePoint) * (spline->tot_point + 1), "add mask vert points");
364
365         memcpy(new_point_array, spline->points, sizeof(MaskSplinePoint) * (point_index + 1));
366         memcpy(new_point_array + point_index + 2, spline->points + point_index + 1,
367                sizeof(MaskSplinePoint) * (spline->tot_point - point_index - 1));
368
369         MEM_freeN(spline->points);
370         spline->points = new_point_array;
371         spline->tot_point++;
372 }
373
374 static int add_vertex_subdivide(const bContext *C, Mask *mask, const float co[2])
375 {
376         MaskLayer *masklay;
377         MaskSpline *spline;
378         MaskSplinePoint *point = NULL;
379         const float threshold = 9;
380         float tangent[2];
381         float u;
382
383         if (find_nearest_diff_point(C, mask, co, threshold, FALSE, &masklay, &spline, &point, &u, tangent, TRUE)) {
384                 MaskSplinePoint *new_point;
385                 int point_index = point - spline->points;
386
387                 ED_mask_select_toggle_all(mask, SEL_DESELECT);
388
389                 mask_spline_add_point_at_index(spline, point_index);
390
391                 new_point = &spline->points[point_index + 1];
392
393                 setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE);
394
395                 /* TODO - we could pass the spline! */
396                 BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, TRUE);
397
398                 masklay->act_point = new_point;
399
400                 WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
401
402                 return TRUE;
403         }
404
405         return FALSE;
406 }
407
408 static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, const float co[2])
409 {
410         MaskSpline *spline;
411         MaskSplinePoint *point;
412         MaskSplinePoint *new_point = NULL, *ref_point = NULL;
413
414         /* check on which side we want to add the point */
415         int point_index;
416         float tangent_point[2];
417         float tangent_co[2];
418         int do_cyclic_correct = FALSE;
419         int do_recalc_src = FALSE;  /* when extruding from endpoints only */
420         int do_prev;                /* use prev point rather then next?? */
421
422         if (!masklay) {
423                 return FALSE;
424         }
425         else {
426                 finSelectedSplinePoint(masklay, &spline, &point, TRUE);
427         }
428
429         ED_mask_select_toggle_all(mask, SEL_DESELECT);
430
431         point_index = (point - spline->points);
432
433         MASKPOINT_DESEL_ALL(point);
434
435         if ((spline->flag & MASK_SPLINE_CYCLIC) ||
436             (point_index > 0 && point_index != spline->tot_point - 1))
437         {
438                 BKE_mask_calc_tangent_polyline(spline, point, tangent_point);
439                 sub_v2_v2v2(tangent_co, co, point->bezt.vec[1]);
440
441                 if (dot_v2v2(tangent_point, tangent_co) < 0.0f) {
442                         do_prev = TRUE;
443                 }
444                 else {
445                         do_prev = FALSE;
446                 }
447         }
448         else if (((spline->flag & MASK_SPLINE_CYCLIC) == 0) && (point_index == 0)) {
449                 do_prev = TRUE;
450                 do_recalc_src = TRUE;
451         }
452         else if (((spline->flag & MASK_SPLINE_CYCLIC) == 0) && (point_index == spline->tot_point - 1)) {
453                 do_prev = FALSE;
454                 do_recalc_src = TRUE;
455         }
456         else {
457                 do_prev = FALSE;  /* quiet warning */
458                 /* should never get here */
459                 BLI_assert(0);
460         }
461
462         /* use the point before the active one */
463         if (do_prev) {
464                 point_index--;
465                 if (point_index < 0) {
466                         point_index += spline->tot_point; /* wrap index */
467                         if ((spline->flag & MASK_SPLINE_CYCLIC) == 0) {
468                                 do_cyclic_correct = TRUE;
469                                 point_index = 0;
470                         }
471                 }
472         }
473
474 //              print_v2("", tangent_point);
475 //              printf("%d\n", point_index);
476
477         mask_spline_add_point_at_index(spline, point_index);
478
479         if (do_cyclic_correct) {
480                 ref_point = &spline->points[point_index + 1];
481                 new_point = &spline->points[point_index];
482                 *ref_point = *new_point;
483                 memset(new_point, 0, sizeof(*new_point));
484         }
485         else {
486                 ref_point = &spline->points[point_index];
487                 new_point = &spline->points[point_index + 1];
488         }
489
490         masklay->act_point = new_point;
491
492         setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE);
493
494         if (masklay->splines_shapes.first) {
495                 point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
496                 BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, TRUE, TRUE);
497         }
498
499         if (do_recalc_src) {
500                 /* TODO, update keyframes in time */
501                 BKE_mask_calc_handle_point_auto(spline, ref_point, FALSE);
502         }
503
504         WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
505
506         return TRUE;
507 }
508
509 static int add_vertex_new(const bContext *C, Mask *mask, MaskLayer *masklay, const float co[2])
510 {
511         MaskSpline *spline;
512         MaskSplinePoint *point;
513         MaskSplinePoint *new_point = NULL, *ref_point = NULL;
514
515         if (!masklay) {
516                 /* if there's no masklay currently operationg on, create new one */
517                 masklay = BKE_mask_layer_new(mask, "");
518                 mask->masklay_act = mask->masklay_tot - 1;
519                 spline = NULL;
520                 point = NULL;
521         }
522         else {
523                 finSelectedSplinePoint(masklay, &spline, &point, TRUE);
524         }
525
526         ED_mask_select_toggle_all(mask, SEL_DESELECT);
527
528         if (!spline) {
529                 /* no selected splines in active masklay, create new spline */
530                 spline = BKE_mask_spline_add(masklay);
531         }
532
533         masklay->act_spline = spline;
534         new_point = spline->points;
535
536         masklay->act_point = new_point;
537
538         setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE);
539
540         {
541                 int point_index = (((int)(new_point - spline->points) + 0) % spline->tot_point);
542                 BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, TRUE, TRUE);
543         }
544
545         WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
546
547         return TRUE;
548 }
549
550 static int add_vertex_exec(bContext *C, wmOperator *op)
551 {
552         Mask *mask = CTX_data_edit_mask(C);
553         MaskLayer *masklay;
554
555         float co[2];
556
557         masklay = BKE_mask_layer_active(mask);
558
559         if (masklay && masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
560                 masklay = NULL;
561         }
562
563         RNA_float_get_array(op->ptr, "location", co);
564
565         if (masklay && masklay->act_point && MASKPOINT_ISSEL_ANY(masklay->act_point)) {
566
567                 /* cheap trick - double click for cyclic */
568                 MaskSpline *spline = masklay->act_spline;
569                 MaskSplinePoint *point = masklay->act_point;
570
571                 int is_sta = (point == spline->points);
572                 int is_end = (point == &spline->points[spline->tot_point - 1]);
573
574                 /* then check are we overlapping the mouse */
575                 if ((is_sta || is_end) && equals_v2v2(co, point->bezt.vec[1])) {
576                         if (spline->flag & MASK_SPLINE_CYCLIC) {
577                                 /* nothing to do */
578                                 return OPERATOR_CANCELLED;
579                         }
580                         else {
581                                 /* recalc the connecting point as well to make a nice even curve */
582                                 MaskSplinePoint *point_other = is_end ? spline->points : &spline->points[spline->tot_point - 1];
583                                 spline->flag |= MASK_SPLINE_CYCLIC;
584
585                                 /* TODO, update keyframes in time */
586                                 BKE_mask_calc_handle_point_auto(spline, point, FALSE);
587                                 BKE_mask_calc_handle_point_auto(spline, point_other, FALSE);
588
589                                 /* TODO: only update this spline */
590                                 BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
591
592                                 WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
593                                 return OPERATOR_FINISHED;
594                         }
595                 }
596
597                 if (!add_vertex_subdivide(C, mask, co)) {
598                         if (!add_vertex_extrude(C, mask, masklay, co)) {
599                                 return OPERATOR_CANCELLED;
600                         }
601                 }
602         }
603         else {
604                 if (!add_vertex_subdivide(C, mask, co)) {
605                         if (!add_vertex_new(C, mask, masklay, co)) {
606                                 return OPERATOR_CANCELLED;
607                         }
608                 }
609         }
610
611         /* TODO: only update this spline */
612         BKE_mask_update_display(mask, CTX_data_scene(C)->r.cfra);
613
614         return OPERATOR_FINISHED;
615 }
616
617 static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
618 {
619         ScrArea *sa = CTX_wm_area(C);
620         ARegion *ar = CTX_wm_region(C);
621
622         float co[2];
623
624         ED_mask_mouse_pos(sa, ar, event->mval, co);
625
626         RNA_float_set_array(op->ptr, "location", co);
627
628         return add_vertex_exec(C, op);
629 }
630
631 void MASK_OT_add_vertex(wmOperatorType *ot)
632 {
633         /* identifiers */
634         ot->name = "Add Vertex";
635         ot->description = "Add vertex to active spline";
636         ot->idname = "MASK_OT_add_vertex";
637
638         /* api callbacks */
639         ot->exec = add_vertex_exec;
640         ot->invoke = add_vertex_invoke;
641         ot->poll = ED_maskedit_mask_poll;
642
643         /* flags */
644         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
645
646         /* properties */
647         RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
648                              "Location", "Location of vertex in normalized space", -1.0f, 1.0f);
649 }
650
651 /******************** add feather vertex *********************/
652
653 static int add_feather_vertex_exec(bContext *C, wmOperator *op)
654 {
655         Mask *mask = CTX_data_edit_mask(C);
656         MaskLayer *masklay;
657         MaskSpline *spline;
658         MaskSplinePoint *point = NULL;
659         const float threshold = 9;
660         float co[2], u;
661
662         RNA_float_get_array(op->ptr, "location", co);
663
664         point = ED_mask_point_find_nearest(C, mask, co, threshold, NULL, NULL, NULL, NULL);
665         if (point)
666                 return OPERATOR_FINISHED;
667
668         if (find_nearest_diff_point(C, mask, co, threshold, TRUE, &masklay, &spline, &point, &u, NULL, TRUE)) {
669                 Scene *scene = CTX_data_scene(C);
670                 float w = BKE_mask_point_weight(spline, point, u);
671                 float weight_scalar = BKE_mask_point_weight_scalar(spline, point, u);
672
673                 if (weight_scalar != 0.0f) {
674                         w = w / weight_scalar;
675                 }
676
677                 BKE_mask_point_add_uw(point, u, w);
678
679                 BKE_mask_update_display(mask, scene->r.cfra);
680
681                 WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
682
683                 DAG_id_tag_update(&mask->id, 0);
684
685                 return OPERATOR_FINISHED;
686         }
687
688         return OPERATOR_CANCELLED;
689 }
690
691 static int add_feather_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event)
692 {
693         ScrArea *sa = CTX_wm_area(C);
694         ARegion *ar = CTX_wm_region(C);
695
696         float co[2];
697
698         ED_mask_mouse_pos(sa, ar, event->mval, co);
699
700         RNA_float_set_array(op->ptr, "location", co);
701
702         return add_feather_vertex_exec(C, op);
703 }
704
705 void MASK_OT_add_feather_vertex(wmOperatorType *ot)
706 {
707         /* identifiers */
708         ot->name = "Add feather Vertex";
709         ot->description = "Add vertex to feather";
710         ot->idname = "MASK_OT_add_feather_vertex";
711
712         /* api callbacks */
713         ot->exec = add_feather_vertex_exec;
714         ot->invoke = add_feather_vertex_invoke;
715         ot->poll = ED_maskedit_mask_poll;
716
717         /* flags */
718         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
719
720         /* properties */
721         RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX,
722                              "Location", "Location of vertex in normalized space", -1.0f, 1.0f);
723 }