From b7fca88b4fb5504af28946ca92b48045310ea46e Mon Sep 17 00:00:00 2001 From: Damnae Date: Wed, 15 Feb 2017 18:55:49 +0100 Subject: [PATCH] Clearer slider Velocity and TickDistance calculations. --- osu.Game.Modes.Osu/Objects/Slider.cs | 11 +++++---- osu.Game/Beatmaps/Beatmap.cs | 35 ++++++++++++++++------------ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 30ad1c0180..f64d443bcc 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -4,6 +4,7 @@ using OpenTK; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Samples; +using osu.Game.Beatmaps.Timing; using System; using System.Collections.Generic; @@ -53,11 +54,13 @@ namespace osu.Game.Modes.Osu.Objects var baseDifficulty = beatmap.BeatmapInfo.BaseDifficulty; - var startBeatLength = beatmap.BeatLengthAt(StartTime); - var multipliedStartBeatLength = beatmap.BeatLengthAt(StartTime, true); + ControlPoint overridePoint; + ControlPoint timingPoint = beatmap.TimingPointAt(StartTime, out overridePoint); + var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1; + var baseVelocity = 100 * baseDifficulty.SliderMultiplier; - Velocity = 100 / multipliedStartBeatLength * baseDifficulty.SliderMultiplier; - TickDistance = (100 * baseDifficulty.SliderMultiplier) / baseDifficulty.SliderTickRate / (multipliedStartBeatLength / startBeatLength); + Velocity = baseVelocity / (timingPoint.BeatLength * velocityAdjustment); + TickDistance = baseVelocity / (baseDifficulty.SliderTickRate * velocityAdjustment); } public int RepeatCount = 1; diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 0914d1a2ad..d0ce290bad 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -26,26 +26,31 @@ namespace osu.Game.Beatmaps return 60000 / BeatLengthAt(time); } - public double BeatLengthAt(double time, bool applyMultipliers = false) + public double BeatLengthAt(double time) { - int point = 0; - int samplePoint = 0; + ControlPoint overridePoint; + ControlPoint timingPoint = TimingPointAt(time, out overridePoint); + return timingPoint.BeatLength; + } - for (int i = 0; i < ControlPoints.Count; i++) - if (ControlPoints[i].Time <= time) + public ControlPoint TimingPointAt(double time, out ControlPoint overridePoint) + { + overridePoint = null; + + ControlPoint timingPoint = null; + foreach (var controlPoint in ControlPoints) + if (controlPoint.Time <= time) { - if (ControlPoints[i].TimingChange) - point = i; - else - samplePoint = i; + if (controlPoint.TimingChange) + { + timingPoint = controlPoint; + overridePoint = null; + } + else overridePoint = controlPoint; } + else break; - double mult = 1; - - if (applyMultipliers && samplePoint > point) - mult = ControlPoints[samplePoint].VelocityAdjustment; - - return ControlPoints[point].BeatLength * mult; + return timingPoint; } } }