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
path: root/source
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2018-07-27 16:05:46 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-07-27 16:28:15 +0300
commit70966af5134b0cf53273e3c6da19ad7d5857b0f2 (patch)
treefba1f343ac327ede662580b3904042604e421d5d /source
parentd6ff77878039a5c3848482c6a82ff626d4b3872c (diff)
Workbench: option to change background
Replaced the draw world option with a shading.background_type enum. Where the user can select Theme, World or a Custom color. World and theme colors do not always work in workbench. We needed to have an option what the user could control locally (per viewport). Especially when using linked data. I removed the world background drawing from the draw_manager. It was never used as EEVEE and Workbench both override the logic. Not 100% sure about the naming of Theme, World, Viewport. In other parts of blender's codebase World is sometimes called Scene. Will stick to the names that describes its location best. {F3990139} Reviewers: fclem, campbellbarton Reviewed By: fclem Subscribers: venomgfx Tags: #bf_blender_2.8 Differential Revision: https://developer.blender.org/D3551
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/screen.c1
-rw-r--r--source/blender/blenloader/intern/versioning_280.c14
-rw-r--r--source/blender/draw/engines/workbench/workbench_data.c8
-rw-r--r--source/blender/draw/intern/draw_view.c11
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h17
-rw-r--r--source/blender/makesrna/intern/rna_space.c26
-rw-r--r--source/blender/makesrna/intern/rna_world.c3
9 files changed, 64 insertions, 20 deletions
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index f8d926a13ed..c107bb04e6e 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -869,6 +869,7 @@ void BKE_screen_view3d_shading_init(View3DShading *shading)
shading->cavity_valley_factor = 1.0f;
shading->cavity_ridge_factor = 1.0f;
copy_v3_fl(shading->single_color, 0.8f);
+ copy_v3_fl(shading->background_color, 0.05f);
}
/* magic zoom calculation, no idea what
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 068c12daa94..39ceb527209 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1546,6 +1546,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShadeing", "short", "background_type")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.background_type = (v3d->flag3 & V3D_SHOW_WORLD)? V3D_SHADING_BACKGROUND_WORLD: V3D_SHADING_BACKGROUND_THEME;
+ copy_v3_fl(v3d->shading.background_color, 0.05f);
+ }
+ }
+ }
+ }
+ }
+
if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", "gi_cubemap_draw_size")) {
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
scene->eevee.gi_irradiance_draw_size = 0.1f;
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index 5c3ab5f6688..24eb0f38a46 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -45,10 +45,16 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0;
wd->background_alpha = (v3d || scene->r.alphamode == R_ADDSKY) ? 1.0f : 0.0f;
- if (!v3d || ((v3d->flag3 & V3D_SHOW_WORLD) && (scene->world != NULL))) {
+ if (!v3d || ((v3d->shading.background_type & V3D_SHADING_BACKGROUND_WORLD) &&
+ (scene->world != NULL)))
+ {
copy_v3_v3(wd->background_color_low, &scene->world->horr);
copy_v3_v3(wd->background_color_high, &scene->world->horr);
}
+ else if (v3d->shading.background_type & V3D_SHADING_BACKGROUND_VIEWPORT) {
+ copy_v3_v3(wd->background_color_low, v3d->shading.background_color);
+ copy_v3_v3(wd->background_color_high, v3d->shading.background_color);
+ }
else if (v3d) {
UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD : TH_HIGH_GRAD, wd->background_color_low);
UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 05aecea1d7a..95835a691a3 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -561,21 +561,12 @@ void DRW_draw_grid(void)
void DRW_draw_background(void)
{
- const DRWContextState *draw_ctx = DRW_context_state_get();
-
/* Just to make sure */
glDepthMask(GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glStencilMask(0xFF);
- if ((draw_ctx->v3d->flag3 & V3D_SHOW_WORLD) &&
- (draw_ctx->scene->world != NULL))
- {
- const World *world = draw_ctx->scene->world;
- glClearColor(world->horr, world->horg, world->horb, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- }
- else if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
+ if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
float m[4][4];
unit_m4(m);
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 71bdd2e20c2..2577077002e 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1406,7 +1406,7 @@ static void space_view3d_listener(
switch (wmn->data) {
case ND_WORLD_DRAW:
case ND_WORLD:
- if (v3d->flag3 & V3D_SHOW_WORLD)
+ if (v3d->shading.background_type & V3D_SHADING_BACKGROUND_WORLD)
ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW);
break;
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 552d84ebb39..941f9262694 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -1599,7 +1599,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(
v3d.flag2 |= V3D_SOLID_TEX;
}
- v3d.flag3 |= V3D_SHOW_WORLD;
+ v3d.shading.background_type = V3D_SHADING_BACKGROUND_WORLD;
if (draw_flags & V3D_OFSDRAW_USE_CAMERA_DOF) {
if (camera->type == OB_CAMERA) {
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index fedc604f120..bbbaf8bb957 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -142,7 +142,9 @@ typedef struct View3DShading {
short color_type;
short light;
- short pad[3];
+ short background_type;
+ short pad2[2];
+
char studio_light[256]; /* FILE_MAXFILE */
char matcap[256]; /* FILE_MAXFILE */
@@ -157,6 +159,10 @@ typedef struct View3DShading {
float cavity_valley_factor;
float cavity_ridge_factor;
+
+ float background_color[3];
+ int pad;
+
} View3DShading;
/* 3D Viewport Overlay setings */
@@ -349,7 +355,7 @@ typedef struct View3D {
/* View3d->flag3 (short) */
-#define V3D_SHOW_WORLD (1 << 0)
+#define V3D_SHOW_WORLD (1 << 0) /* LEGACY replaced by V3D_SHADING_BACKGROUND_WORLD */
/* View3DShading->light */
enum {
@@ -378,6 +384,13 @@ enum {
V3D_SHADING_TEXTURE_COLOR = 3,
};
+/* View3DShading->background_type */
+enum {
+ V3D_SHADING_BACKGROUND_THEME = 0,
+ V3D_SHADING_BACKGROUND_WORLD = 1,
+ V3D_SHADING_BACKGROUND_VIEWPORT = 2,
+};
+
/* View3DOverlay->flag */
enum {
V3D_OVERLAY_FACE_ORIENTATION = (1 << 0),
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index e670d3c31a5..2f009238851 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2427,6 +2427,15 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static const EnumPropertyItem background_type_items[] = {
+ {V3D_SHADING_BACKGROUND_THEME, "THEME", 0, "Theme", "Use the theme for background color"},
+ {V3D_SHADING_BACKGROUND_WORLD, "WORLD", 0, "World", "Use the world for background color"},
+ {V3D_SHADING_BACKGROUND_VIEWPORT, "VIEWPORT", 0, "Viewport", "Use a custom color limited to this viewport only"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static const float default_background_color[] = {0.05f, 0.05f, 0.05f};
+
+
/* Note these settings are used for both 3D viewport and the OpenGL render
* engine in the scene, so can't assume to always be part of a screen. */
srna = RNA_def_struct(brna, "View3DShading", NULL);
@@ -2514,6 +2523,18 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "background_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_items(prop, background_type_items);
+ RNA_def_property_ui_text(prop, "Background", "Way to draw the background");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
+ prop = RNA_def_property(srna, "background_color", PROP_FLOAT, PROP_COLOR);
+ RNA_def_property_array(prop, 3);
+ RNA_def_property_float_array_default(prop, default_background_color);
+ RNA_def_property_ui_text(prop, "Background Color", "Color for custom background color");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "show_shadows", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SHADOW);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -2957,11 +2978,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Lock Camera to View", "Enable view navigation within the camera view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_world", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag3", V3D_SHOW_WORLD);
- RNA_def_property_ui_text(prop, "World Background", "Display world colors in the background");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
prop = RNA_def_property(srna, "use_occlude_geometry", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_ZBUF_SELECT);
RNA_def_property_ui_text(prop, "Occlude Geometry", "Limit selection to visible (clipped with depth buffer)");
diff --git a/source/blender/makesrna/intern/rna_world.c b/source/blender/makesrna/intern/rna_world.c
index f4dc07cf6c3..fe561cdef1c 100644
--- a/source/blender/makesrna/intern/rna_world.c
+++ b/source/blender/makesrna/intern/rna_world.c
@@ -199,6 +199,8 @@ void RNA_def_world(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
+ static float default_world_color[] = {0.05f, 0.05f, 0.05f};
+
srna = RNA_def_struct(brna, "World", "ID");
RNA_def_struct_ui_text(srna, "World",
"World data-block describing the environment and ambient lighting of a scene");
@@ -210,6 +212,7 @@ void RNA_def_world(BlenderRNA *brna)
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "horr");
RNA_def_property_array(prop, 3);
+ RNA_def_property_float_array_default(prop, default_world_color);
RNA_def_property_ui_text(prop, "Color", "Color of the background");
/* RNA_def_property_update(prop, 0, "rna_World_update"); */
/* render-only uses this */