Fix visject connections redo

Previously, it would create double connections
This commit is contained in:
stefnotch
2021-02-26 10:43:31 +01:00
parent 9ed0ace01e
commit 69162ad8d9
2 changed files with 29 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ namespace FlaxEditor.Surface.Undo
/// The helper structure for Surface node box handle.
/// </summary>
[HideInEditor]
public struct BoxHandle
public struct BoxHandle : IEquatable<BoxHandle>
{
private readonly uint _nodeId;
private readonly int _boxId;
@@ -51,5 +51,27 @@ namespace FlaxEditor.Surface.Undo
throw new Exception("Missing box.");
return box;
}
/// <inheritdoc />
public override bool Equals(object obj)
{
return obj is BoxHandle handle && Equals(handle);
}
/// <inheritdoc />
public bool Equals(BoxHandle other)
{
return _nodeId == other._nodeId &&
_boxId == other._boxId;
}
/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
return (_nodeId.GetHashCode() * 397) ^ _boxId.GetHashCode();
}
}
}
}

View File

@@ -104,9 +104,12 @@ namespace FlaxEditor.Surface.Undo
}
for (int i = 0; i < output.Length; i++)
{
var box = output[i].Get(context);
oB.Connections.Add(box);
box.Connections.Add(oB);
if (!output[i].Equals(_input))
{
var box = output[i].Get(context);
oB.Connections.Add(box);
box.Connections.Add(oB);
}
}
toUpdate.AddRange(iB.Connections);