From b0077992d2759b29b536187a226e8382b72261b6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 25 Jul 2018 12:26:09 +0200 Subject: Cycles: add per layer collection mask/holdout support. In the outliner, right click > view layer > set holdout. This is temporary until we have more general dynamic overrides, but helps Spring production for now. --- source/blender/makesrna/intern/rna_object_api.c | 32 ++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'source/blender/makesrna/intern/rna_object_api.c') diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 1a2b3854668..dc799928e5a 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -148,6 +148,18 @@ static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) return ((base->flag & BASE_VISIBLE) != 0) ? 1 : 0; } +static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *view_layer) +{ + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, view_layer->name); + return -1; + } + + return ((base->flag & BASE_HOLDOUT) != 0) ? 1 : 0; +} + /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, float *mat, float *mat_ret, int from, int to) @@ -470,31 +482,39 @@ void RNA_api_object(StructRNA *srna) #endif static EnumPropertyItem object_select_items[] = { - {0, "SELECT", 0, "Select", "Select object from the active render layer"}, - {1, "DESELECT", 0, "Deselect", "Deselect object from the active render layer"}, - {2, "TOGGLE", 0, "Toggle", "Toggle object selection from the active render layer"}, + {0, "SELECT", 0, "Select", "Select object from the active view layer"}, + {1, "DESELECT", 0, "Deselect", "Deselect object from the active view layer"}, + {2, "TOGGLE", 0, "Toggle", "Toggle object selection from the active view layer"}, {0, NULL, 0, NULL, NULL} }; /* Special wrapper to access the base selection value */ func = RNA_def_function(srna, "select_set", "rna_Object_select_set"); - RNA_def_function_ui_description(func, "Select the object (for the active render layer)"); + RNA_def_function_ui_description(func, "Select the object (for the active view layer)"); RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); parm = RNA_def_enum(func, "action", object_select_items, 0, "Action", "Select mode"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); func = RNA_def_function(srna, "select_get", "rna_Object_select_get"); - RNA_def_function_ui_description(func, "Get the object selection for the active render layer"); + RNA_def_function_ui_description(func, "Get the object selection for the active view layer"); RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); parm = RNA_def_boolean(func, "result", 0, "", "Object selected"); RNA_def_function_return(func, parm); func = RNA_def_function(srna, "visible_get", "rna_Object_visible_get"); - RNA_def_function_ui_description(func, "Get the object visibility for the active render layer"); + RNA_def_function_ui_description(func, "Get the object visibility for the active view layer"); RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); parm = RNA_def_boolean(func, "result", 0, "", "Object visible"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "holdout_get", "rna_Object_holdout_get"); + RNA_def_function_ui_description(func, "Test if object is masked in the view layer"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_boolean(func, "result", 0, "", "Object holdout"); + RNA_def_function_return(func, parm); + /* Matrix space conversion */ func = RNA_def_function(srna, "convert_space", "rna_Object_mat_convert_space"); RNA_def_function_ui_description(func, "Convert (transform) the given matrix from one space to another"); -- cgit v1.2.3 From 885cda65c90b3f85dc4e72e2e9759aa926a8f07c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 25 Jul 2018 12:26:09 +0200 Subject: Cycles: add per layer collection indirectly on setting. In the outliner, right click > view layer > set indirect only. This is like clearing camera ray visibility on objects in the collection, and is temporary until we have more general dynamic overrides. --- source/blender/makesrna/intern/rna_object_api.c | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'source/blender/makesrna/intern/rna_object_api.c') diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index dc799928e5a..44709db9d94 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -128,7 +128,7 @@ static bool rna_Object_select_get(Object *ob, bContext *C, ReportList *reports) Base *base = BKE_view_layer_base_find(view_layer, ob); if (!base) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, view_layer->name); + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); return -1; } @@ -141,7 +141,7 @@ static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) Base *base = BKE_view_layer_base_find(view_layer, ob); if (!base) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, view_layer->name); + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); return -1; } @@ -153,13 +153,25 @@ static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *v Base *base = BKE_view_layer_base_find(view_layer, ob); if (!base) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' not in Render Layer '%s'!", ob->id.name + 2, view_layer->name); + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); return -1; } return ((base->flag & BASE_HOLDOUT) != 0) ? 1 : 0; } +static bool rna_Object_indirect_only_get(Object *ob, ReportList *reports, ViewLayer *view_layer) +{ + Base *base = BKE_view_layer_base_find(view_layer, ob); + + if (!base) { + BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); + return -1; + } + + return ((base->flag & BASE_INDIRECT_ONLY) != 0) ? 1 : 0; +} + /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ static void rna_Object_mat_convert_space(Object *ob, ReportList *reports, bPoseChannel *pchan, float *mat, float *mat_ret, int from, int to) @@ -515,6 +527,14 @@ void RNA_api_object(StructRNA *srna) parm = RNA_def_boolean(func, "result", 0, "", "Object holdout"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "indirect_only_get", "rna_Object_indirect_only_get"); + RNA_def_function_ui_description(func, "Test if object is set to contribute only indirectly (through shadows and reflections) in the view layer"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "view_layer", "ViewLayer", "", ""); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + parm = RNA_def_boolean(func, "result", 0, "", "Object indirect only"); + RNA_def_function_return(func, parm); + /* Matrix space conversion */ func = RNA_def_function(srna, "convert_space", "rna_Object_mat_convert_space"); RNA_def_function_ui_description(func, "Convert (transform) the given matrix from one space to another"); -- cgit v1.2.3 From 9a40690242dff4153a48c1da0f0f87a71a020e64 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 25 Jul 2018 18:30:26 +0200 Subject: Fix for holdout / indirect only with collection instances. --- source/blender/makesrna/intern/rna_object_api.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/makesrna/intern/rna_object_api.c') diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 44709db9d94..8f8f3176096 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -129,10 +129,10 @@ static bool rna_Object_select_get(Object *ob, bContext *C, ReportList *reports) if (!base) { BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); - return -1; + return false; } - return ((base->flag & BASE_SELECTED) != 0) ? 1 : 0; + return ((base->flag & BASE_SELECTED) != 0); } static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) @@ -142,10 +142,10 @@ static bool rna_Object_visible_get(Object *ob, bContext *C, ReportList *reports) if (!base) { BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); - return -1; + return false; } - return ((base->flag & BASE_VISIBLE) != 0) ? 1 : 0; + return ((base->flag & BASE_VISIBLE) != 0); } static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *view_layer) @@ -154,10 +154,10 @@ static bool rna_Object_holdout_get(Object *ob, ReportList *reports, ViewLayer *v if (!base) { BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); - return -1; + return false; } - return ((base->flag & BASE_HOLDOUT) != 0) ? 1 : 0; + return ((base->flag & BASE_HOLDOUT) != 0); } static bool rna_Object_indirect_only_get(Object *ob, ReportList *reports, ViewLayer *view_layer) @@ -166,10 +166,10 @@ static bool rna_Object_indirect_only_get(Object *ob, ReportList *reports, ViewLa if (!base) { BKE_reportf(reports, RPT_ERROR, "Object '%s' not in View Layer '%s'!", ob->id.name + 2, view_layer->name); - return -1; + return false; } - return ((base->flag & BASE_INDIRECT_ONLY) != 0) ? 1 : 0; + return ((base->flag & BASE_INDIRECT_ONLY) != 0); } /* Convert a given matrix from a space to another (using the object and/or a bone as reference). */ -- cgit v1.2.3 From 29d1db9ed6253f68c5452be1f0125ed364d4a954 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 25 Jul 2018 21:05:44 +0200 Subject: Fix T55964: Direction not normalized in isect_ray_aabb_v3_simple()? RNA API Object.ray_cast would not normalize direction vector before doing first quick bbox intersection test, while using its returned distance value. This could lead to wrong exclusion of object. Thanks to @codemanx for finding that issue. --- source/blender/makesrna/intern/rna_object_api.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source/blender/makesrna/intern/rna_object_api.c') diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 2acda5985e1..376a89c65d1 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -332,8 +332,10 @@ static void rna_Object_ray_cast( /* Test BoundBox first (efficiency) */ BoundBox *bb = BKE_object_boundbox_get(ob); float distmin; - if (!bb || (isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, NULL) && distmin <= distance)) { - + normalize_v3(direction); /* Needed for valid distance check from isect_ray_aabb_v3_simple() call. */ + if (!bb || + (isect_ray_aabb_v3_simple(origin, direction, bb->vec[0], bb->vec[6], &distmin, NULL) && distmin <= distance)) + { BVHTreeFromMesh treeData = {NULL}; /* no need to managing allocation or freeing of the BVH data. this is generated and freed as needed */ @@ -346,9 +348,6 @@ static void rna_Object_ray_cast( hit.index = -1; hit.dist = distance; - normalize_v3(direction); - - if (BLI_bvhtree_ray_cast(treeData.tree, origin, direction, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { -- cgit v1.2.3