diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index aff06b7ea4..cf9c3a15d1 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -1473,6 +1473,20 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& } +bool PAD::HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const +{ + VECTOR2I delta = aPosition - GetPosition(); + int boundingRadius = GetBoundingRadius() + aAccuracy; + + if( delta.SquaredEuclideanNorm() > SEG::Square( boundingRadius ) ) + return false; + + bool contains = GetEffectivePolygon( aLayer, ERROR_INSIDE )->Contains( aPosition, -1, aAccuracy ); + + return contains; +} + + bool PAD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const { VECTOR2I delta = aPosition - GetPosition(); diff --git a/pcbnew/pad.h b/pcbnew/pad.h index a7b6b3c96f..ab634422c8 100644 --- a/pcbnew/pad.h +++ b/pcbnew/pad.h @@ -823,6 +823,11 @@ public: bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override; + /** + * return true if hit test on the specified layer + */ + bool HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const; + /** * Recombines the pad with other graphical shapes in the footprint * diff --git a/pcbnew/teardrop/teardrop.cpp b/pcbnew/teardrop/teardrop.cpp index 97e5983df2..07d172e69d 100644 --- a/pcbnew/teardrop/teardrop.cpp +++ b/pcbnew/teardrop/teardrop.cpp @@ -275,8 +275,8 @@ void TEARDROP_MANAGER::UpdateTeardrops( BOARD_COMMIT& aCommit, continue; } - bool startHitsPad = pad->HitTest( track->GetStart() ); - bool endHitsPad = pad->HitTest( track->GetEnd() ); + bool startHitsPad = pad->HitTest( track->GetStart(), 0, track->GetLayer() ); + bool endHitsPad = pad->HitTest( track->GetEnd(), 0, track->GetLayer() ); // The track is entirely inside the pad; cannot create a teardrop if( startHitsPad && endHitsPad ) diff --git a/pcbnew/teardrop/teardrop_utils.cpp b/pcbnew/teardrop/teardrop_utils.cpp index 8204967f12..e618aaacf4 100644 --- a/pcbnew/teardrop/teardrop_utils.cpp +++ b/pcbnew/teardrop/teardrop_utils.cpp @@ -724,10 +724,10 @@ bool TEARDROP_MANAGER::computeTeardropPolygon( const TEARDROP_PARAMETERS& aParam { PAD* pad = static_cast( aOther ); - if( pad->HitTest( pointA ) ) + if( pad->HitTest( pointA, 0, layer ) ) return false; - if( pad->HitTest( pointB ) ) + if( pad->HitTest( pointB, 0, layer ) ) return false; }