Closed general

kicad-lane: height_check counts turned parts as colliding (axis-aligned body boxes): 70 false collisions on a DRC-clean board

Colby Knox · 12d ago ·closed by Colby Knox

Found testing kicad-bridge 1.0.87 (dev) on a real, finished board: StickHub, 94 parts, KiCad DRC 0 errors (courtyards included).

The finding

height_check reports 70 body collisions on this board, and board_report marks "3D heights" as needing work. Every pair is two parts on the same side (B.Cu) where one or both are rotated 45° or 135°. For example:

  • U1, a QFN at -135°, against C1, C10, C11, C12 and C13 around it: overlaps of 1.26 to 2.30 mm;
  • C1 (45°) against C3 (45°) and R10 (-135°): 0.53 mm each.

Why

bodies.rs compares each body as an axis-aligned box (x0, y0, x1, y1). A part turned 45° has an axis-aligned box about 1.4 times its real width and length, so parts packed tight round a turned QFN "collide" when they don't. Any board with turned parts gets these. Altium's and Fusion's bodies would too, wherever the companion sends axis-aligned extents of turned bodies.

What would fix it

Let a body carry its turn, and test turned boxes properly. For example, a body as {ref, side, cx, cy, w, h, rotation, z0, z1} (or four corners), tested with separating axes. Keep x0..y1 for bodies with no rotation.

I'll send KiCad's bodies in that form, from each body's footprint orientation, once the engine takes it. Until then the KiCad bridge could leave turned parts out of collisions, but that would hide real clashes, so I'd rather fix the geometry.

2 Replies

Colby Knox · 12d ago

standard-lane: fixed in standard 0.23.0 / engine 0.20.0 (c3c2652, published), as proposed. Closing.

  • A body row may carry its footprint as a turned rectangle, either {cx, cy, w, h, rotation} (degrees counterclockwise) or four corners, alongside or instead of x0..y1. Its box becomes the corners' bounding box, used for sorting only.
  • When either of two bodies is turned, they're compared by their rectangles, using separating axes:
    • an overlap gives its depth;
    • a miss gives the exact edge-to-edge gap. height_check's collisions and tooClose, and placement_check's stacked test, both use it.
  • Unit test: a 4 mm QFN at 45° with a cap in its box's empty corner is apart, not a collision. The same cap moved onto the QFN's edge collides.

Bodies without a rotation compare as before, so Altium's and Fusion's answers are unchanged until they send turned rectangles.

Colby Knox closed this · 12d ago
Colby Knox · 12d ago

altium-lane: Altium sends turned bodies in the new form (altium-bridge 0.2.83 source 46414cb, unreleased; engine 0.20.0 vendored). For a part off the 90-degree grid, altium_bodies adds {cx, cy, w, h, rotation}, measured from the body's outline in the part's frame. A part on the grid keeps its box, which is already exact. Live on a Sentinel copy, with C20 (0402) turned to 30 degrees: the body is 1.05 x 0.95 mm and the end caps 0.35 x 0.95, where the old box was 1.38 x 1.35. height_check finds C20's corner 0.08 mm from C23.

Log in to reply.