From cdf9736c18b754eaaf6112822ed29c3b7e0fe8b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 7 Apr 2023 06:21:07 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/Core/Geometry/MeshPrimitives.hpp | 6 +- src/Engine/Data/Mesh.cpp | 19 ++---- src/Engine/Rendering/ForwardRenderer.cpp | 82 ++++++++++++------------ src/Engine/Scene/SkinningComponent.cpp | 4 +- 4 files changed, 49 insertions(+), 62 deletions(-) diff --git a/src/Core/Geometry/MeshPrimitives.hpp b/src/Core/Geometry/MeshPrimitives.hpp index 268cd33759a..9d598bd211a 100644 --- a/src/Core/Geometry/MeshPrimitives.hpp +++ b/src/Core/Geometry/MeshPrimitives.hpp @@ -1,7 +1,7 @@ #pragma once -#include #include +#include #include #include #include @@ -77,8 +77,8 @@ RA_CORE_API MultiIndexedGeometry makeSharpBox2( const Vector3& halfExts = Vector /// Create an axis-aligned cubic mesh RA_CORE_API MultiIndexedGeometry makeSharpBox2( const Aabb& aabb, - const Utils::optional& color = {}, - bool generateTexCoord = false ); + const Utils::optional& color = {}, + bool generateTexCoord = false ); /// Create a parametric spherical mesh of given radius. Template parameters set the resolution. /// \param generateTexCoord: maps parametric (u,v) to texture corrdinates [0,1]^2 diff --git a/src/Engine/Data/Mesh.cpp b/src/Engine/Data/Mesh.cpp index 0f0613c2e20..9dcdfdde310 100644 --- a/src/Engine/Data/Mesh.cpp +++ b/src/Engine/Data/Mesh.cpp @@ -218,9 +218,7 @@ void GeometryDisplayable::loadGeometry( Core::Geometry::MultiIndexedGeometry&& m addRenderLayer( triangleKey, AttribArrayDisplayable::RM_TRIANGLES ); } } - else { - LOG( logERROR ) << "no valid layer found"; - } + else { LOG( logERROR ) << "no valid layer found"; } m_isDirty = true; } @@ -270,8 +268,7 @@ void GeometryDisplayable::addAttribObserver( const std::string& name ) { attrib->attach( AttribObserver( this, idx ) ); } // else it's an attrib remove, do nothing, cleanup will be done in updateGL() - else { - } + else {} } void GeometryDisplayable::setAttribNameMatching( const std::string& meshAttribName, @@ -395,9 +392,7 @@ void GeometryDisplayable::render( const ShaderProgram* prog, const LayerKeyType& << " [" << key.second << "]\n"; } } - else { - LOG( logERROR ) << "layer was not added as a render layer"; - } + else { LOG( logERROR ) << "layer was not added as a render layer"; } } void GeometryDisplayable::autoVertexAttribPointer( const ShaderProgram* prog, @@ -436,13 +431,9 @@ void GeometryDisplayable::autoVertexAttribPointer( const ShaderProgram* prog, #endif binding->setFormat( attrib->getNumberOfComponents(), GL_SCALAR ); } - else { - m_geomLayers[key].vao->disable( loc ); - } - } - else { - m_geomLayers[key].vao->disable( loc ); + else { m_geomLayers[key].vao->disable( loc ); } } + else { m_geomLayers[key].vao->disable( loc ); } GL_CHECK_ERROR; } } diff --git a/src/Engine/Rendering/ForwardRenderer.cpp b/src/Engine/Rendering/ForwardRenderer.cpp index c32e4dc4b14..d578a9f6352 100644 --- a/src/Engine/Rendering/ForwardRenderer.cpp +++ b/src/Engine/Rendering/ForwardRenderer.cpp @@ -308,9 +308,7 @@ void setupLineMesh( Data::GeometryDisplayable& displayable, const std::string& n { Core::Geometry::LineIndexLayer::staticSemanticName }, name }; auto layerAdded = coreGeometry.addLayer( std::move( lineLayer ), false, name ); if ( !layerAdded.first ) { LOG( logERROR ) << "failed to add wireframe"; } - else { - displayable.addRenderLayer( lineKey, Data::AttribArrayDisplayable::RM_LINES ); - } + else { displayable.addRenderLayer( lineKey, Data::AttribArrayDisplayable::RM_LINES ); } } } } @@ -450,13 +448,13 @@ void ForwardRenderer::renderInternal( const Data::ViewingParameters& renderData // shader. // This pass render in its own FBO and copy the result to the main colortexture if ( m_lightmanagers[0]->count() > 0 ) { - if ( !m_volumetricRenderObjects.empty() ) { + if ( !m_volumetricRenderObjects.empty() ) { - m_volumeFbo->bind(); - GL_ASSERT( glDrawBuffers( 1, buffers ) ); + m_volumeFbo->bind(); + GL_ASSERT( glDrawBuffers( 1, buffers ) ); static const auto alpha = Core::Utils::Color::Alpha().cast().eval(); - GL_ASSERT( glClearBufferfv( GL_COLOR, 0, alpha.data() ) ); - GL_ASSERT( glDisable( GL_BLEND ) ); + GL_ASSERT( glClearBufferfv( GL_COLOR, 0, alpha.data() ) ); + GL_ASSERT( glDisable( GL_BLEND ) ); Data::RenderParameters composeParams; composeParams.addParameter( "imageColor", m_textures[RendererTextures_HDR].get() ); @@ -464,30 +462,30 @@ void ForwardRenderer::renderInternal( const Data::ViewingParameters& renderData Data::RenderParameters passParams; passParams.addParameter( "compose_data", composeParams ); - for ( size_t i = 0; i < m_lightmanagers[0]->count(); ++i ) { - const auto l = m_lightmanagers[0]->getLight( i ); + for ( size_t i = 0; i < m_lightmanagers[0]->count(); ++i ) { + const auto l = m_lightmanagers[0]->getLight( i ); passParams.addParameter( "light_source", l->getRenderParameters() ); - for ( const auto& ro : m_volumetricRenderObjects ) { + for ( const auto& ro : m_volumetricRenderObjects ) { ro->render( passParams, renderData, DefaultRenderingPasses::LIGHTING_VOLUMETRIC ); + } } + m_volumeFbo->unbind(); + m_fbo->bind(); + GL_ASSERT( glDrawBuffers( 1, buffers ) ); + GL_ASSERT( glDisable( GL_DEPTH_TEST ) ); + GL_ASSERT( glEnable( GL_BLEND ) ); + GL_ASSERT( glBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA ) ); + { + auto shader = m_shaderProgramManager->getShaderProgram( "ComposeVolume" ); + shader->bind(); + shader->setUniform( "volumeImage", m_textures[RendererTextures_Volume].get(), 0 ); + m_quadMesh->render( shader ); + } + GL_ASSERT( glEnable( GL_DEPTH_TEST ) ); } - m_volumeFbo->unbind(); - m_fbo->bind(); - GL_ASSERT( glDrawBuffers( 1, buffers ) ); - GL_ASSERT( glDisable( GL_DEPTH_TEST ) ); - GL_ASSERT( glEnable( GL_BLEND ) ); - GL_ASSERT( glBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA ) ); - { - auto shader = m_shaderProgramManager->getShaderProgram( "ComposeVolume" ); - shader->bind(); - shader->setUniform( "volumeImage", m_textures[RendererTextures_Volume].get(), 0 ); - m_quadMesh->render( shader ); - } - GL_ASSERT( glEnable( GL_DEPTH_TEST ) ); - } } if ( m_wireframe ) { @@ -636,31 +634,31 @@ void ForwardRenderer::uiInternal( const Data::ViewingParameters& renderData ) { } else { - // bind data - shader->bind(); + // bind data + shader->bind(); - Core::Matrix4 M = ro->getTransformAsMatrix(); - Core::Matrix4 MV = renderData.viewMatrix * M; - Core::Vector3 V = MV.block<3, 1>( 0, 3 ); - Scalar d = V.norm(); + Core::Matrix4 M = ro->getTransformAsMatrix(); + Core::Matrix4 MV = renderData.viewMatrix * M; + Core::Vector3 V = MV.block<3, 1>( 0, 3 ); + Scalar d = V.norm(); - Core::Matrix4 S = Core::Matrix4::Identity(); - S.coeffRef( 0, 0 ) = S.coeffRef( 1, 1 ) = S.coeffRef( 2, 2 ) = d; + Core::Matrix4 S = Core::Matrix4::Identity(); + S.coeffRef( 0, 0 ) = S.coeffRef( 1, 1 ) = S.coeffRef( 2, 2 ) = d; - M = M * S; + M = M * S; - shader->setUniform( "transform.proj", renderData.projMatrix ); - shader->setUniform( "transform.view", renderData.viewMatrix ); - shader->setUniform( "transform.model", M ); + shader->setUniform( "transform.proj", renderData.projMatrix ); + shader->setUniform( "transform.view", renderData.viewMatrix ); + shader->setUniform( "transform.model", M ); - auto shaderParameter = ro->getRenderTechnique()->getParametersProvider(); - if ( shaderParameter != nullptr ) shaderParameter->getParameters().bind( shader ); + auto shaderParameter = ro->getRenderTechnique()->getParametersProvider(); + if ( shaderParameter != nullptr ) shaderParameter->getParameters().bind( shader ); - // render - ro->getMesh()->render( shader ); + // render + ro->getMesh()->render( shader ); + } } } - } m_uiXrayFbo->unbind(); } diff --git a/src/Engine/Scene/SkinningComponent.cpp b/src/Engine/Scene/SkinningComponent.cpp index 90c1c8f287c..dcd256405d8 100644 --- a/src/Engine/Scene/SkinningComponent.cpp +++ b/src/Engine/Scene/SkinningComponent.cpp @@ -327,9 +327,7 @@ void SkinningComponent::showWeights( bool on ) { // if the UV attrib existed before, reset it, otherwise remove it. handle = geom->getAttribHandle( attrUV ); if ( m_baseUV.size() > 0 ) { geom->getAttrib( handle ).setData( m_baseUV ); } - else { - geom->removeAttrib( handle ); - } + else { geom->removeAttrib( handle ); } } m_forceUpdate = true; }