1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 06:52:55 +08:00

Use existing snap list from BindableBeatDivisor

This commit is contained in:
Bartłomiej Dach 2021-04-25 17:52:11 +02:00
parent e14255f395
commit 33a5c156a1

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Screens.Edit;
namespace osu.Game.Rulesets.Objects namespace osu.Game.Rulesets.Objects
{ {
@ -24,8 +25,6 @@ namespace osu.Game.Rulesets.Objects
this.beatmap = beatmap; this.beatmap = beatmap;
} }
private static readonly int[] snaps = { 1, 2, 3, 4, 6, 8, 12, 16 };
/// <summary> /// <summary>
/// Finds the lowest beat divisor that the given <see cref="HitObject"/> aligns to. /// Finds the lowest beat divisor that the given <see cref="HitObject"/> aligns to.
/// </summary> /// </summary>
@ -35,10 +34,10 @@ namespace osu.Game.Rulesets.Objects
TimingControlPoint currentTimingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime); TimingControlPoint currentTimingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime);
double snapResult = (hitObject.StartTime - currentTimingPoint.Time) % (currentTimingPoint.BeatLength * 4); double snapResult = (hitObject.StartTime - currentTimingPoint.Time) % (currentTimingPoint.BeatLength * 4);
foreach (var snap in snaps) foreach (var divisor in BindableBeatDivisor.VALID_DIVISORS)
{ {
if (almostDivisibleBy(snapResult, currentTimingPoint.BeatLength / snap)) if (almostDivisibleBy(snapResult, currentTimingPoint.BeatLength / divisor))
return snap; return divisor;
} }
return 0; return 0;