[Bf-blender-cvs] [e26c89cd767] master: Fix: Failing curves test after recent commit

Hans Goudey noreply at git.blender.org
Wed Mar 30 06:39:14 CEST 2022


Commit: e26c89cd767ce0f14a52ee112e1124a092744c10
Author: Hans Goudey
Date:   Tue Mar 29 23:39:03 2022 -0500
Branches: master
https://developer.blender.org/rBe26c89cd767ce0f14a52ee112e1124a092744c10

Fix: Failing curves test after recent commit

87e9451d660e8288d missed updating the behavior for Catmull Rom curves.

===================================================================

M	source/blender/blenkernel/intern/curve_catmull_rom.cc
M	source/blender/blenkernel/intern/curves_geometry_test.cc

===================================================================

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)



More information about the Bf-blender-cvs mailing list