Implement angle assessment

This commit is contained in:
smoogipoo
2018-12-08 15:01:26 +09:00
parent e7da5b0400
commit f4eabacd15
4 changed files with 67 additions and 4 deletions

View File

@ -38,7 +38,13 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
// The first jump is formed by the first two hitobjects of the map. // The first jump is formed by the first two hitobjects of the map.
// If the map has less than two OsuHitObjects, the enumerator will not return anything. // If the map has less than two OsuHitObjects, the enumerator will not return anything.
for (int i = 1; i < objects.Count; i++) for (int i = 1; i < objects.Count; i++)
yield return new OsuDifficultyHitObject(objects[i], objects[i - 1], timeRate); {
var prev = objects[i - 1];
var current = objects[i];
var next = i < objects.Count - 1 ? objects[i + 1] : null;
yield return new OsuDifficultyHitObject(prev, current, next, timeRate);
}
} }
} }
} }

View File

@ -40,15 +40,19 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
/// </summary> /// </summary>
public double StrainTime { get; private set; } public double StrainTime { get; private set; }
public double? Angle { get; private set; }
private readonly OsuHitObject lastObject; private readonly OsuHitObject lastObject;
private readonly OsuHitObject nextObject;
private readonly double timeRate; private readonly double timeRate;
/// <summary> /// <summary>
/// Initializes the object calculating extra data required for difficulty calculation. /// Initializes the object calculating extra data required for difficulty calculation.
/// </summary> /// </summary>
public OsuDifficultyHitObject(OsuHitObject currentObject, OsuHitObject lastObject, double timeRate) public OsuDifficultyHitObject(OsuHitObject lastObject, OsuHitObject currentObject, OsuHitObject nextObject, double timeRate)
{ {
this.lastObject = lastObject; this.lastObject = lastObject;
this.nextObject = nextObject;
this.timeRate = timeRate; this.timeRate = timeRate;
BaseObject = currentObject; BaseObject = currentObject;
@ -82,6 +86,26 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
// Don't need to jump to reach spinners // Don't need to jump to reach spinners
if (!(BaseObject is Spinner)) if (!(BaseObject is Spinner))
JumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length; JumpDistance = (BaseObject.StackedPosition * scalingFactor - lastCursorPosition * scalingFactor).Length;
if (nextObject != null)
{
var endCursorPosition = BaseObject.StackedPosition;
var currentSlider = BaseObject as Slider;
if (currentSlider != null)
{
computeSliderCursorPosition(currentSlider);
endCursorPosition = currentSlider.LazyEndPosition ?? endCursorPosition;
}
Vector2 v1 = lastCursorPosition - BaseObject.StackedPosition;
Vector2 v2 = nextObject.StackedPosition - endCursorPosition;
float dot = Vector2.Dot(v1, v2);
float det = v1.X * v2.Y - v1.Y * v2.X;
Angle = Math.Atan2(det, dot);
}
} }
private void setTimingValues() private void setTimingValues()

View File

@ -15,6 +15,27 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
protected override double StrainDecayBase => 0.15; protected override double StrainDecayBase => 0.15;
protected override double StrainValueOf(OsuDifficultyHitObject current) protected override double StrainValueOf(OsuDifficultyHitObject current)
=> (Math.Pow(current.TravelDistance, 0.99) + Math.Pow(current.JumpDistance, 0.99)) / current.StrainTime; {
double angleBonus = 1.0;
if (current.Angle != null)
{
double angle = current.Angle.Value * 180 / Math.PI;
if (current.JumpDistance > SINGLE_SPACING_THRESHOLD)
{
if (angle > 75)
angleBonus = (angle / 45 - 75) / 2;
else if (angle > 120)
angleBonus = 0.5;
}
}
return angleBonus * (
Math.Pow(current.JumpDistance - SINGLE_SPACING_THRESHOLD, 0.99)
+ Math.Pow(current.TravelDistance, 0.99)
+ Math.Pow(current.JumpDistance, 0.99)
) / current.StrainTime;
}
} }
} }

View File

@ -27,7 +27,19 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
if (deltaTime < min_speed_bonus) if (deltaTime < min_speed_bonus)
speedBonus = 1 + Math.Pow((min_speed_bonus - deltaTime) / speed_balancing_factor, 2); speedBonus = 1 + Math.Pow((min_speed_bonus - deltaTime) / speed_balancing_factor, 2);
return speedBonus * (0.95 + Math.Pow(distance / SINGLE_SPACING_THRESHOLD, 4)) / current.StrainTime; double angleBonus = 1.0;
if (current.Angle != null)
{
double angle = current.Angle.Value * 180 / Math.PI;
if (angle < 135)
angleBonus = (135 - angle / 45) * 0.25 + 1.0;
else if (angle <= 90)
angleBonus = 1.25;
}
return angleBonus * (0.95 + Math.Pow(distance / SINGLE_SPACING_THRESHOLD, 4)) / current.StrainTime;
} }
} }
} }