Fix T45258, impossible to select brush when removing it from 2d

painting.

Also system added a brush every time it found no paint brush in the
system which is not what we would want.

Solution:
* Brush panel stays visible always, regardless of whether there is a
brush or not.
* We search for first available brush when we find no brush in paint
struct instead of always generating a new one.
* Generating and searching for a brush take a mode argument now. Needed
some refactoring to users of BKE_paint_init as well.
* Did some style cleanups for paint mode enums.

Patch is big but it's mostly argument refactoring.
This commit is contained in:
Antonis Ryakiotakis 2015-08-31 21:37:38 +03:00
parent 0018483dfa
commit 333feea6e9
Notes: blender-bot 2023-02-14 08:56:50 +01:00
Referenced by issue #45258, Deleting brush closes Paint panel and creates duplicate brush when re-entering a Paint Mode
21 changed files with 167 additions and 89 deletions

View File

@ -705,7 +705,7 @@ class IMAGE_PT_tools_transform_uvs(Panel, UVToolsPanel):
col.operator("transform.shear")
class IMAGE_PT_paint(Panel, BrushButtonsPanel):
class IMAGE_PT_paint(Panel, ImagePaintPanel):
bl_label = "Paint"
bl_category = "Tools"
@ -721,6 +721,11 @@ class IMAGE_PT_paint(Panel, BrushButtonsPanel):
if brush:
brush_texpaint_common(self, context, layout, brush, settings)
@classmethod
def poll(cls, context):
sima = context.space_data
toolsettings = context.tool_settings.image_paint
return sima.show_paint
class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel):
bl_label = "Overlay"

View File

@ -40,7 +40,8 @@ void BKE_brush_system_init(void);
void BKE_brush_system_exit(void);
/* datablock functions */
struct Brush *BKE_brush_add(struct Main *bmain, const char *name);
struct Brush *BKE_brush_add(struct Main *bmain, const char *name, short ob_mode);
struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode);
struct Brush *BKE_brush_copy(struct Brush *brush);
void BKE_brush_make_local(struct Brush *brush);
void BKE_brush_free(struct Brush *brush);

View File

@ -66,13 +66,13 @@ extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
typedef enum PaintMode {
PAINT_SCULPT = 0,
PAINT_VERTEX = 1,
PAINT_WEIGHT = 2,
PAINT_TEXTURE_PROJECTIVE = 3,
PAINT_TEXTURE_2D = 4,
PAINT_SCULPT_UV = 5,
PAINT_INVALID = 6
ePaintSculpt = 0,
ePaintVertex = 1,
ePaintWeight = 2,
ePaintTextureProjective = 3,
ePaintTexture2D = 4,
ePaintSculptUV = 5,
ePaintInvalid = 6
} PaintMode;
/* overlay invalidation */
@ -108,12 +108,14 @@ void BKE_palette_clear(struct Palette *palette);
struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
void BKE_paint_curve_free(struct PaintCurve *pc);
void BKE_paint_init(struct UnifiedPaintSettings *ups, struct Paint *p, const char col[3]);
void BKE_paint_init(struct Scene *sce, PaintMode mode, const char col[3]);
void BKE_paint_free(struct Paint *p);
void BKE_paint_copy(struct Paint *src, struct Paint *tar);
void BKE_paint_cavity_curve_preset(struct Paint *p, int preset);
short BKE_paint_object_mode_from_paint_mode(PaintMode mode);
struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, PaintMode mode);
struct Paint *BKE_paint_get_active(struct Scene *sce);
struct Paint *BKE_paint_get_active_from_context(const struct bContext *C);
PaintMode BKE_paintmode_get_active_from_context(const struct bContext *C);

View File

@ -131,7 +131,7 @@ static void brush_defaults(Brush *brush)
/* Datablock add/copy/free/make_local */
Brush *BKE_brush_add(Main *bmain, const char *name)
Brush *BKE_brush_add(Main *bmain, const char *name, short ob_mode)
{
Brush *brush;
@ -143,6 +143,7 @@ Brush *BKE_brush_add(Main *bmain, const char *name)
brush_defaults(brush);
brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
brush->ob_mode = ob_mode;
/* the default alpha falloff curve */
BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
@ -150,6 +151,17 @@ Brush *BKE_brush_add(Main *bmain, const char *name)
return brush;
}
struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode)
{
Brush *brush;
for (brush = bmain->brush.first; brush; brush = brush->id.next) {
if (brush->ob_mode & ob_mode)
return brush;
}
return NULL;
}
Brush *BKE_brush_copy(Brush *brush)
{
Brush *brushn;

View File

@ -128,6 +128,32 @@ void BKE_paint_reset_overlay_invalid(OverlayControlFlags flag)
overlay_flags &= ~(flag);
}
Paint *BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode)
{
if (sce) {
ToolSettings *ts = sce->toolsettings;
switch (mode) {
case ePaintSculpt:
return &ts->sculpt->paint;
case ePaintVertex:
return &ts->vpaint->paint;
case ePaintWeight:
return &ts->wpaint->paint;
case ePaintTexture2D:
case ePaintTextureProjective:
return &ts->imapaint.paint;
case ePaintSculptUV:
return &ts->uvsculpt->paint;
case ePaintInvalid:
return NULL;
default:
return &ts->imapaint.paint;
}
}
return NULL;
}
Paint *BKE_paint_get_active(Scene *sce)
{
@ -223,39 +249,39 @@ PaintMode BKE_paintmode_get_active_from_context(const bContext *C)
if ((sima = CTX_wm_space_image(C)) != NULL) {
if (obact && obact->mode == OB_MODE_EDIT) {
if (sima->mode == SI_MODE_PAINT)
return PAINT_TEXTURE_2D;
return ePaintTexture2D;
else if (ts->use_uv_sculpt)
return PAINT_SCULPT_UV;
return ePaintSculptUV;
}
else {
return PAINT_TEXTURE_2D;
return ePaintTexture2D;
}
}
else if (obact) {
switch (obact->mode) {
case OB_MODE_SCULPT:
return PAINT_SCULPT;
return ePaintSculpt;
case OB_MODE_VERTEX_PAINT:
return PAINT_VERTEX;
return ePaintVertex;
case OB_MODE_WEIGHT_PAINT:
return PAINT_WEIGHT;
return ePaintWeight;
case OB_MODE_TEXTURE_PAINT:
return PAINT_TEXTURE_PROJECTIVE;
return ePaintTextureProjective;
case OB_MODE_EDIT:
if (ts->use_uv_sculpt)
return PAINT_SCULPT_UV;
return PAINT_TEXTURE_2D;
return ePaintSculptUV;
return ePaintTexture2D;
default:
return PAINT_TEXTURE_2D;
return ePaintTexture2D;
}
}
else {
/* default to image paint */
return PAINT_TEXTURE_2D;
return ePaintTexture2D;
}
}
return PAINT_INVALID;
return ePaintInvalid;
}
Brush *BKE_paint_brush(Paint *p)
@ -418,23 +444,51 @@ void BKE_paint_cavity_curve_preset(Paint *p, int preset)
curvemapping_changed(p->cavity_curve, false);
}
void BKE_paint_init(UnifiedPaintSettings *ups, Paint *p, const char col[3])
short BKE_paint_object_mode_from_paint_mode(PaintMode mode)
{
switch (mode) {
case ePaintSculpt:
return OB_MODE_SCULPT;
case ePaintVertex:
return OB_MODE_VERTEX_PAINT;
case ePaintWeight:
return OB_MODE_WEIGHT_PAINT;
case ePaintTextureProjective:
return OB_MODE_TEXTURE_PAINT;
case ePaintTexture2D:
return OB_MODE_TEXTURE_PAINT;
case ePaintSculptUV:
return OB_MODE_EDIT;
case ePaintInvalid:
default:
return 0;
}
}
void BKE_paint_init(Scene *sce, PaintMode mode, const char col[3])
{
UnifiedPaintSettings *ups = &sce->toolsettings->unified_paint_settings;
Brush *brush;
Paint *paint = BKE_paint_get_active_from_paintmode(sce, mode);
/* If there's no brush, create one */
brush = BKE_paint_brush(p);
if (brush == NULL)
brush = BKE_brush_add(G.main, "Brush");
BKE_paint_brush_set(p, brush);
brush = BKE_paint_brush(paint);
if (brush == NULL) {
short ob_mode = BKE_paint_object_mode_from_paint_mode(mode);
brush = BKE_brush_first_search(G.main, ob_mode);
memcpy(p->paint_cursor_col, col, 3);
p->paint_cursor_col[3] = 128;
if (!brush)
brush = BKE_brush_add(G.main, "Brush", ob_mode);
BKE_paint_brush_set(paint, brush);
}
memcpy(paint->paint_cursor_col, col, 3);
paint->paint_cursor_col[3] = 128;
ups->last_stroke_valid = false;
zero_v3(ups->average_stroke_accum);
ups->average_stroke_counter = 0;
if (!p->cavity_curve)
BKE_paint_cavity_curve_preset(p, CURVE_PRESET_LINE);
if (!paint->cavity_curve)
BKE_paint_cavity_curve_preset(paint, CURVE_PRESET_LINE);
}
void BKE_paint_free(Paint *paint)

View File

@ -151,7 +151,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Fill");
if (!br) {
br = BKE_brush_add(bmain, "Fill");
br = BKE_brush_add(bmain, "Fill", OB_MODE_TEXTURE_PAINT);
br->imagepaint_tool = PAINT_TOOL_FILL;
br->ob_mode = OB_MODE_TEXTURE_PAINT;
}

View File

@ -59,8 +59,8 @@ void ED_space_image_get_uv_aspect(struct SpaceImage *sima, float *aspx, float *a
void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *sima, struct ImBuf *ibuf, bool use_view_settings);
void ED_space_image_paint_update(struct wmWindowManager *wm, struct ToolSettings *settings);
void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSettings *settings);
void ED_space_image_paint_update(struct wmWindowManager *wm, struct Scene *scene);
void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct Scene *scene);
void ED_image_get_uv_aspect(struct Image *ima, struct ImageUser *iuser, float *aspx, float *aspy);
void ED_image_mouse_pos(struct SpaceImage *sima, struct ARegion *ar, const int mval[2], float co[2]);

View File

@ -575,7 +575,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
{
const int mode_flag = OB_MODE_EDIT;
const bool is_mode_set = (CTX_data_edit_object(C) != NULL);
ToolSettings *toolsettings = CTX_data_tool_settings(C);
Scene *scene = CTX_data_scene(C);
if (!is_mode_set) {
Object *ob = CTX_data_active_object(C);
@ -589,7 +589,7 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op)
else
ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */
ED_space_image_uv_sculpt_update(CTX_wm_manager(C), toolsettings);
ED_space_image_uv_sculpt_update(CTX_wm_manager(C), scene);
return OPERATOR_FINISHED;
}

View File

@ -756,7 +756,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
ViewContext *vc, int x, int y, float zoom, PaintMode mode)
{
/* color means that primary brush texture is colured and secondary is used for alpha/mask control */
bool col = ELEM(mode, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D, PAINT_VERTEX) ? true : false;
bool col = ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex) ? true : false;
OverlayControlFlags flags = BKE_paint_get_overlay_flags();
/* save lots of GL state
* TODO: check on whether all of these are needed? */
@ -782,7 +782,7 @@ static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
}
else {
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != PAINT_WEIGHT))
if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY) && (mode != ePaintWeight))
paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, true);
if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR))
paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom);
@ -958,7 +958,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon
static bool ommit_cursor_drawing(Paint *paint, PaintMode mode, Brush *brush)
{
if (paint->flags & PAINT_SHOW_BRUSH) {
if (ELEM(mode, PAINT_TEXTURE_2D, PAINT_TEXTURE_PROJECTIVE) && brush->imagepaint_tool == PAINT_TOOL_FILL) {
if (ELEM(mode, ePaintTexture2D, ePaintTextureProjective) && brush->imagepaint_tool == PAINT_TOOL_FILL) {
return true;
}
return false;
@ -1014,7 +1014,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
/* TODO: as sculpt and other paint modes are unified, this
* special mode of drawing will go away */
if ((mode == PAINT_SCULPT) && vc.obact->sculpt) {
if ((mode == ePaintSculpt) && vc.obact->sculpt) {
float location[3];
int pixel_radius;
bool hit;

View File

@ -134,12 +134,12 @@ static void paintcurve_undo_begin(bContext *C, wmOperator *op, PaintCurve *pc)
UndoCurve *uc;
switch (mode) {
case PAINT_TEXTURE_2D:
case PAINT_TEXTURE_PROJECTIVE:
case ePaintTexture2D:
case ePaintTextureProjective:
undo_stack_id = UNDO_PAINT_IMAGE;
break;
case PAINT_SCULPT:
case ePaintSculpt:
undo_stack_id = UNDO_PAINT_MESH;
break;
@ -737,17 +737,17 @@ static int paintcurve_draw_exec(bContext *C, wmOperator *UNUSED(op))
const char *name;
switch (mode) {
case PAINT_TEXTURE_2D:
case PAINT_TEXTURE_PROJECTIVE:
case ePaintTexture2D:
case ePaintTextureProjective:
name = "PAINT_OT_image_paint";
break;
case PAINT_WEIGHT:
case ePaintWeight:
name = "PAINT_OT_weight_paint";
break;
case PAINT_VERTEX:
case ePaintVertex:
name = "PAINT_OT_vertex_paint";
break;
case PAINT_SCULPT:
case ePaintSculpt:
name = "SCULPT_OT_brush_stroke";
break;
default:
@ -777,7 +777,7 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w
PaintMode mode = BKE_paintmode_get_active_from_context(C);
switch (mode) {
case PAINT_TEXTURE_2D:
case ePaintTexture2D:
{
ARegion *ar = CTX_wm_region(C);
SpaceImage *sima = CTX_wm_space_image(C);

View File

@ -1045,8 +1045,9 @@ static void toggle_paint_cursor(bContext *C, int enable)
* purpose is to make sure the paint cursor is shown if paint
* mode is enabled in the image editor. the paint poll will
* ensure that the cursor is hidden when not in paint mode */
void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
void ED_space_image_paint_update(wmWindowManager *wm, Scene *scene)
{
ToolSettings *settings = scene->toolsettings;
wmWindow *win;
ScrArea *sa;
ImagePaintSettings *imapaint = &settings->imapaint;
@ -1059,7 +1060,7 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings)
enabled = true;
if (enabled) {
BKE_paint_init(&settings->unified_paint_settings, &imapaint->paint, PAINT_CURSOR_TEXTURE_PAINT);
BKE_paint_init(scene, ePaintTexture2D, PAINT_CURSOR_TEXTURE_PAINT);
paint_cursor_start_explicit(&imapaint->paint, wm, image_paint_poll);
}
@ -1212,7 +1213,7 @@ static int sample_color_exec(bContext *C, wmOperator *op)
RNA_int_get_array(op->ptr, "location", location);
use_palette = RNA_boolean_get(op->ptr, "palette");
paint_sample_color(C, ar, location[0], location[1], mode == PAINT_TEXTURE_PROJECTIVE, use_palette);
paint_sample_color(C, ar, location[0], location[1], mode == ePaintTextureProjective, use_palette);
if (show_cursor) {
paint->flags |= PAINT_SHOW_BRUSH;
@ -1250,7 +1251,7 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event
RNA_int_set_array(op->ptr, "location", event->mval);
paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, false);
paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == ePaintTextureProjective, false);
WM_cursor_modal_set(win, BC_EYEDROPPER_CURSOR);
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
@ -1289,7 +1290,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ARegion *ar = CTX_wm_region(C);
RNA_int_set_array(op->ptr, "location", event->mval);
paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, false);
paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == ePaintTextureProjective, false);
WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush);
break;
}
@ -1298,7 +1299,7 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->val == KM_PRESS) {
ARegion *ar = CTX_wm_region(C);
RNA_int_set_array(op->ptr, "location", event->mval);
paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == PAINT_TEXTURE_PROJECTIVE, true);
paint_sample_color(C, ar, event->mval[0], event->mval[1], mode == ePaintTextureProjective, true);
if (!data->sample_palette) {
data->sample_palette = true;
sample_color_update_header(data, C);
@ -1416,7 +1417,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
ob->mode |= mode_flag;
BKE_paint_init(&scene->toolsettings->unified_paint_settings, &imapaint->paint, PAINT_CURSOR_TEXTURE_PAINT);
BKE_paint_init(scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT);
if (U.glreslimit != 0)
GPU_free_images();

View File

@ -66,11 +66,12 @@ static int brush_add_exec(bContext *C, wmOperator *UNUSED(op))
Paint *paint = BKE_paint_get_active_from_context(C);
Brush *br = BKE_paint_brush(paint);
Main *bmain = CTX_data_main(C);
PaintMode mode = BKE_paintmode_get_active_from_context(C);
if (br)
br = BKE_brush_copy(br);
else
br = BKE_brush_add(bmain, "Brush");
br = BKE_brush_add(bmain, "Brush", BKE_paint_object_mode_from_paint_mode(mode));
BKE_paint_brush_set(paint, br);
@ -201,11 +202,11 @@ static int palette_color_add_exec(bContext *C, wmOperator *UNUSED(op))
color = BKE_palette_color_add(palette);
palette->active_color = BLI_listbase_count(&palette->colors) - 1;
if (ELEM(mode, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D, PAINT_VERTEX)) {
if (ELEM(mode, ePaintTextureProjective, ePaintTexture2D, ePaintVertex)) {
copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush));
color->value = 0.0;
}
else if (mode == PAINT_WEIGHT) {
else if (mode == ePaintWeight) {
zero_v3(color->rgb);
color->value = brush->weight;
}
@ -431,9 +432,8 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool,
brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode);
if (!brush && brush_tool(brush_orig, tool_offset) != tool && create_missing) {
brush = BKE_brush_add(bmain, tool_name);
brush = BKE_brush_add(bmain, tool_name, ob_mode);
brush_tool_set(brush, tool_offset, tool);
brush->ob_mode = ob_mode;
brush->toggle_brush = brush_orig;
}

View File

@ -194,7 +194,7 @@ static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
static bool paint_tool_require_location(Brush *brush, PaintMode mode)
{
switch (mode) {
case PAINT_SCULPT:
case ePaintSculpt:
if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE,
SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB))
{
@ -388,7 +388,7 @@ static bool paint_stroke_use_jitter(PaintMode mode, Brush *brush, bool invert)
/* jitter-ed brush gives weird and unpredictable result for this
* kinds of stroke, so manually disable jitter usage (sergey) */
use_jitter &= (brush->flag & (BRUSH_DRAG_DOT | BRUSH_ANCHORED)) == 0;
use_jitter &= (!ELEM(mode, PAINT_TEXTURE_2D, PAINT_TEXTURE_PROJECTIVE) ||
use_jitter &= (!ELEM(mode, ePaintTexture2D, ePaintTextureProjective) ||
!(invert && brush->imagepaint_tool == PAINT_TOOL_CLONE));
@ -759,13 +759,13 @@ bool paint_supports_dynamic_size(Brush *br, PaintMode mode)
return false;
switch (mode) {
case PAINT_SCULPT:
case ePaintSculpt:
if (sculpt_is_grab_tool(br))
return false;
break;
case PAINT_TEXTURE_2D: /* fall through */
case PAINT_TEXTURE_PROJECTIVE:
case ePaintTexture2D: /* fall through */
case ePaintTextureProjective:
if ((br->imagepaint_tool == PAINT_TOOL_FILL) &&
(br->flag & BRUSH_USE_GRADIENT))
{
@ -788,7 +788,7 @@ bool paint_supports_smooth_stroke(Brush *br, PaintMode mode)
}
switch (mode) {
case PAINT_SCULPT:
case ePaintSculpt:
if (sculpt_is_grab_tool(br))
return false;
break;
@ -801,7 +801,7 @@ bool paint_supports_smooth_stroke(Brush *br, PaintMode mode)
bool paint_supports_texture(PaintMode mode)
{
/* omit: PAINT_WEIGHT, PAINT_SCULPT_UV, PAINT_INVALID */
return ELEM(mode, PAINT_SCULPT, PAINT_VERTEX, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D);
return ELEM(mode, ePaintSculpt, ePaintVertex, ePaintTextureProjective, ePaintTexture2D);
}
/* return true if the brush size can change during paint (normally used for pressure) */
@ -811,7 +811,7 @@ bool paint_supports_dynamic_tex_coords(Brush *br, PaintMode mode)
return false;
switch (mode) {
case PAINT_SCULPT:
case ePaintSculpt:
if (sculpt_is_grab_tool(br))
return false;
break;

View File

@ -1956,7 +1956,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op)
paint_cursor_start(C, weight_paint_poll);
BKE_paint_init(&scene->toolsettings->unified_paint_settings, &wp->paint, PAINT_CURSOR_WEIGHT_PAINT);
BKE_paint_init(scene, ePaintWeight, PAINT_CURSOR_WEIGHT_PAINT);
/* weight paint specific */
ED_mesh_mirror_spatial_table(ob, NULL, NULL, 's');
@ -2564,7 +2564,7 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op)
paint_cursor_start(C, vertex_paint_poll);
BKE_paint_init(&scene->toolsettings->unified_paint_settings, &vp->paint, PAINT_CURSOR_VERTEX_PAINT);
BKE_paint_init(scene, ePaintVertex, PAINT_CURSOR_VERTEX_PAINT);
}
/* update modifier stack for mapping requirements */

View File

@ -4062,7 +4062,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
* brush coord/pressure/etc.
* It's more an events design issue, which doesn't split coordinate/pressure/angle
* changing events. We should avoid this after events system re-design */
if (paint_supports_dynamic_size(brush, PAINT_SCULPT) || cache->first_time) {
if (paint_supports_dynamic_size(brush, ePaintSculpt) || cache->first_time) {
cache->pressure = RNA_float_get(ptr, "pressure");
}
@ -4079,7 +4079,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob,
}
}
if (BKE_brush_use_size_pressure(scene, brush) && paint_supports_dynamic_size(brush, PAINT_SCULPT)) {
if (BKE_brush_use_size_pressure(scene, brush) && paint_supports_dynamic_size(brush, ePaintSculpt)) {
cache->radius = cache->initial_radius * cache->pressure;
}
else {
@ -5141,7 +5141,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
"Object has negative scale, sculpting may be unpredictable");
}
BKE_paint_init(&ts->unified_paint_settings, &ts->sculpt->paint, PAINT_CURSOR_SCULPT);
BKE_paint_init(scene, ePaintSculpt, PAINT_CURSOR_SCULPT);
paint_cursor_start(C, sculpt_poll_view3d);
}

View File

@ -224,8 +224,9 @@ static void brush_drawcursor_uvsculpt(bContext *C, int x, int y, void *UNUSED(cu
}
void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings)
void ED_space_image_uv_sculpt_update(wmWindowManager *wm, Scene *scene)
{
ToolSettings *settings = scene->toolsettings;
if (settings->use_uv_sculpt) {
if (!settings->uvsculpt) {
settings->uvsculpt = MEM_callocN(sizeof(*settings->uvsculpt), "UV Smooth paint");
@ -236,7 +237,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings
settings->uvsculpt->paint.flags |= PAINT_SHOW_BRUSH;
}
BKE_paint_init(&settings->unified_paint_settings, &settings->uvsculpt->paint, PAINT_CURSOR_SCULPT);
BKE_paint_init(scene, ePaintSculptUV, PAINT_CURSOR_SCULPT);
settings->uvsculpt->paint.paint_cursor = WM_paint_cursor_activate(wm, uv_sculpt_brush_poll,
brush_drawcursor_uvsculpt, NULL);

View File

@ -111,7 +111,7 @@ void ED_editors_init(bContext *C)
/* image editor paint mode */
if (sce) {
ED_space_image_paint_update(wm, sce->toolsettings);
ED_space_image_paint_update(wm, sce);
}
SWAP(int, reports->flag, reports_flag_prev);

View File

@ -510,7 +510,7 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA *ptr,
Brush *me = (Brush *)(ptr->data);
switch (mode) {
case PAINT_SCULPT:
case ePaintSculpt:
switch (me->sculpt_tool) {
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_CREASE:
@ -550,8 +550,8 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA *ptr,
}
break;
case PAINT_TEXTURE_2D:
case PAINT_TEXTURE_PROJECTIVE:
case ePaintTexture2D:
case ePaintTextureProjective:
switch (me->imagepaint_tool) {
case PAINT_TOOL_SOFTEN:
return prop_soften_sharpen_items;
@ -581,9 +581,9 @@ static EnumPropertyItem *rna_Brush_stroke_itemf(bContext *C, PointerRNA *UNUSED(
};
switch (mode) {
case PAINT_SCULPT:
case PAINT_TEXTURE_2D:
case PAINT_TEXTURE_PROJECTIVE:
case ePaintSculpt:
case ePaintTexture2D:
case ePaintTextureProjective:
return sculpt_stroke_method_items;
default:

View File

@ -36,6 +36,7 @@
#include "DNA_ID.h"
#include "DNA_modifier_types.h"
#include "DNA_space_types.h"
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
#include "BLI_path_util.h"
@ -88,7 +89,6 @@
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_speaker_types.h"
#include "DNA_sound_types.h"
#include "DNA_text_types.h"
@ -483,12 +483,13 @@ static void rna_Main_textures_remove(Main *bmain, ReportList *reports, PointerRN
}
}
static Brush *rna_Main_brushes_new(Main *bmain, const char *name)
static Brush *rna_Main_brushes_new(Main *bmain, const char *name, int mode)
{
Brush *brush = BKE_brush_add(bmain, name);
Brush *brush = BKE_brush_add(bmain, name, mode);
id_us_min(&brush->id);
return brush;
}
static void rna_Main_brushes_remove(Main *bmain, ReportList *reports, PointerRNA *brush_ptr)
{
Brush *brush = brush_ptr->data;
@ -1422,6 +1423,7 @@ void RNA_def_main_brushes(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a new brush to the main database");
parm = RNA_def_string(func, "name", "Brush", 0, "", "New name for the datablock");
RNA_def_property_flag(parm, PROP_REQUIRED);
parm = RNA_def_enum(func, "mode", object_mode_items, OB_MODE_TEXTURE_PAINT, "", "Paint Mode for the new brush");
/* return type */
parm = RNA_def_pointer(func, "brush", "Brush", "", "New brush datablock");
RNA_def_function_return(func, parm);

View File

@ -432,7 +432,7 @@ EnumPropertyItem stereo3d_interlace_type_items[] = {
static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
ED_space_image_uv_sculpt_update(bmain->wm.first, scene->toolsettings);
ED_space_image_uv_sculpt_update(bmain->wm.first, scene);
}
static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr)

View File

@ -730,7 +730,7 @@ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
static void rna_SpaceImageEditor_mode_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
ED_space_image_paint_update(bmain->wm.first, scene->toolsettings);
ED_space_image_paint_update(bmain->wm.first, scene);
}