diff --git a/source/blender/blenkernel/BKE_curves.hh b/source/blender/blenkernel/BKE_curves.hh index c125c347071..bf2d50f63be 100644 --- a/source/blender/blenkernel/BKE_curves.hh +++ b/source/blender/blenkernel/BKE_curves.hh @@ -181,11 +181,18 @@ class CurvesGeometry : public ::CurvesGeometry { /** Update the cached count of curves of each type, necessary after #curve_types_for_write. */ void update_curve_types(); - bool has_curve_with_type(const CurveType type) const; + bool has_curve_with_type(CurveType type) const; /** Return true if all of the curves have the provided type. */ bool is_single_type(CurveType type) const; /** Return the number of curves with each type. */ const std::array &curve_type_counts() const; + /** + * All of the curve indices for curves with a specific type. + */ + IndexMask indices_for_curve_type(CurveType type, Vector &r_indices) const; + IndexMask indices_for_curve_type(CurveType type, + IndexMask selection, + Vector &r_indices) const; Span positions() const; MutableSpan positions_for_write(); @@ -283,11 +290,6 @@ class CurvesGeometry : public ::CurvesGeometry { bool bounds_min_max(float3 &min, float3 &max) const; private: - /** - * All of the curve indices for curves with a specific type. - */ - IndexMask indices_for_curve_type(CurveType type, Vector &r_indices) const; - /* -------------------------------------------------------------------- * Evaluation. */ diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc index 36ea7a3888f..e7337d5c012 100644 --- a/source/blender/blenkernel/intern/curves_geometry.cc +++ b/source/blender/blenkernel/intern/curves_geometry.cc @@ -531,19 +531,19 @@ Span CurvesGeometry::evaluated_offsets() const IndexMask CurvesGeometry::indices_for_curve_type(const CurveType type, Vector &r_indices) const { + return this->indices_for_curve_type(type, this->curves_range(), r_indices); +} - VArray types = this->curve_types(); - if (types.is_single()) { - if (types.get_internal_single() == type) { - return IndexMask(types.size()); - } - return {}; +IndexMask CurvesGeometry::indices_for_curve_type(const CurveType type, + const IndexMask selection, + Vector &r_indices) const +{ + if (this->curve_type_counts()[type] == this->curves_num()) { + return selection; } - Span types_span = types.get_internal_span(); + Span types_span = this->curve_types().get_internal_span(); return index_mask_ops::find_indices_based_on_predicate( - IndexMask(types.size()), 1024, r_indices, [&](const int index) { - return types_span[index] == type; - }); + selection, 1024, r_indices, [&](const int index) { return types_span[index] == type; }); } void CurvesGeometry::ensure_nurbs_basis_cache() const @@ -1196,6 +1196,8 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves, } }); + new_curves.update_curve_types(); + return new_curves; }