From 78f70b45e6f4d837a036b3a7a13a96de4714bd0f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 22 Sep 2023 14:03:15 +0100 Subject: [PATCH] Minor readability improvements. --- 3d-viewer/3d_canvas/board_adapter.cpp | 2 +- 3d-viewer/3d_canvas/board_adapter.h | 12 +-- 3d-viewer/3d_canvas/create_layer_items.cpp | 82 +++++++++---------- .../3d_rendering/opengl/create_scene.cpp | 9 +- .../3d_rendering/opengl/render_3d_opengl.cpp | 47 ++++++----- .../3d_rendering/raytracing/create_scene.cpp | 24 +++--- .../3d_viewer/eda_3d_viewer_settings.cpp | 2 +- 3d-viewer/3d_viewer/eda_3d_viewer_settings.h | 2 +- .../dialogs/panel_3D_display_options.cpp | 4 +- 9 files changed, 91 insertions(+), 93 deletions(-) diff --git a/3d-viewer/3d_canvas/board_adapter.cpp b/3d-viewer/3d_canvas/board_adapter.cpp index a78c8fcf9c..24c122ca89 100644 --- a/3d-viewer/3d_canvas/board_adapter.cpp +++ b/3d-viewer/3d_canvas/board_adapter.cpp @@ -106,7 +106,7 @@ BOARD_ADAPTER::BOARD_ADAPTER() : m_TH_IDs.Clear(); m_TH_ODs.Clear(); - m_THAnnularRings.Clear(); + m_viaAnnuli.Clear(); m_copperLayersCount = 2; diff --git a/3d-viewer/3d_canvas/board_adapter.h b/3d-viewer/3d_canvas/board_adapter.h index 0cd9b93835..8289514fcb 100644 --- a/3d-viewer/3d_canvas/board_adapter.h +++ b/3d-viewer/3d_canvas/board_adapter.h @@ -262,14 +262,14 @@ public: return m_TH_ODPolys; } - const BVH_CONTAINER_2D& GetTHAnnularRings() const noexcept + const BVH_CONTAINER_2D& GetViaAnnuli() const noexcept { - return m_THAnnularRings; + return m_viaAnnuli; } - const SHAPE_POLY_SET& GetTHAnnularRingPolys() const noexcept + const SHAPE_POLY_SET& GetViaAnnuliPolys() const noexcept { - return m_THAnnularRingPolys; + return m_viaAnnuliPolys; } const SHAPE_POLY_SET& GetNPTH_ODPolys() const noexcept @@ -441,7 +441,7 @@ private: SHAPE_POLY_SET m_NPTH_ODPolys; ///< NPTH outer diameters SHAPE_POLY_SET m_TH_ODPolys; ///< PTH outer diameters SHAPE_POLY_SET m_viaTH_ODPolys; ///< Via hole outer diameters - SHAPE_POLY_SET m_THAnnularRingPolys; ///< Via annular ring outer diameters + SHAPE_POLY_SET m_viaAnnuliPolys; ///< Via annular ring outer diameters SHAPE_POLY_SET m_board_poly; ///< Board outline polygon. @@ -453,7 +453,7 @@ private: BVH_CONTAINER_2D m_TH_ODs; ///< List of PTH outer diameters BVH_CONTAINER_2D m_TH_IDs; ///< List of PTH inner diameters - BVH_CONTAINER_2D m_THAnnularRings; ///< List of via annular rings + BVH_CONTAINER_2D m_viaAnnuli; ///< List of via annular rings BVH_CONTAINER_2D m_viaTH_ODs; ///< List of via hole outer diameters unsigned int m_copperLayersCount; diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index 695a613228..3c0a1e9bb3 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -125,7 +125,7 @@ void BOARD_ADAPTER::destroyLayers() m_NPTH_ODPolys.RemoveAllContours(); m_TH_ODPolys.RemoveAllContours(); m_viaTH_ODPolys.RemoveAllContours(); - m_THAnnularRingPolys.RemoveAllContours(); + m_viaAnnuliPolys.RemoveAllContours(); DELETE_AND_FREE_MAP( m_layerMap ) DELETE_AND_FREE_MAP( m_layerHoleMap ) @@ -135,7 +135,7 @@ void BOARD_ADAPTER::destroyLayers() m_TH_ODs.Clear(); m_TH_IDs.Clear(); - m_THAnnularRings.Clear(); + m_viaAnnuli.Clear(); m_viaTH_ODs.Clear(); } @@ -157,6 +157,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) PCB_LAYER_ID cu_seq[MAX_CU_LAYERS]; LSET cu_set = LSET::AllCuMask( m_copperLayersCount ); + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_Cfg->m_Render; + std::bitset visibilityFlags = GetVisibleLayers(); m_trackCount = 0; @@ -225,22 +227,20 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D; m_layerMap[layer] = layerContainer; - if( m_Cfg->m_Render.opengl_copper_thickness - && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL ) + if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL ) { - SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET; + SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET; m_layers_poly[layer] = layerPoly; } } - if( m_Cfg->m_Render.renderPlatedPadsAsPlated ) + if( cfg.renderPlatedPadsAsPlated ) { m_frontPlatedPadPolys = new SHAPE_POLY_SET; m_backPlatedPadPolys = new SHAPE_POLY_SET; m_platedPadsFront = new BVH_CONTAINER_2D; m_platedPadsBack = new BVH_CONTAINER_2D; - } if( aStatusReporter ) @@ -332,16 +332,11 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) m_viaTH_ODs.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius + thickness, *track ) ); - if( m_Cfg->m_Render.clip_silk_on_via_annulus && ring_radius > 0.0 ) - { - m_THAnnularRings.Add( new FILLED_CIRCLE_2D( via_center, ring_radius, - *track ) ); - } + if( cfg.clip_silk_on_via_annuli && ring_radius > 0.0 ) + m_viaAnnuli.Add( new FILLED_CIRCLE_2D( via_center, ring_radius, *track ) ); if( hole_inner_radius > 0.0 ) - { m_TH_IDs.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius, *track ) ); - } } } } @@ -419,9 +414,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) TransformCircleToPolygon( m_viaTH_ODPolys, via->GetStart(), hole_outer_radius, maxError, ERROR_INSIDE ); - if( m_Cfg->m_Render.clip_silk_on_via_annulus ) + if( cfg.clip_silk_on_via_annuli ) { - TransformCircleToPolygon( m_THAnnularRingPolys, via->GetStart(), + TransformCircleToPolygon( m_viaAnnuliPolys, via->GetStart(), hole_outer_ring_radius, maxError, ERROR_INSIDE ); } } @@ -430,7 +425,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } // Creates vertical outline contours of the tracks and add it to the poly of the layer - if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL ) + if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL ) { for( PCB_LAYER_ID layer : layer_ids ) { @@ -450,7 +445,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) // Skip vias annulus when not flashed on this layer if( track->Type() == PCB_VIA_T - && !static_cast( track )->FlashLayer( layer ) ) + && !static_cast( track )->FlashLayer( layer ) ) { continue; } @@ -483,8 +478,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) createPadWithHole( pad, &m_TH_ODs, inflate ); - if( m_Cfg->m_Render.clip_silk_on_via_annulus ) - createPadWithHole( pad, &m_THAnnularRings, inflate ); + if( cfg.clip_silk_on_via_annuli ) + createPadWithHole( pad, &m_viaAnnuli, inflate ); createPadWithHole( pad, &m_TH_IDs, 0 ); } @@ -508,16 +503,16 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( pad->GetAttribute () != PAD_ATTRIB::NPTH ) { - if( m_Cfg->m_Render.clip_silk_on_via_annulus ) - pad->TransformHoleToPolygon( m_THAnnularRingPolys, inflate, maxError, ERROR_INSIDE ); + if( cfg.clip_silk_on_via_annuli ) + pad->TransformHoleToPolygon( m_viaAnnuliPolys, inflate, maxError, ERROR_INSIDE ); pad->TransformHoleToPolygon( m_TH_ODPolys, inflate, maxError, ERROR_INSIDE ); } else { // If not plated, no copper. - if( m_Cfg->m_Render.clip_silk_on_via_annulus ) - pad->TransformHoleToPolygon( m_THAnnularRingPolys, 0, maxError, ERROR_INSIDE ); + if( cfg.clip_silk_on_via_annuli ) + pad->TransformHoleToPolygon( m_viaAnnuliPolys, 0, maxError, ERROR_INSIDE ); pad->TransformHoleToPolygon( m_NPTH_ODPolys, 0, maxError, ERROR_INSIDE ); } @@ -534,15 +529,14 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) // ADD PADS for( FOOTPRINT* footprint : m_board->Footprints() ) { - addPads( footprint, layerContainer, layer, m_Cfg->m_Render.renderPlatedPadsAsPlated, - false ); + addPads( footprint, layerContainer, layer, cfg.renderPlatedPadsAsPlated, false ); // Micro-wave footprints may have items on copper layers addFootprintShapes( footprint, layerContainer, layer, visibilityFlags ); } } - if( m_Cfg->m_Render.renderPlatedPadsAsPlated ) + if( cfg.renderPlatedPadsAsPlated ) { // ADD PLATED PADS for( FOOTPRINT* footprint : m_board->Footprints() ) @@ -556,7 +550,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } // Add footprints PADs poly contours (vertical outlines) - if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL ) + if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL ) { for( PCB_LAYER_ID layer : layer_ids ) { @@ -570,14 +564,13 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) // Note: NPTH pads are not drawn on copper layers when the pad has same shape as // its hole footprint->TransformPadsToPolySet( *layerPoly, layer, 0, maxError, ERROR_INSIDE, - true, m_Cfg->m_Render.renderPlatedPadsAsPlated, - false ); + true, cfg.renderPlatedPadsAsPlated, false ); transformFPShapesToPolySet( footprint, layer, *layerPoly, maxError, ERROR_INSIDE ); } } - if( m_Cfg->m_Render.renderPlatedPadsAsPlated ) + if( cfg.renderPlatedPadsAsPlated ) { // ADD PLATED PADS contours for( FOOTPRINT* footprint : m_board->Footprints() ) @@ -636,7 +629,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } // Add graphic item on copper layers to poly contours (vertical outlines) - if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL ) + if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL ) { for( PCB_LAYER_ID layer : layer_ids ) { @@ -681,7 +674,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } } - if( m_Cfg->m_Render.show_zones ) + if( cfg.show_zones ) { if( aStatusReporter ) aStatusReporter->Report( _( "Create zones" ) ); @@ -726,9 +719,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( layerContainer != m_layerMap.end() ) addSolidAreasShapes( zone, layerContainer->second, layer ); - if( m_Cfg->m_Render.opengl_copper_thickness - && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL - && layerPolyContainer != m_layers_poly.end() ) + if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL + && layerPolyContainer != m_layers_poly.end() ) { auto mut_it = layer_lock.find( layer ); @@ -753,9 +745,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) if( aStatusReporter ) aStatusReporter->Report( _( "Simplifying copper layers polygons" ) ); - if( m_Cfg->m_Render.opengl_copper_thickness && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL ) + if( cfg.opengl_copper_thickness && cfg.engine == RENDER_ENGINE::OPENGL ) { - if( m_Cfg->m_Render.renderPlatedPadsAsPlated ) + if( cfg.renderPlatedPadsAsPlated ) { if( m_frontPlatedPadPolys && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) ) { @@ -783,7 +775,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) std::vector &selected_layer_id = layer_ids; std::vector layer_id_without_F_and_B; - if( m_Cfg->m_Render.renderPlatedPadsAsPlated ) + if( cfg.renderPlatedPadsAsPlated ) { layer_id_without_F_and_B.clear(); layer_id_without_F_and_B.reserve( layer_ids.size() ); @@ -864,7 +856,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) m_TH_ODPolys.Simplify( SHAPE_POLY_SET::PM_FAST ); m_NPTH_ODPolys.Simplify( SHAPE_POLY_SET::PM_FAST ); m_viaTH_ODPolys.Simplify( SHAPE_POLY_SET::PM_FAST ); - m_THAnnularRingPolys.Simplify( SHAPE_POLY_SET::PM_FAST ); + m_viaAnnuliPolys.Simplify( SHAPE_POLY_SET::PM_FAST ); // Build Tech layers // Based on: @@ -876,8 +868,8 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) // Vertical walls (layer thickness) around shapes is really time consumming // They are built on request - bool buildVerticalWallsForTechLayers = m_Cfg->m_Render.opengl_copper_thickness - && m_Cfg->m_Render.engine == RENDER_ENGINE::OPENGL; + bool buildVerticalWallsForTechLayers = cfg.opengl_copper_thickness + && cfg.engine == RENDER_ENGINE::OPENGL; static const PCB_LAYER_ID techLayerList[] = { B_Adhes, @@ -1070,7 +1062,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } // Draw non copper zones - if( m_Cfg->m_Render.show_zones ) + if( cfg.show_zones ) { for( ZONE* zone : m_board->Zones() ) { @@ -1097,7 +1089,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) // A somewhat experimental feature: if we're rendering off-board silk, turn any pads of // footprints which are entirely outside the board outline into silk. This makes off-board // footprints more visually recognizable. - if( m_Cfg->m_Render.show_off_board_silk ) + if( cfg.show_off_board_silk ) { BOX2I boardBBox = m_board_poly.BBox(); @@ -1127,7 +1119,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) m_TH_IDs.BuildBVH(); m_TH_ODs.BuildBVH(); - m_THAnnularRings.BuildBVH(); + m_viaAnnuli.BuildBVH(); if( !m_layerHoleMap.empty() ) { diff --git a/3d-viewer/3d_rendering/opengl/create_scene.cpp b/3d-viewer/3d_rendering/opengl/create_scene.cpp index ac069e36fc..0f19e1d4a4 100644 --- a/3d-viewer/3d_rendering/opengl/create_scene.cpp +++ b/3d-viewer/3d_rendering/opengl/create_scene.cpp @@ -502,10 +502,10 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo m_outerViaThroughHoles = generateHoles( m_boardAdapter.GetViaTH_ODs().GetList(), m_boardAdapter.GetViaTH_ODPolys(), 1.0f, 0.0f, false ); - if( m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annulus ) + if( m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annuli ) { - m_outerThroughHoleRings = generateHoles( m_boardAdapter.GetTHAnnularRings().GetList(), - m_boardAdapter.GetTHAnnularRingPolys(), + m_outerThroughHoleRings = generateHoles( m_boardAdapter.GetViaAnnuli().GetList(), + m_boardAdapter.GetViaAnnuliPolys(), 1.0f, 0.0f, false ); } @@ -567,7 +567,7 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo if( map_poly.find( layer ) != map_poly.end() ) { - polyListSubtracted = *map_poly.at( layer );; + polyListSubtracted = *map_poly.at( layer ); if( LSET::PhysicalLayersMask().test( layer ) ) { @@ -605,7 +605,6 @@ void RENDER_3D_OPENGL::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo if( oglList != nullptr ) m_layers[layer] = oglList; - } if( m_boardAdapter.m_Cfg->m_Render.renderPlatedPadsAsPlated ) diff --git a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp index 7ced03ab09..97dd6601f6 100644 --- a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp +++ b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp @@ -452,6 +452,8 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, return false; } + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render; + if( m_reloadRequested ) { std::unique_ptr busy = CreateBusyIndicator(); @@ -462,16 +464,16 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, reload( aStatusReporter, aWarningReporter ); // generate a new 3D grid as the size of the board may had changed - m_lastGridType = static_cast( m_boardAdapter.m_Cfg->m_Render.grid_type ); + m_lastGridType = static_cast( cfg.grid_type ); generate3dGrid( m_lastGridType ); } else { // Check if grid was changed - if( m_boardAdapter.m_Cfg->m_Render.grid_type != m_lastGridType ) + if( cfg.grid_type != m_lastGridType ) { // and generate a new one - m_lastGridType = static_cast( m_boardAdapter.m_Cfg->m_Render.grid_type ); + m_lastGridType = static_cast( cfg.grid_type ); generate3dGrid( m_lastGridType ); } } @@ -485,7 +487,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, glEnable( GL_NORMALIZE ); // This allow OpenGL to normalize the normals after transformations glViewport( 0, 0, m_windowSize.x, m_windowSize.y ); - if( aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_AA_disableOnMove ) + if( aIsMoving && cfg.opengl_AA_disableOnMove ) glDisable( GL_MULTISAMPLE ); else glEnable( GL_MULTISAMPLE ); @@ -536,9 +538,9 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, glLightfv( GL_LIGHT0, GL_POSITION, headlight_pos ); } - bool skipThickness = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_thickness_disableOnMove; - bool skipRenderHoles = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_holes_disableOnMove; - bool skipRenderVias = aIsMoving && m_boardAdapter.m_Cfg->m_Render.opengl_vias_disableOnMove; + bool skipThickness = aIsMoving && cfg.opengl_thickness_disableOnMove; + bool skipRenderHoles = aIsMoving && cfg.opengl_holes_disableOnMove; + bool skipRenderVias = aIsMoving && cfg.opengl_vias_disableOnMove; bool drawMiddleSegments = !skipThickness; @@ -582,7 +584,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, if( isCopperLayer ) { - if( m_boardAdapter.m_Cfg->m_Render.renderPlatedPadsAsPlated ) + if( cfg.renderPlatedPadsAsPlated ) setCopperMaterial(); else setLayerMaterial( layer_id ); @@ -647,21 +649,18 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, OPENGL_RENDER_LIST* anti_board = nullptr; OPENGL_RENDER_LIST* solder_mask = nullptr; - if( isSilkLayer && m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annulus ) + if( isSilkLayer && cfg.clip_silk_on_via_annuli ) throughHolesOuter = m_outerThroughHoleRings; else throughHolesOuter = m_outerThroughHoles; - if( isSilkLayer && m_boardAdapter.m_Cfg->m_Render.show_off_board_silk ) + if( isSilkLayer && cfg.show_off_board_silk ) anti_board = nullptr; else if( LSET::PhysicalLayersMask().test( layer_id ) ) anti_board = m_antiBoard; - if( isSilkLayer && m_boardAdapter.m_Cfg->m_Render.subtract_mask_from_silk - && !m_boardAdapter.m_Cfg->m_Render.show_off_board_silk ) - { + if( isSilkLayer && cfg.subtract_mask_from_silk && !cfg.show_off_board_silk ) solder_mask = m_layers[ (layer_id == B_SilkS) ? B_Mask : F_Mask ]; - } if( throughHolesOuter ) throughHolesOuter->ApplyScalePosition( pLayerDispList ); @@ -766,7 +765,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, glDepthMask( GL_TRUE ); // Render Grid - if( m_boardAdapter.m_Cfg->m_Render.grid_type != GRID3D_TYPE::NONE ) + if( cfg.grid_type != GRID3D_TYPE::NONE ) { glDisable( GL_LIGHTING ); @@ -777,7 +776,7 @@ bool RENDER_3D_OPENGL::Redraw( bool aIsMoving, REPORTER* aStatusReporter, } // Render 3D arrows - if( m_boardAdapter.m_Cfg->m_Render.show_axis ) + if( cfg.show_axis ) render3dArrows(); // Return back to the original viewport (this is important if we want @@ -947,6 +946,8 @@ void RENDER_3D_OPENGL::get3dModelsSelected( std::list &aDstRender if( !m_boardAdapter.GetBoard() ) return; + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render; + // Go for all footprints for( FOOTPRINT* fp : m_boardAdapter.GetBoard()->Footprints() ) { @@ -957,7 +958,7 @@ void RENDER_3D_OPENGL::get3dModelsSelected( std::list &aDstRender if( fp->IsSelected() ) highlight = true; - if( m_boardAdapter.m_Cfg->m_Render.highlight_on_rollover && fp == m_currentRollOverItem ) + if( cfg.highlight_on_rollover && fp == m_currentRollOverItem ) highlight = true; if( aRenderSelectedOnly != highlight ) @@ -1071,7 +1072,9 @@ void RENDER_3D_OPENGL::get3dModelsFromFootprint( std::list &aDstR void RENDER_3D_OPENGL::renderOpaqueModels( const glm::mat4 &aCameraViewMatrix ) { - const SFVEC3F selColor = m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.opengl_selection_color ); + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render; + + const SFVEC3F selColor = m_boardAdapter.GetColor( cfg.opengl_selection_color ); glPushMatrix(); @@ -1113,7 +1116,9 @@ void RENDER_3D_OPENGL::renderOpaqueModels( const glm::mat4 &aCameraViewMatrix ) void RENDER_3D_OPENGL::renderTransparentModels( const glm::mat4 &aCameraViewMatrix ) { - const SFVEC3F selColor = m_boardAdapter.GetColor( m_boardAdapter.m_Cfg->m_Render.opengl_selection_color ); + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render; + + const SFVEC3F selColor = m_boardAdapter.GetColor( cfg.opengl_selection_color ); std::list renderListModels; // do not clear it until this function returns @@ -1201,6 +1206,8 @@ void RENDER_3D_OPENGL::renderModel( const glm::mat4 &aCameraViewMatrix, const MODELTORENDER &aModelToRender, const SFVEC3F &aSelColor, const SFVEC3F *aCameraWorldPos ) { + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render; + const glm::mat4 modelviewMatrix = aCameraViewMatrix * aModelToRender.m_modelWorldMat; glLoadMatrixf( glm::value_ptr( modelviewMatrix ) ); @@ -1209,7 +1216,7 @@ void RENDER_3D_OPENGL::renderModel( const glm::mat4 &aCameraViewMatrix, aModelToRender.m_isSelected, aSelColor, &aModelToRender.m_modelWorldMat, aCameraWorldPos ); - if( m_boardAdapter.m_Cfg->m_Render.show_model_bbox ) + if( cfg.show_model_bbox ) { const bool wasBlendEnabled = glIsEnabled( GL_BLEND ); diff --git a/3d-viewer/3d_rendering/raytracing/create_scene.cpp b/3d-viewer/3d_rendering/raytracing/create_scene.cpp index b12712dd04..5284593740 100644 --- a/3d-viewer/3d_rendering/raytracing/create_scene.cpp +++ b/3d-viewer/3d_rendering/raytracing/create_scene.cpp @@ -235,7 +235,9 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont if( aContainer2d == nullptr ) return; - const LIST_OBJECT2D& listObject2d = aContainer2d->GetList(); + EDA_3D_VIEWER_SETTINGS::RENDER_SETTINGS& cfg = m_boardAdapter.m_Cfg->m_Render; + bool isSilk = aLayer_id == B_SilkS || aLayer_id == F_SilkS; + const LIST_OBJECT2D& listObject2d = aContainer2d->GetList(); if( listObject2d.size() == 0 ) return; @@ -274,10 +276,8 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont // layer and the flag is set, then clip the silk at the outer edge of the annular ring, // rather than the at the outer edge of the copper plating. const BVH_CONTAINER_2D& throughHoleOuter = - m_boardAdapter.m_Cfg->m_Render.clip_silk_on_via_annulus - && ( aLayer_id == B_SilkS || aLayer_id == F_SilkS ) ? - m_boardAdapter.GetTHAnnularRings() : - m_boardAdapter.GetTH_ODs(); + cfg.clip_silk_on_via_annuli && isSilk ? m_boardAdapter.GetViaAnnuli() + : m_boardAdapter.GetTH_ODs(); if( !throughHoleOuter.GetList().empty() ) { @@ -303,13 +303,13 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont const MAP_CONTAINER_2D_BASE& mapLayers = m_boardAdapter.GetLayerMap(); - if( m_boardAdapter.m_Cfg->m_Render.subtract_mask_from_silk + if( cfg.subtract_mask_from_silk && ( ( aLayer_id == B_SilkS && mapLayers.find( B_Mask ) != mapLayers.end() ) || ( aLayer_id == F_SilkS && mapLayers.find( F_Mask ) != mapLayers.end() ) ) ) { - const PCB_LAYER_ID layerMask_id = ( aLayer_id == B_SilkS ) ? B_Mask : F_Mask; + const PCB_LAYER_ID maskLayer = ( aLayer_id == B_SilkS ) ? B_Mask : F_Mask; - const BVH_CONTAINER_2D* containerMaskLayer2d = mapLayers.at( layerMask_id ); + const BVH_CONTAINER_2D* containerMaskLayer2d = mapLayers.at( maskLayer ); CONST_LIST_OBJECT2D intersecting; @@ -329,8 +329,8 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont if( ( object2d_B == CSGITEM_EMPTY ) && ( object2d_C == CSGITEM_FULL ) ) { LAYER_ITEM* objPtr = new LAYER_ITEM( object2d_A, - m_boardAdapter.GetLayerBottomZPos( aLayer_id ) - aLayerZOffset, - m_boardAdapter.GetLayerTopZPos( aLayer_id ) + aLayerZOffset ); + m_boardAdapter.GetLayerBottomZPos( aLayer_id ) - aLayerZOffset, + m_boardAdapter.GetLayerTopZPos( aLayer_id ) + aLayerZOffset ); objPtr->SetMaterial( aMaterialLayer ); objPtr->SetColor( ConvertSRGBToLinear( aLayerColor ) ); m_objectContainer.Add( objPtr ); @@ -342,8 +342,8 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont m_containerWithObjectsToDelete.Add( itemCSG2d ); LAYER_ITEM* objPtr = new LAYER_ITEM( itemCSG2d, - m_boardAdapter.GetLayerBottomZPos( aLayer_id ) - aLayerZOffset, - m_boardAdapter.GetLayerTopZPos( aLayer_id ) + aLayerZOffset ); + m_boardAdapter.GetLayerBottomZPos( aLayer_id ) - aLayerZOffset, + m_boardAdapter.GetLayerTopZPos( aLayer_id ) + aLayerZOffset ); objPtr->SetMaterial( aMaterialLayer ); objPtr->SetColor( ConvertSRGBToLinear( aLayerColor ) ); diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp index dceed2643d..a1f91f9e3d 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_settings.cpp @@ -365,7 +365,7 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS() : m_params.emplace_back( new PARAM( "render.subtract_mask_from_silk", &m_Render.subtract_mask_from_silk, false ) ); m_params.emplace_back( new PARAM( "render.clip_silk_on_via_annulus", - &m_Render.clip_silk_on_via_annulus, false ) ); + &m_Render.clip_silk_on_via_annuli, false ) ); m_params.emplace_back( new PARAM( "render.plated_and_bare_copper", &m_Render.renderPlatedPadsAsPlated, false ) ); m_params.emplace_back( new PARAM( "camera.animation_enabled", diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_settings.h b/3d-viewer/3d_viewer/eda_3d_viewer_settings.h index fca0dced3b..f5a83b90fb 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_settings.h +++ b/3d-viewer/3d_viewer/eda_3d_viewer_settings.h @@ -145,7 +145,7 @@ public: bool show_fp_values; bool show_fp_text; bool subtract_mask_from_silk; - bool clip_silk_on_via_annulus; + bool clip_silk_on_via_annuli; bool renderPlatedPadsAsPlated; }; diff --git a/3d-viewer/dialogs/panel_3D_display_options.cpp b/3d-viewer/dialogs/panel_3D_display_options.cpp index 17d4abaf89..8eda780d3b 100644 --- a/3d-viewer/dialogs/panel_3D_display_options.cpp +++ b/3d-viewer/dialogs/panel_3D_display_options.cpp @@ -48,7 +48,7 @@ void PANEL_3D_DISPLAY_OPTIONS::loadViewSettings( EDA_3D_VIEWER_SETTINGS* aCfg ) m_checkBoxAreas->SetValue( aCfg->m_Render.show_zones ); m_checkBoxSubtractMaskFromSilk->SetValue( aCfg->m_Render.subtract_mask_from_silk ); - m_checkBoxClipSilkOnViaAnnulus->SetValue( aCfg->m_Render.clip_silk_on_via_annulus ); + m_checkBoxClipSilkOnViaAnnulus->SetValue( aCfg->m_Render.clip_silk_on_via_annuli ); m_checkBoxRenderPlatedPadsAsPlated->SetValue( aCfg->m_Render.renderPlatedPadsAsPlated ); m_materialProperties->SetSelection( static_cast( aCfg->m_Render.material_mode ) ); @@ -79,7 +79,7 @@ bool PANEL_3D_DISPLAY_OPTIONS::TransferDataFromWindow() // Set visibility of items cfg->m_Render.show_zones = m_checkBoxAreas->GetValue(); cfg->m_Render.subtract_mask_from_silk = m_checkBoxSubtractMaskFromSilk->GetValue(); - cfg->m_Render.clip_silk_on_via_annulus = m_checkBoxClipSilkOnViaAnnulus->GetValue(); + cfg->m_Render.clip_silk_on_via_annuli = m_checkBoxClipSilkOnViaAnnulus->GetValue(); cfg->m_Render.renderPlatedPadsAsPlated = m_checkBoxRenderPlatedPadsAsPlated->GetValue(); cfg->m_Render.material_mode = static_cast( m_materialProperties->GetSelection() );