Fix: nurbs basis cache not computed before it is used

This commit is contained in:
Jacques Lucke 2022-08-19 16:24:24 +02:00
parent 188f7585a1
commit 1608406600
3 changed files with 10 additions and 2 deletions

View File

@ -338,12 +338,14 @@ class CurvesGeometry : public ::CurvesGeometry {
/** Calculates the data described by #evaluated_lengths_for_curve if necessary. */
void ensure_evaluated_lengths() const;
void ensure_can_interpolate_to_evaluated() const;
/**
* Evaluate a generic data to the standard evaluated points of a specific curve,
* defined by the resolution attribute or other factors, depending on the curve type.
*
* \warning This function expects offsets to the evaluated points for each curve to be
* calculated. That can be ensured with #ensure_evaluated_offsets.
* calculated. That can be ensured with #ensure_can_interpolate_to_evaluated.
*/
void interpolate_to_evaluated(int curve_index, GSpan src, GMutableSpan dst) const;
/**

View File

@ -938,6 +938,12 @@ void CurvesGeometry::ensure_evaluated_lengths() const
this->runtime->length_cache_dirty = false;
}
void CurvesGeometry::ensure_can_interpolate_to_evaluated() const
{
this->ensure_evaluated_offsets();
this->ensure_nurbs_basis_cache();
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -368,7 +368,7 @@ Curves *resample_to_evaluated(const CurveComponent &src_component,
dst_curves.fill_curve_types(selection, CURVE_TYPE_POLY);
MutableSpan<int> dst_offsets = dst_curves.offsets_for_write();
src_curves.ensure_evaluated_offsets();
src_curves.ensure_can_interpolate_to_evaluated();
threading::parallel_for(selection.index_range(), 4096, [&](IndexRange range) {
for (const int i : selection.slice(range)) {
dst_offsets[i] = src_curves.evaluated_points_for_curve(i).size();