diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-04-21 13:31:48 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-04-21 14:00:40 +0300 |
commit | c7f00feabaa334cd839a9e7904ee0fc1b8d8d718 (patch) | |
tree | ebe3addb97adae7bfd160ca6625fe0972bae8209 /source/blender/makesrna/intern/rna_depsgraph.c | |
parent | 4b77fb30759d1b62224033fc92c55eef7f3e414a (diff) |
Unify RNA and core depsgraph.objects
Note: Since this is not listbase nor array I'm also expanding
RNA_types.h to allow for custom data.
Diffstat (limited to 'source/blender/makesrna/intern/rna_depsgraph.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_depsgraph.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/source/blender/makesrna/intern/rna_depsgraph.c b/source/blender/makesrna/intern/rna_depsgraph.c index 093685b4ff5..571f07471a7 100644 --- a/source/blender/makesrna/intern/rna_depsgraph.c +++ b/source/blender/makesrna/intern/rna_depsgraph.c @@ -40,12 +40,15 @@ #ifdef RNA_RUNTIME +#include "BLI_iterator.h" #include "BKE_report.h" #include "DNA_object_types.h" #include "DEG_depsgraph_debug.h" #include "DEG_depsgraph_query.h" +#include "MEM_guardedalloc.h" + static void rna_Depsgraph_debug_graphviz(Depsgraph *graph, const char *filename) { FILE *f = fopen(filename, "w"); @@ -81,29 +84,29 @@ static void rna_Depsgraph_debug_stats(Depsgraph *graph, ReportList *reports) ops, rels, outer); } -static int rna_Depsgraph_objects_skip(CollectionPropertyIterator *iter, void *UNUSED(data)) +static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - ListBaseIterator *internal = &iter->internal.listbase; - Base *base = (Base *)internal->link; + Depsgraph *graph = (Depsgraph *)ptr->data; + iter->internal.custom = MEM_callocN(sizeof(Iterator), __func__); + DAG_objects_iterator_begin(iter->internal.custom, graph); + iter->valid = ((Iterator *)iter->internal.custom)->valid; +} - return ((base->flag & BASE_VISIBLED) == 0); +static void rna_Depsgraph_objects_next(CollectionPropertyIterator *iter) +{ + DAG_objects_iterator_next(iter->internal.custom); + iter->valid = ((Iterator *)iter->internal.custom)->valid; } -static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_Depsgraph_objects_end(CollectionPropertyIterator *iter) { - Depsgraph *depsgraph = (Depsgraph *)ptr->data; - SceneLayer *sl = DAG_get_scene_layer(depsgraph); - rna_iterator_listbase_begin(iter, &sl->object_bases, rna_Depsgraph_objects_skip); + DAG_objects_iterator_end(iter->internal.custom); + MEM_freeN(iter->internal.custom); } static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter) { - ListBaseIterator *internal = &iter->internal.listbase; - Base *base = (Base *)internal->link; - Object *ob = base->object; - - ob->base_flag = base->flag; - ob->base_collection_properties = base->collection_properties; + Object *ob = ((Iterator *)iter->internal.custom)->current; return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ob); } @@ -133,8 +136,8 @@ static void rna_def_depsgraph(BlenderRNA *brna) prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_collection_funcs(prop, "rna_Depsgraph_objects_begin", "rna_iterator_listbase_next", - "rna_iterator_listbase_end", "rna_Depsgraph_objects_get", + RNA_def_property_collection_funcs(prop, "rna_Depsgraph_objects_begin", "rna_Depsgraph_objects_next", + "rna_Depsgraph_objects_end", "rna_Depsgraph_objects_get", NULL, NULL, NULL, NULL); } |