mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09:32:55 +08:00
Merge pull request #22498 from Wleter/SnapToReverseSlider
Allow snapping objects to slider ends/repeats
This commit is contained in:
commit
5e66a7d2d6
@ -187,28 +187,19 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
if (b.IsSelected)
|
if (b.IsSelected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var hitObject = (OsuHitObject)b.Item;
|
var snapPositions = b.ScreenSpaceSnapPoints;
|
||||||
|
|
||||||
Vector2? snap = checkSnap(hitObject.Position);
|
if (!snapPositions.Any())
|
||||||
if (snap == null && hitObject.Position != hitObject.EndPosition)
|
continue;
|
||||||
snap = checkSnap(hitObject.EndPosition);
|
|
||||||
|
|
||||||
if (snap != null)
|
var closestSnapPosition = snapPositions.MinBy(p => Vector2.Distance(p, screenSpacePosition));
|
||||||
|
|
||||||
|
if (Vector2.Distance(closestSnapPosition, screenSpacePosition) < snapRadius)
|
||||||
{
|
{
|
||||||
// only return distance portion, since time is not really valid
|
// only return distance portion, since time is not really valid
|
||||||
snapResult = new SnapResult(snap.Value, null, playfield);
|
snapResult = new SnapResult(closestSnapPosition, null, playfield);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2? checkSnap(Vector2 checkPos)
|
|
||||||
{
|
|
||||||
Vector2 checkScreenPos = playfield.GamefieldToScreenSpace(checkPos);
|
|
||||||
|
|
||||||
if (Vector2.Distance(checkScreenPos, screenSpacePosition) < snapRadius)
|
|
||||||
return checkScreenPos;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snapResult = null;
|
snapResult = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user