[Bf-blender-cvs] [220fbddc8b6] blender2.8: Merge branch 'master' into blender2.8
Sergey Sharybin
noreply at git.blender.org
Wed Oct 25 12:21:35 CEST 2017
Commit: 220fbddc8b64ac367f88fcf61b805de6626d717a
Author: Sergey Sharybin
Date: Wed Oct 25 12:17:45 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB220fbddc8b64ac367f88fcf61b805de6626d717a
Merge branch 'master' into blender2.8
===================================================================
===================================================================
diff --cc source/blender/makesrna/intern/rna_depsgraph.c
index bab718c7235,adb99acef1f..f5b4d9cde0f
--- a/source/blender/makesrna/intern/rna_depsgraph.c
+++ b/source/blender/makesrna/intern/rna_depsgraph.c
@@@ -36,88 -36,14 +36,89 @@@
#include "DEG_depsgraph.h"
-#include "BKE_depsgraph.h"
+#include "DNA_object_types.h"
+ #define STATS_MAX_SIZE 16384
+
#ifdef RNA_RUNTIME
+#include "BLI_iterator.h"
- #include "BKE_report.h"
+
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_debug.h"
+#include "DEG_depsgraph_query.h"
+
+#include "MEM_guardedalloc.h"
+
+/* **************** Depsgraph **************** */
+
+static PointerRNA rna_DepsgraphIter_object_get(PointerRNA *ptr)
+{
+ BLI_Iterator *iterator = ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_Object, iterator->current);
+}
+
+static PointerRNA rna_DepsgraphIter_instance_object_get(PointerRNA *ptr)
+{
+ BLI_Iterator *iterator = ptr->data;
+ DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data;
+ Object *instance_object = NULL;
+ if (deg_iter->dupli_object_current != NULL) {
+ instance_object = deg_iter->dupli_object_current->ob;
+ }
+ return rna_pointer_inherit_refine(ptr, &RNA_Object, instance_object);
+}
+
+static PointerRNA rna_DepsgraphIter_parent_get(PointerRNA *ptr)
+{
+ BLI_Iterator *iterator = ptr->data;
+ DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data;
+ Object *dupli_parent = NULL;
+ if (deg_iter->dupli_object_current != NULL) {
+ dupli_parent = deg_iter->dupli_parent;
+ }
+ return rna_pointer_inherit_refine(ptr, &RNA_Object, dupli_parent);
+}
+
+static void rna_DepsgraphIter_persistent_id_get(PointerRNA *ptr, int *persistent_id)
+{
+ BLI_Iterator *iterator = ptr->data;
+ DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data;
+ memcpy(persistent_id, deg_iter->dupli_object_current->persistent_id,
+ sizeof(deg_iter->dupli_object_current->persistent_id));
+}
+
+static void rna_DepsgraphIter_orco_get(PointerRNA *ptr, float *orco)
+{
+ BLI_Iterator *iterator = ptr->data;
+ DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data;
+ memcpy(orco, deg_iter->dupli_object_current->orco,
+ sizeof(deg_iter->dupli_object_current->orco));
+}
+
+static unsigned int rna_DepsgraphIter_random_id_get(PointerRNA *ptr)
+{
+ BLI_Iterator *iterator = ptr->data;
+ DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data;
+ return deg_iter->dupli_object_current->random_id;
+}
+
+static void rna_DepsgraphIter_uv_get(PointerRNA *ptr, float *uv)
+{
+ BLI_Iterator *iterator = ptr->data;
+ DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data;
+ memcpy(uv, deg_iter->dupli_object_current->uv,
+ sizeof(deg_iter->dupli_object_current->uv));
+}
+
+static int rna_DepsgraphIter_is_instance_get(PointerRNA *ptr)
+{
+ BLI_Iterator *iterator = ptr->data;
+ DEGObjectsIteratorData *deg_iter = (DEGObjectsIteratorData *)iterator->data;
+ return (deg_iter->dupli_object_current != NULL);
+}
+
+/* **************** Depsgraph **************** */
static void rna_Depsgraph_debug_graphviz(Depsgraph *graph, const char *filename)
{
@@@ -129,108 -55,18 +130,92 @@@
fclose(f);
}
- static void rna_Depsgraph_debug_rebuild(Depsgraph *UNUSED(graph), bContext *C)
+ static void rna_Depsgraph_debug_tag_update(Depsgraph *graph)
{
- Main *bmain = CTX_data_main(C);
- EvaluationContext eval_ctx;
- Scene *sce;
-
- CTX_data_eval_ctx(C, &eval_ctx);
-
- DEG_relations_tag_update(bmain);
- for (sce = bmain->scene.first; sce; sce = sce->id.next) {
- DEG_scene_relations_rebuild(bmain, sce);
- DEG_graph_on_visible_update(bmain, sce->depsgraph_legacy);
- }
+ DEG_graph_tag_relations_update(graph);
}
- static void rna_Depsgraph_debug_stats(Depsgraph *graph, ReportList *reports)
+ static void rna_Depsgraph_debug_stats(Depsgraph *graph, char *result)
{
size_t outer, ops, rels;
-
DEG_stats_simple(graph, &outer, &ops, &rels);
-
- // XXX: report doesn't seem to work
- printf("Approx %lu Operations, %lu Relations, %lu Outer Nodes\n",
- ops, rels, outer);
-
- BKE_reportf(reports, RPT_WARNING, "Approx. %lu Operations, %lu Relations, %lu Outer Nodes",
- ops, rels, outer);
+ BLI_snprintf(result, STATS_MAX_SIZE,
+ "Approx %lu Operations, %lu Relations, %lu Outer Nodes",
- ops, rels, outer);
++ ops, rels, outer);
+}
+
+/* Iteration over objects, simple version */
+
+static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
+ DEGObjectsIteratorData *data = MEM_callocN(sizeof(DEGObjectsIteratorData), __func__);
+
+ data->graph = (Depsgraph *)ptr->data;
+ data->flag = DEG_OBJECT_ITER_FLAG_SET;
+
+ DEG_objects_iterator_begin(iter->internal.custom, data);
+ iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
+}
+
+static void rna_Depsgraph_objects_next(CollectionPropertyIterator *iter)
+{
+ DEG_objects_iterator_next(iter->internal.custom);
+ iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
+}
+
+static void rna_Depsgraph_objects_end(CollectionPropertyIterator *iter)
+{
+ DEG_objects_iterator_end(iter->internal.custom);
+ MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data);
+ MEM_freeN(iter->internal.custom);
+}
+
+static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter)
+{
+ Object *ob = ((BLI_Iterator *)iter->internal.custom)->current;
+ return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ob);
+}
+
+/* Iteration over objects, extended version
+ *
+ * Contains extra information about duplicator and persistent ID.
+ */
+
+static void rna_Depsgraph_duplis_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
+ DEGObjectsIteratorData *data = MEM_callocN(sizeof(DEGObjectsIteratorData), __func__);
+
+ data->graph = (Depsgraph *)ptr->data;
+ data->flag = DEG_OBJECT_ITER_FLAG_ALL;
+
+ DEG_objects_iterator_begin(iter->internal.custom, data);
+ iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
+}
+
+static void rna_Depsgraph_duplis_next(CollectionPropertyIterator *iter)
+{
+ DEG_objects_iterator_next(iter->internal.custom);
+ iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
+}
+
+static void rna_Depsgraph_duplis_end(CollectionPropertyIterator *iter)
+{
+ DEG_objects_iterator_end(iter->internal.custom);
+ MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data);
+ MEM_freeN(iter->internal.custom);
+}
+
+static PointerRNA rna_Depsgraph_duplis_get(CollectionPropertyIterator *iter)
+{
+ BLI_Iterator *iterator = (BLI_Iterator *)iter->internal.custom;
+ return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphIter, iterator);
+}
+
+static ID *rna_Depsgraph_evaluated_id_get(Depsgraph *depsgraph, ID *id_orig)
+{
+ return DEG_get_evaluated_id(depsgraph, id_orig);
}
#else
@@@ -315,32 -89,10 +299,35 @@@ static void rna_def_depsgraph(BlenderRN
func = RNA_def_function(srna, "debug_stats", "rna_Depsgraph_debug_stats");
RNA_def_function_ui_description(func, "Report the number of elements in the Dependency Graph");
- RNA_def_function_flag(func, FUNC_USE_REPORTS);
+ /* weak!, no way to return dynamic string type */
+ parm = RNA_def_string(func, "result", NULL, STATS_MAX_SIZE, "result", "");
+ RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); /* needed for string return value */
+ RNA_def_function_output(func, parm);
+
+ 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_Depsgraph_objects_next",
+ "rna_Depsgraph_objects_end",
+ "rna_Depsgraph_objects_get",
+ NULL, NULL, NULL, NULL);
+
+ func = RNA_def_function(srna, "evaluated_id_get", "rna_Depsgraph_evaluated_id_get");
+ parm = RNA_def_pointer(func, "id", "ID", "", "Original ID to get evaluated complementary part for");
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "evaluated_id", "ID", "", "Evaluated ID for the given original one");
+ RNA_def_function_return(func, parm);
+
+ /* TODO(sergey): Find a better name. */
+ prop = RNA_def_property(srna, "duplis", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "DepsgraphIter");
+ RNA_def_property_collection_funcs(prop,
+ "rna_Depsgraph_duplis_begin",
+ "rna_Depsgraph_duplis_next",
+ "rna_Depsgraph_duplis_end",
+ "rna_Depsgraph_duplis_get",
+ NULL, NULL, NULL, NULL);
}
void RNA_def_depsgraph(BlenderRNA *brna)
More information about the Bf-blender-cvs
mailing list