diff options
-rw-r--r-- | release/scripts/startup/bl_ui/properties_paint_common.py | 3 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 32 |
2 files changed, 29 insertions, 6 deletions
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index 3b9256c6ec9..56b82655e47 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -126,6 +126,9 @@ def brush_mask_texture_settings(layout, brush): layout.row().prop(mask_tex_slot, "mask_map_mode", text="") layout.separator() + if mask_tex_slot.map_mode == 'STENCIL': + layout.operator("brush.stencil_fit_image_aspect").mask = True + if brush.mask_texture: layout.label(text="Mask Mapping:") col = layout.column() diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index ae578ffefd1..ce403b56c77 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -718,9 +718,15 @@ static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op) { Paint *paint = BKE_paint_get_active_from_context(C); Brush *br = BKE_paint_brush(paint); - Tex *tex = (br)? br->mtex.tex : NULL; bool use_scale = RNA_boolean_get(op->ptr, "use_scale"); bool use_repeat = RNA_boolean_get(op->ptr, "use_repeat"); + bool do_mask = RNA_boolean_get(op->ptr, "mask"); + Tex *tex = NULL; + MTex *mtex = NULL; + if (br) { + mtex = do_mask ? &br->mask_mtex : &br->mtex; + tex = mtex->tex; + } if (tex && tex->type == TEX_IMAGE && tex->ima) { float aspx, aspy; @@ -729,8 +735,8 @@ static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op) ED_image_get_uv_aspect(ima, NULL, &aspx, &aspy); if (use_scale) { - aspx *= br->mtex.size[0]; - aspy *= br->mtex.size[1]; + aspx *= mtex->size[0]; + aspy *= mtex->size[1]; } if (use_repeat && tex->extend == TEX_REPEAT) { @@ -739,12 +745,25 @@ static int stencil_fit_image_aspect_exec(bContext *C, wmOperator *op) } orig_area = aspx * aspy; - stencil_area = br->stencil_dimension[0] * br->stencil_dimension[1]; + + if (do_mask) { + stencil_area = br->mask_stencil_dimension[0] * br->mask_stencil_dimension[1]; + } + else { + stencil_area = br->stencil_dimension[0] * br->stencil_dimension[1]; + } factor = sqrt(stencil_area / orig_area); - br->stencil_dimension[0] = factor * aspx; - br->stencil_dimension[1] = factor * aspy; + if (do_mask) { + br->mask_stencil_dimension[0] = factor * aspx; + br->mask_stencil_dimension[1] = factor * aspy; + + } + else { + br->stencil_dimension[0] = factor * aspx; + br->stencil_dimension[1] = factor * aspy; + } } WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -769,6 +788,7 @@ static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_repeat", 1, "Use Repeat", "Use repeat mapping values"); RNA_def_boolean(ot->srna, "use_scale", 1, "Use Scale", "Use texture scale values"); + RNA_def_boolean(ot->srna, "mask", 0, "Modify Mask Stencil", "Modify either the primary or mask stencil"); } |