Fixed bug #23826, Other kind of brushes appear in sculpt mode
Was another problem caused by each brush being allowed in more than one paint mode. Added a new field to the brush struct to indicate what mode the icon was last set for; if it's changed then reset it. Not sure if it's really worth it to cache this, could remove it for simplicity.
This commit is contained in:
@@ -1026,30 +1026,46 @@ static int ui_id_brush_get_icon(bContext *C, ID *id, int preview)
|
|||||||
BKE_icon_getid(id);
|
BKE_icon_getid(id);
|
||||||
ui_id_icon_render(C, id, preview);
|
ui_id_icon_render(C, id, preview);
|
||||||
}
|
}
|
||||||
else if(!id->icon_id) {
|
else {
|
||||||
/* no icon found, reset it */
|
|
||||||
|
|
||||||
/* this is not nice, should probably make
|
|
||||||
brushes be strictly in one paint mode only
|
|
||||||
to avoid this kind of thing */
|
|
||||||
Object *ob = CTX_data_active_object(C);
|
Object *ob = CTX_data_active_object(C);
|
||||||
EnumPropertyItem *items;
|
EnumPropertyItem *items;
|
||||||
int tool;
|
int tool, mode = 0;
|
||||||
|
|
||||||
if(ob && (ob->mode & OB_MODE_SCULPT)) {
|
/* this is not nice, should probably make brushes be
|
||||||
|
strictly in one paint mode only to avoid checking
|
||||||
|
object mode here */
|
||||||
|
|
||||||
|
if(ob) {
|
||||||
|
if(ob->mode & OB_MODE_SCULPT)
|
||||||
|
mode = OB_MODE_SCULPT;
|
||||||
|
else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))
|
||||||
|
mode = OB_MODE_VERTEX_PAINT;
|
||||||
|
else if(ob->mode & OB_MODE_TEXTURE_PAINT)
|
||||||
|
mode = OB_MODE_TEXTURE_PAINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if cached icon is OK */
|
||||||
|
if(!mode || (id->icon_id && mode == br->icon_mode))
|
||||||
|
return id->icon_id;
|
||||||
|
|
||||||
|
br->icon_mode = mode;
|
||||||
|
|
||||||
|
/* reset the icon */
|
||||||
|
if(mode == OB_MODE_SCULPT) {
|
||||||
items = brush_sculpt_tool_items;
|
items = brush_sculpt_tool_items;
|
||||||
tool = br->sculpt_tool;
|
tool = br->sculpt_tool;
|
||||||
}
|
}
|
||||||
else if(ob && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))) {
|
else if(mode == OB_MODE_VERTEX_PAINT) {
|
||||||
items = brush_vertexpaint_tool_items;
|
items = brush_vertexpaint_tool_items;
|
||||||
tool = br->vertexpaint_tool;
|
tool = br->vertexpaint_tool;
|
||||||
}
|
}
|
||||||
else {
|
else if(mode == OB_MODE_TEXTURE_PAINT) {
|
||||||
items = brush_imagepaint_tool_items;
|
items = brush_imagepaint_tool_items;
|
||||||
tool = br->imagepaint_tool;
|
tool = br->imagepaint_tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
RNA_enum_icon_from_value(items, tool, &id->icon_id);
|
if(!RNA_enum_icon_from_value(items, tool, &id->icon_id))
|
||||||
|
id->icon_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return id->icon_id;
|
return id->icon_id;
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ typedef struct Brush {
|
|||||||
struct ImBuf *icon_imbuf;
|
struct ImBuf *icon_imbuf;
|
||||||
PreviewImage *preview;
|
PreviewImage *preview;
|
||||||
char icon_filepath[240];
|
char icon_filepath[240];
|
||||||
|
int icon_mode; /* store paint mode for which brush's icon was last generated */
|
||||||
|
int pad;
|
||||||
|
|
||||||
|
|
||||||
float normal_weight;
|
float normal_weight;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user