[Bf-blender-cvs] [c7f00feabaa] blender2.8: Unify RNA and core depsgraph.objects

Dalai Felinto noreply at git.blender.org
Fri Apr 21 13:01:27 CEST 2017


Commit: c7f00feabaa334cd839a9e7904ee0fc1b8d8d718
Author: Dalai Felinto
Date:   Fri Apr 21 12:31:48 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBc7f00feabaa334cd839a9e7904ee0fc1b8d8d718

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.

===================================================================

M	source/blender/makesrna/RNA_types.h
M	source/blender/makesrna/intern/rna_depsgraph.c

===================================================================

diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index cd04f9e8a6d..99ef0f9c8c4 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -282,6 +282,7 @@ typedef struct CollectionPropertyIterator {
 	union {
 		ArrayIterator array;
 		ListBaseIterator listbase;
+		void *custom;
 	} internal;
 	int idprop;
 	int level;
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);
 }




More information about the Bf-blender-cvs mailing list