Blender  V3.3
pipeline_from_ids.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2020 Blender Foundation. All rights reserved. */
3 
4 #include "pipeline_from_ids.h"
5 
6 #include "DNA_layer_types.h"
7 
10 #include "intern/depsgraph.h"
11 
12 namespace blender::deg {
13 
14 namespace {
15 
16 class DepsgraphFromIDsFilter {
17  public:
18  DepsgraphFromIDsFilter(Span<ID *> ids)
19  {
20  ids_.add_multiple(ids);
21  }
22 
23  bool contains(ID *id)
24  {
25  return ids_.contains(id);
26  }
27 
28  protected:
29  Set<ID *> ids_;
30 };
31 
32 class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {
33  public:
34  DepsgraphFromIDsNodeBuilder(Main *bmain,
36  DepsgraphBuilderCache *cache,
37  Span<ID *> ids)
38  : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids)
39  {
40  }
41 
42  bool need_pull_base_into_graph(const Base *base) override
43  {
44  if (!filter_.contains(&base->object->id)) {
45  return false;
46  }
48  }
49 
50  protected:
51  DepsgraphFromIDsFilter filter_;
52 };
53 
54 class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder {
55  public:
56  DepsgraphFromIDsRelationBuilder(Main *bmain,
58  DepsgraphBuilderCache *cache,
59  Span<ID *> ids)
60  : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids)
61  {
62  }
63 
64  bool need_pull_base_into_graph(const Base *base) override
65  {
66  if (!filter_.contains(&base->object->id)) {
67  return false;
68  }
70  }
71 
72  protected:
73  DepsgraphFromIDsFilter filter_;
74 };
75 
76 } // namespace
77 
80 {
81 }
82 
83 unique_ptr<DepsgraphNodeBuilder> FromIDsBuilderPipeline::construct_node_builder()
84 {
85  return std::make_unique<DepsgraphFromIDsNodeBuilder>(bmain_, deg_graph_, &builder_cache_, ids_);
86 }
87 
88 unique_ptr<DepsgraphRelationBuilder> FromIDsBuilderPipeline::construct_relation_builder()
89 {
90  return std::make_unique<DepsgraphFromIDsRelationBuilder>(
92 }
93 
95 {
97  for (ID *id : ids_) {
98  node_builder.build_id(id);
99  }
100 }
101 
103 {
105  for (ID *id : ids_) {
106  relation_builder.build_id(id);
107  }
108 }
109 
110 } // namespace blender::deg
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
virtual bool need_pull_base_into_graph(const Base *base)
Definition: deg_builder.cc:67
virtual void build_view_layer(Scene *scene, ViewLayer *view_layer, eDepsNode_LinkedState_Type linked_state)
virtual void build_view_layer(Scene *scene, ViewLayer *view_layer, eDepsNode_LinkedState_Type linked_state)
virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override
FromIDsBuilderPipeline(::Depsgraph *graph, Span< ID * > ids)
virtual unique_ptr< DepsgraphRelationBuilder > construct_relation_builder() override
virtual unique_ptr< DepsgraphNodeBuilder > construct_node_builder() override
virtual void build_nodes(DepsgraphNodeBuilder &node_builder) override
Depsgraph * graph
bool contains(const void *owner, const blender::bke::AttributeIDRef &attribute_id)
@ DEG_ID_LINKED_DIRECTLY
Definition: deg_node_id.h:29
DepsgraphFromIDsFilter filter_
Set< ID * > ids_
struct Object * object
Definition: DNA_ID.h:368
Definition: BKE_main.h:121