From 0601d173d75d51bf1ac57b54f6814daf3ab5d084 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 11 Sep 2023 14:16:48 +0200 Subject: [PATCH 1/3] Fix: 3d header missing update changing vertexgroups Since 3b5df8a7ea, we are displaying a "canvas picker" in the 3DView header. In weightpaint mode, this gives us the active vertexgroup to paint on, however the header wasnt updating when changing the vertexgroup elsewhere (e.g. from the Properties Editor). Part of #112186. --- source/blender/editors/space_view3d/space_view3d.cc | 5 +++++ source/blender/makesrna/intern/rna_object.cc | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index fbe70beded6..dcf4a413bdd 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -1620,6 +1620,11 @@ static void view3d_header_region_listener(const wmRegionListenerParams *params) case NC_BRUSH: ED_region_tag_redraw(region); break; + case NC_GEOM: + if (wmn->data & ND_VERTEX_GROUP) { + ED_region_tag_redraw(region); + } + break; } /* From top-bar, which ones are needed? split per header? */ diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index 30ba860b651..407b6a9b10b 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -2754,7 +2754,8 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) "rna_Object_active_vertex_group_index_range"); RNA_def_property_ui_text( prop, "Active Vertex Group Index", "Active index in vertex group array"); - RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); + RNA_def_property_update( + prop, NC_GEOM | ND_DATA | ND_VERTEX_GROUP, "rna_Object_internal_update_data"); /* vertex groups */ /* add_vertex_group */ func = RNA_def_function(srna, "new", "rna_Object_vgroup_new"); -- 2.30.2 From 45d95a5635d24282d17bed95e1b75e418313f24e Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 12 Sep 2023 14:20:59 +0200 Subject: [PATCH 2/3] address PR review - separat add_notifier call (also in a second needed place) - dont compare as flag [even though I think they are :)] --- source/blender/editors/space_view3d/space_view3d.cc | 2 +- source/blender/makesrna/intern/rna_object.cc | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index dcf4a413bdd..8ecb5cfdeef 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -1621,7 +1621,7 @@ static void view3d_header_region_listener(const wmRegionListenerParams *params) ED_region_tag_redraw(region); break; case NC_GEOM: - if (wmn->data & ND_VERTEX_GROUP) { + if (wmn->data == ND_VERTEX_GROUP) { ED_region_tag_redraw(region); } break; diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index 407b6a9b10b..f2be6cc6ce2 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -933,6 +933,7 @@ static void rna_Object_active_vertex_group_set(PointerRNA *ptr, } BKE_object_defgroup_active_index_set(ob, index + 1); + WM_main_add_notifier(NC_GEOM | ND_VERTEX_GROUP, ob->data); } static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr) @@ -953,6 +954,7 @@ static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value) } BKE_object_defgroup_active_index_set(ob, value + 1); + WM_main_add_notifier(NC_GEOM | ND_VERTEX_GROUP, ob->data); } static void rna_Object_active_vertex_group_index_range( @@ -2754,8 +2756,7 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) "rna_Object_active_vertex_group_index_range"); RNA_def_property_ui_text( prop, "Active Vertex Group Index", "Active index in vertex group array"); - RNA_def_property_update( - prop, NC_GEOM | ND_DATA | ND_VERTEX_GROUP, "rna_Object_internal_update_data"); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); /* vertex groups */ /* add_vertex_group */ func = RNA_def_function(srna, "new", "rna_Object_vgroup_new"); -- 2.30.2 From 1d6d1e3c7331133f5f740043f3816aa1aa21ccf4 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Tue, 12 Sep 2023 15:09:45 +0200 Subject: [PATCH 3/3] second PR review - only call notifiers from update callbacks (not from "set" callbacks), therefor, add a special update callback for setting vertex groups --- source/blender/makesrna/intern/rna_object.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index f2be6cc6ce2..d81dd03a8fe 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -861,6 +861,13 @@ static void rna_Object_dup_collection_set(PointerRNA *ptr, } } +static void rna_Object_vertex_groups_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr) +{ + Object *ob = reinterpret_cast(ptr->owner_id); + WM_main_add_notifier(NC_GEOM | ND_VERTEX_GROUP, ob->data); + rna_Object_internal_update_data_impl(ptr); +} + static void rna_Object_vertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Object *ob = static_cast(ptr->data); @@ -933,7 +940,6 @@ static void rna_Object_active_vertex_group_set(PointerRNA *ptr, } BKE_object_defgroup_active_index_set(ob, index + 1); - WM_main_add_notifier(NC_GEOM | ND_VERTEX_GROUP, ob->data); } static int rna_Object_active_vertex_group_index_get(PointerRNA *ptr) @@ -954,7 +960,6 @@ static void rna_Object_active_vertex_group_index_set(PointerRNA *ptr, int value) } BKE_object_defgroup_active_index_set(ob, value + 1); - WM_main_add_notifier(NC_GEOM | ND_VERTEX_GROUP, ob->data); } static void rna_Object_active_vertex_group_index_range( @@ -2746,7 +2751,7 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) nullptr); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Vertex Group", "Vertex groups of the object"); - RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_vertex_groups_update"); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -2756,7 +2761,7 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) "rna_Object_active_vertex_group_index_range"); RNA_def_property_ui_text( prop, "Active Vertex Group Index", "Active index in vertex group array"); - RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_vertex_groups_update"); /* vertex groups */ /* add_vertex_group */ func = RNA_def_function(srna, "new", "rna_Object_vgroup_new"); -- 2.30.2