A few formatting fixes

This commit is contained in:
Jon Evans 2020-05-08 17:32:06 -04:00
parent 9446a9166d
commit 7ca069e63e
3 changed files with 50 additions and 43 deletions

View File

@ -1203,56 +1203,62 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
modelunit_to_3d_units_factor );
// Get the list of model files for this model
for (auto& sM : module->Models ())
for( auto& sM : module->Models () )
{
if( !sM.m_Filename.empty() )
if( sM.m_Filename.empty() )
continue;
// Check if the model is present in our cache map
auto cache_i = m_3dmodel_map.find( sM.m_Filename );
if( cache_i == m_3dmodel_map.end() )
continue;
if( const C_OGL_3DMODEL *modelPtr = cache_i->second )
{
// Check if the model is present in our cache map
auto cache_i = m_3dmodel_map.find( sM.m_Filename );
if( cache_i != m_3dmodel_map.end() )
bool opaque = sM.m_Opacity >= 1.0;
if( ( !aRenderTransparentOnly && modelPtr->Have_opaque() && opaque ) ||
( aRenderTransparentOnly && ( modelPtr->Have_transparent() || !opaque ) ) )
{
if( const C_OGL_3DMODEL *modelPtr = cache_i->second )
glPushMatrix();
// FIXME: don't do this over and over again unless the
// values have changed. cache the matrix somewhere.
glm::mat4 mtx( 1 );
mtx = glm::translate( mtx, { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z } );
mtx = glm::rotate(
mtx, glm::radians( (float) -sM.m_Rotation.z ), { 0.0f, 0.0f, 1.0f } );
mtx = glm::rotate(
mtx, glm::radians( (float) -sM.m_Rotation.y ), { 0.0f, 1.0f, 0.0f } );
mtx = glm::rotate(
mtx, glm::radians( (float) -sM.m_Rotation.x ), { 1.0f, 0.0f, 0.0f } );
mtx = glm::scale( mtx, { sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z } );
glMultMatrixf( glm::value_ptr( mtx ) );
if( aRenderTransparentOnly )
modelPtr->Draw_transparent( sM.m_Opacity );
else
modelPtr->Draw_opaque();
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) )
{
if( ( (!aRenderTransparentOnly) && modelPtr->Have_opaque() && (sM.m_Opacity >= 1.0 ) ) ||
( aRenderTransparentOnly && ( modelPtr->Have_transparent() || (sM.m_Opacity < 1.0 ) ) ) )
{
glPushMatrix();
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
// FIXME: don't do this over and over again unless the
// values have changed. cache the matrix somewhere.
glm::mat4 mtx( 1 );
mtx = glm::translate( mtx, { sM.m_Offset.x, sM.m_Offset.y, sM.m_Offset.z } );
mtx = glm::rotate( mtx, glm::radians( (float)-sM.m_Rotation.z ), { 0.0f, 0.0f, 1.0f } );
mtx = glm::rotate( mtx, glm::radians( (float)-sM.m_Rotation.y ), { 0.0f, 1.0f, 0.0f } );
mtx = glm::rotate( mtx, glm::radians( (float)-sM.m_Rotation.x ), { 1.0f, 0.0f, 0.0f } );
mtx = glm::scale( mtx, { sM.m_Scale.x, sM.m_Scale.y, sM.m_Scale.z } );
glMultMatrixf( glm::value_ptr( mtx ) );
glDisable( GL_LIGHTING );
if( aRenderTransparentOnly )
modelPtr->Draw_transparent( sM.m_Opacity );
else
modelPtr->Draw_opaque();
glLineWidth( 1 );
modelPtr->Draw_bboxes();
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) )
{
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glLineWidth( 4 );
modelPtr->Draw_bbox();
glDisable( GL_LIGHTING );
glLineWidth( 1 );
modelPtr->Draw_bboxes();
glLineWidth( 4 );
modelPtr->Draw_bbox();
glEnable( GL_LIGHTING );
glDisable( GL_BLEND );
}
glPopMatrix();
}
glEnable( GL_LIGHTING );
glDisable( GL_BLEND );
}
glPopMatrix();
}
}
}

View File

@ -1335,7 +1335,7 @@ void C3D_RENDER_RAYTRACING::load_3D_models()
while( sM != eM )
{
if( ( (float)sM->m_Opacity > FLT_EPSILON ) &&
if( ( static_cast<float>( sM->m_Opacity ) > FLT_EPSILON ) &&
( sM->m_Show && !sM->m_Filename.empty() ) )
{
// get it from cache

View File

@ -208,6 +208,7 @@ void OGL_DrawBackground( const SFVEC3F &aTopColor, const SFVEC3F &aBotColor )
glEnd();
}
void OGL_ResetTextureStateDefaults()
{
glActiveTexture( GL_TEXTURE0 );
@ -218,5 +219,5 @@ void OGL_ResetTextureStateDefaults()
const SFVEC4F zero = SFVEC4F( 0.0f );
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const float*)&zero.x );
glTexEnvfv( GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, static_cast<const float*>( &zero.x ) );
}