Fix T48151: Brush texture overlay won't refresh automatically in UV editor when changed in buttons window.

Simple solution is to get rid of this stupid `rna_TextureSlot_brush_update` func, and do what it was doing directly
in BR case of `rna_TextureSlot_update`. That way, all updates to brush texture will invalidate correctly the overlay.

Note that this double definition of texture pointer for brushes looks rather fishy, am really not convinced this helps
keeping things simple and clear at all (what happened here is that texture selector in image paint editor was using
'texture' member of brush itself, which was performing correct RNA update, while context-based brush texture selector
from buttons space was using 'texture' member of the TextureSlot struct, which had default texture update callback
which was not invalidating overlay).
This commit is contained in:
Bastien Montagne 2016-04-15 13:13:00 +02:00
parent 8ac662c77a
commit 10320891f0
Notes: blender-bot 2023-02-14 07:59:33 +01:00
Referenced by issue #48151, Texture won't refresh automatically in UV editor. Minor annoyance.
3 changed files with 13 additions and 28 deletions

View File

@ -653,34 +653,34 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna)
RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
RNA_def_property_enum_items(prop, prop_map_mode_items);
RNA_def_property_ui_text(prop, "Mode", "");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
prop = RNA_def_property(srna, "tex_paint_map_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
RNA_def_property_enum_items(prop, prop_tex_paint_map_mode_items);
RNA_def_property_ui_text(prop, "Mode", "");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
prop = RNA_def_property(srna, "mask_map_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode");
RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items);
RNA_def_property_ui_text(prop, "Mode", "");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
prop = RNA_def_property(srna, "use_rake", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "brush_angle_mode", MTEX_ANGLE_RAKE);
RNA_def_property_ui_text(prop, "Rake", "");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
prop = RNA_def_property(srna, "use_random", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "brush_angle_mode", MTEX_ANGLE_RANDOM);
RNA_def_property_ui_text(prop, "Random", "");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
prop = RNA_def_property(srna, "random_angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_range(prop, 0, M_PI * 2);
RNA_def_property_ui_text(prop, "Random Angle", "Brush texture random angle");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
TEXTURE_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source");
TEXTURE_CAPABILITY(has_random_texture_angle, "Has Random Texture Angle");

View File

@ -234,7 +234,6 @@ int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current);
void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
void rna_TextureSlot_brush_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr);
/* basic poll functions for object types */
int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value);

View File

@ -225,7 +225,7 @@ static void rna_Texture_type_set(PointerRNA *ptr, int value)
BKE_texture_type_set(tex, value);
}
void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
{
ID *id = ptr->id.data;
@ -244,8 +244,12 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
WM_main_add_notifier(NC_LAMP | ND_LIGHTING_DRAW, id);
break;
case ID_BR:
{
MTex *mtex = ptr->data;
BKE_paint_invalidate_overlay_tex(scene, mtex->tex);
WM_main_add_notifier(NC_BRUSH, id);
break;
}
case ID_LS:
WM_main_add_notifier(NC_LINESTYLE, id);
break;
@ -266,24 +270,6 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRN
}
}
void rna_TextureSlot_brush_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ID *id = ptr->id.data;
DAG_id_tag_update(id, 0);
switch (GS(id->name)) {
case ID_BR:
{
MTex *mtex = ptr->data;
BKE_paint_invalidate_overlay_tex(scene, mtex->tex);
break;
}
}
rna_TextureSlot_update(bmain, scene, ptr);
}
char *rna_TextureSlot_path(PointerRNA *ptr)
{
MTex *mtex = ptr->data;
@ -675,14 +661,14 @@ static void rna_def_mtex(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "ofs");
RNA_def_property_ui_range(prop, -10, 10, 10, RNA_TRANSLATION_PREC_DEFAULT);
RNA_def_property_ui_text(prop, "Offset", "Fine tune of the texture mapping X, Y and Z locations");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_flag(prop, PROP_PROPORTIONAL);
RNA_def_property_ui_range(prop, -100, 100, 10, 2);
RNA_def_property_ui_text(prop, "Size", "Set scaling for the texture's X, Y and Z sizes");
RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_update");
RNA_def_property_update(prop, 0, "rna_TextureSlot_update");
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "r");