diff options
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_data.c')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_data.c | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c index 1f5a1e17277..49cdab256f0 100644 --- a/source/blender/draw/engines/workbench/workbench_data.c +++ b/source/blender/draw/engines/workbench/workbench_data.c @@ -19,37 +19,53 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->user_preferences = &U; View3D *v3d = draw_ctx->v3d; - if (v3d) { + if (!v3d) { + wpd->shading = scene->display.shading; + wpd->use_color_view_settings = true; + } + else if (v3d->shading.type == OB_RENDER && + BKE_scene_uses_blender_opengl(scene)) + { + wpd->shading = scene->display.shading; + wpd->use_color_view_settings = true; + } + else { wpd->shading = v3d->shading; - if (wpd->shading.light == V3D_LIGHTING_MATCAP) { - wpd->studio_light = BKE_studiolight_find( - wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL); - } - else { - wpd->studio_light = BKE_studiolight_find( - wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD); - } + wpd->use_color_view_settings = false; + } + + if (wpd->shading.light == V3D_LIGHTING_MATCAP) { + wpd->studio_light = BKE_studiolight_find( + wpd->shading.matcap, STUDIOLIGHT_ORIENTATION_VIEWNORMAL); } else { - memset(&wpd->shading, 0, sizeof(wpd->shading)); - wpd->shading.light = V3D_LIGHTING_STUDIO; - wpd->shading.shadow_intensity = 0.5; - copy_v3_fl(wpd->shading.single_color, 0.8f); - wpd->studio_light = BKE_studiolight_find_first(STUDIOLIGHT_INTERNAL); + wpd->studio_light = BKE_studiolight_find( + wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD); } + + /* If matcaps are missing, use this as fallback. */ + if (UNLIKELY(wpd->studio_light == NULL)) { + wpd->studio_light = BKE_studiolight_find( + wpd->shading.studio_light, STUDIOLIGHT_ORIENTATION_CAMERA | STUDIOLIGHT_ORIENTATION_WORLD); + } + wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity; WORKBENCH_UBO_World *wd = &wpd->world_data; wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) != 0; - wd->background_alpha = 1.0f; + wd->background_alpha = (v3d || scene->r.alphamode == R_ADDSKY) ? 1.0f : 0.0f; - if ((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 { + 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); @@ -58,6 +74,10 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) srgb_to_linearrgb_v3_v3(wd->background_color_high, wd->background_color_high); srgb_to_linearrgb_v3_v3(wd->background_color_low, wd->background_color_low); } + else { + zero_v3(wd->background_color_low); + zero_v3(wd->background_color_high); + } studiolight_update_world(wpd->studio_light, wd); @@ -119,6 +139,9 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd) wpd->viewvecs[1][2] = vec_far[2] - wpd->viewvecs[0][2]; } } + + wpd->volumes_do = false; + BLI_listbase_clear(&wpd->smoke_domains); } void workbench_private_data_get_light_direction(WORKBENCH_PrivateData *wpd, float r_light_direction[3]) |