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.
This commit is contained in:
@@ -282,6 +282,7 @@ typedef struct CollectionPropertyIterator {
|
||||
union {
|
||||
ArrayIterator array;
|
||||
ListBaseIterator listbase;
|
||||
void *custom;
|
||||
} internal;
|
||||
int idprop;
|
||||
int level;
|
||||
|
@@ -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))
|
||||
{
|
||||
ListBaseIterator *internal = &iter->internal.listbase;
|
||||
Base *base = (Base *)internal->link;
|
||||
|
||||
return ((base->flag & BASE_VISIBLED) == 0);
|
||||
}
|
||||
|
||||
static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
||||
{
|
||||
Depsgraph *depsgraph = (Depsgraph *)ptr->data;
|
||||
SceneLayer *sl = DAG_get_scene_layer(depsgraph);
|
||||
rna_iterator_listbase_begin(iter, &sl->object_bases, rna_Depsgraph_objects_skip);
|
||||
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;
|
||||
}
|
||||
|
||||
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_end(CollectionPropertyIterator *iter)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user