3D viewer: Fix: board outlines ignored in 3D for triangular board shapes

Fix also a few minor coding style issues.

Fixes: lp:1814324
https://bugs.launchpad.net/kicad/+bug/1814324
This commit is contained in:
jean-pierre charras 2019-02-02 17:59:53 +01:00
parent c0cd4c03fb
commit 098d9bf056
2 changed files with 25 additions and 48 deletions

View File

@ -501,11 +501,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter )
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 );
container->GetList(), *poly, layer_z_top, layer_z_bot, false );
}
for( MAP_POLY::const_iterator ii = innerMapHoles.begin();
@ -519,11 +515,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter )
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 );
container->GetList(), *poly, layer_z_top, layer_z_bot, false );
}
}
@ -531,7 +523,6 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter )
generate_3D_Vias_and_Pads();
// Add layers maps
// /////////////////////////////////////////////////////////////////////////
if( aStatusTextReporter )
aStatusTextReporter->Report( _( "Load OpenGL: layers" ) );
@ -574,32 +565,27 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter )
{
case OBJ2D_FILLED_CIRCLE:
add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
layerTriangles, layer_z_top, layer_z_bot );
break;
case OBJ2D_POLYGON4PT:
add_object_to_triangle_layer( (const CPOLYGON4PTS2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
layerTriangles, layer_z_top, layer_z_bot );
break;
case OBJ2D_RING:
add_object_to_triangle_layer( (const CRING2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
layerTriangles, layer_z_top, layer_z_bot );
break;
case OBJ2D_TRIANGLE:
add_object_to_triangle_layer( (const CTRIANGLE2D *)object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
layerTriangles, layer_z_top, layer_z_bot );
break;
case OBJ2D_ROUNDSEG:
add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A,
layerTriangles,
layer_z_top, layer_z_bot );
layerTriangles, layer_z_top, layer_z_bot );
break;
default:
@ -885,12 +871,8 @@ 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 );
@ -898,16 +880,14 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads()
if( tht_outer_holes_poly.OutlineCount() > 0 )
{
layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
layer_z_bot,
layer_z_top,
layer_z_bot, layer_z_top,
m_settings.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 );
layer_z_top, layer_z_top );
}
delete layerTriangles;
@ -931,8 +911,7 @@ void C3D_RENDER_OGL_LEGACY::load_3D_models( REPORTER *aStatusTextReporter )
// Go for all modules
for( const MODULE* module = m_settings.GetBoard()->m_Modules;
module;
module = module->Next() )
module; module = module->Next() )
{
if( !module->Models().empty() )
{

View File

@ -150,7 +150,7 @@ void CLAYER_TRIANGLES::AddToMiddleContourns( const std::vector< SFVEC2F > &aCont
float zTop,
bool aInvertFaceDirection )
{
if( aContournPoints.size() > 4 )
if( aContournPoints.size() >= 4 )
{
// Calculate normals of each segment of the contourn
std::vector< SFVEC2F > contournNormals;
@ -164,7 +164,6 @@ void CLAYER_TRIANGLES::AddToMiddleContourns( const std::vector< SFVEC2F > &aCont
{
const SFVEC2F &v0 = aContournPoints[i + 0];
const SFVEC2F &v1 = aContournPoints[i + 1];
const SFVEC2F n = glm::normalize( v1 - v0 );
contournNormals[i] = SFVEC2F( n.y,-n.x );
@ -176,7 +175,6 @@ void CLAYER_TRIANGLES::AddToMiddleContourns( const std::vector< SFVEC2F > &aCont
{
const SFVEC2F &v0 = aContournPoints[i + 0];
const SFVEC2F &v1 = aContournPoints[i + 1];
const SFVEC2F n = glm::normalize( v1 - v0 );
contournNormals[i] = SFVEC2F( -n.y, n.x );