mirror of
https://github.com/ppy/osu.git
synced 2026-05-22 15:10:20 +08:00
apply review
- improve timing tolerance const name and documentation - simplify matching logic in `FindMatchingTimingPoint`
This commit is contained in:
@@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
}
|
||||
|
||||
// Check for BPM inconsistency
|
||||
if (Math.Abs(referencePoint.BeatLength - matchingPoint.BeatLength) > TimingCheckUtils.TIMING_TOLERANCE)
|
||||
if (Math.Abs(referencePoint.BeatLength - matchingPoint.BeatLength) > TimingCheckUtils.TIME_OFFSET_TOLERANCE_MS)
|
||||
{
|
||||
yield return new IssueTemplateInconsistentBPM(this).Create(referencePoint.Time, beatmap.BeatmapInfo.DifficultyName);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Utils;
|
||||
@@ -11,8 +10,8 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
{
|
||||
public static class TimingCheckUtils
|
||||
{
|
||||
// Small tolerance for floating point comparison
|
||||
public const double TIMING_TOLERANCE = 0.01;
|
||||
// Tolerance for exact time offset matching (in milliseconds)
|
||||
public const double TIME_OFFSET_TOLERANCE_MS = 0.01;
|
||||
|
||||
/// <summary>
|
||||
/// Finds a timing control point that starts at approximately the same time (within 1ms after rounding).
|
||||
@@ -22,7 +21,7 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
/// <returns>The matching timing control point, or null if none found.</returns>
|
||||
public static TimingControlPoint? FindMatchingTimingPoint(IEnumerable<TimingControlPoint> timingPoints, double time)
|
||||
{
|
||||
return timingPoints.FirstOrDefault(tp => Precision.AlmostEquals(tp.Time, Math.Round(time), 1.0));
|
||||
return timingPoints.FirstOrDefault(tp => (int)tp.Time == (int)time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -33,7 +32,7 @@ namespace osu.Game.Rulesets.Edit.Checks.Components
|
||||
/// <returns>The exact matching timing control point, or null if none found.</returns>
|
||||
public static TimingControlPoint? FindExactMatchingTimingPoint(IEnumerable<TimingControlPoint> timingPoints, double time)
|
||||
{
|
||||
return timingPoints.FirstOrDefault(tp => Precision.AlmostEquals(tp.Time, time, TIMING_TOLERANCE));
|
||||
return timingPoints.FirstOrDefault(tp => Precision.AlmostEquals(tp.Time, time, TIME_OFFSET_TOLERANCE_MS));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user