3D-Viewer: OpenGL outline, implement an outline board cut
This commit is contained in:
parent
3fce3b6591
commit
78b461a41d
|
@ -455,11 +455,9 @@ CLAYERS_OGL_DISP_LISTS* C3D_RENDER_OGL_LEGACY::createBoard( const SHAPE_POLY_SET
|
|||
layer_z_bot );
|
||||
}
|
||||
|
||||
const SHAPE_POLY_SET &boardPoly = m_boardAdapter.GetBoardPoly();
|
||||
|
||||
if( boardPoly.OutlineCount() > 0 )
|
||||
if( aBoardPoly.OutlineCount() > 0 )
|
||||
{
|
||||
layerTriangles->AddToMiddleContourns( boardPoly,
|
||||
layerTriangles->AddToMiddleContourns( aBoardPoly,
|
||||
layer_z_bot,
|
||||
layer_z_top,
|
||||
m_boardAdapter.BiuTo3Dunits(),
|
||||
|
@ -501,16 +499,22 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin
|
|||
|
||||
m_ogl_disp_list_board = createBoard( m_boardAdapter.GetBoardPoly() );
|
||||
|
||||
SHAPE_POLY_SET anti_board;
|
||||
anti_board.NewOutline();
|
||||
anti_board.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
|
||||
anti_board.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
|
||||
anti_board.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
|
||||
anti_board.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
|
||||
anti_board.Outline( 0 ).SetClosed( true );
|
||||
m_anti_board_poly.RemoveAllContours();
|
||||
m_anti_board_poly.NewOutline();
|
||||
m_anti_board_poly.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
|
||||
m_anti_board_poly.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
|
||||
m_anti_board_poly.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
|
||||
m_anti_board_poly.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
|
||||
m_anti_board_poly.Outline( 0 ).SetClosed( true );
|
||||
|
||||
anti_board.BooleanSubtract( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_FAST );
|
||||
m_ogl_disp_list_anti_board = createBoard( anti_board );
|
||||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
m_ogl_disp_list_board_with_holes = createBoard( board_poly_with_holes );
|
||||
|
||||
if( m_ogl_disp_list_anti_board )
|
||||
m_ogl_disp_list_anti_board->SetItIsTransparent( true );
|
||||
|
@ -521,21 +525,12 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin
|
|||
if( aStatusReporter )
|
||||
aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
|
||||
|
||||
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetThroughHole_Outer_poly();
|
||||
outerPolyTHT.BooleanIntersection( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
||||
|
||||
m_ogl_disp_list_through_holes_outer = generate_holes_display_list(
|
||||
m_boardAdapter.GetThroughHole_Outer().GetList(),
|
||||
m_boardAdapter.GetThroughHole_Outer_poly(),
|
||||
1.0f,
|
||||
0.0f,
|
||||
false );
|
||||
|
||||
SHAPE_POLY_SET bodyHoles = m_boardAdapter.GetThroughHole_Outer_poly();
|
||||
|
||||
bodyHoles.BooleanAdd( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(),
|
||||
SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
m_ogl_disp_list_through_holes_outer_with_npth = generate_holes_display_list(
|
||||
m_boardAdapter.GetThroughHole_Outer().GetList(),
|
||||
bodyHoles,
|
||||
outerPolyTHT,
|
||||
1.0f,
|
||||
0.0f,
|
||||
false );
|
||||
|
@ -634,7 +629,19 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarnin
|
|||
aPolyList = map_poly.at( layer_id );
|
||||
}
|
||||
|
||||
CLAYERS_OGL_DISP_LISTS* oglList = generateLayerListFromContainer( container2d, aPolyList, layer_id );
|
||||
SHAPE_POLY_SET polyListSubtracted;
|
||||
polyListSubtracted = *aPolyList;
|
||||
|
||||
polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(), SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
CLAYERS_OGL_DISP_LISTS* oglList = generateLayerListFromContainer( container2d, &polyListSubtracted, layer_id );
|
||||
|
||||
if( oglList != nullptr )
|
||||
m_ogl_disp_lists_layers[layer_id] = oglList;
|
||||
|
@ -834,7 +841,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads()
|
|||
|
||||
// Subtract the holes
|
||||
tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
tht_outer_holes_poly.BooleanSubtract( m_anti_board_poly, SHAPE_POLY_SET::PM_FAST );
|
||||
|
||||
CCONTAINER2D holesContainer;
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY( BOARD_ADAPTER& aAdapter, CCAMERA&
|
|||
m_ogl_disp_lists_platedPads_F_Cu = nullptr;
|
||||
m_ogl_disp_lists_platedPads_B_Cu = nullptr;
|
||||
|
||||
m_ogl_disp_list_through_holes_outer_with_npth = NULL;
|
||||
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;
|
||||
|
@ -528,33 +527,26 @@ void C3D_RENDER_OGL_LEGACY::unsetDepthOffset()
|
|||
|
||||
void C3D_RENDER_OGL_LEGACY::render_board_body( bool aSkipRenderHoles )
|
||||
{
|
||||
if( m_ogl_disp_list_board )
|
||||
m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor;
|
||||
m_materials.m_EpoxyBoard.m_Transparency = 1.0f - m_boardAdapter.m_BoardBodyColor.a; // opacity to transparency
|
||||
|
||||
OGL_SetMaterial( m_materials.m_EpoxyBoard, 1.0f );
|
||||
|
||||
CLAYERS_OGL_DISP_LISTS* ogl_disp_list = nullptr;
|
||||
|
||||
if( aSkipRenderHoles )
|
||||
ogl_disp_list = m_ogl_disp_list_board;
|
||||
else
|
||||
ogl_disp_list = m_ogl_disp_list_board_with_holes;
|
||||
|
||||
if( ogl_disp_list )
|
||||
{
|
||||
m_ogl_disp_list_board->ApplyScalePosition( -m_boardAdapter.GetEpoxyThickness3DU() / 2.0f,
|
||||
m_boardAdapter.GetEpoxyThickness3DU() );
|
||||
ogl_disp_list->ApplyScalePosition( -m_boardAdapter.GetEpoxyThickness3DU() / 2.0f,
|
||||
m_boardAdapter.GetEpoxyThickness3DU() );
|
||||
|
||||
ogl_disp_list->SetItIsTransparent( true );
|
||||
|
||||
m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor;
|
||||
m_materials.m_EpoxyBoard.m_Transparency = 1.0f - m_boardAdapter.m_BoardBodyColor.a; // opacity to transparency
|
||||
|
||||
OGL_SetMaterial( m_materials.m_EpoxyBoard, 1.0f );
|
||||
|
||||
m_ogl_disp_list_board->SetItIsTransparent( true );
|
||||
|
||||
if( (m_ogl_disp_list_through_holes_outer_with_npth) && (!aSkipRenderHoles) )
|
||||
{
|
||||
m_ogl_disp_list_through_holes_outer_with_npth->ApplyScalePosition(
|
||||
-m_boardAdapter.GetEpoxyThickness3DU() / 2.0f,
|
||||
m_boardAdapter.GetEpoxyThickness3DU() );
|
||||
|
||||
m_ogl_disp_list_board->DrawAllCameraCulledSubtractLayer(
|
||||
true,
|
||||
m_ogl_disp_list_through_holes_outer_with_npth );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ogl_disp_list_board->DrawAll();
|
||||
}
|
||||
ogl_disp_list->DrawAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,6 +759,12 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
|
|||
pLayerDispList->GetZBot(),
|
||||
pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
|
||||
|
||||
if( m_ogl_disp_list_anti_board )
|
||||
{
|
||||
m_ogl_disp_list_anti_board->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() )
|
||||
{
|
||||
|
@ -780,7 +778,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
|
|||
pLayerDispList->DrawAllCameraCulledSubtractLayer(
|
||||
drawMiddleSegments,
|
||||
m_ogl_disp_list_through_holes_outer,
|
||||
viasHolesLayer );
|
||||
viasHolesLayer,
|
||||
m_ogl_disp_list_anti_board );
|
||||
|
||||
// Draw copper plated pads
|
||||
|
||||
|
@ -793,14 +792,16 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
|
|||
m_ogl_disp_lists_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer(
|
||||
drawMiddleSegments,
|
||||
m_ogl_disp_list_through_holes_outer,
|
||||
viasHolesLayer );
|
||||
viasHolesLayer,
|
||||
m_ogl_disp_list_anti_board );
|
||||
}
|
||||
else if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu )
|
||||
{
|
||||
m_ogl_disp_lists_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer(
|
||||
drawMiddleSegments,
|
||||
m_ogl_disp_list_through_holes_outer,
|
||||
viasHolesLayer );
|
||||
viasHolesLayer,
|
||||
m_ogl_disp_list_anti_board );
|
||||
}
|
||||
|
||||
unsetDepthOffset();
|
||||
|
@ -810,7 +811,8 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
|
|||
{
|
||||
pLayerDispList->DrawAllCameraCulledSubtractLayer(
|
||||
drawMiddleSegments,
|
||||
m_ogl_disp_list_through_holes_outer );
|
||||
m_ogl_disp_list_through_holes_outer,
|
||||
m_ogl_disp_list_anti_board );
|
||||
|
||||
// Draw copper plated pads
|
||||
|
||||
|
@ -824,13 +826,15 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
|
|||
{
|
||||
m_ogl_disp_lists_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer(
|
||||
drawMiddleSegments,
|
||||
m_ogl_disp_list_through_holes_outer );
|
||||
m_ogl_disp_list_through_holes_outer,
|
||||
m_ogl_disp_list_anti_board );
|
||||
}
|
||||
else if( ( layer_id == B_Cu ) && m_ogl_disp_lists_platedPads_B_Cu )
|
||||
{
|
||||
m_ogl_disp_lists_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer(
|
||||
drawMiddleSegments,
|
||||
m_ogl_disp_list_through_holes_outer );
|
||||
m_ogl_disp_list_through_holes_outer,
|
||||
m_ogl_disp_list_anti_board );
|
||||
}
|
||||
|
||||
unsetDepthOffset();
|
||||
|
@ -1155,9 +1159,6 @@ void C3D_RENDER_OGL_LEGACY::ogl_free_all_display_lists()
|
|||
delete m_ogl_disp_list_anti_board;
|
||||
m_ogl_disp_list_anti_board = nullptr;
|
||||
|
||||
delete m_ogl_disp_list_through_holes_outer_with_npth;
|
||||
m_ogl_disp_list_through_holes_outer_with_npth = nullptr;
|
||||
|
||||
delete m_ogl_disp_list_through_holes_outer;
|
||||
m_ogl_disp_list_through_holes_outer = nullptr;
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ private:
|
|||
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;
|
||||
|
||||
|
@ -114,6 +115,8 @@ private:
|
|||
|
||||
BOARD_ITEM* m_currentIntersectedBoardItem;
|
||||
|
||||
SHAPE_POLY_SET m_anti_board_poly; ///< negative polygon representation of the board outline
|
||||
|
||||
private:
|
||||
CLAYERS_OGL_DISP_LISTS *generate_holes_display_list( const LIST_OBJECT2D &aListHolesObject2d,
|
||||
const SHAPE_POLY_SET &aPoly,
|
||||
|
|
|
@ -524,7 +524,8 @@ void CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulled(float zCameraPos, bool aDrawMid
|
|||
void CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulledSubtractLayer( bool aDrawMiddle,
|
||||
const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractA,
|
||||
const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractB,
|
||||
const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractC ) const
|
||||
const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractC,
|
||||
const CLAYERS_OGL_DISP_LISTS *aLayerToSubtractD ) const
|
||||
{
|
||||
glClearStencil( 0x00 );
|
||||
glClear( GL_STENCIL_BUFFER_BIT );
|
||||
|
@ -548,6 +549,8 @@ void CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulledSubtractLayer( bool aDrawMiddle,
|
|||
if( aLayerToSubtractC )
|
||||
aLayerToSubtractC->DrawBot();
|
||||
|
||||
if( aLayerToSubtractD )
|
||||
aLayerToSubtractD->DrawBot();
|
||||
|
||||
//if( !m_draw_it_transparent )
|
||||
{
|
||||
|
@ -576,6 +579,9 @@ void CLAYERS_OGL_DISP_LISTS::DrawAllCameraCulledSubtractLayer( bool aDrawMiddle,
|
|||
if( aLayerToSubtractC )
|
||||
aLayerToSubtractC->DrawTop();
|
||||
|
||||
if( aLayerToSubtractD )
|
||||
aLayerToSubtractD->DrawTop();
|
||||
|
||||
//if( !m_draw_it_transparent )
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
|
|
@ -256,7 +256,8 @@ public:
|
|||
void DrawAllCameraCulledSubtractLayer( bool aDrawMiddle,
|
||||
const CLAYERS_OGL_DISP_LISTS* aLayerToSubtractA = nullptr,
|
||||
const CLAYERS_OGL_DISP_LISTS* aLayerToSubtractB = nullptr,
|
||||
const CLAYERS_OGL_DISP_LISTS* aLayerToSubtractC = nullptr ) const;
|
||||
const CLAYERS_OGL_DISP_LISTS* aLayerToSubtractC = nullptr,
|
||||
const CLAYERS_OGL_DISP_LISTS* aLayerToSubtractD = nullptr ) const;
|
||||
|
||||
void ApplyScalePosition( float aZposition, float aZscale );
|
||||
|
||||
|
|
Loading…
Reference in New Issue