Blender V5.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
8
9#include "pipeline_from_ids.h"
10
11#include "DNA_layer_types.h"
12
15#include "intern/depsgraph.hh"
16
17namespace blender::deg {
18
19namespace {
20
21class DepsgraphFromIDsFilter {
22 public:
23 DepsgraphFromIDsFilter(Span<ID *> ids)
24 {
25 ids_.add_multiple(ids);
26 }
27
28 bool contains(ID *id)
29 {
30 return ids_.contains(id);
31 }
32
33 protected:
34 Set<ID *> ids_;
35};
36
37class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder {
38 public:
39 DepsgraphFromIDsNodeBuilder(Main *bmain,
40 Depsgraph *graph,
41 DepsgraphBuilderCache *cache,
42 Span<ID *> ids)
43 : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids)
44 {
45 }
46
47 bool need_pull_base_into_graph(const Base *base) override
48 {
49 if (!filter_.contains(&base->object->id)) {
50 return false;
51 }
53 }
54
55 protected:
56 DepsgraphFromIDsFilter filter_;
57};
58
59class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder {
60 public:
61 DepsgraphFromIDsRelationBuilder(Main *bmain,
62 Depsgraph *graph,
63 DepsgraphBuilderCache *cache,
64 Span<ID *> ids)
65 : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids)
66 {
67 }
68
69 bool need_pull_base_into_graph(const Base *base) override
70 {
71 if (!filter_.contains(&base->object->id)) {
72 return false;
73 }
75 }
76
77 protected:
78 DepsgraphFromIDsFilter filter_;
79};
80
81} // namespace
82
84 : AbstractBuilderPipeline(graph), ids_(ids)
85{
86}
87
88std::unique_ptr<DepsgraphNodeBuilder> FromIDsBuilderPipeline::construct_node_builder()
89{
90 return std::make_unique<DepsgraphFromIDsNodeBuilder>(bmain_, deg_graph_, &builder_cache_, ids_);
91}
92
93std::unique_ptr<DepsgraphRelationBuilder> FromIDsBuilderPipeline::construct_relation_builder()
94{
95 return std::make_unique<DepsgraphFromIDsRelationBuilder>(
97}
98
100{
102 for (ID *id : ids_) {
103 node_builder.build_id(id, true);
104 }
105}
106
108{
110 for (ID *id : ids_) {
111 relation_builder.build_id(id);
112 }
113}
114
115} // 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)
void build_relations(DepsgraphRelationBuilder &relation_builder) override
std::unique_ptr< DepsgraphRelationBuilder > construct_relation_builder() override
FromIDsBuilderPipeline(blender::Depsgraph *graph, Span< ID * > ids)
std::unique_ptr< DepsgraphNodeBuilder > construct_node_builder() override
void build_nodes(DepsgraphNodeBuilder &node_builder) override
bool contains(const VArray< bool > &varray, const IndexMask &indices_to_check, bool value)