Blender V5.3
DEG_depsgraph_query.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#pragma once
12
13#include "BLI_enum_flags.hh"
14#include "BLI_function_ref.hh"
15#include "BLI_iterator.hh"
16#include "BLI_set.hh"
17
18#include "DEG_depsgraph.hh"
20
21/* Needed for the instance iterator. */
22#include "DNA_object_types.h"
23
24#include "BKE_duplilist.hh"
25#include "BKE_object_types.hh"
26
27namespace blender {
28
29struct BLI_Iterator;
31struct Depsgraph;
32struct DupliObject;
33struct ID;
34struct PointerRNA;
35struct Scene;
36struct ViewLayer;
37struct ViewerPath;
38
39/* -------------------------------------------------------------------- */
42
44Scene *DEG_get_input_scene(const Depsgraph *graph);
45
47ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph);
48
50Main *DEG_get_bmain(const Depsgraph *graph);
51
53eEvaluationMode DEG_get_mode(const Depsgraph *graph);
54
56float DEG_get_ctime(const Depsgraph *graph);
57
59
60/* -------------------------------------------------------------------- */
63
65bool DEG_id_type_updated(const Depsgraph *depsgraph, short id_type);
66bool DEG_id_type_any_updated(const Depsgraph *depsgraph);
67
69bool DEG_id_is_user_modified(const Depsgraph *graph, const ID *id);
70
72bool DEG_scene_component_is_user_modified(const Depsgraph *graph,
73 const Scene *scene,
74 eDepsSceneComponentType component_type);
75
77bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type);
78
80uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, const ID *id);
81
83void DEG_get_customdata_mask_for_object(const Depsgraph *graph,
84 Object *object,
85 CustomData_MeshMasks *r_mask);
86
94Scene *DEG_get_evaluated_scene(const Depsgraph *graph);
95
100ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph);
101
103ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id);
104const ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, const ID *id);
105
106template<typename T> T *DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
107{
108 static_assert(dna::is_ID_v<T>);
109 return reinterpret_cast<T *>(DEG_get_evaluated_id(depsgraph, reinterpret_cast<ID *>(id)));
110}
111
112template<typename T> const T *DEG_get_evaluated(const Depsgraph *depsgraph, const T *id)
113{
114 static_assert(dna::is_ID_v<T>);
115 return reinterpret_cast<const T *>(
116 DEG_get_evaluated_id(depsgraph, reinterpret_cast<const ID *>(id)));
117}
118
120void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph,
121 PointerRNA *ptr,
122 PointerRNA *r_ptr_eval);
123
125ID *DEG_get_original_id(ID *id);
126const ID *DEG_get_original_id(const ID *id);
127
128template<typename T> T *DEG_get_original(T *id)
129{
130 static_assert(dna::is_ID_v<T>);
131 return reinterpret_cast<T *>(DEG_get_original_id(reinterpret_cast<ID *>(id)));
132}
133
134template<typename T> const T *DEG_get_original(const T *id)
135{
136 static_assert(dna::is_ID_v<T>);
137 return reinterpret_cast<const T *>(DEG_get_original_id(reinterpret_cast<const ID *>(id)));
138}
139
148Depsgraph *DEG_get_depsgraph_by_id(const ID &id);
149
156bool DEG_is_original_id(const ID *id);
157
158template<typename T> bool DEG_is_original(const T *id)
159{
160 static_assert(dna::is_ID_v<T>);
161 return DEG_is_original_id(reinterpret_cast<const ID *>(id));
162}
163
164/* Opposite of the above (`DEG_is_original_*`).
165 *
166 * If the data-block is not original it must be evaluated, and vice versa. */
167
168bool DEG_is_evaluated_id(const ID *id);
169
170template<typename T> bool DEG_is_evaluated(const T *id)
171{
172 static_assert(dna::is_ID_v<T>);
173 return DEG_is_evaluated_id(reinterpret_cast<const ID *>(id));
174}
175
181bool DEG_is_fully_evaluated(const Depsgraph *depsgraph);
182
187bool DEG_id_is_fully_evaluated(const Depsgraph *depsgraph, const ID *id_eval);
188
199bool DEG_object_geometry_is_evaluated(const Object &object);
200
205bool DEG_object_transform_is_evaluated(const Object &object);
206
211bool DEG_collection_geometry_is_evaluated(const Collection &collection);
212
214
215/* -------------------------------------------------------------------- */
218
227
251
255#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS \
256 blender::DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | blender::DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | \
257 blender::DEG_ITER_OBJECT_FLAG_VISIBLE | blender::DEG_ITER_OBJECT_FLAG_DUPLI
258
261 Depsgraph *graph;
262 int flag;
263
265
268
270
271 /* **** Iteration over dupli-list. *** */
272
273 /* Object which created the dupli-list. */
275 /* List of duplicated objects. */
277 /* Next duplicated object to step into. */
279 /* The dupli_list index of dupli_object_next. */
281 /* Corresponds to current object: current iterator object is evaluated from
282 * this duplicated object. */
284 /* Temporary storage to report fully populated DNA to the render engine or
285 * other users of the iterator. */
288
289 /* **** Iteration over ID nodes **** */
292
293 /* Copy the current/next data and move the DupliList. */
294 void transfer_from(DEGObjectIterData &other);
295};
296
300
301#define DEG_OBJECT_ITER_BEGIN(settings_, instance_) \
302 { \
303 DEGObjectIterData data_ = { \
304 (settings_), \
305 (settings_)->depsgraph, \
306 int((settings_)->flags), \
307 }; \
308\
309 ITER_BEGIN (DEG_iterator_objects_begin, \
310 DEG_iterator_objects_next, \
311 DEG_iterator_objects_end, \
312 &data_, \
313 Object *, \
314 instance_)
315
316#define DEG_OBJECT_ITER_END \
317 ITER_END; \
318 } \
319 ((void)0)
320
322
323/* -------------------------------------------------------------------- */
328
332bool DEG_iterator_object_is_visible(eEvaluationMode eval_mode, const Object *ob);
333
337bool DEG_iterator_dupli_is_visible(const DupliObject *dupli, eEvaluationMode eval_mode);
338
339namespace evil {
348
360[[nodiscard]] bool DEG_iterator_temp_object_from_dupli(const Object *dupli_parent,
361 const DupliObject *dupli,
362 eEvaluationMode eval_mode,
363 bool do_matrix_setup,
364 Object *r_temp_object,
365 bke::ObjectRuntime *r_temp_runtime);
366
371void DEG_iterator_temp_object_free_properties(const DupliObject *dupli, Object *temp_object);
372} // namespace evil
373
375
376/* -------------------------------------------------------------------- */
379
381 Depsgraph *graph;
383
386};
387
391
393
394/* -------------------------------------------------------------------- */
397
400 FunctionRef<void(ID *id, eDepsObjectComponentType component)>;
406 FunctionRef<bool(ID *id, eDepsObjectComponentType component, StringRef component_name)>;
411void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph,
412 const ID *id,
413 DEGForeachIDCallback callback);
414void DEG_foreach_dependent_ID(const Depsgraph *depsgraph,
415 const ID *id,
416 DEGForeachIDCallback callback);
417
422enum {
423 /* Ignore transform solvers which depends on multiple inputs and affects final transform.
424 * Is used for cases like snapping objects which are part of a rigid body simulation:
425 * without this there will be "false-positive" dependencies between transform components of
426 * objects:
427 *
428 * object 1 transform before solver ---> solver ------> object 1 final transform
429 * object 2 transform before solver -----^ \------> object 2 final transform
430 */
432};
433void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph,
434 const ID *id,
435 eDepsObjectComponentType source_component_type,
436 int flags,
448void DEG_foreach_dependent_component(const Depsgraph *depsgraph,
449 const ID *start_id,
450 eDepsObjectComponentType start_component_type,
451 StringRef start_component_name,
453
454void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback);
455
461bool DEG_scene_component_depends_on_time(const Depsgraph &depsgraph,
462 const Scene &scene,
463 const eDepsSceneComponentType component_type);
464
466
467/* -------------------------------------------------------------------- */
470
475std::optional<double> DEG_get_last_evaluation_time(const Depsgraph *depsgraph);
476
478
479} // namespace blender
#define ENUM_OPERATORS(_enum_type)
Object is a sort of wrapper for general info.
Definition scene.h:133
#define T
bool DEG_iterator_temp_object_from_dupli(const Object *dupli_parent, const DupliObject *dupli, eEvaluationMode eval_mode, bool do_matrix_setup, Object *r_temp_object, bke::ObjectRuntime *r_temp_runtime)
void DEG_iterator_temp_object_free_properties(const DupliObject *dupli, Object *temp_object)
BMesh Iterators.
FunctionRef< bool(ID *id, eDepsObjectComponentType component, StringRef component_name)> DEGForeachNamedIDComponentCallback
void DEG_iterator_ids_end(BLI_Iterator *iter)
std::optional< double > DEG_get_last_evaluation_time(const Depsgraph *depsgraph)
ID * DEG_get_original_id(ID *id)
bool DEG_iterator_object_is_visible(eEvaluationMode eval_mode, const Object *ob)
void DEG_foreach_dependent_ID(const Depsgraph *depsgraph, const ID *id, DEGForeachIDCallback callback)
bool DEG_is_fully_evaluated(const Depsgraph *depsgraph)
void DEG_iterator_objects_next(BLI_Iterator *iter)
bool DEG_id_is_fully_evaluated(const Depsgraph *depsgraph, const ID *id_eval)
bool DEG_scene_component_is_user_modified(const Depsgraph *graph, const Scene *scene, eDepsSceneComponentType component_type)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, const ID *id)
void DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *object, CustomData_MeshMasks *r_mask)
bool DEG_id_is_user_modified(const Depsgraph *graph, const ID *id)
void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback)
Depsgraph * DEG_get_depsgraph_by_id(const ID &id)
bool DEG_is_original(const T *id)
unsigned int uint32_t
Definition BKE_text.h:81
bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type)
bool DEG_object_transform_is_evaluated(const Object &object)
ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
bool DEG_id_type_any_updated(const Depsgraph *depsgraph)
Main * DEG_get_bmain(const Depsgraph *graph)
BMesh const char void * data
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void DEG_iterator_ids_next(BLI_Iterator *iter)
@ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY
VectorList< DupliObject > DupliList
ViewLayer * DEG_get_evaluated_view_layer(const Depsgraph *graph)
void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph, const ID *id, DEGForeachIDCallback callback)
void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph, PointerRNA *ptr, PointerRNA *r_ptr_eval)
void DEG_iterator_objects_end(BLI_Iterator *iter)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph, const ID *id, eDepsObjectComponentType source_component_type, int flags, DEGForeachIDComponentCallback callback)
bool DEG_is_evaluated_id(const ID *id)
FunctionRef< void(ID *id, eDepsObjectComponentType component)> DEGForeachIDComponentCallback
bool DEG_iterator_dupli_is_visible(const DupliObject *dupli, eEvaluationMode eval_mode)
T * DEG_get_original(T *id)
@ DEG_FOREACH_COMPONENT_IGNORE_TRANSFORM_SOLVERS
bool DEG_collection_geometry_is_evaluated(const Collection &collection)
void DEG_foreach_dependent_component(const Depsgraph *depsgraph, const ID *start_id, eDepsObjectComponentType start_component_type, StringRef start_component_name, DEGForeachNamedIDComponentCallback callback)
Scene * DEG_get_input_scene(const Depsgraph *graph)
bool DEG_id_type_updated(const Depsgraph *depsgraph, short id_type)
FunctionRef< void(ID *id)> DEGForeachIDCallback
void DEG_iterator_ids_begin(BLI_Iterator *iter, DEGIDIterData *data)
bool DEG_is_original_id(const ID *id)
void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
bool DEG_is_evaluated(const T *id)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
bool DEG_object_geometry_is_evaluated(const Object &object)
float DEG_get_ctime(const Depsgraph *graph)
bool DEG_scene_component_depends_on_time(const Depsgraph &depsgraph, const Scene &scene, const eDepsSceneComponentType component_type)
bke::ObjectRuntime temp_dupli_object_runtime
DEGObjectIterSettings * settings
void transfer_from(DEGObjectIterData &other)
Set< const Object * > * included_objects