Blender V4.3
pipeline_from_ids.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "pipeline_from_ids.h"
6
7#include "DNA_layer_types.h"
8
11#include "intern/depsgraph.hh"
12
13namespace blender::deg {
14
15namespace {
16
17class DepsgraphFromIDsFilter {
18 public:
19 DepsgraphFromIDsFilter(Span<ID *> ids)
20 {
21 ids_.add_multiple(ids);
22 }
23
24 bool contains(ID *id)
25 {
26 return ids_.contains(id);
27 }
28
29 protected:
30 Set<ID *> ids_;
31};
32
33class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {
34 public:
35 DepsgraphFromIDsNodeBuilder(Main *bmain,
36 Depsgraph *graph,
37 DepsgraphBuilderCache *cache,
38 Span<ID *> ids)
39 : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids)
40 {
41 }
42
43 bool need_pull_base_into_graph(const Base *base) override
44 {
45 if (!filter_.contains(&base->object->id)) {
46 return false;
47 }
49 }
50
51 protected:
52 DepsgraphFromIDsFilter filter_;
53};
54
55class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder {
56 public:
57 DepsgraphFromIDsRelationBuilder(Main *bmain,
58 Depsgraph *graph,
59 DepsgraphBuilderCache *cache,
60 Span<ID *> ids)
61 : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids)
62 {
63 }
64
65 bool need_pull_base_into_graph(const Base *base) override
66 {
67 if (!filter_.contains(&base->object->id)) {
68 return false;
69 }
71 }
72
73 protected:
74 DepsgraphFromIDsFilter filter_;
75};
76
77} // namespace
78
83
84unique_ptr<DepsgraphNodeBuilder> FromIDsBuilderPipeline::construct_node_builder()
85{
86 return std::make_unique<DepsgraphFromIDsNodeBuilder>(bmain_, deg_graph_, &builder_cache_, ids_);
87}
88
89unique_ptr<DepsgraphRelationBuilder> FromIDsBuilderPipeline::construct_relation_builder()
90{
91 return std::make_unique<DepsgraphFromIDsRelationBuilder>(
93}
94
96{
98 for (ID *id : ids_) {
99 node_builder.build_id(id, true);
100 }
101}
102
104{
106 for (ID *id : ids_) {
107 relation_builder.build_id(id);
108 }
109}
110
111} // namespace blender::deg
virtual bool need_pull_base_into_graph(const Base *base)
virtual void build_id(ID *id, bool force_be_visible=false)
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
const Set< ID * > & ids_
DepsgraphFromCollectionIDsFilter filter_
struct Object * object
Definition DNA_ID.h:413