1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 23:36:10 +08:00

fix RepeatPoint animations

- FadeIn and -Out for RepeatPoints are now calculated instead of fixed values
- TimePreempt is now cut down if too long for RepeatPoints following the first one to only show up to two RepeatPoints at any given time
This commit is contained in:
Aergwyn 2018-01-22 12:36:38 +01:00
parent 85d1e81a92
commit 66176f2882
5 changed files with 36 additions and 26 deletions

View File

@ -17,7 +17,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly DrawableSlider drawableSlider; private readonly DrawableSlider drawableSlider;
public double FadeInTime; public double FadeInTime;
public double FadeOutTime; private double animDuration;
public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider) public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider)
: base(repeatPoint) : base(repeatPoint)
@ -48,11 +48,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void UpdatePreemptState() protected override void UpdatePreemptState()
{ {
var animIn = Math.Min(150, repeatPoint.StartTime - FadeInTime); animDuration = Math.Min(150, repeatPoint.StartTime - FadeInTime);
this.FadeIn(animIn).ScaleTo(1.2f, animIn) this.FadeIn(animDuration).ScaleTo(1.2f, animDuration / 2)
.Then() .Then()
.ScaleTo(1, 150, Easing.Out); .ScaleTo(1, animDuration / 2, Easing.Out);
} }
protected override void UpdateCurrentState(ArmedState state) protected override void UpdateCurrentState(ArmedState state)
@ -60,14 +60,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
switch (state) switch (state)
{ {
case ArmedState.Idle: case ArmedState.Idle:
this.Delay(FadeOutTime - repeatPoint.StartTime).FadeOut(); this.Delay(HitObject.TimePreempt).FadeOut();
break; break;
case ArmedState.Miss: case ArmedState.Miss:
this.FadeOut(160); this.FadeOut(animDuration);
break; break;
case ArmedState.Hit: case ArmedState.Hit:
this.FadeOut(120, Easing.OutQuint) this.FadeOut(animDuration, Easing.OutQuint)
.ScaleTo(Scale * 1.5f, 120, Easing.OutQuint); .ScaleTo(Scale * 1.5f, animDuration, Easing.OutQuint);
break; break;
} }
} }

View File

@ -72,12 +72,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
AddNested(InitialCircle); AddNested(InitialCircle);
var repeatDuration = s.Curve.Distance / s.Velocity;
foreach (var tick in s.NestedHitObjects.OfType<SliderTick>()) foreach (var tick in s.NestedHitObjects.OfType<SliderTick>())
{ {
var repeatStartTime = s.StartTime + tick.RepeatIndex * repeatDuration; var repeatStartTime = s.StartTime + tick.RepeatIndex * s.RepeatDuration;
var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? HitObject.TimeFadein : HitObject.TimeFadein / 2); var fadeInTime = repeatStartTime + (tick.StartTime - repeatStartTime) / 2 - (tick.RepeatIndex == 0 ? HitObject.TimeFadein : HitObject.TimeFadein / 2);
var fadeOutTime = repeatStartTime + repeatDuration; var fadeOutTime = repeatStartTime + s.RepeatDuration;
var drawableTick = new DrawableSliderTick(tick) var drawableTick = new DrawableSliderTick(tick)
{ {
@ -92,15 +91,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>()) foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
{ {
var repeatStartTime = s.StartTime + repeatPoint.RepeatIndex * repeatDuration;
var fadeInTime = repeatStartTime + (repeatPoint.StartTime - repeatStartTime) / 2 - (repeatPoint.RepeatIndex == 0 ? HitObject.TimeFadein : HitObject.TimeFadein / 2);
var fadeOutTime = repeatStartTime + repeatDuration;
var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this) var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this)
{ {
FadeInTime = fadeInTime, FadeInTime = repeatPoint.StartTime - s.RepeatDuration / 2,
FadeOutTime = fadeOutTime, Position = repeatPoint.Position
Position = repeatPoint.Position,
}; };
repeatPoints.Add(drawableRepeatPoint); repeatPoints.Add(drawableRepeatPoint);

View File

@ -1,10 +1,24 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Rulesets.Osu.Objects namespace osu.Game.Rulesets.Osu.Objects
{ {
public class RepeatPoint : OsuHitObject public class RepeatPoint : OsuHitObject
{ {
public int RepeatIndex { get; set; } public int RepeatIndex { get; set; }
public double RepeatDuration { get; set; }
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
// We want to show the first RepeatPoint as the TimePreempt dictates but on short (and possibly fast) sliders
// we may need to cut down this time on following RepeatPoints to only show up to two RepeatPoints at any given time.
if (RepeatIndex > 1 && TimePreempt > RepeatDuration * 2)
TimePreempt = (float)RepeatDuration * 2;
}
} }
} }

View File

@ -60,6 +60,11 @@ namespace osu.Game.Rulesets.Osu.Objects
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>(); public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>();
public int RepeatCount { get; set; } = 1; public int RepeatCount { get; set; } = 1;
/// <summary>
/// The length of one repeat if any repeats are present, otherwise it equals the <see cref="Duration"/>.
/// </summary>
public double RepeatDuration => RepeatCount > 1 ? Distance / Velocity : Duration;
private int stackHeight; private int stackHeight;
public override int StackHeight public override int StackHeight
@ -114,13 +119,12 @@ namespace osu.Game.Rulesets.Osu.Objects
var length = Curve.Distance; var length = Curve.Distance;
var tickDistance = Math.Min(TickDistance, length); var tickDistance = Math.Min(TickDistance, length);
var repeatDuration = length / Velocity;
var minDistanceFromEnd = Velocity * 0.01; var minDistanceFromEnd = Velocity * 0.01;
for (var repeat = 0; repeat < RepeatCount; repeat++) for (var repeat = 0; repeat < RepeatCount; repeat++)
{ {
var repeatStartTime = StartTime + repeat * repeatDuration; var repeatStartTime = StartTime + repeat * RepeatDuration;
var reversed = repeat % 2 == 1; var reversed = repeat % 2 == 1;
for (var d = tickDistance; d <= length; d += tickDistance) for (var d = tickDistance; d <= length; d += tickDistance)
@ -145,7 +149,7 @@ namespace osu.Game.Rulesets.Osu.Objects
AddNested(new SliderTick AddNested(new SliderTick
{ {
RepeatIndex = repeat, RepeatIndex = repeat,
StartTime = repeatStartTime + timeProgress * repeatDuration, StartTime = repeatStartTime + timeProgress * RepeatDuration,
Position = Curve.PositionAt(distanceProgress), Position = Curve.PositionAt(distanceProgress),
StackHeight = StackHeight, StackHeight = StackHeight,
Scale = Scale, Scale = Scale,
@ -158,16 +162,13 @@ namespace osu.Game.Rulesets.Osu.Objects
private void createRepeatPoints() private void createRepeatPoints()
{ {
var repeatDuration = Distance / Velocity;
for (var repeat = 1; repeat < RepeatCount; repeat++) for (var repeat = 1; repeat < RepeatCount; repeat++)
{ {
var repeatStartTime = StartTime + repeat * repeatDuration;
AddNested(new RepeatPoint AddNested(new RepeatPoint
{ {
RepeatIndex = repeat, RepeatIndex = repeat,
StartTime = repeatStartTime, RepeatDuration = RepeatDuration,
StartTime = StartTime + repeat * RepeatDuration,
Position = Curve.PositionAt(repeat % 2), Position = Curve.PositionAt(repeat % 2),
StackHeight = StackHeight, StackHeight = StackHeight,
Scale = Scale, Scale = Scale,

View File

@ -63,6 +63,7 @@ namespace osu.Game.Rulesets.Osu.Tests
AddStep("Fast Short Slider", () => testShortHighSpeed()); AddStep("Fast Short Slider", () => testShortHighSpeed());
AddStep("Fast Short Slider 1 Repeat", () => testShortHighSpeed(1)); AddStep("Fast Short Slider 1 Repeat", () => testShortHighSpeed(1));
AddStep("Fast Short Slider 2 Repeats", () => testShortHighSpeed(2)); AddStep("Fast Short Slider 2 Repeats", () => testShortHighSpeed(2));
AddStep("Fast Short Slider 6 Repeats", () => testShortHighSpeed(6));
AddStep("Perfect Curve", testCurve); AddStep("Perfect Curve", testCurve);
// TODO more curve types? // TODO more curve types?