1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Cleanup pass

This commit is contained in:
Andrei Zavatski 2023-12-05 02:48:11 +03:00
parent ec5c7d7830
commit 68907fe1ba

View File

@ -6,7 +6,6 @@ using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -78,30 +77,29 @@ namespace osu.Game.Rulesets.Osu.Mods
foreach (var drawable in playfield.HitObjectContainer.AliveObjects) foreach (var drawable in playfield.HitObjectContainer.AliveObjects)
{ {
if (drawable is not DrawableOsuHitObject d) switch (drawable)
continue;
switch (d)
{ {
case DrawableHitCircle: case DrawableHitCircle circle:
case DrawableSlider: processObject(time, circle, 0);
processObject(time, d); break;
case DrawableSlider slider:
processObject(time, slider, slider.HitObject.Duration);
break; break;
} }
} }
} }
private void processObject(double time, DrawableOsuHitObject drawable) private void processObject(double time, DrawableOsuHitObject drawable, double duration)
{ {
var hitObject = drawable.HitObject; var hitObject = drawable.HitObject;
double baseSpeed = MaxDepth.Value / hitObject.TimePreempt; double baseSpeed = MaxDepth.Value / hitObject.TimePreempt;
double hitObjectDuration = hitObject is Slider s ? s.Duration : 0.0; double offsetAfterStartTime = duration + hitObject.MaximumJudgementOffset + 500;
double offsetAfterStartTime = hitObjectDuration + hitObject.MaximumJudgementOffset + 500; double slowSpeed = Math.Min(-minDepth / offsetAfterStartTime, baseSpeed);
double slowSpeed = -minDepth / offsetAfterStartTime;
float decelerationDistance = MaxDepth.Value * 0.2f; double decelerationTime = hitObject.TimePreempt * 0.2;
double decelerationTime = (slowSpeed - baseSpeed) * 2 * decelerationDistance / (slowSpeed * slowSpeed - baseSpeed * baseSpeed); float decelerationDistance = (float)(decelerationTime * (baseSpeed + slowSpeed) * 0.5);
float z; float z;
@ -109,7 +107,7 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
double appearTime = hitObject.StartTime - hitObject.TimePreempt; double appearTime = hitObject.StartTime - hitObject.TimePreempt;
float fullDistance = decelerationDistance + (float)(baseSpeed * (hitObject.TimePreempt - decelerationTime)); float fullDistance = decelerationDistance + (float)(baseSpeed * (hitObject.TimePreempt - decelerationTime));
z = Interpolation.ValueAt(Math.Max(time, appearTime), fullDistance, decelerationDistance, appearTime, hitObject.StartTime - decelerationTime); z = fullDistance - (float)((Math.Max(time, appearTime) - appearTime) * baseSpeed);
} }
else if (time < hitObject.StartTime) else if (time < hitObject.StartTime)
{ {
@ -120,11 +118,11 @@ namespace osu.Game.Rulesets.Osu.Mods
else else
{ {
double endTime = hitObject.StartTime + offsetAfterStartTime; double endTime = hitObject.StartTime + offsetAfterStartTime;
z = Interpolation.ValueAt(Math.Min(time, endTime), 0f, minDepth, hitObject.StartTime, endTime); z = -(float)((Math.Min(time, endTime) - hitObject.StartTime) * slowSpeed);
} }
float scale = scaleForDepth(z); float scale = scaleForDepth(z);
drawable.Position = positionAtDepth(scale, hitObject.Position); drawable.Position = toPlayfieldPosition(scale, hitObject.Position);
drawable.Scale = new Vector2(scale); drawable.Scale = new Vector2(scale);
} }
@ -132,7 +130,7 @@ namespace osu.Game.Rulesets.Osu.Mods
private static float depthForScale(float scale) => 100 / scale + camera_position.Z; private static float depthForScale(float scale) => 100 / scale + camera_position.Z;
private static Vector2 positionAtDepth(float scale, Vector2 positionAtZeroDepth) private static Vector2 toPlayfieldPosition(float scale, Vector2 positionAtZeroDepth)
{ {
return (positionAtZeroDepth - camera_position.Xy) * scale + camera_position.Xy; return (positionAtZeroDepth - camera_position.Xy) * scale + camera_position.Xy;
} }