feat: implement snapping logic and collinear merging phase#176
feat: implement snapping logic and collinear merging phase#176Puroonjay wants to merge 1 commit intotscircuit:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
I have formatted the entire repository to ensure the Format check passes. The Bun test failure is expected as it is a snapshot mismatch because the new geometry is straighter than the old snapshots. Once these are updated on linux env all the tests will pass |
2026-04-13.00-52-28.mp4 |
|
I have updated the snapshots to reflect the improved, straighter geometry. All tests are now passing locally. |
|
I have just submitted a full fix for this issue. It implements axial snapping to fix the staircasing and adds net-aware logic to merge same-net traces |
|
I don't understand what was fixed, i watched the video, there are lots of snapshots updated, just confused what the fix and the related code change is |
|
I understand your confusion. The reason for the many snapshot changes was that i included logic to fix the staircase jitter along with the same-net merging. i will remove the visual fix and resubmit the version that only implements the net aware merging. This will solve the issue with almost zero snapshot changes |
|
How do you know this works? |
|
I figured it out by checking the collision logic against the glitches I saw in the original issue. The main issue was in isPathColliding.ts inside the isPathColliding function. It was treating every wire like a solid wall. Even if a wire belonged to the same net the solver would try to swerve around it to avoid a collision. That swerve created the jagged "staircase" look. In other cases it would just draw a second wire right next to the first one because it was afraid to overlap. What I changed => isPathColliding.ts: I added a Net-Aware check using globalConnNetId. Now, the solver checks the ID of the trace. If it’s the same net it knows there’s no collision and just merges. This stops the "swerving" before it even starts. => simplifyPath.ts: Since same-net wires can now overlap, I added a cleanup pass here. It removes extra points and merges those overlapping parts into one straight clean line Tbh in my first attempt I was forcing the lines to be straight with heavy snapping which is why the snapshots went crazy. I was basically just patching the symptoms instead of fixing the root cause shown in the video. This new version is a pure logic fix. I have updated how the solver actually thinks so it naturally knows when to merge. That’s why all tests are passing now with zero snapshot changes. |
|
There is no test snapshot demonstrating the fix, you need a clear example of a reproduction and a fix |
|
Alright then i will create a new test repro-issue-34.test.ts to demonstrate the fix in isolation. Will push it shortly |
|
@rushabhcodes that gap was a side effect of the visual fix I had for the staircase jitter that's why I zoomed in there in the video. I have already removed that in the latest commit to focus entirely on the core logic so the example snapshots won't change anymore. |

added a merging_collinear phase to the TraceCleanupSolver pipeline
Logic: used an epsilon-based snapping pass in simplifyPath to handle coordinate jitter and force alignment. This solves the "staircase" effect mentioned in #34 and purges redundant points
/claim #34