mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 04:53:06 +08:00
Increase acceptable difference for Precision calls
This commit is contained in:
parent
be55c7e075
commit
1a47bc254d
@ -84,6 +84,11 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private const double undim_duration = 96;
|
private const double undim_duration = 96;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Acceptable difference for timing comparisons
|
||||||
|
/// </summary>
|
||||||
|
private const double timing_precision = 1;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
@ -198,11 +203,11 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
var beats = beatmap.ControlPointInfo.TimingPoints
|
var beats = beatmap.ControlPointInfo.TimingPoints
|
||||||
// Ignore timing points after endTime
|
// Ignore timing points after endTime
|
||||||
.Where(timingPoint => Precision.AlmostBigger(endTime, timingPoint.Time))
|
.Where(timingPoint => almostBigger(endTime, timingPoint.Time))
|
||||||
// Generate the beats
|
// Generate the beats
|
||||||
.SelectMany(timingPoint => getBeatsForTimingPoint(timingPoint, endTime))
|
.SelectMany(timingPoint => getBeatsForTimingPoint(timingPoint, endTime))
|
||||||
// Remove beats before startTime
|
// Remove beats before startTime
|
||||||
.Where(beat => Precision.AlmostBigger(beat, startTime))
|
.Where(beat => almostBigger(beat, startTime))
|
||||||
// Remove beats during breaks
|
// Remove beats during breaks
|
||||||
.Where(beat => !isInsideBreakPeriod(beatmap.Breaks, beat))
|
.Where(beat => !isInsideBreakPeriod(beatmap.Breaks, beat))
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -212,7 +217,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
var beat = beats[i];
|
var beat = beats[i];
|
||||||
|
|
||||||
if (Precision.AlmostBigger(beatmap.ControlPointInfo.TimingPointAt(beat).BeatLength / 2, beats[i + 1] - beat))
|
if (almostBigger(beatmap.ControlPointInfo.TimingPointAt(beat).BeatLength / 2, beats[i + 1] - beat))
|
||||||
beats.RemoveAt(i);
|
beats.RemoveAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +262,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
// Copy combo indices from the closest preceding object
|
// Copy combo indices from the closest preceding object
|
||||||
hitObjects.ForEach(obj =>
|
hitObjects.ForEach(obj =>
|
||||||
{
|
{
|
||||||
var closestOrigObj = origHitObjects.FindLast(y => Precision.AlmostBigger(obj.StartTime, y.StartTime));
|
var closestOrigObj = origHitObjects.FindLast(y => almostBigger(obj.StartTime, y.StartTime));
|
||||||
|
|
||||||
// It shouldn't be possible for closestOrigObj to be null
|
// It shouldn't be possible for closestOrigObj to be null
|
||||||
// But if it is, obj should be in the first combo
|
// But if it is, obj should be in the first combo
|
||||||
@ -397,10 +402,10 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
return breaks.Any(breakPeriod =>
|
return breaks.Any(breakPeriod =>
|
||||||
{
|
{
|
||||||
var firstObjAfterBreak = origHitObjects.First(obj => Precision.AlmostBigger(obj.StartTime, breakPeriod.EndTime));
|
var firstObjAfterBreak = origHitObjects.First(obj => almostBigger(obj.StartTime, breakPeriod.EndTime));
|
||||||
|
|
||||||
return Precision.AlmostBigger(time, breakPeriod.StartTime)
|
return almostBigger(time, breakPeriod.StartTime)
|
||||||
&& Precision.AlmostBigger(firstObjAfterBreak.StartTime, time);
|
&& almostBigger(firstObjAfterBreak.StartTime, time);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +415,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
var currentTime = timingPoint.Time;
|
var currentTime = timingPoint.Time;
|
||||||
|
|
||||||
while (Precision.AlmostBigger(mapEndTime, currentTime) && controlPointInfo.TimingPointAt(currentTime) == timingPoint)
|
while (almostBigger(mapEndTime, currentTime) && controlPointInfo.TimingPointAt(currentTime) == timingPoint)
|
||||||
{
|
{
|
||||||
beats.Add(Math.Floor(currentTime));
|
beats.Add(Math.Floor(currentTime));
|
||||||
i++;
|
i++;
|
||||||
@ -436,13 +441,13 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
// or has a repeat node at the target time
|
// or has a repeat node at the target time
|
||||||
var sampleObj = hitObjects.FirstOrDefault(hitObject =>
|
var sampleObj = hitObjects.FirstOrDefault(hitObject =>
|
||||||
{
|
{
|
||||||
if (Precision.AlmostEquals(time, hitObject.StartTime))
|
if (almostEquals(time, hitObject.StartTime))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(hitObject is IHasPathWithRepeats s))
|
if (!(hitObject is IHasPathWithRepeats s))
|
||||||
return false;
|
return false;
|
||||||
if (!Precision.AlmostBigger(time, hitObject.StartTime)
|
if (!almostBigger(time, hitObject.StartTime)
|
||||||
|| !Precision.AlmostBigger(s.EndTime, time))
|
|| !almostBigger(s.EndTime, time))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return nodeIndexFromTime(s, time - hitObject.StartTime) != -1;
|
return nodeIndexFromTime(s, time - hitObject.StartTime) != -1;
|
||||||
@ -470,7 +475,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
double spanDuration = curve.Duration / curve.SpanCount();
|
double spanDuration = curve.Duration / curve.SpanCount();
|
||||||
double nodeIndex = timeSinceStart / spanDuration;
|
double nodeIndex = timeSinceStart / spanDuration;
|
||||||
|
|
||||||
if (Precision.AlmostEquals(nodeIndex - Math.Round(nodeIndex), 0))
|
if (almostEquals(nodeIndex - Math.Round(nodeIndex), 0))
|
||||||
return (int)Math.Round(nodeIndex);
|
return (int)Math.Round(nodeIndex);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -583,6 +588,16 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
return (value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow;
|
return (value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool almostBigger(double value1, double value2)
|
||||||
|
{
|
||||||
|
return Precision.AlmostBigger(value1, value2, timing_precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool almostEquals(double value1, double value2)
|
||||||
|
{
|
||||||
|
return Precision.AlmostEquals(value1, value2, timing_precision);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user