Commit Graph

1445 Commits

Author SHA1 Message Date
Seth Hillbrand 2451cbddec Consolidate Maximum clearance calculation
We were calculating the same thing in three locations and we missed
adding the clearance from the footprints in, resulting in bad fills and
missed drc errors (see QA addition)

(cherry picked from commit 96a34e5b57)
2023-07-26 13:16:32 -07:00
Jeff Young a43adf7d4f Allow routing to a free pad (even if it has a hole).
Fixes https://gitlab.com/kicad/code/kicad/-/issues/15093

(cherry picked from commit 6da71e5d24)
2023-07-09 21:55:21 +01:00
Tomasz Wlostowski 2f35d97b27 router: when no collision search context is provided, assume differentNetsOnly is true
(cherry picked from commit a0a68d198c)
2023-06-23 07:55:50 -04:00
Tomasz Wlostowski 152dc56df4 router: provisional fix for 14926
(cherry picked from commit bd5954242e)
2023-06-22 12:54:22 -04:00
Jeff Young d3099ecf75 Don't create 22.5-degree gateways if we're not cardinal or diagonal.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14984
2023-06-17 16:05:07 +01:00
Jeff Young a348fde7d1 Assertion checking for hole/parent ownership mismatch.
(This mismatch is the root of the problem in issue #14852.)
2023-06-10 01:05:00 +02:00
Tomasz Włostowski d25017dd5b router: can't add a clone of a VIA's hole when adding the via to INDEX - this will result in bogus colliding objects
This commit partially reverts deb3cbf8. VIA and SOLID operator='s introduced in it do a good job but the cloning of holes in addHole() causes bogus collisions.
2023-06-10 01:04:49 +02:00
Jeff Young 9b965f367a Prevent use-after-free crashes by not fighting over who owns a HOLE.
The diff-pair placer creates DIFF_PAIRs on the stack, which have
VIAs in them, which have HOLEs in them.  The HOLEs get put in the
NODE's index, and we then crash later when doing a collision after
the stack variable has gone out of scope.

The stack variable is also copied while doing a search for "best",
and without the operator= definitions the "best" and the "original"
both think they own the HOLE.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14852
2023-06-10 01:04:37 +02:00
Tomasz Wlostowski adca34ac6a router: invalidate items freed by PNS::NODE in the clearance cache
This was causing intermittent shove hiccups/freezes as RULE_RESOLVER::GetClearance() could return a bogus clearance value, taking
a cached value for an item that does not exist anymore. If the allocator/stack accidentally reclaimed such item's address - we were getting
very nasty and difficult to reproduce misbehaviours of the shove algorithm. Hopefully this patch fixes this. More info in the comments.

Note to self - I'm still not fully convinced I want PNS::ITEM pointers as the cache key, probably a unique counter would be better here.
2023-06-10 01:04:25 +02:00
Tomasz Wlostowski 51a4a92ec4 router: fix use-after-free crash in drag walkaround mode 2023-06-10 01:04:13 +02:00
Tomasz Wlostowski ae8ea3b938 router: correctly assign owner via/pad to its hole when committing the world state
fixes #14852
2023-06-10 00:27:38 +02:00
Jeff Young 214f785c97 Use rendered text to generate bounding box for knockout text.
Don't open-code knockout text shape generation in several different
places.

Make sure triangulated knockout text gets clearance added when
specified.

Collapse duplicated footprint text item plot routine (they're no
longer any different from plotting pcb text items).

(cherry picked from commit c71cf21e2f)
2023-06-06 11:19:41 +01:00
Jeff Young dfd11b7596 Reconcile PNS router with DRC.
Hole-to-hole is only for drilled holes.
NPTH slots also get EDGE_CLEARANCE applied.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14771

(cherry picked from commit df763eaf88)
(cherry picked from commit ad9109cad4)
2023-05-28 19:38:27 +02:00
Tomasz Wlostowski 0180cb380f router: prevent pushout/bogus collision of via with is own hole (or copper) when dragging
The root cause was not removing the original (pre-dragging) via from the world, comparing the ITEM::Parent() pointers of the items was only hiding the main issue.
This also fixes the PNSViaCollisions test in the qa/ suite.
2023-05-24 19:47:20 -07:00
Jeff Young 882e48b457 Don't allow collisions with self.
The previous test didn't handle is-self-tests between a hole and
its override in a different NODE.  When calculating the pushout
force we don't remove the via (and its hole) from the current
node until after the calculation, so we end up checking for
collisions between the new (cloned) via's hole and the original
hole in the root node.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14795

(cherry picked from commit b442d769fd)
2023-05-24 08:54:27 -07:00
Seth Hillbrand 1958cafbdf Revert "Reconcile PNS router with DRC."
This reverts commit ad9109cad4.
2023-05-24 08:54:16 -07:00
Jeff Young ad9109cad4 Reconcile PNS router with DRC.
Hole-to-hole is only for drilled holes.
NPTH slots also get EDGE_CLEARANCE applied.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14771

(cherry picked from commit df763eaf88)
2023-05-23 09:40:32 +01:00
Jon Evans f02cd717bc PNS: Collision search context may be null
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14741


(cherry picked from commit 94130716a5)
2023-05-14 21:21:19 +00:00
Alex 91f40ac779 Make sure text bounding box exists when syncing PNS world.
Based on d790865549

Fixes https://gitlab.com/kicad/code/kicad/issues/14733
2023-05-14 15:37:45 +03:00
Steve Bollinger 1020cdd7a6 pcbnew: switching track posture may not work on first attempt
If you drag a track out and connect to a pad then press the hotkey
to switch the track posture it may not switch because the track
posture selected when the pad was reached is different than the one
that the mouse trail placer drew. As the aspect switching is done
in the mouse trail placer it does not know that the line placer
already override the track.

To correct this, in LINE_PLACER::FlipPosture() if the aspect is not
currently manually forced then copy the current aspect from the
line placer to m_mouseTrailPlacer before calling the FlipPosture()
method of m_mouseTrailPlacer. This will only be done once per
dragging session as once the aspect is manually forced it remains
manually forced. This seems to fix the issue with no undesirable
side effects.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/12369
(cherry picked from commit 85f4f0d6c8)
2023-05-11 16:36:21 -07:00
Jon Evans 253ff41819 PNS: make sure context options are used in collideSimple
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14659


(cherry picked from commit 89aae88e96)
2023-05-11 20:48:56 +00:00
Jon Evans 24d95b410d PNS: Don't use clearance epsilon for calculating shove distances
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14707


(cherry picked from commit 2e60315959)
2023-05-11 20:48:46 +00:00
Jeff Young 8e1bcaed37 Holes need a parent.
SetHole() handles all this for us.  Make sure it's called.

Fixes https://gitlab.com/kicad/code/kicad/issues/14702

(cherry picked from commit 5b3798a370)
2023-05-08 14:51:47 +01:00
Jon Evans f3c864c178 PNS: Remove holes when removing items with holes
Related to https://gitlab.com/kicad/code/kicad/-/issues/14702


(cherry picked from commit b06f90335b)
2023-05-08 02:48:55 +00:00
Jeff Young 947923509e Fix a typo.
Fixes https://gitlab.com/kicad/code/kicad/issues/14515

(cherry picked from commit 6059e895d7)
2023-05-08 03:32:32 +03:00
Seth Hillbrand ce5f72207e Cleanup printf bits
(cherry picked from commit 990641d2eb)
2023-05-07 19:02:02 +03:00
Jeff Young c31c14e46b Don't call BuildInitialTrace() for entry gateways.
We're going to call it to connect the entry and target gateways
anyway, so all we need are gateways at 22.5 degrees to setup entry
at +/- 45 degrees from the current direction.

Fixes https://gitlab.com/kicad/code/kicad/issues/14324

Fixes https://gitlab.com/kicad/code/kicad/issues/12459

(cherry picked from commit 507a25f150)
2023-05-04 11:52:02 +01:00
Jeff Young ebc14b35f5 Commenting and formatting. 2023-05-02 14:14:05 +01:00
Jeff Young 2acc0a6844 Use Net() accessor uniformly; init hole parent in VIA::Clone()
Fixes https://gitlab.com/kicad/code/kicad/issues/14603

(cherry picked from commit 16e000f2b0)
2023-04-28 18:33:27 +01:00
Lucas Dumont 8ffba3a52f Update collide for hole
As hole don't keep track of the net, update the collide function to keep it working

(cherry picked from commit b1a4353c34)
2023-04-28 16:20:31 +01:00
Jeff Young f8270b9cec Tighten ownership model of PNS::ITEM.
In particular, ownership must be explicitly set.  It is
no longer inherited through copy/clone/etc.
2023-04-28 11:03:24 +01:00
Jeff Young 21eb2c8dad Simplify PNS::VIA construction.
(cherry picked from commit 9646e3c1c0)
2023-04-28 00:33:27 +01:00
Lucas Dumont 9a0e2f3395 Fix typo in QueryConstraint switch
(cherry picked from commit 2992d7c68b)
2023-04-26 14:21:38 +01:00
Lucas Dumont b926d2f0bd Don't override clearance when routing
The default `m_overrideClearance = -1` used here was changed to 1.
Reseting it to -1 to solve linked issue

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14595

(cherry picked from commit e2e901de1d)
2023-04-25 10:21:13 +01:00
Jeff Young 89d1d36e79 Don't try to keep track of a HOLE's net.
Keep track of it's parentPadVia instead.

Fixes https://gitlab.com/kicad/code/kicad/issues/14603

(cherry picked from commit 676a15df65)
2023-04-24 18:32:48 +01:00
Lucas Dumont 0736c141b9 pcbnew: Fix crash with differential routing
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14537

(cherry picked from commit 469fe76994)
2023-04-17 09:48:18 +01:00
Jeff Young 2d13ddc70c Fix PNS_KICAD_IFACE_BASE::IsFlashedOnLayer() to be able to handle multi-layer queries. 2023-04-14 10:59:10 +01:00
Jeff Young 0be01f3c24 Don't steal an existing via's hole.
(cherry picked from commit 6fb30398ca)
2023-04-14 10:09:03 +01:00
Jeff Young eb492724c7 Further simplify PNS::ITEM::collideSimple().
Also brings text_pns_basic's mocks into line with their "real"
counterparts.

(cherry picked from commit 2f198bdcb2)
2023-04-14 10:09:03 +01:00
Jeff Young 3b05d03220 Add PNS::ITEM::BoardItem() call.
About 1/3 of callers to Parent() don't care if they get the immediate
parent or not, about 1/3 want only the immediate parent, and about 1/3
want the hole parent's Parent().

I had earlier changed PNS::ITEM::HOLE to override Parent() and return
the hole parent's Parent(), but since the callers are pretty evenly
split I've reverted that and added BoardItem() for callers who want the
eventual BOARD_ITEM (whether a direct parent or a grandparent).

(Also removes a dead routine so I didn't have to figure out which of
the two it wanted....)

(cherry picked from commit 6f0d963683)
2023-04-14 10:09:03 +01:00
Jeff Young 4c04233a20 Unify most special-case processing to the clearance if-then-else.
This also allows us to support hole-to-hole clearance when dragging
a via near another via on the same net.

Fixes https://gitlab.com/kicad/code/kicad/issues/12781

(cherry picked from commit 8a0c225efa)
2023-04-14 00:10:48 +01:00
Jeff Young 2b6d2fc117 Don't return holes that have a parent pad or via.
(While we don't currently have holes without a parent pad or via, you
could imagine using HOLEs in the future to represent a hole in a first-class
board outline, so better not to build this assumption in.)

(cherry picked from commit b18bf09208)
2023-04-14 00:10:43 +01:00
Jeff Young f64ef39687 Post-merge cleanup of holes-as-first-class-citizens.
(cherry picked from commit 4cc289c6fb)
2023-04-14 00:10:34 +01:00
Tomasz Wlostowski c1fb392333 router: hole as first-class-object, initial version of rewritten collision check routine
Rebased and modified by Jeff Young <jeff@rokeby.ie> 6 April 2023

(cherry picked from commit 1532a83330)
2023-04-14 00:10:07 +01:00
Tomasz Wlostowski de60d5467c router: further changes to the ownership model
- LINEs now own their vias optionally (depending whether a LINE with its VIA belongs to a node)
- get rid of unique_ptr on the internal NODE::Add API (and also made it private)
- make sure stack pointers are not added to the node
- use rvalue reference for NODE::Add/NODE::Replace

Manually rebased by Jeff Young <jeff@rokeby.ie> 5 April 2023

(cherry picked from commit d961cdce3f)
2023-04-14 00:10:01 +01:00
Tomasz Wlostowski c1274e24b0 router: hole as first class objects, wip
Rebased by Jeff Young <jeff@rokeby.ie> 5 April 2023

(Also includes a bug-fix for highlighting collisions with edge-cut
items.)

(cherry picked from commit bfbda978b8)
2023-04-14 00:09:56 +01:00
Tomasz Wlostowski 7f593d3999 router: rework ITEM ownership model.
- prerequisite for holes as first class objects code
- introduced the OWNABLE_ITEM interface that defines the owning container (NODE/other ITEM/ITEM_SET)
- simplified the ITEM_SET interface
- constified a lot of APIs (ownership/JOINT management) as a side effect

Rebased and cleaned up by Jeff Young <jeff@rokeby.ie> 5 April 2023
- some STL cover types removed

(cherry picked from commit 1283c4713f)
2023-04-14 00:09:49 +01:00
Tomasz Wlostowski 3a6a6097a7 router: pass collision query options in a structure
Selectively cherry-picked by Jeff Young <jeff@rokeby.ie> 4 April 2023
- Jon's user-clearance-epsilon algo kept intact
- Jeff's castellated-pad code kept intact

(cherry picked from commit eed05191a9)
2023-04-14 00:07:47 +01:00
Jeff Young 323a2d83fa Ease acquisition of a target item.
pickSingleItem() had a two-attempt algorithm, but the second attempt
was never made because we'd check for no hits before throwing out the
aAvoidItems.

The second attempt would fail anyway because QueryHoverItems() ignored
the aUseClearance flag when not idle, and didn't factor in the actual
clearance.

(cherry picked from commit d040690f60)
2023-04-09 23:13:44 +01:00
Jeff Young 03c3393616 Handle more pad shapes when building diffpair gateways.
Fixes https://gitlab.com/kicad/code/kicad/issues/1883

(cherry picked from commit 1d19672054)
2023-04-09 23:07:38 +01:00