Pull out debug iteration steps from DrawCubicBezierCurve

This commit is contained in:
2024-08-05 20:11:12 -04:00
parent 166db43f2e
commit 6286b62998

View File

@@ -507,26 +507,18 @@ namespace JGL {
const J3ML::LinearAlgebra::Vector2 &controlB, int subdivisions, float thickness) {
for (int k = 2; k < subdivisions; ++k)
Vector2 last = controlA;
Vector2 first = controlB;
for (int i = 0; i < subdivisions; ++i)
{
Vector2 last = controlA;
Vector2 first = controlB;
for (int i = 0; i < k; ++i)
{
float alpha = (float)i / (float)k;
Vector2 step = J3ML::Algorithm::Bezier(alpha, controlA, pointA, pointB, controlB);
DrawLine(color, last, step, thickness);
last = step;
}
// Manually draw the last segment of the curve
DrawLine(color, last, first, thickness);
float alpha = (float)i / (float)subdivisions;
Vector2 step = J3ML::Algorithm::Bezier(alpha, controlA, pointA, pointB, controlB);
DrawLine(color, last, step, thickness);
last = step;
}
// Have to manually draw the last segment of the curve.
DrawLine(color, last, first, thickness);
// Display control points
DrawPoint(Colors::Red, controlA, 2.f);