mirror of
https://github.com/ppy/osu
synced 2025-01-30 09:52:23 +00:00
Add better slider duration calculation using bpm and difficulty information.
This commit is contained in:
parent
a5651427f6
commit
bf63be0602
@ -2,18 +2,20 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Database;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public class Slider : OsuHitObject
|
||||
{
|
||||
public override double EndTime => StartTime + (RepeatCount + 1) * Curve.Length;
|
||||
public override double EndTime => StartTime + (RepeatCount + 1) * Curve.Length / VelocityAt(StartTime);
|
||||
|
||||
public double VelocityAt(double time) => 10000 / Beatmap.BeatLengthAt(time, true) * Beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier;
|
||||
|
||||
public int RepeatCount;
|
||||
|
||||
public SliderCurve Curve;
|
||||
|
||||
}
|
||||
|
||||
public class SliderCurve
|
||||
|
@ -16,5 +16,27 @@ namespace osu.Game.Beatmaps
|
||||
public List<HitObject> HitObjects { get; set; }
|
||||
public List<ControlPoint> ControlPoints { get; set; }
|
||||
public List<Color4> ComboColors { get; set; }
|
||||
|
||||
public double BeatLengthAt(double time, bool applyMultipliers = false)
|
||||
{
|
||||
int point = 0;
|
||||
int samplePoint = 0;
|
||||
|
||||
for (int i = 0; i < ControlPoints.Count; i++)
|
||||
if (ControlPoints[i].Time <= time)
|
||||
{
|
||||
if (ControlPoints[i].TimingChange)
|
||||
point = i;
|
||||
else
|
||||
samplePoint = i;
|
||||
}
|
||||
|
||||
double mult = 1;
|
||||
|
||||
if (applyMultipliers && samplePoint > point && ControlPoints[samplePoint].BeatLength < 0)
|
||||
mult = ControlPoints[samplePoint].VelocityAdjustment;
|
||||
|
||||
return ControlPoints[point].BeatLength * mult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -294,8 +294,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
break;
|
||||
case Section.HitObjects:
|
||||
var obj = parser?.Parse(val);
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
obj.Beatmap = beatmap;
|
||||
beatmap.HitObjects.Add(obj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -20,6 +21,8 @@ namespace osu.Game.Modes.Objects
|
||||
|
||||
public double Duration => EndTime - StartTime;
|
||||
|
||||
public Beatmap Beatmap;
|
||||
|
||||
public HitSampleInfo Sample;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user