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-12-21 18:29:14 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-12-21 18:43:24 +0300
commitb89f2276e502da6480b4ceeb414b0e6b79e4edfe (patch)
tree77d5756979af9137e645fcdfc3fff5dc36702b4a /source/blender/depsgraph
parent103dd660573bb77b8917387bb2773a96de56fb38 (diff)
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
Diffstat (limited to 'source/blender/depsgraph')
-rw-r--r--source/blender/depsgraph/DEG_depsgraph_query.h13
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_iter.cc17
2 files changed, 25 insertions, 5 deletions
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index c782a91f76e..83fb100436c 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -77,12 +77,18 @@ enum {
DEG_ITER_OBJECT_FLAG_DUPLI = (1 << 4),
};
+typedef enum eDepsObjectIteratorMode {
+ DEG_ITER_OBJECT_MODE_VIEWPORT = 0,
+ DEG_ITER_OBJECT_MODE_RENDER = 1,
+} eDepsObjectIteratorMode;
+
typedef struct DEGObjectIterData {
struct Depsgraph *graph;
struct Scene *scene;
struct EvaluationContext eval_ctx;
int flag;
+ eDepsObjectIteratorMode mode;
/* **** Iteration over dupli-list. *** */
@@ -115,10 +121,11 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
* Although they are available they have no overrides (collection_properties)
* and will crash if you try to access it.
*/
-#define DEG_OBJECT_ITER(graph_, instance_, flag_) \
+#define DEG_OBJECT_ITER(graph_, instance_, mode_, flag_) \
{ \
DEGObjectIterData data_ = { \
.graph = (graph_), \
+ .mode = (mode_), \
.flag = (flag_), \
}; \
\
@@ -134,8 +141,8 @@ void DEG_iterator_objects_end(struct BLI_Iterator *iter);
/**
* Depsgraph objects iterator for draw manager and final render
*/
-#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE(graph_, instance_) \
- DEG_OBJECT_ITER(graph_, instance_, \
+#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE(graph_, instance_, mode_) \
+ DEG_OBJECT_ITER(graph_, instance_, mode_, \
DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | \
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | \
DEG_ITER_OBJECT_FLAG_VISIBLE | \
diff --git a/source/blender/depsgraph/intern/depsgraph_query_iter.cc b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
index 2a323fe63bd..42d512d473c 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_iter.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_iter.cc
@@ -84,6 +84,7 @@ static bool deg_objects_dupli_iterator_next(BLI_Iterator *iter)
Object *dupli_parent = data->dupli_parent;
Object *temp_dupli_object = &data->temp_dupli_object;
*temp_dupli_object = *dob->ob;
+ temp_dupli_object->transflag &= ~OB_DUPLI;
temp_dupli_object->select_color = dupli_parent->select_color;
temp_dupli_object->base_flag = dupli_parent->base_flag | BASE_FROMDUPLI;
@@ -139,7 +140,7 @@ static void DEG_iterator_objects_step(BLI_Iterator *iter, DEG::IDDepsNode *id_no
Object *object = (Object *)id_node->id_cow;
BLI_assert(DEG::deg_validate_copy_on_write_datablock(&object->id));
- if ((BKE_object_is_visible(object) == false) &&
+ if ((BKE_object_is_visible(object, OB_VISIBILITY_CHECK_UNKNOWN_RENDER_MODE) == false) &&
((data->flag & DEG_ITER_OBJECT_FLAG_VISIBLE) != 0))
{
return;
@@ -149,6 +150,14 @@ static void DEG_iterator_objects_step(BLI_Iterator *iter, DEG::IDDepsNode *id_no
data->dupli_parent = object;
data->dupli_list = object_duplilist(&data->eval_ctx, data->scene, object);
data->dupli_object_next = (DupliObject *)data->dupli_list->first;
+
+ const eObjectVisibilityCheck mode = (data->mode == DEG_ITER_OBJECT_MODE_RENDER) ?
+ OB_VISIBILITY_CHECK_FOR_RENDER :
+ OB_VISIBILITY_CHECK_FOR_VIEWPORT;
+
+ if (BKE_object_is_visible(object, mode) == false) {
+ return;
+ }
}
iter->current = object;
@@ -167,7 +176,10 @@ void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
}
/* TODO(sergey): What evaluation type we want here? */
- DEG_evaluation_context_init(&data->eval_ctx, DAG_EVAL_RENDER);
+ /* TODO(dfelinto): Get rid of evaluation context here, it's only used to do
+ * direct dupli-objects update in group.c. Which is terribly bad, and all
+ * objects are expected to be evaluated already. */
+ DEG_evaluation_context_init(&data->eval_ctx, DAG_EVAL_VIEWPORT);
data->eval_ctx.view_layer = DEG_get_evaluated_view_layer(depsgraph);
iter->data = data;
@@ -193,6 +205,7 @@ void DEG_iterator_objects_next(BLI_Iterator *iter)
Depsgraph *depsgraph = data->graph;
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(depsgraph);
do {
+ iter->skip = false;
if (data->dupli_list) {
if (deg_objects_dupli_iterator_next(iter)) {
return;