diff options
author | Hans Goudey <h.goudey@me.com> | 2022-05-04 11:27:46 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-05-04 11:27:46 +0300 |
commit | 2d80f814cc249d26b01fe1a306d4f7d1c2ffed90 (patch) | |
tree | ddd4f29e131db32ef249649df7aee5069e7e4453 /source/blender/blenkernel/intern/curve_nurbs.cc | |
parent | 7dc94155f62025248e8c111efa8bf0561b3bb492 (diff) |
Curves: Use copied original data for invalid NURBS curves
NURBS curves can be invalid when the order is less than the number
of points, or in a few other situations. Currently the evaluated data of
an invalid NURBS curve is empty. This is inconvenient because it
requires checking for empty curves when it otherwise wouldn't be
necessary. This patch replaces that fallback with copying the original
data to the evaluated points. This makes conceptual sense too, as if
the curve couldn't be evaluated-- which wouldn't necessarily delete it.
Usually the UI protects against this happening, but it's currently
possible to create an invalid curve with some operations like the
delete geometry node.
Differential Revision: https://developer.blender.org/D14837
Diffstat (limited to 'source/blender/blenkernel/intern/curve_nurbs.cc')
-rw-r--r-- | source/blender/blenkernel/intern/curve_nurbs.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/curve_nurbs.cc b/source/blender/blenkernel/intern/curve_nurbs.cc index 0114c0b45f4..45440358221 100644 --- a/source/blender/blenkernel/intern/curve_nurbs.cc +++ b/source/blender/blenkernel/intern/curve_nurbs.cc @@ -36,7 +36,7 @@ int calculate_evaluated_size(const int points_num, const KnotsMode knots_mode) { if (!check_valid_size_and_order(points_num, order, cyclic, knots_mode)) { - return 0; + return points_num; } return resolution * curve_segment_size(points_num, cyclic); } @@ -232,8 +232,12 @@ void interpolate_to_evaluated(const BasisCache &basis_cache, const GSpan src, GMutableSpan dst) { - BLI_assert(dst.size() == basis_cache.start_indices.size()); + if (basis_cache.invalid) { + dst.copy_from(src); + return; + } + BLI_assert(dst.size() == basis_cache.start_indices.size()); attribute_math::convert_to_static_type(src.type(), [&](auto dummy) { using T = decltype(dummy); if constexpr (!std::is_void_v<attribute_math::DefaultMixer<T>>) { |