From d68b81687cb636015faf809b11edb6eac92b9831 Mon Sep 17 00:00:00 2001 From: illua1 Date: Tue, 7 Feb 2023 22:00:45 +0300 Subject: [PATCH 1/8] / --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- source/blender/blenkernel/intern/node.cc | 8 ++++++-- source/tools | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index 4331c8e76c2..547a54b294f 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 4331c8e76c2f42b9fd903716c333d6cdeaa5cebd +Subproject commit 547a54b294f32ee11bce73273c6f183d8b235f92 diff --git a/release/scripts/addons b/release/scripts/addons index b3f0ffc587d..78b0fc30b6b 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a +Subproject commit 78b0fc30b6b6e610ef897fc7d26e812da348f2ff diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 14ab9273409..65ff08e325d 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 14ab9273409ea0231d08ba6e86fdc73d4e459e99 +Subproject commit 65ff08e325d54a58b47fb3219ec7dbf417f20f18 diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 74351022fd3..cb64ed07e1d 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2342,8 +2342,10 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree, node_dst->typeinfo->copyfunc_api(&ptr, &node_src); } - /* Reset the declaration of the new node. */ - nodeDeclarationEnsure(dst_tree, node_dst); + /* Reset the declaration of the new node in real tree. */ + if (dst_tree != nullptr) { + nodeDeclarationEnsure(dst_tree, node_dst); + } return node_dst; } @@ -3617,6 +3619,8 @@ bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree *ntree, bNode *node) return false; } if (node->typeinfo->declare_dynamic) { + BLI_assert(ntree != nullptr); + BLI_assert(node != nullptr); node->runtime->declaration = new blender::nodes::NodeDeclaration(); blender::nodes::build_node_declaration_dynamic(*ntree, *node, *node->runtime->declaration); return true; diff --git a/source/tools b/source/tools index e133fc08cd3..979bfe2504e 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit e133fc08cd3254bb3d3bd1345028c8486700bca4 +Subproject commit 979bfe2504eb2f446639ab5768aac9b80b1f4864 -- 2.30.2 From 7f48fbb00c0c7efbbb09e7d8ddb3d405925e3215 Mon Sep 17 00:00:00 2001 From: illua1 Date: Tue, 7 Feb 2023 22:47:33 +0300 Subject: [PATCH 2/8] test --- source/blender/blenkernel/BKE_node.h | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index c358f56c0d9..b68ef2c0625 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -142,6 +142,7 @@ typedef void *SocketGetCPPValueFunction; typedef struct CPPTypeHandle CPPTypeHandle; #endif + /** * \brief Defines a socket type. * -- 2.30.2 From afe64c34e8a78eb16848b47a84ec143aacf7465b Mon Sep 17 00:00:00 2001 From: illua1 Date: Tue, 7 Feb 2023 22:51:49 +0300 Subject: [PATCH 3/8] / --- source/blender/blenkernel/BKE_node.h | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index b68ef2c0625..c358f56c0d9 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -142,7 +142,6 @@ typedef void *SocketGetCPPValueFunction; typedef struct CPPTypeHandle CPPTypeHandle; #endif - /** * \brief Defines a socket type. * -- 2.30.2 From 8e3bd0376a443bf8edbdd5039aaade2c31ac96f8 Mon Sep 17 00:00:00 2001 From: illua1 Date: Tue, 7 Feb 2023 22:52:59 +0300 Subject: [PATCH 4/8] / --- .../scripts/startup/bl_ui/space_userpref.py | 30 +++++++++---------- source/blender/blenkernel/intern/node.cc | 8 ++--- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 1ced3d95d03..421e600c58f 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -2267,7 +2267,7 @@ class ExperimentalPanel: bl_region_type = 'WINDOW' bl_context = "experimental" - url_prefix = "https://developer.blender.org/" + url_prefix = "https://projects.blender.org/" @classmethod def poll(cls, _context): @@ -2308,8 +2308,8 @@ class USERPREF_PT_experimental_virtual_reality(ExperimentalPanel, Panel): def draw(self, context): self._draw_items( context, ( - ({"property": "use_virtual_reality_scene_inspection"}, "T71347"), - ({"property": "use_virtual_reality_immersive_drawing"}, "T71348"), + ({"property": "use_virtual_reality_scene_inspection"}, ("blender/blender/issues/71347", "#71347")), + ({"property": "use_virtual_reality_immersive_drawing"}, ("blender/blender/issues/71348", "#71348")), ), ) """ @@ -2321,9 +2321,9 @@ class USERPREF_PT_experimental_new_features(ExperimentalPanel, Panel): def draw(self, context): self._draw_items( context, ( - ({"property": "use_sculpt_tools_tilt"}, "T82877"), - ({"property": "use_extended_asset_browser"}, ("project/view/130/", "Project Page")), - ({"property": "use_override_templates"}, ("T73318", "Milestone 4")), + ({"property": "use_sculpt_tools_tilt"}, ("blender/blender/issues/82877", "#82877")), + ({"property": "use_extended_asset_browser"}, ("blender/blender/projects/10", "Pipeline, Assets & IO Project Page")), + ({"property": "use_override_templates"}, ("blender/blender/issues/73318", "Milestone 4")), ), ) @@ -2334,12 +2334,12 @@ class USERPREF_PT_experimental_prototypes(ExperimentalPanel, Panel): def draw(self, context): self._draw_items( context, ( - ({"property": "use_new_curves_tools"}, "T68981"), - ({"property": "use_new_point_cloud_type"}, "T75717"), - ({"property": "use_sculpt_texture_paint"}, "T96225"), - ({"property": "use_full_frame_compositor"}, "T88150"), - ({"property": "enable_eevee_next"}, "T93220"), - ({"property": "enable_workbench_next"}, "T101619"), + ({"property": "use_new_curves_tools"}, ("blender/blender/issues/68981", "#68981")), + ({"property": "use_new_point_cloud_type"}, ("blender/blender/issues/75717", "#75717")), + ({"property": "use_sculpt_texture_paint"}, ("blender/blender/issues/96225", "#96225")), + ({"property": "use_full_frame_compositor"}, ("blender/blender/issues/88150", "#88150")), + ({"property": "enable_eevee_next"}, ("blender/blender/issues/93220", "#93220")), + ({"property": "enable_workbench_next"}, ("blender/blender/issues/101619", "#101619")), ), ) @@ -2352,7 +2352,7 @@ class USERPREF_PT_experimental_tweaks(ExperimentalPanel, Panel): def draw(self, context): self._draw_items( context, ( - ({"property": "use_select_nearest_on_first_click"}, "T96752"), + ({"property": "use_select_nearest_on_first_click"}, ("blender/blender/issues/96752", "#96752")), ), ) @@ -2371,8 +2371,8 @@ class USERPREF_PT_experimental_debugging(ExperimentalPanel, Panel): def draw(self, context): self._draw_items( context, ( - ({"property": "use_undo_legacy"}, "T60695"), - ({"property": "override_auto_resync"}, "T83811"), + ({"property": "use_undo_legacy"}, ("blender/blender/issues/60695", "#60695")), + ({"property": "override_auto_resync"}, ("blender/blender/issues/83811", "#83811")), ({"property": "use_cycles_debug"}, None), ({"property": "show_asset_debug_info"}, None), ({"property": "use_asset_indexing"}, None), diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index cb64ed07e1d..74351022fd3 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2342,10 +2342,8 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree, node_dst->typeinfo->copyfunc_api(&ptr, &node_src); } - /* Reset the declaration of the new node in real tree. */ - if (dst_tree != nullptr) { - nodeDeclarationEnsure(dst_tree, node_dst); - } + /* Reset the declaration of the new node. */ + nodeDeclarationEnsure(dst_tree, node_dst); return node_dst; } @@ -3619,8 +3617,6 @@ bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree *ntree, bNode *node) return false; } if (node->typeinfo->declare_dynamic) { - BLI_assert(ntree != nullptr); - BLI_assert(node != nullptr); node->runtime->declaration = new blender::nodes::NodeDeclaration(); blender::nodes::build_node_declaration_dynamic(*ntree, *node, *node->runtime->declaration); return true; -- 2.30.2 From d36df2bc14c369f7080e524df8e01fb781ccadee Mon Sep 17 00:00:00 2001 From: illua1 Date: Tue, 7 Feb 2023 22:55:30 +0300 Subject: [PATCH 5/8] / --- source/blender/blenkernel/intern/node.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 74351022fd3..cb64ed07e1d 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2342,8 +2342,10 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree, node_dst->typeinfo->copyfunc_api(&ptr, &node_src); } - /* Reset the declaration of the new node. */ - nodeDeclarationEnsure(dst_tree, node_dst); + /* Reset the declaration of the new node in real tree. */ + if (dst_tree != nullptr) { + nodeDeclarationEnsure(dst_tree, node_dst); + } return node_dst; } @@ -3617,6 +3619,8 @@ bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree *ntree, bNode *node) return false; } if (node->typeinfo->declare_dynamic) { + BLI_assert(ntree != nullptr); + BLI_assert(node != nullptr); node->runtime->declaration = new blender::nodes::NodeDeclaration(); blender::nodes::build_node_declaration_dynamic(*ntree, *node, *node->runtime->declaration); return true; -- 2.30.2 From d198dfefc5b3afc88435ee061368fe20254221f4 Mon Sep 17 00:00:00 2001 From: illua1 Date: Wed, 8 Feb 2023 16:52:52 +0300 Subject: [PATCH 6/8] changes based on comments --- .../nodes/node_geo_accumulate_field.cc | 161 ++++++++++-------- 1 file changed, 91 insertions(+), 70 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index f7a8496868e..5ce67779384 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -2,6 +2,10 @@ #include "BKE_attribute_math.hh" +#include "BLI_array.hh" +#include "BLI_generic_virtual_array.hh" +#include "BLI_virtual_array.hh" + #include "NOD_socket_search_link.hh" #include "node_geometry_util.hh" @@ -192,19 +196,19 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) } } -template class AccumulateFieldInput final : public bke::GeometryFieldInput { +class AccumulateFieldInput final : public bke::GeometryFieldInput { private: - Field input_; + GField input_; Field group_index_; eAttrDomain source_domain_; AccumulationMode accumulation_mode_; public: AccumulateFieldInput(const eAttrDomain source_domain, - Field input, + GField input, Field group_index, AccumulationMode accumulation_mode) - : bke::GeometryFieldInput(CPPType::get(), "Accumulation"), + : bke::GeometryFieldInput(input.cpp_type(), "Accumulation"), input_(input), group_index_(group_index), source_domain_(source_domain), @@ -216,7 +220,7 @@ template class AccumulateFieldInput final : public bke::GeometryFiel const IndexMask /*mask*/) const final { const AttributeAccessor attributes = *context.attributes(); - const int domain_size = attributes.domain_size(source_domain_); + const int64_t domain_size = attributes.domain_size(source_domain_); if (domain_size == 0) { return {}; } @@ -227,46 +231,55 @@ template class AccumulateFieldInput final : public bke::GeometryFiel evaluator.add(input_); evaluator.add(group_index_); evaluator.evaluate(); - const VArray values = evaluator.get_evaluated(0); + const GVArray g_values = evaluator.get_evaluated(0); const VArray group_indices = evaluator.get_evaluated(1); - Array accumulations_out(domain_size); + GVArray g_output; - if (group_indices.is_single()) { - T accumulation = T(); - if (accumulation_mode_ == AccumulationMode::Leading) { - for (const int i : values.index_range()) { - accumulation = values[i] + accumulation; - accumulations_out[i] = accumulation; - } - } - else { - for (const int i : values.index_range()) { - accumulations_out[i] = accumulation; - accumulation = values[i] + accumulation; - } - } - } - else { - Map accumulations; - if (accumulation_mode_ == AccumulationMode::Leading) { - for (const int i : values.index_range()) { - T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); - accumulation_value += values[i]; - accumulations_out[i] = accumulation_value; - } - } - else { - for (const int i : values.index_range()) { - T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); - accumulations_out[i] = accumulation_value; - accumulation_value += values[i]; - } - } - } + attribute_math::convert_to_static_type(g_values.type(), [&](auto dummy) { + using T = decltype(dummy); + if constexpr (is_same_any_v) { + Array outputs(domain_size); + const VArray values = g_values.typed(); - return attributes.adapt_domain( - VArray::ForContainer(std::move(accumulations_out)), source_domain_, context.domain()); + if (group_indices.is_single()) { + T accumulation = T(); + if (accumulation_mode_ == AccumulationMode::Leading) { + for (const int i : values.index_range()) { + accumulation = values[i] + accumulation; + outputs[i] = accumulation; + } + } + else { + for (const int i : values.index_range()) { + outputs[i] = accumulation; + accumulation = values[i] + accumulation; + } + } + } + else { + Map accumulations; + if (accumulation_mode_ == AccumulationMode::Leading) { + for (const int i : values.index_range()) { + T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); + accumulation_value += values[i]; + outputs[i] = accumulation_value; + } + } + else { + for (const int i : values.index_range()) { + T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); + outputs[i] = accumulation_value; + accumulation_value += values[i]; + } + } + } + + g_output = VArray::ForContainer(std::move(outputs)); + } + }); + + return attributes.adapt_domain(std::move(g_output), source_domain_, context.domain()); } uint64_t hash() const override @@ -293,15 +306,15 @@ template class AccumulateFieldInput final : public bke::GeometryFiel } }; -template class TotalFieldInput final : public bke::GeometryFieldInput { +class TotalFieldInput final : public bke::GeometryFieldInput { private: - Field input_; + GField input_; Field group_index_; eAttrDomain source_domain_; public: - TotalFieldInput(const eAttrDomain source_domain, Field input, Field group_index) - : bke::GeometryFieldInput(CPPType::get(), "Total Value"), + TotalFieldInput(const eAttrDomain source_domain, GField input, Field group_index) + : bke::GeometryFieldInput(input.cpp_type(), "Total Value"), input_(input), group_index_(group_index), source_domain_(source_domain) @@ -312,7 +325,7 @@ template class TotalFieldInput final : public bke::GeometryFieldInpu IndexMask /*mask*/) const final { const AttributeAccessor attributes = *context.attributes(); - const int domain_size = attributes.domain_size(source_domain_); + const int64_t domain_size = attributes.domain_size(source_domain_); if (domain_size == 0) { return {}; } @@ -323,29 +336,38 @@ template class TotalFieldInput final : public bke::GeometryFieldInpu evaluator.add(input_); evaluator.add(group_index_); evaluator.evaluate(); - const VArray values = evaluator.get_evaluated(0); + const GVArray g_values = evaluator.get_evaluated(0); const VArray group_indices = evaluator.get_evaluated(1); - if (group_indices.is_single()) { - T accumulation = T(); - for (const int i : values.index_range()) { - accumulation = values[i] + accumulation; + GVArray g_outputs; + + attribute_math::convert_to_static_type(g_values.type(), [&](auto dummy) { + using T = decltype(dummy); + if constexpr (is_same_any_v) { + const VArray values = g_values.typed(); + if (group_indices.is_single()) { + T accumulation = {}; + for (const int i : values.index_range()) { + accumulation = values[i] + accumulation; + } + g_outputs = VArray::ForSingle(accumulation, domain_size); + } + else { + Map accumulations; + for (const int i : values.index_range()) { + T &value = accumulations.lookup_or_add_default(group_indices[i]); + value = value + values[i]; + } + Array outputs(domain_size); + for (const int i : values.index_range()) { + outputs[i] = accumulations.lookup(group_indices[i]); + } + g_outputs = VArray::ForContainer(std::move(outputs)); + } } - return VArray::ForSingle(accumulation, domain_size); - } + }); - Array accumulations_out(domain_size); - Map accumulations; - for (const int i : values.index_range()) { - T &value = accumulations.lookup_or_add_default(group_indices[i]); - value = value + values[i]; - } - for (const int i : values.index_range()) { - accumulations_out[i] = accumulations.lookup(group_indices[i]); - } - - return attributes.adapt_domain( - VArray::ForContainer(std::move(accumulations_out)), source_domain_, context.domain()); + return attributes.adapt_domain(std::move(g_outputs), source_domain_, context.domain()); } uint64_t hash() const override @@ -391,25 +413,24 @@ static void node_geo_exec(GeoNodeExecParams params) Field group_index_field = params.extract_input>("Group Index"); attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); - if constexpr (std::is_same_v || std::is_same_v || - std::is_same_v) { + if constexpr (is_same_any_v) { const std::string suffix = " " + identifier_suffix(); Field input_field = params.extract_input>("Value" + suffix); if (params.output_is_required("Leading" + suffix)) { params.set_output( "Leading" + suffix, - Field{std::make_shared>( + Field{std::make_shared( source_domain, input_field, group_index_field, AccumulationMode::Leading)}); } if (params.output_is_required("Trailing" + suffix)) { params.set_output( "Trailing" + suffix, - Field{std::make_shared>( + Field{std::make_shared( source_domain, input_field, group_index_field, AccumulationMode::Trailing)}); } if (params.output_is_required("Total" + suffix)) { params.set_output("Total" + suffix, - Field{std::make_shared>( + Field{std::make_shared( source_domain, input_field, group_index_field)}); } } -- 2.30.2 From 033b4c871b498ca234290ffbd90dfdd91bae5ac5 Mon Sep 17 00:00:00 2001 From: illua1 Date: Wed, 8 Feb 2023 16:59:57 +0300 Subject: [PATCH 7/8] undo changes in wrong branch --- .../nodes/node_geo_accumulate_field.cc | 157 ++++++++---------- 1 file changed, 68 insertions(+), 89 deletions(-) diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index 5ce67779384..f7a8496868e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -2,10 +2,6 @@ #include "BKE_attribute_math.hh" -#include "BLI_array.hh" -#include "BLI_generic_virtual_array.hh" -#include "BLI_virtual_array.hh" - #include "NOD_socket_search_link.hh" #include "node_geometry_util.hh" @@ -196,19 +192,19 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) } } -class AccumulateFieldInput final : public bke::GeometryFieldInput { +template class AccumulateFieldInput final : public bke::GeometryFieldInput { private: - GField input_; + Field input_; Field group_index_; eAttrDomain source_domain_; AccumulationMode accumulation_mode_; public: AccumulateFieldInput(const eAttrDomain source_domain, - GField input, + Field input, Field group_index, AccumulationMode accumulation_mode) - : bke::GeometryFieldInput(input.cpp_type(), "Accumulation"), + : bke::GeometryFieldInput(CPPType::get(), "Accumulation"), input_(input), group_index_(group_index), source_domain_(source_domain), @@ -220,7 +216,7 @@ class AccumulateFieldInput final : public bke::GeometryFieldInput { const IndexMask /*mask*/) const final { const AttributeAccessor attributes = *context.attributes(); - const int64_t domain_size = attributes.domain_size(source_domain_); + const int domain_size = attributes.domain_size(source_domain_); if (domain_size == 0) { return {}; } @@ -231,55 +227,46 @@ class AccumulateFieldInput final : public bke::GeometryFieldInput { evaluator.add(input_); evaluator.add(group_index_); evaluator.evaluate(); - const GVArray g_values = evaluator.get_evaluated(0); + const VArray values = evaluator.get_evaluated(0); const VArray group_indices = evaluator.get_evaluated(1); - GVArray g_output; + Array accumulations_out(domain_size); - attribute_math::convert_to_static_type(g_values.type(), [&](auto dummy) { - using T = decltype(dummy); - if constexpr (is_same_any_v) { - Array outputs(domain_size); - const VArray values = g_values.typed(); - - if (group_indices.is_single()) { - T accumulation = T(); - if (accumulation_mode_ == AccumulationMode::Leading) { - for (const int i : values.index_range()) { - accumulation = values[i] + accumulation; - outputs[i] = accumulation; - } - } - else { - for (const int i : values.index_range()) { - outputs[i] = accumulation; - accumulation = values[i] + accumulation; - } - } + if (group_indices.is_single()) { + T accumulation = T(); + if (accumulation_mode_ == AccumulationMode::Leading) { + for (const int i : values.index_range()) { + accumulation = values[i] + accumulation; + accumulations_out[i] = accumulation; } - else { - Map accumulations; - if (accumulation_mode_ == AccumulationMode::Leading) { - for (const int i : values.index_range()) { - T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); - accumulation_value += values[i]; - outputs[i] = accumulation_value; - } - } - else { - for (const int i : values.index_range()) { - T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); - outputs[i] = accumulation_value; - accumulation_value += values[i]; - } - } - } - - g_output = VArray::ForContainer(std::move(outputs)); } - }); + else { + for (const int i : values.index_range()) { + accumulations_out[i] = accumulation; + accumulation = values[i] + accumulation; + } + } + } + else { + Map accumulations; + if (accumulation_mode_ == AccumulationMode::Leading) { + for (const int i : values.index_range()) { + T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); + accumulation_value += values[i]; + accumulations_out[i] = accumulation_value; + } + } + else { + for (const int i : values.index_range()) { + T &accumulation_value = accumulations.lookup_or_add_default(group_indices[i]); + accumulations_out[i] = accumulation_value; + accumulation_value += values[i]; + } + } + } - return attributes.adapt_domain(std::move(g_output), source_domain_, context.domain()); + return attributes.adapt_domain( + VArray::ForContainer(std::move(accumulations_out)), source_domain_, context.domain()); } uint64_t hash() const override @@ -306,15 +293,15 @@ class AccumulateFieldInput final : public bke::GeometryFieldInput { } }; -class TotalFieldInput final : public bke::GeometryFieldInput { +template class TotalFieldInput final : public bke::GeometryFieldInput { private: - GField input_; + Field input_; Field group_index_; eAttrDomain source_domain_; public: - TotalFieldInput(const eAttrDomain source_domain, GField input, Field group_index) - : bke::GeometryFieldInput(input.cpp_type(), "Total Value"), + TotalFieldInput(const eAttrDomain source_domain, Field input, Field group_index) + : bke::GeometryFieldInput(CPPType::get(), "Total Value"), input_(input), group_index_(group_index), source_domain_(source_domain) @@ -325,7 +312,7 @@ class TotalFieldInput final : public bke::GeometryFieldInput { IndexMask /*mask*/) const final { const AttributeAccessor attributes = *context.attributes(); - const int64_t domain_size = attributes.domain_size(source_domain_); + const int domain_size = attributes.domain_size(source_domain_); if (domain_size == 0) { return {}; } @@ -336,38 +323,29 @@ class TotalFieldInput final : public bke::GeometryFieldInput { evaluator.add(input_); evaluator.add(group_index_); evaluator.evaluate(); - const GVArray g_values = evaluator.get_evaluated(0); + const VArray values = evaluator.get_evaluated(0); const VArray group_indices = evaluator.get_evaluated(1); - GVArray g_outputs; - - attribute_math::convert_to_static_type(g_values.type(), [&](auto dummy) { - using T = decltype(dummy); - if constexpr (is_same_any_v) { - const VArray values = g_values.typed(); - if (group_indices.is_single()) { - T accumulation = {}; - for (const int i : values.index_range()) { - accumulation = values[i] + accumulation; - } - g_outputs = VArray::ForSingle(accumulation, domain_size); - } - else { - Map accumulations; - for (const int i : values.index_range()) { - T &value = accumulations.lookup_or_add_default(group_indices[i]); - value = value + values[i]; - } - Array outputs(domain_size); - for (const int i : values.index_range()) { - outputs[i] = accumulations.lookup(group_indices[i]); - } - g_outputs = VArray::ForContainer(std::move(outputs)); - } + if (group_indices.is_single()) { + T accumulation = T(); + for (const int i : values.index_range()) { + accumulation = values[i] + accumulation; } - }); + return VArray::ForSingle(accumulation, domain_size); + } - return attributes.adapt_domain(std::move(g_outputs), source_domain_, context.domain()); + Array accumulations_out(domain_size); + Map accumulations; + for (const int i : values.index_range()) { + T &value = accumulations.lookup_or_add_default(group_indices[i]); + value = value + values[i]; + } + for (const int i : values.index_range()) { + accumulations_out[i] = accumulations.lookup(group_indices[i]); + } + + return attributes.adapt_domain( + VArray::ForContainer(std::move(accumulations_out)), source_domain_, context.domain()); } uint64_t hash() const override @@ -413,24 +391,25 @@ static void node_geo_exec(GeoNodeExecParams params) Field group_index_field = params.extract_input>("Group Index"); attribute_math::convert_to_static_type(data_type, [&](auto dummy) { using T = decltype(dummy); - if constexpr (is_same_any_v) { + if constexpr (std::is_same_v || std::is_same_v || + std::is_same_v) { const std::string suffix = " " + identifier_suffix(); Field input_field = params.extract_input>("Value" + suffix); if (params.output_is_required("Leading" + suffix)) { params.set_output( "Leading" + suffix, - Field{std::make_shared( + Field{std::make_shared>( source_domain, input_field, group_index_field, AccumulationMode::Leading)}); } if (params.output_is_required("Trailing" + suffix)) { params.set_output( "Trailing" + suffix, - Field{std::make_shared( + Field{std::make_shared>( source_domain, input_field, group_index_field, AccumulationMode::Trailing)}); } if (params.output_is_required("Total" + suffix)) { params.set_output("Total" + suffix, - Field{std::make_shared( + Field{std::make_shared>( source_domain, input_field, group_index_field)}); } } -- 2.30.2 From 89a778846da010f039f7e4f322ff6b31c3881e88 Mon Sep 17 00:00:00 2001 From: illua1 Date: Thu, 9 Feb 2023 19:59:53 +0300 Subject: [PATCH 8/8] delete unrelated changes --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- source/tools | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index 547a54b294f..4331c8e76c2 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 547a54b294f32ee11bce73273c6f183d8b235f92 +Subproject commit 4331c8e76c2f42b9fd903716c333d6cdeaa5cebd diff --git a/release/scripts/addons b/release/scripts/addons index 78b0fc30b6b..b3f0ffc587d 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 78b0fc30b6b6e610ef897fc7d26e812da348f2ff +Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 65ff08e325d..14ab9273409 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 65ff08e325d54a58b47fb3219ec7dbf417f20f18 +Subproject commit 14ab9273409ea0231d08ba6e86fdc73d4e459e99 diff --git a/source/tools b/source/tools index 6a627cf37f0..e133fc08cd3 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 6a627cf37f040f27175c430fb6c1a89cb4278297 +Subproject commit e133fc08cd3254bb3d3bd1345028c8486700bca4 -- 2.30.2