Ensure that arc closest positions are matched

We switch from squared to absolute calcualtion when calling into the arc
collision so be sure to catch the new positions and distances
This commit is contained in:
Seth Hillbrand 2024-05-17 10:58:56 -07:00
parent 625d241adf
commit 160a493885
1 changed files with 5 additions and 3 deletions

View File

@ -662,12 +662,13 @@ bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance, int* aActual,
for( size_t i = 0; i < ArcCount(); i++ )
{
const SHAPE_ARC& arc = Arc( i );
VECTOR2I pos;
// The arcs in the chain should have zero width
wxASSERT_MSG( arc.GetWidth() == 0, wxT( "Invalid arc width - should be zero" ) );
if( arc.Collide( aSeg, aClearance, aActual || aLocation ? &dist : nullptr,
aLocation ? &nearest : nullptr ) )
aLocation ? &pos : nullptr ) )
{
if( !aActual )
return true;
@ -675,17 +676,18 @@ bool SHAPE_LINE_CHAIN::Collide( const SEG& aSeg, int aClearance, int* aActual,
if( dist < closest_dist )
{
closest_dist = dist;
nearest = pos;
}
}
}
if( closest_dist_sq == 0 || closest_dist_sq < clearance_sq )
if( closest_dist == 0 || closest_dist < aClearance )
{
if( aLocation )
*aLocation = nearest;
if( aActual )
*aActual = sqrt( closest_dist_sq );
*aActual = closest_dist;
return true;
}