Blender V4.5
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_object_types.hh"
25
26struct BLI_Iterator;
28struct Depsgraph;
29struct DupliObject;
30struct ID;
31struct ListBase;
32struct PointerRNA;
33struct Scene;
34struct ViewLayer;
35struct ViewerPath;
36
37/* -------------------------------------------------------------------- */
40
42Scene *DEG_get_input_scene(const Depsgraph *graph);
43
45ViewLayer *DEG_get_input_view_layer(const Depsgraph *graph);
46
48Main *DEG_get_bmain(const Depsgraph *graph);
49
51eEvaluationMode DEG_get_mode(const Depsgraph *graph);
52
54float DEG_get_ctime(const Depsgraph *graph);
55
57
58/* -------------------------------------------------------------------- */
61
63bool DEG_id_type_updated(const Depsgraph *depsgraph, short id_type);
64bool DEG_id_type_any_updated(const Depsgraph *depsgraph);
65
67bool DEG_id_type_any_exists(const Depsgraph *depsgraph, short id_type);
68
70uint32_t DEG_get_eval_flags_for_id(const Depsgraph *graph, const ID *id);
71
73void DEG_get_customdata_mask_for_object(const Depsgraph *graph,
74 Object *object,
75 CustomData_MeshMasks *r_mask);
76
84Scene *DEG_get_evaluated_scene(const Depsgraph *graph);
85
90ViewLayer *DEG_get_evaluated_view_layer(const Depsgraph *graph);
91
93ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id);
94const ID *DEG_get_evaluated_id(const Depsgraph *depsgraph, const ID *id);
95
96template<typename T> T *DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
97{
98 static_assert(blender::dna::is_ID_v<T>);
99 return reinterpret_cast<T *>(DEG_get_evaluated_id(depsgraph, reinterpret_cast<ID *>(id)));
100}
101
102template<typename T> const T *DEG_get_evaluated(const Depsgraph *depsgraph, const T *id)
103{
104 static_assert(blender::dna::is_ID_v<T>);
105 return reinterpret_cast<const T *>(
106 DEG_get_evaluated_id(depsgraph, reinterpret_cast<const ID *>(id)));
107}
108
110void DEG_get_evaluated_rna_pointer(const Depsgraph *depsgraph,
112 PointerRNA *r_ptr_eval);
113
116const ID *DEG_get_original_id(const ID *id);
117
118template<typename T> T *DEG_get_original(T *id)
119{
120 static_assert(blender::dna::is_ID_v<T>);
121 return reinterpret_cast<T *>(DEG_get_original_id(reinterpret_cast<ID *>(id)));
122}
123
124template<typename T> const T *DEG_get_original(const T *id)
125{
126 static_assert(blender::dna::is_ID_v<T>);
127 return reinterpret_cast<const T *>(DEG_get_original_id(reinterpret_cast<const ID *>(id)));
128}
129
138Depsgraph *DEG_get_depsgraph_by_id(const ID &id);
139
146bool DEG_is_original_id(const ID *id);
147
148template<typename T> bool DEG_is_original(const T *id)
149{
150 static_assert(blender::dna::is_ID_v<T>);
151 return DEG_is_original_id(reinterpret_cast<const ID *>(id));
152}
153
154/* Opposite of the above (`DEG_is_original_*`).
155 *
156 * If the data-block is not original it must be evaluated, and vice versa. */
157
158bool DEG_is_evaluated_id(const ID *id);
159
160template<typename T> bool DEG_is_evaluated(const T *id)
161{
162 static_assert(blender::dna::is_ID_v<T>);
163 return DEG_is_evaluated_id(reinterpret_cast<const ID *>(id));
164}
165
171bool DEG_is_fully_evaluated(const Depsgraph *depsgraph);
172
177bool DEG_id_is_fully_evaluated(const Depsgraph *depsgraph, const ID *id_eval);
178
189bool DEG_object_geometry_is_evaluated(const Object &object);
190
195bool DEG_object_transform_is_evaluated(const Object &object);
196
202
204
205/* -------------------------------------------------------------------- */
208
217
241
245#define DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS \
246 DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET | \
247 DEG_ITER_OBJECT_FLAG_VISIBLE | DEG_ITER_OBJECT_FLAG_DUPLI
248
251 Depsgraph *graph;
252 int flag;
253
255
257
260
262
263 /* **** Iteration over dupli-list. *** */
264
265 /* Object which created the dupli-list. */
267 /* List of duplicated objects. */
269 /* Next duplicated object to step into. */
271 /* Corresponds to current object: current iterator object is evaluated from
272 * this duplicated object. */
274 /* Temporary storage to report fully populated DNA to the render engine or
275 * other users of the iterator. */
278
279 /* **** Iteration over ID nodes **** */
283};
284
288
289#define DEG_OBJECT_ITER_BEGIN(settings_, instance_) \
290 { \
291 DEGObjectIterData data_ = { \
292 (settings_), \
293 (settings_)->depsgraph, \
294 (int)(settings_)->flags, \
295 }; \
296\
297 ITER_BEGIN (DEG_iterator_objects_begin, \
298 DEG_iterator_objects_next, \
299 DEG_iterator_objects_end, \
300 &data_, \
301 Object *, \
302 instance_)
303
304#define DEG_OBJECT_ITER_END \
305 ITER_END; \
306 } \
307 ((void)0)
308
310
311/* -------------------------------------------------------------------- */
314
316 Depsgraph *graph;
318
321};
322
326
328
329/* -------------------------------------------------------------------- */
332
336
341void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph,
342 const ID *id,
343 DEGForeachIDCallback callback);
344void DEG_foreach_dependent_ID(const Depsgraph *depsgraph,
345 const ID *id,
346 DEGForeachIDCallback callback);
347
352enum {
353 /* Ignore transform solvers which depends on multiple inputs and affects final transform.
354 * Is used for cases like snapping objects which are part of a rigid body simulation:
355 * without this there will be "false-positive" dependencies between transform components of
356 * objects:
357 *
358 * object 1 transform before solver ---> solver ------> object 1 final transform
359 * object 2 transform before solver -----^ \------> object 2 final transform
360 */
362};
364 const ID *id,
365 eDepsObjectComponentType source_component_type,
366 int flags,
368
369void DEG_foreach_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback);
370
#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)
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)
void DEG_iterator_objects_next(BLI_Iterator *iter)
bool DEG_id_type_any_updated(const Depsgraph *depsgraph)
@ DEG_FOREACH_COMPONENT_IGNORE_TRANSFORM_SOLVERS
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.
BMesh const char void * data
BPy_StructRNA * depsgraph
#define T
DEGObjectIterSettings * settings
eEvaluationMode eval_mode
DEGObjectIterData & operator=(const 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:404
PointerRNA * ptr
Definition wm_files.cc:4227