diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp index 612959c003..5033bf03ae 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp @@ -22,17 +22,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file c3d_render_createscene_ogl_legacy.cpp - * @brief - */ - #include "c3d_render_ogl_legacy.h" #include "ogl_legacy_utils.h" #include #include #include "../../3d_math.h" -#include "../../3d_fastmath.h" #include #include #include // To use GetRunningMicroSecs or another profiling utility @@ -40,8 +34,7 @@ void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CFILLEDCIRCLE2D * aFilledCircle, CLAYER_TRIANGLES *aDstLayer, - float aZtop, - float aZbot ) + float aZtop, float aZbot ) { const SFVEC2F ¢er = aFilledCircle->GetCenter(); const float radius = aFilledCircle->GetRadius() * @@ -55,30 +48,25 @@ void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CFILLEDCIRCLE2D // it in duplicated aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZtop ), SFVEC3F( center.x - f, center.y, aZtop ), - SFVEC3F( center.x, - center.y - f, aZtop ) ); + SFVEC3F( center.x, center.y - f, aZtop ) ); aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZtop ), SFVEC3F( center.x + f, center.y, aZtop ), - SFVEC3F( center.x, - center.y + f, aZtop ) ); + SFVEC3F( center.x, center.y + f, aZtop ) ); aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZbot ), SFVEC3F( center.x + f, center.y, aZbot ), - SFVEC3F( center.x, - center.y - f, aZbot ) ); + SFVEC3F( center.x, center.y - f, aZbot ) ); aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZbot ), SFVEC3F( center.x - f, center.y, aZbot ), - SFVEC3F( center.x, - center.y + f, aZbot ) ); + SFVEC3F( center.x, center.y + f, aZbot ) ); } void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CPOLYGON4PTS2D * aPoly, CLAYER_TRIANGLES *aDstLayer, - float aZtop, - float aZbot ) + float aZtop, float aZbot ) { const SFVEC2F &v0 = aPoly->GetV0(); const SFVEC2F &v1 = aPoly->GetV1(); @@ -91,8 +79,7 @@ void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CPOLYGON4PTS2D * void C3D_RENDER_OGL_LEGACY::generate_ring_contour( const SFVEC2F &aCenter, - float aInnerRadius, - float aOuterRadius, + float aInnerRadius, float aOuterRadius, unsigned int aNr_sides_per_circle, std::vector< SFVEC2F > &aInnerContourResult, std::vector< SFVEC2F > &aOuterContourResult, @@ -113,10 +100,10 @@ void C3D_RENDER_OGL_LEGACY::generate_ring_contour( const SFVEC2F &aCenter, const SFVEC2F rotatedDir = SFVEC2F( cos( angle ), sin( angle ) ); aInnerContourResult.emplace_back( aCenter.x + rotatedDir.x * aInnerRadius, - aCenter.y + rotatedDir.y * aInnerRadius ); + aCenter.y + rotatedDir.y * aInnerRadius ); aOuterContourResult.emplace_back( aCenter.x + rotatedDir.x * aOuterRadius, - aCenter.y + rotatedDir.y * aOuterRadius ); + aCenter.y + rotatedDir.y * aOuterRadius ); } aInnerContourResult.push_back( aInnerContourResult[0] ); @@ -128,8 +115,7 @@ void C3D_RENDER_OGL_LEGACY::generate_ring_contour( const SFVEC2F &aCenter, void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CRING2D * aRing, CLAYER_TRIANGLES *aDstLayer, - float aZtop, - float aZbot ) + float aZtop, float aZbot ) { const SFVEC2F ¢er = aRing->GetCenter(); const float inner = aRing->GetInnerRadius(); @@ -170,8 +156,7 @@ void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CRING2D * aRing, void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CTRIANGLE2D * aTri, CLAYER_TRIANGLES *aDstLayer, - float aZtop, - float aZbot ) + float aZtop, float aZbot ) { const SFVEC2F &v1 = aTri->GetP1(); const SFVEC2F &v2 = aTri->GetP2(); @@ -183,8 +168,7 @@ void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CTRIANGLE2D * aT void C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer( const CROUNDSEGMENT2D * aSeg, CLAYER_TRIANGLES *aDstLayer, - float aZtop, - float aZbot ) + float aZtop, float aZbot ) { const SFVEC2F& leftStart = aSeg->GetLeftStar(); const SFVEC2F& leftEnd = aSeg->GetLeftEnd(); @@ -295,17 +279,17 @@ CLAYERS_OGL_DISP_LISTS *C3D_RENDER_OGL_LEGACY::generate_holes_display_list( { case OBJECT2D_TYPE::FILLED_CIRCLE: add_object_to_triangle_layer( static_cast( object2d_A ), - layerTriangles, aZtop, aZbot ); + layerTriangles, aZtop, aZbot ); break; case OBJECT2D_TYPE::ROUNDSEG: add_object_to_triangle_layer( static_cast( object2d_A ), - layerTriangles, aZtop, aZbot ); + layerTriangles, aZtop, aZbot ); break; default: - wxFAIL_MSG( - "C3D_RENDER_OGL_LEGACY::generate_holes_display_list: Object type is not implemented" ); + wxFAIL_MSG( "C3D_RENDER_OGL_LEGACY::generate_holes_display_list: " + "Object type is not implemented" ); break; } } @@ -316,18 +300,12 @@ CLAYERS_OGL_DISP_LISTS *C3D_RENDER_OGL_LEGACY::generate_holes_display_list( if( aPoly.OutlineCount() > 0 ) { - layerTriangles->AddToMiddleContourns( aPoly, - aZbot, - aZtop, + layerTriangles->AddToMiddleContourns( aPoly, aZbot, aZtop, m_boardAdapter.BiuTo3Dunits(), - aInvertFaces, - aThroughHoles ); + aInvertFaces, aThroughHoles ); } - ret = new CLAYERS_OGL_DISP_LISTS( *layerTriangles, - m_ogl_circle_texture, - aZbot, - aZtop ); + ret = new CLAYERS_OGL_DISP_LISTS( *layerTriangles, m_ogl_circle_texture, aZbot, aZtop ); delete layerTriangles; } @@ -336,10 +314,11 @@ CLAYERS_OGL_DISP_LISTS *C3D_RENDER_OGL_LEGACY::generate_holes_display_list( } -CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::generateLayerListFromContainer( const CBVHCONTAINER2D *aContainer, - const SHAPE_POLY_SET *aPolyList, - PCB_LAYER_ID aLayerId, - const CBVHCONTAINER2D *aThroughHoles ) +CLAYERS_OGL_DISP_LISTS* +C3D_RENDER_OGL_LEGACY::generateLayerListFromContainer( const CBVHCONTAINER2D *aContainer, + const SHAPE_POLY_SET *aPolyList, + PCB_LAYER_ID aLayerId, + const CBVHCONTAINER2D *aThroughHoles ) { if( aContainer == nullptr ) return nullptr; @@ -402,19 +381,20 @@ CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::generateLayerListFromContainer( c } } - if( aPolyList ) - if( aPolyList->OutlineCount() > 0 ) - layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top, - m_boardAdapter.BiuTo3Dunits(), false, - aThroughHoles ); + if( aPolyList &&aPolyList->OutlineCount() > 0 ) + { + layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top, + m_boardAdapter.BiuTo3Dunits(), false, aThroughHoles ); + } // Create display list // ///////////////////////////////////////////////////////////////////// - return new CLAYERS_OGL_DISP_LISTS( *layerTriangles, m_ogl_circle_texture, - layer_z_bot, layer_z_top ); + return new CLAYERS_OGL_DISP_LISTS( *layerTriangles, m_ogl_circle_texture, layer_z_bot, + layer_z_top ); } -CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::createBoard( const SHAPE_POLY_SET& aBoardPoly, const CBVHCONTAINER2D *aThroughHoles ) +CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::createBoard( const SHAPE_POLY_SET& aBoardPoly, + const CBVHCONTAINER2D *aThroughHoles ) { CLAYERS_OGL_DISP_LISTS* dispLists = nullptr; CCONTAINER2D boardContainer; @@ -451,27 +431,17 @@ CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::createBoard( const SHAPE_POLY_SET const SFVEC2F &v2 = tri->GetP2(); const SFVEC2F &v3 = tri->GetP3(); - add_triangle_top_bot( layerTriangles, - v1, - v2, - v3, - layer_z_top, - layer_z_bot ); + add_triangle_top_bot( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot ); } if( aBoardPoly.OutlineCount() > 0 ) { - layerTriangles->AddToMiddleContourns( aBoardPoly, - layer_z_bot, - layer_z_top, - m_boardAdapter.BiuTo3Dunits(), - false, + layerTriangles->AddToMiddleContourns( aBoardPoly, layer_z_bot, layer_z_top, + m_boardAdapter.BiuTo3Dunits(), false, aThroughHoles ); - dispLists = new CLAYERS_OGL_DISP_LISTS( *layerTriangles, - m_ogl_circle_texture, - layer_z_top, - layer_z_top ); + dispLists = new CLAYERS_OGL_DISP_LISTS( *layerTriangles, m_ogl_circle_texture, + layer_z_top, layer_z_top ); } delete layerTriangles; @@ -502,7 +472,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin // Create Board // ///////////////////////////////////////////////////////////////////////// - m_ogl_disp_list_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetThroughHole_Inner() ); + m_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetThroughHole_Inner() ); if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) { @@ -514,19 +484,22 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin m_anti_board_poly.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) ); m_anti_board_poly.Outline( 0 ).SetClosed( true ); - m_anti_board_poly.BooleanSubtract( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); - m_ogl_disp_list_anti_board = createBoard( m_anti_board_poly ); + m_anti_board_poly.BooleanSubtract( m_boardAdapter.GetBoardPoly(), + SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); + m_anti_board = createBoard( m_anti_board_poly ); } SHAPE_POLY_SET board_poly_with_holes = m_boardAdapter.GetBoardPoly(); - board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), SHAPE_POLY_SET::PM_FAST ); - board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), SHAPE_POLY_SET::PM_FAST ); + board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), + SHAPE_POLY_SET::PM_FAST ); + board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), + SHAPE_POLY_SET::PM_FAST ); - m_ogl_disp_list_board_with_holes = createBoard( board_poly_with_holes ); + m_board_with_holes = createBoard( board_poly_with_holes ); - if( m_ogl_disp_list_anti_board ) - m_ogl_disp_list_anti_board->SetItIsTransparent( true ); + if( m_anti_board ) + m_anti_board->SetItIsTransparent( true ); // Create Through Holes and vias // ///////////////////////////////////////////////////////////////////////// @@ -539,7 +512,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) outerPolyTHT.BooleanIntersection( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE ); - m_ogl_disp_list_through_holes_outer = generate_holes_display_list( + m_through_holes_outer = generate_holes_display_list( m_boardAdapter.GetThroughHole_Outer().GetList(), outerPolyTHT, 1.0f, @@ -547,7 +520,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin false, &m_boardAdapter.GetThroughHole_Inner() ); - m_ogl_disp_list_through_holes_vias_outer = generate_holes_display_list( + m_through_holes_vias_outer = generate_holes_display_list( m_boardAdapter.GetThroughHole_Vias_Outer().GetList(), m_boardAdapter.GetThroughHole_Vias_Outer_poly(), 1.0f, @@ -557,7 +530,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin if( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) { - m_ogl_disp_list_through_holes_outer_ring = generate_holes_display_list( + m_through_holes_outer_ring = generate_holes_display_list( m_boardAdapter.GetThroughHole_Outer_Ring().GetList(), m_boardAdapter.GetThroughHole_Outer_Ring_poly(), 1.0f, @@ -594,8 +567,9 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin get_layer_z_pos( layer_id, layer_z_top, layer_z_bot ); - m_ogl_disp_lists_layers_holes_outer[layer_id] = generate_holes_display_list( - container->GetList(), *poly, layer_z_top, layer_z_bot, false ); + m_layers_holes_outer[layer_id] = generate_holes_display_list( container->GetList(), + *poly, layer_z_top, + layer_z_bot, false ); } for( MAP_POLY::const_iterator ii = innerMapHoles.begin(); @@ -608,8 +582,9 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin get_layer_z_pos( layer_id, layer_z_top, layer_z_bot ); - m_ogl_disp_lists_layers_holes_inner[layer_id] = generate_holes_display_list( - container->GetList(), *poly, layer_z_top, layer_z_bot, false ); + m_layers_holes_inner[layer_id] = generate_holes_display_list( container->GetList(), + *poly, layer_z_top, + layer_z_bot, false ); } } @@ -650,17 +625,24 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin if( ( layer_id != B_Mask ) && ( layer_id != F_Mask ) ) { - polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), SHAPE_POLY_SET::PM_FAST ); - polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), SHAPE_POLY_SET::PM_FAST ); + polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), + SHAPE_POLY_SET::PM_FAST ); + polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), + SHAPE_POLY_SET::PM_FAST ); } if( m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) ) { - if( ( ( layer_id == B_SilkS ) && ( map_poly.find( B_Mask ) != map_poly.end() ) ) ) - polyListSubtracted.BooleanSubtract( *map_poly.at( B_Mask ), SHAPE_POLY_SET::PM_FAST ); - else - if( ( ( layer_id == F_SilkS ) && ( map_poly.find( F_Mask ) != map_poly.end() ) ) ) - polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ), SHAPE_POLY_SET::PM_FAST ); + if( layer_id == B_SilkS && map_poly.find( B_Mask ) != map_poly.end() ) + { + polyListSubtracted.BooleanSubtract( *map_poly.at( B_Mask ), + SHAPE_POLY_SET::PM_FAST ); + } + else if( layer_id == F_SilkS && map_poly.find( F_Mask ) != map_poly.end() ) + { + polyListSubtracted.BooleanSubtract( *map_poly.at( F_Mask ), + SHAPE_POLY_SET::PM_FAST ); + } } } @@ -668,13 +650,12 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin aPolyList = &polyListSubtracted; } - CLAYERS_OGL_DISP_LISTS* oglList = generateLayerListFromContainer( container2d, - aPolyList, + CLAYERS_OGL_DISP_LISTS* oglList = generateLayerListFromContainer( container2d, aPolyList, layer_id, &m_boardAdapter.GetThroughHole_Inner() ); if( oglList != nullptr ) - m_ogl_disp_lists_layers[layer_id] = oglList; + m_layers[layer_id] = oglList; }// for each layer on @@ -684,23 +665,29 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin if( m_boardAdapter.GetPolyPlatedPads_Front() ) { SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetPolyPlatedPads_Front(); - polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_FAST ); - polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), SHAPE_POLY_SET::PM_FAST ); - polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), SHAPE_POLY_SET::PM_FAST ); + polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(), + SHAPE_POLY_SET::PM_FAST ); + polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), + SHAPE_POLY_SET::PM_FAST ); + polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), + SHAPE_POLY_SET::PM_FAST ); - m_ogl_disp_lists_platedPads_F_Cu = generateLayerListFromContainer( m_boardAdapter.GetPlatedPads_Front(), - &polySubtracted, F_Cu ); + m_platedPads_F_Cu = generateLayerListFromContainer( m_boardAdapter.GetPlatedPads_Front(), + &polySubtracted, F_Cu ); } if( m_boardAdapter.GetPolyPlatedPads_Back() ) { SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetPolyPlatedPads_Back(); - polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_FAST ); - polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), SHAPE_POLY_SET::PM_FAST ); - polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), SHAPE_POLY_SET::PM_FAST ); + polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(), + SHAPE_POLY_SET::PM_FAST ); + polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(), + SHAPE_POLY_SET::PM_FAST ); + polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(), + SHAPE_POLY_SET::PM_FAST ); - m_ogl_disp_lists_platedPads_B_Cu = generateLayerListFromContainer( m_boardAdapter.GetPlatedPads_Back(), - &polySubtracted, B_Cu ); + m_platedPads_B_Cu = generateLayerListFromContainer( m_boardAdapter.GetPlatedPads_Back(), + &polySubtracted, B_Cu ); } } @@ -766,13 +753,8 @@ void C3D_RENDER_OGL_LEGACY::generate_cylinder( const SFVEC2F &aCenter, std::vector< SFVEC2F > innerContour; std::vector< SFVEC2F > outerContour; - generate_ring_contour( aCenter, - aInnerRadius, - aOuterRadius, - aNr_sides_per_circle, - innerContour, - outerContour, - false ); + generate_ring_contour( aCenter, aInnerRadius, aOuterRadius, aNr_sides_per_circle, + innerContour, outerContour, false ); for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i ) { @@ -836,20 +818,12 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() wxASSERT( zbot < ztop ); - generate_cylinder( via_center, - hole_inner_radius, - hole_inner_radius + thickness, - ztop, - zbot, - nrSegments, - layerTriangleVIA ); + generate_cylinder( via_center, hole_inner_radius, hole_inner_radius + thickness, + ztop, zbot, nrSegments, layerTriangleVIA ); } } - m_ogl_disp_list_via = new CLAYERS_OGL_DISP_LISTS( *layerTriangleVIA, - 0, - 0.0f, - 0.0f ); + m_vias = new CLAYERS_OGL_DISP_LISTS( *layerTriangleVIA, 0, 0.0f, 0.0f ); delete layerTriangleVIA; } @@ -895,8 +869,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() CCONTAINER2D holesContainer; - Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly, - holesContainer, + Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly, holesContainer, m_boardAdapter.BiuTo3Dunits(), (const BOARD_ITEM &)*m_boardAdapter.GetBoard() ); @@ -926,8 +899,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() const SFVEC2F &v2 = tri->GetP2(); const SFVEC2F &v3 = tri->GetP3(); - add_triangle_top_bot( layerTriangles, v1, v2, v3, - layer_z_top, layer_z_bot ); + add_triangle_top_bot( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot ); } wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 ); @@ -936,13 +908,11 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() { layerTriangles->AddToMiddleContourns( tht_outer_holes_poly, layer_z_bot, layer_z_top, - m_boardAdapter.BiuTo3Dunits(), - false ); + m_boardAdapter.BiuTo3Dunits(), false ); - m_ogl_disp_list_pads_holes = new CLAYERS_OGL_DISP_LISTS( - *layerTriangles, - m_ogl_circle_texture, // not need - layer_z_top, layer_z_top ); + m_pad_holes = new CLAYERS_OGL_DISP_LISTS( *layerTriangles, + m_ogl_circle_texture, // not need + layer_z_top, layer_z_top ); } delete layerTriangles; diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp index f046a05244..436cfc179e 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp @@ -22,18 +22,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file c3d_render_ogl_legacy.cpp - * @brief - */ - #include // Must be included first #include "c3d_render_ogl_legacy.h" #include "ogl_legacy_utils.h" #include "common_ogl/ogl_utils.h" -#include "../cimage.h" -#include #include #include <3d_math.h> #include // for KiROUND @@ -50,30 +43,29 @@ C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY( BOARD_ADAPTER& aAdapter, CCAMERA& { wxLogTrace( m_logTrace, wxT( "C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY" ) ); - m_ogl_disp_lists_layers.clear(); - m_ogl_disp_lists_layers_holes_outer.clear(); - m_ogl_disp_lists_layers_holes_inner.clear(); + m_layers.clear(); + m_layers_holes_outer.clear(); + m_layers_holes_inner.clear(); m_triangles.clear(); - m_ogl_disp_list_board = NULL; - m_ogl_disp_list_anti_board = NULL; + m_board = NULL; + m_anti_board = NULL; - m_ogl_disp_lists_platedPads_F_Cu = nullptr; - m_ogl_disp_lists_platedPads_B_Cu = nullptr; + m_platedPads_F_Cu = nullptr; + m_platedPads_B_Cu = nullptr; - m_ogl_disp_list_through_holes_outer = NULL; - m_ogl_disp_list_through_holes_outer_ring = NULL; - m_ogl_disp_list_through_holes_vias_outer = NULL; + m_through_holes_outer = NULL; + m_through_holes_outer_ring = NULL; + m_through_holes_vias_outer = NULL; //m_ogl_disp_list_through_holes_vias_inner = NULL; - m_ogl_disp_list_via = NULL; - m_ogl_disp_list_pads_holes = NULL; - m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps = NULL; + m_vias = NULL; + m_pad_holes = NULL; + m_vias_and_pad_holes_outer_contourn_and_caps = NULL; m_ogl_circle_texture = 0; - m_ogl_disp_list_grid = 0; - m_last_grid_type = GRID3D_TYPE::NONE; + m_grid = 0; + m_last_grid_type = GRID3D_TYPE::NONE; m_currentIntersectedBoardItem = nullptr; - m_ogl_disp_list_board_with_holes = nullptr; - m_ogl_disp_list_through_holes_outer_with_npth = nullptr; + m_board_with_holes = nullptr; m_3dmodel_map.clear(); } @@ -151,9 +143,8 @@ void C3D_RENDER_OGL_LEGACY::render_3D_arrows() glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); - const glm::mat4 TranslationMatrix = glm::translate( - glm::mat4(1.0f), - SFVEC3F( 0.0f, 0.0f, -(arrow_size * 2.75f) ) ); + const glm::mat4 TranslationMatrix = glm::translate( glm::mat4(1.0f), + SFVEC3F( 0.0f, 0.0f, -(arrow_size * 2.75f) ) ); const glm::mat4 ViewMatrix = TranslationMatrix * m_camera.GetRotationMatrix(); @@ -378,15 +369,14 @@ void C3D_RENDER_OGL_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID ) case B_Fab: case F_Fab: m_materials.m_Plastic.m_Diffuse = get_layer_color( aLayerID ); - m_materials.m_Plastic.m_Ambient = SFVEC3F( - m_materials.m_Plastic.m_Diffuse.r * 0.05f, - m_materials.m_Plastic.m_Diffuse.g * 0.05f, - m_materials.m_Plastic.m_Diffuse.b * 0.05f ); - m_materials.m_Plastic.m_Specular = SFVEC3F( - m_materials.m_Plastic.m_Diffuse.r * 0.7f, - m_materials.m_Plastic.m_Diffuse.g * 0.7f, - m_materials.m_Plastic.m_Diffuse.b * 0.7f ); + m_materials.m_Plastic.m_Ambient = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.05f, + m_materials.m_Plastic.m_Diffuse.g * 0.05f, + m_materials.m_Plastic.m_Diffuse.b * 0.05f ); + + m_materials.m_Plastic.m_Specular = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.7f, + m_materials.m_Plastic.m_Diffuse.g * 0.7f, + m_materials.m_Plastic.m_Diffuse.b * 0.7f ); m_materials.m_Plastic.m_Shininess = 0.078125f * 128.0f; m_materials.m_Plastic.m_Emissive = SFVEC3F( 0.0f, 0.0f, 0.0f ); @@ -538,9 +528,9 @@ void C3D_RENDER_OGL_LEGACY::render_board_body( bool aSkipRenderHoles ) CLAYERS_OGL_DISP_LISTS* ogl_disp_list = nullptr; if( aSkipRenderHoles ) - ogl_disp_list = m_ogl_disp_list_board; + ogl_disp_list = m_board; else - ogl_disp_list = m_ogl_disp_list_board_with_holes; + ogl_disp_list = m_board_with_holes; if( ogl_disp_list ) { @@ -683,21 +673,15 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter, OGL_SetMaterial( m_materials.m_GrayMaterial, 1.0f ); } - if( (!( skipRenderVias || skipRenderHoles ) ) && m_ogl_disp_list_via ) - { - m_ogl_disp_list_via->DrawAll(); - } + if( !( skipRenderVias || skipRenderHoles ) && m_vias ) + m_vias->DrawAll(); - if( ( !skipRenderHoles ) && m_ogl_disp_list_pads_holes ) - { - m_ogl_disp_list_pads_holes->DrawAll(); - } + if( !skipRenderHoles && m_pad_holes ) + m_pad_holes->DrawAll(); // Display copper and tech layers // ///////////////////////////////////////////////////////////////////////// - for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin(); - ii != m_ogl_disp_lists_layers.end(); - ++ii ) + for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers.begin(); ii != m_layers.end(); ++ii ) { const PCB_LAYER_ID layer_id = (PCB_LAYER_ID)(ii->first); @@ -738,69 +722,73 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter, // Draw copper plated pads if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) && - ( m_ogl_disp_lists_platedPads_F_Cu || m_ogl_disp_lists_platedPads_B_Cu ) ) + ( m_platedPads_F_Cu || m_platedPads_B_Cu ) ) setPlatedCopperAndDepthOffset( layer_id ); - if( ( layer_id == F_Cu ) && m_ogl_disp_lists_platedPads_F_Cu ) - m_ogl_disp_lists_platedPads_F_Cu->DrawAllCameraCulled( m_camera.GetPos().z, - drawMiddleSegments ); - else - if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu ) - m_ogl_disp_lists_platedPads_B_Cu->DrawAllCameraCulled( m_camera.GetPos().z, - drawMiddleSegments ); + if( layer_id == F_Cu && m_platedPads_F_Cu ) + { + + m_platedPads_F_Cu->DrawAllCameraCulled( m_camera.GetPos().z, + drawMiddleSegments ); + } + else if( layer_id == B_Cu && m_platedPads_B_Cu ) + { + m_platedPads_B_Cu->DrawAllCameraCulled( m_camera.GetPos().z, + drawMiddleSegments ); + } unsetDepthOffset(); } else { - if( m_ogl_disp_list_through_holes_outer ) - m_ogl_disp_list_through_holes_outer->ApplyScalePosition( - pLayerDispList->GetZBot(), - pLayerDispList->GetZTop() - pLayerDispList->GetZBot() ); - - if( m_ogl_disp_list_anti_board ) + if( m_through_holes_outer ) { - m_ogl_disp_list_anti_board->ApplyScalePosition( pLayerDispList->GetZBot(), - pLayerDispList->GetZTop() - pLayerDispList->GetZBot() ); + m_through_holes_outer->ApplyScalePosition( pLayerDispList->GetZBot(), + pLayerDispList->GetZTop() + - pLayerDispList->GetZBot() ); } - if( m_ogl_disp_lists_layers_holes_outer.find( layer_id ) != - m_ogl_disp_lists_layers_holes_outer.end() ) + if( m_anti_board ) { - const CLAYERS_OGL_DISP_LISTS* viasHolesLayer = - m_ogl_disp_lists_layers_holes_outer.at( layer_id ); + m_anti_board->ApplyScalePosition( pLayerDispList->GetZBot(), + pLayerDispList->GetZTop() + - pLayerDispList->GetZBot() ); + } + + if( m_layers_holes_outer.find( layer_id ) != m_layers_holes_outer.end() ) + { + const CLAYERS_OGL_DISP_LISTS* viasHolesLayer = m_layers_holes_outer.at( layer_id ); wxASSERT( viasHolesLayer != NULL ); if( viasHolesLayer != NULL ) { - pLayerDispList->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - m_ogl_disp_list_through_holes_outer, - viasHolesLayer, - m_ogl_disp_list_anti_board ); + pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, + m_through_holes_outer, + viasHolesLayer, + m_anti_board ); // Draw copper plated pads if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) && - ( m_ogl_disp_lists_platedPads_F_Cu || m_ogl_disp_lists_platedPads_B_Cu ) ) + ( m_platedPads_F_Cu || m_platedPads_B_Cu ) ) + { setPlatedCopperAndDepthOffset( layer_id ); - - if( ( layer_id == F_Cu ) && m_ogl_disp_lists_platedPads_F_Cu ) - { - m_ogl_disp_lists_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - m_ogl_disp_list_through_holes_outer, - viasHolesLayer, - m_ogl_disp_list_anti_board ); } - else if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu ) + + if( layer_id == F_Cu && m_platedPads_F_Cu ) { - m_ogl_disp_lists_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - m_ogl_disp_list_through_holes_outer, - viasHolesLayer, - m_ogl_disp_list_anti_board ); + m_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, + m_through_holes_outer, + viasHolesLayer, + m_anti_board ); + } + else if( layer_id == B_Cu && m_platedPads_B_Cu ) + { + m_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, + m_through_holes_outer, + viasHolesLayer, + m_anti_board ); } unsetDepthOffset(); @@ -808,32 +796,28 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter, } else { - pLayerDispList->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - m_ogl_disp_list_through_holes_outer, - m_ogl_disp_list_anti_board ); + pLayerDispList->DrawAllCameraCulledSubtractLayer( m_through_holes_outer, + m_anti_board ); // Draw copper plated pads if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) && - ( m_ogl_disp_lists_platedPads_F_Cu || m_ogl_disp_lists_platedPads_B_Cu ) ) + ( m_platedPads_F_Cu || m_platedPads_B_Cu ) ) { setPlatedCopperAndDepthOffset( layer_id ); } - if( ( layer_id == F_Cu ) && m_ogl_disp_lists_platedPads_F_Cu ) + if( layer_id == F_Cu && m_platedPads_F_Cu ) { - m_ogl_disp_lists_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - m_ogl_disp_list_through_holes_outer, - m_ogl_disp_list_anti_board ); + m_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, + m_through_holes_outer, + m_anti_board ); } - else if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu ) + else if( layer_id == B_Cu && m_platedPads_B_Cu ) { - m_ogl_disp_lists_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - m_ogl_disp_list_through_holes_outer, - m_ogl_disp_list_anti_board ); + m_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, + m_through_holes_outer, + m_anti_board ); } unsetDepthOffset(); @@ -844,58 +828,51 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter, { set_layer_material( layer_id ); - CLAYERS_OGL_DISP_LISTS* dispListThroughHolesOuter = - ( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && - m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) - && ( ( layer_id == B_SilkS ) || ( layer_id == F_SilkS ) ) ) ? - m_ogl_disp_list_through_holes_outer_ring : - m_ogl_disp_list_through_holes_outer; + CLAYERS_OGL_DISP_LISTS* throughHolesOuter = + m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) + && m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) + && ( layer_id == B_SilkS || layer_id == F_SilkS ) ? m_through_holes_outer_ring + : m_through_holes_outer; - if( dispListThroughHolesOuter ) + if( throughHolesOuter ) { - dispListThroughHolesOuter->ApplyScalePosition( pLayerDispList->GetZBot(), - pLayerDispList->GetZTop() - pLayerDispList->GetZBot() ); + throughHolesOuter->ApplyScalePosition( pLayerDispList->GetZBot(), + pLayerDispList->GetZTop() - pLayerDispList->GetZBot() ); } - CLAYERS_OGL_DISP_LISTS* ogl_disp_list_anti_board = m_ogl_disp_list_anti_board; + CLAYERS_OGL_DISP_LISTS* anti_board = m_anti_board; if( ( layer_id == B_Paste ) || ( layer_id == F_Paste ) ) - ogl_disp_list_anti_board = nullptr; + anti_board = nullptr; - if( ogl_disp_list_anti_board ) + if( anti_board ) { - ogl_disp_list_anti_board->ApplyScalePosition( pLayerDispList->GetZBot(), - pLayerDispList->GetZTop() - pLayerDispList->GetZBot() ); + anti_board->ApplyScalePosition( pLayerDispList->GetZBot(), + pLayerDispList->GetZTop() - pLayerDispList->GetZBot() ); } - if( (!skipRenderHoles) && - m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) && - m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) && - ( ( ( layer_id == B_SilkS ) && - ( m_ogl_disp_lists_layers.find( B_Mask ) != m_ogl_disp_lists_layers.end() ) ) || - ( ( layer_id == F_SilkS ) && - ( m_ogl_disp_lists_layers.find( F_Mask ) != m_ogl_disp_lists_layers.end() ) ) ) ) + if( !skipRenderHoles + && m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) + && m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) + && ( ( layer_id == B_SilkS && m_layers.find( B_Mask ) != m_layers.end() ) + || ( layer_id == F_SilkS && m_layers.find( F_Mask ) != m_layers.end() ) ) ) { const PCB_LAYER_ID layerMask_id = (layer_id == B_SilkS) ? B_Mask : F_Mask; - const CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( layerMask_id ); + const CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_layers.at( layerMask_id ); - pLayerDispList->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - pLayerDispListMask, - dispListThroughHolesOuter, - ogl_disp_list_anti_board ); + pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, + pLayerDispListMask, + throughHolesOuter, anti_board ); } else { - if( !skipRenderHoles && - dispListThroughHolesOuter && ( layer_id == B_SilkS || layer_id == F_SilkS ) ) + if( !skipRenderHoles + && throughHolesOuter + && ( layer_id == B_SilkS || layer_id == F_SilkS ) ) { - pLayerDispList->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - nullptr, - dispListThroughHolesOuter, - ogl_disp_list_anti_board ); + pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, nullptr, + throughHolesOuter, anti_board ); } else { @@ -903,9 +880,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter, // otherwise it will cause z-fight issues if( !( skipRenderHoles && ( layer_id == B_Paste || layer_id == F_Paste ) ) ) { - pLayerDispList->DrawAllCameraCulledSubtractLayer( - drawMiddleSegments, - ogl_disp_list_anti_board ); + pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments, + anti_board ); } } } @@ -1004,8 +980,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter, { glDisable( GL_LIGHTING ); - if( glIsList( m_ogl_disp_list_grid ) ) - glCallList( m_ogl_disp_list_grid ); + if( glIsList( m_grid ) ) + glCallList( m_grid ); glEnable( GL_LIGHTING ); } @@ -1094,52 +1070,48 @@ void C3D_RENDER_OGL_LEGACY::ogl_set_arrow_material() void C3D_RENDER_OGL_LEGACY::ogl_free_all_display_lists() { - if( glIsList( m_ogl_disp_list_grid ) ) - glDeleteLists( m_ogl_disp_list_grid, 1 ); + if( glIsList( m_grid ) ) + glDeleteLists( m_grid, 1 ); - m_ogl_disp_list_grid = 0; + m_grid = 0; - for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers.begin(); - ii != m_ogl_disp_lists_layers.end(); + for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers.begin(); ii != m_layers.end(); ++ii ) + { + CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast(ii->second); + delete pLayerDispList; + } + + m_layers.clear(); + + delete m_platedPads_F_Cu; + m_platedPads_F_Cu = nullptr; + + delete m_platedPads_B_Cu; + m_platedPads_B_Cu = nullptr; + + + for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers_holes_outer.begin(); + ii != m_layers_holes_outer.end(); ++ii ) { CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast(ii->second); delete pLayerDispList; } - m_ogl_disp_lists_layers.clear(); - - delete m_ogl_disp_lists_platedPads_F_Cu; - m_ogl_disp_lists_platedPads_F_Cu = nullptr; - - delete m_ogl_disp_lists_platedPads_B_Cu; - m_ogl_disp_lists_platedPads_B_Cu = nullptr; + m_layers_holes_outer.clear(); - for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_outer.begin(); - ii != m_ogl_disp_lists_layers_holes_outer.end(); + for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers_holes_inner.begin(); + ii != m_layers_holes_inner.end(); ++ii ) { CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast(ii->second); delete pLayerDispList; } - m_ogl_disp_lists_layers_holes_outer.clear(); + m_layers_holes_inner.clear(); - - for( MAP_OGL_DISP_LISTS::const_iterator ii = m_ogl_disp_lists_layers_holes_inner.begin(); - ii != m_ogl_disp_lists_layers_holes_inner.end(); - ++ii ) - { - CLAYERS_OGL_DISP_LISTS *pLayerDispList = static_cast(ii->second); - delete pLayerDispList; - } - - m_ogl_disp_lists_layers_holes_inner.clear(); - - for( LIST_TRIANGLES::const_iterator ii = m_triangles.begin(); - ii != m_triangles.end(); - ++ii ) + for( LIST_TRIANGLES::const_iterator ii = m_triangles.begin(); ii != m_triangles.end(); ++ii ) { delete *ii; } @@ -1147,9 +1119,7 @@ void C3D_RENDER_OGL_LEGACY::ogl_free_all_display_lists() m_triangles.clear(); - for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin(); - ii != m_3dmodel_map.end(); - ++ii ) + for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin(); ii != m_3dmodel_map.end(); ++ii ) { C_OGL_3DMODEL *pointer = static_cast(ii->second); delete pointer; @@ -1158,99 +1128,86 @@ void C3D_RENDER_OGL_LEGACY::ogl_free_all_display_lists() m_3dmodel_map.clear(); - delete m_ogl_disp_list_board; - m_ogl_disp_list_board = nullptr; + delete m_board; + m_board = nullptr; - delete m_ogl_disp_list_anti_board; - m_ogl_disp_list_anti_board = nullptr; + delete m_anti_board; + m_anti_board = nullptr; - delete m_ogl_disp_list_through_holes_outer; - m_ogl_disp_list_through_holes_outer = nullptr; + delete m_through_holes_outer; + m_through_holes_outer = nullptr; - delete m_ogl_disp_list_through_holes_vias_outer; - m_ogl_disp_list_through_holes_vias_outer = nullptr; + delete m_through_holes_vias_outer; + m_through_holes_vias_outer = nullptr; - delete m_ogl_disp_list_through_holes_outer_ring; - m_ogl_disp_list_through_holes_outer_ring = nullptr; + delete m_through_holes_outer_ring; + m_through_holes_outer_ring = nullptr; - delete m_ogl_disp_list_via; - m_ogl_disp_list_via = nullptr; + delete m_vias; + m_vias = nullptr; - delete m_ogl_disp_list_pads_holes; - m_ogl_disp_list_pads_holes = nullptr; + delete m_pad_holes; + m_pad_holes = nullptr; - delete m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps; - m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps = nullptr; + delete m_vias_and_pad_holes_outer_contourn_and_caps; + m_vias_and_pad_holes_outer_contourn_and_caps = nullptr; } -void C3D_RENDER_OGL_LEGACY::render_solder_mask_layer(PCB_LAYER_ID aLayerID, - float aZPosition, +void C3D_RENDER_OGL_LEGACY::render_solder_mask_layer(PCB_LAYER_ID aLayerID, float aZPosition, bool aDrawMiddleSegments, bool aSkipRenderHoles ) { wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) ); - if( m_ogl_disp_list_board ) + float nonCopperThickness = m_boardAdapter.GetNonCopperLayerThickness3DU(); + + if( m_board ) { - if( m_ogl_disp_lists_layers.find( aLayerID ) != - m_ogl_disp_lists_layers.end() ) + if( m_layers.find( aLayerID ) != m_layers.end() ) { - CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_ogl_disp_lists_layers.at( aLayerID ); + CLAYERS_OGL_DISP_LISTS *pLayerDispListMask = m_layers.at( aLayerID ); - if( m_ogl_disp_list_through_holes_vias_outer ) - m_ogl_disp_list_through_holes_vias_outer->ApplyScalePosition( - aZPosition, - m_boardAdapter.GetNonCopperLayerThickness3DU() ); + if( m_through_holes_vias_outer ) + m_through_holes_vias_outer->ApplyScalePosition( aZPosition, nonCopperThickness ); - m_ogl_disp_list_board->ApplyScalePosition( - aZPosition, - m_boardAdapter.GetNonCopperLayerThickness3DU() ); + m_board->ApplyScalePosition( aZPosition, nonCopperThickness ); set_layer_material( aLayerID ); - m_ogl_disp_list_board->SetItIsTransparent( true ); + m_board->SetItIsTransparent( true ); if( aSkipRenderHoles ) { - m_ogl_disp_list_board->DrawAllCameraCulled( m_camera.GetPos().z, - aDrawMiddleSegments ); + m_board->DrawAllCameraCulled( m_camera.GetPos().z, aDrawMiddleSegments ); } else { - m_ogl_disp_list_board->DrawAllCameraCulledSubtractLayer( - aDrawMiddleSegments, - pLayerDispListMask, - m_ogl_disp_list_through_holes_vias_outer ); + m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments, pLayerDispListMask, + m_through_holes_vias_outer ); } } else { // This case there is no layer with mask, so we will render the full board as mask - if( m_ogl_disp_list_through_holes_vias_outer ) - m_ogl_disp_list_through_holes_vias_outer->ApplyScalePosition( - aZPosition, - m_boardAdapter.GetNonCopperLayerThickness3DU() ); + if( m_through_holes_vias_outer ) + m_through_holes_vias_outer->ApplyScalePosition( aZPosition, nonCopperThickness ); - m_ogl_disp_list_board->ApplyScalePosition( - aZPosition, - m_boardAdapter.GetNonCopperLayerThickness3DU() ); + m_board->ApplyScalePosition( aZPosition, nonCopperThickness ); set_layer_material( aLayerID ); - m_ogl_disp_list_board->SetItIsTransparent( true ); + m_board->SetItIsTransparent( true ); if( aSkipRenderHoles ) { - m_ogl_disp_list_board->DrawAllCameraCulled( m_camera.GetPos().z, - aDrawMiddleSegments ); + m_board->DrawAllCameraCulled( m_camera.GetPos().z, aDrawMiddleSegments ); } else { - m_ogl_disp_list_board->DrawAllCameraCulledSubtractLayer( - aDrawMiddleSegments, - m_ogl_disp_list_through_holes_vias_outer ); + m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments, + m_through_holes_vias_outer ); } } } @@ -1289,8 +1246,8 @@ void C3D_RENDER_OGL_LEGACY::render_3D_models_selected( bool aRenderTopOrBot, { if( m_boardAdapter.ShouldFPBeDisplayed( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) ) { - if( ( aRenderTopOrBot && !fp->IsFlipped() ) - || ( !aRenderTopOrBot && fp->IsFlipped() ) ) + if( ( aRenderTopOrBot && !fp->IsFlipped() ) + || ( !aRenderTopOrBot && fp->IsFlipped() ) ) { render_3D_footprint( fp, aRenderTransparentOnly, isIntersected ); } @@ -1333,7 +1290,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint, glTranslatef( pos.x * m_boardAdapter.BiuTo3Dunits(), -pos.y * m_boardAdapter.BiuTo3Dunits(), - zpos ); + zpos ); if( aFootprint->GetOrientation() ) glRotated((double) aFootprint->GetOrientation() / 10.0, 0.0, 0.0, 1.0 ); @@ -1385,12 +1342,16 @@ void C3D_RENDER_OGL_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint, glMultMatrixf( glm::value_ptr( mtx ) ); if( aRenderTransparentOnly ) + { modelPtr->Draw_transparent( sM.m_Opacity, aFootprint->IsSelected() || aIsSelected, m_boardAdapter.m_opengl_selectionColor ); + } else + { modelPtr->Draw_opaque( aFootprint->IsSelected() || aIsSelected, m_boardAdapter.m_opengl_selectionColor ); + } if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) ) { @@ -1423,20 +1384,20 @@ void C3D_RENDER_OGL_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint, // and a vertical grid (XZ plane and Y = 0) void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType ) { - if( glIsList( m_ogl_disp_list_grid ) ) - glDeleteLists( m_ogl_disp_list_grid, 1 ); + if( glIsList( m_grid ) ) + glDeleteLists( m_grid, 1 ); - m_ogl_disp_list_grid = 0; + m_grid = 0; if( aGridType == GRID3D_TYPE::NONE ) return; - m_ogl_disp_list_grid = glGenLists( 1 ); + m_grid = glGenLists( 1 ); - if( !glIsList( m_ogl_disp_list_grid ) ) + if( !glIsList( m_grid ) ) return; - glNewList( m_ogl_disp_list_grid, GL_COMPILE ); + glNewList( m_grid, GL_COMPILE ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h index 122f7f9f52..d63b475074 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.h @@ -76,43 +76,34 @@ public: private: bool initializeOpenGL(); - CLAYERS_OGL_DISP_LISTS* createBoard( const SHAPE_POLY_SET& aBoardPoly, const CBVHCONTAINER2D *aThroughHoles = nullptr ); + CLAYERS_OGL_DISP_LISTS* createBoard( const SHAPE_POLY_SET& aBoardPoly, + const CBVHCONTAINER2D *aThroughHoles = nullptr ); void reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter ); void ogl_set_arrow_material(); void ogl_free_all_display_lists(); - MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_lists_platedPads_F_Cu; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_lists_platedPads_B_Cu; - MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_outer; - MAP_OGL_DISP_LISTS m_ogl_disp_lists_layers_holes_inner; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_board; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_board_with_holes; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_anti_board; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_outer; - - // User for body render - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_outer_with_npth; - - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_outer; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_outer_ring; - //CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_through_holes_vias_inner; // Not in use - - // This is for pads holes of the footprints - //CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_vias_and_pad_holes_inner_contourn_and_caps; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_vias_and_pad_holes_outer_contourn_and_caps; - - LIST_TRIANGLES m_triangles; // store pointers so can be deleted latter + MAP_OGL_DISP_LISTS m_layers; + CLAYERS_OGL_DISP_LISTS* m_platedPads_F_Cu; + CLAYERS_OGL_DISP_LISTS* m_platedPads_B_Cu; + MAP_OGL_DISP_LISTS m_layers_holes_outer; + MAP_OGL_DISP_LISTS m_layers_holes_inner; + CLAYERS_OGL_DISP_LISTS* m_board; + CLAYERS_OGL_DISP_LISTS* m_board_with_holes; + CLAYERS_OGL_DISP_LISTS* m_anti_board; + CLAYERS_OGL_DISP_LISTS* m_through_holes_outer; + CLAYERS_OGL_DISP_LISTS* m_through_holes_vias_outer; + CLAYERS_OGL_DISP_LISTS* m_through_holes_outer_ring; + CLAYERS_OGL_DISP_LISTS* m_vias_and_pad_holes_outer_contourn_and_caps; + LIST_TRIANGLES m_triangles; ///< store pointers so can be deleted latter GLuint m_ogl_circle_texture; - GLuint m_ogl_disp_list_grid; ///< oGL list that stores current grid - + GLuint m_grid; ///< oGL list that stores current grid GRID3D_TYPE m_last_grid_type; ///< Stores the last grid computed - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_via; - CLAYERS_OGL_DISP_LISTS* m_ogl_disp_list_pads_holes; + CLAYERS_OGL_DISP_LISTS* m_vias; + CLAYERS_OGL_DISP_LISTS* m_pad_holes; MAP_3DMODEL m_3dmodel_map;