[Bf-blender-cvs] [180a68c1dcc] blender-v3.1-release: Fix (studio-reported) missing RNA path for EEVEE render passes.

Bastien Montagne noreply at git.blender.org
Mon Jan 31 15:28:49 CET 2022


Commit: 180a68c1dcc7f18d746b43803e34119f31fc323d
Author: Bastien Montagne
Date:   Mon Jan 31 15:16:36 2022 +0100
Branches: blender-v3.1-release
https://developer.blender.org/rB180a68c1dcc7f18d746b43803e34119f31fc323d

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.

===================================================================

M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_layer.c
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

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



More information about the Bf-blender-cvs mailing list