Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mask/mask_add.c
| Show First 20 Lines • Show All 759 Lines • ▼ Show 20 Lines | static int create_primitive_from_points(bContext *C, wmOperator *op, const float (*points)[2], | ||||
| location[0] /= width; | location[0] /= width; | ||||
| location[1] /= height; | location[1] /= height; | ||||
| BKE_mask_coord_from_frame(location, location, frame_size); | BKE_mask_coord_from_frame(location, location, frame_size); | ||||
| /* Make it so new primitive is centered to mouse location. */ | /* Make it so new primitive is centered to mouse location. */ | ||||
| location[0] -= 0.5f * scale; | location[0] -= 0.5f * scale; | ||||
| location[1] -= 0.5f * scale; | location[1] -= 0.5f * scale; | ||||
| mask_layer = ED_mask_layer_ensure(C); | bool added_mask = false; | ||||
| mask_layer = ED_mask_layer_ensure(C, &added_mask); | |||||
| mask = CTX_data_edit_mask(C); | mask = CTX_data_edit_mask(C); | ||||
| ED_mask_select_toggle_all(mask, SEL_DESELECT); | ED_mask_select_toggle_all(mask, SEL_DESELECT); | ||||
| new_spline = BKE_mask_spline_add(mask_layer); | new_spline = BKE_mask_spline_add(mask_layer); | ||||
| new_spline->flag = MASK_SPLINE_CYCLIC | SELECT; | new_spline->flag = MASK_SPLINE_CYCLIC | SELECT; | ||||
| new_spline->points = MEM_recallocN(new_spline->points, | new_spline->points = MEM_recallocN(new_spline->points, | ||||
| sizeof(MaskSplinePoint) * num_points); | sizeof(MaskSplinePoint) * num_points); | ||||
| Show All 19 Lines | for (i = 0; i < num_points; i++) { | ||||
| if (mask_layer->splines_shapes.first) { | if (mask_layer->splines_shapes.first) { | ||||
| BKE_mask_layer_shape_changed_add(mask_layer, | BKE_mask_layer_shape_changed_add(mask_layer, | ||||
| spline_index + i, | spline_index + i, | ||||
| true, true); | true, true); | ||||
| } | } | ||||
| } | } | ||||
| if (added_mask) { | |||||
| WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL); | |||||
| } | |||||
| WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); | WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); | ||||
| /* TODO: only update this spline */ | /* TODO: only update this spline */ | ||||
| BKE_mask_update_display(mask, CFRA); | BKE_mask_update_display(mask, CFRA); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||