Include the set in the depsgraph objects iterator

Pending: Include the set in the rna depsgraph.objects

In fact it would be nice to unify them both. However this will likely
change once Depsgraph incorporate this iterator, so I'm not sure we
should bother with that.

Related to T51203
This commit is contained in:
Dalai Felinto
2017-04-20 18:59:47 +02:00
parent 3a75e84376
commit 01a627dac9
6 changed files with 45 additions and 39 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 */

View File

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