Commit: 1177debb01966984415c5d62a59d07ce369376a8
Author: Hans Goudey
Date: Fri Aug 6 17:48:53 2021 -0500
Branches: temp-geometry-nodes-fields-prototype
https://developer.blender.org/rB1177debb01966984415c5d62a59d07ce369376a8
Support selection in the point translate node
===================================================================
M source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
===================================================================
diff --git a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
index 717ac50eafd..e9ec7b110c6 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_point_translate.cc
@@ -31,6 +31,7 @@ static bNodeSocketTemplate geo_node_point_translate_in[] = {
FLT_MAX,
PROP_TRANSLATION,
SOCK_FIELD},
+ {SOCK_BOOLEAN, N_("Selection"), 1, 0, 0, 0, 0, 0, PROP_NONE,
SOCK_HIDE_VALUE | SOCK_FIELD},
{-1, ""},
};
@@ -49,6 +50,15 @@ static void execute_on_component(GeoNodeExecParams params,
GeometryComponent &co
return;
}
+ bke::FieldRef<bool> selection_field =
params.get_input_field<bool>("Selection");
+ bke::FieldInputs selection_field_inputs = selection_field->prepare_inputs();
+ Vector<std::unique_ptr<bke::FieldInputValue>> selection_field_input_values;
+ prepare_field_inputs(
+ selection_field_inputs, component, ATTR_DOMAIN_POINT,
selection_field_input_values);
+ bke::FieldOutput selection_field_output = selection_field->evaluate(
+ IndexRange(component.attribute_domain_size(ATTR_DOMAIN_POINT)),
selection_field_inputs);
+ GVArray_Typed<bool> selection{selection_field_output.varray_ref()};
+
bke::FieldRef<float3> field = params.get_input_field<float3>("Translation");
bke::FieldInputs field_inputs = field->prepare_inputs();
Vector<std::unique_ptr<bke::FieldInputValue>> field_input_values;
@@ -59,7 +69,9 @@ static void execute_on_component(GeoNodeExecParams params,
GeometryComponent &co
GVArray_Typed<float3> translation{field_output.varray_ref()};
for (const int i : IndexRange(translation.size())) {
- position_attribute->set(i, position_attribute->get(i) + translation[i]);
+ if (selection[i]) {
+ position_attribute->set(i, position_attribute->get(i) + translation[i]);
+ }
}
position_attribute.save();
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs