diff options
author | Hans Goudey <h.goudey@me.com> | 2022-04-25 21:39:51 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-04-25 21:40:07 +0300 |
commit | f431be224fa58374386a32dba2542ee20d2a2d61 (patch) | |
tree | 7470402341cd9e9b8f5dbb50dc101249bf15c4bb /source/blender/nodes | |
parent | 845e2ed3a282913cd9d37207a313627275acc158 (diff) |
Curves: Cache the number of curves of each type
Remembering the number of curves of every type makes it fast to know
whether processing specific to a single curve type has to be done.
This information was accessed in quite a few places, so this should be
an overall reduction in overhead for the new curves type.
The cache is computed eagerly, in other words every time after changing
the curve types. In order to reduce verbosity I added helper functions
for some common ways to set the types.
Differential Revision: https://developer.blender.org/D14732
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index fababfd027b..121ee015d2d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -173,7 +173,6 @@ static void gather_point_attributes_to_interpolate(const CurveComponent &src_com { const Curves &dst_curves_id = *dst_component.get_for_read(); const bke::CurvesGeometry &dst_curves = bke::CurvesGeometry::wrap(dst_curves_id.geometry); - const std::array<int, CURVE_TYPES_NUM> type_counts = dst_curves.count_curve_types(); VectorSet<AttributeIDRef> ids; VectorSet<AttributeIDRef> ids_no_interpolation; @@ -182,7 +181,7 @@ static void gather_point_attributes_to_interpolate(const CurveComponent &src_com if (meta_data.domain != ATTR_DOMAIN_POINT) { return true; } - if (!interpolate_attribute_to_curves(id, type_counts)) { + if (!interpolate_attribute_to_curves(id, dst_curves.curve_type_counts())) { return true; } if (interpolate_attribute_to_poly_curve(id)) { @@ -318,7 +317,7 @@ static Curves *resample_to_uniform_count(const CurveComponent &src_component, dst_curves.resize(dst_offsets.last(), dst_curves.curves_num()); /* All resampled curves are poly curves. */ - dst_curves.curve_types_for_write().fill_indices(selection, CURVE_TYPE_POLY); + dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY); VArray<bool> curves_cyclic = src_curves.cyclic(); VArray<int8_t> curve_types = src_curves.curve_types(); @@ -464,7 +463,7 @@ static Curves *resample_to_evaluated(const CurveComponent &src_component, CD_DUPLICATE, src_curves.curves_num()); /* All resampled curves are poly curves. */ - dst_curves.curve_types_for_write().fill_indices(selection, CURVE_TYPE_POLY); + dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY); MutableSpan<int> dst_offsets = dst_curves.offsets_for_write(); src_curves.ensure_evaluated_offsets(); |