From 5c09662c14640543616937680b00a4da7427f75c Mon Sep 17 00:00:00 2001 From: jorolf Date: Wed, 7 Nov 2018 23:40:33 +0100 Subject: [PATCH] Allow flashlight size to be variant --- osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs index b6e16ff537..c6b6d67ce6 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModFlashlight.cs @@ -32,7 +32,10 @@ namespace osu.Game.Rulesets.Osu.Mods private class Flashlight : Drawable, IRequireHighFrequencyMousePosition { private Shader shader; - private readonly MousePositionWrapper mousePosWrapper = new MousePositionWrapper(); + private readonly MousePositionWrapper mousePosWrapper = new MousePositionWrapper + { + FlashlightSize = 300f + }; protected override DrawNode CreateDrawNode() => new FlashlightDrawNode(); @@ -45,7 +48,6 @@ namespace osu.Game.Rulesets.Osu.Mods flashNode.Shader = shader; flashNode.ScreenSpaceDrawQuad = ScreenSpaceDrawQuad; flashNode.MousePosWrapper = mousePosWrapper; - flashNode.FlashlightSize = 100f; } [BackgroundDependencyLoader] @@ -64,6 +66,8 @@ namespace osu.Game.Rulesets.Osu.Mods private class MousePositionWrapper { public Vector2 MousePosition; + public float FlashlightSize; + public bool FlashlightUniformUpdated; } private class FlashlightDrawNode : DrawNode @@ -71,8 +75,6 @@ namespace osu.Game.Rulesets.Osu.Mods public Shader Shader; public Quad ScreenSpaceDrawQuad; public MousePositionWrapper MousePosWrapper; - public float FlashlightSize; - private bool sizeSet; public override void Draw(Action vertexAction) { @@ -80,8 +82,8 @@ namespace osu.Game.Rulesets.Osu.Mods Shader.Bind(); // ReSharper disable once AssignmentInConditionalExpression - if(sizeSet = !sizeSet) - Shader.GetUniform("flashlightSize").UpdateValue(ref FlashlightSize); + if(MousePosWrapper.FlashlightUniformUpdated = !MousePosWrapper.FlashlightUniformUpdated) + Shader.GetUniform("flashlightSize").UpdateValue(ref MousePosWrapper.FlashlightSize); Shader.GetUniform("mousePos").UpdateValue(ref MousePosWrapper.MousePosition);