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:
authorHans Goudey <h.goudey@me.com>2022-03-30 07:39:03 +0300
committerHans Goudey <h.goudey@me.com>2022-03-30 07:39:03 +0300
commite26c89cd767ce0f14a52ee112e1124a092744c10 (patch)
tree02447d9a56e543d97487c3783b4fb1e4070cbf18
parente74880a659270c91db721e9490a2fe15df837760 (diff)
Fix: Failing curves test after recent commit
87e9451d660e8288d missed updating the behavior for Catmull Rom curves.
-rw-r--r--source/blender/blenkernel/intern/curve_catmull_rom.cc12
-rw-r--r--source/blender/blenkernel/intern/curves_geometry_test.cc5
2 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/curve_catmull_rom.cc b/source/blender/blenkernel/intern/curve_catmull_rom.cc
index ea3672dd56b..2db183eea3e 100644
--- a/source/blender/blenkernel/intern/curve_catmull_rom.cc
+++ b/source/blender/blenkernel/intern/curve_catmull_rom.cc
@@ -13,7 +13,7 @@ int calculate_evaluated_size(const int points_num, const bool cyclic, const int
{
const int eval_size = resolution * curve_segment_size(points_num, cyclic);
/* If the curve isn't cyclic, one last point is added to the final point. */
- return (cyclic && points_num > 2) ? eval_size : eval_size + 1;
+ return cyclic ? eval_size : eval_size + 1;
}
/* Adapted from Cycles #catmull_rom_basis_eval function. */
@@ -58,8 +58,14 @@ static void interpolate_to_evaluated(const Span<T> src,
return;
}
if (src.size() == 2) {
- evaluate_segment(src.first(), src.first(), src.last(), src.last(), dst);
- dst.last() = src.last();
+ evaluate_segment(src.first(), src.first(), src.last(), src.last(), dst.take_front(resolution));
+ if (cyclic) {
+ evaluate_segment(
+ src.last(), src.last(), src.first(), src.first(), dst.take_back(resolution));
+ }
+ else {
+ dst.last() = src.last();
+ }
return;
}
diff --git a/source/blender/blenkernel/intern/curves_geometry_test.cc b/source/blender/blenkernel/intern/curves_geometry_test.cc
index e4dc9eead60..baa47bb7cf6 100644
--- a/source/blender/blenkernel/intern/curves_geometry_test.cc
+++ b/source/blender/blenkernel/intern/curves_geometry_test.cc
@@ -226,9 +226,8 @@ TEST(curves_geometry, CatmullRomTwoPointCyclic)
curves.offsets().last() = 2;
curves.cyclic().fill(true);
- /* The cyclic value should be ignored when there are only two control points. There should
- * be 12 evaluated points for the single segment and an extra for the last point. */
- EXPECT_EQ(curves.evaluated_points_num(), 13);
+ /* The curve should still be cyclic when there are only two control points. */
+ EXPECT_EQ(curves.evaluated_points_num(), 24);
}
TEST(curves_geometry, BezierPositionEvaluation)