Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mask/mask_shapekey.c
| Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | |||||
| static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op)) | static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| const int frame = CFRA; | const int frame = CFRA; | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| bool changed = false; | bool changed = false; | ||||
| for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { | LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { | ||||
| MaskLayerShape *mask_layer_shape; | MaskLayerShape *mask_layer_shape; | ||||
| if (!ED_mask_layer_select_check(mask_layer)) { | if (!ED_mask_layer_select_check(mask_layer)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| mask_layer_shape = BKE_mask_layer_shape_verify_frame(mask_layer, frame); | mask_layer_shape = BKE_mask_layer_shape_verify_frame(mask_layer, frame); | ||||
| BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape); | BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape); | ||||
| Show All 28 Lines | |||||
| static int mask_shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) | static int mask_shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| const int frame = CFRA; | const int frame = CFRA; | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| bool changed = false; | bool changed = false; | ||||
| for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { | LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { | ||||
| MaskLayerShape *mask_layer_shape; | MaskLayerShape *mask_layer_shape; | ||||
| if (!ED_mask_layer_select_check(mask_layer)) { | if (!ED_mask_layer_select_check(mask_layer)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| mask_layer_shape = BKE_mask_layer_shape_find_frame(mask_layer, frame); | mask_layer_shape = BKE_mask_layer_shape_find_frame(mask_layer, frame); | ||||
| Show All 31 Lines | |||||
| static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)) | static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| const int frame = CFRA; | const int frame = CFRA; | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| bool changed = false; | bool changed = false; | ||||
| for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { | LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { | ||||
| if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { | if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (mask_layer->splines_shapes.first) { | if (mask_layer->splines_shapes.first) { | ||||
| MaskLayerShape *mask_layer_shape_reset; | MaskLayerShape *mask_layer_shape_reset; | ||||
| MaskLayerShape *mask_layer_shape; | MaskLayerShape *mask_layer_shape; | ||||
| Show All 9 Lines | if (mask_layer->splines_shapes.first) { | ||||
| if (mask_layer_shape_reset->tot_vert == mask_layer_shape->tot_vert) { | if (mask_layer_shape_reset->tot_vert == mask_layer_shape->tot_vert) { | ||||
| int i_abs = 0; | int i_abs = 0; | ||||
| MaskLayerShapeElem *shape_ele_src; | MaskLayerShapeElem *shape_ele_src; | ||||
| MaskLayerShapeElem *shape_ele_dst; | MaskLayerShapeElem *shape_ele_dst; | ||||
| shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_reset->data; | shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_reset->data; | ||||
| shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape->data; | shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape->data; | ||||
| for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { | LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { | ||||
| for (int i = 0; i < spline->tot_point; i++) { | for (int i = 0; i < spline->tot_point; i++) { | ||||
| MaskSplinePoint *point = &spline->points[i]; | MaskSplinePoint *point = &spline->points[i]; | ||||
| if (MASKPOINT_ISSEL_ANY(point)) { | if (MASKPOINT_ISSEL_ANY(point)) { | ||||
| /* TODO - nicer access here */ | /* TODO - nicer access here */ | ||||
| shape_ele_dst->value[6] = shape_ele_src->value[6]; | shape_ele_dst->value[6] = shape_ele_src->value[6]; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op) | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| const int frame = CFRA; | const int frame = CFRA; | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| bool changed = false; | bool changed = false; | ||||
| const bool do_feather = RNA_boolean_get(op->ptr, "feather"); | const bool do_feather = RNA_boolean_get(op->ptr, "feather"); | ||||
| const bool do_location = RNA_boolean_get(op->ptr, "location"); | const bool do_location = RNA_boolean_get(op->ptr, "location"); | ||||
| for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { | LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { | ||||
| if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { | if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* we need at least one point selected here to bother re-interpolating */ | /* we need at least one point selected here to bother re-interpolating */ | ||||
| if (!ED_mask_layer_select_check(mask_layer)) { | if (!ED_mask_layer_select_check(mask_layer)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | if (mask_layer->splines_shapes.first) { | ||||
| /* we know this exists, added above */ | /* we know this exists, added above */ | ||||
| mask_layer_shape_tmp_rekey = BKE_mask_layer_shape_find_frame( | mask_layer_shape_tmp_rekey = BKE_mask_layer_shape_find_frame( | ||||
| mask_layer, mask_layer_shape_tmp->frame); | mask_layer, mask_layer_shape_tmp->frame); | ||||
| shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_tmp->data; | shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_tmp->data; | ||||
| shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape_tmp_rekey->data; | shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape_tmp_rekey->data; | ||||
| for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) { | LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { | ||||
| for (int i = 0; i < spline->tot_point; i++) { | for (int i = 0; i < spline->tot_point; i++) { | ||||
| MaskSplinePoint *point = &spline->points[i]; | MaskSplinePoint *point = &spline->points[i]; | ||||
| /* not especially efficient but makes this easier to follow */ | /* not especially efficient but makes this easier to follow */ | ||||
| SWAP(MaskLayerShapeElem, *shape_ele_src, *shape_ele_dst); | SWAP(MaskLayerShapeElem, *shape_ele_src, *shape_ele_dst); | ||||
| if (MASKPOINT_ISSEL_ANY(point)) { | if (MASKPOINT_ISSEL_ANY(point)) { | ||||
| if (do_location) { | if (do_location) { | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | void ED_mask_layer_shape_auto_key(MaskLayer *mask_layer, const int frame) | ||||
| mask_layer_shape = BKE_mask_layer_shape_verify_frame(mask_layer, frame); | mask_layer_shape = BKE_mask_layer_shape_verify_frame(mask_layer, frame); | ||||
| BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape); | BKE_mask_layer_shape_from_mask(mask_layer, mask_layer_shape); | ||||
| } | } | ||||
| bool ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame) | bool ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame) | ||||
| { | { | ||||
| bool changed = false; | bool changed = false; | ||||
| for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { | LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { | ||||
| ED_mask_layer_shape_auto_key(mask_layer, frame); | ED_mask_layer_shape_auto_key(mask_layer, frame); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| bool ED_mask_layer_shape_auto_key_select(Mask *mask, const int frame) | bool ED_mask_layer_shape_auto_key_select(Mask *mask, const int frame) | ||||
| { | { | ||||
| bool changed = false; | bool changed = false; | ||||
| for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) { | LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) { | ||||
| if (!ED_mask_layer_select_check(mask_layer)) { | if (!ED_mask_layer_select_check(mask_layer)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ED_mask_layer_shape_auto_key(mask_layer, frame); | ED_mask_layer_shape_auto_key(mask_layer, frame); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| return changed; | return changed; | ||||
| } | } | ||||