diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/brush.c | 16 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 42 |
2 files changed, 52 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 41eb641f899..5ddc215dc2c 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -777,7 +777,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf const int radius = BKE_brush_size_get(scene, brush); unsigned char *dst, crgb[3]; const float alpha = (use_brush_alpha)? BKE_brush_alpha_get(scene, brush): 1.0f; - float brush_rgb[3]; + float brush_rgb[3] = {1.0f, 1.0f, 1.0f}; int thread = 0; imbflag = (flt) ? IB_rectfloat : IB_rect; @@ -791,9 +791,11 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf ibuf = IMB_allocImBuf(bufsize, bufsize, 32, imbflag); if (flt) { - copy_v3_v3(brush_rgb, brush->rgb); - if (use_color_correction) { - srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb); + if (brush->imagepaint_tool == PAINT_TOOL_DRAW) { + copy_v3_v3(brush_rgb, brush->rgb); + if (use_color_correction) { + srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb); + } } for (y = 0; y < ibuf->y; y++) { @@ -834,7 +836,11 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf } else { float alpha_f; /* final float alpha to convert to char */ - rgb_float_to_uchar(crgb, brush->rgb); + + if (brush->imagepaint_tool == PAINT_TOOL_DRAW) + rgb_float_to_uchar(crgb, brush->rgb); + else + rgb_float_to_uchar(crgb, brush_rgb); for (y = 0; y < ibuf->y; y++) { dst = (unsigned char *)ibuf->rect + y * rowbytes; diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 85d70c9342f..e4cc1c72237 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -807,7 +807,7 @@ static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot) { /* identifiers */ ot->name = "Image Aspect"; - ot->description = "Adjust the stencil size to fit image aspect ratio"; + ot->description = "When using an image texture, adjust the stencil size to fit the image aspect ratio"; ot->idname = "BRUSH_OT_stencil_fit_image_aspect"; /* api callbacks */ @@ -823,6 +823,45 @@ static void BRUSH_OT_stencil_fit_image_aspect(wmOperatorType *ot) } +static int stencil_reset_transform(bContext *C, wmOperator *UNUSED(op)) +{ + Paint *paint = BKE_paint_get_active_from_context(C); + Brush *br = BKE_paint_brush(paint); + + if (!br) + return OPERATOR_CANCELLED; + + br->stencil_pos[0] = 256; + br->stencil_pos[1] = 256; + + br->stencil_dimension[0] = 256; + br->stencil_dimension[1] = 256; + + br->mtex.rot = 0; + br->mask_mtex.rot = 0; + + WM_event_add_notifier(C, NC_WINDOW, NULL); + + return OPERATOR_FINISHED; +} + + +static void BRUSH_OT_stencil_reset_transform(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Reset Transform"; + ot->description = "Reset the stencil transformation to the default"; + ot->idname = "BRUSH_OT_stencil_reset_transform"; + + /* api callbacks */ + ot->exec = stencil_reset_transform; + ot->poll = stencil_control_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + + static void ed_keymap_stencil(wmKeyMap *keymap) { wmKeyMapItem *kmi; @@ -856,6 +895,7 @@ void ED_operatortypes_paint(void) WM_operatortype_append(BRUSH_OT_reset); WM_operatortype_append(BRUSH_OT_stencil_control); WM_operatortype_append(BRUSH_OT_stencil_fit_image_aspect); + WM_operatortype_append(BRUSH_OT_stencil_reset_transform); /* note, particle uses a different system, can be added with existing operators in wm.py */ WM_operatortype_append(PAINT_OT_brush_select); |