Naming standardisation and enforcing.

This commit is contained in:
Dean Herbert
2017-02-07 16:15:45 +09:00
parent 50bd80cb0c
commit 6b011a50d2
28 changed files with 182 additions and 136 deletions

View File

@ -13,8 +13,8 @@ namespace osu.Game.Modes.Osu.Objects
private Vector2[] subdivisionBuffer1;
private Vector2[] subdivisionBuffer2;
private const float TOLERANCE = 0.25f;
private const float TOLERANCE_SQ = TOLERANCE * TOLERANCE;
private const float tolerance = 0.25f;
private const float tolerance_sq = tolerance * tolerance;
public BezierApproximator(List<Vector2> controlPoints)
{
@ -33,10 +33,10 @@ namespace osu.Game.Modes.Osu.Objects
/// </summary>
/// <param name="controlPoints">The control points to check for flatness.</param>
/// <returns>Whether the control points are flat enough.</returns>
private static bool IsFlatEnough(Vector2[] controlPoints)
private static bool isFlatEnough(Vector2[] controlPoints)
{
for (int i = 1; i < controlPoints.Length - 1; i++)
if ((controlPoints[i - 1] - 2 * controlPoints[i] + controlPoints[i + 1]).LengthSquared > TOLERANCE_SQ * 4)
if ((controlPoints[i - 1] - 2 * controlPoints[i] + controlPoints[i + 1]).LengthSquared > tolerance_sq * 4)
return false;
return true;
@ -50,7 +50,7 @@ namespace osu.Game.Modes.Osu.Objects
/// <param name="controlPoints">The control points to split.</param>
/// <param name="l">Output: The control points corresponding to the left half of the curve.</param>
/// <param name="r">Output: The control points corresponding to the right half of the curve.</param>
private void Subdivide(Vector2[] controlPoints, Vector2[] l, Vector2[] r)
private void subdivide(Vector2[] controlPoints, Vector2[] l, Vector2[] r)
{
Vector2[] midpoints = subdivisionBuffer1;
@ -73,12 +73,12 @@ namespace osu.Game.Modes.Osu.Objects
/// </summary>
/// <param name="controlPoints">The control points describing the bezier curve to be approximated.</param>
/// <param name="output">The points representing the resulting piecewise-linear approximation.</param>
private void Approximate(Vector2[] controlPoints, List<Vector2> output)
private void approximate(Vector2[] controlPoints, List<Vector2> output)
{
Vector2[] l = subdivisionBuffer2;
Vector2[] r = subdivisionBuffer1;
Subdivide(controlPoints, l, r);
subdivide(controlPoints, l, r);
for (int i = 0; i < count - 1; ++i)
l[count + i] = r[i + 1];
@ -119,13 +119,13 @@ namespace osu.Game.Modes.Osu.Objects
while (toFlatten.Count > 0)
{
Vector2[] parent = toFlatten.Pop();
if (IsFlatEnough(parent))
if (isFlatEnough(parent))
{
// If the control points we currently operate on are sufficiently "flat", we use
// an extension to De Casteljau's algorithm to obtain a piecewise-linear approximation
// of the bezier curve represented by our control points, consisting of the same amount
// of points as there are control points.
Approximate(parent, output);
approximate(parent, output);
freeBuffers.Push(parent);
continue;
}
@ -133,7 +133,7 @@ namespace osu.Game.Modes.Osu.Objects
// If we do not yet have a sufficiently "flat" (in other words, detailed) approximation we keep
// subdividing the curve we are currently operating on.
Vector2[] rightChild = freeBuffers.Count > 0 ? freeBuffers.Pop() : new Vector2[count];
Subdivide(parent, leftChild, rightChild);
subdivide(parent, leftChild, rightChild);
// We re-use the buffer of the parent for one of the children, so that we save one allocation per iteration.
for (int i = 0; i < count; ++i)