From b89f2276e502da6480b4ceeb414b0e6b79e4edfe Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 21 Dec 2017 13:29:14 -0200 Subject: Implement duplicator viewport/render visibility options This allows a duplicator (as known as dupli parent) to be in a visible collection so its duplicated objects are visible, however while being invisible for the final render. An object that is a particle emitter is also considered a duplicator. Many thanks for the reviewers for the extense feedback. Reviewers: sergey, campbellbarton Differential Revision: https://developer.blender.org/D2966 --- source/blender/makesrna/intern/rna_depsgraph.c | 2 ++ source/blender/makesrna/intern/rna_layer.c | 2 +- source/blender/makesrna/intern/rna_object.c | 16 +++++++++++++++- source/blender/makesrna/intern/rna_particle.c | 5 ----- 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index 20ce54a4a01..706fb23ab56 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -168,6 +168,7 @@ static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, Pointe data->flag = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET; + data->mode = DEG_ITER_OBJECT_MODE_RENDER; ((BLI_Iterator *)iter->internal.custom)->valid = true; DEG_iterator_objects_begin(iter->internal.custom, data); @@ -208,6 +209,7 @@ static void rna_Depsgraph_duplis_begin(CollectionPropertyIterator *iter, Pointer DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI; + data->mode = DEG_ITER_OBJECT_MODE_RENDER; ((BLI_Iterator *)iter->internal.custom)->valid = true; DEG_iterator_objects_begin(iter->internal.custom, data); diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 00b08957fdd..f64cfef45df 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -870,7 +870,7 @@ static void rna_LayerObjects_selected_begin(CollectionPropertyIterator *iter, Po static void rna_ViewLayer_update_tagged(ViewLayer *UNUSED(view_layer), bContext *C) { Depsgraph *graph = CTX_data_depsgraph(C); - DEG_OBJECT_ITER(graph, ob, + DEG_OBJECT_ITER(graph, ob, DEG_ITER_OBJECT_MODE_VIEWPORT, DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY | diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 786598b0731..b83b793b431 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -232,7 +232,13 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA static int rna_Object_is_visible_get(PointerRNA *ptr) { Object *ob = ptr->id.data; - return BKE_object_is_visible(ob); + /* The duplicators final visibility is not evaluated by depsgraph, so it's + * in ob->base_flag & VISIBLED. Instead we need to take into account whether + * we are rendering or not, and the ob->duplicator_visibility_flag. + * However for this assessor we don't know if we are rendering, so we just + * ignore the duplicator visibility + */ + return BKE_object_is_visible(ob, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE); } static void rna_Object_collection_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) @@ -2798,6 +2804,14 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update"); + prop = RNA_def_property(srna, "show_duplicator_for_render", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_RENDER); + RNA_def_property_ui_text(prop, "Render Duplicator", "Make duplicator visible when rendering"); + + prop = RNA_def_property(srna, "show_duplicator_for_viewport", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "duplicator_visibility_flag", OB_DUPLI_FLAG_VIEWPORT); + RNA_def_property_ui_text(prop, "Show Duplicator", "Make duplicator visible in the viewport"); + prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_Object_is_visible_get", NULL); RNA_def_property_ui_text(prop, "Visible", "Visible to camera rays, set only on objects evaluated by depsgraph"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 67eaa22fbe4..12e56b8e926 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -2292,11 +2292,6 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Size", "Show particle size"); RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "use_render_emitter", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_EMITTER); - RNA_def_property_ui_text(prop, "Emitter", "Render emitter Object also"); - RNA_def_property_update(prop, 0, "rna_Particle_redo"); - prop = RNA_def_property(srna, "show_health", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw", PART_DRAW_HEALTH); RNA_def_property_ui_text(prop, "Health", "Draw boid health"); -- cgit v1.2.3