diff --git a/Source/Editor/Surface/Elements/OutputBox.cs b/Source/Editor/Surface/Elements/OutputBox.cs
index 7e271fef0..8836dc0dc 100644
--- a/Source/Editor/Surface/Elements/OutputBox.cs
+++ b/Source/Editor/Surface/Elements/OutputBox.cs
@@ -34,11 +34,6 @@ namespace FlaxEditor.Surface.Elements
///
public const float DefaultConnectionOffset = 24f;
- ///
- /// Distance for the mouse to be considered above the connection
- ///
- public float MouseOverConnectionDistance => 100f / Surface.ViewScale;
-
///
public OutputBox(SurfaceNode parentNode, NodeElementArchetype archetype)
: base(parentNode, archetype, archetype.Position + new Float2(parentNode.Archetype.Size.X, 0))
@@ -109,12 +104,13 @@ namespace FlaxEditor.Surface.Elements
///
/// The other box.
/// The mouse position
- public bool IntersectsConnection(Box targetBox, ref Float2 mousePosition)
+ /// Distance at which its an intersection
+ public bool IntersectsConnection(Box targetBox, ref Float2 mousePosition, float distance)
{
float connectionOffset = Mathf.Max(0f, DefaultConnectionOffset * (1 - Editor.Instance.Options.Options.Interface.ConnectionCurvature));
Float2 start = new Float2(ConnectionOrigin.X + connectionOffset, ConnectionOrigin.Y);
Float2 end = new Float2(targetBox.ConnectionOrigin.X - connectionOffset, targetBox.ConnectionOrigin.Y);
- return IntersectsConnection(ref start, ref end, ref mousePosition, MouseOverConnectionDistance);
+ return IntersectsConnection(ref start, ref end, ref mousePosition, distance);
}
///
@@ -182,7 +178,7 @@ namespace FlaxEditor.Surface.Elements
{
// Draw all the connections
var style = Surface.Style;
- var mouseOverDistance = MouseOverConnectionDistance;
+ var mouseOverDistance = Surface.MouseOverConnectionDistance;
var startPos = ConnectionOrigin;
var startHighlight = ConnectionsHighlightIntensity;
for (int i = 0; i < Connections.Count; i++)
diff --git a/Source/Editor/Surface/VisjectSurface.Input.cs b/Source/Editor/Surface/VisjectSurface.Input.cs
index 74eaa3e04..01c78ccb1 100644
--- a/Source/Editor/Surface/VisjectSurface.Input.cs
+++ b/Source/Editor/Surface/VisjectSurface.Input.cs
@@ -24,6 +24,16 @@ namespace FlaxEditor.Surface
///
public bool PanWithMiddleMouse = false;
+ ///
+ /// Distance for the mouse to be considered above the connection.
+ ///
+ public float MouseOverConnectionDistance => 100f / ViewScale;
+
+ ///
+ /// Distance of a node from which it is able to be slotted into an existing connection.
+ ///
+ public float SlotNodeIntoConnectionDistance => 250f / ViewScale;
+
private string _currentInputText = string.Empty;
private Float2 _movingNodesDelta;
private Float2 _gridRoundingDelta;
@@ -456,7 +466,7 @@ namespace FlaxEditor.Surface
if (!handled && CanEdit && CanUseNodeType(7, 29))
{
var mousePos = _rootControl.PointFromParent(ref _mousePos);
- if (IntersectsConnection(mousePos, out InputBox inputBox, out OutputBox outputBox) && GetControlUnderMouse() == null)
+ if (IntersectsConnection(mousePos, out InputBox inputBox, out OutputBox outputBox, MouseOverConnectionDistance) && GetControlUnderMouse() == null)
{
if (Undo != null)
{
@@ -653,7 +663,7 @@ namespace FlaxEditor.Surface
var mousePos = _rootControl.PointFromParent(ref _mousePos);
InputBox intersectedConnectionInputBox;
OutputBox intersectedConnectionOutputBox;
- if (IntersectsConnection(mousePos, out intersectedConnectionInputBox, out intersectedConnectionOutputBox))
+ if (IntersectsConnection(mousePos, out intersectedConnectionInputBox, out intersectedConnectionOutputBox, SlotNodeIntoConnectionDistance))
{
SurfaceNode node = _movingNodes.First();
InputBox nodeInputBox = (InputBox)node.GetBoxes().First(b => !b.IsOutput);
@@ -783,7 +793,7 @@ namespace FlaxEditor.Surface
{
// Surface was not moved with MMB so try to remove connection underneath
var mousePos = _rootControl.PointFromParent(ref location);
- if (IntersectsConnection(mousePos, out InputBox inputBox, out OutputBox outputBox))
+ if (IntersectsConnection(mousePos, out InputBox inputBox, out OutputBox outputBox, MouseOverConnectionDistance))
{
var action = new EditNodeConnections(inputBox.ParentNode.Context, inputBox.ParentNode);
inputBox.BreakConnection(outputBox);
@@ -1180,7 +1190,7 @@ namespace FlaxEditor.Surface
return new Float2(xLocation, yLocation);
}
- private bool IntersectsConnection(Float2 mousePosition, out InputBox inputBox, out OutputBox outputBox)
+ private bool IntersectsConnection(Float2 mousePosition, out InputBox inputBox, out OutputBox outputBox, float distance)
{
for (int i = 0; i < Nodes.Count; i++)
{
@@ -1190,7 +1200,7 @@ namespace FlaxEditor.Surface
{
for (int k = 0; k < ob.Connections.Count; k++)
{
- if (ob.IntersectsConnection(ob.Connections[k], ref mousePosition))
+ if (ob.IntersectsConnection(ob.Connections[k], ref mousePosition, distance))
{
outputBox = ob;
inputBox = ob.Connections[k] as InputBox;