mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:32:55 +08:00
Refactor opacity computation algorithm
This commit is contained in:
parent
ce095d6af6
commit
4463a26f4e
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -85,19 +86,33 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
|||||||
setDistances(clockRate);
|
setDistances(clockRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Opacity(double mapTime, bool hidden)
|
public double OpacityAt(double time, bool hidden)
|
||||||
{
|
{
|
||||||
double ms = BaseObject.StartTime - mapTime;
|
if (time > BaseObject.StartTime)
|
||||||
if (ms < 0)
|
{
|
||||||
|
// Consider a hitobject as being invisible when its start time is passed.
|
||||||
|
// In reality the hitobject will be visible beyond its start time up until its hittable window has passed,
|
||||||
|
// but this is an approximation and such a case is unlikely to be hit where this function is used.
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
double preemptTime = BaseObject.TimePreempt;
|
double fadeInStartTime = BaseObject.StartTime - BaseObject.TimePreempt;
|
||||||
double fadeInTime = BaseObject.TimeFadeIn;
|
double fadeInDuration = BaseObject.TimeFadeIn;
|
||||||
|
|
||||||
if (hidden)
|
if (hidden)
|
||||||
return Math.Clamp(Math.Min((1.0 - ms / preemptTime) * 2.5, (ms / preemptTime - 0.3) * (1.0 / 0.3)), 0.0, 1.0);
|
{
|
||||||
else
|
// Taken from OsuModHidden.
|
||||||
return Math.Clamp((preemptTime - ms) / fadeInTime, 0.0, 1.0);
|
double fadeOutStartTime = BaseObject.StartTime - BaseObject.TimePreempt + BaseObject.TimeFadeIn;
|
||||||
|
double fadeOutDuration = BaseObject.TimePreempt * OsuModHidden.FADE_OUT_DURATION_MULTIPLIER;
|
||||||
|
|
||||||
|
return Math.Min
|
||||||
|
(
|
||||||
|
Math.Clamp((time - fadeInStartTime) / fadeInDuration, 0.0, 1.0),
|
||||||
|
1.0 - Math.Clamp((time - fadeOutStartTime) / fadeOutDuration, 0.0, 1.0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.Clamp((time - fadeInStartTime) / fadeInDuration, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDistances(double clockRate)
|
private void setDistances(double clockRate)
|
||||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
|||||||
double stackNerf = Math.Min(1.0, (currentObj.LazyJumpDistance / scalingFactor) / 25.0);
|
double stackNerf = Math.Min(1.0, (currentObj.LazyJumpDistance / scalingFactor) / 25.0);
|
||||||
|
|
||||||
// Bonus based on how visible the object is.
|
// Bonus based on how visible the object is.
|
||||||
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - osuCurrent.Opacity(currentHitObject.StartTime, hidden));
|
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - osuCurrent.OpacityAt(currentHitObject.StartTime, hidden));
|
||||||
|
|
||||||
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
|
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn) };
|
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn) };
|
||||||
|
|
||||||
private const double fade_in_duration_multiplier = 0.4;
|
public const double FADE_IN_DURATION_MULTIPLIER = 0.4;
|
||||||
private const double fade_out_duration_multiplier = 0.3;
|
public const double FADE_OUT_DURATION_MULTIPLIER = 0.3;
|
||||||
|
|
||||||
protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner || hitObject is SpinnerTick);
|
protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner || hitObject is SpinnerTick);
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
static void applyFadeInAdjustment(OsuHitObject osuObject)
|
static void applyFadeInAdjustment(OsuHitObject osuObject)
|
||||||
{
|
{
|
||||||
osuObject.TimeFadeIn = osuObject.TimePreempt * fade_in_duration_multiplier;
|
osuObject.TimeFadeIn = osuObject.TimePreempt * FADE_IN_DURATION_MULTIPLIER;
|
||||||
foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>())
|
foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>())
|
||||||
applyFadeInAdjustment(nested);
|
applyFadeInAdjustment(nested);
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject)
|
static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject)
|
||||||
{
|
{
|
||||||
double fadeOutStartTime = hitObject.StartTime - hitObject.TimePreempt + hitObject.TimeFadeIn;
|
double fadeOutStartTime = hitObject.StartTime - hitObject.TimePreempt + hitObject.TimeFadeIn;
|
||||||
double fadeOutDuration = hitObject.TimePreempt * fade_out_duration_multiplier;
|
double fadeOutDuration = hitObject.TimePreempt * FADE_OUT_DURATION_MULTIPLIER;
|
||||||
|
|
||||||
// new duration from completed fade in to end (before fading out)
|
// new duration from completed fade in to end (before fading out)
|
||||||
double longFadeDuration = hitObject.GetEndTime() - fadeOutStartTime;
|
double longFadeDuration = hitObject.GetEndTime() - fadeOutStartTime;
|
||||||
|
Loading…
Reference in New Issue
Block a user