Skip to content

Commit

Permalink
Fix another merge issue
Browse files Browse the repository at this point in the history
  • Loading branch information
andybak committed Dec 23, 2024
1 parent b8e5684 commit c8de1fd
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions Assets/Scripts/Tools/SnipTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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();
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -110,6 +148,14 @@ override public void UpdateTool()

if (m_ResetDetection)
{
if (m_ValidBrushFoundThisFrame)
{
SetState(State.Enter);
}
else
{
SetState(State.Exit);
}
ResetDetection();
}
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c8de1fd

Please sign in to comment.