1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 15:12:57 +08:00

Use an infinite tick distance instead of directly disabling tick generation for SliderEventGenerator

This commit is contained in:
Khang 2022-08-22 23:31:24 -04:00
parent 8f708c1dcf
commit a81672f3dc
5 changed files with 18 additions and 37 deletions

View File

@ -40,9 +40,6 @@ namespace osu.Game.Rulesets.Catch.Objects
[JsonIgnore] [JsonIgnore]
public double TickDistance => tickDistanceFactor * DifficultyControlPoint.SliderVelocity; public double TickDistance => tickDistanceFactor * DifficultyControlPoint.SliderVelocity;
[JsonIgnore]
public bool GenerateTicks => DifficultyControlPoint.GenerateTicks;
/// <summary> /// <summary>
/// The length of one span of this <see cref="JuiceStream"/>. /// The length of one span of this <see cref="JuiceStream"/>.
/// </summary> /// </summary>
@ -67,7 +64,7 @@ namespace osu.Game.Rulesets.Catch.Objects
int nodeIndex = 0; int nodeIndex = 0;
SliderEventDescriptor? lastEvent = null; SliderEventDescriptor? lastEvent = null;
foreach (var e in SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset, GenerateTicks, cancellationToken)) foreach (var e in SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset, cancellationToken))
{ {
// generate tiny droplets since the last point // generate tiny droplets since the last point
if (lastEvent != null) if (lastEvent != null)

View File

@ -102,7 +102,7 @@ namespace osu.Game.Rulesets.Osu.Mods
protected override void CreateNestedHitObjects(CancellationToken cancellationToken) protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
{ {
var sliderEvents = SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset, GenerateTicks, cancellationToken); var sliderEvents = SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset, cancellationToken);
foreach (var e in sliderEvents) foreach (var e in sliderEvents)
{ {

View File

@ -142,11 +142,6 @@ namespace osu.Game.Rulesets.Osu.Objects
/// </summary> /// </summary>
public double TickDistanceMultiplier = 1; public double TickDistanceMultiplier = 1;
/// <summary>
/// Whether this <see cref="Slider"/> should generate <see cref="SliderTick"/>s.
/// </summary>
public bool GenerateTicks { get; private set; }
/// <summary> /// <summary>
/// Whether this <see cref="Slider"/>'s judgement is fully handled by its nested <see cref="HitObject"/>s. /// Whether this <see cref="Slider"/>'s judgement is fully handled by its nested <see cref="HitObject"/>s.
/// If <c>false</c>, this <see cref="Slider"/> will be judged proportionally to the number of nested <see cref="HitObject"/>s hit. /// If <c>false</c>, this <see cref="Slider"/> will be judged proportionally to the number of nested <see cref="HitObject"/>s hit.
@ -174,15 +169,14 @@ namespace osu.Game.Rulesets.Osu.Objects
double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * DifficultyControlPoint.SliderVelocity; double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * DifficultyControlPoint.SliderVelocity;
Velocity = scoringDistance / timingPoint.BeatLength; Velocity = scoringDistance / timingPoint.BeatLength;
TickDistance = scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier; TickDistance = DifficultyControlPoint.GenerateTicks ? (scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier) : double.PositiveInfinity;
GenerateTicks = DifficultyControlPoint.GenerateTicks;
} }
protected override void CreateNestedHitObjects(CancellationToken cancellationToken) protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
{ {
base.CreateNestedHitObjects(cancellationToken); base.CreateNestedHitObjects(cancellationToken);
var sliderEvents = SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset, GenerateTicks, cancellationToken); var sliderEvents = SliderEventGenerator.Generate(StartTime, SpanDuration, Velocity, TickDistance, Path.Distance, this.SpanCount(), LegacyLastTickOffset, cancellationToken);
foreach (var e in sliderEvents) foreach (var e in sliderEvents)
{ {

View File

@ -18,7 +18,7 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestSingleSpan() public void TestSingleSpan()
{ {
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 1, null, true).ToArray(); var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 1, null).ToArray();
Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head)); Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head));
Assert.That(events[0].Time, Is.EqualTo(start_time)); Assert.That(events[0].Time, Is.EqualTo(start_time));
@ -33,7 +33,7 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestRepeat() public void TestRepeat()
{ {
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 2, null, true).ToArray(); var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 2, null).ToArray();
Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head)); Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head));
Assert.That(events[0].Time, Is.EqualTo(start_time)); Assert.That(events[0].Time, Is.EqualTo(start_time));
@ -54,7 +54,7 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestNonEvenTicks() public void TestNonEvenTicks()
{ {
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, 300, span_duration, 2, null, true).ToArray(); var events = SliderEventGenerator.Generate(start_time, span_duration, 1, 300, span_duration, 2, null).ToArray();
Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head)); Assert.That(events[0].Type, Is.EqualTo(SliderEventType.Head));
Assert.That(events[0].Time, Is.EqualTo(start_time)); Assert.That(events[0].Time, Is.EqualTo(start_time));
@ -87,7 +87,7 @@ namespace osu.Game.Tests.Beatmaps
[Test] [Test]
public void TestLegacyLastTickOffset() public void TestLegacyLastTickOffset()
{ {
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 1, 100, true).ToArray(); var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 1, 100).ToArray();
Assert.That(events[2].Type, Is.EqualTo(SliderEventType.LegacyLastTick)); Assert.That(events[2].Type, Is.EqualTo(SliderEventType.LegacyLastTick));
Assert.That(events[2].Time, Is.EqualTo(900)); Assert.That(events[2].Time, Is.EqualTo(900));
@ -99,7 +99,7 @@ namespace osu.Game.Tests.Beatmaps
const double velocity = 5; const double velocity = 5;
const double min_distance = velocity * 10; const double min_distance = velocity * 10;
var events = SliderEventGenerator.Generate(start_time, span_duration, velocity, velocity, span_duration, 2, 0, true).ToArray(); var events = SliderEventGenerator.Generate(start_time, span_duration, velocity, velocity, span_duration, 2, 0).ToArray();
Assert.Multiple(() => Assert.Multiple(() =>
{ {
@ -114,12 +114,5 @@ namespace osu.Game.Tests.Beatmaps
} }
}); });
} }
[Test]
public void TestNoTickGeneration()
{
var events = SliderEventGenerator.Generate(start_time, span_duration, 1, span_duration / 2, span_duration, 1, null, false).ToArray();
Assert.That(events.Any(e => e.Type == SliderEventType.Tick), Is.False);
}
} }
} }

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Objects
{ {
// ReSharper disable once MethodOverloadWithOptionalParameter // ReSharper disable once MethodOverloadWithOptionalParameter
public static IEnumerable<SliderEventDescriptor> Generate(double startTime, double spanDuration, double velocity, double tickDistance, double totalDistance, int spanCount, public static IEnumerable<SliderEventDescriptor> Generate(double startTime, double spanDuration, double velocity, double tickDistance, double totalDistance, int spanCount,
double? legacyLastTickOffset, bool shouldGenerateTicks, CancellationToken cancellationToken = default) double? legacyLastTickOffset, CancellationToken cancellationToken = default)
{ {
// A very lenient maximum length of a slider for ticks to be generated. // A very lenient maximum length of a slider for ticks to be generated.
// This exists for edge cases such as /b/1573664 where the beatmap has been edited by the user, and should never be reached in normal usage. // This exists for edge cases such as /b/1573664 where the beatmap has been edited by the user, and should never be reached in normal usage.
@ -41,8 +41,6 @@ namespace osu.Game.Rulesets.Objects
double spanStartTime = startTime + span * spanDuration; double spanStartTime = startTime + span * spanDuration;
bool reversed = span % 2 == 1; bool reversed = span % 2 == 1;
if (shouldGenerateTicks)
{
var ticks = generateTicks(span, spanStartTime, spanDuration, reversed, length, tickDistance, minDistanceFromEnd, cancellationToken); var ticks = generateTicks(span, spanStartTime, spanDuration, reversed, length, tickDistance, minDistanceFromEnd, cancellationToken);
if (reversed) if (reversed)
@ -53,7 +51,6 @@ namespace osu.Game.Rulesets.Objects
foreach (var e in ticks) foreach (var e in ticks)
yield return e; yield return e;
}
if (span < spanCount - 1) if (span < spanCount - 1)
{ {