[Bf-blender-cvs] [b2184402aea] temp-attribute-processor: support selection
Jacques Lucke
noreply at git.blender.org
Wed Jun 9 12:51:21 CEST 2021
Commit: b2184402aea0be9f552553e12f1dc2afc12cc8c4
Author: Jacques Lucke
Date: Wed Jun 9 10:52:13 2021 +0200
Branches: temp-attribute-processor
https://developer.blender.org/rBb2184402aea0be9f552553e12f1dc2afc12cc8c4
support selection
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
index 88edcbdeb9e..a4c3d000f6a 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_processor.cc
@@ -71,6 +71,7 @@ static void geo_node_attribute_processor_init(bNodeTree *ntree, bNode *node)
node->storage = node_storage;
nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketGeometry", "Geometry", "Geometry");
+ nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketString", "Selection", "Selection");
nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketGeometry", "Geometry", "Geometry");
}
@@ -188,8 +189,9 @@ static void geo_node_attribute_processor_group_update(bNodeTree *ntree, bNode *n
VectorSet<AttributeProcessorInputSettings *> new_inputs_settings;
VectorSet<AttributeProcessorOutputSettings *> new_output_settings;
- /* Keep geometry socket. */
+ /* Keep geometry and selection socket. */
new_inputs.add_new((bNodeSocket *)node->inputs.first);
+ new_inputs.add_new(((bNodeSocket *)node->inputs.first)->next);
LISTBASE_FOREACH (bNodeSocket *, interface_sock, &ngroup_inputs) {
AttributeProcessorInputSettings *input_settings =
@@ -297,8 +299,8 @@ static void geo_node_attribute_processor_update(bNodeTree *UNUSED(ntree), bNode
}
bNodeSocket *next_socket = (bNodeSocket *)node->inputs.first;
- /* Skip geometry socket. */
- next_socket = next_socket->next;
+ /* Skip geometry and selection socket. */
+ next_socket = next_socket->next->next;
LISTBASE_FOREACH (AttributeProcessorInputSettings *, input_settings, &storage->inputs_settings) {
bNodeSocket *value_socket = next_socket;
bNodeSocket *attribute_socket = value_socket->next;
@@ -359,6 +361,23 @@ static void process_attributes_on_component(GeoNodeExecParams &geo_params,
return;
}
+ Vector<int64_t> selection_indices;
+ IndexMask selection;
+ const std::string selection_name = geo_params.get_input<std::string>("Selection");
+ if (selection_name.empty()) {
+ selection = IndexRange(domain_size);
+ }
+ else {
+ GVArray_Typed<bool> selection_attribute = component.attribute_get_for_read<bool>(
+ selection_name, domain, false);
+ for (const int i : IndexRange(domain_size)) {
+ if (selection_attribute[i]) {
+ selection_indices.append(i);
+ }
+ }
+ selection = selection_indices.as_span();
+ }
+
fn::MFParamsBuilder fn_params{network_fn, domain_size};
fn::MFContextBuilder context;
@@ -443,7 +462,7 @@ static void process_attributes_on_component(GeoNodeExecParams &geo_params,
output_attributes.append(std::move(attribute));
}
- network_fn.call(IndexRange(domain_size), fn_params, context);
+ network_fn.call(selection, fn_params, context);
for (std::unique_ptr<OutputAttribute> &output_attribute : output_attributes) {
output_attribute->save();
More information about the Bf-blender-cvs
mailing list