diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 290c8ed1b7..fe3db632eb 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -305,7 +305,7 @@ void D_PAD::BuildEffectiveShapes() const if( board ) maxError = board->GetDesignSettings().m_MaxError; - TransformRoundChamferedRectToPolygon( outline, wxPoint(0,0), GetSize(), m_Orient, + TransformRoundChamferedRectToPolygon( outline, shapePos, GetSize(), m_Orient, GetRoundRectCornerRadius(), GetChamferRectRatio(), GetChamferPositions(), maxError ); diff --git a/pcbnew/drc/drc.h b/pcbnew/drc/drc.h index a650740d67..d109ee8ed9 100644 --- a/pcbnew/drc/drc.h +++ b/pcbnew/drc/drc.h @@ -259,10 +259,12 @@ private: * @param aRefPad The reference pad to check * @param aPad Another pad to check against * @param aMinClearance is the minimum allowed distance between the pads - * @param aActual [out] it the actual distance (only guaranteed to be set for violations) - * @return bool - true if clearance between aRefPad and aPad is >= aMinClearance, else false + * @param aActualDist [out] it the actual distance + * (only guaranteed to be set for violations) + * @return true if clearance between aRefPad and aPad is >= aMinClearance, else false */ - bool checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance, int* aActual ); + bool checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, + int aMinClearance, int* aActualDist ); /** diff --git a/pcbnew/drc/drc_clearance_test_functions.cpp b/pcbnew/drc/drc_clearance_test_functions.cpp index da105edcae..b0ca0ae029 100644 --- a/pcbnew/drc/drc_clearance_test_functions.cpp +++ b/pcbnew/drc/drc_clearance_test_functions.cpp @@ -687,7 +687,7 @@ void DRC::doTrackDrc( BOARD_COMMIT& aCommit, TRACK* aRefSeg, TRACKS::iterator aS } -bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance, int* aActual ) +bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance, int* aActualDist ) { int center2center = KiROUND( EuclideanNorm( aPad->ShapePos() - aRefPad->ShapePos() ) ); @@ -698,8 +698,10 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance // JEY TODO: // TOM TODO: MTV only works as a proxy for actual-distance for convex shapes - VECTOR2I mtv; - VECTOR2I maxMtv( 0, 0 ); + VECTOR2I mtv; // minimum translation vector calculated by Collide() + VECTOR2I maxMtv( 0, 0 ); // is the move distance between 2 shapes calculated + // by Collide to do not have a collision + bool shapes_collide = false; for( const std::shared_ptr& aShape : aRefPad->GetEffectiveShapes() ) { @@ -707,15 +709,20 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, int aMinClearance { if( aShape->Collide( bShape.get(), aMinClearance, mtv ) ) { + shapes_collide = true; + if( mtv.SquaredEuclideanNorm() > maxMtv.SquaredEuclideanNorm() ) maxMtv = mtv; } } } - if( maxMtv.x > 0 || maxMtv.y > 0 ) + if( shapes_collide ) { - *aActual = std::max( 0, aMinClearance - maxMtv.EuclideanNorm() ); + // returns the actual clearance (clearance < aMinClearance) for diags: + if( aActualDist ) + *aActualDist = std::max( 0, aMinClearance - maxMtv.EuclideanNorm() ); + return false; }