diff options
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 26 | ||||
-rw-r--r-- | source/blender/depsgraph/DEG_depsgraph_query.h | 3 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_query.cc | 13 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 32 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_layer_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 9 |
6 files changed, 45 insertions, 39 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index e1aaf39e2a3..b91ff82dc9f 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -216,20 +216,30 @@ void BKE_visible_bases_Iterator_end(Iterator *iter); } /* temporary hacky solution waiting for CoW depsgraph implementation */ -#define DEG_OBJECT_ITER(sl_, instance_) \ +#define DEG_OBJECT_ITER(graph_, instance_) \ { \ + Scene *sce_, *scene_ = DAG_get_scene(graph_); \ + SceneLayer *sl_ = DAG_get_scene_layer(graph_); \ + int flag_ = ~(BASE_FROM_SET); \ + \ /* flush all the depsgraph data to objects */ \ Object *instance_; \ Base *base_; \ - for (base_ = (sl_)->object_bases.first; base_; base_ = base_->next) { \ - if ((base_->flag & BASE_VISIBLED) != 0) { \ - instance_ = base_->object; \ - instance_->base_flag = base_->flag; \ - instance_->base_collection_properties = base_->collection_properties; + for(sce_ = scene_; sce_; sce_ = sce_->set) { \ + for (base_ = (sl_)->object_bases.first; base_; base_ = base_->next) { \ + if ((base_->flag & BASE_VISIBLED) != 0) { \ + instance_ = base_->object; \ + instance_->base_flag = (base_->flag | BASE_FROM_SET) & flag_; \ + instance_->base_collection_properties = base_->collection_properties; #define DEG_OBJECT_ITER_END \ - } \ - } \ + } \ + } \ + if (sce_->set) { \ + sl_ = BKE_scene_layer_render_active(sce_->set); \ + flag_ = ~(BASE_SELECTED | BASE_SELECTABLED); \ + } \ + } \ } #ifdef __cplusplus diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h index 01cbaf503b5..4bf2b63cf41 100644 --- a/source/blender/depsgraph/DEG_depsgraph_query.h +++ b/source/blender/depsgraph/DEG_depsgraph_query.h @@ -48,6 +48,9 @@ bool DEG_id_type_tagged(struct Main *bmain, short idtype); /* Get additional evaluation flags for the given ID. */ short DEG_get_eval_flags_for_id(struct Depsgraph *graph, struct ID *id); +/* Get scene the despgraph is created for. */ +struct Scene *DAG_get_scene(struct Depsgraph *graph); + /* Get scene layer the despgraph is created for. */ struct SceneLayer *DAG_get_scene_layer(struct Depsgraph *graph); diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index 7d09cdf4ac2..d15217c40da 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -73,14 +73,23 @@ short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id) return id_node->eval_flags; } -SceneLayer *DAG_get_scene_layer(Depsgraph *graph) +Scene *DAG_get_scene(Depsgraph *graph) { Main *bmain = G.main; LINKLIST_FOREACH (Scene*, scene, &bmain->scene) { if (scene->depsgraph == graph) { /* Got the scene! */ - return BKE_scene_layer_context_active(scene); + return scene; } } return NULL; } + +SceneLayer *DAG_get_scene_layer(Depsgraph *graph) +{ + Scene *scene = DAG_get_scene(graph); + if (scene) { + return BKE_scene_layer_context_active(scene); + } + return NULL; +} diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 0cfdf8926a0..3ef317f9c8a 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -67,6 +67,9 @@ #include "clay.h" #include "eevee.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + #define MAX_ATTRIB_NAME 32 #define MAX_PASS_NAME 32 @@ -1820,23 +1823,6 @@ static void DRW_debug_gpu_stats(void) draw_stat(&rect, 0, v, pass_name, sizeof(pass_name)); } -static void drw_draw_view_set_recursive(Scene *scene) -{ - if (scene->set) { - drw_draw_view_set_recursive(scene->set); - } - - SceneLayer *sl = BKE_scene_layer_render_active(scene); - DEG_OBJECT_ITER(sl, ob); - { - /* XXX FIXME!!! - dont de-select users data! - * (set drawing should use a fixed color - ignoring select and other theme colors) */ - ob->base_flag &= ~BASE_SELECTED; - DRW_engines_cache_populate(ob); - } - DEG_OBJECT_ITER_END -} - /* Everything starts here. * This function takes care of calling all cache and rendering functions * for each relevant engine / mode engine. */ @@ -1865,18 +1851,10 @@ void DRW_draw_view(const bContext *C) /* ideally only refresh when objects are added/removed */ /* or render properties / materials change */ if (cache_is_dirty) { - SceneLayer *sl; - Scene *scene = CTX_data_scene(C); - DRW_engines_cache_init(); - /* draw set first */ - if (scene->set) { - drw_draw_view_set_recursive(scene->set); - } - - sl = CTX_data_scene_layer(C); - DEG_OBJECT_ITER(sl, ob); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + DEG_OBJECT_ITER(depsgraph, ob); { DRW_engines_cache_populate(ob); } diff --git a/source/blender/makesdna/DNA_layer_types.h b/source/blender/makesdna/DNA_layer_types.h index 6fe3a9f1c8a..6233cdb8c24 100644 --- a/source/blender/makesdna/DNA_layer_types.h +++ b/source/blender/makesdna/DNA_layer_types.h @@ -96,6 +96,7 @@ enum { BASE_SELECTABLED = (1 << 2), BASE_FROMDUPLI = (1 << 3), BASE_DIRTY_ENGINE_SETTINGS = (1 << 4), + BASE_FROM_SET = (1 << 5), /* To be set only by the depsgraph */ }; /* LayerCollection->flag */ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 9b394957779..72bf65f1671 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -485,6 +485,9 @@ EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = { #include "ED_keyframing.h" #include "ED_image.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" + #ifdef WITH_FREESTYLE #include "FRS_freestyle.h" #endif @@ -2842,9 +2845,10 @@ static int rna_SceneLayer_multiple_engines_get(PointerRNA *UNUSED(ptr)) return (BLI_listbase_count(&R_engines) > 1); } -static void rna_SceneLayer_update_tagged(SceneLayer *sl) +static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C) { - DEG_OBJECT_ITER(sl, ob) + Depsgraph *graph = CTX_data_depsgraph(C); + DEG_OBJECT_ITER(graph, ob) { /* Don't do anything, we just need to run the iterator to flush * the base info to the objects. */ @@ -6382,6 +6386,7 @@ static void rna_def_scene_layer(BlenderRNA *brna) /* debug update routine */ func = RNA_def_function(srna, "update", "rna_SceneLayer_update_tagged"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Update data tagged to be updated from previous access to data or operators"); } |