mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:20:04 +08:00
Merge branch 'aim-refactor-slider' into aim-refactor-velocity
This commit is contained in:
commit
beea8e8ba6
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
@ -14,6 +15,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
{
|
||||
private const int normalized_radius = 50; // Change radius to 50 to make 100 the diameter. Easier for mental maths.
|
||||
private const int min_delta_time = 25;
|
||||
private const float maximum_slider_radius = normalized_radius * 2.4f;
|
||||
private const float assumed_slider_radius = normalized_radius * 1.6f;
|
||||
|
||||
protected new OsuHitObject BaseObject => (OsuHitObject)base.BaseObject;
|
||||
|
||||
@ -89,67 +92,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
if (lastObject is Slider lastSlider)
|
||||
{
|
||||
computeSliderCursorPosition(lastSlider);
|
||||
TravelDistance = 0;
|
||||
TravelDistance = lastSlider.LazyTravelDistance;
|
||||
TravelTime = Math.Max(lastSlider.LazyTravelTime / clockRate, min_delta_time);
|
||||
MovementTime = Math.Max(StrainTime - TravelTime, min_delta_time);
|
||||
MovementDistance = Vector2.Subtract(lastSlider.TailCircle.StackedPosition, BaseObject.StackedPosition).Length * scalingFactor;
|
||||
|
||||
int repeatCount = 0;
|
||||
|
||||
Vector2 currSliderPosition = ((OsuHitObject)lastSlider.NestedHitObjects[0]).StackedPosition;
|
||||
|
||||
for (int i = 1; i < lastSlider.NestedHitObjects.Count; i++)
|
||||
{
|
||||
Vector2 currSlider = Vector2.Subtract(((OsuHitObject)lastSlider.NestedHitObjects[i]).StackedPosition, currSliderPosition);
|
||||
double currSliderLength = currSlider.Length * scalingFactor;
|
||||
|
||||
if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderEndCircle && !((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderRepeat))
|
||||
{
|
||||
Vector2 possSlider = Vector2.Subtract((Vector2)lastSlider.LazyEndPosition, currSliderPosition);
|
||||
if (possSlider.Length < currSlider.Length)
|
||||
currSlider = possSlider; // Take the least distance from slider end vs lazy end.
|
||||
|
||||
currSliderLength = currSlider.Length * scalingFactor;
|
||||
}
|
||||
|
||||
if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderTick)
|
||||
{
|
||||
if (currSliderLength > 120)
|
||||
{
|
||||
currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 120) / currSliderLength)));
|
||||
currSliderLength *= (currSliderLength - 120) / currSliderLength;
|
||||
}
|
||||
else
|
||||
currSliderLength = 0;
|
||||
}
|
||||
else if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderRepeat)
|
||||
{
|
||||
if (currSliderLength > 50)
|
||||
{
|
||||
currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 50) / currSliderLength)));
|
||||
currSliderLength *= (currSliderLength - 50) / currSliderLength;
|
||||
}
|
||||
else
|
||||
currSliderLength = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currSliderLength > 0)
|
||||
{
|
||||
currSliderPosition = Vector2.Add(currSliderPosition, Vector2.Multiply(currSlider, (float)((currSliderLength - 0) / currSliderLength)));
|
||||
currSliderLength *= (currSliderLength - 0) / currSliderLength;
|
||||
}
|
||||
else
|
||||
currSliderLength = 0;
|
||||
}
|
||||
|
||||
if ((OsuHitObject)lastSlider.NestedHitObjects[i] is SliderRepeat)
|
||||
repeatCount++;
|
||||
|
||||
TravelDistance += currSliderLength;
|
||||
}
|
||||
|
||||
TravelDistance *= Math.Pow(1 + repeatCount / 2.5, 1.0 / 2.5); // Bonus for repeat sliders until a better per nested object strain system can be achieved.
|
||||
|
||||
// Jump distance from the slider tail to the next object, as opposed to the lazy position of JumpDistance.
|
||||
float tailJumpDistance = Vector2.Subtract(lastSlider.TailCircle.StackedPosition, BaseObject.StackedPosition).Length * scalingFactor;
|
||||
@ -158,8 +103,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
// such that they're not jumping from the lazy position but rather from very close to (or the end of) the slider.
|
||||
// In such cases, a leniency is applied by also considering the jump distance from the tail of the slider, and taking the minimum jump distance.
|
||||
// Additional distance is removed based on position of jump relative to slider follow circle radius.
|
||||
// JumpDistance is 50 since follow radius = 1.4 * radius. tailJumpDistance is 120 since the full distance of radial leniency is still possible.
|
||||
MovementDistance = Math.Max(0, Math.Min(JumpDistance - 50, tailJumpDistance - 120));
|
||||
// JumpDistance is the distance beyond the s. tailJumpDistance is maximum_slider_radius since the full distance of radial leniency is still possible.
|
||||
MovementDistance = Math.Max(0, Math.Min(JumpDistance - (maximum_slider_radius - assumed_slider_radius), tailJumpDistance - maximum_slider_radius));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -186,37 +131,64 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
||||
if (slider.LazyEndPosition != null)
|
||||
return;
|
||||
|
||||
slider.LazyEndPosition = slider.StackedPosition;
|
||||
slider.LazyTravelTime = slider.NestedHitObjects[slider.NestedHitObjects.Count - 1].StartTime - slider.StartTime;
|
||||
|
||||
float approxFollowCircleRadius = (float)(slider.Radius * 1.4); // using 1.4 to better follow the real movement of a cursor.
|
||||
var computeVertex = new Action<double>(t =>
|
||||
{
|
||||
double progress = (t - slider.StartTime) / slider.SpanDuration;
|
||||
if (progress % 2 >= 1)
|
||||
progress = 1 - progress % 1;
|
||||
double endTimeMin = slider.LazyTravelTime / slider.SpanDuration;
|
||||
if (endTimeMin % 2 >= 1)
|
||||
endTimeMin = 1 - endTimeMin % 1;
|
||||
else
|
||||
progress %= 1;
|
||||
endTimeMin %= 1;
|
||||
|
||||
// ReSharper disable once PossibleInvalidOperationException (bugged in current r# version)
|
||||
var diff = slider.StackedPosition + slider.Path.PositionAt(progress) - slider.LazyEndPosition.Value;
|
||||
float dist = diff.Length;
|
||||
slider.LazyEndPosition = slider.StackedPosition + slider.Path.PositionAt(endTimeMin); // temporary lazy end position until a real result can be derived.
|
||||
var currCursorPosition = slider.StackedPosition;
|
||||
double scalingFactor = normalized_radius / slider.Radius; // lazySliderDistance is coded to be sensitive to scaling, this makes the maths easier with the thresholds being used.
|
||||
|
||||
slider.LazyTravelTime = t - slider.StartTime;
|
||||
for (int i = 1; i < slider.NestedHitObjects.Count; i++)
|
||||
{
|
||||
var currMovementObj = (OsuHitObject)slider.NestedHitObjects[i];
|
||||
|
||||
if (dist > approxFollowCircleRadius)
|
||||
Vector2 currMovement = Vector2.Subtract(currMovementObj.StackedPosition, currCursorPosition);
|
||||
double currMovementLength = scalingFactor * currMovement.Length;
|
||||
|
||||
if (i == slider.NestedHitObjects.Count - 1)
|
||||
{
|
||||
// The cursor would be outside the follow circle, we need to move it
|
||||
diff.Normalize(); // Obtain direction of diff
|
||||
dist -= approxFollowCircleRadius;
|
||||
slider.LazyEndPosition += diff * dist;
|
||||
slider.LazyTravelDistance += dist;
|
||||
}
|
||||
});
|
||||
// The end of a slider has special aim rules due to the relaxed time constraint on position.
|
||||
// There is both a lazy end position as well as the actual end slider position. We assume the player takes the simpler movement.
|
||||
// For sliders that are circular, the lazy end position may actually be farther away than the sliders true end.
|
||||
// This code is designed to prevent buffing situations where lazy end is actually a less efficient movement.
|
||||
Vector2 lazyMovement = Vector2.Subtract((Vector2)slider.LazyEndPosition, currCursorPosition);
|
||||
|
||||
// Skip the head circle
|
||||
var scoringTimes = slider.NestedHitObjects.Skip(1).Select(t => t.StartTime);
|
||||
foreach (double time in scoringTimes)
|
||||
computeVertex(time);
|
||||
if (lazyMovement.Length < currMovement.Length)
|
||||
currMovement = lazyMovement;
|
||||
|
||||
currMovementLength = scalingFactor * currMovement.Length;
|
||||
|
||||
if (currMovementLength > assumed_slider_radius)
|
||||
{
|
||||
// Calculate the vector movement, regardless of final location to get the true lazy end position.
|
||||
currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - assumed_slider_radius) / currMovementLength)));
|
||||
currMovementLength *= (currMovementLength - assumed_slider_radius) / currMovementLength;
|
||||
slider.LazyTravelDistance += (float)currMovementLength;
|
||||
}
|
||||
slider.LazyEndPosition = currCursorPosition;
|
||||
}
|
||||
else if (currMovementObj is SliderRepeat && currMovementLength > normalized_radius)
|
||||
{
|
||||
// For a slider repeat, assume a tighter movement threshold to better assess repeat sliders.
|
||||
currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - normalized_radius) / currMovementLength)));
|
||||
currMovementLength *= (currMovementLength - normalized_radius) / currMovementLength;
|
||||
slider.LazyTravelDistance += (float)currMovementLength;
|
||||
}
|
||||
else if (currMovementLength > assumed_slider_radius)
|
||||
{
|
||||
// For a slider ticks, use the assumed slider radius for a more accurate movement assessment.
|
||||
currCursorPosition = Vector2.Add(currCursorPosition, Vector2.Multiply(currMovement, (float)((currMovementLength - assumed_slider_radius) / currMovementLength)));
|
||||
currMovementLength *= (currMovementLength - assumed_slider_radius) / currMovementLength;
|
||||
slider.LazyTravelDistance += (float)currMovementLength;
|
||||
}
|
||||
}
|
||||
|
||||
slider.LazyTravelDistance *= (float)Math.Pow(1 + slider.RepeatCount / 2.5, 1.0 / 2.5); // Bonus for repeat sliders until a better per nested object strain system can be achieved.
|
||||
}
|
||||
|
||||
private Vector2 getEndCursorPosition(OsuHitObject hitObject)
|
||||
|
Loading…
Reference in New Issue
Block a user