Skip to content

Commit

Permalink
Rename some members for understanding
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Dec 7, 2023
1 parent bfb75b4 commit e7c7397
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions osu.Framework/Utils/IncrementalBSplineBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ private static float getAbsWindingAt(List<Vector2> path, List<float> cumulativeD
Value = new List<List<Vector2>>()
};

private bool controlPointsPartiallyInvalid;
private bool shouldOptimiseLastSegment;

private bool shouldFinishLastSegment;
private bool finishedDrawing;

private int degree;

Expand Down Expand Up @@ -174,10 +174,10 @@ public IReadOnlyList<List<Vector2>> ControlPoints
get
{
if (!controlPoints.IsValid)
regenerateApproximatedPathControlPoints();
regenerateFullApproximatedPath();

if (controlPointsPartiallyInvalid)
updateApproximatedPathControlPoints();
if (shouldOptimiseLastSegment)
regenerateLastApproximatedSegment();

return controlPoints.Value;
}
Expand Down Expand Up @@ -392,11 +392,11 @@ private void updateLastSegment(List<Vector2> vertices, List<float> distances, Li
res, iterations, 4f, initialControlPoints: lastSegment, learnableMask: learnableMask);
}

private void updateApproximatedPathControlPoints()
private void regenerateLastApproximatedSegment()
{
if (!controlPoints.IsValid)
{
regenerateApproximatedPathControlPoints();
regenerateFullApproximatedPath();
return;
}

Expand Down Expand Up @@ -430,15 +430,15 @@ private void updateApproximatedPathControlPoints()
segments.Add(new List<Vector2>());
}

if (shouldFinishLastSegment)
if (finishedDrawing)
updateLastSegment(vertices, distances, cornerTs, segments, 100, false);
else
updateLastSegment(vertices, distances, cornerTs, segments, 10, true);

controlPointsPartiallyInvalid = false;
shouldOptimiseLastSegment = false;
}

private void regenerateApproximatedPathControlPoints()
private void regenerateFullApproximatedPath()
{
// Approximating a given input path with a BSpline has three stages:
// 1. Fit a dense-ish BSpline (with one control point in FdEpsilon-sized intervals) to the input path.
Expand Down Expand Up @@ -478,7 +478,7 @@ private void regenerateApproximatedPathControlPoints()
segments.Add(cps);
}

controlPointsPartiallyInvalid = false;
shouldOptimiseLastSegment = false;
}

private void redrawApproximatedPath()
Expand All @@ -502,8 +502,8 @@ public void Clear()
controlPoints.Value = new List<List<Vector2>>();
outputCache.Value = new List<Vector2>();

controlPointsPartiallyInvalid = false;
shouldFinishLastSegment = false;
shouldOptimiseLastSegment = false;
finishedDrawing = false;
}

/// <summary>
Expand All @@ -513,7 +513,7 @@ public void Clear()
public void AddLinearPoint(Vector2 v)
{
outputCache.Invalidate();
controlPointsPartiallyInvalid = true;
shouldOptimiseLastSegment = true;

// Implementation detail: we would like to disregard input path detail that is smaller than
// FD_EPSILON * 2 because it can otherwise mess with the winding calculations. However, we
Expand Down Expand Up @@ -551,8 +551,8 @@ public void Finish()
// Do additional optimization steps on the entire last segment.
// This improves results after drawing, so the performance stays fast and control points dont wobble too much while drawing.
outputCache.Invalidate();
controlPointsPartiallyInvalid = true;
shouldFinishLastSegment = true;
shouldOptimiseLastSegment = true;
finishedDrawing = true;
}
}
}

0 comments on commit e7c7397

Please sign in to comment.