mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 11:23:00 +08:00
Make slider control points relative to start position
This commit is contained in:
parent
08bb25347c
commit
8c90abe0dc
@ -78,8 +78,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
bool isRepeatAtEnd = repeatPoint.RepeatIndex % 2 == 0;
|
||||
List<Vector2> curve = drawableSlider.Body.CurrentCurve;
|
||||
|
||||
var positionOnCurve = isRepeatAtEnd ? end : start;
|
||||
Position = positionOnCurve - curve[0] + drawableSlider.HitObject.StackOffset;
|
||||
Position = isRepeatAtEnd ? end : start;
|
||||
|
||||
if (curve.Count < 2)
|
||||
return;
|
||||
@ -90,10 +89,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
// find the next vector2 in the curve which is not equal to our current position to infer a rotation.
|
||||
for (int i = searchStart; i >= 0 && i < curve.Count; i += direction)
|
||||
{
|
||||
if (curve[i] == positionOnCurve)
|
||||
if (curve[i] == Position)
|
||||
continue;
|
||||
|
||||
Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(curve[i].Y - positionOnCurve.Y, curve[i].X - positionOnCurve.X));
|
||||
Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(curve[i].Y - Position.Y, curve[i].X - Position.X));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
@ -53,8 +54,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
AlwaysPresent = true,
|
||||
Alpha = 0
|
||||
},
|
||||
HeadCircle = new DrawableHitCircle(s.HeadCircle) { Position = s.HeadCircle.StackedPosition },
|
||||
tail = new DrawableSliderTail(s.TailCircle) { Position = s.TailCircle.StackedPosition }
|
||||
HeadCircle = new DrawableHitCircle(s.HeadCircle) { Position = s.HeadCircle.Position - s.Position },
|
||||
tail = new DrawableSliderTail(s.TailCircle) { Position = s.TailCircle.Position - s.Position }
|
||||
};
|
||||
|
||||
components.Add(Body);
|
||||
@ -67,10 +68,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
foreach (var tick in s.NestedHitObjects.OfType<SliderTick>())
|
||||
{
|
||||
var drawableTick = new DrawableSliderTick(tick)
|
||||
{
|
||||
Position = tick.StackedPosition
|
||||
};
|
||||
var drawableTick = new DrawableSliderTick(tick) { Position = tick.Position - s.Position };
|
||||
|
||||
ticks.Add(drawableTick);
|
||||
components.Add(drawableTick);
|
||||
@ -79,10 +77,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
|
||||
{
|
||||
var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this)
|
||||
{
|
||||
Position = repeatPoint.StackedPosition
|
||||
};
|
||||
var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this) { Position = repeatPoint.Position - s.Position };
|
||||
|
||||
repeatPoints.Add(drawableRepeatPoint);
|
||||
components.Add(drawableRepeatPoint);
|
||||
@ -109,7 +104,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
|
||||
//todo: we probably want to reconsider this before adding scoring, but it looks and feels nice.
|
||||
if (!HeadCircle.IsHit)
|
||||
HeadCircle.Position = slider.StackedPositionAt(completionProgress);
|
||||
HeadCircle.Position = slider.PositionAt(completionProgress);
|
||||
|
||||
foreach (var c in components.OfType<ISliderProgress>()) c.UpdateProgress(completionProgress);
|
||||
foreach (var c in components.OfType<ITrackSnaking>()) c.UpdateSnakingPosition(slider.Curve.PositionAt(Body.SnakedStart ?? 0), slider.Curve.PositionAt(Body.SnakedEnd ?? 0));
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
@ -141,7 +142,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
|
||||
public void UpdateProgress(double completionProgress)
|
||||
{
|
||||
Position = slider.StackedPositionAt(completionProgress);
|
||||
Position = slider.PositionAt(completionProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
public double EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity;
|
||||
public double Duration => EndTime - StartTime;
|
||||
|
||||
public Vector2 StackedPositionAt(double t) => this.PositionAt(t) + StackOffset;
|
||||
public override Vector2 EndPosition => this.PositionAt(1);
|
||||
public Vector2 StackedPositionAt(double t) => StackedPosition + this.PositionAt(t);
|
||||
public override Vector2 EndPosition => Position + this.PositionAt(1);
|
||||
|
||||
public SliderCurve Curve { get; } = new SliderCurve();
|
||||
|
||||
@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
HeadCircle = new HitCircle
|
||||
{
|
||||
StartTime = StartTime,
|
||||
Position = this.PositionAt(0),
|
||||
Position = Position,
|
||||
IndexInCurrentCombo = IndexInCurrentCombo,
|
||||
ComboColour = ComboColour,
|
||||
Samples = Samples,
|
||||
@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
TailCircle = new HitCircle
|
||||
{
|
||||
StartTime = EndTime,
|
||||
Position = this.PositionAt(1),
|
||||
Position = EndPosition,
|
||||
IndexInCurrentCombo = IndexInCurrentCombo,
|
||||
ComboColour = ComboColour
|
||||
};
|
||||
@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
SpanIndex = span,
|
||||
SpanStartTime = spanStartTime,
|
||||
StartTime = spanStartTime + timeProgress * SpanDuration,
|
||||
Position = Curve.PositionAt(distanceProgress) - Curve.PositionAt(0),
|
||||
Position = Position + Curve.PositionAt(distanceProgress),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
@ -175,7 +175,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
RepeatIndex = repeatIndex,
|
||||
SpanDuration = SpanDuration,
|
||||
StartTime = StartTime + repeat * SpanDuration,
|
||||
Position = Curve.PositionAt(repeat % 2) - Curve.PositionAt(0),
|
||||
Position = Position + Curve.PositionAt(repeat % 2),
|
||||
StackHeight = StackHeight,
|
||||
Scale = Scale,
|
||||
ComboColour = ComboColour,
|
||||
@ -184,10 +184,4 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SliderExtensions
|
||||
{
|
||||
public static Vector2 PositionAt(this Slider slider, double progress)
|
||||
=> ((IHasCurve)slider).PositionAt(progress) - slider.Curve.PositionAt(0);
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,11 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
}
|
||||
else if ((type & ConvertHitObjectType.Slider) > 0)
|
||||
{
|
||||
var pos = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
||||
|
||||
CurveType curveType = CurveType.Catmull;
|
||||
double length = 0;
|
||||
var points = new List<Vector2> { new Vector2(int.Parse(split[0]), int.Parse(split[1])) };
|
||||
var points = new List<Vector2> { Vector2.Zero };
|
||||
|
||||
string[] pointsplit = split[5].Split('|');
|
||||
foreach (string t in pointsplit)
|
||||
@ -69,7 +71,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
}
|
||||
|
||||
string[] temp = t.Split(':');
|
||||
points.Add(new Vector2((int)Convert.ToDouble(temp[0], CultureInfo.InvariantCulture), (int)Convert.ToDouble(temp[1], CultureInfo.InvariantCulture)));
|
||||
points.Add(new Vector2((int)Convert.ToDouble(temp[0], CultureInfo.InvariantCulture), (int)Convert.ToDouble(temp[1], CultureInfo.InvariantCulture)) - pos);
|
||||
}
|
||||
|
||||
int repeatCount = Convert.ToInt32(split[6], CultureInfo.InvariantCulture);
|
||||
@ -134,7 +136,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
||||
for (int i = 0; i < nodes; i++)
|
||||
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i]));
|
||||
|
||||
result = CreateSlider(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, points, length, curveType, repeatCount, nodeSamples);
|
||||
result = CreateSlider(pos, combo, points, length, curveType, repeatCount, nodeSamples);
|
||||
}
|
||||
else if ((type & ConvertHitObjectType.Spinner) > 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user