Snap corridor endpoints to target node top face
Corridor vertical drops now land on the target node's actual top boundary (Y = node.Y) at the clamped X position. Endpoints visually connect to the node instead of floating near it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -324,15 +324,29 @@ internal static partial class ElkEdgeRouterIterative
|
|||||||
// corridors so they're visually distinct.
|
// corridors so they're visually distinct.
|
||||||
var localCorridorY = baseCorridorY - (corridorFixed * (nodeSizeClearance * 2d));
|
var localCorridorY = baseCorridorY - (corridorFixed * (nodeSizeClearance * 2d));
|
||||||
|
|
||||||
// Route through corridor then drop to the ORIGINAL target
|
// Route through corridor then drop to the target. Re-snap
|
||||||
// endpoint (which the router placed on the actual node boundary).
|
// the endpoint to the node boundary from the new approach
|
||||||
|
// direction (vertical drop from above).
|
||||||
|
var corridorTgtNode = nodesById.TryGetValue(edge.TargetNodeId ?? string.Empty, out var ctn) ? ctn : null;
|
||||||
|
ElkPoint endPoint;
|
||||||
|
if (corridorTgtNode is not null)
|
||||||
|
{
|
||||||
|
// Vertical drop lands on the top face at the drop X.
|
||||||
|
var dropEndX = Math.Clamp(tgt.X, corridorTgtNode.X + 4d, corridorTgtNode.X + corridorTgtNode.Width - 4d);
|
||||||
|
endPoint = new ElkPoint { X = dropEndX, Y = corridorTgtNode.Y };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
endPoint = tgt;
|
||||||
|
}
|
||||||
|
|
||||||
var newPath = new List<ElkPoint>
|
var newPath = new List<ElkPoint>
|
||||||
{
|
{
|
||||||
src,
|
src,
|
||||||
new() { X = stubX, Y = src.Y },
|
new() { X = stubX, Y = src.Y },
|
||||||
new() { X = stubX, Y = localCorridorY },
|
new() { X = stubX, Y = localCorridorY },
|
||||||
new() { X = tgt.X, Y = localCorridorY },
|
new() { X = endPoint.X, Y = localCorridorY },
|
||||||
tgt,
|
endPoint,
|
||||||
};
|
};
|
||||||
corridorResult[ei] = new ElkRoutedEdge
|
corridorResult[ei] = new ElkRoutedEdge
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user