mirror of https://github.com/ppy/osu
add controllable leniency
This commit is contained in:
parent
1930476192
commit
89859b85b7
|
@ -95,6 +95,11 @@ protected override void LoadComplete()
|
||||||
bSplineBuilder.CornerThreshold = e.NewValue;
|
bSplineBuilder.CornerThreshold = e.NewValue;
|
||||||
Scheduler.AddOnce(updateSliderPathFromBSplineBuilder);
|
Scheduler.AddOnce(updateSliderPathFromBSplineBuilder);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
freehandToolboxGroup.CircleThreshold.BindValueChanged(e =>
|
||||||
|
{
|
||||||
|
Scheduler.AddOnce(updateSliderPathFromBSplineBuilder);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +363,7 @@ private void updateSliderPathFromBSplineBuilder()
|
||||||
|
|
||||||
private Vector2[] tryCircleArc(List<Vector2> segment)
|
private Vector2[] tryCircleArc(List<Vector2> segment)
|
||||||
{
|
{
|
||||||
if (segment.Count < 3) return null;
|
if (segment.Count < 3 || freehandToolboxGroup.CircleThreshold.Value == 0) return null;
|
||||||
|
|
||||||
// Assume the segment creates a reasonable circular arc and then check if it reasonable
|
// Assume the segment creates a reasonable circular arc and then check if it reasonable
|
||||||
var points = PathApproximator.BSplineToPiecewiseLinear(segment.ToArray(), bSplineBuilder.Degree);
|
var points = PathApproximator.BSplineToPiecewiseLinear(segment.ToArray(), bSplineBuilder.Degree);
|
||||||
|
@ -412,7 +417,7 @@ private Vector2[] tryCircleArc(List<Vector2> segment)
|
||||||
|
|
||||||
loss /= points.Count;
|
loss /= points.Count;
|
||||||
|
|
||||||
return loss > 0.002 || totalWinding > MathHelper.TwoPi ? null : circleArcControlPoints;
|
return loss > freehandToolboxGroup.CircleThreshold.Value || totalWinding > MathHelper.TwoPi ? null : circleArcControlPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum SliderPlacementState
|
private enum SliderPlacementState
|
||||||
|
|
|
@ -31,6 +31,13 @@ public FreehandSliderToolboxGroup()
|
||||||
Precision = 0.01f
|
Precision = 0.01f
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public BindableFloat CircleThreshold { get; } = new BindableFloat(0.002f)
|
||||||
|
{
|
||||||
|
MinValue = 0f,
|
||||||
|
MaxValue = 0.005f,
|
||||||
|
Precision = 0.0001f
|
||||||
|
};
|
||||||
|
|
||||||
// We map internal ranges to a more standard range of values for display to the user.
|
// We map internal ranges to a more standard range of values for display to the user.
|
||||||
private readonly BindableInt displayTolerance = new BindableInt(100)
|
private readonly BindableInt displayTolerance = new BindableInt(100)
|
||||||
{
|
{
|
||||||
|
@ -44,8 +51,15 @@ public FreehandSliderToolboxGroup()
|
||||||
MaxValue = 100
|
MaxValue = 100
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private readonly BindableInt displayCircleThreshold = new BindableInt(40)
|
||||||
|
{
|
||||||
|
MinValue = 0,
|
||||||
|
MaxValue = 100
|
||||||
|
};
|
||||||
|
|
||||||
private ExpandableSlider<int> toleranceSlider = null!;
|
private ExpandableSlider<int> toleranceSlider = null!;
|
||||||
private ExpandableSlider<int> cornerThresholdSlider = null!;
|
private ExpandableSlider<int> cornerThresholdSlider = null!;
|
||||||
|
private ExpandableSlider<int> circleThresholdSlider = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
|
@ -59,6 +73,10 @@ private void load()
|
||||||
cornerThresholdSlider = new ExpandableSlider<int>
|
cornerThresholdSlider = new ExpandableSlider<int>
|
||||||
{
|
{
|
||||||
Current = displayCornerThreshold
|
Current = displayCornerThreshold
|
||||||
|
},
|
||||||
|
circleThresholdSlider = new ExpandableSlider<int>
|
||||||
|
{
|
||||||
|
Current = displayCircleThreshold
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -83,18 +101,32 @@ protected override void LoadComplete()
|
||||||
CornerThreshold.Value = displayToInternalCornerThreshold(threshold.NewValue);
|
CornerThreshold.Value = displayToInternalCornerThreshold(threshold.NewValue);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
displayCircleThreshold.BindValueChanged(threshold =>
|
||||||
|
{
|
||||||
|
circleThresholdSlider.ContractedLabelText = $"P. C. T.: {threshold.NewValue:N0}";
|
||||||
|
circleThresholdSlider.ExpandedLabelText = $"Perfect Curve Threshold: {threshold.NewValue:N0}";
|
||||||
|
|
||||||
|
CircleThreshold.Value = displayToInternalCircleThreshold(threshold.NewValue);
|
||||||
|
}, true);
|
||||||
|
|
||||||
Tolerance.BindValueChanged(tolerance =>
|
Tolerance.BindValueChanged(tolerance =>
|
||||||
displayTolerance.Value = internalToDisplayTolerance(tolerance.NewValue)
|
displayTolerance.Value = internalToDisplayTolerance(tolerance.NewValue)
|
||||||
);
|
);
|
||||||
CornerThreshold.BindValueChanged(threshold =>
|
CornerThreshold.BindValueChanged(threshold =>
|
||||||
displayCornerThreshold.Value = internalToDisplayCornerThreshold(threshold.NewValue)
|
displayCornerThreshold.Value = internalToDisplayCornerThreshold(threshold.NewValue)
|
||||||
);
|
);
|
||||||
|
CircleThreshold.BindValueChanged(threshold =>
|
||||||
|
displayCircleThreshold.Value = internalToDisplayCircleThreshold(threshold.NewValue)
|
||||||
|
);
|
||||||
|
|
||||||
float displayToInternalTolerance(float v) => v / 50f;
|
float displayToInternalTolerance(float v) => v / 50f;
|
||||||
int internalToDisplayTolerance(float v) => (int)Math.Round(v * 50f);
|
int internalToDisplayTolerance(float v) => (int)Math.Round(v * 50f);
|
||||||
|
|
||||||
float displayToInternalCornerThreshold(float v) => v / 100f;
|
float displayToInternalCornerThreshold(float v) => v / 100f;
|
||||||
int internalToDisplayCornerThreshold(float v) => (int)Math.Round(v * 100f);
|
int internalToDisplayCornerThreshold(float v) => (int)Math.Round(v * 100f);
|
||||||
|
|
||||||
|
float displayToInternalCircleThreshold(float v) => v / 20000f;
|
||||||
|
int internalToDisplayCircleThreshold(float v) => (int)Math.Round(v * 20000f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue