From 236881ff9c0d5dddc0da6f87ce1b69f030c6bf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 30 Jan 2024 17:12:17 +0100 Subject: [PATCH] Anim: Armature, move notifiers from setters to updaters Move WM notifiers from property setter functions to `RNA_def_property_update` call. This actually makes them work properly, for example setting `bone_collection.is_solo` from Python now actually updates the armature in the 3D Viewport. Toggling the property from the UI already worked (for other reasons, apparently), masking this issue. --- source/blender/makesrna/intern/rna_armature.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/source/blender/makesrna/intern/rna_armature.cc b/source/blender/makesrna/intern/rna_armature.cc index 528be8ed67c..c489f97170b 100644 --- a/source/blender/makesrna/intern/rna_armature.cc +++ b/source/blender/makesrna/intern/rna_armature.cc @@ -352,7 +352,6 @@ static void rna_BoneCollections_active_name_set(PointerRNA *ptr, const char *nam { bArmature *arm = (bArmature *)ptr->data; ANIM_armature_bonecoll_active_name_set(arm, name); - WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, ptr->data); } static void rna_BoneCollections_move(bArmature *arm, ReportList *reports, int from, int to) @@ -373,7 +372,6 @@ static void rna_BoneCollection_name_set(PointerRNA *ptr, const char *name) BoneCollection *bcoll = (BoneCollection *)ptr->data; ANIM_armature_bonecoll_name_set(arm, bcoll, name); - WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, &arm->id); } static void rna_BoneCollection_is_visible_set(PointerRNA *ptr, const bool is_visible) @@ -382,9 +380,6 @@ static void rna_BoneCollection_is_visible_set(PointerRNA *ptr, const bool is_vis BoneCollection *bcoll = (BoneCollection *)ptr->data; ANIM_armature_bonecoll_is_visible_set(arm, bcoll, is_visible); - - WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, &arm->id); - WM_main_add_notifier(NC_OBJECT | ND_POSE, &arm->id); } static bool rna_BoneCollection_is_visible_effectively_get(PointerRNA *ptr) @@ -400,9 +395,6 @@ static void rna_BoneCollection_is_solo_set(PointerRNA *ptr, const bool is_solo) BoneCollection *bcoll = (BoneCollection *)ptr->data; ANIM_armature_bonecoll_solo_set(arm, bcoll, is_solo); - - WM_main_add_notifier(NC_OBJECT | ND_BONE_COLLECTION, &arm->id); - WM_main_add_notifier(NC_OBJECT | ND_POSE, &arm->id); } static char *rna_BoneCollection_path(const PointerRNA *ptr) @@ -1999,6 +1991,7 @@ static void rna_def_armature_collections(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_funcs( prop, nullptr, "rna_BoneCollections_active_set", nullptr, nullptr); RNA_def_property_ui_text(prop, "Active Collection", "Armature's active bone collection"); + RNA_def_property_update(prop, NC_OBJECT | ND_BONE_COLLECTION, nullptr); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, nullptr, "runtime.active_collection_index"); @@ -2018,6 +2011,7 @@ static void rna_def_armature_collections(BlenderRNA *brna, PropertyRNA *cprop) "rna_BoneCollections_active_index_get", "rna_BoneCollections_active_index_set", "rna_BoneCollections_active_index_range"); + RNA_def_property_update(prop, NC_OBJECT | ND_BONE_COLLECTION, nullptr); prop = RNA_def_property(srna, "active_name", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, nullptr, "active_collection_name"); @@ -2029,6 +2023,7 @@ static void rna_def_armature_collections(BlenderRNA *brna, PropertyRNA *cprop) "The name of the Armature's active bone collection; empty when there " "is no active collection"); RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_BoneCollections_active_name_set"); + RNA_def_property_update(prop, NC_OBJECT | ND_BONE_COLLECTION, nullptr); prop = RNA_def_property(srna, "is_solo_active", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flag", ARM_BCOLL_SOLO_ACTIVE); @@ -2308,6 +2303,7 @@ static void rna_def_bonecollection(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Name", "Unique within the Armature"); RNA_def_struct_name_property(srna, prop); RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_BoneCollection_name_set"); + RNA_def_property_update(prop, NC_OBJECT | ND_BONE_COLLECTION, nullptr); prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flags", BONE_COLLECTION_VISIBLE); @@ -2316,6 +2312,7 @@ static void rna_def_bonecollection(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_boolean_funcs(prop, nullptr, "rna_BoneCollection_is_visible_set"); + RNA_def_property_update(prop, NC_OBJECT | ND_BONE_COLLECTION, nullptr); prop = RNA_def_property(srna, "is_visible_ancestors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flags", BONE_COLLECTION_ANCESTORS_VISIBLE); @@ -2341,6 +2338,7 @@ static void rna_def_bonecollection(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_boolean_funcs(prop, nullptr, "rna_BoneCollection_is_solo_set"); + RNA_def_property_update(prop, NC_OBJECT | ND_BONE_COLLECTION, nullptr); prop = RNA_def_property(srna, "is_local_override", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, nullptr, "flags", BONE_COLLECTION_OVERRIDE_LIBRARY_LOCAL);