2015-12-08 07:31:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 17:35:25 +00:00
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2020-12-13 23:02:57 +00:00
|
|
|
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 07:31:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2021-01-03 22:23:00 +00:00
|
|
|
#include "render_3d_legacy.h"
|
2015-12-08 07:31:57 +00:00
|
|
|
#include "ogl_legacy_utils.h"
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
2016-07-19 17:35:25 +00:00
|
|
|
#include "../../3d_math.h"
|
2015-12-08 07:31:57 +00:00
|
|
|
#include <trigo.h>
|
2016-07-19 17:35:25 +00:00
|
|
|
#include <project.h>
|
2018-04-08 10:28:59 +00:00
|
|
|
#include <profile.h> // To use GetRunningMicroSecs or another profiling utility
|
2021-08-16 14:28:46 +00:00
|
|
|
#include <eda_3d_canvas.h>
|
|
|
|
#include <eda_3d_viewer_frame.h>
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::addObjectTriangles( const FILLED_CIRCLE_2D* aFilledCircle,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& center = aFilledCircle->GetCenter();
|
2021-01-05 22:19:00 +00:00
|
|
|
const float radius = aFilledCircle->GetRadius() * 2.0f; // Double because the render triangle
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// This is a small adjustment to the circle texture
|
2021-01-05 22:19:00 +00:00
|
|
|
const float texture_factor = ( 8.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
|
|
|
|
const float f = ( sqrtf( 2.0f ) / 2.0f ) * radius * texture_factor;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
// Top and Bot segments ends are just triangle semi-circles, so need to add it in duplicated.
|
2016-07-19 17:35:25 +00:00
|
|
|
aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZtop ),
|
|
|
|
SFVEC3F( center.x - f, center.y, aZtop ),
|
2020-11-30 01:07:49 +00:00
|
|
|
SFVEC3F( center.x, center.y - f, aZtop ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZtop ),
|
|
|
|
SFVEC3F( center.x + f, center.y, aZtop ),
|
2020-11-30 01:07:49 +00:00
|
|
|
SFVEC3F( center.x, center.y + f, aZtop ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x - f, center.y, aZbot ),
|
|
|
|
SFVEC3F( center.x + f, center.y, aZbot ),
|
2020-11-30 01:07:49 +00:00
|
|
|
SFVEC3F( center.x, center.y - f, aZbot ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
aDstLayer->m_layer_bot_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZbot ),
|
|
|
|
SFVEC3F( center.x - f, center.y, aZbot ),
|
2020-11-30 01:07:49 +00:00
|
|
|
SFVEC3F( center.x, center.y + f, aZbot ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::addObjectTriangles( const POLYGON_4PT_2D* aPoly,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& v0 = aPoly->GetV0();
|
|
|
|
const SFVEC2F& v1 = aPoly->GetV1();
|
|
|
|
const SFVEC2F& v2 = aPoly->GetV2();
|
|
|
|
const SFVEC2F& v3 = aPoly->GetV3();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
addTopAndBottomTriangles( aDstLayer, v0, v2, v1, aZtop, aZbot );
|
|
|
|
addTopAndBottomTriangles( aDstLayer, v2, v0, v3, aZtop, aZbot );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::generateRing( const SFVEC2F& aCenter, float aInnerRadius,
|
|
|
|
float aOuterRadius, unsigned int aNr_sides_per_circle,
|
|
|
|
std::vector< SFVEC2F >& aInnerContourResult,
|
|
|
|
std::vector< SFVEC2F >& aOuterContourResult,
|
|
|
|
bool aInvertOrder )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
aInnerContourResult.clear();
|
|
|
|
aInnerContourResult.reserve( aNr_sides_per_circle + 2 );
|
|
|
|
|
|
|
|
aOuterContourResult.clear();
|
|
|
|
aOuterContourResult.reserve( aNr_sides_per_circle + 2 );
|
|
|
|
|
|
|
|
const int delta = 3600 / aNr_sides_per_circle;
|
|
|
|
|
|
|
|
for( int ii = 0; ii < 3600; ii += delta )
|
|
|
|
{
|
2018-02-06 12:28:53 +00:00
|
|
|
float angle = (float)( aInvertOrder ? ( 3600 - ii ) : ii )
|
2020-12-13 23:02:57 +00:00
|
|
|
* 2.0f * glm::pi<float>() / 3600.0f;
|
2018-02-06 12:28:53 +00:00
|
|
|
const SFVEC2F rotatedDir = SFVEC2F( cos( angle ), sin( angle ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-12-05 15:41:21 +00:00
|
|
|
aInnerContourResult.emplace_back( aCenter.x + rotatedDir.x * aInnerRadius,
|
2020-11-30 01:07:49 +00:00
|
|
|
aCenter.y + rotatedDir.y * aInnerRadius );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-12-05 15:41:21 +00:00
|
|
|
aOuterContourResult.emplace_back( aCenter.x + rotatedDir.x * aOuterRadius,
|
2020-11-30 01:07:49 +00:00
|
|
|
aCenter.y + rotatedDir.y * aOuterRadius );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aInnerContourResult.push_back( aInnerContourResult[0] );
|
|
|
|
aOuterContourResult.push_back( aOuterContourResult[0] );
|
|
|
|
|
|
|
|
wxASSERT( aInnerContourResult.size() == aOuterContourResult.size() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::addObjectTriangles( const RING_2D* aRing,
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& center = aRing->GetCenter();
|
2016-07-19 17:35:25 +00:00
|
|
|
const float inner = aRing->GetInnerRadius();
|
|
|
|
const float outer = aRing->GetOuterRadius();
|
|
|
|
|
|
|
|
std::vector< SFVEC2F > innerContour;
|
|
|
|
std::vector< SFVEC2F > outerContour;
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
generateRing( center, inner, outer, m_boardAdapter.GetCircleSegmentCount( outer * 2.0f ),
|
|
|
|
innerContour, outerContour, false );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// This will add the top and bot quads that will form the approximated ring
|
|
|
|
for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& vi0 = innerContour[i + 0];
|
|
|
|
const SFVEC2F& vi1 = innerContour[i + 1];
|
|
|
|
const SFVEC2F& vo0 = outerContour[i + 0];
|
|
|
|
const SFVEC2F& vo1 = outerContour[i + 1];
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
|
|
|
|
SFVEC3F( vi0.x, vi0.y, aZtop ),
|
|
|
|
SFVEC3F( vo0.x, vo0.y, aZtop ),
|
|
|
|
SFVEC3F( vo1.x, vo1.y, aZtop ) );
|
|
|
|
|
|
|
|
aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
|
|
|
|
SFVEC3F( vo1.x, vo1.y, aZbot ),
|
|
|
|
SFVEC3F( vo0.x, vo0.y, aZbot ),
|
|
|
|
SFVEC3F( vi0.x, vi0.y, aZbot ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::addObjectTriangles( const TRIANGLE_2D* aTri,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& v1 = aTri->GetP1();
|
|
|
|
const SFVEC2F& v2 = aTri->GetP2();
|
|
|
|
const SFVEC2F& v3 = aTri->GetP3();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
addTopAndBottomTriangles( aDstLayer, v1, v2, v3, aZtop, aZbot );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::addObjectTriangles( const ROUND_SEGMENT_2D* aSeg,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer,
|
|
|
|
float aZtop, float aZbot )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2019-12-05 15:40:22 +00:00
|
|
|
const SFVEC2F& leftStart = aSeg->GetLeftStar();
|
|
|
|
const SFVEC2F& leftEnd = aSeg->GetLeftEnd();
|
|
|
|
const SFVEC2F& leftDir = aSeg->GetLeftDir();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-12-05 15:40:22 +00:00
|
|
|
const SFVEC2F& rightStart = aSeg->GetRightStar();
|
|
|
|
const SFVEC2F& rightEnd = aSeg->GetRightEnd();
|
|
|
|
const SFVEC2F& rightDir = aSeg->GetRightDir();
|
2021-03-06 09:27:41 +00:00
|
|
|
const float radius = aSeg->GetRadius();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2019-12-05 15:40:22 +00:00
|
|
|
const SFVEC2F& start = aSeg->GetStart();
|
|
|
|
const SFVEC2F& end = aSeg->GetEnd();
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
const float texture_factor = ( 12.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
|
|
|
|
const float texture_factorF = ( 6.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
const float radius_of_the_square = sqrtf( aSeg->GetRadiusSquared() * 2.0f );
|
2020-12-13 23:02:57 +00:00
|
|
|
const float radius_triangle_factor = ( radius_of_the_square - radius ) / radius;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
const SFVEC2F factorS = SFVEC2F( -rightDir.y * radius * radius_triangle_factor,
|
|
|
|
rightDir.x * radius * radius_triangle_factor );
|
|
|
|
|
|
|
|
const SFVEC2F factorE = SFVEC2F( -leftDir.y * radius * radius_triangle_factor,
|
|
|
|
leftDir.x * radius * radius_triangle_factor );
|
|
|
|
|
|
|
|
// Top end segment triangles (semi-circles)
|
|
|
|
aDstLayer->m_layer_top_segment_ends->AddTriangle(
|
|
|
|
SFVEC3F( rightEnd.x + texture_factor * factorS.x,
|
|
|
|
rightEnd.y + texture_factor * factorS.y,
|
|
|
|
aZtop ),
|
|
|
|
SFVEC3F( leftStart.x + texture_factor * factorE.x,
|
|
|
|
leftStart.y + texture_factor * factorE.y,
|
|
|
|
aZtop ),
|
|
|
|
SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
|
|
|
|
start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
|
|
|
|
aZtop ) );
|
|
|
|
|
|
|
|
aDstLayer->m_layer_top_segment_ends->AddTriangle(
|
|
|
|
SFVEC3F( leftEnd.x + texture_factor * factorE.x,
|
|
|
|
leftEnd.y + texture_factor * factorE.y, aZtop ),
|
|
|
|
SFVEC3F( rightStart.x + texture_factor * factorS.x,
|
|
|
|
rightStart.y + texture_factor * factorS.y, aZtop ),
|
|
|
|
SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
|
|
|
|
end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
|
|
|
|
aZtop ) );
|
|
|
|
|
|
|
|
// Bot end segment triangles (semi-circles)
|
|
|
|
aDstLayer->m_layer_bot_segment_ends->AddTriangle(
|
|
|
|
SFVEC3F( leftStart.x + texture_factor * factorE.x,
|
|
|
|
leftStart.y + texture_factor * factorE.y,
|
|
|
|
aZbot ),
|
|
|
|
SFVEC3F( rightEnd.x + texture_factor * factorS.x,
|
|
|
|
rightEnd.y + texture_factor * factorS.y,
|
|
|
|
aZbot ),
|
|
|
|
SFVEC3F( start.x - texture_factorF * leftDir.x * radius * sqrtf( 2.0f ),
|
|
|
|
start.y - texture_factorF * leftDir.y * radius * sqrtf( 2.0f ),
|
|
|
|
aZbot ) );
|
|
|
|
|
|
|
|
aDstLayer->m_layer_bot_segment_ends->AddTriangle(
|
|
|
|
SFVEC3F( rightStart.x + texture_factor * factorS.x,
|
|
|
|
rightStart.y + texture_factor * factorS.y, aZbot ),
|
|
|
|
SFVEC3F( leftEnd.x + texture_factor * factorE.x,
|
|
|
|
leftEnd.y + texture_factor * factorE.y, aZbot ),
|
|
|
|
SFVEC3F( end.x - texture_factorF * rightDir.x * radius * sqrtf( 2.0f ),
|
|
|
|
end.y - texture_factorF * rightDir.y * radius * sqrtf( 2.0f ),
|
|
|
|
aZbot ) );
|
|
|
|
|
|
|
|
// Segment top and bot planes
|
|
|
|
aDstLayer->m_layer_top_triangles->AddQuad(
|
|
|
|
SFVEC3F( rightEnd.x, rightEnd.y, aZtop ),
|
|
|
|
SFVEC3F( rightStart.x, rightStart.y, aZtop ),
|
|
|
|
SFVEC3F( leftEnd.x, leftEnd.y, aZtop ),
|
|
|
|
SFVEC3F( leftStart.x, leftStart.y, aZtop ) );
|
|
|
|
|
|
|
|
aDstLayer->m_layer_bot_triangles->AddQuad(
|
|
|
|
SFVEC3F( rightEnd.x, rightEnd.y, aZbot ),
|
|
|
|
SFVEC3F( leftStart.x, leftStart.y, aZbot ),
|
|
|
|
SFVEC3F( leftEnd.x, leftEnd.y, aZbot ),
|
|
|
|
SFVEC3F( rightStart.x, rightStart.y, aZbot ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generateHoles( const LIST_OBJECT2D& aListHolesObject2d,
|
|
|
|
const SHAPE_POLY_SET& aPoly, float aZtop,
|
|
|
|
float aZbot, bool aInvertFaces,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST* ret = nullptr;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
if( aListHolesObject2d.size() > 0 )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST* layerTriangles =
|
|
|
|
new TRIANGLE_DISPLAY_LIST( aListHolesObject2d.size() * 2 );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
// Convert the list of objects(filled circles) to triangle layer structure
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const OBJECT_2D* itemOnLayer : aListHolesObject2d )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const OBJECT_2D* object2d_A = itemOnLayer;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::FILLED_CIRCLE )
|
|
|
|
|| ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::ROUNDSEG ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
switch( object2d_A->GetObjectType() )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
case OBJECT_2D_TYPE::FILLED_CIRCLE:
|
2021-01-05 22:19:00 +00:00
|
|
|
addObjectTriangles( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
|
|
|
|
layerTriangles, aZtop, aZbot );
|
2016-07-19 17:35:25 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
case OBJECT_2D_TYPE::ROUNDSEG:
|
2021-01-05 22:19:00 +00:00
|
|
|
addObjectTriangles( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
|
|
|
|
layerTriangles, aZtop, aZbot );
|
2016-07-19 17:35:25 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-30 13:01:06 +00:00
|
|
|
default:
|
2021-01-05 22:19:00 +00:00
|
|
|
wxFAIL_MSG( "RENDER_3D_LEGACY::generateHoles: Object type is not implemented" );
|
2016-07-19 17:35:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Note: he can have a aListHolesObject2d with holes but without contours
|
2020-12-13 23:02:57 +00:00
|
|
|
// eg: when there are only NPTH on the list and the contours were not added
|
2016-07-19 17:35:25 +00:00
|
|
|
if( aPoly.OutlineCount() > 0 )
|
|
|
|
{
|
2020-11-30 01:07:49 +00:00
|
|
|
layerTriangles->AddToMiddleContourns( aPoly, aZbot, aZtop,
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.BiuTo3dUnits(),
|
2020-11-30 01:07:49 +00:00
|
|
|
aInvertFaces, aThroughHoles );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
ret = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, aZbot, aZtop );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
delete layerTriangles;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generateLayerList( const BVH_CONTAINER_2D* aContainer,
|
|
|
|
const SHAPE_POLY_SET* aPolyList,
|
|
|
|
PCB_LAYER_ID aLayerId,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles )
|
2020-09-06 19:09:43 +00:00
|
|
|
{
|
|
|
|
if( aContainer == nullptr )
|
|
|
|
return nullptr;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const LIST_OBJECT2D& listObject2d = aContainer->GetList();
|
2020-09-06 19:09:43 +00:00
|
|
|
|
|
|
|
if( listObject2d.size() == 0 )
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
float layer_z_bot = 0.0f;
|
|
|
|
float layer_z_top = 0.0f;
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
getLayerZPos( aLayerId, layer_z_top, layer_z_bot );
|
2020-09-06 19:09:43 +00:00
|
|
|
|
|
|
|
// Calculate an estimation for the nr of triangles based on the nr of objects
|
|
|
|
unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( nrTrianglesEstimation );
|
2020-09-06 19:09:43 +00:00
|
|
|
|
|
|
|
// store in a list so it will be latter deleted
|
|
|
|
m_triangles.push_back( layerTriangles );
|
|
|
|
|
|
|
|
// Load the 2D (X,Y axis) component of shapes
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const OBJECT_2D* itemOnLayer : listObject2d )
|
2020-09-06 19:09:43 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const OBJECT_2D* object2d_A = itemOnLayer;
|
2020-09-06 19:09:43 +00:00
|
|
|
|
|
|
|
switch( object2d_A->GetObjectType() )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
case OBJECT_2D_TYPE::FILLED_CIRCLE:
|
2021-03-06 09:27:41 +00:00
|
|
|
addObjectTriangles( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
|
|
|
|
layerTriangles, layer_z_top, layer_z_bot );
|
2020-09-06 19:09:43 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
case OBJECT_2D_TYPE::POLYGON4PT:
|
2021-03-06 09:27:41 +00:00
|
|
|
addObjectTriangles( static_cast<const POLYGON_4PT_2D*>( object2d_A ),
|
|
|
|
layerTriangles, layer_z_top, layer_z_bot );
|
2020-09-06 19:09:43 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
case OBJECT_2D_TYPE::RING:
|
2021-03-06 09:27:41 +00:00
|
|
|
addObjectTriangles( static_cast<const RING_2D*>( object2d_A ),
|
|
|
|
layerTriangles, layer_z_top, layer_z_bot );
|
2020-09-06 19:09:43 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
case OBJECT_2D_TYPE::TRIANGLE:
|
2021-03-06 09:27:41 +00:00
|
|
|
addObjectTriangles( static_cast<const TRIANGLE_2D*>( object2d_A ),
|
|
|
|
layerTriangles, layer_z_top, layer_z_bot );
|
2020-09-06 19:09:43 +00:00
|
|
|
break;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
case OBJECT_2D_TYPE::ROUNDSEG:
|
2021-03-06 09:27:41 +00:00
|
|
|
addObjectTriangles( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
|
|
|
|
layerTriangles, layer_z_top, layer_z_bot );
|
2020-09-06 19:09:43 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-01-02 21:05:29 +00:00
|
|
|
wxFAIL_MSG( "RENDER_3D_LEGACY: Object type is not implemented" );
|
2020-09-06 19:09:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
if( aPolyList && aPolyList->OutlineCount() > 0 )
|
2020-11-30 01:07:49 +00:00
|
|
|
{
|
|
|
|
layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top,
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.BiuTo3dUnits(), false, aThroughHoles );
|
2020-11-30 01:07:49 +00:00
|
|
|
}
|
2020-12-13 23:02:57 +00:00
|
|
|
|
2020-09-06 19:09:43 +00:00
|
|
|
// Create display list
|
2021-01-05 22:19:00 +00:00
|
|
|
return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top );
|
2020-09-06 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST* RENDER_3D_LEGACY::createBoard( const SHAPE_POLY_SET& aBoardPoly,
|
|
|
|
const BVH_CONTAINER_2D* aThroughHoles )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
OPENGL_RENDER_LIST* dispLists = nullptr;
|
|
|
|
CONTAINER_2D boardContainer;
|
2020-10-26 18:43:43 +00:00
|
|
|
SHAPE_POLY_SET brd_outlines = aBoardPoly;
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
ConvertPolygonToTriangles( brd_outlines, boardContainer, m_boardAdapter.BiuTo3dUnits(),
|
|
|
|
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const LIST_OBJECT2D& listBoardObject2d = boardContainer.GetList();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
if( listBoardObject2d.size() > 0 )
|
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
// We will set a unitary Z so it will in future used with transformations
|
|
|
|
// since the board poly will be used not only to draw itself but also the
|
|
|
|
// solder mask layers.
|
|
|
|
const float layer_z_top = 1.0f;
|
|
|
|
const float layer_z_bot = 0.0f;
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST* layerTriangles =
|
|
|
|
new TRIANGLE_DISPLAY_LIST( listBoardObject2d.size() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Convert the list of objects(triangles) to triangle layer structure
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const OBJECT_2D* itemOnLayer : listBoardObject2d )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const OBJECT_2D* object2d_A = itemOnLayer;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& v1 = tri->GetP1();
|
|
|
|
const SFVEC2F& v2 = tri->GetP2();
|
|
|
|
const SFVEC2F& v3 = tri->GetP3();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 09:38:07 +00:00
|
|
|
if( aBoardPoly.OutlineCount() > 0 )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2020-11-30 01:07:49 +00:00
|
|
|
layerTriangles->AddToMiddleContourns( aBoardPoly, layer_z_bot, layer_z_top,
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.BiuTo3dUnits(), false,
|
2020-11-04 09:36:41 +00:00
|
|
|
aThroughHoles );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
dispLists = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
|
|
|
|
layer_z_top, layer_z_top );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
delete layerTriangles;
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-10-01 15:49:36 +00:00
|
|
|
return dispLists;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter )
|
2020-10-01 15:49:36 +00:00
|
|
|
{
|
|
|
|
m_reloadRequested = false;
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
freeAllLists();
|
2020-10-01 15:49:36 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
OBJECT_2D_STATS::Instance().ResetStats();
|
2020-10-01 15:49:36 +00:00
|
|
|
|
|
|
|
unsigned stats_startReloadTime = GetRunningMicroSecs();
|
|
|
|
|
|
|
|
m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter();
|
2020-10-01 15:49:36 +00:00
|
|
|
m_camera.SetBoardLookAtPos( camera_pos );
|
|
|
|
|
|
|
|
if( aStatusReporter )
|
|
|
|
aStatusReporter->Report( _( "Load OpenGL: board" ) );
|
|
|
|
|
|
|
|
// Create Board
|
2021-01-05 22:19:00 +00:00
|
|
|
m_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetThroughHoleIds() );
|
2020-10-01 15:49:36 +00:00
|
|
|
|
2020-11-07 16:19:42 +00:00
|
|
|
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
|
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
m_antiBoardPolys.RemoveAllContours();
|
|
|
|
m_antiBoardPolys.NewOutline();
|
|
|
|
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
|
|
|
|
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
|
|
|
|
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
|
|
|
|
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
|
|
|
|
m_antiBoardPolys.Outline( 0 ).SetClosed( true );
|
|
|
|
|
|
|
|
m_antiBoardPolys.BooleanSubtract( m_boardAdapter.GetBoardPoly(),
|
|
|
|
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
|
|
|
m_antiBoard = createBoard( m_antiBoardPolys );
|
2020-11-07 16:19:42 +00:00
|
|
|
}
|
2020-11-03 09:38:07 +00:00
|
|
|
|
|
|
|
SHAPE_POLY_SET board_poly_with_holes = m_boardAdapter.GetBoardPoly();
|
2021-01-05 22:19:00 +00:00
|
|
|
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
2020-11-30 01:07:49 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2021-01-05 22:19:00 +00:00
|
|
|
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
2020-11-30 01:07:49 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2020-10-01 15:49:36 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardWithHoles = createBoard( board_poly_with_holes );
|
2020-10-06 10:38:08 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
if( m_antiBoard )
|
|
|
|
m_antiBoard->SetItIsTransparent( true );
|
2020-10-01 15:49:36 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Create Through Holes and vias
|
2020-06-03 23:00:40 +00:00
|
|
|
if( aStatusReporter )
|
|
|
|
aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetThroughHoleOdPolys();
|
2020-11-07 16:19:42 +00:00
|
|
|
|
|
|
|
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
|
2020-12-13 23:02:57 +00:00
|
|
|
outerPolyTHT.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
|
|
|
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
m_outerThroughHoles = generateHoles( m_boardAdapter.GetThroughHoleOds().GetList(),
|
|
|
|
outerPolyTHT, 1.0f, 0.0f, false,
|
|
|
|
&m_boardAdapter.GetThroughHoleIds() );
|
|
|
|
|
|
|
|
m_outerViaThroughHoles = generateHoles(
|
|
|
|
m_boardAdapter.GetThroughHoleViaOds().GetList(),
|
|
|
|
m_boardAdapter.GetThroughHoleViaOdPolys(), 1.0f, 0.0f, false );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-11-07 16:19:42 +00:00
|
|
|
if( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) &&
|
|
|
|
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
|
2020-07-16 22:36:06 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
m_outerThroughHoleRings = generateHoles(
|
|
|
|
m_boardAdapter.GetThroughHoleAnnularRings().GetList(),
|
|
|
|
m_boardAdapter.GetThroughHoleAnnularRingPolys(), 1.0f, 0.0f, false );
|
2020-07-16 22:36:06 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const MAP_POLY& innerMapHoles = m_boardAdapter.GetHoleIdPolysMap();
|
|
|
|
const MAP_POLY& outerMapHoles = m_boardAdapter.GetHoleOdPolysMap();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const MAP_CONTAINER_2D_BASE& map_holes = m_boardAdapter.GetLayerHoleMap();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( outerMapHoles.size() > 0 )
|
|
|
|
{
|
|
|
|
float layer_z_bot = 0.0f;
|
|
|
|
float layer_z_top = 0.0f;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const auto ii : outerMapHoles )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const PCB_LAYER_ID layer_id = ii.first;
|
|
|
|
const SHAPE_POLY_SET* poly = ii.second;
|
2021-01-02 21:05:29 +00:00
|
|
|
const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
getLayerZPos( layer_id, layer_z_top, layer_z_bot );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
m_outerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
|
|
|
|
layer_z_top, layer_z_bot, false );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const auto ii : innerMapHoles )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const PCB_LAYER_ID layer_id = ii.first;
|
|
|
|
const SHAPE_POLY_SET* poly = ii.second;
|
2021-01-02 21:05:29 +00:00
|
|
|
const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
getLayerZPos( layer_id, layer_z_top, layer_z_bot );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
m_innerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
|
|
|
|
layer_z_top, layer_z_bot, false );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Generate vertical cylinders of vias and pads (copper)
|
2021-01-05 22:19:00 +00:00
|
|
|
generateViasAndPads();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Add layers maps
|
2020-06-03 23:00:40 +00:00
|
|
|
if( aStatusReporter )
|
|
|
|
aStatusReporter->Report( _( "Load OpenGL: layers" ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
|
2020-09-06 19:09:43 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const auto ii : m_boardAdapter.GetLayerMap() )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const PCB_LAYER_ID layer_id = ii.first;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
if( !m_boardAdapter.Is3dLayerEnabled( layer_id ) )
|
2015-12-08 07:31:57 +00:00
|
|
|
continue;
|
|
|
|
|
2021-07-22 14:13:27 +00:00
|
|
|
if( aStatusReporter )
|
|
|
|
aStatusReporter->Report( wxString::Format(
|
|
|
|
_( "Load OpenGL layer %d" ), (int)layer_id ) );
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
const BVH_CONTAINER_2D* container2d = ii.second;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-11-03 09:38:07 +00:00
|
|
|
SHAPE_POLY_SET polyListSubtracted;
|
2021-01-02 21:05:29 +00:00
|
|
|
SHAPE_POLY_SET* aPolyList = nullptr;
|
2020-11-03 09:38:07 +00:00
|
|
|
|
2020-11-15 14:53:12 +00:00
|
|
|
// Load the vertical (Z axis) component of shapes
|
|
|
|
|
|
|
|
if( map_poly.find( layer_id ) != map_poly.end() )
|
2020-11-03 09:38:07 +00:00
|
|
|
{
|
2020-11-15 14:53:12 +00:00
|
|
|
polyListSubtracted = *map_poly.at( layer_id );;
|
2020-11-04 09:36:41 +00:00
|
|
|
|
2020-11-15 14:53:12 +00:00
|
|
|
if( ( layer_id != B_Paste ) && ( layer_id != F_Paste ) &&
|
|
|
|
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
|
2020-11-04 09:36:41 +00:00
|
|
|
{
|
2020-12-13 23:02:57 +00:00
|
|
|
polyListSubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2020-11-15 14:53:12 +00:00
|
|
|
|
|
|
|
if( ( layer_id != B_Mask ) && ( layer_id != F_Mask ) )
|
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
2020-11-30 01:07:49 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2020-12-13 23:02:57 +00:00
|
|
|
polyListSubtracted.BooleanSubtract(
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
2020-12-13 23:02:57 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2020-11-15 14:53:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK ) )
|
|
|
|
{
|
2020-11-30 01:07:49 +00:00
|
|
|
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 );
|
|
|
|
}
|
2020-11-15 14:53:12 +00:00
|
|
|
}
|
2020-11-04 09:36:41 +00:00
|
|
|
}
|
|
|
|
|
2020-11-15 14:53:12 +00:00
|
|
|
aPolyList = &polyListSubtracted;
|
2020-11-03 09:38:07 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, aPolyList, layer_id,
|
|
|
|
&m_boardAdapter.GetThroughHoleIds() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-09-06 19:09:43 +00:00
|
|
|
if( oglList != nullptr )
|
2020-11-30 01:07:49 +00:00
|
|
|
m_layers[layer_id] = oglList;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-11-07 16:19:42 +00:00
|
|
|
if( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
|
|
|
|
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
|
2020-09-27 09:28:05 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
if( m_boardAdapter.GetFrontPlatedPadPolys() )
|
2020-11-03 10:43:52 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetFrontPlatedPadPolys();
|
2020-11-30 01:07:49 +00:00
|
|
|
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2021-01-05 22:19:00 +00:00
|
|
|
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
2020-11-30 01:07:49 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2021-01-05 22:19:00 +00:00
|
|
|
polySubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
2020-11-30 01:07:49 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(),
|
|
|
|
&polySubtracted, F_Cu );
|
2020-11-03 10:43:52 +00:00
|
|
|
}
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
if( m_boardAdapter.GetBackPlatedPadPolys() )
|
2020-11-03 10:43:52 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetBackPlatedPadPolys();
|
2020-11-30 01:07:49 +00:00
|
|
|
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
|
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2021-01-05 22:19:00 +00:00
|
|
|
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
|
2020-11-30 01:07:49 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
2021-01-05 22:19:00 +00:00
|
|
|
polySubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
|
2020-11-30 01:07:49 +00:00
|
|
|
SHAPE_POLY_SET::PM_FAST );
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
m_platedPadsBack = generateLayerList( m_boardAdapter.GetPlatedPadsBack(),
|
|
|
|
&polySubtracted, B_Cu );
|
2020-11-03 10:43:52 +00:00
|
|
|
}
|
2020-09-27 09:28:05 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Load 3D models
|
2020-06-03 23:00:40 +00:00
|
|
|
if( aStatusReporter )
|
2021-06-26 11:33:37 +00:00
|
|
|
aStatusReporter->Report( _( "Loading 3D models..." ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
load3dModels( aStatusReporter );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-06-03 23:00:40 +00:00
|
|
|
if( aStatusReporter )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
// Calculation time in seconds
|
|
|
|
const double calculation_time = (double)( GetRunningMicroSecs() -
|
|
|
|
stats_startReloadTime) / 1e6;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-06-03 23:00:40 +00:00
|
|
|
aStatusReporter->Report( wxString::Format( _( "Reload time %.3f s" ), calculation_time ) );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::addTopAndBottomTriangles( TRIANGLE_DISPLAY_LIST* aDst, const SFVEC2F& v0,
|
|
|
|
const SFVEC2F& v1, const SFVEC2F& v2,
|
|
|
|
float top, float bot )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
|
|
|
|
SFVEC3F( v1.x, v1.y, bot ),
|
|
|
|
SFVEC3F( v2.x, v2.y, bot ) );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
aDst->m_layer_top_triangles->AddTriangle( SFVEC3F( v2.x, v2.y, top ),
|
|
|
|
SFVEC3F( v1.x, v1.y, top ),
|
|
|
|
SFVEC3F( v0.x, v0.y, top ) );
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::getLayerZPos( PCB_LAYER_ID aLayerID, float& aOutZtop,
|
|
|
|
float& aOutZbot ) const
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
aOutZbot = m_boardAdapter.GetLayerBottomZPos( aLayerID );
|
|
|
|
aOutZtop = m_boardAdapter.GetLayerTopZPos( aLayerID );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( aOutZtop < aOutZbot )
|
|
|
|
{
|
|
|
|
float tmpFloat = aOutZbot;
|
|
|
|
aOutZbot = aOutZtop;
|
|
|
|
aOutZtop = tmpFloat;
|
|
|
|
}
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::generateCylinder( const SFVEC2F& aCenter, float aInnerRadius,
|
|
|
|
float aOuterRadius, float aZtop, float aZbot,
|
|
|
|
unsigned int aNr_sides_per_circle,
|
|
|
|
TRIANGLE_DISPLAY_LIST* aDstLayer )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
std::vector< SFVEC2F > innerContour;
|
|
|
|
std::vector< SFVEC2F > outerContour;
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
generateRing( aCenter, aInnerRadius, aOuterRadius, aNr_sides_per_circle, innerContour,
|
|
|
|
outerContour, false );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
|
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& vi0 = innerContour[i + 0];
|
|
|
|
const SFVEC2F& vi1 = innerContour[i + 1];
|
|
|
|
const SFVEC2F& vo0 = outerContour[i + 0];
|
|
|
|
const SFVEC2F& vo1 = outerContour[i + 1];
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
aDstLayer->m_layer_top_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZtop ),
|
|
|
|
SFVEC3F( vi0.x, vi0.y, aZtop ),
|
|
|
|
SFVEC3F( vo0.x, vo0.y, aZtop ),
|
|
|
|
SFVEC3F( vo1.x, vo1.y, aZtop ) );
|
|
|
|
|
|
|
|
aDstLayer->m_layer_bot_triangles->AddQuad( SFVEC3F( vi1.x, vi1.y, aZbot ),
|
|
|
|
SFVEC3F( vo1.x, vo1.y, aZbot ),
|
|
|
|
SFVEC3F( vo0.x, vo0.y, aZbot ),
|
|
|
|
SFVEC3F( vi0.x, vi0.y, aZbot ) );
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true );
|
|
|
|
aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false );
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::generateViasAndPads()
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-07-18 15:44:54 +00:00
|
|
|
if( !m_boardAdapter.GetBoard() )
|
|
|
|
return;
|
|
|
|
|
2021-04-18 20:17:31 +00:00
|
|
|
const int platingThickness = m_boardAdapter.GetHolePlatingThickness();
|
|
|
|
const float platingThickness3d = platingThickness * m_boardAdapter.BiuTo3dUnits();
|
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
if( m_boardAdapter.GetViaCount() > 0 )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
const unsigned int reserve_nr_triangles_estimation =
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.GetCircleSegmentCount(
|
|
|
|
m_boardAdapter.GetAverageViaHoleDiameter() ) * 8 *
|
|
|
|
m_boardAdapter.GetViaCount();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST* layerTriangleVIA =
|
|
|
|
new TRIANGLE_DISPLAY_LIST( reserve_nr_triangles_estimation );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Insert plated vertical holes inside the board
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Insert vias holes (vertical cylinders)
|
2021-06-11 21:07:02 +00:00
|
|
|
for( const PCB_TRACK* track : m_boardAdapter.GetBoard()->Tracks() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
if( track->Type() == PCB_VIA_T )
|
|
|
|
{
|
2021-06-11 21:07:02 +00:00
|
|
|
const PCB_VIA* via = static_cast<const PCB_VIA*>( track );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits();
|
|
|
|
const int nrSegments = m_boardAdapter.GetCircleSegmentCount( via->GetDrillValue() );
|
2020-12-13 23:02:57 +00:00
|
|
|
const float hole_inner_radius = holediameter / 2.0f;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
|
|
|
|
-via->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID top_layer, bottom_layer;
|
2016-07-19 17:35:25 +00:00
|
|
|
via->LayerPair( &top_layer, &bottom_layer );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
float ztop, zbot, dummy;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
getLayerZPos( top_layer, ztop, dummy );
|
|
|
|
getLayerZPos( bottom_layer, dummy, zbot );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
wxASSERT( zbot < ztop );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-04-18 20:17:31 +00:00
|
|
|
generateCylinder( via_center, hole_inner_radius,
|
|
|
|
hole_inner_radius + platingThickness3d,
|
2021-01-05 22:19:00 +00:00
|
|
|
ztop, zbot, nrSegments, layerTriangleVIA );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
m_vias = new OPENGL_RENDER_LIST( *layerTriangleVIA, 0, 0.0f, 0.0f );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
delete layerTriangleVIA;
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
if( m_boardAdapter.GetHoleCount() > 0 )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
|
|
|
|
SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
tht_outer_holes_poly.RemoveAllContours();
|
|
|
|
tht_inner_holes_poly.RemoveAllContours();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Insert pads holes (vertical cylinders)
|
2020-11-13 15:15:52 +00:00
|
|
|
for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const PAD* pad : footprint->Pads() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-05-01 14:46:50 +00:00
|
|
|
if( pad->GetAttribute() != PAD_ATTRIB::NPTH )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
const wxSize drillsize = pad->GetDrillSize();
|
|
|
|
const bool hasHole = drillsize.x && drillsize.y;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( !hasHole )
|
|
|
|
continue;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2020-06-22 19:35:09 +00:00
|
|
|
pad->TransformHoleWithClearanceToPolygon( tht_outer_holes_poly,
|
2021-04-18 20:17:31 +00:00
|
|
|
platingThickness,
|
|
|
|
ARC_HIGH_DEF, ERROR_INSIDE );
|
2020-10-13 10:55:24 +00:00
|
|
|
pad->TransformHoleWithClearanceToPolygon( tht_inner_holes_poly, 0,
|
2021-04-18 20:17:31 +00:00
|
|
|
ARC_HIGH_DEF, ERROR_INSIDE );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Subtract the holes
|
|
|
|
tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
|
2020-11-07 16:19:42 +00:00
|
|
|
|
|
|
|
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
|
2021-01-05 22:19:00 +00:00
|
|
|
tht_outer_holes_poly.BooleanSubtract( m_antiBoardPolys, SHAPE_POLY_SET::PM_FAST );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
CONTAINER_2D holesContainer;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
ConvertPolygonToTriangles( tht_outer_holes_poly, holesContainer,
|
|
|
|
m_boardAdapter.BiuTo3dUnits(),
|
|
|
|
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const LIST_OBJECT2D& listHolesObject2d = holesContainer.GetList();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( listHolesObject2d.size() > 0 )
|
|
|
|
{
|
|
|
|
float layer_z_top, layer_z_bot, dummy;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
getLayerZPos( F_Cu, layer_z_top, dummy );
|
|
|
|
getLayerZPos( B_Cu, dummy, layer_z_bot );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
TRIANGLE_DISPLAY_LIST* layerTriangles =
|
|
|
|
new TRIANGLE_DISPLAY_LIST( listHolesObject2d.size() );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
// Convert the list of objects(triangles) to triangle layer structure
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const OBJECT_2D* itemOnLayer : listHolesObject2d )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-03-06 09:27:41 +00:00
|
|
|
const OBJECT_2D* object2d_A = itemOnLayer;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
wxASSERT( object2d_A->GetObjectType() == OBJECT_2D_TYPE::TRIANGLE );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-03-06 09:27:41 +00:00
|
|
|
const TRIANGLE_2D* tri = static_cast<const TRIANGLE_2D*>( object2d_A );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC2F& v1 = tri->GetP1();
|
|
|
|
const SFVEC2F& v2 = tri->GetP2();
|
|
|
|
const SFVEC2F& v3 = tri->GetP3();
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
if( tht_outer_holes_poly.OutlineCount() > 0 )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
|
2019-02-02 16:59:53 +00:00
|
|
|
layer_z_bot, layer_z_top,
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.BiuTo3dUnits(), false );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
m_padHoles = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
|
|
|
|
layer_z_top, layer_z_top );
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
delete layerTriangles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
|
2021-08-16 14:28:46 +00:00
|
|
|
void RENDER_3D_LEGACY::Load3dModelsIfNeeded()
|
|
|
|
{
|
|
|
|
if( m_3dModelMap.size() > 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxFrame* frame = dynamic_cast<EDA_3D_VIEWER_FRAME*>( m_canvas->GetParent() );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
{
|
|
|
|
STATUSBAR_REPORTER activityReporter( frame->GetStatusBar(),
|
|
|
|
(int) EDA_3D_VIEWER_STATUSBAR::ACTIVITY );
|
|
|
|
load3dModels( &activityReporter );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
load3dModels( nullptr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-01-05 22:19:00 +00:00
|
|
|
void RENDER_3D_LEGACY::load3dModels( REPORTER* aStatusReporter )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2021-07-18 15:44:54 +00:00
|
|
|
if( !m_boardAdapter.GetBoard() )
|
|
|
|
return;
|
|
|
|
|
2020-11-12 23:50:33 +00:00
|
|
|
if( !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL )
|
2020-12-13 23:02:57 +00:00
|
|
|
&& !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL_INSERT )
|
|
|
|
&& !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_VIRTUAL ) )
|
2020-11-12 23:50:33 +00:00
|
|
|
{
|
2016-07-19 17:35:25 +00:00
|
|
|
return;
|
2020-11-12 23:50:33 +00:00
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-10-21 03:48:06 +00:00
|
|
|
// Go for all footprints
|
2021-03-06 09:27:41 +00:00
|
|
|
for( const FOOTPRINT* footprint : m_boardAdapter.GetBoard()->Footprints() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-11-13 00:43:45 +00:00
|
|
|
for( const FP_3DMODEL& model : footprint->Models() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-09-08 19:41:43 +00:00
|
|
|
if( model.m_Show && !model.m_Filename.empty() )
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
2020-09-08 19:41:43 +00:00
|
|
|
if( aStatusReporter )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2020-09-08 19:41:43 +00:00
|
|
|
// Display the short filename of the 3D model loaded:
|
|
|
|
// (the full name is usually too long to be displayed)
|
|
|
|
wxFileName fn( model.m_Filename );
|
2021-06-26 11:33:37 +00:00
|
|
|
aStatusReporter->Report( wxString::Format( _( "Loading %s..." ),
|
|
|
|
fn.GetFullName() ) );
|
2020-09-08 19:41:43 +00:00
|
|
|
}
|
2018-05-08 14:07:09 +00:00
|
|
|
|
2020-09-08 19:41:43 +00:00
|
|
|
// Check if the model is not present in our cache map
|
|
|
|
// (Not already loaded in memory)
|
2021-01-05 22:19:00 +00:00
|
|
|
if( m_3dModelMap.find( model.m_Filename ) == m_3dModelMap.end() )
|
2020-09-08 19:41:43 +00:00
|
|
|
{
|
|
|
|
// It is not present, try get it from cache
|
|
|
|
const S3DMODEL* modelPtr =
|
2021-01-05 22:19:00 +00:00
|
|
|
m_boardAdapter.Get3dCacheManager()->GetModel( model.m_Filename );
|
2020-09-08 19:41:43 +00:00
|
|
|
|
|
|
|
// only add it if the return is not NULL
|
|
|
|
if( modelPtr )
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2021-01-05 22:19:00 +00:00
|
|
|
MATERIAL_MODE materialMode = m_boardAdapter.GetMaterialMode();
|
2021-01-02 21:05:29 +00:00
|
|
|
MODEL_3D* ogl_model = new MODEL_3D( *modelPtr, materialMode );
|
2020-09-08 19:41:43 +00:00
|
|
|
|
|
|
|
if( ogl_model )
|
2021-01-05 22:19:00 +00:00
|
|
|
m_3dModelMap[ model.m_Filename ] = ogl_model;
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-19 17:35:25 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
}
|