Cleanup: Rename spline interpolation functions

The names were slightly longer than they needed to be clear,
and when they are shorter they tend to fit on one line better.
This commit is contained in:
2021-06-20 22:05:57 -05:00
parent a1c3e45100
commit feb6fd632f
8 changed files with 63 additions and 66 deletions

View File

@@ -49,7 +49,7 @@ using SplinePtr = std::unique_ptr<Spline>;
* evaluation happens in a layer on top of the evaluated points generated by the derived types.
*
* There are a few methods to evaluate a spline:
* 1. #evaluated_positions and #interpolate_to_evaluated_points give data for the initial
* 1. #evaluated_positions and #interpolate_to_evaluated give data for the initial
* evaluated points, depending on the resolution.
* 2. #lookup_evaluated_factor and #lookup_evaluated_factor are meant for one-off lookups
* along the length of a curve.
@@ -171,23 +171,23 @@ class Spline {
blender::Array<float> sample_uniform_index_factors(const int samples_size) const;
LookupResult lookup_data_from_index_factor(const float index_factor) const;
void sample_based_on_index_factors(const blender::fn::GVArray &src,
blender::Span<float> index_factors,
blender::fn::GMutableSpan dst) const;
void sample_with_index_factors(const blender::fn::GVArray &src,
blender::Span<float> index_factors,
blender::fn::GMutableSpan dst) const;
template<typename T>
void sample_based_on_index_factors(const blender::VArray<T> &src,
blender::Span<float> index_factors,
blender::MutableSpan<T> dst) const
void sample_with_index_factors(const blender::VArray<T> &src,
blender::Span<float> index_factors,
blender::MutableSpan<T> dst) const
{
this->sample_based_on_index_factors(
this->sample_with_index_factors(
blender::fn::GVArray_For_VArray(src), index_factors, blender::fn::GMutableSpan(dst));
}
template<typename T>
void sample_based_on_index_factors(blender::Span<T> src,
blender::Span<float> index_factors,
blender::MutableSpan<T> dst) const
void sample_with_index_factors(blender::Span<T> src,
blender::Span<float> index_factors,
blender::MutableSpan<T> dst) const
{
this->sample_based_on_index_factors(blender::VArray_For_Span(src), index_factors, dst);
this->sample_with_index_factors(blender::VArray_For_Span(src), index_factors, dst);
}
/**
@@ -195,14 +195,13 @@ class Spline {
* evaluated points. For poly splines, the lifetime of the returned virtual array must not
* exceed the lifetime of the input data.
*/
virtual blender::fn::GVArrayPtr interpolate_to_evaluated_points(
virtual blender::fn::GVArrayPtr interpolate_to_evaluated(
const blender::fn::GVArray &source_data) const = 0;
blender::fn::GVArrayPtr interpolate_to_evaluated_points(blender::fn::GSpan data) const;
blender::fn::GVArrayPtr interpolate_to_evaluated(blender::fn::GSpan data) const;
template<typename T>
blender::fn::GVArray_Typed<T> interpolate_to_evaluated_points(blender::Span<T> data) const
blender::fn::GVArray_Typed<T> interpolate_to_evaluated(blender::Span<T> data) const
{
return blender::fn::GVArray_Typed<T>(
this->interpolate_to_evaluated_points(blender::fn::GSpan(data)));
return blender::fn::GVArray_Typed<T>(this->interpolate_to_evaluated(blender::fn::GSpan(data)));
}
protected:
@@ -333,7 +332,7 @@ class BezierSpline final : public Spline {
};
InterpolationData interpolation_data_from_index_factor(const float index_factor) const;
virtual blender::fn::GVArrayPtr interpolate_to_evaluated_points(
virtual blender::fn::GVArrayPtr interpolate_to_evaluated(
const blender::fn::GVArray &source_data) const override;
void evaluate_segment(const int index,
@@ -456,7 +455,7 @@ class NURBSpline final : public Spline {
blender::Span<blender::float3> evaluated_positions() const final;
blender::fn::GVArrayPtr interpolate_to_evaluated_points(
blender::fn::GVArrayPtr interpolate_to_evaluated(
const blender::fn::GVArray &source_data) const final;
protected:
@@ -506,7 +505,7 @@ class PolySpline final : public Spline {
blender::Span<blender::float3> evaluated_positions() const final;
blender::fn::GVArrayPtr interpolate_to_evaluated_points(
blender::fn::GVArrayPtr interpolate_to_evaluated(
const blender::fn::GVArray &source_data) const final;
protected:

View File

@@ -331,7 +331,7 @@ Span<float3> Spline::evaluated_normals() const
}
/* Rotate the generated normals with the interpolated tilt data. */
GVArray_Typed<float> tilts = this->interpolate_to_evaluated_points(this->tilts());
GVArray_Typed<float> tilts = this->interpolate_to_evaluated(this->tilts());
for (const int i : normals.index_range()) {
normals[i] = rotate_direction_around_axis(normals[i], tangents[i], tilts[i]);
}
@@ -438,9 +438,9 @@ void Spline::bounds_min_max(float3 &min, float3 &max, const bool use_evaluated)
}
}
GVArrayPtr Spline::interpolate_to_evaluated_points(GSpan data) const
GVArrayPtr Spline::interpolate_to_evaluated(GSpan data) const
{
return this->interpolate_to_evaluated_points(GVArray_For_GSpan(data));
return this->interpolate_to_evaluated(GVArray_For_GSpan(data));
}
/**
@@ -448,9 +448,9 @@ GVArrayPtr Spline::interpolate_to_evaluated_points(GSpan data) const
* points) to arbitrary parameters in between the evaluated points. The interpolation is quite
* simple, but this handles the cyclic and end point special cases.
*/
void Spline::sample_based_on_index_factors(const GVArray &src,
Span<float> index_factors,
GMutableSpan dst) const
void Spline::sample_with_index_factors(const GVArray &src,
Span<float> index_factors,
GMutableSpan dst) const
{
BLI_assert(src.size() == this->evaluated_points_size());

View File

@@ -545,9 +545,9 @@ BezierSpline::InterpolationData BezierSpline::interpolation_data_from_index_fact
/* Use a spline argument to avoid adding this to the header. */
template<typename T>
static void interpolate_to_evaluated_points_impl(const BezierSpline &spline,
const blender::VArray<T> &source_data,
MutableSpan<T> result_data)
static void interpolate_to_evaluated_impl(const BezierSpline &spline,
const blender::VArray<T> &source_data,
MutableSpan<T> result_data)
{
Span<float> mappings = spline.evaluated_mappings();
@@ -562,7 +562,7 @@ static void interpolate_to_evaluated_points_impl(const BezierSpline &spline,
}
}
blender::fn::GVArrayPtr BezierSpline::interpolate_to_evaluated_points(
blender::fn::GVArrayPtr BezierSpline::interpolate_to_evaluated(
const blender::fn::GVArray &source_data) const
{
BLI_assert(source_data.size() == this->size());
@@ -581,7 +581,7 @@ blender::fn::GVArrayPtr BezierSpline::interpolate_to_evaluated_points(
using T = decltype(dummy);
if constexpr (!std::is_void_v<blender::attribute_math::DefaultMixer<T>>) {
Array<T> values(eval_size);
interpolate_to_evaluated_points_impl<T>(*this, source_data.typed<T>(), values);
interpolate_to_evaluated_impl<T>(*this, source_data.typed<T>(), values);
new_varray = std::make_unique<blender::fn::GVArray_For_ArrayContainer<Array<T>>>(
std::move(values));
}

View File

@@ -374,9 +374,9 @@ void NURBSpline::calculate_basis_cache() const
}
template<typename T>
void interpolate_to_evaluated_points_impl(Span<NURBSpline::BasisCache> weights,
const blender::VArray<T> &source_data,
MutableSpan<T> result_data)
void interpolate_to_evaluated_impl(Span<NURBSpline::BasisCache> weights,
const blender::VArray<T> &source_data,
MutableSpan<T> result_data)
{
const int points_len = source_data.size();
BLI_assert(result_data.size() == weights.size());
@@ -395,7 +395,7 @@ void interpolate_to_evaluated_points_impl(Span<NURBSpline::BasisCache> weights,
mixer.finalize();
}
blender::fn::GVArrayPtr NURBSpline::interpolate_to_evaluated_points(
blender::fn::GVArrayPtr NURBSpline::interpolate_to_evaluated(
const blender::fn::GVArray &source_data) const
{
BLI_assert(source_data.size() == this->size());
@@ -412,7 +412,7 @@ blender::fn::GVArrayPtr NURBSpline::interpolate_to_evaluated_points(
using T = decltype(dummy);
if constexpr (!std::is_void_v<blender::attribute_math::DefaultMixer<T>>) {
Array<T> values(this->evaluated_points_size());
interpolate_to_evaluated_points_impl<T>(weights, source_data.typed<T>(), values);
interpolate_to_evaluated_impl<T>(weights, source_data.typed<T>(), values);
new_varray = std::make_unique<blender::fn::GVArray_For_ArrayContainer<Array<T>>>(
std::move(values));
}
@@ -436,7 +436,7 @@ Span<float3> NURBSpline::evaluated_positions() const
evaluated_position_cache_.resize(eval_size);
/* TODO: Avoid copying the evaluated data from the temporary array. */
GVArray_Typed<float3> evaluated = Spline::interpolate_to_evaluated_points(positions_.as_span());
GVArray_Typed<float3> evaluated = Spline::interpolate_to_evaluated(positions_.as_span());
evaluated->materialize(evaluated_position_cache_);
position_cache_dirty_ = false;

View File

@@ -115,7 +115,7 @@ Span<float3> PolySpline::evaluated_positions() const
* the original data. Therefore the lifetime of the returned virtual array must not be longer than
* the source data.
*/
blender::fn::GVArrayPtr PolySpline::interpolate_to_evaluated_points(
blender::fn::GVArrayPtr PolySpline::interpolate_to_evaluated(
const blender::fn::GVArray &source_data) const
{
BLI_assert(source_data.size() == this->size());