2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2017-08-10 17:37:41 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2018-03-05 18:45:49 +08:00
|
|
|
|
using System.Runtime.InteropServices;
|
2016-11-26 18:22:56 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-04-14 13:20:18 +08:00
|
|
|
|
using osu.Framework.Extensions.EnumExtensions;
|
2016-11-26 18:22:56 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-08-10 17:37:41 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2022-07-29 21:33:34 +08:00
|
|
|
|
using osu.Framework.Graphics.Rendering;
|
2022-08-05 19:36:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Rendering.Vertices;
|
2016-11-26 18:22:56 +08:00
|
|
|
|
using osu.Framework.Graphics.Shaders;
|
2023-02-25 00:21:37 +08:00
|
|
|
|
using osu.Framework.Graphics.Shaders.Types;
|
2016-11-26 18:22:56 +08:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
|
using osu.Framework.Input;
|
2018-10-02 11:02:47 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2020-02-24 19:52:15 +08:00
|
|
|
|
using osu.Framework.Layout;
|
2017-08-10 17:37:41 +08:00
|
|
|
|
using osu.Framework.Timing;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK.Graphics.ES30;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-10 17:37:41 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.UI.Cursor
|
2016-11-26 18:22:56 +08:00
|
|
|
|
{
|
2019-09-09 16:53:51 +08:00
|
|
|
|
public partial class CursorTrail : Drawable, IRequireHighFrequencyMousePosition
|
2016-11-26 18:22:56 +08:00
|
|
|
|
{
|
2019-09-09 11:35:15 +08:00
|
|
|
|
private const int max_sprites = 2048;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-13 09:27:26 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// An exponentiating factor to ease the trail fade.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual float FadeExponent => 1.7f;
|
|
|
|
|
|
2019-09-09 11:35:15 +08:00
|
|
|
|
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
|
|
|
|
private int currentIndex;
|
2021-08-13 09:27:26 +08:00
|
|
|
|
private IShader shader;
|
2016-11-26 18:22:56 +08:00
|
|
|
|
private double timeOffset;
|
|
|
|
|
private float time;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-04-15 22:37:05 +08:00
|
|
|
|
private Anchor trailOrigin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
protected Anchor TrailOrigin
|
|
|
|
|
{
|
|
|
|
|
get => trailOrigin;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
trailOrigin = value;
|
|
|
|
|
Invalidate(Invalidation.DrawNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-14 13:20:18 +08:00
|
|
|
|
|
2016-11-26 18:22:56 +08:00
|
|
|
|
public CursorTrail()
|
|
|
|
|
{
|
2017-04-13 13:13:53 +08:00
|
|
|
|
// as we are currently very dependent on having a running clock, let's make our own clock for the time being.
|
|
|
|
|
Clock = new FramedClock();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-11-26 18:22:56 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-02-07 15:15:45 +08:00
|
|
|
|
for (int i = 0; i < max_sprites; i++)
|
2016-11-27 01:01:24 +08:00
|
|
|
|
{
|
2019-09-25 15:25:15 +08:00
|
|
|
|
// -1 signals that the part is unusable, and should not be drawn
|
|
|
|
|
parts[i].InvalidationID = -1;
|
2016-11-27 01:01:24 +08:00
|
|
|
|
}
|
2020-02-24 19:52:15 +08:00
|
|
|
|
|
|
|
|
|
AddLayout(partSizeCache);
|
2016-11-26 18:22:56 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-11-26 18:22:56 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2022-08-02 18:50:57 +08:00
|
|
|
|
private void load(IRenderer renderer, ShaderManager shaders)
|
2016-11-26 18:22:56 +08:00
|
|
|
|
{
|
2022-08-02 18:50:57 +08:00
|
|
|
|
texture ??= renderer.WhitePixel;
|
2021-08-13 09:27:26 +08:00
|
|
|
|
shader = shaders.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
|
2016-11-26 18:22:56 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-02 15:08:10 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
resetTime();
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-08-02 18:50:57 +08:00
|
|
|
|
private Texture texture;
|
2019-09-09 18:00:42 +08:00
|
|
|
|
|
|
|
|
|
public Texture Texture
|
|
|
|
|
{
|
|
|
|
|
get => texture;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (texture == value)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
texture = value;
|
|
|
|
|
Invalidate(Invalidation.DrawNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-24 19:52:15 +08:00
|
|
|
|
private readonly LayoutValue<Vector2> partSizeCache = new LayoutValue<Vector2>(Invalidation.DrawInfo | Invalidation.RequiredParentSizeToFit | Invalidation.Presence);
|
2019-09-09 18:30:31 +08:00
|
|
|
|
|
|
|
|
|
private Vector2 partSize => partSizeCache.IsValid
|
|
|
|
|
? partSizeCache.Value
|
|
|
|
|
: (partSizeCache.Value = new Vector2(Texture.DisplayWidth, Texture.DisplayHeight) * DrawInfo.Matrix.ExtractScale().Xy);
|
|
|
|
|
|
2019-09-09 18:02:10 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The amount of time to fade the cursor trail pieces.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual double FadeDuration => 300;
|
|
|
|
|
|
2019-09-09 11:35:15 +08:00
|
|
|
|
public override bool IsPresent => true;
|
|
|
|
|
|
2016-11-26 18:22:56 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-25 10:30:33 +08:00
|
|
|
|
Invalidate(Invalidation.DrawNode);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-23 12:52:38 +08:00
|
|
|
|
const int fade_clock_reset_threshold = 1000000;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-09-09 18:02:10 +08:00
|
|
|
|
time = (float)((Time.Current - timeOffset) / FadeDuration);
|
2017-03-23 12:52:38 +08:00
|
|
|
|
if (time > fade_clock_reset_threshold)
|
2017-02-07 15:15:45 +08:00
|
|
|
|
resetTime();
|
2016-11-26 18:22:56 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-02-07 15:15:45 +08:00
|
|
|
|
private void resetTime()
|
2016-11-26 18:22:56 +08:00
|
|
|
|
{
|
2016-11-27 01:01:24 +08:00
|
|
|
|
for (int i = 0; i < parts.Length; ++i)
|
|
|
|
|
{
|
|
|
|
|
parts[i].Time -= time;
|
2019-09-25 15:25:15 +08:00
|
|
|
|
|
|
|
|
|
if (parts[i].InvalidationID != -1)
|
|
|
|
|
++parts[i].InvalidationID;
|
2016-11-27 01:01:24 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-11-26 18:22:56 +08:00
|
|
|
|
time = 0;
|
|
|
|
|
timeOffset = Time.Current;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-09-09 18:22:27 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether to interpolate mouse movements and add trail pieces at intermediate points.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual bool InterpolateMovements => true;
|
|
|
|
|
|
2020-10-03 00:34:06 +08:00
|
|
|
|
protected virtual float IntervalMultiplier => 1.0f;
|
2021-08-17 03:52:19 +08:00
|
|
|
|
protected virtual bool AvoidDrawingNearCursor => false;
|
2020-10-03 00:34:06 +08:00
|
|
|
|
|
2019-09-09 11:35:15 +08:00
|
|
|
|
private Vector2? lastPosition;
|
|
|
|
|
private readonly InputResampler resampler = new InputResampler();
|
|
|
|
|
|
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
2016-11-26 18:25:58 +08:00
|
|
|
|
{
|
2021-08-13 11:10:33 +08:00
|
|
|
|
AddTrail(e.ScreenSpaceMousePosition);
|
2021-08-12 22:13:03 +08:00
|
|
|
|
return base.OnMouseMove(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void AddTrail(Vector2 position)
|
|
|
|
|
{
|
|
|
|
|
if (InterpolateMovements)
|
|
|
|
|
{
|
2021-08-13 11:10:33 +08:00
|
|
|
|
if (!lastPosition.HasValue)
|
|
|
|
|
{
|
|
|
|
|
lastPosition = position;
|
|
|
|
|
resampler.AddPosition(lastPosition.Value);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 22:13:03 +08:00
|
|
|
|
foreach (Vector2 pos2 in resampler.AddPosition(position))
|
2017-05-04 00:33:42 +08:00
|
|
|
|
{
|
2021-08-12 22:13:03 +08:00
|
|
|
|
Trace.Assert(lastPosition.HasValue);
|
|
|
|
|
|
2019-09-09 18:22:27 +08:00
|
|
|
|
Vector2 pos1 = lastPosition.Value;
|
|
|
|
|
Vector2 diff = pos2 - pos1;
|
|
|
|
|
float distance = diff.Length;
|
|
|
|
|
Vector2 direction = diff / distance;
|
|
|
|
|
|
2020-10-03 00:34:49 +08:00
|
|
|
|
float interval = partSize.X / 2.5f * IntervalMultiplier;
|
2021-08-17 03:52:19 +08:00
|
|
|
|
float stopAt = distance - (AvoidDrawingNearCursor ? interval : 0);
|
2019-09-09 18:22:27 +08:00
|
|
|
|
|
2021-08-17 03:52:19 +08:00
|
|
|
|
for (float d = interval; d < stopAt; d += interval)
|
2019-09-09 18:22:27 +08:00
|
|
|
|
{
|
|
|
|
|
lastPosition = pos1 + direction * d;
|
|
|
|
|
addPart(lastPosition.Value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-26 18:25:58 +08:00
|
|
|
|
}
|
2021-08-12 22:13:03 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lastPosition = position;
|
|
|
|
|
addPart(lastPosition.Value);
|
|
|
|
|
}
|
2016-11-26 18:25:58 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-09-09 18:22:27 +08:00
|
|
|
|
private void addPart(Vector2 screenSpacePosition)
|
|
|
|
|
{
|
|
|
|
|
parts[currentIndex].Position = screenSpacePosition;
|
2019-12-16 14:15:26 +08:00
|
|
|
|
parts[currentIndex].Time = time + 1;
|
2019-09-09 18:22:27 +08:00
|
|
|
|
++parts[currentIndex].InvalidationID;
|
|
|
|
|
|
|
|
|
|
currentIndex = (currentIndex + 1) % max_sprites;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-09 11:35:15 +08:00
|
|
|
|
protected override DrawNode CreateDrawNode() => new TrailDrawNode(this);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private struct TrailPart
|
2016-11-27 01:01:24 +08:00
|
|
|
|
{
|
|
|
|
|
public Vector2 Position;
|
|
|
|
|
public float Time;
|
|
|
|
|
public long InvalidationID;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private class TrailDrawNode : DrawNode
|
2016-11-26 18:22:56 +08:00
|
|
|
|
{
|
2019-04-02 10:56:22 +08:00
|
|
|
|
protected new CursorTrail Source => (CursorTrail)base.Source;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-04-02 10:56:22 +08:00
|
|
|
|
private IShader shader;
|
|
|
|
|
private Texture texture;
|
|
|
|
|
|
|
|
|
|
private float time;
|
2021-08-13 09:27:26 +08:00
|
|
|
|
private float fadeExponent;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-04-02 10:56:22 +08:00
|
|
|
|
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
|
|
|
|
private Vector2 size;
|
2021-04-14 13:20:18 +08:00
|
|
|
|
private Vector2 originPosition;
|
|
|
|
|
|
2022-07-29 22:32:06 +08:00
|
|
|
|
private IVertexBatch<TexturedTrailVertex> vertexBatch;
|
2019-03-01 12:01:52 +08:00
|
|
|
|
|
2019-04-02 10:56:22 +08:00
|
|
|
|
public TrailDrawNode(CursorTrail source)
|
|
|
|
|
: base(source)
|
2016-11-27 01:01:24 +08:00
|
|
|
|
{
|
2019-04-02 10:56:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ApplyState()
|
|
|
|
|
{
|
|
|
|
|
base.ApplyState();
|
|
|
|
|
|
2021-08-13 09:27:26 +08:00
|
|
|
|
shader = Source.shader;
|
2019-04-02 10:56:22 +08:00
|
|
|
|
texture = Source.texture;
|
2019-09-09 18:30:31 +08:00
|
|
|
|
size = Source.partSize;
|
2019-04-02 10:56:22 +08:00
|
|
|
|
time = Source.time;
|
2021-08-13 09:27:26 +08:00
|
|
|
|
fadeExponent = Source.FadeExponent;
|
2019-04-02 10:56:22 +08:00
|
|
|
|
|
2021-04-14 13:20:18 +08:00
|
|
|
|
originPosition = Vector2.Zero;
|
|
|
|
|
|
|
|
|
|
if (Source.TrailOrigin.HasFlagFast(Anchor.x1))
|
|
|
|
|
originPosition.X = 0.5f;
|
|
|
|
|
else if (Source.TrailOrigin.HasFlagFast(Anchor.x2))
|
|
|
|
|
originPosition.X = 1f;
|
|
|
|
|
|
|
|
|
|
if (Source.TrailOrigin.HasFlagFast(Anchor.y1))
|
|
|
|
|
originPosition.Y = 0.5f;
|
|
|
|
|
else if (Source.TrailOrigin.HasFlagFast(Anchor.y2))
|
|
|
|
|
originPosition.Y = 1f;
|
|
|
|
|
|
2019-09-25 15:25:15 +08:00
|
|
|
|
Source.parts.CopyTo(parts, 0);
|
2016-11-27 01:01:24 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2023-02-25 00:21:37 +08:00
|
|
|
|
private IUniformBuffer<CursorTrailParameters> cursorTrailParameters;
|
|
|
|
|
|
2023-12-04 07:51:21 +08:00
|
|
|
|
protected override void Draw(IRenderer renderer)
|
2016-11-26 18:22:56 +08:00
|
|
|
|
{
|
2022-07-29 21:33:34 +08:00
|
|
|
|
base.Draw(renderer);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-07-29 22:32:06 +08:00
|
|
|
|
vertexBatch ??= renderer.CreateQuadBatch<TexturedTrailVertex>(max_sprites, 1);
|
|
|
|
|
|
2023-02-25 00:21:37 +08:00
|
|
|
|
cursorTrailParameters ??= renderer.CreateUniformBuffer<CursorTrailParameters>();
|
|
|
|
|
cursorTrailParameters.Data = cursorTrailParameters.Data with
|
|
|
|
|
{
|
|
|
|
|
FadeClock = time,
|
|
|
|
|
FadeExponent = fadeExponent
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-10 19:29:01 +08:00
|
|
|
|
shader.Bind();
|
2023-02-25 00:21:37 +08:00
|
|
|
|
shader.BindUniformBlock("m_CursorTrailParameters", cursorTrailParameters);
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2022-08-02 18:50:57 +08:00
|
|
|
|
texture.Bind();
|
2019-12-16 17:10:44 +08:00
|
|
|
|
|
2019-12-16 14:15:26 +08:00
|
|
|
|
RectangleF textureRect = texture.GetTextureRect();
|
|
|
|
|
|
|
|
|
|
foreach (var part in parts)
|
2016-11-26 21:08:43 +08:00
|
|
|
|
{
|
2019-12-16 14:15:26 +08:00
|
|
|
|
if (part.InvalidationID == -1)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (time - part.Time >= 1)
|
2019-09-25 15:25:15 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
2023-09-13 22:10:13 +08:00
|
|
|
|
vertexBatch.Add(new TexturedTrailVertex
|
2019-12-16 14:15:26 +08:00
|
|
|
|
{
|
2021-04-14 13:20:18 +08:00
|
|
|
|
Position = new Vector2(part.Position.X - size.X * originPosition.X, part.Position.Y + size.Y * (1 - originPosition.Y)),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
TexturePosition = textureRect.BottomLeft,
|
2020-06-02 22:47:18 +08:00
|
|
|
|
TextureRect = new Vector4(0, 0, 1, 1),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
Colour = DrawColourInfo.Colour.BottomLeft.Linear,
|
|
|
|
|
Time = part.Time
|
|
|
|
|
});
|
|
|
|
|
|
2023-09-13 22:10:13 +08:00
|
|
|
|
vertexBatch.Add(new TexturedTrailVertex
|
2019-12-16 14:15:26 +08:00
|
|
|
|
{
|
2021-04-14 13:20:18 +08:00
|
|
|
|
Position = new Vector2(part.Position.X + size.X * (1 - originPosition.X), part.Position.Y + size.Y * (1 - originPosition.Y)),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
TexturePosition = textureRect.BottomRight,
|
2020-06-02 22:47:18 +08:00
|
|
|
|
TextureRect = new Vector4(0, 0, 1, 1),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
Colour = DrawColourInfo.Colour.BottomRight.Linear,
|
|
|
|
|
Time = part.Time
|
|
|
|
|
});
|
2019-06-10 19:29:01 +08:00
|
|
|
|
|
2023-09-13 22:10:13 +08:00
|
|
|
|
vertexBatch.Add(new TexturedTrailVertex
|
2019-12-16 14:15:26 +08:00
|
|
|
|
{
|
2021-04-14 13:20:18 +08:00
|
|
|
|
Position = new Vector2(part.Position.X + size.X * (1 - originPosition.X), part.Position.Y - size.Y * originPosition.Y),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
TexturePosition = textureRect.TopRight,
|
2020-06-02 22:47:18 +08:00
|
|
|
|
TextureRect = new Vector4(0, 0, 1, 1),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
Colour = DrawColourInfo.Colour.TopRight.Linear,
|
|
|
|
|
Time = part.Time
|
|
|
|
|
});
|
2019-07-16 16:50:03 +08:00
|
|
|
|
|
2023-09-13 22:10:13 +08:00
|
|
|
|
vertexBatch.Add(new TexturedTrailVertex
|
2019-12-16 14:15:26 +08:00
|
|
|
|
{
|
2021-04-14 13:20:18 +08:00
|
|
|
|
Position = new Vector2(part.Position.X - size.X * originPosition.X, part.Position.Y - size.Y * originPosition.Y),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
TexturePosition = textureRect.TopLeft,
|
2020-06-02 22:47:18 +08:00
|
|
|
|
TextureRect = new Vector4(0, 0, 1, 1),
|
2019-12-16 14:15:26 +08:00
|
|
|
|
Colour = DrawColourInfo.Colour.TopLeft.Linear,
|
|
|
|
|
Time = part.Time
|
|
|
|
|
});
|
2016-11-26 21:08:43 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-12-16 14:15:26 +08:00
|
|
|
|
vertexBatch.Draw();
|
2019-04-02 10:56:22 +08:00
|
|
|
|
shader.Unbind();
|
2016-11-26 18:22:56 +08:00
|
|
|
|
}
|
2019-03-01 12:01:52 +08:00
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
2022-07-29 22:32:06 +08:00
|
|
|
|
vertexBatch?.Dispose();
|
2023-02-25 00:21:37 +08:00
|
|
|
|
cursorTrailParameters?.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
|
|
|
|
private record struct CursorTrailParameters
|
|
|
|
|
{
|
|
|
|
|
public UniformFloat FadeClock;
|
|
|
|
|
public UniformFloat FadeExponent;
|
|
|
|
|
private readonly UniformPadding8 pad1;
|
2019-03-01 12:01:52 +08:00
|
|
|
|
}
|
2016-11-26 18:22:56 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-05 18:45:49 +08:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
public struct TexturedTrailVertex : IEquatable<TexturedTrailVertex>, IVertex
|
|
|
|
|
{
|
|
|
|
|
[VertexMember(2, VertexAttribPointerType.Float)]
|
|
|
|
|
public Vector2 Position;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-03-05 18:45:49 +08:00
|
|
|
|
[VertexMember(4, VertexAttribPointerType.Float)]
|
|
|
|
|
public Color4 Colour;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-03-05 18:45:49 +08:00
|
|
|
|
[VertexMember(2, VertexAttribPointerType.Float)]
|
|
|
|
|
public Vector2 TexturePosition;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2020-06-02 22:47:18 +08:00
|
|
|
|
[VertexMember(4, VertexAttribPointerType.Float)]
|
|
|
|
|
public Vector4 TextureRect;
|
|
|
|
|
|
2018-03-05 18:45:49 +08:00
|
|
|
|
[VertexMember(1, VertexAttribPointerType.Float)]
|
|
|
|
|
public float Time;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-05 18:45:49 +08:00
|
|
|
|
public bool Equals(TexturedTrailVertex other)
|
|
|
|
|
{
|
|
|
|
|
return Position.Equals(other.Position)
|
|
|
|
|
&& TexturePosition.Equals(other.TexturePosition)
|
|
|
|
|
&& Colour.Equals(other.Colour)
|
2023-09-13 22:10:13 +08:00
|
|
|
|
&& Time.Equals(other.Time);
|
2018-03-05 18:45:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-11-26 18:22:56 +08:00
|
|
|
|
}
|
2017-04-13 13:13:53 +08:00
|
|
|
|
}
|