From 20e220df56894ff137693d649a4d531bd76c736f Mon Sep 17 00:00:00 2001 From: Wleter Date: Fri, 3 Feb 2023 16:05:16 +0100 Subject: [PATCH] prioritize closest snap position --- osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs index 8a1d8f597c..f5bbac72d7 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuHitObjectComposer.cs @@ -189,11 +189,14 @@ namespace osu.Game.Rulesets.Osu.Edit var snapPositions = b.ScreenSpaceSnapPoints; - var filteredSnapPositions = snapPositions.Cast().FirstOrDefault(p => Vector2.Distance(p.Value, screenSpacePosition) < snapRadius); + if (!snapPositions.Any()) + continue; + + var closestSnapPosition = snapPositions.MinBy(p => Vector2.Distance(p, screenSpacePosition)); - if (filteredSnapPositions.HasValue) + if (Vector2.Distance(closestSnapPosition, screenSpacePosition) < snapRadius) { - var snap = filteredSnapPositions.Value; + var snap = closestSnapPosition; // only return distance portion, since time is not really valid snapResult = new SnapResult(snap, null, playfield);