Fix guaranteed divide-by-zero error when called with correction of 0.

This commit is contained in:
Jeff Young 2020-01-11 16:50:18 +00:00
parent 715448611d
commit 2e509480a4
1 changed files with 12 additions and 5 deletions

View File

@ -645,16 +645,23 @@ void D_PAD::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer,
break;
case PAD_SHAPE_CUSTOM:
{
SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
outline.Append( m_customShapeAsPolygon );
CustomShapeAsPolygonToBoardPosition( &outline, GetPosition(), GetOrientation() );
// TODO: do we need the Simplify() & Fracture() if we're not inflating?
outline.Simplify( SHAPE_POLY_SET::PM_FAST );
if( aClearanceValue )
{
int numSegs = std::max( GetArcToSegmentCount( aClearanceValue, aError, 360.0 ),
pad_min_seg_per_circle_count );
double correction = GetCircletoPolyCorrectionFactor( numSegs );
int clearance = KiROUND( aClearanceValue * correction );
SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
outline.Append( m_customShapeAsPolygon );
CustomShapeAsPolygonToBoardPosition( &outline, GetPosition(), GetOrientation() );
outline.Simplify( SHAPE_POLY_SET::PM_FAST );
outline.Inflate( clearance, numSegs );
}
outline.Fracture( SHAPE_POLY_SET::PM_FAST );
aCornerBuffer.Append( outline );
}