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

@ -1205,16 +1205,21 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
// Get the list of model files for this model
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() )
{
if( cache_i == m_3dmodel_map.end() )
continue;
if( const C_OGL_3DMODEL *modelPtr = cache_i->second )
{
if( ( (!aRenderTransparentOnly) && modelPtr->Have_opaque() && (sM.m_Opacity >= 1.0 ) ) ||
( aRenderTransparentOnly && ( modelPtr->Have_transparent() || (sM.m_Opacity < 1.0 ) ) ) )
bool opaque = sM.m_Opacity >= 1.0;
if( ( !aRenderTransparentOnly && modelPtr->Have_opaque() && opaque ) ||
( aRenderTransparentOnly && ( modelPtr->Have_transparent() || !opaque ) ) )
{
glPushMatrix();
@ -1222,9 +1227,12 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
// 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::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 ) );
@ -1254,8 +1262,6 @@ void C3D_RENDER_OGL_LEGACY::render_3D_module( const MODULE* module,
}
}
}
}
}
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 ) );
}