[Bf-blender-cvs] [3e946a6f138] temp-dynamic-overrides: Tag COW when link/unlinking collections
Dalai Felinto
noreply at git.blender.org
Mon May 28 01:48:18 CEST 2018
Commit: 3e946a6f1383511d4094096757087230e78e1ddf
Author: Dalai Felinto
Date: Mon May 28 01:42:01 2018 +0200
Branches: temp-dynamic-overrides
https://developer.blender.org/rB3e946a6f1383511d4094096757087230e78e1ddf
Tag COW when link/unlinking collections
In theory we can tag only the objects that are in the corresponding colletction
and its children.
===================================================================
M source/blender/editors/scene/scene_edit.c
M source/blender/makesrna/intern/rna_layer.c
===================================================================
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index 07fd18313b3..a165714c322 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -388,6 +388,7 @@ static int view_layer_override_set_collection_link_exec(bContext *C, wmOperator
if (BKE_view_layer_override_set_collection_link(override_set, collection)) {
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_graph_id_type_tag_update(CTX_data_main(C), CTX_data_depsgraph(C), ID_OB, DEG_TAG_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_SCENE | ND_DYN_OVERRIDES, scene);
return OPERATOR_FINISHED;
}
@@ -571,6 +572,8 @@ static int view_layer_override_set_collection_unlink_exec(bContext *C, wmOperato
BKE_view_layer_override_set_collection_unlink(override_set, collection);
DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_graph_id_type_tag_update(CTX_data_main(C), CTX_data_depsgraph(C), ID_OB, DEG_TAG_COPY_ON_WRITE);
+
WM_event_add_notifier(C, NC_SCENE | ND_DYN_OVERRIDES, scene);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index e56e2022901..ac4a3ac7268 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -240,24 +240,26 @@ static void rna_OverriddenCollections_active_set(PointerRNA *ptr, PointerRNA val
}
static void rna_OverriddenCollection_link(
- ID *id, OverrideSet *override_set, Main *UNUSED(bmain), ReportList *reports, Collection *collection)
+ ID *id, OverrideSet *override_set, Main *bmain, bContext *C, ReportList *reports, Collection *collection)
{
- if (BKE_view_layer_override_set_collection_link(override_set, collection)) {
- Scene *scene = (Scene *)id;
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
- WM_main_add_notifier(NC_SCENE | ND_DYN_OVERRIDES, scene);
- }
- else {
+ if (!BKE_view_layer_override_set_collection_link(override_set, collection)) {
BKE_reportf(reports,
RPT_ERROR,
"Collection '%s' already affected by override set '%s'",
collection->id.name + 2,
override_set->name);
+ return;
}
+
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene = (Scene *)id;
+ DEG_graph_id_tag_update(bmain, depsgraph, &scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_graph_id_type_tag_update(bmain, depsgraph, ID_OB, DEG_TAG_COPY_ON_WRITE);
+ WM_main_add_notifier(NC_SCENE | ND_DYN_OVERRIDES, scene);
}
static void rna_OverriddenCollection_unlink(
- ID *id, OverrideSet *override_set, Main *UNUSED(bmain), ReportList *reports, Collection *collection)
+ ID *id, OverrideSet *override_set, Main *bmain, bContext *C, ReportList *reports, Collection *collection)
{
if (!BKE_view_layer_override_set_collection_unlink(override_set, collection)) {
BKE_reportf(reports,
@@ -265,12 +267,14 @@ static void rna_OverriddenCollection_unlink(
"Collection '%s' is not affected by override set '%s'",
collection->id.name + 2,
override_set->name);
+ return;
}
- else {
- Scene *scene = (Scene *)id;
- DEG_id_tag_update(&scene->id, DEG_TAG_COPY_ON_WRITE);
- WM_main_add_notifier(NC_SCENE | ND_DYN_OVERRIDES, scene);
- }
+
+ Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Scene *scene = (Scene *)id;
+ DEG_graph_id_tag_update(bmain, depsgraph, &scene->id, DEG_TAG_COPY_ON_WRITE);
+ DEG_graph_id_type_tag_update(bmain, depsgraph, ID_OB, DEG_TAG_COPY_ON_WRITE);
+ WM_main_add_notifier(NC_SCENE | ND_DYN_OVERRIDES, scene);
}
static char *rna_OverrideSet_path(PointerRNA *ptr)
@@ -532,13 +536,13 @@ static void rna_def_overridden_collections(BlenderRNA *brna, PropertyRNA *cprop)
func = RNA_def_function(srna, "link", "rna_OverriddenCollection_link");
RNA_def_function_ui_description(func, "Link collection to override set");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "collection", "Collection", "", "Collection to link to override set");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
func = RNA_def_function(srna, "unlink", "rna_OverriddenCollection_unlink");
RNA_def_function_ui_description(func, "Unlink a collection from override set");
- RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_REPORTS);
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
parm = RNA_def_pointer(func, "collection", "Collection", "", "Collection to unlink from override set");
RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
More information about the Bf-blender-cvs
mailing list