Blender  V2.93
rna_depsgraph.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stdlib.h>
22 
23 #include "BLI_path_util.h"
24 #include "BLI_utildefines.h"
25 
26 #include "RNA_define.h"
27 #include "RNA_enum_types.h"
28 
29 #include "rna_internal.h"
30 
31 #include "DNA_object_types.h"
32 
33 #include "DEG_depsgraph.h"
34 
35 #define STATS_MAX_SIZE 16384
36 
37 #ifdef RNA_RUNTIME
38 
39 # ifdef WITH_PYTHON
40 # include "BPY_extern.h"
41 # endif
42 
43 # include "BLI_iterator.h"
44 # include "BLI_math.h"
45 
46 # include "RNA_access.h"
47 
48 # include "BKE_duplilist.h"
49 # include "BKE_object.h"
50 # include "BKE_scene.h"
51 
52 # include "DEG_depsgraph_build.h"
53 # include "DEG_depsgraph_debug.h"
54 # include "DEG_depsgraph_query.h"
55 
56 # include "MEM_guardedalloc.h"
57 
58 /* **************** Object Instance **************** */
59 
60 static PointerRNA rna_DepsgraphObjectInstance_object_get(PointerRNA *ptr)
61 {
62  BLI_Iterator *iterator = ptr->data;
63  return rna_pointer_inherit_refine(ptr, &RNA_Object, iterator->current);
64 }
65 
66 static int rna_DepsgraphObjectInstance_is_instance_get(PointerRNA *ptr)
67 {
68  BLI_Iterator *iterator = ptr->data;
69  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
70  return (deg_iter->dupli_object_current != NULL);
71 }
72 
73 static PointerRNA rna_DepsgraphObjectInstance_instance_object_get(PointerRNA *ptr)
74 {
75  BLI_Iterator *iterator = ptr->data;
76  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
77  Object *instance_object = NULL;
78  if (deg_iter->dupli_object_current != NULL) {
79  instance_object = deg_iter->dupli_object_current->ob;
80  }
81  return rna_pointer_inherit_refine(ptr, &RNA_Object, instance_object);
82 }
83 
84 static bool rna_DepsgraphObjectInstance_show_self_get(PointerRNA *ptr)
85 {
86  BLI_Iterator *iterator = ptr->data;
87  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
88  int ob_visibility = BKE_object_visibility(iterator->current, deg_iter->eval_mode);
89  return (ob_visibility & OB_VISIBLE_SELF) != 0;
90 }
91 
92 static bool rna_DepsgraphObjectInstance_show_particles_get(PointerRNA *ptr)
93 {
94  BLI_Iterator *iterator = ptr->data;
95  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
96  int ob_visibility = BKE_object_visibility(iterator->current, deg_iter->eval_mode);
97  return (ob_visibility & OB_VISIBLE_PARTICLES) != 0;
98 }
99 
100 static PointerRNA rna_DepsgraphObjectInstance_parent_get(PointerRNA *ptr)
101 {
102  BLI_Iterator *iterator = ptr->data;
103  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
104  Object *dupli_parent = NULL;
105  if (deg_iter->dupli_object_current != NULL) {
106  dupli_parent = deg_iter->dupli_parent;
107  }
108  return rna_pointer_inherit_refine(ptr, &RNA_Object, dupli_parent);
109 }
110 
111 static PointerRNA rna_DepsgraphObjectInstance_particle_system_get(PointerRNA *ptr)
112 {
113  BLI_Iterator *iterator = ptr->data;
114  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
115  struct ParticleSystem *particle_system = NULL;
116  if (deg_iter->dupli_object_current != NULL) {
117  particle_system = deg_iter->dupli_object_current->particle_system;
118  }
119  return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, particle_system);
120 }
121 
122 static void rna_DepsgraphObjectInstance_persistent_id_get(PointerRNA *ptr, int *persistent_id)
123 {
124  BLI_Iterator *iterator = ptr->data;
125  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
126  if (deg_iter->dupli_object_current != NULL) {
127  memcpy(persistent_id,
129  sizeof(deg_iter->dupli_object_current->persistent_id));
130  }
131  else {
132  memset(persistent_id, 0, sizeof(deg_iter->dupli_object_current->persistent_id));
133  }
134 }
135 
136 static unsigned int rna_DepsgraphObjectInstance_random_id_get(PointerRNA *ptr)
137 {
138  BLI_Iterator *iterator = ptr->data;
139  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
140  if (deg_iter->dupli_object_current != NULL) {
141  return deg_iter->dupli_object_current->random_id;
142  }
143  else {
144  return 0;
145  }
146 }
147 
148 static void rna_DepsgraphObjectInstance_matrix_world_get(PointerRNA *ptr, float *mat)
149 {
150  BLI_Iterator *iterator = ptr->data;
151  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
152  if (deg_iter->dupli_object_current != NULL) {
153  copy_m4_m4((float(*)[4])mat, deg_iter->dupli_object_current->mat);
154  }
155  else {
156  /* We can return actual object's matrix here, no reason to return identity matrix
157  * when this is not actually an instance... */
158  Object *ob = (Object *)iterator->current;
159  copy_m4_m4((float(*)[4])mat, ob->obmat);
160  }
161 }
162 
163 static void rna_DepsgraphObjectInstance_orco_get(PointerRNA *ptr, float *orco)
164 {
165  BLI_Iterator *iterator = ptr->data;
166  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
167  if (deg_iter->dupli_object_current != NULL) {
168  copy_v3_v3(orco, deg_iter->dupli_object_current->orco);
169  }
170  else {
171  zero_v3(orco);
172  }
173 }
174 
175 static void rna_DepsgraphObjectInstance_uv_get(PointerRNA *ptr, float *uv)
176 {
177  BLI_Iterator *iterator = ptr->data;
178  DEGObjectIterData *deg_iter = (DEGObjectIterData *)iterator->data;
179  if (deg_iter->dupli_object_current != NULL) {
180  copy_v2_v2(uv, deg_iter->dupli_object_current->uv);
181  }
182  else {
183  zero_v2(uv);
184  }
185 }
186 
187 /* ******************** Sorted ***************** */
188 
189 static int rna_Depsgraph_mode_get(PointerRNA *ptr)
190 {
192  return DEG_get_mode(depsgraph);
193 }
194 
195 /* ******************** Updates ***************** */
196 
197 static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr)
198 {
200 }
201 
202 static bool rna_DepsgraphUpdate_is_updated_transform_get(PointerRNA *ptr)
203 {
204  ID *id = ptr->data;
205  return ((id->recalc & ID_RECALC_TRANSFORM) != 0);
206 }
207 
208 static bool rna_DepsgraphUpdate_is_updated_shading_get(PointerRNA *ptr)
209 {
210  /* Assume any animated parameters can affect shading, we don't have fine
211  * grained enough updates to distinguish this. */
212  ID *id = ptr->data;
213  return ((id->recalc & (ID_RECALC_SHADING | ID_RECALC_ANIMATION)) != 0);
214 }
215 
216 static bool rna_DepsgraphUpdate_is_updated_geometry_get(PointerRNA *ptr)
217 {
218  ID *id = ptr->data;
219  if (id->recalc & ID_RECALC_GEOMETRY) {
220  return true;
221  }
222  if (GS(id->name) != ID_OB) {
223  return false;
224  }
225  Object *object = (Object *)id;
226  ID *data = object->data;
227  if (data == NULL) {
228  return false;
229  }
230  return ((data->recalc & ID_RECALC_ALL) != 0);
231 }
232 
233 /* **************** Depsgraph **************** */
234 
235 static void rna_Depsgraph_debug_relations_graphviz(Depsgraph *depsgraph, const char *filename)
236 {
237  FILE *f = fopen(filename, "w");
238  if (f == NULL) {
239  return;
240  }
241  DEG_debug_relations_graphviz(depsgraph, f, "Depsgraph");
242  fclose(f);
243 }
244 
245 static void rna_Depsgraph_debug_stats_gnuplot(Depsgraph *depsgraph,
246  const char *filename,
247  const char *output_filename)
248 {
249  FILE *f = fopen(filename, "w");
250  if (f == NULL) {
251  return;
252  }
253  DEG_debug_stats_gnuplot(depsgraph, f, "Timing Statistics", output_filename);
254  fclose(f);
255 }
256 
257 static void rna_Depsgraph_debug_tag_update(Depsgraph *depsgraph)
258 {
260 }
261 
262 static void rna_Depsgraph_debug_stats(Depsgraph *depsgraph, char *result)
263 {
264  size_t outer, ops, rels;
265  DEG_stats_simple(depsgraph, &outer, &ops, &rels);
268  "Approx %zu Operations, %zu Relations, %zu Outer Nodes",
269  ops,
270  rels,
271  outer);
272 }
273 
274 static void rna_Depsgraph_update(Depsgraph *depsgraph, Main *bmain, ReportList *reports)
275 {
277  BKE_report(reports, RPT_ERROR, "Dependency graph update requested during evaluation");
278  return;
279  }
280 
281 # ifdef WITH_PYTHON
282  /* Allow drivers to be evaluated */
284 # endif
285 
287 
288 # ifdef WITH_PYTHON
290 # endif
291 }
292 
293 /* Iteration over objects, simple version */
294 
295 static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
296 {
297  iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
298  DEGObjectIterData *data = MEM_callocN(sizeof(DEGObjectIterData), __func__);
299 
300  data->graph = (Depsgraph *)ptr->data;
303 
304  ((BLI_Iterator *)iter->internal.custom)->valid = true;
306  iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
307 }
308 
309 static void rna_Depsgraph_objects_next(CollectionPropertyIterator *iter)
310 {
312  iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
313 }
314 
315 static void rna_Depsgraph_objects_end(CollectionPropertyIterator *iter)
316 {
318  MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data);
319  MEM_freeN(iter->internal.custom);
320 }
321 
322 static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter)
323 {
324  Object *ob = ((BLI_Iterator *)iter->internal.custom)->current;
325  return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ob);
326 }
327 
328 /* Iteration over objects, extended version
329  *
330  * Contains extra information about duplicator and persistent ID.
331  */
332 
333 /* XXX Ugly python seems to query next item of an iterator before using current one (see T57558).
334  * This forces us to use that nasty ping-pong game between two sets of iterator data,
335  * so that previous one remains valid memory for python to access to. Yuck.
336  */
337 typedef struct RNA_Depsgraph_Instances_Iterator {
338  BLI_Iterator iterators[2];
339  DEGObjectIterData deg_data[2];
340  DupliObject dupli_object_current[2];
341  int counter;
342 } RNA_Depsgraph_Instances_Iterator;
343 
344 static void rna_Depsgraph_object_instances_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
345 {
346  RNA_Depsgraph_Instances_Iterator *di_it = iter->internal.custom = MEM_callocN(sizeof(*di_it),
347  __func__);
348 
349  DEGObjectIterData *data = &di_it->deg_data[0];
350  data->graph = (Depsgraph *)ptr->data;
353 
354  di_it->iterators[0].valid = true;
355  DEG_iterator_objects_begin(&di_it->iterators[0], data);
356  iter->valid = di_it->iterators[0].valid;
357 }
358 
359 static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter)
360 {
361  RNA_Depsgraph_Instances_Iterator *di_it = (RNA_Depsgraph_Instances_Iterator *)
362  iter->internal.custom;
363 
364  /* We need to copy current iterator status to next one being worked on. */
365  di_it->iterators[(di_it->counter + 1) % 2] = di_it->iterators[di_it->counter % 2];
366  di_it->deg_data[(di_it->counter + 1) % 2] = di_it->deg_data[di_it->counter % 2];
367  di_it->counter++;
368 
369  di_it->iterators[di_it->counter % 2].data = &di_it->deg_data[di_it->counter % 2];
370  DEG_iterator_objects_next(&di_it->iterators[di_it->counter % 2]);
371  /* Dupli_object_current is also temp memory generated during the iterations,
372  * it may be freed when last item has been iterated,
373  * so we have same issue as with the iterator itself:
374  * we need to keep a local copy, which memory remains valid a bit longer,
375  * for Python accesses to work. */
376  if (di_it->deg_data[di_it->counter % 2].dupli_object_current != NULL) {
377  di_it->dupli_object_current[di_it->counter % 2] =
378  *di_it->deg_data[di_it->counter % 2].dupli_object_current;
379  di_it->deg_data[di_it->counter % 2].dupli_object_current =
380  &di_it->dupli_object_current[di_it->counter % 2];
381  }
382  iter->valid = di_it->iterators[di_it->counter % 2].valid;
383 }
384 
385 static void rna_Depsgraph_object_instances_end(CollectionPropertyIterator *iter)
386 {
387  RNA_Depsgraph_Instances_Iterator *di_it = (RNA_Depsgraph_Instances_Iterator *)
388  iter->internal.custom;
389  DEG_iterator_objects_end(&di_it->iterators[0]);
390  DEG_iterator_objects_end(&di_it->iterators[1]);
391  MEM_freeN(di_it);
392 }
393 
394 static PointerRNA rna_Depsgraph_object_instances_get(CollectionPropertyIterator *iter)
395 {
396  RNA_Depsgraph_Instances_Iterator *di_it = (RNA_Depsgraph_Instances_Iterator *)
397  iter->internal.custom;
398  BLI_Iterator *iterator = &di_it->iterators[di_it->counter % 2];
400 }
401 
402 /* Iteration over evaluated IDs */
403 
404 static void rna_Depsgraph_ids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
405 {
406  iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
407  DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__);
408 
409  data->graph = (Depsgraph *)ptr->data;
410 
411  ((BLI_Iterator *)iter->internal.custom)->valid = true;
413  iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
414 }
415 
416 static void rna_Depsgraph_ids_next(CollectionPropertyIterator *iter)
417 {
419  iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
420 }
421 
422 static void rna_Depsgraph_ids_end(CollectionPropertyIterator *iter)
423 {
425  MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data);
426  MEM_freeN(iter->internal.custom);
427 }
428 
429 static PointerRNA rna_Depsgraph_ids_get(CollectionPropertyIterator *iter)
430 {
431  ID *id = ((BLI_Iterator *)iter->internal.custom)->current;
432  return rna_pointer_inherit_refine(&iter->parent, &RNA_ID, id);
433 }
434 
435 static void rna_Depsgraph_updates_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
436 {
437  iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
438  DEGIDIterData *data = MEM_callocN(sizeof(DEGIDIterData), __func__);
439 
440  data->graph = (Depsgraph *)ptr->data;
441  data->only_updated = true;
442 
443  ((BLI_Iterator *)iter->internal.custom)->valid = true;
445  iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
446 }
447 
448 static PointerRNA rna_Depsgraph_updates_get(CollectionPropertyIterator *iter)
449 {
450  ID *id = ((BLI_Iterator *)iter->internal.custom)->current;
452 }
453 
454 static ID *rna_Depsgraph_id_eval_get(Depsgraph *depsgraph, ID *id_orig)
455 {
456  return DEG_get_evaluated_id(depsgraph, id_orig);
457 }
458 
459 static bool rna_Depsgraph_id_type_updated(Depsgraph *depsgraph, int id_type)
460 {
461  return DEG_id_type_updated(depsgraph, id_type);
462 }
463 
464 static PointerRNA rna_Depsgraph_scene_get(PointerRNA *ptr)
465 {
468  PointerRNA newptr;
469  RNA_pointer_create(&scene->id, &RNA_Scene, scene, &newptr);
470  return newptr;
471 }
472 
473 static PointerRNA rna_Depsgraph_view_layer_get(PointerRNA *ptr)
474 {
478  PointerRNA newptr;
479  RNA_pointer_create(&scene->id, &RNA_ViewLayer, view_layer, &newptr);
480  return newptr;
481 }
482 
483 static PointerRNA rna_Depsgraph_scene_eval_get(PointerRNA *ptr)
484 {
486  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
487  PointerRNA newptr;
488  RNA_pointer_create(&scene_eval->id, &RNA_Scene, scene_eval, &newptr);
489  return newptr;
490 }
491 
492 static PointerRNA rna_Depsgraph_view_layer_eval_get(PointerRNA *ptr)
493 {
495  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
497  PointerRNA newptr;
498  RNA_pointer_create(&scene_eval->id, &RNA_ViewLayer, view_layer_eval, &newptr);
499  return newptr;
500 }
501 
502 #else
503 
505 {
506  StructRNA *srna;
507  PropertyRNA *prop;
508 
509  srna = RNA_def_struct(brna, "DepsgraphObjectInstance", NULL);
511  "Dependency Graph Object Instance",
512  "Extended information about dependency graph object iterator "
513  "(Warning: All data here is 'evaluated' one, not original .blend IDs)");
514 
515  prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
516  RNA_def_property_struct_type(prop, "Object");
517  RNA_def_property_ui_text(prop, "Object", "Evaluated object the iterator points to");
519  RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_object_get", NULL, NULL, NULL);
520 
521  prop = RNA_def_property(srna, "show_self", PROP_BOOLEAN, PROP_NONE);
524  prop, "Show Self", "The object geometry itself should be visible in the render");
525  RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_show_self_get", NULL);
526 
527  prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE);
530  prop, "Show Particles", "Particles part of the object should be visible in the render");
531  RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_show_particles_get", NULL);
532 
533  prop = RNA_def_property(srna, "is_instance", PROP_BOOLEAN, PROP_NONE);
536  prop, "Is Instance", "Denotes if the object is generated by another object");
537  RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_is_instance_get", NULL);
538 
539  prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE);
540  RNA_def_property_struct_type(prop, "Object");
542  prop, "Instance Object", "Evaluated object which is being instanced by this iterator");
545  prop, "rna_DepsgraphObjectInstance_instance_object_get", NULL, NULL, NULL);
546 
547  prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
548  RNA_def_property_struct_type(prop, "Object");
550  prop, "Parent", "If the object is an instance, the parent object that generated it");
552  RNA_def_property_pointer_funcs(prop, "rna_DepsgraphObjectInstance_parent_get", NULL, NULL, NULL);
553 
554  prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
555  RNA_def_property_struct_type(prop, "ParticleSystem");
558  prop, "Particle System", "Evaluated particle system that this object was instanced from");
560  prop, "rna_DepsgraphObjectInstance_particle_system_get", NULL, NULL, NULL);
561 
562  prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
564  prop,
565  "Persistent ID",
566  "Persistent identifier for inter-frame matching of objects with motion blur");
569  RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_persistent_id_get", NULL, NULL);
570 
571  prop = RNA_def_property(srna, "random_id", PROP_INT, PROP_UNSIGNED);
574  prop, "Instance Random ID", "Random id for this instance, typically for randomized shading");
575  RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_random_id_get", NULL, NULL);
576 
577  prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
580  RNA_def_property_ui_text(prop, "Generated Matrix", "Generated transform matrix in world space");
581  RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_matrix_world_get", NULL, NULL);
582 
583  prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
585  RNA_def_property_array(prop, 3);
587  prop, "Generated Coordinates", "Generated coordinates in parent object space");
588  RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_orco_get", NULL, NULL);
589 
590  prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
591  RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");
592  RNA_def_property_array(prop, 2);
594  RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_uv_get", NULL, NULL);
595 }
596 
598 {
599  StructRNA *srna;
600  PropertyRNA *prop;
601 
602  srna = RNA_def_struct(brna, "DepsgraphUpdate", NULL);
603  RNA_def_struct_ui_text(srna, "Dependency Graph Update", "Information about ID that was updated");
604 
605  prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
606  RNA_def_property_struct_type(prop, "ID");
607  RNA_def_property_ui_text(prop, "ID", "Updated data-block");
609  RNA_def_property_pointer_funcs(prop, "rna_DepsgraphUpdate_id_get", NULL, NULL, NULL);
610 
611  /* Use term 'is_updated' instead of 'is_dirty' here because this is a signal
612  * that users of the depsgraph may want to update their data (render engines for eg). */
613 
614  prop = RNA_def_property(srna, "is_updated_transform", PROP_BOOLEAN, PROP_NONE);
616  RNA_def_property_ui_text(prop, "Transform", "Object transformation is updated");
617  RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_updated_transform_get", NULL);
618 
619  prop = RNA_def_property(srna, "is_updated_geometry", PROP_BOOLEAN, PROP_NONE);
621  RNA_def_property_ui_text(prop, "Geometry", "Object geometry is updated");
622  RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_updated_geometry_get", NULL);
623 
624  prop = RNA_def_property(srna, "is_updated_shading", PROP_BOOLEAN, PROP_NONE);
626  RNA_def_property_ui_text(prop, "Shading", "Object shading is updated");
627  RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_updated_shading_get", NULL);
628 }
629 
630 static void rna_def_depsgraph(BlenderRNA *brna)
631 {
632  StructRNA *srna;
633  FunctionRNA *func;
634  PropertyRNA *parm;
635  PropertyRNA *prop;
636 
637  static EnumPropertyItem enum_depsgraph_mode_items[] = {
638  {DAG_EVAL_VIEWPORT, "VIEWPORT", 0, "Viewport", "Viewport non-rendered mode"},
639  {DAG_EVAL_RENDER, "RENDER", 0, "Render", "Render"},
640  {0, NULL, 0, NULL, NULL},
641  };
642 
643  srna = RNA_def_struct(brna, "Depsgraph", NULL);
644  RNA_def_struct_ui_text(srna, "Dependency Graph", "");
645 
646  prop = RNA_def_enum(srna, "mode", enum_depsgraph_mode_items, 0, "Mode", "Evaluation mode");
648  RNA_def_property_enum_funcs(prop, "rna_Depsgraph_mode_get", NULL, NULL);
649 
650  /* Debug helpers. */
651 
652  func = RNA_def_function(
653  srna, "debug_relations_graphviz", "rna_Depsgraph_debug_relations_graphviz");
655  func, "filename", NULL, FILE_MAX, "File Name", "Output path for the graphviz debug file");
657 
658  func = RNA_def_function(srna, "debug_stats_gnuplot", "rna_Depsgraph_debug_stats_gnuplot");
660  func, "filename", NULL, FILE_MAX, "File Name", "Output path for the gnuplot debug file");
662  parm = RNA_def_string_file_path(func,
663  "output_filename",
664  NULL,
665  FILE_MAX,
666  "Output File Name",
667  "File name where gnuplot script will save the result");
669 
670  func = RNA_def_function(srna, "debug_tag_update", "rna_Depsgraph_debug_tag_update");
671 
672  func = RNA_def_function(srna, "debug_stats", "rna_Depsgraph_debug_stats");
673  RNA_def_function_ui_description(func, "Report the number of elements in the Dependency Graph");
674  /* weak!, no way to return dynamic string type */
675  parm = RNA_def_string(func, "result", NULL, STATS_MAX_SIZE, "result", "");
676  RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); /* needed for string return value */
677  RNA_def_function_output(func, parm);
678 
679  /* Updates. */
680 
681  func = RNA_def_function(srna, "update", "rna_Depsgraph_update");
683  func,
684  "Re-evaluate any modified data-blocks, for example for animation or modifiers. "
685  "This invalidates all references to evaluated data-blocks from this dependency graph.");
687 
688  /* Queries for original data-blocks (the ones depsgraph is built for). */
689 
690  prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
691  RNA_def_property_struct_type(prop, "Scene");
692  RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_get", NULL, NULL, NULL);
694  RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for");
695 
696  prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE);
697  RNA_def_property_struct_type(prop, "ViewLayer");
698  RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_get", NULL, NULL, NULL);
701  prop, "View Layer", "Original view layer dependency graph is built for");
702 
703  /* Queries for evaluated data-blocks (the ones depsgraph is evaluating). */
704 
705  func = RNA_def_function(srna, "id_eval_get", "rna_Depsgraph_id_eval_get");
706  parm = RNA_def_pointer(
707  func, "id", "ID", "", "Original ID to get evaluated complementary part for");
709  parm = RNA_def_pointer(func, "id_eval", "ID", "", "Evaluated ID for the given original one");
710  RNA_def_function_return(func, parm);
711 
712  func = RNA_def_function(srna, "id_type_updated", "rna_Depsgraph_id_type_updated");
713  parm = RNA_def_enum(func, "id_type", rna_enum_id_type_items, 0, "ID Type", "");
715  parm = RNA_def_boolean(func,
716  "updated",
717  false,
718  "Updated",
719  "True if any datablock with this type was added, updated or removed");
720  RNA_def_function_return(func, parm);
721 
722  prop = RNA_def_property(srna, "scene_eval", PROP_POINTER, PROP_NONE);
723  RNA_def_property_struct_type(prop, "Scene");
724  RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_eval_get", NULL, NULL, NULL);
726  RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for");
727 
728  prop = RNA_def_property(srna, "view_layer_eval", PROP_POINTER, PROP_NONE);
729  RNA_def_property_struct_type(prop, "ViewLayer");
730  RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_eval_get", NULL, NULL, NULL);
733  prop, "View Layer", "Original view layer dependency graph is built for");
734 
735  /* Iterators. */
736 
737  prop = RNA_def_property(srna, "ids", PROP_COLLECTION, PROP_NONE);
738  RNA_def_property_struct_type(prop, "ID");
740  "rna_Depsgraph_ids_begin",
741  "rna_Depsgraph_ids_next",
742  "rna_Depsgraph_ids_end",
743  "rna_Depsgraph_ids_get",
744  NULL,
745  NULL,
746  NULL,
747  NULL);
748  RNA_def_property_ui_text(prop, "IDs", "All evaluated data-blocks");
749 
750  prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
751  RNA_def_property_struct_type(prop, "Object");
753  "rna_Depsgraph_objects_begin",
754  "rna_Depsgraph_objects_next",
755  "rna_Depsgraph_objects_end",
756  "rna_Depsgraph_objects_get",
757  NULL,
758  NULL,
759  NULL,
760  NULL);
761  RNA_def_property_ui_text(prop, "Objects", "Evaluated objects in the dependency graph");
762 
763  prop = RNA_def_property(srna, "object_instances", PROP_COLLECTION, PROP_NONE);
764  RNA_def_property_struct_type(prop, "DepsgraphObjectInstance");
766  "rna_Depsgraph_object_instances_begin",
767  "rna_Depsgraph_object_instances_next",
768  "rna_Depsgraph_object_instances_end",
769  "rna_Depsgraph_object_instances_get",
770  NULL,
771  NULL,
772  NULL,
773  NULL);
775  "Object Instances",
776  "All object instances to display or render "
777  "(Warning: Only use this as an iterator, never as a sequence, "
778  "and do not keep any references to its items)");
779 
780  prop = RNA_def_property(srna, "updates", PROP_COLLECTION, PROP_NONE);
781  RNA_def_property_struct_type(prop, "DepsgraphUpdate");
783  "rna_Depsgraph_updates_begin",
784  "rna_Depsgraph_ids_next",
785  "rna_Depsgraph_ids_end",
786  "rna_Depsgraph_updates_get",
787  NULL,
788  NULL,
789  NULL,
790  NULL);
791  RNA_def_property_ui_text(prop, "Updates", "Updates to data-blocks");
792 }
793 
795 {
798  rna_def_depsgraph(brna);
799 }
800 
801 #endif
General operations, lookup, etc. for blender objects.
@ OB_VISIBLE_SELF
Definition: BKE_object.h:125
@ OB_VISIBLE_PARTICLES
Definition: BKE_object.h:126
int BKE_object_visibility(const struct Object *ob, const int dag_eval_mode)
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_scene_graph_update_tagged(struct Depsgraph *depsgraph, struct Main *bmain)
Definition: scene.c:2713
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v2(float r[2])
MINLINE void zero_v3(float r[3])
#define FILE_MAX
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define BPy_BEGIN_ALLOW_THREADS
Definition: BPY_extern.h:62
#define BPy_END_ALLOW_THREADS
Definition: BPY_extern.h:66
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:62
@ DAG_EVAL_VIEWPORT
Definition: DEG_depsgraph.h:61
bool DEG_is_evaluating(const struct Depsgraph *depsgraph)
Definition: depsgraph.cc:325
void DEG_graph_tag_relations_update(struct Depsgraph *graph)
void DEG_debug_relations_graphviz(const struct Depsgraph *graph, FILE *fp, const char *label)
void DEG_stats_simple(const struct Depsgraph *graph, size_t *r_outer, size_t *r_operations, size_t *r_relations)
void DEG_debug_stats_gnuplot(const struct Depsgraph *graph, FILE *fp, const char *label, const char *output_filename)
void DEG_iterator_objects_next(struct BLI_Iterator *iter)
struct Scene * DEG_get_input_scene(const Depsgraph *graph)
void DEG_iterator_ids_begin(struct BLI_Iterator *iter, DEGIDIterData *data)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
void DEG_iterator_ids_end(struct BLI_Iterator *iter)
struct ID * DEG_get_evaluated_id(const struct Depsgraph *depsgraph, struct ID *id)
struct ViewLayer * DEG_get_evaluated_view_layer(const struct Depsgraph *graph)
void DEG_iterator_objects_end(struct BLI_Iterator *iter)
void DEG_iterator_objects_begin(struct BLI_Iterator *iter, DEGObjectIterData *data)
void DEG_iterator_ids_next(struct BLI_Iterator *iter)
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_VISIBLE
@ DEG_ITER_OBJECT_FLAG_DUPLI
@ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET
struct ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
bool DEG_id_type_updated(const struct Depsgraph *depsgraph, short id_type)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:599
@ ID_RECALC_SHADING
Definition: DNA_ID.h:631
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:614
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
@ ID_RECALC_ALL
Definition: DNA_ID.h:697
@ ID_OB
Definition: DNA_ID_enums.h:59
Object is a sort of wrapper for general info.
#define MAX_DUPLI_RECUR
Read Guarded memory(de)allocation.
StructRNA RNA_Scene
StructRNA RNA_ViewLayer
StructRNA RNA_DepsgraphObjectInstance
StructRNA RNA_DepsgraphUpdate
StructRNA RNA_ParticleSystem
StructRNA RNA_ID
StructRNA RNA_Object
@ PARM_REQUIRED
Definition: RNA_types.h:337
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ FUNC_USE_MAIN
Definition: RNA_types.h:576
@ PROP_FLOAT
Definition: RNA_types.h:75
@ PROP_BOOLEAN
Definition: RNA_types.h:73
@ PROP_INT
Definition: RNA_types.h:74
@ PROP_POINTER
Definition: RNA_types.h:78
@ PROP_COLLECTION
Definition: RNA_types.h:79
@ PROP_THICK_WRAP
Definition: RNA_types.h:270
@ PROP_ANIMATABLE
Definition: RNA_types.h:188
@ PROP_EDITABLE
Definition: RNA_types.h:175
@ PROP_MATRIX
Definition: RNA_types.h:144
@ PROP_NONE
Definition: RNA_types.h:113
@ PROP_TRANSLATION
Definition: RNA_types.h:140
@ PROP_UNSIGNED
Definition: RNA_types.h:129
return(oflags[bm->toolflag_index].f &oflag) !=0
const char * output_filename
Scene scene
const Depsgraph * depsgraph
#define GS(x)
Definition: iris.c:241
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
const EnumPropertyItem rna_enum_id_type_items[]
Definition: rna_ID.c:46
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *data)
Definition: rna_access.c:196
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
Definition: rna_define.c:4159
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
Definition: rna_define.c:4302
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3153
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1676
PropertyRNA * RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3699
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3408
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1259
void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret)
Definition: rna_define.c:4327
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2971
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1629
void RNA_def_property_array(PropertyRNA *prop, int length)
Definition: rna_define.c:1568
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1792
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
const int rna_matrix_dimsize_4x4[]
Definition: rna_define.c:1626
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3251
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1279
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1517
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
Definition: rna_define.c:3373
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1047
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3055
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3675
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition: rna_define.c:1547
void RNA_def_depsgraph(BlenderRNA *brna)
#define STATS_MAX_SIZE
Definition: rna_depsgraph.c:35
static void rna_def_depsgraph_instance(BlenderRNA *brna)
static void rna_def_depsgraph_update(BlenderRNA *brna)
static void rna_def_depsgraph(BlenderRNA *brna)
void * current
Definition: BLI_iterator.h:28
union CollectionPropertyIterator::@1099 internal
eEvaluationMode eval_mode
struct Object * dupli_parent
struct DupliObject * dupli_object_current
float uv[2]
Definition: BKE_duplilist.h:47
float mat[4][4]
Definition: BKE_duplilist.h:46
struct ParticleSystem * particle_system
Definition: BKE_duplilist.h:57
int persistent_id[8]
Definition: BKE_duplilist.h:54
float orco[3]
Definition: BKE_duplilist.h:47
struct Object * ob
Definition: BKE_duplilist.h:45
unsigned int random_id
Definition: BKE_duplilist.h:60
Definition: DNA_ID.h:273
int recalc
Definition: DNA_ID.h:295
char name[66]
Definition: DNA_ID.h:283
Definition: BKE_main.h:116
float obmat[4][4]
void * data
Definition: RNA_types.h:52
PointerRNA * ptr
Definition: wm_files.c:3157