mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 00:21:31 +00:00
Implement MTV for arcs
This commit is contained in:
parent
b73481dd49
commit
bcebc694b8
@ -734,16 +734,13 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_LINE_CHAIN_BASE& aB
|
||||
static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_ARC& aB, int aClearance,
|
||||
int* aActual, VECTOR2I* aLocation, VECTOR2I* aMTV )
|
||||
{
|
||||
wxASSERT_MSG( !aMTV, wxString::Format( wxT( "MTV not implemented for %s : %s collisions" ),
|
||||
aA.TypeName(),
|
||||
aB.TypeName() ) );
|
||||
|
||||
VECTOR2I ptA, ptB;
|
||||
int64_t dist_sq = std::numeric_limits<int64_t>::max();
|
||||
aA.NearestPoints( aB, ptA, ptB, dist_sq );
|
||||
int dual_width = ( aA.GetWidth() + aB.GetWidth() ) / 2;
|
||||
int min_dist = aClearance + dual_width;
|
||||
|
||||
if( dist_sq < SEG::Square( aClearance + dual_width ) )
|
||||
if( dist_sq < SEG::Square( min_dist ) )
|
||||
{
|
||||
if( aLocation )
|
||||
*aLocation = ( ptA + ptB ) / 2;
|
||||
@ -751,6 +748,12 @@ static inline bool Collide( const SHAPE_ARC& aA, const SHAPE_ARC& aB, int aClear
|
||||
if( aActual )
|
||||
*aActual = std::max( 0, KiROUND( std::sqrt( dist_sq ) - dual_width ) );
|
||||
|
||||
if( aMTV )
|
||||
{
|
||||
const VECTOR2I delta = ptB - ptA;
|
||||
*aMTV = delta.Resize( min_dist - std::sqrt( dist_sq ) + 3 );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user