1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:03:22 +08:00

Split out grid snapping modes into "relative" and "global" types

This commit is contained in:
Dean Herbert 2023-05-25 21:41:19 +09:00
parent 59768c5ffd
commit 804671ca74
5 changed files with 26 additions and 7 deletions

View File

@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Catch.Edit
result.ScreenSpacePosition.X = screenSpacePosition.X;
if (snapType.HasFlagFast(SnapType.Grids))
if (snapType.HasFlagFast(SnapType.GlobalGrids))
{
if (distanceSnapGrid.IsPresent && distanceSnapGrid.GetSnappedPosition(result.ScreenSpacePosition) is SnapResult snapResult &&
Vector2.Distance(snapResult.ScreenSpacePosition, result.ScreenSpacePosition) < distance_snap_radius)

View File

@ -143,7 +143,7 @@ namespace osu.Game.Rulesets.Osu.Edit
// We want to ensure that in this particular case, the time-snapping component of distance snap is still applied.
// The easiest way to ensure this is to attempt application of distance snap after a nearby object is found, and copy over
// the time value if the proposed positions are roughly the same.
if (snapType.HasFlagFast(SnapType.Grids) && DistanceSnapToggle.Value == TernaryState.True && distanceSnapGrid != null)
if (snapType.HasFlagFast(SnapType.RelativeGrids) && DistanceSnapToggle.Value == TernaryState.True && distanceSnapGrid != null)
{
(Vector2 distanceSnappedPosition, double distanceSnappedTime) = distanceSnapGrid.GetSnappedPosition(distanceSnapGrid.ToLocalSpace(snapResult.ScreenSpacePosition));
if (Precision.AlmostEquals(distanceSnapGrid.ToScreenSpace(distanceSnappedPosition), snapResult.ScreenSpacePosition, 1))
@ -155,7 +155,7 @@ namespace osu.Game.Rulesets.Osu.Edit
SnapResult result = base.FindSnappedPositionAndTime(screenSpacePosition, snapType);
if (snapType.HasFlagFast(SnapType.Grids))
if (snapType.HasFlagFast(SnapType.RelativeGrids))
{
if (DistanceSnapToggle.Value == TernaryState.True && distanceSnapGrid != null)
{
@ -164,7 +164,10 @@ namespace osu.Game.Rulesets.Osu.Edit
result.ScreenSpacePosition = distanceSnapGrid.ToScreenSpace(pos);
result.Time = time;
}
}
if (snapType.HasFlagFast(SnapType.GlobalGrids))
{
if (rectangularGridSnapToggle.Value == TernaryState.True)
{
Vector2 pos = rectangularPositionSnapGrid.GetSnappedPosition(rectangularPositionSnapGrid.ToLocalSpace(result.ScreenSpacePosition));

View File

@ -187,7 +187,7 @@ namespace osu.Game.Tests.Visual.Editing
private class SnapProvider : IDistanceSnapProvider
{
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.Grids) => new SnapResult(screenSpacePosition, 0);
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.AllGrids) => new SnapResult(screenSpacePosition, 0);
public Bindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1);

View File

@ -428,7 +428,7 @@ namespace osu.Game.Rulesets.Edit
var playfield = PlayfieldAtScreenSpacePosition(screenSpacePosition);
double? targetTime = null;
if (snapType.HasFlagFast(SnapType.Grids))
if (snapType.HasFlagFast(SnapType.GlobalGrids))
{
if (playfield is ScrollingPlayfield scrollingPlayfield)
{

View File

@ -11,8 +11,24 @@ namespace osu.Game.Rulesets.Edit
public enum SnapType
{
None = 0,
/// <summary>
/// Snapping to visible nearby objects.
/// </summary>
NearbyObjects = 1 << 0,
Grids = 1 << 1,
All = NearbyObjects | Grids,
/// <summary>
/// Grids which are global to the playfield.
/// </summary>
GlobalGrids = 1 << 1,
/// <summary>
/// Grids which are relative to other nearby hit objects.
/// </summary>
RelativeGrids = 1 << 2,
AllGrids = RelativeGrids | GlobalGrids,
All = NearbyObjects | GlobalGrids | RelativeGrids,
}
}