diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index cd62223475..e84341ead6 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -896,8 +896,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } else { - AddPadsShapesWithClearanceToContainer( - module, layerContainer, curr_layer_id, 0, false ); + AddPadsShapesWithClearanceToContainer( module, layerContainer, curr_layer_id, 0, + false ); } AddGraphicsShapesWithClearanceToContainer( module, layerContainer, curr_layer_id, 0 ); diff --git a/pcbnew/board_items_to_polygon_shape_transform.cpp b/pcbnew/board_items_to_polygon_shape_transform.cpp index b1b0014459..a674363c7b 100644 --- a/pcbnew/board_items_to_polygon_shape_transform.cpp +++ b/pcbnew/board_items_to_polygon_shape_transform.cpp @@ -116,8 +116,9 @@ void BOARD::ConvertBrdLayerToPolygonalContours( PCB_LAYER_ID aLayer, SHAPE_POLY_ void MODULE::TransformPadsShapesWithClearanceToPolygon( PCB_LAYER_ID aLayer, - SHAPE_POLY_SET& aCornerBuffer, int aInflateValue, int aMaxError, - bool aSkipNPTHPadsWihNoCopper ) const + SHAPE_POLY_SET& aCornerBuffer, + int aInflateValue, int aMaxError, + bool aSkipNPTHPadsWihNoCopper ) const { for( D_PAD* pad : m_pads ) { @@ -151,27 +152,43 @@ void MODULE::TransformPadsShapesWithClearanceToPolygon( PCB_LAYER_ID aLayer, } } - wxSize margin; - int clearance = aInflateValue; + wxSize clearance( aInflateValue, aInflateValue ); switch( aLayer ) { case F_Mask: case B_Mask: - clearance += pad->GetSolderMaskMargin(); + clearance.x += pad->GetSolderMaskMargin(); + clearance.y += pad->GetSolderMaskMargin(); break; case F_Paste: case B_Paste: - margin = pad->GetSolderPasteMargin(); - clearance += ( margin.x + margin.y ) / 2; + clearance += pad->GetSolderPasteMargin(); break; default: break; } - pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, clearance ); + // Our standard TransformShapeWithClearanceToPolygon() routines can't handle differing + // x:y clearance values (which get generated when a relative paste margin is used with + // an oblong pad). So we apply this huge hack and fake a larger pad to run the transform + // on. + // Of course being a hack it falls down when dealing with custom shape pads (where the + // size is only the size of the anchor), so for those we punt and just use clearance.x. + + if( clearance.x != clearance.y && pad->GetShape() != PAD_SHAPE_CUSTOM ) + { + D_PAD dummy( *pad ); + dummy.SetSize( pad->GetSize() + clearance + clearance ); + dummy.TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, 0, aMaxError ); + } + else + { + pad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, clearance.x, + aMaxError ); + } } }