diff options
Diffstat (limited to 'source/blender')
3 files changed, 25 insertions, 28 deletions
diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc index e44f554f197..c42bccaadec 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc +++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc @@ -32,11 +32,9 @@ namespace { class DepsgraphFromIDsFilter { public: - DepsgraphFromIDsFilter(ID **ids, const int num_ids) + DepsgraphFromIDsFilter(Span<ID *> ids) { - for (int i = 0; i < num_ids; ++i) { - ids_.add(ids[i]); - } + ids_.add_multiple(ids); } bool contains(ID *id) @@ -50,9 +48,11 @@ class DepsgraphFromIDsFilter { class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder { public: - DepsgraphFromIDsNodeBuilder( - Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids) - : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids, num_ids) + DepsgraphFromIDsNodeBuilder(Main *bmain, + Depsgraph *graph, + DepsgraphBuilderCache *cache, + Span<ID *> ids) + : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids) { } @@ -81,9 +81,11 @@ class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder { class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder { public: - DepsgraphFromIDsRelationBuilder( - Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids) - : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids, num_ids) + DepsgraphFromIDsRelationBuilder(Main *bmain, + Depsgraph *graph, + DepsgraphBuilderCache *cache, + Span<ID *> ids) + : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids) { } @@ -112,41 +114,36 @@ class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder { } // namespace -FromIDsBuilderPipeline::FromIDsBuilderPipeline(::Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer, - ID **ids, - const int num_ids) - : AbstractBuilderPipeline(graph, bmain, scene, view_layer), ids_(ids), num_ids_(num_ids) +FromIDsBuilderPipeline::FromIDsBuilderPipeline( + ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, Span<ID *> ids) + : AbstractBuilderPipeline(graph, bmain, scene, view_layer), ids_(ids) { } unique_ptr<DepsgraphNodeBuilder> FromIDsBuilderPipeline::construct_node_builder() { - return std::make_unique<DepsgraphFromIDsNodeBuilder>( - bmain_, deg_graph_, &builder_cache_, ids_, num_ids_); + return std::make_unique<DepsgraphFromIDsNodeBuilder>(bmain_, deg_graph_, &builder_cache_, ids_); } unique_ptr<DepsgraphRelationBuilder> FromIDsBuilderPipeline::construct_relation_builder() { return std::make_unique<DepsgraphFromIDsRelationBuilder>( - bmain_, deg_graph_, &builder_cache_, ids_, num_ids_); + bmain_, deg_graph_, &builder_cache_, ids_); } void FromIDsBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder) { node_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY); - for (int i = 0; i < num_ids_; ++i) { - node_builder.build_id(ids_[i]); + for (ID *id : ids_) { + node_builder.build_id(id); } } void FromIDsBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder) { relation_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY); - for (int i = 0; i < num_ids_; ++i) { - relation_builder.build_id(ids_[i]); + for (ID *id : ids_) { + relation_builder.build_id(id); } } diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h index 4a507f2c728..a52a9f6f252 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h +++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h @@ -44,7 +44,7 @@ namespace deg { class FromIDsBuilderPipeline : public AbstractBuilderPipeline { public: FromIDsBuilderPipeline( - ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, ID **ids, int num_ids); + ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, Span<ID *> ids); protected: virtual unique_ptr<DepsgraphNodeBuilder> construct_node_builder() override; @@ -54,8 +54,7 @@ class FromIDsBuilderPipeline : public AbstractBuilderPipeline { virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override; private: - ID **ids_; - const int num_ids_; + Span<ID *> ids_; }; } // namespace deg diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index 230c59bd651..dc49534eb2d 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -251,7 +251,8 @@ void DEG_graph_build_from_ids(Depsgraph *graph, ID **ids, const int num_ids) { - deg::FromIDsBuilderPipeline builder(graph, bmain, scene, view_layer, ids, num_ids); + deg::FromIDsBuilderPipeline builder( + graph, bmain, scene, view_layer, blender::Span(ids, num_ids)); builder.build(); } |