[Bf-blender-cvs] [c0667c2f35a] blender2.8: T55008: Migrating RE-Collection data to Scene data

Jeroen Bakker noreply at git.blender.org
Wed May 9 13:40:03 CEST 2018


Commit: c0667c2f35a1be4c56fac21d48b3a19bd460cb8d
Author: Jeroen Bakker
Date:   Wed May 9 13:30:27 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc0667c2f35a1be4c56fac21d48b3a19bd460cb8d

T55008: Migrating RE-Collection data to Scene data

in Scene DNA is available in scene.display New DNA Struct DisplayData
Added RNA (scene.display).

We already have scene.display_settings which contains non viewpoert
specific color management settings. I did not merge those two.

Patch should be in line with the ideas that @brecht wrote in T55008.

As I am not in detail aware of the decisions that have been made for the override feature I want a short review if it is in line with the plans.

Reviewers: brecht, dfelinto

Reviewed By: brecht

Subscribers: brecht

Tags: #code_quest, #bf_blender_2.8

Differential Revision: https://developer.blender.org/D3290

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

M	release/scripts/startup/bl_ui/properties_render.py
M	release/scripts/startup/bl_ui/properties_scene.py
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/workbench/workbench_engine.c
M	source/blender/draw/engines/workbench/workbench_materials.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_layer.c
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 610166f5845..e6d5d9bf837 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -743,22 +743,6 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
         col.prop(rd, "alpha_mode", text="Alpha")
 
 
-class RENDER_PT_workbench_environment_light(RenderButtonsPanel, Panel):
-    bl_label = "Workbench Environment Light"
-    bl_options = {'DEFAULT_CLOSED'}
-    COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
-
-    @classmethod
-    def poll(cls, context):
-        return (context.engine in cls.COMPAT_ENGINES)
-
-    def draw(self, context):
-        layout = self.layout
-        scene = context.scene
-        props = scene.layer_properties['BLENDER_WORKBENCH']
-        layout.prop(props, "light_direction", text="")
-
-
 classes = (
     RENDER_MT_presets,
     RENDER_MT_ffmpeg_presets,
@@ -785,7 +769,6 @@ classes = (
     RENDER_PT_eevee_motion_blur,
     RENDER_PT_eevee_depth_of_field,
     RENDER_PT_eevee_bloom,
-	RENDER_PT_workbench_environment_light,
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 094f2a9dc31..cf17adfe5c1 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -429,6 +429,20 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel):
         col.prop(rd, "simplify_child_particles_render", text="Child Particles")
 
 
+class SCENE_PT_viewport_display(SceneButtonsPanel, Panel):
+    bl_label = "Viewport Display"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        return True
+
+    def draw(self, context):
+        layout = self.layout
+        scene = context.scene
+        layout.prop(scene.display, "light_direction", text="")
+
+
 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
     _context_path = "scene"
@@ -443,6 +457,7 @@ classes = (
     SCENE_PT_keying_sets,
     SCENE_PT_keying_set_paths,
     SCENE_PT_color_management,
+    SCENE_PT_viewport_display,
     SCENE_PT_audio,
     SCENE_PT_physics,
     SCENE_PT_rigid_body_world,
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 1c8d153d0d1..90906d2fef1 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -819,6 +819,10 @@ void BKE_scene_init(Scene *sce)
 	BKE_view_layer_engine_settings_create(sce->layer_properties);
 
 	BKE_view_layer_add(sce, "View Layer");
+
+	/* SceneDisplay */
+	static float default_light_direction[] = {-0.577350269, -0.577350269, 0.577350269};
+	copy_v3_v3(sce->display.light_direction, default_light_direction);
 }
 
 Scene *BKE_scene_add(Main *bmain, const char *name)
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 0cfab7976d6..103cf819db1 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1077,4 +1077,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 	}
+
+	{
+		if (!DNA_struct_elem_find(fd->filesdna, "Scene", "SceneDisplay", "display")) {
+			/* Initialize new scene.SceneDisplay */
+			for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
+				static float default_light_direction[] = {-0.577350269, -0.577350269, 0.577350269};
+				copy_v3_v3(scene->display.light_direction, default_light_direction);
+			}
+		}
+	}
 }
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index 40d5c2b12f9..248534d7e51 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -28,47 +28,17 @@
 
 #include "DRW_render.h"
 
-#include "BKE_icons.h"
-#include "BKE_idprop.h"
-#include "BKE_main.h"
-
-#include "GPU_shader.h"
-
 #include "workbench_engine.h"
-#include "workbench_private.h"
 /* Shaders */
 
 #define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
 
 
-/* Functions */
-
-static void workbench_layer_collection_settings_create(RenderEngine *UNUSED(engine), IDProperty *props)
-{
-	BLI_assert(props &&
-	           props->type == IDP_GROUP &&
-	           props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
-
-	BKE_collection_engine_property_add_float(props, "random_object_color_saturation", 0.5f);
-	BKE_collection_engine_property_add_float(props, "random_object_color_value", 0.9f);
-}
-
-static void workbench_view_layer_settings_create(RenderEngine *UNUSED(engine), IDProperty *props)
-{
-	BLI_assert(props &&
-	           props->type == IDP_GROUP &&
-	           props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
-
-	const float light_direction[3] = {-0.577350269, -0.577350269, 0.577350269};
-	BKE_collection_engine_property_add_float_array(props, "light_direction", light_direction, 3);	UNUSED_VARS_NDEBUG(props);
-}
-
 /* Note: currently unused, we may want to register so we can see this when debugging the view. */
-
 RenderEngineType DRW_engine_viewport_workbench_type = {
 	NULL, NULL,
 	WORKBENCH_ENGINE, N_("Workbench"), RE_INTERNAL,
-	NULL, NULL, NULL, NULL, NULL, NULL, NULL, &workbench_layer_collection_settings_create, &workbench_view_layer_settings_create,
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 	&draw_engine_workbench_solid,
 	{NULL, NULL, NULL}
 };
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 526eab44982..a84bfb9066f 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -329,15 +329,12 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
 	WORKBENCH_PrivateData *wpd = stl->g_data;
 	DRWShadingGroup *grp;
 	const DRWContextState *draw_ctx = DRW_context_state_get();
-	ViewLayer *view_layer = draw_ctx->view_layer;
-	IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, RE_engine_id_BLENDER_WORKBENCH);
 	static float shadow_multiplier = 0.0f;
 
-	const DRWContextState *DCS = DRW_context_state_get();
-
 	wpd->material_hash = BLI_ghash_ptr_new(__func__);
 
-	View3D *v3d = DCS->v3d;
+	View3D *v3d = draw_ctx->v3d;
+	Scene *scene = draw_ctx->scene;
 	if (v3d) {
 		wpd->shading = v3d->shading;
 		wpd->drawtype = v3d->drawtype;
@@ -368,7 +365,7 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
 		wpd->world_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_World), NULL);
 		DRW_uniformbuffer_update(wpd->world_ubo, &wpd->world_data);
 
-		copy_v3_v3(e_data.light_direction, BKE_collection_engine_property_value_get_float_array(props, "light_direction"));
+		copy_v3_v3(e_data.light_direction, scene->display.light_direction);
 		negate_v3(e_data.light_direction);
 
 		if (SHADOW_ENABLED(wpd)) {
@@ -419,10 +416,9 @@ static WORKBENCH_MaterialData *get_or_create_material_data(WORKBENCH_Data *vedat
 	        ob, &draw_engine_workbench_solid, sizeof(WORKBENCH_ObjectData), &workbench_init_object_data, NULL);
 	WORKBENCH_MaterialData material_template;
 	const DRWContextState *draw_ctx = DRW_context_state_get();
-	ViewLayer *view_layer = draw_ctx->view_layer;
-	IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, RE_engine_id_BLENDER_WORKBENCH);
-	const float hsv_saturation = BKE_collection_engine_property_value_get_float(props, "random_object_color_saturation");
-	const float hsv_value = BKE_collection_engine_property_value_get_float(props, "random_object_color_value");
+	const Scene *scene = draw_ctx->scene;
+	const float hsv_saturation = 0.5;
+	const float hsv_value = 0.9;
 
 	/* Solid */
 	get_material_solid_color(wpd, ob, mat, material_template.color, hsv_saturation, hsv_value);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index cd51474accf..d9ba59de887 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1082,10 +1082,6 @@ static void view3d_main_region_message_subscribe(
 		extern StructRNA RNA_ViewLayerEngineSettingsEevee;
 		WM_msg_subscribe_rna_anon_type(mbus, ViewLayerEngineSettingsEevee, &msg_sub_value_region_tag_redraw);
 	}
-	else if (STREQ(scene->r.engine, RE_engine_id_BLENDER_WORKBENCH)) {
-		extern StructRNA RNA_ViewLayerEngineSettingsWorkbench;
-		WM_msg_subscribe_rna_anon_type(mbus, ViewLayerEngineSettingsWorkbench, &msg_sub_value_region_tag_redraw);
-	}
 #ifdef WITH_CLAY_ENGINE
 	else if (STREQ(scene->r.engine, RE_engine_id_BLENDER_CLAY)) {
 		extern StructRNA RNA_ViewLayerEngineSettingsClay;
@@ -1093,6 +1089,8 @@ static void view3d_main_region_message_subscribe(
 	}
 #endif
 
+	WM_msg_subscribe_rna_anon_type(mbus, SceneDisplay, &msg_sub_value_region_tag_redraw);
+
 	if (workspace->tool.spacetype == SPACE_VIEW3D) {
 		wmMsgSubscribeValue msg_sub_value_region_tag_refresh = {
 			.owner = ar,
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index a164ffd802a..f3301718bbb 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1353,6 +1353,13 @@ typedef struct DisplaySafeAreas {
 	float action_center[2];
 } DisplaySafeAreas;
 
+/* ------------------------------------------- */
+/* Scene Display - used for store scene specific display settings for the 3d view */
+typedef struct SceneDisplay {
+	float light_direction[3];      /* light direction for shadows/highlight */
+	int pad;
+} SceneDisplay;
+
 /* *************************************************************** */
 /* Scene ID-Block */
 
@@ -1444,6 +1451,8 @@ typedef struct Scene {
 
 	IDProperty *collection_properties;  /* settings to be overriden by layer collections */
 	IDProperty *layer_properties;  /* settings to be override by workspaces */
+
+	struct SceneDisplay display;
 }

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list