Skip to content

fix: skip pcb pad overlap check for elements on different layers#121

Merged
rushabhcodes merged 4 commits intotscircuit:mainfrom
rushabhcodes:fix/pad-overlap-different-layers
Mar 12, 2026
Merged

fix: skip pcb pad overlap check for elements on different layers#121
rushabhcodes merged 4 commits intotscircuit:mainfrom
rushabhcodes:fix/pad-overlap-different-layers

Conversation

@rushabhcodes
Copy link
Copy Markdown
Contributor

@rushabhcodes rushabhcodes commented Mar 12, 2026

Problem

SMT pads positioned at the same XY coordinates but on different layers (e.g. top vs bottom) were incorrectly reported as overlapping. Since these pads exist on physically separate copper planes, there is no actual conflict.

/fixes #120

Fix

Updated doPcbElementsOverlap to check layer intersection before comparing XY bounds. If the two elements share no common layers, the function returns false immediately without performing a bounds check.

  • pcb_smtpad elements carry a single layer value
  • pcb_plated_hole / pcb_hole / pcb_via span all layers and will still be checked against everything (correct behaviour preserved)

Tests

Added different-layer-pads-no-overlap.test.ts with snapshot tests:

  1. Pads on top vs bottom at the same position → 0 errors (reproduces the bug and confirms the fix)

Copilot AI review requested due to automatic review settings March 12, 2026 19:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes false-positive PCB overlap errors by making overlap detection layer-aware, so copper features on different layers (e.g. top vs bottom) are not treated as physically colliding.

Changes:

  • Add a layer-intersection early-return to doPcbElementsOverlap before doing XY bounds overlap.
  • Add a regression test covering SMT pads on different layers and its SVG snapshot output.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
lib/check-pcb-components-overlap/doPcbElementsOverlap.ts Adds layer intersection logic to skip overlap checks for elements on disjoint layers.
tests/lib/check-pcb-component-overlap/different-layer-pads-no-overlap.test.ts Adds regression test ensuring different-layer SMT pads aren’t flagged as overlapping.
tests/lib/check-pcb-component-overlap/__snapshots__/different-layer-pads-no-overlap.snap.svg Adds snapshot for the new regression test’s rendered PCB SVG.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rushabhcodes rushabhcodes requested a review from seveibar March 12, 2026 19:16
- Updated the test for SMT pads on different layers to utilize a circuit JSON file instead of hardcoded data.
- Adjusted the error handling to incorporate errors from the overlap check into the circuit JSON for SVG conversion.
- Enhanced SVG snapshot comparison to reflect the new structure of the test data.
@rushabhcodes
Copy link
Copy Markdown
Contributor Author

@imrishabh18 fixed

@rushabhcodes rushabhcodes merged commit f3ed786 into tscircuit:main Mar 12, 2026
7 checks passed
@rushabhcodes rushabhcodes deleted the fix/pad-overlap-different-layers branch March 12, 2026 20:10
@tscircuitbot
Copy link
Copy Markdown
Contributor


Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pads on different layers are throwing overlap errors (they are not overlapping, they are on separate layers)

4 participants