diff options
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_lightprobes.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 18 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_lightprobe_types.h | 1 |
3 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 1cb9a957211..b58e389b558 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -846,10 +846,11 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved /* If we update grid we need to update the cubemaps too. * So always refresh cubemaps. */ scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_CUBE; + /* Tag the lightcache to auto update. */ + scene_orig->eevee.light_cache->flag |= LIGHTCACHE_UPDATE_AUTO; + /* Use a notifier to trigger the operator after drawing. */ + WM_event_add_notifier(draw_ctx->evil_C, NC_LIGHTPROBE, scene_orig); } - - /* Use a notifier to trigger the operator after drawing. */ - WM_event_add_notifier(draw_ctx->evil_C, NC_LIGHTPROBE, scene_orig); } } } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 5cff64218ec..43b6a1b0621 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -32,6 +32,7 @@ #include <string.h> #include <stdio.h> +#include "DNA_lightprobe_types.h" #include "DNA_material_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -685,6 +686,13 @@ static void view3d_lightcache_update(bContext *C) { PointerRNA op_ptr; + Scene *scene = CTX_data_scene(C); + + if (strcmp(scene->r.engine, RE_engine_id_BLENDER_EEVEE) != 0) { + /* Only do auto bake if eevee is the active engine */ + return; + } + WM_operator_properties_create(&op_ptr, "SCENE_OT_light_cache_bake"); RNA_int_set(&op_ptr, "delay", 200); RNA_enum_set_identifier(C, &op_ptr, "subset", "DIRTY"); @@ -1424,9 +1432,13 @@ static void space_view3d_listener( static void space_view3d_refresh(const bContext *C, ScrArea *UNUSED(sa)) { - /* This is only used by the auto lightprobe refresh for the moment. - * So we don't need to check anything to know what to do. */ - view3d_lightcache_update((bContext *)C); + Scene *scene = CTX_data_scene(C); + LightCache *lcache = scene->eevee.light_cache; + + if (lcache && (lcache->flag & LIGHTCACHE_UPDATE_AUTO) != 0) { + lcache->flag &= ~LIGHTCACHE_UPDATE_AUTO; + view3d_lightcache_update((bContext *)C); + } } const char *view3d_context_dir[] = { diff --git a/source/blender/makesdna/DNA_lightprobe_types.h b/source/blender/makesdna/DNA_lightprobe_types.h index c06d75a4021..81286e5e4d0 100644 --- a/source/blender/makesdna/DNA_lightprobe_types.h +++ b/source/blender/makesdna/DNA_lightprobe_types.h @@ -169,6 +169,7 @@ enum { LIGHTCACHE_UPDATE_CUBE = (1 << 4), LIGHTCACHE_UPDATE_GRID = (1 << 5), LIGHTCACHE_UPDATE_WORLD = (1 << 6), + LIGHTCACHE_UPDATE_AUTO = (1 << 7), }; /* EEVEE_LightCacheTexture->data_type */ |