diff options
author | Hans Goudey <h.goudey@me.com> | 2021-12-22 23:35:46 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-12-22 23:35:46 +0300 |
commit | 0fd72a98ac1377a385b6558bf34a7cb372677ac1 (patch) | |
tree | 26c8071c95a22e258cbe69442ebc2aa20b7f9642 /source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc | |
parent | b4f978e9011d6c14f73ad871c77b1a325769e7c5 (diff) |
Cleanup: Avoid adding points to splines sequentially
This should be faster because it avoids reallocating the internal
vectors when the size is known beforehand, but it may also help
a potential refactor to a different data structure (see T94193).
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc | 7 |
1 files changed, 5 insertions, 2 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 741dad95362..c11b4cb5cc8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -81,8 +81,11 @@ static SplinePtr resample_spline(const Spline &src, const int count) Spline::copy_base_settings(src, *dst); if (src.evaluated_edges_size() < 1 || count == 1) { - dst->add_point(src.positions().first(), src.radii().first(), src.tilts().first()); - dst->attributes.reallocate(1); + dst->resize(1); + dst->positions().first() = src.positions().first(); + dst->radii().first() = src.radii().first(); + dst->tilts().first() = src.tilts().first(); + src.attributes.foreach_attribute( [&](const AttributeIDRef &attribute_id, const AttributeMetaData &meta_data) { std::optional<GSpan> src_attribute = src.attributes.get_for_read(attribute_id); |