From 85fa6d80256de4bcf86ca04b0875b7d1a4b9022b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 27 Mar 2020 10:30:03 +0100 Subject: [PATCH] 3D viewer: apply patch from master 04d6ea982. The 3D viewer does not show the issue on solder paste layer having negative clearance. However the bug was here and not seen just because some draw code was different: The code tried to draw outlines with segments having a negative thickness. It happens mainly on solder paste layers. --- .../3d_canvas/create_3Dgraphic_brd_items.cpp | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index 9586a0ad2e..e0dbf8d6ef 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -386,9 +386,22 @@ void CINFO3D_VISU::createNewPadWithClearance( const D_PAD* aPad, case PAD_SHAPE_RECT: { // see pcbnew/board_items_to_polygon_shape_transform.cpp - wxPoint corners[4]; - aPad->BuildPadPolygon( corners, aClearanceValue, aPad->GetOrientation() ); + bool drawOutline; + + // For aClearanceValue.x == aClearanceValue.y and > 0 we use the pad shape + // and draw outlines with thicknes = aClearanceValue. + // Otherwise we draw only the inflated/deflated shape + if( aClearanceValue.x > 0 && aClearanceValue.x == aClearanceValue.y ) + { + drawOutline = true; + aPad->BuildPadPolygon( corners, wxSize( 0, 0 ), aPad->GetOrientation() ); + } + else + { + drawOutline = false; + aPad->BuildPadPolygon( corners, aClearanceValue, aPad->GetOrientation() ); + } SFVEC2F corners3DU[4]; @@ -416,20 +429,23 @@ void CINFO3D_VISU::createNewPadWithClearance( const D_PAD* aPad, // Add the PAD contours // Round segments cannot have 0-length elements, so we approximate them // as a small circle - for( int i = 1; i <= 4; i++ ) + if( drawOutline ) { - if( Is_segment_a_circle( corners3DU[i - 1], corners3DU[i & 3] ) ) + for( int i = 1; i <= 4; i++ ) { - aDstContainer->Add( new CFILLEDCIRCLE2D( corners3DU[i - 1], - aClearanceValue.x * m_biuTo3Dunits, - *aPad ) ); - } - else - { - aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[i - 1], - corners3DU[i & 3], - aClearanceValue.x * 2.0f * m_biuTo3Dunits, - *aPad ) ); + if( Is_segment_a_circle( corners3DU[i - 1], corners3DU[i & 3] ) ) + { + aDstContainer->Add( new CFILLEDCIRCLE2D( corners3DU[i - 1], + aClearanceValue.x * m_biuTo3Dunits, + *aPad ) ); + } + else + { + aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[i - 1], + corners3DU[i & 3], + aClearanceValue.x * 2.0f * m_biuTo3Dunits, + *aPad ) ); + } } } }