diff options
author | Hans Goudey <h.goudey@me.com> | 2022-06-05 17:46:09 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-06-05 17:46:20 +0300 |
commit | c4e11122c537e1928dd423574d3e9a7d59cd152b (patch) | |
tree | d0d608830ec436357880e171b4a48ee59ce8064c /source/blender/functions | |
parent | 72ea37ae5fca88aee03bf9354dd9329121bbe01f (diff) |
Geometry Nodes: Use fields for delete geometry inversion
The separate geometry and delete geometry nodes often invert the
selection so that deleting elements from a geometry can be implemented
as copying the opposite selection of elements. This should make the two
nodes faster in some cases, since the generic versions of selection
creation functions (i.e. from d3a1e9cbb92cca04e) are used instead
of the single threaded code that was used for this node.
The change also makes the deletion/separation code easier to
understand because it doesn't have to pass around the inversion.
Diffstat (limited to 'source/blender/functions')
-rw-r--r-- | source/blender/functions/FN_field.hh | 2 | ||||
-rw-r--r-- | source/blender/functions/intern/field.cc | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/functions/FN_field.hh b/source/blender/functions/FN_field.hh index 46051a58e8b..a8136d06c5f 100644 --- a/source/blender/functions/FN_field.hh +++ b/source/blender/functions/FN_field.hh @@ -476,6 +476,8 @@ template<typename T> T evaluate_constant_field(const Field<T> &field) return value; } +Field<bool> invert_boolean_field(const Field<bool> &field); + GField make_constant_field(const CPPType &type, const void *value); template<typename T> Field<T> make_constant_field(T value) diff --git a/source/blender/functions/intern/field.cc b/source/blender/functions/intern/field.cc index a53da717606..47f6a0f19ca 100644 --- a/source/blender/functions/intern/field.cc +++ b/source/blender/functions/intern/field.cc @@ -518,6 +518,14 @@ GField make_field_constant_if_possible(GField field) return new_field; } +Field<bool> invert_boolean_field(const Field<bool> &field) +{ + static CustomMF_SI_SO<bool, bool> not_fn{ + "Not", [](bool a) { return !a; }, CustomMF_presets::AllSpanOrSingle()}; + auto not_op = std::make_shared<FieldOperation>(FieldOperation(not_fn, {field})); + return Field<bool>(not_op); +} + GField make_constant_field(const CPPType &type, const void *value) { auto constant_node = std::make_shared<FieldConstant>(type, value); |