diff --git a/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.WinnerRefinement.Hybrid.cs b/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.WinnerRefinement.Hybrid.cs index c10dc0e35..a04e17f16 100644 --- a/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.WinnerRefinement.Hybrid.cs +++ b/src/__Libraries/StellaOps.ElkSharp/ElkEdgeRouterIterative.WinnerRefinement.Hybrid.cs @@ -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 { 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 {