1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Merge branch 'master' into fix-autoplay-tests

This commit is contained in:
Dan Balasescu 2019-03-08 12:14:40 +09:00 committed by GitHub
commit 101009c92e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 63 additions and 65 deletions

View File

@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
path = new SmoothPath path = new SmoothPath
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
PathWidth = 1 PathRadius = 1
}, },
marker = new CircularContainer marker = new CircularContainer
{ {

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
InternalChild = body = new ManualSliderBody InternalChild = body = new ManualSliderBody
{ {
AccentColour = Color4.Transparent, AccentColour = Color4.Transparent,
PathWidth = slider.Scale * 64 PathRadius = slider.Scale * 64
}; };
} }
@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
body.BorderColour = colours.Yellow; body.BorderColour = colours.Yellow;
PositionBindable.BindValueChanged(_ => updatePosition(), true); PositionBindable.BindValueChanged(_ => updatePosition(), true);
ScaleBindable.BindValueChanged(scale => body.PathWidth = scale.NewValue * 64, true); ScaleBindable.BindValueChanged(scale => body.PathRadius = scale.NewValue * 64, true);
} }
private void updatePosition() => Position = slider.StackedPosition; private void updatePosition() => Position = slider.StackedPosition;

View File

@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
Body = new SnakingSliderBody(s) Body = new SnakingSliderBody(s)
{ {
PathWidth = s.Scale * 64, PathRadius = s.Scale * 64,
}, },
ticks = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both }, ticks = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both },
repeatPoints = new Container<DrawableRepeatPoint> { RelativeSizeAxes = Axes.Both }, repeatPoints = new Container<DrawableRepeatPoint> { RelativeSizeAxes = Axes.Both },
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition); positionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
scaleBindable.BindValueChanged(scale => scaleBindable.BindValueChanged(scale =>
{ {
Body.PathWidth = scale.NewValue * 64; Body.PathRadius = scale.NewValue * 64;
Ball.Scale = new Vector2(scale.NewValue); Ball.Scale = new Vector2(scale.NewValue);
}); });

View File

@ -19,10 +19,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private readonly BufferedContainer container; private readonly BufferedContainer container;
public float PathWidth public float PathRadius
{ {
get => path.PathWidth; get => path.PathRadius;
set => path.PathWidth = value; set => path.PathRadius = value;
} }
/// <summary> /// <summary>

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
{ {
private int currentIndex; private int currentIndex;
private Shader shader; private IShader shader;
private Texture texture; private Texture texture;
private Vector2 size => texture.Size * Scale; private Vector2 size => texture.Size * Scale;
@ -35,7 +35,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public override bool IsPresent => true; public override bool IsPresent => true;
private readonly TrailDrawNodeSharedData trailDrawNodeSharedData = new TrailDrawNodeSharedData();
private const int max_sprites = 2048; private const int max_sprites = 2048;
private readonly TrailPart[] parts = new TrailPart[max_sprites]; private readonly TrailPart[] parts = new TrailPart[max_sprites];
@ -55,7 +54,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
tNode.Texture = texture; tNode.Texture = texture;
tNode.Size = size; tNode.Size = size;
tNode.Time = time; tNode.Time = time;
tNode.Shared = trailDrawNodeSharedData;
for (int i = 0; i < parts.Length; ++i) for (int i = 0; i < parts.Length; ++i)
if (parts[i].InvalidationID > tNode.Parts[i].InvalidationID) if (parts[i].InvalidationID > tNode.Parts[i].InvalidationID)
@ -81,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ShaderManager shaders, TextureStore textures) private void load(ShaderManager shaders, TextureStore textures)
{ {
shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE); shader = shaders.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
texture = textures.Get(@"Cursor/cursortrail"); texture = textures.Get(@"Cursor/cursortrail");
Scale = new Vector2(1 / texture.ScaleAdjust); Scale = new Vector2(1 / texture.ScaleAdjust);
} }
@ -167,22 +165,18 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public bool WasUpdated; public bool WasUpdated;
} }
private class TrailDrawNodeSharedData
{
public VertexBuffer<TexturedTrailVertex> VertexBuffer;
}
private class TrailDrawNode : DrawNode private class TrailDrawNode : DrawNode
{ {
public Shader Shader; public IShader Shader;
public Texture Texture; public Texture Texture;
public float Time; public float Time;
public TrailDrawNodeSharedData Shared;
public readonly TrailPart[] Parts = new TrailPart[max_sprites]; public readonly TrailPart[] Parts = new TrailPart[max_sprites];
public Vector2 Size; public Vector2 Size;
private readonly VertexBuffer<TexturedTrailVertex> vertexBuffer = new QuadVertexBuffer<TexturedTrailVertex>(max_sprites, BufferUsageHint.DynamicDraw);
public TrailDrawNode() public TrailDrawNode()
{ {
for (int i = 0; i < max_sprites; i++) for (int i = 0; i < max_sprites; i++)
@ -194,9 +188,6 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public override void Draw(Action<TexturedVertex2D> vertexAction) public override void Draw(Action<TexturedVertex2D> vertexAction)
{ {
if (Shared.VertexBuffer == null)
Shared.VertexBuffer = new QuadVertexBuffer<TexturedTrailVertex>(max_sprites, BufferUsageHint.DynamicDraw);
Shader.GetUniform<float>("g_FadeClock").UpdateValue(ref Time); Shader.GetUniform<float>("g_FadeClock").UpdateValue(ref Time);
int updateStart = -1, updateEnd = 0; int updateStart = -1, updateEnd = 0;
@ -218,7 +209,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
new Quad(pos.X - Size.X / 2, pos.Y - Size.Y / 2, Size.X, Size.Y), new Quad(pos.X - Size.X / 2, pos.Y - Size.Y / 2, Size.X, Size.Y),
DrawColourInfo.Colour, DrawColourInfo.Colour,
null, null,
v => Shared.VertexBuffer.Vertices[end++] = new TexturedTrailVertex v => vertexBuffer.Vertices[end++] = new TexturedTrailVertex
{ {
Position = v.Position, Position = v.Position,
TexturePosition = v.TexturePosition, TexturePosition = v.TexturePosition,
@ -230,24 +221,31 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
} }
else if (updateStart != -1) else if (updateStart != -1)
{ {
Shared.VertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4); vertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4);
updateStart = -1; updateStart = -1;
} }
} }
// Update all remaining vertices that have been changed. // Update all remaining vertices that have been changed.
if (updateStart != -1) if (updateStart != -1)
Shared.VertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4); vertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4);
base.Draw(vertexAction); base.Draw(vertexAction);
Shader.Bind(); Shader.Bind();
Texture.TextureGL.Bind(); Texture.TextureGL.Bind();
Shared.VertexBuffer.Draw(); vertexBuffer.Draw();
Shader.Unbind(); Shader.Unbind();
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
vertexBuffer.Dispose();
}
} }
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]

View File

@ -113,6 +113,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
[TestCase(normal)] [TestCase(normal)]
[TestCase(marathon)] [TestCase(marathon)]
[Ignore("temporarily disabled pending DeepEqual fix (https://github.com/jamesfoster/DeepEqual/pull/35)")]
// Currently fails: // Currently fails:
// [TestCase(with_sb)] // [TestCase(with_sb)]
public void TestParity(string beatmap) public void TestParity(string beatmap)

View File

@ -64,7 +64,7 @@ namespace osu.Game.Graphics.Backgrounds
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default); private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
private Shader shader; private IShader shader;
private readonly Texture texture; private readonly Texture texture;
public Triangles() public Triangles()
@ -75,7 +75,7 @@ namespace osu.Game.Graphics.Backgrounds
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ShaderManager shaders) private void load(ShaderManager shaders)
{ {
shader = shaders?.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED); shader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -180,8 +180,6 @@ namespace osu.Game.Graphics.Backgrounds
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode(); protected override DrawNode CreateDrawNode() => new TrianglesDrawNode();
private readonly TrianglesDrawNodeSharedData sharedData = new TrianglesDrawNodeSharedData();
protected override void ApplyDrawNode(DrawNode node) protected override void ApplyDrawNode(DrawNode node)
{ {
base.ApplyDrawNode(node); base.ApplyDrawNode(node);
@ -191,27 +189,21 @@ namespace osu.Game.Graphics.Backgrounds
trianglesNode.Shader = shader; trianglesNode.Shader = shader;
trianglesNode.Texture = texture; trianglesNode.Texture = texture;
trianglesNode.Size = DrawSize; trianglesNode.Size = DrawSize;
trianglesNode.Shared = sharedData;
trianglesNode.Parts.Clear(); trianglesNode.Parts.Clear();
trianglesNode.Parts.AddRange(parts); trianglesNode.Parts.AddRange(parts);
} }
private class TrianglesDrawNodeSharedData
{
public readonly LinearBatch<TexturedVertex2D> VertexBatch = new LinearBatch<TexturedVertex2D>(100 * 3, 10, PrimitiveType.Triangles);
}
private class TrianglesDrawNode : DrawNode private class TrianglesDrawNode : DrawNode
{ {
public Shader Shader; public IShader Shader;
public Texture Texture; public Texture Texture;
public TrianglesDrawNodeSharedData Shared;
public readonly List<TriangleParticle> Parts = new List<TriangleParticle>(); public readonly List<TriangleParticle> Parts = new List<TriangleParticle>();
public Vector2 Size; public Vector2 Size;
private readonly LinearBatch<TexturedVertex2D> vertexBatch = new LinearBatch<TexturedVertex2D>(100 * 3, 10, PrimitiveType.Triangles);
public override void Draw(Action<TexturedVertex2D> vertexAction) public override void Draw(Action<TexturedVertex2D> vertexAction)
{ {
base.Draw(vertexAction); base.Draw(vertexAction);
@ -239,12 +231,19 @@ namespace osu.Game.Graphics.Backgrounds
triangle, triangle,
colourInfo, colourInfo,
null, null,
Shared.VertexBatch.AddAction, vertexBatch.AddAction,
Vector2.Divide(localInflationAmount, size)); Vector2.Divide(localInflationAmount, size));
} }
Shader.Unbind(); Shader.Unbind();
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
vertexBatch.Dispose();
}
} }
protected struct TriangleParticle : IComparable<TriangleParticle> protected struct TriangleParticle : IComparable<TriangleParticle>

View File

@ -69,7 +69,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
Masking = true, Masking = true,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = path = new SmoothPath { RelativeSizeAxes = Axes.Both, PathWidth = 1 } Child = path = new SmoothPath { RelativeSizeAxes = Axes.Both, PathRadius = 1 }
}); });
} }
@ -102,9 +102,10 @@ namespace osu.Game.Graphics.UserInterface
for (int i = 0; i < values.Length; i++) for (int i = 0; i < values.Length; i++)
{ {
float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1; // Make sure that we are accounting for path width when calculating vertex positions
float y = GetYPosition(values[i]) * DrawHeight - 1; // We need to apply 2x the path radius to account for it because the full diameter of the line accounts into height
// the -1 is for inner offset in path (actually -PathWidth) float x = (i + count - values.Length) / (float)(count - 1) * (DrawWidth - 2 * path.PathRadius);
float y = GetYPosition(values[i]) * (DrawHeight - 2 * path.PathRadius);
path.AddVertex(new Vector2(x, y)); path.AddVertex(new Vector2(x, y));
} }
} }

View File

@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Mods
public abstract class Flashlight : Drawable public abstract class Flashlight : Drawable
{ {
internal BindableInt Combo; internal BindableInt Combo;
private Shader shader; private IShader shader;
protected override DrawNode CreateDrawNode() => new FlashlightDrawNode(); protected override DrawNode CreateDrawNode() => new FlashlightDrawNode();
@ -139,7 +139,7 @@ namespace osu.Game.Rulesets.Mods
private class FlashlightDrawNode : DrawNode private class FlashlightDrawNode : DrawNode
{ {
public Shader Shader; public IShader Shader;
public Quad ScreenSpaceDrawQuad; public Quad ScreenSpaceDrawQuad;
public Vector2 FlashlightPosition; public Vector2 FlashlightPosition;
public Vector2 FlashlightSize; public Vector2 FlashlightSize;

View File

@ -89,7 +89,7 @@ namespace osu.Game.Screens
/// </summary> /// </summary>
public class ShaderPrecompiler : Drawable public class ShaderPrecompiler : Drawable
{ {
private readonly List<Shader> loadTargets = new List<Shader>(); private readonly List<IShader> loadTargets = new List<IShader>();
public bool FinishedCompiling { get; private set; } public bool FinishedCompiling { get; private set; }
@ -106,7 +106,7 @@ namespace osu.Game.Screens
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE)); loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE));
} }
protected virtual bool AllLoaded => loadTargets.All(s => s.Loaded); protected virtual bool AllLoaded => loadTargets.All(s => s.IsLoaded);
protected override void Update() protected override void Update()
{ {

View File

@ -63,7 +63,7 @@ namespace osu.Game.Screens.Menu
private readonly float[] frequencyAmplitudes = new float[256]; private readonly float[] frequencyAmplitudes = new float[256];
private Shader shader; private IShader shader;
private readonly Texture texture; private readonly Texture texture;
public LogoVisualisation() public LogoVisualisation()
@ -131,8 +131,6 @@ namespace osu.Game.Screens.Menu
protected override DrawNode CreateDrawNode() => new VisualisationDrawNode(); protected override DrawNode CreateDrawNode() => new VisualisationDrawNode();
private readonly VisualiserSharedData sharedData = new VisualiserSharedData();
protected override void ApplyDrawNode(DrawNode node) protected override void ApplyDrawNode(DrawNode node)
{ {
base.ApplyDrawNode(node); base.ApplyDrawNode(node);
@ -142,29 +140,23 @@ namespace osu.Game.Screens.Menu
visNode.Shader = shader; visNode.Shader = shader;
visNode.Texture = texture; visNode.Texture = texture;
visNode.Size = DrawSize.X; visNode.Size = DrawSize.X;
visNode.Shared = sharedData;
visNode.Colour = AccentColour; visNode.Colour = AccentColour;
visNode.AudioData = frequencyAmplitudes; visNode.AudioData = frequencyAmplitudes;
} }
private class VisualiserSharedData
{
public readonly QuadBatch<TexturedVertex2D> VertexBatch = new QuadBatch<TexturedVertex2D>(100, 10);
}
private class VisualisationDrawNode : DrawNode private class VisualisationDrawNode : DrawNode
{ {
public Shader Shader; public IShader Shader;
public Texture Texture; public Texture Texture;
public VisualiserSharedData Shared;
//Asuming the logo is a circle, we don't need a second dimension. //Asuming the logo is a circle, we don't need a second dimension.
public float Size; public float Size;
public Color4 Colour; public Color4 Colour;
public float[] AudioData; public float[] AudioData;
private readonly QuadBatch<TexturedVertex2D> vertexBatch = new QuadBatch<TexturedVertex2D>(100, 10);
public override void Draw(Action<TexturedVertex2D> vertexAction) public override void Draw(Action<TexturedVertex2D> vertexAction)
{ {
base.Draw(vertexAction); base.Draw(vertexAction);
@ -209,7 +201,7 @@ namespace osu.Game.Screens.Menu
rectangle, rectangle,
colourInfo, colourInfo,
null, null,
Shared.VertexBatch.AddAction, vertexBatch.AddAction,
//barSize by itself will make it smooth more in the X axis than in the Y axis, this reverts that. //barSize by itself will make it smooth more in the X axis than in the Y axis, this reverts that.
Vector2.Divide(inflation, barSize.Yx)); Vector2.Divide(inflation, barSize.Yx));
} }
@ -218,6 +210,13 @@ namespace osu.Game.Screens.Menu
Shader.Unbind(); Shader.Unbind();
} }
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
vertexBatch.Dispose();
}
} }
} }
} }

View File

@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.301.0" /> <PackageReference Include="ppy.osu.Framework" Version="2019.307.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" /> <PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -105,12 +105,12 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2019.128.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.301.0" /> <PackageReference Include="ppy.osu.Framework" Version="2019.307.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.301.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2019.307.0" />
<PackageReference Include="SharpCompress" Version="0.22.0" /> <PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" /> <PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" /> <PackageReference Include="SharpRaven" Version="2.4.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
<PackageReference Include="ppy.osu.Framework.NativeLibs" Version="2019.208.0" ExcludeAssets="all" /> <PackageReference Include="ppy.osu.Framework.NativeLibs" Version="2019.307.0" ExcludeAssets="all" />
</ItemGroup> </ItemGroup>
</Project> </Project>