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.
|
||||
var localCorridorY = baseCorridorY - (corridorFixed * (nodeSizeClearance * 2d));
|
||||
|
||||
// Route through corridor then drop to the ORIGINAL target
|
||||
// endpoint (which the router placed on the actual node boundary).
|
||||
// Route through corridor then drop to the target. Re-snap
|
||||
// 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>
|
||||
{
|
||||
src,
|
||||
new() { X = stubX, Y = src.Y },
|
||||
new() { X = stubX, Y = localCorridorY },
|
||||
new() { X = tgt.X, Y = localCorridorY },
|
||||
tgt,
|
||||
new() { X = endPoint.X, Y = localCorridorY },
|
||||
endPoint,
|
||||
};
|
||||
corridorResult[ei] = new ElkRoutedEdge
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user