Commit d9c76c0d authored by unknown's avatar unknown Committed by jean-pierre charras
Browse files

3D viewer bug fixes

parent 7b936f4d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ void CheckGLError(const char *aFileName, int aLineNumber)

        errLast = err;
        
        wxLogError( wxT( "OpenGL error %d\nAt: %s, line: %d" ), err, aFileName, aLineNumber );
        wxLogError( wxT( "OpenGL error %d At: %s, line: %d" ), err,  GetChars( FROM_UTF8( aFileName ) ), aLineNumber );
    }
}

+0 −1
Original line number Diff line number Diff line
@@ -531,7 +531,6 @@ void EDA_3D_CANVAS::Redraw()
            glBindTexture( GL_TEXTURE_2D, m_text_fake_shadow_back );
            glCallList( m_glLists[GL_ID_SHADOW_BACK] );
        }

        glColor4f( 1.0, 1.0, 1.0, 1.0 );

        glEnable( GL_DEPTH_TEST );
+9 −1
Original line number Diff line number Diff line
@@ -172,9 +172,11 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
    // Draw solid areas contained in this list
    CPOLYGONS_LIST polylist = aPolysList;    // temporary copy for gluTessVertex

    int startContour;

    for( int side = 0; side < 2; side++ )
    {
        int startContour = 1;
        startContour = 1;

        for( unsigned ii = 0; ii < polylist.GetCornersCount(); ii++ )
        {
@@ -217,6 +219,12 @@ void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList,
        SetNormalZneg();
    }

    if( startContour == 0 )
    {
        gluTessEndContour( tess );
        gluTessEndPolygon( tess );
    }

    gluDeleteTess( tess );

    if( aThickness == 0 )
+19 −11
Original line number Diff line number Diff line
@@ -211,8 +211,11 @@ void S3D_MESH::calcPointNormalized ()
        p = m_Point[i] * biggerPoint;
        m_PointNormalized.push_back( p );
    }

    //DBG( printf("m_Point.size %u\n", m_Point.size()) );
}


bool IsClockwise( glm::vec3 v0, glm::vec3 v1, glm::vec3 v2 )
{
    double sum = 0.0;
@@ -253,6 +256,9 @@ void S3D_MESH::calcPerFaceNormals ()
    m_PerFaceNormalsRaw.clear();
    m_PerFaceSquaredArea.clear();

    //DBG( printf("m_CoordIndex.size %u\n", m_CoordIndex.size()) );
    //DBG( printf("m_PointNormalized.size %u\n", m_PointNormalized.size()) );
    
    for( unsigned int idx = 0; idx < m_CoordIndex.size(); idx++ )
    {

@@ -363,17 +369,19 @@ void S3D_MESH::calcPerPointNormals ()
        {
            face_A_normals[each_vert_A_idx] = m_PerFaceNormalsRaw[each_face_A_idx] * (m_PerFaceSquaredArea[each_face_A_idx]);

            // for each face A in mesh
            int vertexIndex = (int)(m_CoordIndex[each_face_A_idx][each_vert_A_idx]);
            glm::vec3 vector_face_A = m_PerFaceNormalsNormalized[each_face_A_idx];

            // for each face B in mesh
            for( unsigned int each_face_B_idx = 0; each_face_B_idx < m_CoordIndex.size(); each_face_B_idx++ )
            {
                //if A != B { // ignore self
                if ( each_face_A_idx != each_face_B_idx)
                {
                    if( (m_CoordIndex[each_face_B_idx][0] == (int)(m_CoordIndex[each_face_A_idx][each_vert_A_idx])) ||
                        (m_CoordIndex[each_face_B_idx][1] == (int)(m_CoordIndex[each_face_A_idx][each_vert_A_idx])) ||
                        (m_CoordIndex[each_face_B_idx][2] == (int)(m_CoordIndex[each_face_A_idx][each_vert_A_idx])) )
                    if( (m_CoordIndex[each_face_B_idx][0] == vertexIndex) ||
                        (m_CoordIndex[each_face_B_idx][1] == vertexIndex) ||
                        (m_CoordIndex[each_face_B_idx][2] == vertexIndex) )
                    {
                        glm::vec3 vector_face_A = m_PerFaceNormalsNormalized[each_face_A_idx];
                        glm::vec3 vector_face_B = m_PerFaceNormalsNormalized[each_face_B_idx];

                        float dot_prod = glm::dot(vector_face_A, vector_face_B);
+8 −9
Original line number Diff line number Diff line
@@ -80,7 +80,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename )

#define SCALE_3D_CONV ((IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB)

    //glPushMatrix();
    glTranslatef( matPos.x * SCALE_3D_CONV, matPos.y * SCALE_3D_CONV, matPos.z * SCALE_3D_CONV );

    glRotatef(-matRot.z, 0.0f, 0.0f, 1.0f );
@@ -140,7 +139,7 @@ int VRML2_MODEL_PARSER::read_Transform()
{
    char       text[128];

    ///DBG( printf( "Transform\n" ) ); 
    //DBG( printf( "Transform\n" ) ); 

    while( GetNextTag( m_file, text ) )
    {
@@ -204,7 +203,7 @@ int VRML2_MODEL_PARSER::read_Transform()
            read_DEF();
        } else
        {
            //DBG( printf( "    %s NotImplemented\n", text ) );
            DBG( printf( "    %s NotImplemented\n", text ) );
            read_NotImplemented( m_file, '}' );
        }
    }
@@ -264,7 +263,7 @@ int VRML2_MODEL_PARSER::read_DEF()
        }
    }

    //DBG( printf( "  DEF failed\n" ) );
    DBG( printf( "  DEF failed\n" ) );
    return -1;
}

@@ -302,12 +301,12 @@ int VRML2_MODEL_PARSER::read_Shape()
            read_IndexedFaceSet();
        } else
        {
            //DBG( printf( "    %s NotImplemented\n", text ) );
            DBG( printf( "    %s NotImplemented\n", text ) );
            read_NotImplemented( m_file, '}' );
        }
    }

    //DBG( printf( "  Shape failed\n") );
    DBG( printf( "  Shape failed\n") );
    return -1;
}

@@ -336,7 +335,7 @@ int VRML2_MODEL_PARSER::read_Appearance()
        }
    }

    //DBG( printf( "  Appearance failed\n") );
    DBG( printf( "  Appearance failed\n") );
    return -1;
}

@@ -407,12 +406,12 @@ int VRML2_MODEL_PARSER::read_material()
                        return 0;
                    }
                }
                //DBG( printf( "   read_material error: material not found\n" ) );
                DBG( printf( "   read_material error: material not found\n" ) );
            }
        }
    }

    //DBG( printf( "  failed material\n") );
    DBG( printf( "  failed material\n") );
    return -1;
}

Loading