Move DEG_OBJECT_ITER inside depsgraph
This commit is contained in:
parent
3540b50780
commit
4b77fb3075
Notes:
blender-bot
2023-02-14 09:03:55 +01:00
Referenced by commit 2f506b9458
, Fix objects visibility evaluation bug
|
@ -215,33 +215,6 @@ void BKE_visible_bases_Iterator_end(Iterator *iter);
|
|||
ITER_END \
|
||||
}
|
||||
|
||||
/* temporary hacky solution waiting for CoW depsgraph implementation */
|
||||
#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(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
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
struct ID;
|
||||
|
||||
struct Depsgraph;
|
||||
struct Iterator;
|
||||
struct SceneLayer;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -57,6 +58,22 @@ struct SceneLayer *DAG_get_scene_layer(struct Depsgraph *graph);
|
|||
/* Get the object as properly evaluated by depsgraph. */
|
||||
struct Object *DAG_get_object(struct Depsgraph *depsgraph, struct Object *ob);
|
||||
|
||||
/* ************************ DAG iterators ********************* */
|
||||
|
||||
void DAG_objects_iterator_begin(struct Iterator *iter, void *data_in);
|
||||
void DAG_objects_iterator_next(struct Iterator *iter);
|
||||
void DAG_objects_iterator_end(struct Iterator *iter);
|
||||
|
||||
/* Temporary hacky solution waiting for cow depsgrpah implementation. */
|
||||
#define DEG_OBJECT_ITER(graph_, instance_) \
|
||||
ITER_BEGIN(DAG_objects_iterator_begin, \
|
||||
DAG_objects_iterator_next, \
|
||||
DAG_objects_iterator_end, \
|
||||
graph_, Object *, instance_)
|
||||
|
||||
#define DEG_OBJECT_ITER_END \
|
||||
ITER_END
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -37,6 +37,7 @@ extern "C" {
|
|||
#include "BKE_layer.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "DEG_depsgraph_query.h"
|
||||
|
@ -99,3 +100,78 @@ Object *DAG_get_object(Depsgraph * /*depsgraph*/, Object *ob)
|
|||
/* XXX TODO */
|
||||
return ob;
|
||||
}
|
||||
|
||||
/* ************************ DAG ITERATORS ********************* */
|
||||
|
||||
typedef struct DAGObjectsIteratorData {
|
||||
Depsgraph *graph;
|
||||
Scene *scene;
|
||||
SceneLayer *scene_layer;
|
||||
Base *base;
|
||||
int flag;
|
||||
} DAGObjectsIteratorData;
|
||||
|
||||
void DAG_objects_iterator_begin(Iterator *iter, void *data_in)
|
||||
{
|
||||
SceneLayer *scene_layer;
|
||||
Depsgraph *graph = (Depsgraph *) data_in;
|
||||
DAGObjectsIteratorData *data = (DAGObjectsIteratorData *)
|
||||
MEM_callocN(sizeof(DAGObjectsIteratorData), __func__);
|
||||
iter->data = data;
|
||||
iter->valid = true;
|
||||
|
||||
data->graph = graph;
|
||||
data->scene = DAG_get_scene(graph);
|
||||
scene_layer = DAG_get_scene_layer(graph);
|
||||
data->flag = ~(BASE_FROM_SET);
|
||||
|
||||
Base base = {(Base *)scene_layer->object_bases.first, NULL};
|
||||
data->base = &base;
|
||||
DAG_objects_iterator_next(iter);
|
||||
}
|
||||
|
||||
void DAG_objects_iterator_next(Iterator *iter)
|
||||
{
|
||||
DAGObjectsIteratorData *data = (DAGObjectsIteratorData *)iter->data;
|
||||
Base *base = data->base->next;
|
||||
|
||||
while (base) {
|
||||
if ((base->flag & data->flag) != BASE_VISIBLED) {
|
||||
Object *ob = DAG_get_object(data->graph, base->object);
|
||||
iter->current = ob;
|
||||
|
||||
/* Flushing depsgraph data. */
|
||||
ob->base_flag = (base->flag | BASE_FROM_SET) & data->flag;
|
||||
ob->base_collection_properties = base->collection_properties;
|
||||
data->base = base;
|
||||
return;
|
||||
}
|
||||
base = base->next;
|
||||
}
|
||||
|
||||
/* Look for an object in the next set. */
|
||||
if (data->scene->set) {
|
||||
SceneLayer *scene_layer;
|
||||
data->scene = data->scene->set;
|
||||
data->flag = ~(BASE_SELECTED | BASE_SELECTABLED);
|
||||
|
||||
/* For the sets we use the layer used for rendering. */
|
||||
scene_layer = BKE_scene_layer_render_active(data->scene);
|
||||
|
||||
Base base = {(Base *)scene_layer->object_bases.first, NULL};
|
||||
data->base = &base;
|
||||
DAG_objects_iterator_next(iter);
|
||||
return;
|
||||
}
|
||||
|
||||
iter->current = NULL;
|
||||
iter->valid = false;
|
||||
}
|
||||
|
||||
void DAG_objects_iterator_end(Iterator *iter)
|
||||
{
|
||||
DAGObjectsIteratorData *data = (DAGObjectsIteratorData *)iter->data;
|
||||
if (data) {
|
||||
MEM_freeN(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_global.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
@ -1853,8 +1854,8 @@ void DRW_draw_view(const bContext *C)
|
|||
if (cache_is_dirty) {
|
||||
DRW_engines_cache_init();
|
||||
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph(C);
|
||||
DEG_OBJECT_ITER(depsgraph, ob);
|
||||
Depsgraph *graph = CTX_data_depsgraph(C);
|
||||
DEG_OBJECT_ITER(graph, ob);
|
||||
{
|
||||
DRW_engines_cache_populate(ob);
|
||||
}
|
||||
|
|
|
@ -2852,6 +2852,7 @@ static void rna_SceneLayer_update_tagged(SceneLayer *UNUSED(sl), bContext *C)
|
|||
{
|
||||
/* Don't do anything, we just need to run the iterator to flush
|
||||
* the base info to the objects. */
|
||||
UNUSED_VARS(ob);
|
||||
}
|
||||
DEG_OBJECT_ITER_END
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue