Fix: Failing curves test after recent commit
87e9451d66
missed updating the behavior for Catmull Rom curves.
This commit is contained in:
parent
e74880a659
commit
e26c89cd76
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue