Fix (studio-reported) missing RNA path for EEVEE render passes.

For those EEVEE passes a bit of trickery with pointer offsets allows to
get the owning viewlayer, so path generation is not too bad.

Also moved ViewLayer path generation itself into a public utils, to
avoid duplicating code.

NOTE: Doing the same for AOV would be needed, but since pointer offsets
won't help us here to find the owning viewlayer, not sure how to do it
nicely yet (only solution I think is to loop over all AOVs of all
ViewLayer of the scene to find it :( ).

Reported by Beau Gerbrands (@Beaug), thanks.
This commit is contained in:
Bastien Montagne 2022-01-31 15:16:36 +01:00
parent b9718899fa
commit 180a68c1dc
3 changed files with 37 additions and 4 deletions

View File

@ -369,6 +369,13 @@ void rna_ViewLayer_active_aov_index_range(
PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax);
int rna_ViewLayer_active_aov_index_get(PointerRNA *ptr);
void rna_ViewLayer_active_aov_index_set(PointerRNA *ptr, int value);
/** Set `r_rna_path` with the base viewlayer path.
* `rna_path_buffer_size` should be at least `sizeof(ViewLayer.name) * 3`.
* \return actual length of the generayted RNA path.
*/
size_t rna_ViewLayer_path_buffer_get(struct ViewLayer *view_layer,
char *r_rna_path,
const size_t rna_path_buffer_size);
/* named internal so as not to conflict with obj.update() rna func */
void rna_Object_internal_update_data(struct Main *bmain,

View File

@ -112,13 +112,24 @@ static void rna_LayerObjects_active_object_set(PointerRNA *ptr,
}
}
size_t rna_ViewLayer_path_buffer_get(ViewLayer *view_layer,
char *r_rna_path,
const size_t rna_path_buffer_size)
{
char name_esc[sizeof(view_layer->name) * 2];
BLI_str_escape(name_esc, view_layer->name, sizeof(name_esc));
return BLI_snprintf_rlen(r_rna_path, rna_path_buffer_size, "view_layers[\"%s\"]", name_esc);
}
static char *rna_ViewLayer_path(PointerRNA *ptr)
{
ViewLayer *srl = (ViewLayer *)ptr->data;
char name_esc[sizeof(srl->name) * 2];
ViewLayer *view_layer = (ViewLayer *)ptr->data;
char rna_path[sizeof(view_layer->name) * 3];
BLI_str_escape(name_esc, srl->name, sizeof(name_esc));
return BLI_sprintfN("view_layers[\"%s\"]", name_esc);
rna_ViewLayer_path_buffer_get(view_layer, rna_path, sizeof(rna_path));
return BLI_strdup(rna_path);
}
static IDProperty **rna_ViewLayer_idprops(PointerRNA *ptr)

View File

@ -1769,6 +1769,20 @@ void rna_ViewLayer_pass_update(Main *bmain, Scene *activescene, PointerRNA *ptr)
rna_Scene_glsl_update(bmain, activescene, ptr);
}
static char *rna_ViewLayerEEVEE_path(PointerRNA *ptr)
{
ViewLayerEEVEE *view_layer_eevee = (ViewLayerEEVEE *)ptr->data;
ViewLayer *view_layer = (ViewLayer *)((uint8_t *)view_layer_eevee - offsetof(ViewLayer, eevee));
char rna_path[sizeof(view_layer->name) * 3];
const size_t view_layer_path_len = rna_ViewLayer_path_buffer_get(
view_layer, rna_path, sizeof(rna_path));
BLI_strncpy(rna_path + view_layer_path_len, ".eevee", sizeof(rna_path) - view_layer_path_len);
return BLI_strdup(rna_path);
}
static char *rna_SceneRenderView_path(PointerRNA *ptr)
{
SceneRenderView *srv = (SceneRenderView *)ptr->data;
@ -4019,6 +4033,7 @@ static void rna_def_view_layer_eevee(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "ViewLayerEEVEE", NULL);
RNA_def_struct_path_func(srna, "rna_ViewLayerEEVEE_path");
RNA_def_struct_ui_text(srna, "Eevee Settings", "View layer settings for Eevee");
prop = RNA_def_property(srna, "use_pass_volume_direct", PROP_BOOLEAN, PROP_NONE);