From ffc7740cc270f4edf0bb80f4f9c7afd69664a54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Luzeiro?= Date: Wed, 6 Apr 2016 21:48:51 -0400 Subject: [PATCH] 3D: fix bounding box assert and include order --- 3d-viewer/3d_draw.cpp | 5 +++-- 3d-viewer/3d_mesh_model.cpp | 16 ++-------------- 3d-viewer/3d_read_mesh.cpp | 8 +------- 3d-viewer/3d_viewer.h | 2 +- 3d-viewer/info3d_visu.h | 2 -- 5 files changed, 7 insertions(+), 26 deletions(-) diff --git a/3d-viewer/3d_draw.cpp b/3d-viewer/3d_draw.cpp index 32c5179353..1799dbcc4d 100644 --- a/3d-viewer/3d_draw.cpp +++ b/3d-viewer/3d_draw.cpp @@ -1129,14 +1129,15 @@ void EDA_3D_CANVAS::render3DComponentShape( MODULE* module, shape3D->Render( aIsRenderingJustNonTransparentObjects, aIsRenderingJustTransparentObjects ); - if( isEnabled( FL_RENDER_SHOW_MODEL_BBOX ) ) + const CBBOX &shapeBBox = shape3D->getBBox(); + if( isEnabled( FL_RENDER_SHOW_MODEL_BBOX ) && shapeBBox.IsInitialized() ) { // Set the alpha current color to opaque float currentColor[4]; glGetFloatv( GL_CURRENT_COLOR,currentColor ); currentColor[3] = 1.0f; glColor4fv( currentColor ); - OGL_draw_bbox( shape3D->getBBox() ); + OGL_draw_bbox( shapeBBox ); } glPopMatrix(); diff --git a/3d-viewer/3d_mesh_model.cpp b/3d-viewer/3d_mesh_model.cpp index 04dcdbb4a4..914d4a4f5a 100644 --- a/3d-viewer/3d_mesh_model.cpp +++ b/3d-viewer/3d_mesh_model.cpp @@ -112,24 +112,12 @@ void S3D_MESH::calcBBoxAllChilds( ) void S3D_MESH::calcBBox( ) { - CBBOX tmpBBox; - - bool firstBBox = true; + m_BBox.Reset(); // Calc boudingbox for all coords for( unsigned int idx = 0; idx < m_CoordIndex.size(); idx++ ) - { for( unsigned int ii = 0; ii < m_CoordIndex[idx].size(); ii++ ) - if( firstBBox ) - { - firstBBox = false; - tmpBBox = CBBOX( m_Point[m_CoordIndex[idx][ii]] ); // Initialize with the first vertex found - } - else - tmpBBox.Union( m_Point[m_CoordIndex[idx][ii]] ); - } - - m_BBox = tmpBBox; + m_BBox.Union( m_Point[m_CoordIndex[idx][ii]] ); } diff --git a/3d-viewer/3d_read_mesh.cpp b/3d-viewer/3d_read_mesh.cpp index af269ce979..d99b42148e 100644 --- a/3d-viewer/3d_read_mesh.cpp +++ b/3d-viewer/3d_read_mesh.cpp @@ -139,15 +139,9 @@ void S3D_MASTER::calcBBox() if( m_parser == NULL ) return; - bool firstBBox = true; + m_BBox.Reset(); for( unsigned int idx = 0; idx < m_parser->childs.size(); idx++ ) - if( firstBBox ) - { - firstBBox = false; - m_BBox = m_parser->childs[idx]->getBBox(); - } - else m_BBox.Union( m_parser->childs[idx]->getBBox() ); // Calc transformation matrix to apply in AABBox diff --git a/3d-viewer/3d_viewer.h b/3d-viewer/3d_viewer.h index 3412288d35..7898fe0ce9 100644 --- a/3d-viewer/3d_viewer.h +++ b/3d-viewer/3d_viewer.h @@ -36,9 +36,9 @@ #error Please build wxWidgets with Opengl support (./configure --with-opengl) #endif -#include #include <3d_struct.h> #include +#include /// A variable name whose value holds the path of 3D shape files. /// Currently an environment variable, eventually a project variable. diff --git a/3d-viewer/info3d_visu.h b/3d-viewer/info3d_visu.h index 7326a0408b..49258e9035 100644 --- a/3d-viewer/info3d_visu.h +++ b/3d-viewer/info3d_visu.h @@ -32,8 +32,6 @@ #include // Layers id definitions -#include - #ifdef __WXMAC__ # ifdef __DARWIN__ # include