From c8de1fd78447bc6317b670e2a0c8b680b30f9ea3 Mon Sep 17 00:00:00 2001 From: Andy Baker Date: Mon, 23 Dec 2024 10:49:52 +0000 Subject: [PATCH] Fix another merge issue --- Assets/Scripts/Tools/SnipTool.cs | 57 ++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Tools/SnipTool.cs b/Assets/Scripts/Tools/SnipTool.cs index 15476f4af9..88c22beb62 100644 --- a/Assets/Scripts/Tools/SnipTool.cs +++ b/Assets/Scripts/Tools/SnipTool.cs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +using System.Linq; using UnityEngine; namespace TiltBrush @@ -26,16 +27,45 @@ public class SnipTool : BaseStrokeIntersectionTool private Renderer m_DropperColorDescriptionSwatchRenderer; + private bool m_ValidBrushFoundThisFrame; + private bool m_SelectionValid; private Color m_SelectionColor; private BrushDescriptor m_SelectionBrush; private Stroke m_SelectionStroke; + private enum State + { + Enter, + Standard, + Exit, + Off + } + private State m_CurrentState; + private float m_EnterAmount; + [SerializeField] private float m_EnterSpeed = 16.0f; + [SerializeField] private Transform m_OffsetTransform; private Vector3 m_OffsetTransformBaseScale; + public void DisableRequestExit_HackForSceneSurgeon() { m_RequestExit = false; } + + override public void Init() + { + base.Init(); + + m_OffsetTransformBaseScale = m_OffsetTransform.localScale; + SetState(State.Off); + m_EnterAmount = 0.0f; + UpdateScale(); + } + override public void HideTool(bool bHide) { base.HideTool(bHide); + if (bHide) + { + SetState(State.Exit); + } ResetDetection(); m_DropperRenderer.enabled = !bHide; m_DropperConeRenderer.enabled = !bHide; @@ -45,11 +75,18 @@ override public void EnableTool(bool bEnable) { base.EnableTool(bEnable); ResetDetection(); + m_SelectionValid = false; if (bEnable) { EatInput(); } + else + { + SetState(State.Off); + m_EnterAmount = 0.0f; + UpdateScale(); + } SnapIntersectionObjectToController(); } @@ -93,11 +130,12 @@ override public void UpdateTool() { base.UpdateTool(); - // keep description locked to controller + //keep description locked to controller SnapIntersectionObjectToController(); - // always default to resetting detection + //always default to resetting detection m_ResetDetection = true; + m_ValidBrushFoundThisFrame = false; if (App.Config.m_UseBatchedBrushes) { @@ -110,6 +148,14 @@ override public void UpdateTool() if (m_ResetDetection) { + if (m_ValidBrushFoundThisFrame) + { + SetState(State.Enter); + } + else + { + SetState(State.Exit); + } ResetDetection(); } } @@ -153,6 +199,13 @@ override protected void HandleIntersection(Stroke stroke) } } + void UpdateScale() + { + Vector3 vScale = m_OffsetTransformBaseScale; + vScale.x *= m_EnterAmount; + m_OffsetTransform.localScale = vScale; + } + override public float GetSize() { return m_DropperBrushSelectRadius;