Blender  V3.3
deg_builder.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2016 Blender Foundation. All rights reserved. */
3 
9 
10 #include <cstring>
11 
12 #include "DNA_ID.h"
13 #include "DNA_anim_types.h"
14 #include "DNA_armature_types.h"
15 #include "DNA_layer_types.h"
16 #include "DNA_object_types.h"
17 
18 #include "BLI_stack.h"
19 #include "BLI_utildefines.h"
20 
21 #include "BKE_action.h"
22 
23 #include "RNA_prototypes.h"
24 
27 #include "intern/depsgraph.h"
29 #include "intern/depsgraph_tag.h"
30 #include "intern/depsgraph_type.h"
33 #include "intern/node/deg_node.h"
37 
38 #include "DEG_depsgraph.h"
39 
40 namespace blender::deg {
41 
43 {
44  IDNode *id_node = graph->find_id_node(id_orig);
45  return id_node != nullptr;
46 }
47 
49 {
50  Object *object_orig = base->base_orig->object;
51  IDNode *id_node = graph->find_id_node(&object_orig->id);
52  if (id_node == nullptr) {
53  return false;
54  }
55  return id_node->has_base;
56 }
57 
58 /* -------------------------------------------------------------------- */
63  : bmain_(bmain), graph_(graph), cache_(cache)
64 {
65 }
66 
68 {
69  /* Simple check: enabled bases are always part of dependency graph. */
70  const int base_flag = (graph_->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT :
72  if (base->flag & base_flag) {
73  return true;
74  }
75 
76  /* More involved check: since we don't support dynamic changes in dependency graph topology and
77  * all visible objects are to be part of dependency graph, we pull all objects which has animated
78  * visibility. */
80 }
81 
83 {
84  AnimatedPropertyID property_id;
85  if (graph_->mode == DAG_EVAL_VIEWPORT) {
86  property_id = AnimatedPropertyID(&object->id, &RNA_Object, "hide_viewport");
87  }
88  else if (graph_->mode == DAG_EVAL_RENDER) {
89  property_id = AnimatedPropertyID(&object->id, &RNA_Object, "hide_render");
90  }
91  else {
92  BLI_assert_msg(0, "Unknown evaluation mode.");
93  return false;
94  }
95  return cache_->isPropertyAnimated(&object->id, property_id);
96 }
97 
99 {
100  BLI_assert(object->type == OB_ARMATURE);
101  if (pchan == nullptr || pchan->bone == nullptr) {
102  return false;
103  }
104  /* We don't really care whether segments are higher than 1 due to static user input (as in,
105  * rigger entered value like 3 manually), or due to animation. In either way we need to create
106  * special evaluation. */
107  if (pchan->bone->segments > 1) {
108  return true;
109  }
110  bArmature *armature = static_cast<bArmature *>(object->data);
111  AnimatedPropertyID property_id(&armature->id, &RNA_Bone, pchan->bone, "bbone_segments");
112  /* Check both Object and Armature animation data, because drivers modifying Armature
113  * state could easily be created in the Object AnimData. */
114  return cache_->isPropertyAnimated(&object->id, property_id) ||
115  cache_->isPropertyAnimated(&armature->id, property_id);
116 }
117 
119  const bPoseChannel *pchan)
120 {
121  return check_pchan_has_bbone(object, pchan);
122 }
123 
124 bool DepsgraphBuilder::check_pchan_has_bbone_segments(const Object *object, const char *bone_name)
125 {
126  const bPoseChannel *pchan = BKE_pose_channel_find_name(object->pose, bone_name);
127  return check_pchan_has_bbone_segments(object, pchan);
128 }
129 
132 /* -------------------------------------------------------------------- */
137 {
140 
141  /* Re-tag IDs for update if it was tagged before the relations
142  * update tag. */
143  for (IDNode *id_node : graph->id_nodes) {
144  ID *id_orig = id_node->id_orig;
146  int flag = 0;
147  /* Tag rebuild if special evaluation flags changed. */
150  }
151  /* Tag rebuild if the custom data mask changed. */
153  flag |= ID_RECALC_GEOMETRY;
154  }
156  flag |= ID_RECALC_COPY_ON_WRITE;
157  /* This means ID is being added to the dependency graph first
158  * time, which is similar to "ob-visible-change" */
159  if (GS(id_orig->name) == ID_OB) {
161  }
162  }
163  /* Restore recalc flags from original ID, which could possibly contain recalc flags set by
164  * an operator and then were carried on by the undo system. */
165  flag |= id_orig->recalc;
166  if (flag != 0) {
168  }
169  }
170 }
171 
174 } // namespace blender::deg
Blender kernel action and pose functionality.
struct bPoseChannel * BKE_pose_channel_find_name(const struct bPose *pose, const char *name)
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:46
@ DAG_EVAL_VIEWPORT
Definition: DEG_depsgraph.h:45
ID and Library types, which are fundamental for sdna.
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:771
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ ID_OB
Definition: DNA_ID_enums.h:47
@ BASE_ENABLED_RENDER
@ BASE_ENABLED_VIEWPORT
Object is a sort of wrapper for general info.
@ OB_ARMATURE
bool isPropertyAnimated(const ID *id, Args... args)
DepsgraphBuilderCache * cache_
Definition: deg_builder.h:40
virtual bool check_pchan_has_bbone_segments(const Object *object, const bPoseChannel *pchan)
Definition: deg_builder.cc:118
virtual bool need_pull_base_into_graph(const Base *base)
Definition: deg_builder.cc:67
virtual bool check_pchan_has_bbone(const Object *object, const bPoseChannel *pchan)
Definition: deg_builder.cc:98
virtual bool is_object_visibility_animated(const Object *object)
Definition: deg_builder.cc:82
DepsgraphBuilder(Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache)
Definition: deg_builder.cc:62
Depsgraph * graph
const IDNode * id_node
#define GS(x)
Definition: iris.c:225
void deg_graph_remove_unused_noops(Depsgraph *graph)
bool deg_check_base_in_depsgraph(const Depsgraph *graph, Base *base)
Definition: deg_builder.cc:48
void deg_graph_flush_visibility_flags(Depsgraph *graph)
void deg_graph_build_finalize(Main *bmain, Depsgraph *graph)
Definition: deg_builder.cc:136
bool deg_copy_on_write_is_expanded(const ID *id_cow)
void graph_id_tag_update(Main *bmain, Depsgraph *graph, ID *id, int flag, eUpdateSource update_source)
bool deg_check_id_in_depsgraph(const Depsgraph *graph, ID *id_orig)
Definition: deg_builder.cc:42
@ DEG_UPDATE_SOURCE_RELATIONS
short flag
struct Object * object
struct Base * base_orig
short segments
Definition: DNA_ID.h:368
int recalc
Definition: DNA_ID.h:390
char name[66]
Definition: DNA_ID.h:378
Definition: BKE_main.h:121
struct bPose * pose
struct Bone * bone
IDNode * find_id_node(const ID *id) const
Definition: depsgraph.cc:101
eEvaluationMode mode
Definition: depsgraph.h:130
IDDepsNodes id_nodes
Definition: depsgraph.h:86
DEGCustomDataMeshMasks customdata_masks
Definition: deg_node_id.h:89
DEGCustomDataMeshMasks previous_customdata_masks
Definition: deg_node_id.h:90
void finalize_build(Depsgraph *graph)
Definition: deg_node_id.cc:179
uint32_t previous_eval_flags
Definition: deg_node_id.h:86