Geometry Node: Index of Nearest #104619

Merged
Jacques Lucke merged 31 commits from mod_moder/blender:index_of_nearest into main 2023-04-22 13:12:03 +02:00
1 changed files with 7 additions and 7 deletions
Showing only changes of commit f1720d2022 - Show all commits

View File

@ -18,7 +18,7 @@ static void node_declare(NodeDeclarationBuilder &b)
b.add_input<decl::Int>(N_("Nearest Group ID")).supports_field().hide_value().default_value(0);
b.add_output<decl::Int>(N_("Index")).field_source().description(N_("Index of nearest element"));
b.add_output<decl::Bool>(N_("Valid")).field_source();
b.add_output<decl::Bool>(N_("Has Neighbor")).field_source();
}
class IndexOfNearestFieldInput final : public bke::GeometryFieldInput {
mod_moder marked this conversation as resolved Outdated

These identifiers/names are missing the translation macro N_

These identifiers/names are missing the translation macro `N_`
@ -28,9 +28,9 @@ class IndexOfNearestFieldInput final : public bke::GeometryFieldInput {
const Field<int> search_group_field_;
public:
IndexOfNearestFieldInput(const Field<float3> positions_field,
const Field<int> group_field,
const Field<int> search_group_field)
IndexOfNearestFieldInput(Field<float3> positions_field,
mod_moder marked this conversation as resolved Outdated

Pass spans by value

Pass spans by value
Field<int> group_field,
Field<int> search_group_field)
: bke::GeometryFieldInput(CPPType::get<int>(), "Nearest to"),
positions_field_(std::move(positions_field)),
group_field_(std::move(group_field)),
@ -107,7 +107,7 @@ class IndexOfNearestFieldInput final : public bke::GeometryFieldInput {
}
protected:
int kdtree_find_neighboard(KDTree_3d *tree, const float3 &position, const int index) const
int kdtree_find_neighboard(KDTree_3d *tree, const float3 &position, const int &index) const
{
mod_moder marked this conversation as resolved Outdated

While forest is used as a technical term for a graph containing multiple trees, I don't think the term should be used for a collection of multiple independent kd trees. Just use kdtrees.

While forest is used as a technical term for a graph containing multiple trees, I don't think the term should be used for a collection of multiple independent kd trees. Just use `kdtrees`.

If i do merge parallel_fors below, i can delete this vector.

If i do merge `parallel_for`s below, i can delete this vector.
return BLI_kdtree_3d_find_nearest_cb_cpp(
tree,
@ -171,14 +171,14 @@ static void node_geo_exec(GeoNodeExecParams params)
params.set_output("Index", Field<int>(clamp_op, 0));
}
if (params.output_is_required("Valid")) {
if (params.output_is_required("Has Neighbor")) {
static auto valid_fn = mf::build::SI1_SO<int, bool>(
"Index Validating",
[](const int index) { return index != -1; },
mf::build::exec_presets::Materialized());
auto valid_op = std::make_shared<FieldOperation>(
FieldOperation(std::move(valid_fn), {std::move(index_of_nearest_field)}));
params.set_output("Valid", Field<bool>(valid_op, 0));
params.set_output("Has Neighbor", Field<bool>(valid_op, 0));
}
}