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.
This commit is contained in:
2018-07-25 12:26:09 +02:00
parent 41130ecf16
commit b0077992d2
11 changed files with 129 additions and 38 deletions

View File

@@ -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");