mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +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;
|
bool isRepeatAtEnd = repeatPoint.RepeatIndex % 2 == 0;
|
||||||
List<Vector2> curve = drawableSlider.Body.CurrentCurve;
|
List<Vector2> curve = drawableSlider.Body.CurrentCurve;
|
||||||
|
|
||||||
var positionOnCurve = isRepeatAtEnd ? end : start;
|
Position = isRepeatAtEnd ? end : start;
|
||||||
Position = positionOnCurve - curve[0] + drawableSlider.HitObject.StackOffset;
|
|
||||||
|
|
||||||
if (curve.Count < 2)
|
if (curve.Count < 2)
|
||||||
return;
|
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.
|
// 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)
|
for (int i = searchStart; i >= 0 && i < curve.Count; i += direction)
|
||||||
{
|
{
|
||||||
if (curve[i] == positionOnCurve)
|
if (curve[i] == Position)
|
||||||
continue;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Game.Rulesets.Osu.Judgements;
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
@ -53,8 +54,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
AlwaysPresent = true,
|
AlwaysPresent = true,
|
||||||
Alpha = 0
|
Alpha = 0
|
||||||
},
|
},
|
||||||
HeadCircle = new DrawableHitCircle(s.HeadCircle) { Position = s.HeadCircle.StackedPosition },
|
HeadCircle = new DrawableHitCircle(s.HeadCircle) { Position = s.HeadCircle.Position - s.Position },
|
||||||
tail = new DrawableSliderTail(s.TailCircle) { Position = s.TailCircle.StackedPosition }
|
tail = new DrawableSliderTail(s.TailCircle) { Position = s.TailCircle.Position - s.Position }
|
||||||
};
|
};
|
||||||
|
|
||||||
components.Add(Body);
|
components.Add(Body);
|
||||||
@ -67,10 +68,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
foreach (var tick in s.NestedHitObjects.OfType<SliderTick>())
|
foreach (var tick in s.NestedHitObjects.OfType<SliderTick>())
|
||||||
{
|
{
|
||||||
var drawableTick = new DrawableSliderTick(tick)
|
var drawableTick = new DrawableSliderTick(tick) { Position = tick.Position - s.Position };
|
||||||
{
|
|
||||||
Position = tick.StackedPosition
|
|
||||||
};
|
|
||||||
|
|
||||||
ticks.Add(drawableTick);
|
ticks.Add(drawableTick);
|
||||||
components.Add(drawableTick);
|
components.Add(drawableTick);
|
||||||
@ -79,10 +77,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
|
foreach (var repeatPoint in s.NestedHitObjects.OfType<RepeatPoint>())
|
||||||
{
|
{
|
||||||
var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this)
|
var drawableRepeatPoint = new DrawableRepeatPoint(repeatPoint, this) { Position = repeatPoint.Position - s.Position };
|
||||||
{
|
|
||||||
Position = repeatPoint.StackedPosition
|
|
||||||
};
|
|
||||||
|
|
||||||
repeatPoints.Add(drawableRepeatPoint);
|
repeatPoints.Add(drawableRepeatPoint);
|
||||||
components.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.
|
//todo: we probably want to reconsider this before adding scoring, but it looks and feels nice.
|
||||||
if (!HeadCircle.IsHit)
|
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<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));
|
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.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
@ -141,7 +142,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
public void UpdateProgress(double completionProgress)
|
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 EndTime => StartTime + this.SpanCount() * Curve.Distance / Velocity;
|
||||||
public double Duration => EndTime - StartTime;
|
public double Duration => EndTime - StartTime;
|
||||||
|
|
||||||
public Vector2 StackedPositionAt(double t) => this.PositionAt(t) + StackOffset;
|
public Vector2 StackedPositionAt(double t) => StackedPosition + this.PositionAt(t);
|
||||||
public override Vector2 EndPosition => this.PositionAt(1);
|
public override Vector2 EndPosition => Position + this.PositionAt(1);
|
||||||
|
|
||||||
public SliderCurve Curve { get; } = new SliderCurve();
|
public SliderCurve Curve { get; } = new SliderCurve();
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
HeadCircle = new HitCircle
|
HeadCircle = new HitCircle
|
||||||
{
|
{
|
||||||
StartTime = StartTime,
|
StartTime = StartTime,
|
||||||
Position = this.PositionAt(0),
|
Position = Position,
|
||||||
IndexInCurrentCombo = IndexInCurrentCombo,
|
IndexInCurrentCombo = IndexInCurrentCombo,
|
||||||
ComboColour = ComboColour,
|
ComboColour = ComboColour,
|
||||||
Samples = Samples,
|
Samples = Samples,
|
||||||
@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
TailCircle = new HitCircle
|
TailCircle = new HitCircle
|
||||||
{
|
{
|
||||||
StartTime = EndTime,
|
StartTime = EndTime,
|
||||||
Position = this.PositionAt(1),
|
Position = EndPosition,
|
||||||
IndexInCurrentCombo = IndexInCurrentCombo,
|
IndexInCurrentCombo = IndexInCurrentCombo,
|
||||||
ComboColour = ComboColour
|
ComboColour = ComboColour
|
||||||
};
|
};
|
||||||
@ -156,7 +156,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
SpanIndex = span,
|
SpanIndex = span,
|
||||||
SpanStartTime = spanStartTime,
|
SpanStartTime = spanStartTime,
|
||||||
StartTime = spanStartTime + timeProgress * SpanDuration,
|
StartTime = spanStartTime + timeProgress * SpanDuration,
|
||||||
Position = Curve.PositionAt(distanceProgress) - Curve.PositionAt(0),
|
Position = Position + Curve.PositionAt(distanceProgress),
|
||||||
StackHeight = StackHeight,
|
StackHeight = StackHeight,
|
||||||
Scale = Scale,
|
Scale = Scale,
|
||||||
ComboColour = ComboColour,
|
ComboColour = ComboColour,
|
||||||
@ -175,7 +175,7 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
RepeatIndex = repeatIndex,
|
RepeatIndex = repeatIndex,
|
||||||
SpanDuration = SpanDuration,
|
SpanDuration = SpanDuration,
|
||||||
StartTime = StartTime + repeat * SpanDuration,
|
StartTime = StartTime + repeat * SpanDuration,
|
||||||
Position = Curve.PositionAt(repeat % 2) - Curve.PositionAt(0),
|
Position = Position + Curve.PositionAt(repeat % 2),
|
||||||
StackHeight = StackHeight,
|
StackHeight = StackHeight,
|
||||||
Scale = Scale,
|
Scale = Scale,
|
||||||
ComboColour = ComboColour,
|
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)
|
else if ((type & ConvertHitObjectType.Slider) > 0)
|
||||||
{
|
{
|
||||||
|
var pos = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
||||||
|
|
||||||
CurveType curveType = CurveType.Catmull;
|
CurveType curveType = CurveType.Catmull;
|
||||||
double length = 0;
|
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('|');
|
string[] pointsplit = split[5].Split('|');
|
||||||
foreach (string t in pointsplit)
|
foreach (string t in pointsplit)
|
||||||
@ -69,7 +71,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
}
|
}
|
||||||
|
|
||||||
string[] temp = t.Split(':');
|
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);
|
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++)
|
for (int i = 0; i < nodes; i++)
|
||||||
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[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)
|
else if ((type & ConvertHitObjectType.Spinner) > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user