Blender V5.0
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_function_ref.hh"
14#include "BLI_iterator.h"
15#include "BLI_set.hh"
16#include "BLI_utildefines.h"
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
27struct BLI_Iterator;
29struct Depsgraph;
30struct DupliObject;
31struct ID;
32struct ListBase;
33struct PointerRNA;
34struct Scene;
35struct ViewLayer;
36struct ViewerPath;
37
38/* -------------------------------------------------------------------- */
41
43Scene *DEG_get_input_scene(const Depsgraph *graph);
44
46ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph);
47
49Main *DEG_get_bmain(const Depsgraph *graph);
50
52eEvaluationMode DEG_get_mode(const Depsgraph *graph);
53
55float DEG_get_ctime(const Depsgraph *graph);
56
58
59/* -------------------------------------------------------------------- */
62
64bool DEG_id_type_updated(const Depsgraph *depsgraph, short id_type);
65bool DEG_id_type_any_updated(const Depsgraph *depsgraph);
66
68bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type);
69
71uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, const ID *id);
72
74void DEG_get_customdata_mask_for_object(const Depsgraph *graph,
75 Object *object,
76 CustomData_MeshMasks *r_mask);
77
85Scene *DEG_get_evaluated_scene(const Depsgraph *graph);
86
91ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph);
92
94ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id);
95const ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, const ID *id);
96
97template<typename T> T *DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
98{
99 static_assert(blender::dna::is_ID_v<T>);
100 return reinterpret_cast<T *>(DEG_get_evaluated_id(depsgraph, reinterpret_cast<ID *>(id)));
101}
102
103template<typename T> const T *DEG_get_evaluated(const Depsgraph *depsgraph, const T *id)
104{
105 static_assert(blender::dna::is_ID_v<T>);
106 return reinterpret_cast<const T *>(
107 DEG_get_evaluated_id(depsgraph, reinterpret_cast<const ID *>(id)));
108}
109
111void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph,
113 PointerRNA *r_ptr_eval);
114
117const ID *DEG_get_original_id(const ID *id);
118
119template<typename T> T *DEG_get_original(T *id)
120{
121 static_assert(blender::dna::is_ID_v<T>);
122 return reinterpret_cast<T *>(DEG_get_original_id(reinterpret_cast<ID *>(id)));
123}
124
125template<typename T> const T *DEG_get_original(const T *id)
126{
127 static_assert(blender::dna::is_ID_v<T>);
128 return reinterpret_cast<const T *>(DEG_get_original_id(reinterpret_cast<const ID *>(id)));
129}
130
139Depsgraph *DEG_get_depsgraph_by_id(const ID &id);
140
147bool DEG_is_original_id(const ID *id);
148
149template<typename T> bool DEG_is_original(const T *id)
150{
151 static_assert(blender::dna::is_ID_v<T>);
152 return DEG_is_original_id(reinterpret_cast<const ID *>(id));
153}
154
155/* Opposite of the above (`DEG_is_original_*`).
156 *
157 * If the data-block is not original it must be evaluated, and vice versa. */
158
159bool DEG_is_evaluated_id(const ID *id);
160
161template<typename T> bool DEG_is_evaluated(const T *id)
162{
163 static_assert(blender::dna::is_ID_v<T>);
164 return DEG_is_evaluated_id(reinterpret_cast<const ID *>(id));
165}
166
172bool DEG_is_fully_evaluated(const Depsgraph *depsgraph);
173
178bool DEG_id_is_fully_evaluated(const Depsgraph *depsgraph, const ID *id_eval);
179
190bool DEG_object_geometry_is_evaluated(const Object &object);
191
196bool DEG_object_transform_is_evaluated(const Object &object);
197
203
205
206/* -------------------------------------------------------------------- */
209
218
242
246#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS \
247 DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | \
248 DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI
249
252 Depsgraph *graph;
253 int flag;
254
256
258
261
263
264 /* **** Iteration over dupli-list. *** */
265
266 /* Object which created the dupli-list. */
268 /* List of duplicated objects. */
270 /* Next duplicated object to step into. */
272 /* The dupli_list index of dupli_object_next. */
274 /* Corresponds to current object: current iterator object is evaluated from
275 * this duplicated object. */
277 /* Temporary storage to report fully populated DNA to the render engine or
278 * other users of the iterator. */
281
282 /* **** Iteration over ID nodes **** */
285
286 /* Copy the current/next data and move the DupliList. */
287 void transfer_from(DEGObjectIterData &other);
288};
289
293
294#define DEG_OBJECT_ITER_BEGIN(settings_, instance_) \
295 { \
296 DEGObjectIterData data_ = { \
297 (settings_), \
298 (settings_)->depsgraph, \
299 (int)(settings_)->flags, \
300 }; \
301\
302 ITER_BEGIN (DEG_iterator_objects_begin, \
303 DEG_iterator_objects_next, \
304 DEG_iterator_objects_end, \
305 &data_, \
306 Object *, \
307 instance_)
308
309#define DEG_OBJECT_ITER_END \
310 ITER_END; \
311 } \
312 ((void)0)
313
315
316/* -------------------------------------------------------------------- */
321
325bool DEG_iterator_object_is_visible(eEvaluationMode eval_mode, const Object *ob);
326
330bool DEG_iterator_dupli_is_visible(const DupliObject *dupli, eEvaluationMode eval_mode);
331
332namespace evil {
341
353[[nodiscard]] bool DEG_iterator_temp_object_from_dupli(const Object *dupli_parent,
354 const DupliObject *dupli,
355 eEvaluationMode eval_mode,
356 bool do_matrix_setup,
357 Object *r_temp_object,
358 ObjectRuntimeHandle *r_temp_runtime);
359
364void DEG_iterator_temp_object_free_properties(const DupliObject *dupli, Object *temp_object);
365} // namespace evil
366
368
369/* -------------------------------------------------------------------- */
372
374 Depsgraph *graph;
376
379};
380
384
386
387/* -------------------------------------------------------------------- */
390
394
399void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph,
400 const ID *id,
401 DEGForeachIDCallback callback);
402void DEG_foreach_dependent_ID(const Depsgraph *depsgraph,
403 const ID *id,
404 DEGForeachIDCallback callback);
405
410enum {
411 /* Ignore transform solvers which depends on multiple inputs and affects final transform.
412 * Is used for cases like snapping objects which are part of a rigid body simulation:
413 * without this there will be "false-positive" dependencies between transform components of
414 * objects:
415 *
416 * object 1 transform before solver ---> solver ------> object 1 final transform
417 * object 2 transform before solver -----^ \------> object 2 final transform
418 */
420};
422 const ID *id,
423 eDepsObjectComponentType source_component_type,
424 int flags,
426
427void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback);
428
blender::VectorList< DupliObject > DupliList
#define ENUM_OPERATORS(_type, _max)
eEvaluationMode
eDepsObjectComponentType
float DEG_get_ctime(const Depsgraph *graph)
bool DEG_object_transform_is_evaluated(const Object &object)
uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, const ID *id)
void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback)
bool DEG_id_is_fully_evaluated(const Depsgraph *depsgraph, const ID *id_eval)
bool DEG_is_fully_evaluated(const Depsgraph *depsgraph)
bool DEG_is_evaluated_id(const ID *id)
bool DEG_iterator_dupli_is_visible(const DupliObject *dupli, eEvaluationMode eval_mode)
blender::FunctionRef< void(ID *id, eDepsObjectComponentType component)> DEGForeachIDComponentCallback
bool DEG_is_original(const T *id)
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)
bool DEG_is_evaluated(const T *id)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
bool DEG_is_original_id(const ID *id)
ID * DEG_get_original_id(ID *id)
void DEG_iterator_objects_begin(BLI_Iterator *iter, DEGObjectIterData *data)
void DEG_iterator_objects_end(BLI_Iterator *iter)
void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph, const ID *id, eDepsObjectComponentType source_component_type, int flags, DEGForeachIDComponentCallback callback)
Depsgraph * DEG_get_depsgraph_by_id(const ID &id)
bool DEG_object_geometry_is_evaluated(const Object &object)
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_foreach_dependent_ID(const Depsgraph *depsgraph, const ID *id, DEGForeachIDCallback callback)
Main * DEG_get_bmain(const Depsgraph *graph)
@ DEG_FOREACH_COMPONENT_IGNORE_TRANSFORM_SOLVERS
bool DEG_iterator_object_is_visible(eEvaluationMode eval_mode, const Object *ob)
void DEG_iterator_objects_next(BLI_Iterator *iter)
bool DEG_id_type_any_updated(const Depsgraph *depsgraph)
void DEG_iterator_ids_next(BLI_Iterator *iter)
T * DEG_get_original(T *id)
Scene * DEG_get_input_scene(const Depsgraph *graph)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type)
void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph, PointerRNA *ptr, PointerRNA *r_ptr_eval)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
bool DEG_collection_geometry_is_evaluated(const Collection &collection)
blender::FunctionRef< void(ID *id)> DEGForeachIDCallback
void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph, const ID *id, DEGForeachIDCallback callback)
void DEG_get_customdata_mask_for_object(const Depsgraph *graph, Object *object, CustomData_MeshMasks *r_mask)
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_VISIBLE
@ DEG_ITER_OBJECT_FLAG_DUPLI
@ DEG_ITER_OBJECT_FLAG_LINKED_INDIRECTLY
@ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET
Object is a sort of wrapper for general info.
struct ObjectRuntimeHandle ObjectRuntimeHandle
BMesh const char void * data
BPy_StructRNA * depsgraph
#define T
void DEG_iterator_temp_object_free_properties(const DupliObject *dupli, Object *temp_object)
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, ObjectRuntimeHandle *r_temp_runtime)
DEGObjectIterSettings * settings
eEvaluationMode eval_mode
void transfer_from(DEGObjectIterData &other)
DupliObject * dupli_object_next
DupliObject * dupli_object_current
blender::bke::ObjectRuntime temp_dupli_object_runtime
blender::Set< const Object * > * included_objects
const ViewerPath * viewer_path
Definition DNA_ID.h:414
PointerRNA * ptr
Definition wm_files.cc:4238