diff options
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_translate_instances.cc | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_translate_instances.cc b/source/blender/nodes/geometry/nodes/node_geo_translate_instances.cc index 763f8a3ccc3..91c503ff047 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_translate_instances.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_translate_instances.cc @@ -26,47 +26,47 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field(); b.add_input<decl::Vector>(N_("Translation")).subtype(PROP_TRANSLATION).supports_field(); b.add_input<decl::Bool>(N_("Local Space")).default_value(true).supports_field(); - b.add_output<decl::Geometry>(N_("Instances")) + b.add_output<decl::Geometry>(N_("Instances")); +} - static void - translate_instances(GeoNodeExecParams & params, InstancesComponent & instances_component) - { - GeometryComponentFieldContext field_context{instances_component, ATTR_DOMAIN_INSTANCE}; +static void translate_instances(GeoNodeExecParams ¶ms, InstancesComponent &instances_component) +{ + GeometryComponentFieldContext field_context{instances_component, ATTR_DOMAIN_INSTANCE}; - fn::FieldEvaluator evaluator{field_context, instances_component.instances_amount()}; - evaluator.set_selection(params.extract_input<Field<bool>>("Selection")); - evaluator.add(params.extract_input<Field<float3>>("Translation")); - evaluator.add(params.extract_input<Field<bool>>("Local Space")); - evaluator.evaluate(); + fn::FieldEvaluator evaluator{field_context, instances_component.instances_amount()}; + evaluator.set_selection(params.extract_input<Field<bool>>("Selection")); + evaluator.add(params.extract_input<Field<float3>>("Translation")); + evaluator.add(params.extract_input<Field<bool>>("Local Space")); + evaluator.evaluate(); - const IndexMask selection = evaluator.get_evaluated_selection_as_mask(); - const VArray<float3> &translations = evaluator.get_evaluated<float3>(0); - const VArray<bool> &local_spaces = evaluator.get_evaluated<bool>(1); + const IndexMask selection = evaluator.get_evaluated_selection_as_mask(); + const VArray<float3> &translations = evaluator.get_evaluated<float3>(0); + const VArray<bool> &local_spaces = evaluator.get_evaluated<bool>(1); - MutableSpan<float4x4> instance_transforms = instances_component.instance_transforms(); + MutableSpan<float4x4> instance_transforms = instances_component.instance_transforms(); - threading::parallel_for(selection.index_range(), 1024, [&](IndexRange range) { - for (const int i_selection : range) { - const int i = selection[i_selection]; - if (local_spaces[i]) { - instance_transforms[i] *= float4x4::from_location(translations[i]); - } - else { - add_v3_v3(instance_transforms[i].values[3], translations[i]); - } + threading::parallel_for(selection.index_range(), 1024, [&](IndexRange range) { + for (const int i_selection : range) { + const int i = selection[i_selection]; + if (local_spaces[i]) { + instance_transforms[i] *= float4x4::from_location(translations[i]); + } + else { + add_v3_v3(instance_transforms[i].values[3], translations[i]); } - }); - } - - static void node_geo_exec(GeoNodeExecParams params) - { - GeometrySet geometry_set = params.extract_input<GeometrySet>("Instances"); - if (geometry_set.has_instances()) { - InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); - translate_instances(params, instances); } - params.set_output("Instances", std::move(geometry_set)); + }); +} + +static void node_geo_exec(GeoNodeExecParams params) +{ + GeometrySet geometry_set = params.extract_input<GeometrySet>("Instances"); + if (geometry_set.has_instances()) { + InstancesComponent &instances = geometry_set.get_component_for_write<InstancesComponent>(); + translate_instances(params, instances); } + params.set_output("Instances", std::move(geometry_set)); +} } // namespace blender::nodes::node_geo_translate_instances_cc |