Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 7, 2023
1 parent 9de129a commit cdf9736
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 62 deletions.
6 changes: 3 additions & 3 deletions src/Core/Geometry/MeshPrimitives.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <Core/Geometry/TopologicalMesh.hpp>
#include <Core/Geometry/IndexedGeometry.hpp>
#include <Core/Geometry/TopologicalMesh.hpp>
#include <Core/Geometry/TriangleMesh.hpp>
#include <Core/Math/LinearAlgebra.hpp>
#include <Core/RaCore.hpp>
Expand Down Expand Up @@ -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<Utils::Color>& color = {},
bool generateTexCoord = false );
const Utils::optional<Utils::Color>& 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
Expand Down
19 changes: 5 additions & 14 deletions src/Engine/Data/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}
Expand Down
82 changes: 40 additions & 42 deletions src/Engine/Rendering/ForwardRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); }
}
}
}
Expand Down Expand Up @@ -450,44 +448,44 @@ 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<GL_SCALAR_PLAIN>().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() );
composeParams.addParameter( "imageDepth", m_textures[RendererTextures_Depth].get() );
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 ) {
Expand Down Expand Up @@ -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();
}

Expand Down
4 changes: 1 addition & 3 deletions src/Engine/Scene/SkinningComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@ void SkinningComponent::showWeights( bool on ) {
// if the UV attrib existed before, reset it, otherwise remove it.
handle = geom->getAttribHandle<Vector3>( attrUV );
if ( m_baseUV.size() > 0 ) { geom->getAttrib( handle ).setData( m_baseUV ); }
else {
geom->removeAttrib( handle );
}
else { geom->removeAttrib( handle ); }
}
m_forceUpdate = true;
}
Expand Down

0 comments on commit cdf9736

Please sign in to comment.