3D viewer: Fix bug #1509506: Crash with MeshLab reduced 3D model.

This commit is contained in:
unknown 2015-10-25 19:51:41 +01:00 committed by jean-pierre charras
parent ade51289a7
commit c721c21bdf
2 changed files with 12 additions and 1 deletions

View File

@ -333,6 +333,10 @@ void S3D_MESH::openGL_Render( bool aIsRenderingJustNonTransparentObjects,
#endif
*/
if( m_Materials->m_ColorPerVertex == false )
if( m_Materials->m_DiffuseColor.size() == m_Point.size() )
m_Materials->m_ColorPerVertex = true;
for( unsigned int idx = 0; idx < m_CoordIndex.size(); idx++ )
{
if( m_Materials )

View File

@ -1314,7 +1314,8 @@ int VRML2_MODEL_PARSER::read_Material()
if( strcmp( text, "diffuseColor" ) == 0 )
{
ParseVertex( m_file, vertex );
m_model->m_Materials->m_DiffuseColor.push_back( vertex );
if( m_model->m_Materials->m_DiffuseColor.empty() )
m_model->m_Materials->m_DiffuseColor.push_back( vertex );
}
else if( strcmp( text, "emissiveColor" ) == 0 )
{
@ -1640,6 +1641,12 @@ int VRML2_MODEL_PARSER::read_Color()
if( strcmp( text, "color" ) == 0 )
{
if( m_model->m_Materials == NULL )
{
m_model->m_Materials = new S3D_MATERIAL( m_Master, "" );
m_Master->Insert( m_model->m_Materials );
}
m_model->m_Materials->m_DiffuseColor.clear();
ParseVertexList( m_file, m_model->m_Materials->m_DiffuseColor );
}