Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-07-02 22:51:45 +0300
committerJacques Lucke <jacques@blender.org>2022-07-02 22:51:58 +0300
commitab444a80a280e125b3e4d002941504d56f340ced (patch)
tree7862c87f35f3d0463d3322ddb68442014ba1afdd /source/blender/blenlib/tests
parent69ee9ca90e36aa6a74317262fccb1e3e2e9210bc (diff)
BLI: refactor length parameterization
This refactor had two main goals: * Simplify the sampling code by using an algorithm with fewer special cases. * Generalize the sampling to support non-sorted samples. The `SampleSegmentHint` optimization was inspired by `ValueAccessor` from OpenVDB and improves performance 2x in my test cases. Differential Revision: https://developer.blender.org/D15348
Diffstat (limited to 'source/blender/blenlib/tests')
-rw-r--r--source/blender/blenlib/tests/BLI_length_parameterize_test.cc20
1 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/blenlib/tests/BLI_length_parameterize_test.cc b/source/blender/blenlib/tests/BLI_length_parameterize_test.cc
index b63e3a0ec86..11f4997f563 100644
--- a/source/blender/blenlib/tests/BLI_length_parameterize_test.cc
+++ b/source/blender/blenlib/tests/BLI_length_parameterize_test.cc
@@ -10,7 +10,7 @@ namespace blender::length_parameterize::tests {
template<typename T> Array<float> calculate_lengths(const Span<T> values, const bool cyclic)
{
- Array<float> lengths(lengths_num(values.size(), cyclic));
+ Array<float> lengths(segments_num(values.size(), cyclic));
accumulate_lengths<T>(values, cyclic, lengths);
return lengths;
}
@@ -30,7 +30,7 @@ TEST(length_parameterize, FloatSimple)
Array<int> indices(4);
Array<float> factors(4);
- create_uniform_samples(lengths, false, indices, factors);
+ sample_uniform(lengths, true, indices, factors);
Array<float> results(4);
linear_interpolation<float>(values, indices, factors, results);
Array<float> expected({
@@ -52,7 +52,7 @@ TEST(length_parameterize, Float)
Array<int> indices(20);
Array<float> factors(20);
- create_uniform_samples(lengths, false, indices, factors);
+ sample_uniform(lengths, true, indices, factors);
Array<float> results(20);
linear_interpolation<float>(values, indices, factors, results);
Array<float> expected({
@@ -73,7 +73,7 @@ TEST(length_parameterize, Float2)
Array<int> indices(12);
Array<float> factors(12);
- create_uniform_samples(lengths, false, indices, factors);
+ sample_uniform(lengths, true, indices, factors);
Array<float2> results(12);
linear_interpolation<float2>(values, indices, factors, results);
Array<float2> expected({
@@ -103,7 +103,7 @@ TEST(length_parameterize, Float2Cyclic)
Array<int> indices(12);
Array<float> factors(12);
- create_uniform_samples(lengths, true, indices, factors);
+ sample_uniform(lengths, false, indices, factors);
Array<float2> results(12);
linear_interpolation<float2>(values, indices, factors, results);
Array<float2> expected({
@@ -133,7 +133,7 @@ TEST(length_parameterize, LineMany)
Array<int> indices(5007);
Array<float> factors(5007);
- create_uniform_samples(lengths, false, indices, factors);
+ sample_uniform(lengths, true, indices, factors);
Array<float> results(5007);
linear_interpolation<float>(values, indices, factors, results);
Array<float> expected({
@@ -152,7 +152,7 @@ TEST(length_parameterize, CyclicMany)
Array<int> indices(5007);
Array<float> factors(5007);
- create_uniform_samples(lengths, true, indices, factors);
+ sample_uniform(lengths, false, indices, factors);
Array<float2> results(5007);
linear_interpolation<float2>(values, indices, factors, results);
Array<float2> expected({
@@ -176,7 +176,7 @@ TEST(length_parameterize, InterpolateColor)
Array<int> indices(10);
Array<float> factors(10);
- create_uniform_samples(lengths, true, indices, factors);
+ sample_uniform(lengths, false, indices, factors);
Array<ColorGeometry4f> results(10);
linear_interpolation<ColorGeometry4f>(colors, indices, factors, results);
Array<ColorGeometry4f> expected({
@@ -207,7 +207,7 @@ TEST(length_parameterize, ArbitraryFloatSimple)
Array<float> sample_lengths{{0.5f, 1.5f, 2.0f, 4.0f}};
Array<int> indices(4);
Array<float> factors(4);
- create_samples_from_sorted_lengths(lengths, sample_lengths, false, indices, factors);
+ sample_at_lengths(lengths, sample_lengths, indices, factors);
Array<float> results(4);
linear_interpolation<float>(values, indices, factors, results);
results.as_span().print_as_lines("results");
@@ -231,7 +231,7 @@ TEST(length_parameterize, ArbitraryFloat2)
{0.5f, 1.5f, 2.0f, 2.0f, 2.1f, 2.5f, 3.5f, 3.6f, 3.8f, 3.85f, 3.90f, 4.0f}};
Array<int> indices(12);
Array<float> factors(12);
- create_samples_from_sorted_lengths(lengths, sample_lengths, true, indices, factors);
+ sample_at_lengths(lengths, sample_lengths, indices, factors);
Array<float2> results(12);
linear_interpolation<float2>(values, indices, factors, results);
results.as_span().print_as_lines("results");