Commit: 7395062480a6b6c623516eaad7e489451e16bcaf Author: Hans Goudey Date: Wed Nov 9 12:13:59 2022 -0600 Branches: master https://developer.blender.org/rB7395062480a6b6c623516eaad7e489451e16bcaf
Cleanup: Miscellaneous cleanups to trim curves node - Fix braces initialization warning - Fixed missing static specifier - Removed two unused functions =================================================================== M source/blender/blenkernel/BKE_curves_utils.hh M source/blender/blenkernel/intern/curves_utils.cc M source/blender/geometry/intern/trim_curves.cc =================================================================== diff --git a/source/blender/blenkernel/BKE_curves_utils.hh b/source/blender/blenkernel/BKE_curves_utils.hh index 670b25bf80f..c8ca24b756a 100644 --- a/source/blender/blenkernel/BKE_curves_utils.hh +++ b/source/blender/blenkernel/BKE_curves_utils.hh @@ -543,12 +543,6 @@ IndexMask indices_for_type(const VArray<int8_t> &types, const IndexMask selection, Vector<int64_t> &r_indices); -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); - void foreach_curve_by_type(const VArray<int8_t> &types, const std::array<int, CURVE_TYPES_NUM> &type_counts, IndexMask selection, @@ -557,15 +551,6 @@ void foreach_curve_by_type(const VArray<int8_t> &types, FunctionRef<void(IndexMask)> bezier_fn, FunctionRef<void(IndexMask)> nurbs_fn); -/** - * Same as 'by_type' but index mask for each curve type is pre-computed. - */ -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); - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/curves_utils.cc b/source/blender/blenkernel/intern/curves_utils.cc index 2b13a7d3c8a..f5a69a995a3 100644 --- a/source/blender/blenkernel/intern/curves_utils.cc +++ b/source/blender/blenkernel/intern/curves_utils.cc @@ -128,18 +128,6 @@ 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, @@ -162,21 +150,4 @@ 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 diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index 0e23a3d53f0..192c47b0d43 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -752,116 +752,114 @@ static float trim_sample_length(const Span<float> accumulated_lengths, * Compute the selection for the given curve type. Tracks indices for splitting the selection if * there are curves reduced to a single point. */ -void compute_curve_trim_parameters(const bke::CurvesGeometry &curves, - const IndexMask selection, - const VArray<float> &starts, - const VArray<float> &ends, - const GeometryNodeCurveSampleMode mode, - MutableSpan<int> dst_curve_size, - MutableSpan<int8_t> dst_curve_types, - MutableSpan<bke::curves::CurvePoint> start_points, - MutableSpan<bke::curves::CurvePoint> end_points, - MutableSpan<bke::curves::IndexRangeCyclic> src_ranges) +static void compute_curve_trim_parameters(const bke::CurvesGeometry &curves, + const IndexMask selection, + const VArray<float> &starts, + const VArray<float> &ends, + const GeometryNodeCurveSampleMode mode, + MutableSpan<int> dst_curve_size, + MutableSpan<int8_t> dst_curve_types, + MutableSpan<bke::curves::CurvePoint> start_points, + MutableSpan<bke::curves::CurvePoint> end_points, + MutableSpan<bke::curves::IndexRangeCyclic> src_ranges) { const VArray<bool> src_cyclic = curves.cyclic(); const VArray<int> resolution = curves.resolution(); const VArray<int8_t> curve_types = curves.curve_types(); /* Compute. */ - threading::parallel_for( - selection.index_range(), 128, [&](const IndexRange selection_range) { - for (const int64_t curve_i : selection.slice(selection_range)) { - CurveType curve_type = CurveType(curve_types[curve_i]); - - int point_count; - if (curve_type == CURVE_TYPE_NURBS) { - dst_curve_types[curve_i] = CURVE_TYPE_POLY; - point_count = curves.evaluated_points_for_curve(curve_i).size(); - } - else { - dst_curve_types[curve_i] = curve_type; - point_count = curves.points_num_for_curve(curve_i); - } - if (point_count == 1) { - /* Single point. */ - dst_curve_size[curve_i] = 1; - src_ranges[curve_i] = bke::curves::IndexRangeCyclic(0, 0, 1, 1); - start_points[curve_i] = {0, 0, 0.0f}; - end_points[curve_i] = {0, 0, 0.0f}; - continue; - } - - const bool cyclic = src_cyclic[curve_i]; - const Span<float> lengths = curves.evaluated_lengths_for_curve(curve_i, cyclic); - BLI_assert(lengths.size() > 0); - - const float start_length = trim_sample_length(lengths, starts[curve_i], mode); - float end_length; - - bool equal_sample_point; - if (cyclic) { - end_length = trim_sample_length(lengths, ends[curve_i], mode); - const float cyclic_start = start_length == lengths.last() ? 0.0f : start_length; - const float cyclic_end = end_length == lengths.last() ? 0.0f : end_length; - equal_sample_point = cyclic_start == cyclic_end; - } - else { - end_length = ends[curve_i] <= starts[curve_i] ? - start_length : - trim_sample_length(lengths, ends[curve_i], mode); - equal_sample_point = start_length == end_length; - } - - start_points[curve_i] = lookup_curve_point(curves, - curve_type, - curve_i, - lengths, - start_length, - cyclic, - resolution[curve_i], - point_count); - if (equal_sample_point) { - end_points[curve_i] = start_points[curve_i]; - if (end_length <= start_length) { - /* Single point. */ - dst_curve_size[curve_i] = 1; - src_ranges[curve_i] = bke::curves::IndexRangeCyclic::get_range_from_size( - start_points[curve_i].index, - start_points[curve_i].is_controlpoint(), /* Only iterate if control point. */ - point_count); - } - else { - /* Split. */ - src_ranges[curve_i] = bke::curves::IndexRangeCyclic::get_range_between_endpoints( - start_points[curve_i], end_points[curve_i], point_count) - .push_loop(); - const int count = 1 + !start_points[curve_i].is_controlpoint() + point_count; - BLI_assert(count > 1); - dst_curve_size[curve_i] = count; - } - } - else { - /* General case. */ - end_points[curve_i] = lookup_curve_point(curves, - curve_type, - curve_i, - lengths, - end_length, - cyclic, - resolution[curve_i], - point_count); - - src_ @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs