From e105451f446cf6dec373640e813fd61ddaf3c2fb Mon Sep 17 00:00:00 2001 From: Mario Luzeiro Date: Tue, 10 Nov 2020 16:30:11 +0000 Subject: [PATCH] 3D-Viewer: when possible, uses only the board edges to calculate boundings Add Report messages to Raytracing Fixes https://gitlab.com/kicad/code/kicad/issues/6316 --- 3d-viewer/3d_canvas/board_adapter.cpp | 37 ++++++++++++------- .../c3d_render_createscene.cpp | 7 ++++ 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/3d-viewer/3d_canvas/board_adapter.cpp b/3d-viewer/3d_canvas/board_adapter.cpp index 14be76a19d..312725f4e6 100644 --- a/3d-viewer/3d_canvas/board_adapter.cpp +++ b/3d-viewer/3d_canvas/board_adapter.cpp @@ -278,9 +278,31 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR { wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::InitSettings" ) ); + if( aStatusReporter ) + aStatusReporter->Report( _( "Build board outline" ) ); + + wxString msg; + + const bool succeedToGetBoardPolygon = createBoardPolygon( &msg ); + + if( aWarningReporter ) + { + if( !succeedToGetBoardPolygon ) + aWarningReporter->Report( msg, RPT_SEVERITY_WARNING ); + else + aWarningReporter->Report( wxEmptyString ); + } + // Calculates the board bounding box (board outlines + items) // to ensure any item, even outside the board outlines can be seen - EDA_RECT bbbox = m_board->ComputeBoundingBox( false ); + + bool boardEdgesOnly = true; + + if( m_board->IsFootprintHolder() || !GetFlag( FL_USE_REALISTIC_MODE ) + || !succeedToGetBoardPolygon ) + boardEdgesOnly = false; + + EDA_RECT bbbox = m_board->ComputeBoundingBox( boardEdgesOnly ); // Gives a non null size to avoid issues in zoom / scale calculations if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) ) @@ -422,19 +444,6 @@ void BOARD_ADAPTER::InitSettings( REPORTER* aStatusReporter, REPORTER* aWarningR unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs(); #endif - if( aStatusReporter ) - aStatusReporter->Report( _( "Build board body" ) ); - - wxString msg; - - if( aWarningReporter ) - { - if( !createBoardPolygon( &msg ) ) - aWarningReporter->Report( msg, RPT_SEVERITY_WARNING ); - else - aWarningReporter->Report( wxEmptyString ); - } - if( aStatusReporter ) aStatusReporter->Report( _( "Create layers" ) ); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp index 9868a07b91..0d6d021647 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp @@ -485,6 +485,9 @@ void C3D_RENDER_RAYTRACING::Reload( REPORTER* aStatusReporter, setupMaterials(); + if( aStatusReporter ) + aStatusReporter->Report( _( "Load Raytracing: board" ) ); + // Create and add the outline board // ///////////////////////////////////////////////////////////////////////// @@ -696,6 +699,8 @@ void C3D_RENDER_RAYTRACING::Reload( REPORTER* aStatusReporter, } } + if( aStatusReporter ) + aStatusReporter->Report( _( "Load Raytracing: layers" ) ); // Add layers maps (except B_Mask and F_Mask) // ///////////////////////////////////////////////////////////////////////// @@ -952,6 +957,8 @@ void C3D_RENDER_RAYTRACING::Reload( REPORTER* aStatusReporter, unsigned stats_startLoad3DmodelsTime = stats_endConvertTime; #endif + if( aStatusReporter ) + aStatusReporter->Report( _( "Loading 3D models" ) ); load_3D_models( m_object_container, aOnlyLoadCopperAndShapes );