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:
authorBastien Montagne <bastien@blender.org>2022-01-31 17:16:36 +0300
committerBastien Montagne <bastien@blender.org>2022-01-31 17:16:36 +0300
commit180a68c1dcc7f18d746b43803e34119f31fc323d (patch)
tree15a60f84ba3ee4775d623ba936e1027f6e2754a2
parentb9718899fa6448e96868de4e56a5a12835381ae1 (diff)
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.
-rw-r--r--source/blender/makesrna/intern/rna_internal.h7
-rw-r--r--source/blender/makesrna/intern/rna_layer.c19
-rw-r--r--source/blender/makesrna/intern/rna_scene.c15
3 files changed, 37 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index 4687e86916e..d4de20b5328 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -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,
diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c
index b02a5c8dc1e..278d611cc41 100644
--- a/source/blender/makesrna/intern/rna_layer.c
+++ b/source/blender/makesrna/intern/rna_layer.c
@@ -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];
+
+ rna_ViewLayer_path_buffer_get(view_layer, rna_path, sizeof(rna_path));
- BLI_str_escape(name_esc, srl->name, sizeof(name_esc));
- return BLI_sprintfN("view_layers[\"%s\"]", name_esc);
+ return BLI_strdup(rna_path);
}
static IDProperty **rna_ViewLayer_idprops(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 7f9890e492d..064dc255811 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -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);