1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 10:43:21 +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.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Screens.Edit;
namespace osu.Game.Rulesets.Objects
{
@ -24,8 +25,6 @@ namespace osu.Game.Rulesets.Objects
this.beatmap = beatmap;
}
private static readonly int[] snaps = { 1, 2, 3, 4, 6, 8, 12, 16 };
/// <summary>
/// Finds the lowest beat divisor that the given <see cref="HitObject"/> aligns to.
/// </summary>
@ -35,10 +34,10 @@ namespace osu.Game.Rulesets.Objects
TimingControlPoint currentTimingPoint = beatmap.ControlPointInfo.TimingPointAt(hitObject.StartTime);
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))
return snap;
if (almostDivisibleBy(snapResult, currentTimingPoint.BeatLength / divisor))
return divisor;
}
return 0;