mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Rename grid snapping methods
This commit is contained in:
@ -142,7 +142,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
|
|
||||||
private void assertSnappedDistance(float expectedDistance) => AddAssert($"snap distance = {expectedDistance}", () =>
|
private void assertSnappedDistance(float expectedDistance) => AddAssert($"snap distance = {expectedDistance}", () =>
|
||||||
{
|
{
|
||||||
Vector2 snappedPosition = grid.GetSnapPosition(grid.ToLocalSpace(InputManager.CurrentState.Mouse.Position));
|
Vector2 snappedPosition = grid.GetSnappedPosition(grid.ToLocalSpace(InputManager.CurrentState.Mouse.Position));
|
||||||
float distance = Vector2.Distance(snappedPosition, grid_position);
|
float distance = Vector2.Distance(snappedPosition, grid_position);
|
||||||
|
|
||||||
return Precision.AlmostEquals(expectedDistance, distance);
|
return Precision.AlmostEquals(expectedDistance, distance);
|
||||||
@ -160,7 +160,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
Colour = Color4.SlateGray
|
Colour = Color4.SlateGray
|
||||||
},
|
},
|
||||||
grid = new TestOsuDistanceSnapGrid(new HitCircle { Position = grid_position }),
|
grid = new TestOsuDistanceSnapGrid(new HitCircle { Position = grid_position }),
|
||||||
new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnapPosition(grid.ToLocalSpace(v)) }
|
new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnappedPosition(grid.ToLocalSpace(v)) }
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -106,10 +106,10 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
|
|
||||||
Vector2 snapPosition = Vector2.Zero;
|
Vector2 snapPosition = Vector2.Zero;
|
||||||
AddStep("get first tick position", () => snapPosition = grid_position + new Vector2((float)beat_length, 0));
|
AddStep("get first tick position", () => snapPosition = grid_position + new Vector2((float)beat_length, 0));
|
||||||
AddAssert("snap time is 1 beat away", () => Precision.AlmostEquals(beat_length, grid.GetSnapTime(snapPosition), 0.01));
|
AddAssert("snap time is 1 beat away", () => Precision.AlmostEquals(beat_length, grid.GetSnappedTime(snapPosition), 0.01));
|
||||||
|
|
||||||
createGrid(g => g.Velocity = 2, "with velocity = 2");
|
createGrid(g => g.Velocity = 2, "with velocity = 2");
|
||||||
AddAssert("snap time is now 0.5 beats away", () => Precision.AlmostEquals(beat_length / 2, grid.GetSnapTime(snapPosition), 0.01));
|
AddAssert("snap time is now 0.5 beats away", () => Precision.AlmostEquals(beat_length / 2, grid.GetSnappedTime(snapPosition), 0.01));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGrid(Action<TestDistanceSnapGrid> func = null, string description = null)
|
private void createGrid(Action<TestDistanceSnapGrid> func = null, string description = null)
|
||||||
@ -206,7 +206,7 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
protected override float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
=> Velocity;
|
=> Velocity;
|
||||||
|
|
||||||
public override Vector2 GetSnapPosition(Vector2 screenSpacePosition)
|
public override Vector2 GetSnappedPosition(Vector2 screenSpacePosition)
|
||||||
=> Vector2.Zero;
|
=> Vector2.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,11 +257,11 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
|
|
||||||
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
|
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
|
||||||
|
|
||||||
public override Vector2 GetSnappedPosition(Vector2 position) => distanceSnapGrid?.GetSnapPosition(position) ?? position;
|
public override Vector2 GetSnappedPosition(Vector2 position) => distanceSnapGrid?.GetSnappedPosition(position) ?? position;
|
||||||
|
|
||||||
public override double GetSnappedTime(double startTime, Vector2 position) => distanceSnapGrid?.GetSnapTime(position) ?? startTime;
|
public override double GetSnappedTime(double startTime, Vector2 position) => distanceSnapGrid?.GetSnappedTime(position) ?? startTime;
|
||||||
|
|
||||||
public override float GetSnappedDistance(float distance) => distanceSnapGrid?.GetSnapDistance(distance) ?? distance;
|
public override float GetSnappedDistance(float distance) => distanceSnapGrid?.GetSnappedDistance(distance) ?? distance;
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Vector2 GetSnapPosition(Vector2 position)
|
public override Vector2 GetSnappedPosition(Vector2 position)
|
||||||
{
|
{
|
||||||
Vector2 direction = position - CentrePosition;
|
Vector2 direction = position - CentrePosition;
|
||||||
|
|
||||||
|
@ -119,21 +119,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">The original position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</param>
|
/// <param name="position">The original position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</param>
|
||||||
/// <returns>The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</returns>
|
/// <returns>The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</returns>
|
||||||
public abstract Vector2 GetSnapPosition(Vector2 position);
|
public abstract Vector2 GetSnappedPosition(Vector2 position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the time at a snapped position.
|
/// Retrieves the time at a snapped position.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</param>
|
/// <param name="position">The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</param>
|
||||||
/// <returns>The time at the snapped position.</returns>
|
/// <returns>The time at the snapped position.</returns>
|
||||||
public double GetSnapTime(Vector2 position) => startTime + (position - CentrePosition).Length / Velocity;
|
public double GetSnappedTime(Vector2 position) => startTime + (position - CentrePosition).Length / Velocity;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Snaps a distance by the snap distance of this grid.
|
/// Snaps a distance by the snap distance of this grid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="distance">The distance to snap.</param>
|
/// <param name="distance">The distance to snap.</param>
|
||||||
/// <returns>The snapped distance.</returns>
|
/// <returns>The snapped distance.</returns>
|
||||||
public float GetSnapDistance(float distance) => (int)(distance / DistanceSpacing) * DistanceSpacing;
|
public float GetSnappedDistance(float distance) => (int)(distance / DistanceSpacing) * DistanceSpacing;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the applicable colour for a beat index.
|
/// Retrieves the applicable colour for a beat index.
|
||||||
|
Reference in New Issue
Block a user