mirror of
https://github.com/ppy/osu
synced 2025-01-19 04:20:59 +00:00
Improve snaking logic.
This commit is contained in:
parent
899c341fd3
commit
15096c2f00
@ -100,7 +100,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
private Path path;
|
private Path path;
|
||||||
|
|
||||||
double snakeDrawn = 0;
|
double? drawnProgress;
|
||||||
|
|
||||||
Slider slider;
|
Slider slider;
|
||||||
|
|
||||||
@ -134,26 +134,37 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
double snake = MathHelper.Clamp((Time.Current - slider.StartTime + 450) / 200, 0, 1);
|
double segmentSize = 1 / (slider.Curve.Length / 5);
|
||||||
if (snake != snakeDrawn)
|
double progress = MathHelper.Clamp((Time.Current - slider.StartTime + TIME_PREEMPT) / TIME_FADEIN, 0, 1);
|
||||||
|
|
||||||
|
if (progress != drawnProgress)
|
||||||
{
|
{
|
||||||
if (snake < snakeDrawn)
|
if (progress == 0)
|
||||||
{
|
{
|
||||||
//if we have gone backwards, just clear the path for now.
|
//if we have gone backwards, just clear the path for now.
|
||||||
snakeDrawn = 0;
|
drawnProgress = 0;
|
||||||
path.Positions.Clear();
|
path.Positions.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const double segment_size = 10;
|
if (drawnProgress == null)
|
||||||
|
|
||||||
while (snakeDrawn < snake)
|
|
||||||
{
|
{
|
||||||
snakeDrawn += segment_size;
|
drawnProgress = 0;
|
||||||
path.Positions.Add(slider.Curve.PositionAt(snake));
|
path.Positions.Add(slider.Curve.PositionAt(drawnProgress.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
snakeDrawn = snake;
|
while (drawnProgress + segmentSize < progress)
|
||||||
path.Positions.Add(slider.Curve.PositionAt(snake));
|
{
|
||||||
|
drawnProgress += segmentSize;
|
||||||
|
path.Positions.Add(slider.Curve.PositionAt(drawnProgress.Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (progress == 1 && drawnProgress != progress)
|
||||||
|
{
|
||||||
|
drawnProgress = progress;
|
||||||
|
path.Positions.Add(slider.Curve.PositionAt(drawnProgress.Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
path.Invalidate(Invalidation.DrawNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user