Fix build error in tests binary after previous commit
Also remove an unused include and add a comment, const, use the math namespace.
This commit is contained in:
parent
63be57307e
commit
4ba6bac2f1
|
@ -9,7 +9,6 @@
|
|||
#include "BLI_math_base.hh"
|
||||
#include "BLI_math_color.hh"
|
||||
#include "BLI_math_vector.hh"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
namespace blender::length_parameterize {
|
||||
|
||||
|
@ -75,6 +74,7 @@ struct SampleSegmentHint {
|
|||
|
||||
/**
|
||||
* \param accumulated_segment_lengths: Lengths of individual segments added up.
|
||||
* Each value describes the total length at the end of the segment following a point.
|
||||
* \param sample_length: The position to sample at.
|
||||
* \param r_segment_index: Returns the index of the segment that #sample_length is in.
|
||||
* \param r_factor: Returns the position within the segment.
|
||||
|
@ -82,7 +82,7 @@ struct SampleSegmentHint {
|
|||
* \note #sample_length must not be outside of any segment.
|
||||
*/
|
||||
inline void sample_at_length(const Span<float> accumulated_segment_lengths,
|
||||
float sample_length,
|
||||
const float sample_length,
|
||||
int &r_segment_index,
|
||||
float &r_factor,
|
||||
SampleSegmentHint *hint = nullptr)
|
||||
|
@ -117,7 +117,7 @@ inline void sample_at_length(const Span<float> accumulated_segment_lengths,
|
|||
const float segment_start = prev_point_index == 0 ? 0.0f : lengths[prev_point_index - 1];
|
||||
const float segment_end = lengths[prev_point_index];
|
||||
const float segment_length = segment_end - segment_start;
|
||||
const float segment_length_inv = safe_divide(1.0f, segment_length);
|
||||
const float segment_length_inv = math::safe_divide(1.0f, segment_length);
|
||||
const float length_in_segment = sample_length - segment_start;
|
||||
const float factor = length_in_segment * segment_length_inv;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ TEST(length_parameterize, FloatSimple)
|
|||
Array<float> factors(4);
|
||||
sample_uniform(lengths, true, indices, factors);
|
||||
Array<float> results(4);
|
||||
linear_interpolation<float>(values, indices, factors, results);
|
||||
interpolate<float>(values, indices, factors, results);
|
||||
Array<float> expected({
|
||||
0.0f,
|
||||
1.33333f,
|
||||
|
@ -54,7 +54,7 @@ TEST(length_parameterize, Float)
|
|||
Array<float> factors(20);
|
||||
sample_uniform(lengths, true, indices, factors);
|
||||
Array<float> results(20);
|
||||
linear_interpolation<float>(values, indices, factors, results);
|
||||
interpolate<float>(values, indices, factors, results);
|
||||
Array<float> expected({
|
||||
1.0f, 1.47368f, 1.94737f, 2.42105f, 2.89474f, 3.36842f, 3.84211f,
|
||||
4.31579f, 4.78947f, 5.26316f, 5.73684f, 6.21053f, 6.68421f, 7.1579f,
|
||||
|
@ -75,7 +75,7 @@ TEST(length_parameterize, Float2)
|
|||
Array<float> factors(12);
|
||||
sample_uniform(lengths, true, indices, factors);
|
||||
Array<float2> results(12);
|
||||
linear_interpolation<float2>(values, indices, factors, results);
|
||||
interpolate<float2>(values, indices, factors, results);
|
||||
Array<float2> expected({
|
||||
{0.0f, 0.0f},
|
||||
{0.272727f, 0.0f},
|
||||
|
@ -105,7 +105,7 @@ TEST(length_parameterize, Float2Cyclic)
|
|||
Array<float> factors(12);
|
||||
sample_uniform(lengths, false, indices, factors);
|
||||
Array<float2> results(12);
|
||||
linear_interpolation<float2>(values, indices, factors, results);
|
||||
interpolate<float2>(values, indices, factors, results);
|
||||
Array<float2> expected({
|
||||
{0.0f, 0.0f},
|
||||
{0.333333f, 0.0f},
|
||||
|
@ -135,7 +135,7 @@ TEST(length_parameterize, LineMany)
|
|||
Array<float> factors(5007);
|
||||
sample_uniform(lengths, true, indices, factors);
|
||||
Array<float> results(5007);
|
||||
linear_interpolation<float>(values, indices, factors, results);
|
||||
interpolate<float>(values, indices, factors, results);
|
||||
Array<float> expected({
|
||||
1.9962f, 1.9964f, 1.9966f, 1.9968f, 1.997f, 1.9972f, 1.9974f, 1.9976f, 1.9978f, 1.998f,
|
||||
1.9982f, 1.9984f, 1.9986f, 1.9988f, 1.999f, 1.9992f, 1.9994f, 1.9996f, 1.9998f, 2.0f,
|
||||
|
@ -154,7 +154,7 @@ TEST(length_parameterize, CyclicMany)
|
|||
Array<float> factors(5007);
|
||||
sample_uniform(lengths, false, indices, factors);
|
||||
Array<float2> results(5007);
|
||||
linear_interpolation<float2>(values, indices, factors, results);
|
||||
interpolate<float2>(values, indices, factors, results);
|
||||
Array<float2> expected({
|
||||
{0, 0.0159776}, {0, 0.0151787}, {0, 0.0143797}, {0, 0.013581}, {0, 0.0127821},
|
||||
{0, 0.0119832}, {0, 0.0111842}, {0, 0.0103855}, {0, 0.00958657}, {0, 0.00878763},
|
||||
|
@ -178,7 +178,7 @@ TEST(length_parameterize, InterpolateColor)
|
|||
Array<float> factors(10);
|
||||
sample_uniform(lengths, false, indices, factors);
|
||||
Array<ColorGeometry4f> results(10);
|
||||
linear_interpolation<ColorGeometry4f>(colors, indices, factors, results);
|
||||
interpolate<ColorGeometry4f>(colors, indices, factors, results);
|
||||
Array<ColorGeometry4f> expected({
|
||||
{0, 0, 0, 1},
|
||||
{0.4, 0, 0, 1},
|
||||
|
@ -209,7 +209,7 @@ TEST(length_parameterize, ArbitraryFloatSimple)
|
|||
Array<float> factors(4);
|
||||
sample_at_lengths(lengths, sample_lengths, indices, factors);
|
||||
Array<float> results(4);
|
||||
linear_interpolation<float>(values, indices, factors, results);
|
||||
interpolate<float>(values, indices, factors, results);
|
||||
Array<float> expected({
|
||||
0.5f,
|
||||
1.5f,
|
||||
|
@ -232,7 +232,7 @@ TEST(length_parameterize, ArbitraryFloat2)
|
|||
Array<float> factors(12);
|
||||
sample_at_lengths(lengths, sample_lengths, indices, factors);
|
||||
Array<float2> results(12);
|
||||
linear_interpolation<float2>(values, indices, factors, results);
|
||||
interpolate<float2>(values, indices, factors, results);
|
||||
Array<float2> expected({
|
||||
{0.5f, 0.0f},
|
||||
{1.0f, 0.5f},
|
||||
|
|
Loading…
Reference in New Issue