Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2017-09-21 13:55:14 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-09-21 15:45:08 +0300
commit9ad2c0b6154b8e11521e9ee0422a79d5e0b9a2e1 (patch)
tree424a2422613eb855726d8b9e1a1b679d5e58f0c1 /source/blender
parent77377f0ea8152d0ed5009a4940298b081b186787 (diff)
Depsgraph and collection enable/visibility
Iterate over invisible objects too, so lamps can still lit the scene. Also, now you can use a collection to set an object to invisible, not only to visible. For example: Scene > Master collection > bedroom > furniture Scene > View Layer > bedroom (visible) > furniture (invisible) The View Layer has two linked collections, bedroom and furniture. This setup will make the furniture collection invisible. Note: Unlike what was suggested on D2849, this does not make collection visibility influence camera visibility. I will keep this as a separate patch. Reviewers: sergey Subscribers: sergey, brecht, fclem Differential Revision: https://developer.blender.org/D2849
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_object.h1
-rw-r--r--source/blender/blenkernel/intern/layer.c3
-rw-r--r--source/blender/blenkernel/intern/object.c9
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query.cc49
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c6
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c18
-rw-r--r--source/blender/draw/intern/draw_manager.c4
-rw-r--r--source/blender/draw/modes/object_mode.c7
-rw-r--r--source/blender/editors/space_view3d/drawobject.c2
-rw-r--r--source/blender/makesrna/intern/rna_object.c6
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c11
11 files changed, 73 insertions, 43 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 35cde742ff0..ce6a95c682b 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -83,6 +83,7 @@ bool BKE_object_exists_check(struct Object *obtest);
bool BKE_object_is_in_editmode(struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
+bool BKE_object_is_visible(struct Object *ob);
void BKE_object_init(struct Object *ob);
struct Object *BKE_object_add_only_object(
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 5d0cb6ae430..126a2b7bb6c 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1860,6 +1860,9 @@ void BKE_layer_eval_layer_collection(const struct EvaluationContext *UNUSED(eval
IDP_MergeGroup(base->collection_properties, layer_collection->properties_evaluated, true);
base->flag |= BASE_VISIBLED;
}
+ else {
+ base->flag &= ~BASE_VISIBLED;
+ }
if (is_selectable) {
base->flag |= BASE_SELECTABLED;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 9f48d8f6b11..cfb6db35810 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -562,6 +562,15 @@ bool BKE_object_is_in_wpaint_select_vert(Object *ob)
return false;
}
+/**
+ * Return if the object is visible, as evaluated by depsgraph
+ * Keep in sync with rna_object.c (object.is_visible).
+ */
+bool BKE_object_is_visible(Object *ob)
+{
+ return (ob->base_flag & BASE_VISIBLED) != 0;
+}
+
bool BKE_object_exists_check(Object *obtest)
{
Object *ob;
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc
index 7d0ac47e6fd..0d06cc48b88 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query.cc
@@ -211,33 +211,30 @@ void DEG_objects_iterator_next(BLI_Iterator *iter)
}
base = data->base->next;
- while (base != NULL) {
- if ((base->flag & BASE_VISIBLED) != 0) {
- // Object *ob = DEG_get_evaluated_object(data->graph, base->object);
- Object *ob = base->object;
- iter->current = ob;
- data->base = base;
-
- BLI_assert(DEG::deg_validate_copy_on_write_datablock(&ob->id));
-
- /* Make sure we have the base collection settings is already populated.
- * This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
- * Which usually means a missing call to DEG_id_tag_update(). */
- BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
-
- /* Flushing depsgraph data. */
- deg_flush_base_flags_and_settings(ob,
- base,
- data->base_flag);
-
- if ((data->flag & DEG_OBJECT_ITER_FLAG_DUPLI) && (ob->transflag & OB_DUPLI)) {
- data->dupli_parent = ob;
- data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, ob);
- data->dupli_object_next = (DupliObject *)data->dupli_list->first;
- }
- return;
+ if (base != NULL) {
+ // Object *ob = DEG_get_evaluated_object(data->graph, base->object);
+ Object *ob = base->object;
+ iter->current = ob;
+ data->base = base;
+
+ BLI_assert(DEG::deg_validate_copy_on_write_datablock(&ob->id));
+
+ /* Make sure we have the base collection settings is already populated.
+ * This will fail when BKE_layer_eval_layer_collection_pre hasn't run yet
+ * Which usually means a missing call to DEG_id_tag_update(). */
+ BLI_assert(!BLI_listbase_is_empty(&base->collection_properties->data.group));
+
+ /* Flushing depsgraph data. */
+ deg_flush_base_flags_and_settings(ob,
+ base,
+ data->base_flag);
+
+ if ((data->flag & DEG_OBJECT_ITER_FLAG_DUPLI) && (ob->transflag & OB_DUPLI)) {
+ data->dupli_parent = ob;
+ data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, ob);
+ data->dupli_object_next = (DupliObject *)data->dupli_list->first;
}
- base = base->next;
+ return;
}
/* Look for an object in the next set. */
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index e8821f23633..f27b5236d71 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -29,6 +29,8 @@
#include "BLI_dynstr.h"
#include "BLI_rand.h"
+#include "BKE_object.h"
+
#include "GPU_material.h"
#include "GPU_glew.h"
@@ -93,6 +95,10 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
}
if (ELEM(ob->type, OB_MESH)) {
+ if (!BKE_object_is_visible(ob)) {
+ return;
+ }
+
EEVEE_materials_cache_populate(vedata, sldata, ob);
const bool cast_shadow = true;
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 96db3164fe1..a37dc091aa8 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -590,7 +590,10 @@ static void EEVEE_planar_reflections_updates(EEVEE_SceneLayerData *sldata, EEVEE
eplanar->attenuation_bias = max_dist * -eplanar->attenuation_scale;
/* Debug Display */
- if (DRW_state_draw_support() && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
+ if (BKE_object_is_visible(ob) &&
+ DRW_state_draw_support() &&
+ (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+ {
DRWShadingGroup *grp = DRW_shgroup_create(e_data.probe_planar_display_sh, psl->probe_display);
DRW_shgroup_uniform_int(grp, "probeIdx", &ped->probe_id, 1);
@@ -643,8 +646,12 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
invert_m4(eprobe->parallaxmat);
/* Debug Display */
- if (DRW_state_draw_support() && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
- DRW_shgroup_call_dynamic_add(stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &probe->data_draw_size);
+ if (BKE_object_is_visible(ob) &&
+ DRW_state_draw_support() &&
+ (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+ {
+ DRW_shgroup_call_dynamic_add(
+ stl->g_data->cube_display_shgrp, &ped->probe_id, ob->obmat[3], &probe->data_draw_size);
}
}
@@ -701,7 +708,10 @@ static void EEVEE_lightprobes_updates(EEVEE_SceneLayerData *sldata, EEVEE_PassLi
copy_v3_v3_int(egrid->resolution, &probe->grid_resolution_x);
/* Debug Display */
- if (DRW_state_draw_support() && (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA)) {
+ if (BKE_object_is_visible(ob) &&
+ DRW_state_draw_support() &&
+ (probe->flag & LIGHTPROBE_FLAG_SHOW_DATA))
+ {
struct Gwn_Batch *geom = DRW_cache_sphere_get();
DRWShadingGroup *grp = DRW_shgroup_instance_create(e_data.probe_grid_display_sh, psl->probe_display, geom);
DRW_shgroup_set_instance_count(grp, ped->num_cell);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index bd143e33d09..b20c9fe013b 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2164,6 +2164,10 @@ bool DRW_object_is_renderable(Object *ob)
Scene *scene = DST.draw_ctx.scene;
Object *obedit = scene->obedit;
+ if (!BKE_object_is_visible(ob)) {
+ return false;
+ }
+
if (ob->type == OB_MESH) {
if (ob == obedit) {
IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_EDIT, "");
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 933f8a60b9f..22571808cbc 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -43,6 +43,7 @@
#include "BKE_camera.h"
#include "BKE_curve.h"
#include "BKE_global.h"
+#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_image.h"
#include "BKE_texture.h"
@@ -1562,7 +1563,7 @@ static void DRW_shgroup_lightprobe(OBJECT_StorageList *stl, Object *ob, SceneLay
static void DRW_shgroup_relationship_lines(OBJECT_StorageList *stl, Object *ob)
{
- if (ob->parent && ((ob->parent->base_flag & BASE_VISIBLED) != 0)) {
+ if (ob->parent && BKE_object_is_visible(ob->parent)) {
DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->obmat[3]);
DRW_shgroup_call_dynamic_add(stl->g_data->relationship_lines, ob->parent->obmat[3]);
}
@@ -1677,6 +1678,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
View3D *v3d = draw_ctx->v3d;
int theme_id = TH_UNDEFINED;
+ if (!BKE_object_is_visible(ob)) {
+ return;
+ }
+
//CollectionEngineSettings *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
//bool do_wire = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_wire");
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 2fce8783aa2..4df7f6762bc 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -9217,7 +9217,7 @@ afterdraw:
/* help lines and so */
if (ob != scene->obedit && ob->parent) {
- if ((ob->parent->base_flag & BASE_VISIBLED) != 0) {
+ if (BKE_object_is_visible(ob->parent)) {
setlinestyle(3);
immBegin(GWN_PRIM_LINES, 2);
immVertex3fv(pos, ob->obmat[3]);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 427ef5c307f..e57333fb8a7 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2897,6 +2897,12 @@ 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");
+ /* Keep it in sync with BKE_object_is_visible. */
+ prop = RNA_def_property(srna, "is_visible", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "base_flag", BASE_VISIBLED);
+ RNA_def_property_ui_text(prop, "Visible", "Visible to camera rays, set only on objects evaluated by depsgraph");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
prop = RNA_def_property(srna, "collection_properties", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "base_collection_properties->data.group", NULL);
RNA_def_property_struct_type(prop, "LayerCollectionSettings");
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index 7bf483ad2f0..1234bd9f367 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -329,11 +329,6 @@ static void rna_Object_shape_key_remove(
RNA_POINTER_INVALIDATE(kb_ptr);
}
-static int rna_Object_is_visible(Object *ob, Scene *sce)
-{
- return !(ob->restrictflag & OB_RESTRICT_VIEW) && (ob->lay & sce->lay);
-}
-
#if 0
static void rna_Mesh_assign_verts_to_group(Object *ob, bDeformGroup *group, int *indices, int totindex,
float weight, int assignmode)
@@ -754,12 +749,6 @@ void RNA_api_object(StructRNA *srna)
RNA_def_function_output(func, parm);
/* View */
- func = RNA_def_function(srna, "is_visible", "rna_Object_is_visible");
- RNA_def_function_ui_description(func, "Determine if object is visible in a given scene");
- parm = RNA_def_pointer(func, "scene", "Scene", "", "");
- RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED);
- parm = RNA_def_boolean(func, "result", 0, "", "Object visibility");
- RNA_def_function_return(func, parm);
/* utility function for checking if the object is modified */
func = RNA_def_function(srna, "is_modified", "rna_Object_is_modified");