diff options
author | Mattias Fredriksson <Osares> | 2022-11-09 19:50:51 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-11-09 19:54:19 +0300 |
commit | 11f6c65e61a22ea9423962d6165f54ec29e221a8 (patch) | |
tree | 6f924b00d29af30eda3de692240d0149c1ce50b5 /source/blender/blenkernel/intern/curves_utils.cc | |
parent | d01187c9634631b53c932e2a2eed1f2e9e203989 (diff) |
Geometry Nodes: Trim curve node selection input and corrections
Correct trim for cyclical curves mentioned in T101379, splitting the
curves if the start/endpoint is at the 'loop point'.
Correct implementation based on comments in D14481, request was made to
use 'foreach_curve_by_type' to computing the point lookups.
Included corrections from D16066 as it may not be a adopted solution.
Exposed selection input by adding it as input to the node.
Note: This is disabled for 3.4 to avoid making UI changes in Bcon3.
Differential Revision: https://developer.blender.org/D16161
Diffstat (limited to 'source/blender/blenkernel/intern/curves_utils.cc')
-rw-r--r-- | source/blender/blenkernel/intern/curves_utils.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/curves_utils.cc b/source/blender/blenkernel/intern/curves_utils.cc index f5a69a995a3..2b13a7d3c8a 100644 --- a/source/blender/blenkernel/intern/curves_utils.cc +++ b/source/blender/blenkernel/intern/curves_utils.cc @@ -128,6 +128,18 @@ IndexMask indices_for_type(const VArray<int8_t> &types, selection, 4096, r_indices, [&](const int index) { return types_span[index] == type; }); } +void indices_for_each_type(const VArray<int8_t> &types, + const std::array<int, CURVE_TYPES_NUM> &counts, + const IndexMask selection, + std::array<IndexMask, CURVE_TYPES_NUM> &r_type_masks, + std::array<Vector<int64_t>, CURVE_TYPES_NUM> &r_type_indices) +{ + for (const int64_t curve_type : IndexRange(CURVE_TYPES_NUM)) { + r_type_masks[curve_type] = indices_for_type( + types, counts, CurveType(curve_type), selection, r_type_indices[curve_type]); + } +} + void foreach_curve_by_type(const VArray<int8_t> &types, const std::array<int, CURVE_TYPES_NUM> &counts, const IndexMask selection, @@ -150,4 +162,21 @@ void foreach_curve_by_type(const VArray<int8_t> &types, call_if_not_empty(CURVE_TYPE_NURBS, nurbs_fn); } +void foreach_curve_by_type_mask(const std::array<IndexMask, CURVE_TYPES_NUM> &curve_type_mask, + FunctionRef<void(IndexMask)> catmull_rom_fn, + FunctionRef<void(IndexMask)> poly_fn, + FunctionRef<void(IndexMask)> bezier_fn, + FunctionRef<void(IndexMask)> nurbs_fn) +{ + auto call_if_not_empty = [&](const IndexMask curve_type_mask, FunctionRef<void(IndexMask)> fn) { + if (!curve_type_mask.is_empty()) { + fn(curve_type_mask); + } + }; + call_if_not_empty(curve_type_mask[0], catmull_rom_fn); + call_if_not_empty(curve_type_mask[1], poly_fn); + call_if_not_empty(curve_type_mask[2], bezier_fn); + call_if_not_empty(curve_type_mask[3], nurbs_fn); +} + } // namespace blender::bke::curves |