Blender V4.3
rna_depsgraph.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <array>
10#include <cstdlib>
11
12#include "BLI_math_matrix.h"
13#include "BLI_math_vector.h"
14#include "BLI_path_utils.hh"
15#include "BLI_utildefines.h"
16
17#include "RNA_define.hh"
18#include "RNA_enum_types.hh"
19
20#include "rna_internal.hh"
21
22#include "DNA_object_types.h"
23
24#include "DEG_depsgraph.hh"
25
26#define STATS_MAX_SIZE 16384
27
28#ifdef RNA_RUNTIME
29
30# ifdef WITH_PYTHON
31# include "BPY_extern.hh"
32# endif
33
34# include "BLI_iterator.h"
35
36# include "RNA_access.hh"
37
38# include "BKE_duplilist.hh"
39# include "BKE_object.hh"
40# include "BKE_scene.hh"
41
42# include "DEG_depsgraph_build.hh"
43# include "DEG_depsgraph_debug.hh"
44# include "DEG_depsgraph_query.hh"
45
46# include "MEM_guardedalloc.h"
47
48/* **************** Object Instance **************** */
49
50struct RNA_DepsgraphIterator {
51 BLI_Iterator iter;
52# ifdef WITH_PYTHON
56 void *py_instance;
57# endif
58};
59
60# ifdef WITH_PYTHON
61void **rna_DepsgraphIterator_instance(PointerRNA *ptr)
62{
63 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
64 return &di->py_instance;
65}
66# endif
67
68/* Temporary hack for Cycles until it is changed to work with the C API directly. */
70{
71 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
72 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
73 return deg_iter->dupli_object_current;
74}
75
76static PointerRNA rna_DepsgraphObjectInstance_object_get(PointerRNA *ptr)
77{
78 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
79 return rna_pointer_inherit_refine(ptr, &RNA_Object, di->iter.current);
80}
81
82static bool rna_DepsgraphObjectInstance_is_instance_get(PointerRNA *ptr)
83{
84 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
85 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
86 return (deg_iter->dupli_object_current != nullptr);
87}
88
89static PointerRNA rna_DepsgraphObjectInstance_instance_object_get(PointerRNA *ptr)
90{
91 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
92 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
93 Object *instance_object = nullptr;
94 if (deg_iter->dupli_object_current != nullptr) {
95 instance_object = deg_iter->dupli_object_current->ob;
96 }
97 return rna_pointer_inherit_refine(ptr, &RNA_Object, instance_object);
98}
99
100static bool rna_DepsgraphObjectInstance_show_self_get(PointerRNA *ptr)
101{
102 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
103 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
104 int ob_visibility = BKE_object_visibility(static_cast<const Object *>(di->iter.current),
105 deg_iter->eval_mode);
106 return (ob_visibility & OB_VISIBLE_SELF) != 0;
107}
108
109static bool rna_DepsgraphObjectInstance_show_particles_get(PointerRNA *ptr)
110{
111 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
112 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
113 int ob_visibility = BKE_object_visibility(static_cast<const Object *>(di->iter.current),
114 deg_iter->eval_mode);
115 return (ob_visibility & OB_VISIBLE_PARTICLES) != 0;
116}
117
118static PointerRNA rna_DepsgraphObjectInstance_parent_get(PointerRNA *ptr)
119{
120 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
121 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
122 Object *dupli_parent = nullptr;
123 if (deg_iter->dupli_object_current != nullptr) {
124 dupli_parent = deg_iter->dupli_parent;
125 }
126 return rna_pointer_inherit_refine(ptr, &RNA_Object, dupli_parent);
127}
128
129static PointerRNA rna_DepsgraphObjectInstance_particle_system_get(PointerRNA *ptr)
130{
131 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
132 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
133 ParticleSystem *particle_system = nullptr;
134 if (deg_iter->dupli_object_current != nullptr) {
135 particle_system = deg_iter->dupli_object_current->particle_system;
136 }
137 return rna_pointer_inherit_refine(ptr, &RNA_ParticleSystem, particle_system);
138}
139
140static void rna_DepsgraphObjectInstance_persistent_id_get(PointerRNA *ptr, int *persistent_id)
141{
142 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
143 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
144 if (deg_iter->dupli_object_current != nullptr) {
145 memcpy(persistent_id,
146 deg_iter->dupli_object_current->persistent_id,
147 sizeof(deg_iter->dupli_object_current->persistent_id));
148 }
149 else {
150 memset(persistent_id, 0, sizeof(deg_iter->dupli_object_current->persistent_id));
151 }
152}
153
154static int rna_DepsgraphObjectInstance_random_id_get(PointerRNA *ptr)
155{
156 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
157 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
158 if (deg_iter->dupli_object_current != nullptr) {
159 return int(deg_iter->dupli_object_current->random_id);
160 }
161 else {
162 return 0;
163 }
164}
165
166static void rna_DepsgraphObjectInstance_matrix_world_get(PointerRNA *ptr, float *mat)
167{
168 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
169 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
170 if (deg_iter->dupli_object_current != nullptr) {
171 copy_m4_m4((float(*)[4])mat, deg_iter->dupli_object_current->mat);
172 }
173 else {
174 /* We can return actual object's matrix here, no reason to return identity matrix
175 * when this is not actually an instance... */
176 Object *ob = (Object *)di->iter.current;
177 copy_m4_m4((float(*)[4])mat, ob->object_to_world().ptr());
178 }
179}
180
181static void rna_DepsgraphObjectInstance_orco_get(PointerRNA *ptr, float *orco)
182{
183 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
184 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
185 if (deg_iter->dupli_object_current != nullptr) {
186 copy_v3_v3(orco, deg_iter->dupli_object_current->orco);
187 }
188 else {
189 zero_v3(orco);
190 }
191}
192
193static void rna_DepsgraphObjectInstance_uv_get(PointerRNA *ptr, float *uv)
194{
195 RNA_DepsgraphIterator *di = static_cast<RNA_DepsgraphIterator *>(ptr->data);
196 DEGObjectIterData *deg_iter = (DEGObjectIterData *)di->iter.data;
197 if (deg_iter->dupli_object_current != nullptr) {
198 copy_v2_v2(uv, deg_iter->dupli_object_current->uv);
199 }
200 else {
201 zero_v2(uv);
202 }
203}
204
205/* ******************** Sorted ***************** */
206
207static int rna_Depsgraph_mode_get(PointerRNA *ptr)
208{
209 Depsgraph *depsgraph = static_cast<Depsgraph *>(ptr->data);
210 return DEG_get_mode(depsgraph);
211}
212
213/* ******************** Updates ***************** */
214
215static PointerRNA rna_DepsgraphUpdate_id_get(PointerRNA *ptr)
216{
217 return rna_pointer_inherit_refine(ptr, &RNA_ID, ptr->data);
218}
219
220static bool rna_DepsgraphUpdate_is_updated_transform_get(PointerRNA *ptr)
221{
222 ID *id = static_cast<ID *>(ptr->data);
223 return ((id->recalc & ID_RECALC_TRANSFORM) != 0);
224}
225
226static bool rna_DepsgraphUpdate_is_updated_shading_get(PointerRNA *ptr)
227{
228 /* Assume any animated parameters can affect shading, we don't have fine
229 * grained enough updates to distinguish this. */
230 ID *id = static_cast<ID *>(ptr->data);
231 return ((id->recalc & (ID_RECALC_SHADING | ID_RECALC_ANIMATION)) != 0);
232}
233
234static bool rna_DepsgraphUpdate_is_updated_geometry_get(PointerRNA *ptr)
235{
236 ID *id = static_cast<ID *>(ptr->data);
237 if (id->recalc & ID_RECALC_GEOMETRY) {
238 return true;
239 }
240 if (GS(id->name) != ID_OB) {
241 return false;
242 }
243 Object *object = (Object *)id;
244 ID *data = static_cast<ID *>(object->data);
245 if (data == nullptr) {
246 return false;
247 }
248 return ((data->recalc & ID_RECALC_ALL) != 0);
249}
250
251/* **************** Depsgraph **************** */
252
253static void rna_Depsgraph_debug_relations_graphviz(Depsgraph *depsgraph,
254 const char *filepath,
255 const char **r_str,
256 int *r_len)
257{
258 const std::string dot_str = DEG_debug_graph_to_dot(*depsgraph, "Depsgraph");
259 *r_len = dot_str.size();
260 *r_str = BLI_strdup(dot_str.c_str());
261
262 if (filepath) {
263 FILE *f = fopen(filepath, "w");
264 if (f == nullptr) {
265 return;
266 }
267 fprintf(f, "%s", dot_str.c_str());
268 fclose(f);
269 }
270}
271
272static void rna_Depsgraph_debug_stats_gnuplot(Depsgraph *depsgraph,
273 const char *filepath,
274 const char *output_filepath)
275{
276 FILE *f = fopen(filepath, "w");
277 if (f == nullptr) {
278 return;
279 }
280 DEG_debug_stats_gnuplot(depsgraph, f, "Timing Statistics", output_filepath);
281 fclose(f);
282}
283
284static void rna_Depsgraph_debug_tag_update(Depsgraph *depsgraph)
285{
287}
288
289static void rna_Depsgraph_debug_stats(Depsgraph *depsgraph, char *result)
290{
291 size_t outer, ops, rels;
292 DEG_stats_simple(depsgraph, &outer, &ops, &rels);
293 BLI_snprintf(result,
295 "Approx %zu Operations, %zu Relations, %zu Outer Nodes",
296 ops,
297 rels,
298 outer);
299}
300
301static void rna_Depsgraph_update(Depsgraph *depsgraph, Main *bmain, ReportList *reports)
302{
304 BKE_report(reports, RPT_ERROR, "Dependency graph update requested during evaluation");
305 return;
306 }
307
308# ifdef WITH_PYTHON
309 /* Allow drivers to be evaluated */
311# endif
312
314
315# ifdef WITH_PYTHON
317# endif
318}
319
320/* Iteration over objects, simple version */
321
322static void rna_Depsgraph_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
323{
324 iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
325 DEGObjectIterData *data = MEM_new<DEGObjectIterData>(__func__);
326 DEGObjectIterSettings *deg_iter_settings = static_cast<DEGObjectIterSettings *>(
327 MEM_callocN(sizeof(DEGObjectIterSettings), __func__));
328 deg_iter_settings->depsgraph = (Depsgraph *)ptr->data;
331
332 data->settings = deg_iter_settings;
333 data->graph = deg_iter_settings->depsgraph;
334 data->flag = deg_iter_settings->flags;
335
336 ((BLI_Iterator *)iter->internal.custom)->valid = true;
337 DEG_iterator_objects_begin(static_cast<BLI_Iterator *>(iter->internal.custom), data);
338 iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
339}
340
341static void rna_Depsgraph_objects_next(CollectionPropertyIterator *iter)
342{
344 iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
345}
346
347static void rna_Depsgraph_objects_end(CollectionPropertyIterator *iter)
348{
351 MEM_freeN(data->settings);
352 MEM_delete(data);
354}
355
356static PointerRNA rna_Depsgraph_objects_get(CollectionPropertyIterator *iter)
357{
358 Object *ob = static_cast<Object *>(((BLI_Iterator *)iter->internal.custom)->current);
359 return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ob);
360}
361
362/* Iteration over objects, extended version
363 *
364 * Contains extra information about duplicator and persistent ID.
365 */
366
367/* XXX Ugly python seems to query next item of an iterator before using current one (see #57558).
368 * This forces us to use that nasty ping-pong game between two sets of iterator data,
369 * so that previous one remains valid memory for python to access to. Yuck.
370 */
371struct RNA_Depsgraph_Instances_Iterator {
372 RNA_DepsgraphIterator iterators[2];
373 DEGObjectIterData deg_data[2];
374 DupliObject dupli_object_current[2];
375 int counter;
376};
377
378static void rna_Depsgraph_object_instances_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
379{
380 RNA_Depsgraph_Instances_Iterator *di_it = MEM_new<RNA_Depsgraph_Instances_Iterator>(__func__);
381 iter->internal.custom = di_it;
382 DEGObjectIterSettings *deg_iter_settings = static_cast<DEGObjectIterSettings *>(
383 MEM_callocN(sizeof(DEGObjectIterSettings), __func__));
384 deg_iter_settings->depsgraph = (Depsgraph *)ptr->data;
385 deg_iter_settings->flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
388
389 DEGObjectIterData *data = &di_it->deg_data[0];
390 data->settings = deg_iter_settings;
391 data->graph = deg_iter_settings->depsgraph;
392 data->flag = deg_iter_settings->flags;
393
394 di_it->iterators[0].iter.valid = true;
395 DEG_iterator_objects_begin(&di_it->iterators[0].iter, data);
396 iter->valid = di_it->iterators[0].iter.valid;
397}
398
399static void rna_Depsgraph_object_instances_next(CollectionPropertyIterator *iter)
400{
401 RNA_Depsgraph_Instances_Iterator *di_it = (RNA_Depsgraph_Instances_Iterator *)
402 iter->internal.custom;
403
404 /* We need to copy current iterator status to next one being worked on. */
405 di_it->iterators[(di_it->counter + 1) % 2].iter = di_it->iterators[di_it->counter % 2].iter;
406 di_it->deg_data[(di_it->counter + 1) % 2] = di_it->deg_data[di_it->counter % 2];
407 di_it->counter++;
408
409 di_it->iterators[di_it->counter % 2].iter.data = &di_it->deg_data[di_it->counter % 2];
410 DEG_iterator_objects_next(&di_it->iterators[di_it->counter % 2].iter);
411 /* Dupli_object_current is also temp memory generated during the iterations,
412 * it may be freed when last item has been iterated,
413 * so we have same issue as with the iterator itself:
414 * we need to keep a local copy, which memory remains valid a bit longer,
415 * for Python accesses to work. */
416 if (di_it->deg_data[di_it->counter % 2].dupli_object_current != nullptr) {
417 di_it->dupli_object_current[di_it->counter % 2] =
418 *di_it->deg_data[di_it->counter % 2].dupli_object_current;
419 di_it->deg_data[di_it->counter % 2].dupli_object_current =
420 &di_it->dupli_object_current[di_it->counter % 2];
421 }
422 iter->valid = di_it->iterators[di_it->counter % 2].iter.valid;
423}
424
425static void rna_Depsgraph_object_instances_end(CollectionPropertyIterator *iter)
426{
427 RNA_Depsgraph_Instances_Iterator *di_it = (RNA_Depsgraph_Instances_Iterator *)
428 iter->internal.custom;
429 for (int i = 0; i < ARRAY_SIZE(di_it->iterators); i++) {
430 RNA_DepsgraphIterator *di = &di_it->iterators[i];
431 DEGObjectIterData *data = &di_it->deg_data[i];
432 if (i == 0) {
433 /* Is shared between both iterators. */
434 MEM_freeN(data->settings);
435 }
436 DEG_iterator_objects_end(&di->iter);
437
438# ifdef WITH_PYTHON
439 if (di->py_instance) {
440 BPY_DECREF_RNA_INVALIDATE(di->py_instance);
441 }
442# endif
443 }
444
445 MEM_delete(di_it);
446}
447
448static PointerRNA rna_Depsgraph_object_instances_get(CollectionPropertyIterator *iter)
449{
450 RNA_Depsgraph_Instances_Iterator *di_it = (RNA_Depsgraph_Instances_Iterator *)
451 iter->internal.custom;
452 RNA_DepsgraphIterator *di = &di_it->iterators[di_it->counter % 2];
453 return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphObjectInstance, di);
454}
455
456/* Iteration over evaluated IDs */
457
458static void rna_Depsgraph_ids_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
459{
460 iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
461 DEGIDIterData *data = static_cast<DEGIDIterData *>(MEM_callocN(sizeof(DEGIDIterData), __func__));
462
463 data->graph = (Depsgraph *)ptr->data;
464
465 ((BLI_Iterator *)iter->internal.custom)->valid = true;
466 DEG_iterator_ids_begin(static_cast<BLI_Iterator *>(iter->internal.custom), data);
467 iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
468}
469
470static void rna_Depsgraph_ids_next(CollectionPropertyIterator *iter)
471{
472 DEG_iterator_ids_next(static_cast<BLI_Iterator *>(iter->internal.custom));
473 iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
474}
475
476static void rna_Depsgraph_ids_end(CollectionPropertyIterator *iter)
477{
478 DEG_iterator_ids_end(static_cast<BLI_Iterator *>(iter->internal.custom));
479 MEM_freeN(((BLI_Iterator *)iter->internal.custom)->data);
481}
482
483static PointerRNA rna_Depsgraph_ids_get(CollectionPropertyIterator *iter)
484{
485 ID *id = static_cast<ID *>(((BLI_Iterator *)iter->internal.custom)->current);
486 return rna_pointer_inherit_refine(&iter->parent, &RNA_ID, id);
487}
488
489static void rna_Depsgraph_updates_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
490{
491 iter->internal.custom = MEM_callocN(sizeof(BLI_Iterator), __func__);
492 DEGIDIterData *data = static_cast<DEGIDIterData *>(MEM_callocN(sizeof(DEGIDIterData), __func__));
493
494 data->graph = (Depsgraph *)ptr->data;
495 data->only_updated = true;
496
497 ((BLI_Iterator *)iter->internal.custom)->valid = true;
498 DEG_iterator_ids_begin(static_cast<BLI_Iterator *>(iter->internal.custom), data);
499 iter->valid = ((BLI_Iterator *)iter->internal.custom)->valid;
500}
501
502static PointerRNA rna_Depsgraph_updates_get(CollectionPropertyIterator *iter)
503{
504 ID *id = static_cast<ID *>(((BLI_Iterator *)iter->internal.custom)->current);
505 return rna_pointer_inherit_refine(&iter->parent, &RNA_DepsgraphUpdate, id);
506}
507
508static ID *rna_Depsgraph_id_eval_get(Depsgraph *depsgraph, ID *id_orig)
509{
510 return DEG_get_evaluated_id(depsgraph, id_orig);
511}
512
513static bool rna_Depsgraph_id_type_updated(Depsgraph *depsgraph, int id_type)
514{
515 return DEG_id_type_updated(depsgraph, id_type);
516}
517
518static PointerRNA rna_Depsgraph_scene_get(PointerRNA *ptr)
519{
520 Depsgraph *depsgraph = (Depsgraph *)ptr->data;
522 PointerRNA newptr = RNA_pointer_create(&scene->id, &RNA_Scene, scene);
523 return newptr;
524}
525
526static PointerRNA rna_Depsgraph_view_layer_get(PointerRNA *ptr)
527{
528 Depsgraph *depsgraph = (Depsgraph *)ptr->data;
531 PointerRNA newptr = RNA_pointer_create(&scene->id, &RNA_ViewLayer, view_layer);
532 return newptr;
533}
534
535static PointerRNA rna_Depsgraph_scene_eval_get(PointerRNA *ptr)
536{
537 Depsgraph *depsgraph = (Depsgraph *)ptr->data;
539 PointerRNA newptr = RNA_pointer_create(&scene_eval->id, &RNA_Scene, scene_eval);
540 return newptr;
541}
542
543static PointerRNA rna_Depsgraph_view_layer_eval_get(PointerRNA *ptr)
544{
545 Depsgraph *depsgraph = (Depsgraph *)ptr->data;
548 PointerRNA newptr = RNA_pointer_create(&scene_eval->id, &RNA_ViewLayer, view_layer_eval);
549 return newptr;
550}
551
552#else
553
555{
556 StructRNA *srna;
557 PropertyRNA *prop;
558
559 srna = RNA_def_struct(brna, "DepsgraphObjectInstance", nullptr);
561 "Dependency Graph Object Instance",
562 "Extended information about dependency graph object iterator "
563 "(Warning: All data here is 'evaluated' one, not original .blend IDs)");
564
565# ifdef WITH_PYTHON
566 RNA_def_struct_register_funcs(srna, nullptr, nullptr, "rna_DepsgraphIterator_instance");
567# endif
568
569 prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
570 RNA_def_property_struct_type(prop, "Object");
571 RNA_def_property_ui_text(prop, "Object", "Evaluated object the iterator points to");
574 prop, "rna_DepsgraphObjectInstance_object_get", nullptr, nullptr, nullptr);
575
576 prop = RNA_def_property(srna, "show_self", PROP_BOOLEAN, PROP_NONE);
579 prop, "Show Self", "The object geometry itself should be visible in the render");
580 RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_show_self_get", nullptr);
581
582 prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE);
585 prop, "Show Particles", "Particles part of the object should be visible in the render");
586 RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_show_particles_get", nullptr);
587
588 prop = RNA_def_property(srna, "is_instance", PROP_BOOLEAN, PROP_NONE);
591 prop, "Is Instance", "Denotes if the object is generated by another object");
592 RNA_def_property_boolean_funcs(prop, "rna_DepsgraphObjectInstance_is_instance_get", nullptr);
593
594 prop = RNA_def_property(srna, "instance_object", PROP_POINTER, PROP_NONE);
595 RNA_def_property_struct_type(prop, "Object");
597 prop, "Instance Object", "Evaluated object which is being instanced by this iterator");
600 prop, "rna_DepsgraphObjectInstance_instance_object_get", nullptr, nullptr, nullptr);
601
602 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
603 RNA_def_property_struct_type(prop, "Object");
605 prop, "Parent", "If the object is an instance, the parent object that generated it");
608 prop, "rna_DepsgraphObjectInstance_parent_get", nullptr, nullptr, nullptr);
609
610 prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
611 RNA_def_property_struct_type(prop, "ParticleSystem");
614 prop, "Particle System", "Evaluated particle system that this object was instanced from");
616 prop, "rna_DepsgraphObjectInstance_particle_system_get", nullptr, nullptr, nullptr);
617
618 prop = RNA_def_property(srna, "persistent_id", PROP_INT, PROP_NONE);
620 prop,
621 "Persistent ID",
622 "Persistent identifier for inter-frame matching of objects with motion blur");
626 prop, "rna_DepsgraphObjectInstance_persistent_id_get", nullptr, nullptr);
627
628 prop = RNA_def_property(srna, "random_id", PROP_INT, PROP_UNSIGNED);
631 prop, "Instance Random ID", "Random id for this instance, typically for randomized shading");
632 RNA_def_property_int_funcs(prop, "rna_DepsgraphObjectInstance_random_id_get", nullptr, nullptr);
633
634 prop = RNA_def_property(srna, "matrix_world", PROP_FLOAT, PROP_MATRIX);
637 RNA_def_property_ui_text(prop, "Generated Matrix", "Generated transform matrix in world space");
639 prop, "rna_DepsgraphObjectInstance_matrix_world_get", nullptr, nullptr);
640
641 prop = RNA_def_property(srna, "orco", PROP_FLOAT, PROP_TRANSLATION);
643 RNA_def_property_array(prop, 3);
645 prop, "Generated Coordinates", "Generated coordinates in parent object space");
646 RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_orco_get", nullptr, nullptr);
647
648 prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
649 RNA_def_property_ui_text(prop, "UV Coordinates", "UV coordinates in parent object space");
650 RNA_def_property_array(prop, 2);
652 RNA_def_property_float_funcs(prop, "rna_DepsgraphObjectInstance_uv_get", nullptr, nullptr);
653}
654
656{
657 StructRNA *srna;
658 PropertyRNA *prop;
659
660 srna = RNA_def_struct(brna, "DepsgraphUpdate", nullptr);
661 RNA_def_struct_ui_text(srna, "Dependency Graph Update", "Information about ID that was updated");
662
663 prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
665 RNA_def_property_ui_text(prop, "ID", "Updated data-block");
667 RNA_def_property_pointer_funcs(prop, "rna_DepsgraphUpdate_id_get", nullptr, nullptr, nullptr);
668
669 /* Use term 'is_updated' instead of 'is_dirty' here because this is a signal
670 * that users of the depsgraph may want to update their data (render engines for eg). */
671
672 prop = RNA_def_property(srna, "is_updated_transform", PROP_BOOLEAN, PROP_NONE);
674 RNA_def_property_ui_text(prop, "Transform", "Object transformation is updated");
675 RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_updated_transform_get", nullptr);
676
677 prop = RNA_def_property(srna, "is_updated_geometry", PROP_BOOLEAN, PROP_NONE);
679 RNA_def_property_ui_text(prop, "Geometry", "Object geometry is updated");
680 RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_updated_geometry_get", nullptr);
681
682 prop = RNA_def_property(srna, "is_updated_shading", PROP_BOOLEAN, PROP_NONE);
684 RNA_def_property_ui_text(prop, "Shading", "Object shading is updated");
685 RNA_def_property_boolean_funcs(prop, "rna_DepsgraphUpdate_is_updated_shading_get", nullptr);
686}
687
689{
690 StructRNA *srna;
691 FunctionRNA *func;
692 PropertyRNA *parm;
693 PropertyRNA *prop;
694
695 static const EnumPropertyItem enum_depsgraph_mode_items[] = {
696 {DAG_EVAL_VIEWPORT, "VIEWPORT", 0, "Viewport", "Viewport non-rendered mode"},
697 {DAG_EVAL_RENDER, "RENDER", 0, "Render", "Render"},
698 {0, nullptr, 0, nullptr, nullptr},
699 };
700
701 srna = RNA_def_struct(brna, "Depsgraph", nullptr);
702 RNA_def_struct_ui_text(srna, "Dependency Graph", "");
703
704 prop = RNA_def_enum(srna, "mode", enum_depsgraph_mode_items, 0, "Mode", "Evaluation mode");
706 RNA_def_property_enum_funcs(prop, "rna_Depsgraph_mode_get", nullptr, nullptr);
707
708 /* Debug helpers. */
709
710 func = RNA_def_function(
711 srna, "debug_relations_graphviz", "rna_Depsgraph_debug_relations_graphviz");
712 parm = RNA_def_string_file_path(func,
713 "filepath",
714 nullptr,
715 FILE_MAX,
716 "File Name",
717 "Optional output path for the graphviz debug file");
718 parm = RNA_def_string(func, "dot_graph", nullptr, INT32_MAX, "Dot Graph", "Graph in dot format");
721 RNA_def_function_output(func, parm);
722
723 func = RNA_def_function(srna, "debug_stats_gnuplot", "rna_Depsgraph_debug_stats_gnuplot");
725 func, "filepath", nullptr, FILE_MAX, "File Name", "Output path for the gnuplot debug file");
727 parm = RNA_def_string_file_path(func,
728 "output_filepath",
729 nullptr,
730 FILE_MAX,
731 "Output File Name",
732 "File name where gnuplot script will save the result");
734
735 func = RNA_def_function(srna, "debug_tag_update", "rna_Depsgraph_debug_tag_update");
736
737 func = RNA_def_function(srna, "debug_stats", "rna_Depsgraph_debug_stats");
738 RNA_def_function_ui_description(func, "Report the number of elements in the Dependency Graph");
739 /* weak!, no way to return dynamic string type */
740 parm = RNA_def_string(func, "result", nullptr, STATS_MAX_SIZE, "result", "");
742 parm, PROP_THICK_WRAP, ParameterFlag(0)); /* needed for string return value */
743 RNA_def_function_output(func, parm);
744
745 /* Updates. */
746
747 func = RNA_def_function(srna, "update", "rna_Depsgraph_update");
749 func,
750 "Re-evaluate any modified data-blocks, for example for animation or modifiers. "
751 "This invalidates all references to evaluated data-blocks from this dependency graph.");
753
754 /* Queries for original data-blocks (the ones depsgraph is built for). */
755
756 prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
757 RNA_def_property_struct_type(prop, "Scene");
758 RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_get", nullptr, nullptr, nullptr);
760 RNA_def_property_ui_text(prop, "Scene", "Original scene dependency graph is built for");
761
762 prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE);
763 RNA_def_property_struct_type(prop, "ViewLayer");
764 RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_view_layer_get", nullptr, nullptr, nullptr);
767 prop, "View Layer", "Original view layer dependency graph is built for");
768
769 /* Queries for evaluated data-blocks (the ones depsgraph is evaluating). */
770
771 func = RNA_def_function(srna, "id_eval_get", "rna_Depsgraph_id_eval_get");
772 parm = RNA_def_pointer(
773 func, "id", "ID", "", "Original ID to get evaluated complementary part for");
775 parm = RNA_def_pointer(func, "id_eval", "ID", "", "Evaluated ID for the given original one");
776 RNA_def_function_return(func, parm);
777
778 func = RNA_def_function(srna, "id_type_updated", "rna_Depsgraph_id_type_updated");
779 parm = RNA_def_enum(func, "id_type", rna_enum_id_type_items, 0, "ID Type", "");
781 parm = RNA_def_boolean(func,
782 "updated",
783 false,
784 "Updated",
785 "True if any datablock with this type was added, updated or removed");
786 RNA_def_function_return(func, parm);
787
788 prop = RNA_def_property(srna, "scene_eval", PROP_POINTER, PROP_NONE);
789 RNA_def_property_struct_type(prop, "Scene");
790 RNA_def_property_pointer_funcs(prop, "rna_Depsgraph_scene_eval_get", nullptr, nullptr, nullptr);
792 RNA_def_property_ui_text(prop, "Scene", "Scene at its evaluated state");
793
794 prop = RNA_def_property(srna, "view_layer_eval", PROP_POINTER, PROP_NONE);
795 RNA_def_property_struct_type(prop, "ViewLayer");
797 prop, "rna_Depsgraph_view_layer_eval_get", nullptr, nullptr, nullptr);
799 RNA_def_property_ui_text(prop, "View Layer", "View layer at its evaluated state");
800
801 /* Iterators. */
802
803 prop = RNA_def_property(srna, "ids", PROP_COLLECTION, PROP_NONE);
806 "rna_Depsgraph_ids_begin",
807 "rna_Depsgraph_ids_next",
808 "rna_Depsgraph_ids_end",
809 "rna_Depsgraph_ids_get",
810 nullptr,
811 nullptr,
812 nullptr,
813 nullptr);
814 RNA_def_property_ui_text(prop, "IDs", "All evaluated data-blocks");
815
816 prop = RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
817 RNA_def_property_struct_type(prop, "Object");
819 "rna_Depsgraph_objects_begin",
820 "rna_Depsgraph_objects_next",
821 "rna_Depsgraph_objects_end",
822 "rna_Depsgraph_objects_get",
823 nullptr,
824 nullptr,
825 nullptr,
826 nullptr);
827 RNA_def_property_ui_text(prop, "Objects", "Evaluated objects in the dependency graph");
828
829 prop = RNA_def_property(srna, "object_instances", PROP_COLLECTION, PROP_NONE);
830 RNA_def_property_struct_type(prop, "DepsgraphObjectInstance");
832 "rna_Depsgraph_object_instances_begin",
833 "rna_Depsgraph_object_instances_next",
834 "rna_Depsgraph_object_instances_end",
835 "rna_Depsgraph_object_instances_get",
836 nullptr,
837 nullptr,
838 nullptr,
839 nullptr);
841 "Object Instances",
842 "All object instances to display or render "
843 "(Warning: Only use this as an iterator, never as a sequence, "
844 "and do not keep any references to its items)");
845
846 prop = RNA_def_property(srna, "updates", PROP_COLLECTION, PROP_NONE);
847 RNA_def_property_struct_type(prop, "DepsgraphUpdate");
849 "rna_Depsgraph_updates_begin",
850 "rna_Depsgraph_ids_next",
851 "rna_Depsgraph_ids_end",
852 "rna_Depsgraph_updates_get",
853 nullptr,
854 nullptr,
855 nullptr,
856 nullptr);
857 RNA_def_property_ui_text(prop, "Updates", "Updates to data-blocks");
858}
859
866
867#endif
General operations, lookup, etc. for blender objects.
@ OB_VISIBLE_SELF
@ OB_VISIBLE_PARTICLES
int BKE_object_visibility(const Object *ob, int dag_eval_mode)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
Definition scene.cc:2568
void copy_m4_m4(float m1[4][4], const float m2[4][4])
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
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.c:40
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define ARRAY_SIZE(arr)
#define BPy_BEGIN_ALLOW_THREADS
Definition BPY_extern.hh:50
void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr)
#define BPy_END_ALLOW_THREADS
Definition BPY_extern.hh:54
bool DEG_is_evaluating(const Depsgraph *depsgraph)
Definition depsgraph.cc:312
@ DAG_EVAL_RENDER
@ DAG_EVAL_VIEWPORT
void DEG_graph_tag_relations_update(Depsgraph *graph)
std::string DEG_debug_graph_to_dot(const Depsgraph &graph, blender::StringRef label)
void DEG_stats_simple(const Depsgraph *graph, size_t *r_outer, size_t *r_operations, size_t *r_relations)
void DEG_debug_stats_gnuplot(const Depsgraph *graph, FILE *fp, const char *label, const char *output_filename)
void DEG_iterator_ids_begin(BLI_Iterator *iter, DEGIDIterData *data)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
bool DEG_id_type_updated(const Depsgraph *depsgraph, short id_type)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
void DEG_iterator_objects_end(BLI_Iterator *iter)
void DEG_iterator_ids_end(BLI_Iterator *iter)
ViewLayer * DEG_get_evaluated_view_layer(const Depsgraph *graph)
ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
void DEG_iterator_objects_next(BLI_Iterator *iter)
void DEG_iterator_ids_next(BLI_Iterator *iter)
Scene * DEG_get_input_scene(const Depsgraph *graph)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_VISIBLE
@ DEG_ITER_OBJECT_FLAG_DUPLI
@ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1021
@ ID_RECALC_SHADING
Definition DNA_ID.h:1061
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1044
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ ID_RECALC_ALL
Definition DNA_ID.h:1155
@ ID_OB
Object is a sort of wrapper for general info.
#define MAX_DUPLI_RECUR
Read Guarded memory(de)allocation.
ParameterFlag
Definition RNA_types.hh:396
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_DYNAMIC
Definition RNA_types.hh:317
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_MATRIX
Definition RNA_types.hh:168
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_TRANSLATION
Definition RNA_types.hh:164
@ PROP_UNSIGNED
Definition RNA_types.hh:152
DupliObject * rna_hack_DepsgraphObjectInstance_dupli_object_get(PointerRNA *ptr)
const Depsgraph * depsgraph
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define GS(x)
Definition iris.cc:202
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
const EnumPropertyItem rna_enum_id_type_items[]
Definition rna_ID.cc:35
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
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)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
const int rna_matrix_dimsize_4x4[]
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
PropertyRNA * RNA_def_string_file_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_depsgraph(BlenderRNA *brna)
#define STATS_MAX_SIZE
static void rna_def_depsgraph_instance(BlenderRNA *brna)
static void rna_def_depsgraph_update(BlenderRNA *brna)
static void rna_def_depsgraph(BlenderRNA *brna)
#define INT32_MAX
Definition stdint.h:137
union CollectionPropertyIterator::@1329 internal
Definition DNA_ID.h:413
void * data
Definition RNA_types.hh:42
PointerRNA * ptr
Definition wm_files.cc:4126