mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 23:33:23 +08:00
Fix flashlight potentially not correctly blocking vision (#5437)
Fix flashlight potentially not correctly blocking vision Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
0cff93bf20
26
osu.Game/Graphics/OpenGL/Vertices/PositionAndColourVertex.cs
Normal file
26
osu.Game/Graphics/OpenGL/Vertices/PositionAndColourVertex.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
using osuTK.Graphics.ES30;
|
||||||
|
|
||||||
|
namespace osu.Game.Graphics.OpenGL.Vertices
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct PositionAndColourVertex : IEquatable<PositionAndColourVertex>, IVertex
|
||||||
|
{
|
||||||
|
[VertexMember(2, VertexAttribPointerType.Float)]
|
||||||
|
public Vector2 Position;
|
||||||
|
|
||||||
|
[VertexMember(4, VertexAttribPointerType.Float)]
|
||||||
|
public Color4 Colour;
|
||||||
|
|
||||||
|
public bool Equals(PositionAndColourVertex other)
|
||||||
|
=> Position.Equals(other.Position)
|
||||||
|
&& Colour.Equals(other.Colour);
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Batches;
|
||||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Shaders;
|
using osu.Framework.Graphics.Shaders;
|
||||||
@ -13,6 +14,7 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.OpenGL.Vertices;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -153,9 +155,17 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
private Vector2 flashlightSize;
|
private Vector2 flashlightSize;
|
||||||
private float flashlightDim;
|
private float flashlightDim;
|
||||||
|
|
||||||
|
private readonly VertexBatch<PositionAndColourVertex> quadBatch = new QuadBatch<PositionAndColourVertex>(1, 1);
|
||||||
|
private readonly Action<TexturedVertex2D> addAction;
|
||||||
|
|
||||||
public FlashlightDrawNode(Flashlight source)
|
public FlashlightDrawNode(Flashlight source)
|
||||||
: base(source)
|
: base(source)
|
||||||
{
|
{
|
||||||
|
addAction = v => quadBatch.Add(new PositionAndColourVertex
|
||||||
|
{
|
||||||
|
Position = v.Position,
|
||||||
|
Colour = v.Colour
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ApplyState()
|
public override void ApplyState()
|
||||||
@ -179,7 +189,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
shader.GetUniform<Vector2>("flashlightSize").UpdateValue(ref flashlightSize);
|
shader.GetUniform<Vector2>("flashlightSize").UpdateValue(ref flashlightSize);
|
||||||
shader.GetUniform<float>("flashlightDim").UpdateValue(ref flashlightDim);
|
shader.GetUniform<float>("flashlightDim").UpdateValue(ref flashlightDim);
|
||||||
|
|
||||||
DrawQuad(Texture.WhitePixel, screenSpaceDrawQuad, DrawColourInfo.Colour, vertexAction: vertexAction);
|
DrawQuad(Texture.WhitePixel, screenSpaceDrawQuad, DrawColourInfo.Colour, vertexAction: addAction);
|
||||||
|
|
||||||
shader.Unbind();
|
shader.Unbind();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user