diff --git a/common/geometry/shape_collisions.cpp b/common/geometry/shape_collisions.cpp index 677c9e1d6f..806a50244b 100644 --- a/common/geometry/shape_collisions.cpp +++ b/common/geometry/shape_collisions.cpp @@ -175,7 +175,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_SEGMENT& aSeg, i if( col && aNeedMTV ) { - aMTV = pushoutForce( aA, aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2); + aMTV = -pushoutForce( aA, aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2); } return col; } @@ -231,16 +231,28 @@ static inline bool Collide( const SHAPE_LINE_CHAIN& aA, const SHAPE_SEGMENT& aB, } -template bool -CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) +template +inline bool CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { return Collide (*static_cast( aA ), *static_cast( aB ), aClearance, aNeedMTV, aMTV); } -bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) +template +inline bool CollCaseReversed ( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { + bool rv = Collide (*static_cast( aB ), + *static_cast( aA ), + aClearance, aNeedMTV, aMTV); + if(rv && aNeedMTV) + aMTV = -aMTV; + return rv; +} + + +bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) +{ switch( aA->Type() ) { case SH_RECT: @@ -263,8 +275,8 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed switch( aB->Type() ) { case SH_RECT: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); - + return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); + case SH_CIRCLE: return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); @@ -272,8 +284,9 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); case SH_SEGMENT: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - default: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + + default: break; } @@ -303,7 +316,7 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); case SH_CIRCLE: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); case SH_LINE_CHAIN: return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index ed82b947bf..e5f4dfc46f 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -597,7 +597,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::onCollidingVia (PNS_ITEM* aCurrent, PNS_VIA* { CollideShapes( aObstacleVia->Shape(), aCurrent->Shape(), clearance + PNS_HULL_MARGIN, true, mtvSolid ); - mtv = mtvSolid; + mtv = -mtvSolid; rank = aCurrent->Rank() + 10000; } @@ -924,7 +924,7 @@ PNS_SHOVE::SHOVE_STATUS PNS_SHOVE::ShoveLines( const PNS_LINE& aCurrentHead ) if( m_newHead && st == SH_OK ) { st = SH_HEAD_MODIFIED; - Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 ); + //Router()->DisplayDebugLine( m_newHead->CLine(), 3, 20000 ); } m_currentNode->RemoveByMarker( MK_HEAD );