Simplify highlighting logic.
Fixes https://gitlab.com/kicad/code/kicad/issues/8410
This commit is contained in:
parent
69509c9dd1
commit
7e8f2cdb94
|
@ -419,10 +419,9 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
|
|||
reinterpret_cast<const void*>( offsetof( VERTEX, m_nrm ) ) );
|
||||
|
||||
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VERTEX ),
|
||||
reinterpret_cast<const void*>(
|
||||
m_materialMode == MATERIAL_MODE::CAD_MODE
|
||||
? offsetof( VERTEX, m_cad_color )
|
||||
: offsetof( VERTEX, m_color ) ) );
|
||||
reinterpret_cast<const void*>( m_materialMode == MATERIAL_MODE::CAD_MODE
|
||||
? offsetof( VERTEX, m_cad_color )
|
||||
: offsetof( VERTEX, m_color ) ) );
|
||||
|
||||
glTexCoordPointer( 2, GL_FLOAT, sizeof( VERTEX ),
|
||||
reinterpret_cast<const void*>( offsetof( VERTEX, m_tex_uv ) ) );
|
||||
|
@ -448,11 +447,12 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
|
|||
break;
|
||||
|
||||
case MATERIAL_MODE::DIFFUSE_ONLY:
|
||||
OglSetDiffuseMaterial( mat.m_Diffuse, aOpacity );
|
||||
OglSetDiffuseMaterial( mat.m_Diffuse, aOpacity, aUseSelectedMaterial, aSelectionColor );
|
||||
break;
|
||||
|
||||
case MATERIAL_MODE::CAD_MODE:
|
||||
OglSetDiffuseMaterial( MaterialDiffuseToColorCAD( mat.m_Diffuse ), aOpacity );
|
||||
OglSetDiffuseMaterial( MaterialDiffuseToColorCAD( mat.m_Diffuse ), aOpacity,
|
||||
aUseSelectedMaterial, aSelectionColor );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -511,8 +511,8 @@ void MODEL_3D::DrawBboxes() const
|
|||
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VERTEX ),
|
||||
reinterpret_cast<const void*>( offsetof( VERTEX, m_color ) ) );
|
||||
|
||||
unsigned int idx_size = m_bbox_index_buffer_type == GL_UNSIGNED_SHORT
|
||||
? sizeof( GLushort ) : sizeof( GLuint );
|
||||
unsigned int idx_size = m_bbox_index_buffer_type == GL_UNSIGNED_SHORT ? sizeof( GLushort )
|
||||
: sizeof( GLuint );
|
||||
|
||||
glDrawElements( GL_LINES, bbox_idx_count * m_meshes_bbox.size(), m_bbox_index_buffer_type,
|
||||
reinterpret_cast<const void*>(
|
||||
|
|
|
@ -1186,49 +1186,28 @@ void RENDER_3D_LEGACY::render3dModelsSelected( bool aRenderTopOrBot, bool aRende
|
|||
// Go for all footprints
|
||||
for( FOOTPRINT* fp : m_boardAdapter.GetBoard()->Footprints() )
|
||||
{
|
||||
const bool isIntersected = fp == m_currentRollOverItem;
|
||||
bool highlight = false;
|
||||
|
||||
if( m_boardAdapter.GetFlag( FL_USE_SELECTION ) )
|
||||
{
|
||||
if( isIntersected )
|
||||
{
|
||||
if( aRenderSelectedOnly )
|
||||
highlight = m_boardAdapter.GetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM );
|
||||
}
|
||||
else if( ( aRenderSelectedOnly && !fp->IsSelected() )
|
||||
|| ( !aRenderSelectedOnly && fp->IsSelected() ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( fp->IsSelected() )
|
||||
highlight = true;
|
||||
|
||||
if( highlight )
|
||||
{
|
||||
glEnable( GL_POLYGON_OFFSET_LINE );
|
||||
glPolygonOffset( 8.0, 1.0 );
|
||||
glPolygonMode( GL_FRONT, GL_LINE );
|
||||
glLineWidth( 6 );
|
||||
if( m_boardAdapter.GetFlag( FL_HIGHLIGHT_ROLLOVER_ITEM ) && fp == m_currentRollOverItem )
|
||||
highlight = true;
|
||||
|
||||
if( aRenderSelectedOnly != highlight )
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !fp->Models().empty() )
|
||||
{
|
||||
if( m_boardAdapter.IsFootprintShown( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
|
||||
{
|
||||
if( ( aRenderTopOrBot && !fp->IsFlipped() )
|
||||
|| ( !aRenderTopOrBot && fp->IsFlipped() ) )
|
||||
{
|
||||
renderFootprint( fp, aRenderTransparentOnly, isIntersected );
|
||||
}
|
||||
if( aRenderTopOrBot == !fp->IsFlipped() )
|
||||
renderFootprint( fp, aRenderTransparentOnly, highlight );
|
||||
}
|
||||
}
|
||||
|
||||
if( highlight )
|
||||
{
|
||||
// Restore
|
||||
glDisable( GL_POLYGON_OFFSET_LINE );
|
||||
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
|
||||
}
|
||||
}
|
||||
|
||||
MODEL_3D::EndDrawMulti();
|
||||
|
|
|
@ -124,7 +124,7 @@ void OglSetMaterial( const SMATERIAL& aMaterial, float aOpacity, bool aUseSelec
|
|||
// !TODO: at this moment, diffuse color is added via
|
||||
// glEnableClientState( GL_COLOR_ARRAY ) so this line may has no effect
|
||||
// but can be used for optimization
|
||||
const SFVEC4F diffuse = SFVEC4F( aUseSelectedMaterial?aSelectionColor:aMaterial.m_Diffuse,
|
||||
const SFVEC4F diffuse = SFVEC4F( aUseSelectedMaterial ? aSelectionColor : aMaterial.m_Diffuse,
|
||||
( 1.0f - aMaterial.m_Transparency ) * aOpacity );
|
||||
const SFVEC4F specular = SFVEC4F( aMaterial.m_Specular, 1.0f );
|
||||
const SFVEC4F emissive = SFVEC4F( aMaterial.m_Emissive, 1.0f );
|
||||
|
@ -140,10 +140,12 @@ void OglSetMaterial( const SMATERIAL& aMaterial, float aOpacity, bool aUseSelec
|
|||
}
|
||||
|
||||
|
||||
void OglSetDiffuseMaterial( const SFVEC3F &aMaterialDiffuse, float aOpacity )
|
||||
void OglSetDiffuseMaterial( const SFVEC3F &aMaterialDiffuse, float aOpacity,
|
||||
bool aUseSelectedMaterial, SFVEC3F aSelectionColor )
|
||||
{
|
||||
const SFVEC4F ambient = SFVEC4F( 0.2f, 0.2f, 0.2f, 1.0f );
|
||||
const SFVEC4F diffuse = SFVEC4F( aMaterialDiffuse, aOpacity );
|
||||
const SFVEC4F diffuse = SFVEC4F( aUseSelectedMaterial ? aSelectionColor : aMaterialDiffuse,
|
||||
aOpacity );
|
||||
const SFVEC4F specular = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
const SFVEC4F emissive = SFVEC4F( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
|
||||
|
|
|
@ -52,7 +52,9 @@ void OglSetMaterial( const SMATERIAL& aMaterial, float aOpacity,
|
|||
*
|
||||
* @param aMaterialDiffuse the diffuse color to assign to material properties.
|
||||
*/
|
||||
void OglSetDiffuseMaterial( const SFVEC3F& aMaterialDiffuse, float aOpacity );
|
||||
void OglSetDiffuseMaterial( const SFVEC3F& aMaterialDiffuse, float aOpacity,
|
||||
bool aUseSelectedMaterial = false,
|
||||
SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) );
|
||||
|
||||
/**
|
||||
* Generate a new OpenGL texture.
|
||||
|
|
Loading…
Reference in New Issue