From 2c91241410f78a90d6a8fac4c504ec20c7d19eff Mon Sep 17 00:00:00 2001 From: master <> Date: Thu, 2 Apr 2026 12:40:00 +0300 Subject: [PATCH] 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) --- ...RouterIterative.WinnerRefinement.Hybrid.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) 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 {