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
This commit is contained in:
Jeroen Bakker 2018-05-09 13:30:27 +02:00
parent 56d65719b3
commit c0667c2f35
11 changed files with 74 additions and 138 deletions

@ -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.

@ -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,

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

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

@ -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}
};

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

@ -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,

@ -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;
} Scene;
/* **************** RENDERDATA ********************* */

@ -216,6 +216,7 @@ extern StructRNA RNA_DecimateModifier;
extern StructRNA RNA_DelaySensor;
extern StructRNA RNA_CorrectiveSmoothModifier;
extern StructRNA RNA_DisplaceModifier;
extern StructRNA RNA_SceneDisplay;
extern StructRNA RNA_DisplaySafeAreas;
extern StructRNA RNA_DistortedNoiseTexture;
extern StructRNA RNA_DomainFluidSettings;

@ -302,18 +302,6 @@ static void rna_LayerEngineSettings_##_ENGINE_##_##_NAME_##_set(PointerRNA *ptr,
#define RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(bool, Eevee, _NAME_)
#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(_NAME_, _LEN_) \
RNA_LAYER_ENGINE_GET_SET_ARRAY(float, Workbench, _NAME_, _LEN_)
#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(float, Workbench, _NAME_)
#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_INT(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(int, Workbench, _NAME_)
#define RNA_LAYER_ENGINE_WORKBENCH_GET_SET_BOOL(_NAME_) \
RNA_LAYER_ENGINE_GET_SET(bool, Workbench, _NAME_)
/* clay engine */
#ifdef WITH_CLAY_ENGINE
/* ViewLayer settings. */
@ -332,13 +320,6 @@ RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(ssao_attenuation)
RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(hair_brightness_randomness)
#endif /* WITH_CLAY_ENGINE */
/* workbench engine */
/* Collection settings */
RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT(random_object_color_saturation)
RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT(random_object_color_value)
/* View Layer settings */
RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(light_direction, 3)
/* eevee engine */
/* ViewLayer settings. */
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(gtao_enable)
@ -470,9 +451,6 @@ static StructRNA *rna_ViewLayerSettings_refine(PointerRNA *ptr)
if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) {
return &RNA_ViewLayerEngineSettingsEevee;
}
else if (STREQ(props->name, RE_engine_id_BLENDER_WORKBENCH)) {
return &RNA_ViewLayerEngineSettingsWorkbench;
}
break;
default:
BLI_assert(!"Mode not fully implemented");
@ -530,9 +508,6 @@ static StructRNA *rna_LayerCollectionSettings_refine(PointerRNA *ptr)
return &RNA_LayerCollectionEngineSettingsClay;
}
#endif
if (STREQ(props->name, RE_engine_id_BLENDER_WORKBENCH)) {
return &RNA_LayerCollectionEngineSettingsWorkbench;
}
if (STREQ(props->name, RE_engine_id_BLENDER_EEVEE)) {
/* printf("Mode not fully implemented\n"); */
return &RNA_LayerCollectionSettings;
@ -1603,54 +1578,6 @@ static void rna_def_layer_collection_engine_settings_clay(BlenderRNA *brna)
}
#endif /* WITH_CLAY_ENGINE */
/* Workbench engine */
static void rna_def_view_layer_engine_settings_workbench(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "ViewLayerEngineSettingsWorkbench", "ViewLayerSettings");
RNA_def_struct_ui_text(srna, "Workbench Scene Layer Settings", "Workbench Engine settings");
RNA_define_verify_sdna(0); /* not in sdna */
prop = RNA_def_property(srna, "light_direction", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_light_direction_get", "rna_LayerEngineSettings_Workbench_light_direction_set", NULL);
RNA_def_property_ui_text(prop, "Light Direction", "Direction of the light for shadow calculation");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_ViewLayerEngineSettings_update");
RNA_define_verify_sdna(1); /* not in sdna */
}
static void rna_def_layer_collection_engine_settings_workbench(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna = RNA_def_struct(brna, "LayerCollectionEngineSettingsWorkbench", "LayerCollectionSettings");
RNA_def_struct_ui_text(srna, "Collections Workbench Engine Settings", "Workbench specific settings for this collection");
RNA_define_verify_sdna(0); /* not in sdna */
prop = RNA_def_property(srna, "random_object_color_saturation", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_random_object_color_saturation_get", "rna_LayerEngineSettings_Workbench_random_object_color_saturation_set", NULL);
RNA_def_property_ui_text(prop, "Random Saturation", "Random Object Color Saturation");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
prop = RNA_def_property(srna, "random_object_color_value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_random_object_color_value_get", "rna_LayerEngineSettings_Workbench_random_object_color_value_set", NULL);
RNA_def_property_ui_text(prop, "Random Value", "Random Object Color Value");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
RNA_define_verify_sdna(1); /* not in sdna */
}
static void rna_def_view_layer_settings(BlenderRNA *brna)
{
StructRNA *srna;
@ -1687,7 +1614,6 @@ static void rna_def_view_layer_settings(BlenderRNA *brna)
#ifdef WITH_CLAY_ENGINE
rna_def_view_layer_engine_settings_clay(brna);
#endif
rna_def_view_layer_engine_settings_workbench(brna);
rna_def_view_layer_engine_settings_eevee(brna);
RNA_define_verify_sdna(1);
@ -1730,8 +1656,6 @@ static void rna_def_layer_collection_settings(BlenderRNA *brna)
rna_def_layer_collection_engine_settings_clay(brna);
#endif
rna_def_layer_collection_engine_settings_workbench(brna);
RNA_define_verify_sdna(1);
}

@ -5643,6 +5643,25 @@ static void rna_def_display_safe_areas(BlenderRNA *brna)
RNA_def_property_update(prop, NC_SCENE | ND_DRAW_RENDER_VIEWPORT, NULL);
}
static void rna_def_scene_display(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
static float default_light_direction[3] = {-0.577350269, -0.577350269, 0.577350269};
srna = RNA_def_struct(brna, "SceneDisplay", NULL);
RNA_def_struct_ui_text(srna, "Scene Display", "Scene display settings for 3d viewport");
RNA_def_struct_sdna(srna, "SceneDisplay");
prop = RNA_def_property(srna, "light_direction", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_float_sdna(prop, NULL, "light_direction");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_array(prop, 3);
RNA_def_property_float_array_default(prop, default_light_direction);
RNA_def_property_ui_text(prop, "Light Direction", "Direction of the light for shadows and highlights");
RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_set_update");
}
void RNA_def_scene(BlenderRNA *brna)
{
@ -6102,6 +6121,12 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "SceneCollection");
RNA_def_property_ui_text(prop, "Master Collection", "Collection that contains all other collections");
/* Scene Display */
prop = RNA_def_property(srna, "display", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "display");
RNA_def_property_struct_type(prop, "SceneDisplay");
RNA_def_property_ui_text(prop, "Scene Display", "Scene display settings for 3d viewport");
/* Nestled Data */
/* *** Non-Animated *** */
RNA_define_animate_sdna(false);
@ -6116,6 +6141,7 @@ void RNA_def_scene(BlenderRNA *brna)
rna_def_transform_orientation(brna);
rna_def_selected_uv_element(brna);
rna_def_display_safe_areas(brna);
rna_def_scene_display(brna);
RNA_define_animate_sdna(true);
/* *** Animated *** */
rna_def_scene_render_data(brna);