Skip to content

Commit

Permalink
Castor3D: Fixed some SonarLint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonJoker committed Jan 16, 2025
1 parent 819ef7d commit b7045c0
Show file tree
Hide file tree
Showing 51 changed files with 584 additions and 633 deletions.
2 changes: 1 addition & 1 deletion include/Core/Castor3D/Animation/Animable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace castor3d
*\~french
*\return \p true si l'objet a une animation.
*/
C3D_API bool hasAnimation()const;
C3D_API virtual bool hasAnimation()const noexcept;
/**
*\~english
*\param[in] name The animation name
Expand Down
4 changes: 2 additions & 2 deletions include/Core/Castor3D/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace castor3d
uint32_t overlayCount;
uint32_t samplerCount;

C3D_API EngineCounts( castor3d::Engine const & engine );
C3D_API explicit EngineCounts( castor3d::Engine const & engine );
};

struct EngineConfig
Expand Down Expand Up @@ -781,7 +781,7 @@ namespace castor3d
*\~french
*\return Un random engine, avec graine aléatoir si activé.
*/
C3D_API std::default_random_engine createRandomEngine();
C3D_API std::default_random_engine createRandomEngine()const;
/**
*\~english
*\brief Retrieves plug-ins path
Expand Down
4 changes: 2 additions & 2 deletions include/Core/Castor3D/Gui/Controls/CtrlEdit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ namespace castor3d
/** Event when a keyboard key is pressed
*\param[in] event The mouse event
*/
void onKeyUp( KeyboardEvent const & event );
void onKeyUp( KeyboardEvent const & event )const;

/** adds a character at caret index
*/
Expand Down Expand Up @@ -300,7 +300,7 @@ namespace castor3d

/** Normalises selection.
*/
Selection doGetNormalisedSelection();
Selection doGetNormalisedSelection()const;

/** Deletes selected text.
*/
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Castor3D/Gui/GuiModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ namespace castor3d
*\param[in] pass The pass.
*\param[in] colour The material colour.
*/
void setMaterialColour( Pass & pass, castor::HdrRgbColour const & colour );
void setMaterialColour( Pass const & pass, castor::HdrRgbColour const & colour );

/** Retrieves the pass colour.
*\param[in] pass The pass.
Expand Down
15 changes: 6 additions & 9 deletions include/Core/Castor3D/Material/Pass/Pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace castor3d
*\brief Définit la couleur basique de la passe.
*\param[in] value La nouvelle valeur.
*/
C3D_API void setColour( castor::HdrRgbColour const & value );
C3D_API void setColour( castor::HdrRgbColour const & value )const;
/**
*\~english
*\return The basic pass colour.
Expand All @@ -286,7 +286,7 @@ namespace castor3d
*\param vis
* Le ... visiteur.
*/
C3D_API void accept( ConfigurationVisitorBase & vis );
C3D_API void accept( ConfigurationVisitorBase & vis )const;
/**
*\~english
*\brief Fills the pass buffer with this pass data.
Expand Down Expand Up @@ -331,7 +331,7 @@ namespace castor3d
* Le ... visiteur.
*/
C3D_API void fillConfig( TextureConfiguration & config
, ConfigurationVisitorBase & vis );
, ConfigurationVisitorBase & vis )const;

C3D_API static void addParsers( castor::AttributeParsers & result
, castor::UInt32StrMap const & textureChannels );
Expand Down Expand Up @@ -502,17 +502,17 @@ namespace castor3d
}

void setColour( castor::RgbColour const & v
, float gamma = 2.2f )
, float gamma = 2.2f )const
{
setColour( castor::HdrRgbColour{ v, gamma } );
}

void setColour( castor::Coords3f const & v )
void setColour( castor::Coords3f const & v )const
{
setColour( castor::HdrRgbColour{ v[0u], v[1u], v[2u] } );
}

void setColour( castor::Point3f const & v )
void setColour( castor::Point3f const & v )const
{
setColour( castor::HdrRgbColour{ v[0u], v[1u], v[2u] } );
}
Expand All @@ -536,9 +536,6 @@ namespace castor3d
private:
void onSssChanged( SubsurfaceScattering const & sss );
void doPrepareImage( PassTextureSource const & cfg );
void doAddUnit( TextureUnitData & unitData
, TextureUnitRPtr unit
, UnitArray & result );
void doUpdateTextureFlags();
castor::Vector< PassComponentUPtr > doRemoveDependencies( castor::String const & name );
void doRemoveConfiguration( PassComponentTextureFlag flag );
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Castor3D/Material/Texture/TextureUnit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ namespace castor3d
return *m_device;
}

bool hasAnimation()const noexcept
bool hasAnimation()const noexcept override
{
return m_animated || hasAnimation( cuT( "Default" ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace castor3d
*\brief Met à jour la passe de rendu, au niveau CPU.
*\param[in, out] updater Les données d'update.
*/
C3D_API void update( CpuUpdater & updater );
C3D_API void update( CpuUpdater const & updater );
/**
*\copydoc castor3d::RenderTechniquePass::accept
*/
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Castor3D/Render/PBR/IblTextures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace castor3d
*\brief Met à jour les textures d'environnement.
*\param[in] queueData La queue recevant les commandes GPU.
*/
C3D_API void update( QueueData const & queueData );
C3D_API void update( QueueData const & queueData )const;
/**
*\~english
*\brief Updates the environment maps.
Expand Down
8 changes: 4 additions & 4 deletions include/Core/Castor3D/Render/Passes/GaussianBlur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace castor3d
, castor::String const & prefix
, crg::ImageViewIdArray const & views
, uint32_t kernelSize
, crg::RunnablePass::IsEnabledCallback isEnabled = crg::RunnablePass::IsEnabledCallback( []() { return true; } ) );
, crg::RunnablePass::IsEnabledCallback const & isEnabled = crg::RunnablePass::IsEnabledCallback( []() { return true; } ) );
/**
*\~english
*\brief Constructor.
Expand All @@ -111,7 +111,7 @@ namespace castor3d
, castor::String const & prefix
, crg::ImageViewId const & view
, uint32_t kernelSize
, crg::RunnablePass::IsEnabledCallback isEnabled = crg::RunnablePass::IsEnabledCallback( []() { return true; } ) );
, crg::RunnablePass::IsEnabledCallback const & isEnabled = crg::RunnablePass::IsEnabledCallback( []() { return true; } ) );
/**
*\~english
*\brief Constructor.
Expand Down Expand Up @@ -141,11 +141,11 @@ namespace castor3d
, crg::ImageViewId const & view
, crg::ImageViewId const & intermediateView
, uint32_t kernelSize
, crg::RunnablePass::IsEnabledCallback isEnabled = crg::RunnablePass::IsEnabledCallback( []() { return true; } ) );
, crg::RunnablePass::IsEnabledCallback const & isEnabled = crg::RunnablePass::IsEnabledCallback( []() { return true; } ) );
/**
*\copydoc castor3d::RenderTechniquePass::accept
*/
C3D_API void accept( ConfigurationVisitorBase & visitor );
C3D_API void accept( ConfigurationVisitorBase & visitor )const;
/**
*\~english
*name
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Castor3D/Render/RenderModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ namespace castor3d
AllocationStats uboAllocated;
castor::Vector< castor::Pair< MemChunk, castor::String > > uboAllocations;

C3D_API DeviceCounts( RenderDevice const & device );
C3D_API explicit DeviceCounts( RenderDevice const & device );
};

using RenderQueueArray = castor::Vector< castor::ReferenceWrapper< RenderQueue > >;
Expand Down
10 changes: 2 additions & 8 deletions include/Core/Castor3D/Render/RenderTarget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,13 @@ namespace castor3d
*\~english
*\brief Initialisation function.
*\param[in] device The GPU device.
*\param[in] queueData The queue receiving the GPU commands.
*\param[in] progress The optional progress bar.
*\~french
*\brief Fonction d'initialisation.
*\param[in] device Le device GPU.
*\param[in] queueData La queue recevant les commandes GPU.
*\param[in] progress La barre de progression optionnelle.
*/
C3D_API void initialise( RenderDevice const & device
, QueueData const & queueData
, ProgressBar * progress = nullptr );
/**
*\~english
Expand Down Expand Up @@ -173,7 +170,7 @@ namespace castor3d
*\brief Définit le ViewportType.
*\param[in] value Le nouveau ViewportType.
*/
C3D_API void setViewportType( ViewportType value );
C3D_API void setViewportType( ViewportType value )const;
/**
*\~english
*\brief Sets the camera.
Expand Down Expand Up @@ -213,7 +210,7 @@ namespace castor3d
*/
C3D_API PostEffectRPtr getPostEffect( castor::String const & name )const;
C3D_API void resetSemaphore();
C3D_API crg::FramePass const & createVertexTransformPass( crg::FramePassGroup & graph );
C3D_API crg::FramePass const & createVertexTransformPass( crg::FramePassGroup & graph )const;

C3D_API static void addParsers( castor::AttributeParsers & result );
/**
Expand Down Expand Up @@ -465,18 +462,15 @@ namespace castor3d

private:
void doInitialise( RenderDevice const & device
, QueueData const & queueData
, ProgressBar * progress = nullptr );
crg::FramePass & doCreateOverlayPass( ProgressBar * progress
, RenderDevice const & device );
crg::FramePass & doCreateCombinePass( ProgressBar * progress
, crg::ImageViewIdArray source );
bool doInitialiseTechnique( RenderDevice const & device
, QueueData const & queueData
, ProgressBar * progress
, crg::FramePassArray previousPasses );
void doCleanupTechnique();
void doCleanupCopyCommands();
void doInitCombineProgram();
void doCleanupCombineProgram();
Texture const & doUpdatePostEffects( CpuUpdater & updater
Expand Down
5 changes: 1 addition & 4 deletions include/Core/Castor3D/Render/RenderWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,14 @@ namespace castor3d
/**
*\~english
*\brief Renders one frame.
*\param[in,out] info Receives the render infos.
*\param[in] signalOnly \p true to only signal the semaphores.
*\param[in] toWait The semaphores to wait.
*\~french
*\brief Renders one frame.
*\param[in,out] info Reçoit les infos de rendu.
*\param[in] signalOnly \p true pour ne faire que signaler les semaphores.
*\param[in] toWait Les sémaphores à attendre.
*/
C3D_API void render( RenderInfo & info
, bool signalOnly
C3D_API void render( bool signalOnly
, crg::SemaphoreWaitArray & toWait );
/**
*\~english
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Castor3D/Render/Ssao/SsaoBlurPass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace castor3d
*\brief Met à jour la passe de rendu, au niveau CPU.
*\param[in, out] updater Les données d'update.
*/
C3D_API void update( CpuUpdater & updater );
C3D_API void update( CpuUpdater const & updater );
/**
*\~english
*\brief Accepts a visitor.
Expand Down
20 changes: 20 additions & 0 deletions include/Core/Castor3D/Shader/Shaders/GlslBaseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ namespace castor3d::shader
using UvStructT = sdw::IOStructInstanceHelperT< FlagT
, "C3D_Uv"
, sdw::IOStructFieldT< UvTypeT, "uv", 0u > >;
template< typename UvTypeT, sdw::var::Flag FlagT >
using TwoUvStructT = sdw::IOStructInstanceHelperT< FlagT
, "C3D_TwoUv"
, sdw::IOStructFieldT< UvTypeT, "uv0", 0u >
, sdw::IOStructFieldT< UvTypeT, "uv1", 1u > >;

template< typename ColTypeT, sdw::var::Flag FlagT >
struct ColourT
Expand Down Expand Up @@ -85,6 +90,21 @@ namespace castor3d::shader

auto uv()const { return this->template getMember< "uv" >(); }
};

template< typename UvTypeT, sdw::var::Flag FlagT >
struct TwoUvT
: public TwoUvStructT< UvTypeT, FlagT >
{
TwoUvT( sdw::ShaderWriter & writer
, sdw::expr::ExprPtr expr
, bool enabled )
: TwoUvStructT< UvTypeT, FlagT >{ writer, castor::move( expr ), enabled }
{
}

auto uv0()const { return this->template getMember< "uv0" >(); }
auto uv1()const { return this->template getMember< "uv1" >(); }
};
}

#endif
6 changes: 6 additions & 0 deletions include/Core/Castor3D/Shader/Shaders/SdwModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ namespace castor3d::shader
struct PosUvT;
template< typename UvTypeT, sdw::var::Flag FlagT >
struct UvT;
template< typename UvTypeT, sdw::var::Flag FlagT >
struct TwoUvT;
template< typename ValueT, sdw::StringLiteralT StructNameT >
struct DerivativeValueT;

Expand Down Expand Up @@ -152,6 +154,10 @@ namespace castor3d::shader
using Uv2FT = UvT< sdw::Vec2, FlagT >;
template< sdw::var::Flag FlagT >
using Uv3FT = UvT< sdw::Vec3, FlagT >;
template< sdw::var::Flag FlagT >
using TwoUv2FT = TwoUvT< sdw::Vec2, FlagT >;
template< sdw::var::Flag FlagT >
using TwoUv3FT = TwoUvT< sdw::Vec3, FlagT >;

class BackgroundModel;
class BufferBase;
Expand Down
6 changes: 3 additions & 3 deletions include/Core/CastorUtils/Data/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,11 @@ namespace castor
, bool allowReplace = false );
/**
*\~english
*\brief Replaces the characters non valid for file name with '_'
*\brief Replaces the characters non valid for file name with given replacement character
*\~french
*\brief Remplace les caractères non valides pour un nim de fichier par des '_'
*\brief Remplace les caractères non valides pour un nim de fichier par le caractère de remplacement donné
*/
CU_API static String normaliseFileName( String const & name );
CU_API static String normaliseFileName( String const & name, castor::StringView repl = cuT( "_" ) );
/**
*\~english
*\brief Retrieves the file size
Expand Down
6 changes: 3 additions & 3 deletions include/Core/CastorUtils/Math/Angle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,17 +560,17 @@ namespace castor
using Angle = AngleT< float >;
}

inline constexpr castor::Angle operator "" _turns( long double value )
constexpr castor::Angle operator "" _turns( long double value )
{
return castor::Angle::fromTurns( value );
}

inline constexpr castor::Angle operator "" _degrees( long double value )
constexpr castor::Angle operator "" _degrees( long double value )
{
return castor::Angle::fromDegrees( value );
}

inline constexpr castor::Angle operator "" _radians( long double value )
constexpr castor::Angle operator "" _radians( long double value )
{
return castor::Angle::fromRadians( value );
}
Expand Down
5 changes: 5 additions & 0 deletions include/Core/CastorUtils/Miscellaneous/StringUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,11 @@ namespace castor::string
}
}

constexpr castor::StringView operator "" _sv( castor::xchar const * const value, size_t length )noexcept
{
return castor::StringView{ value, length };
}

#include "StringUtils.inl"

#endif
2 changes: 1 addition & 1 deletion source/Core/Castor3D/Animation/Animable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace castor3d
m_animations.clear();
}

bool Animable::hasAnimation()const
bool Animable::hasAnimation()const noexcept
{
return !m_animations.empty();
}
Expand Down
2 changes: 1 addition & 1 deletion source/Core/Castor3D/Buffer/ObjectBufferPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ namespace castor3d

if ( it == buffers.end() )
{
auto & submeshComponents = getOwner()->getEngine()->getSubmeshComponentsRegister();
auto const & submeshComponents = getOwner()->getEngine()->getSubmeshComponentsRegister();
auto name = objbuf::getName( components, isGpuComputed );
ModelBuffers modelBuffers;

Expand Down
6 changes: 4 additions & 2 deletions source/Core/Castor3D/Buffer/PoolUniformBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ namespace castor3d
? 0u
: m_allocated.rbegin()->first.offset + m_allocated.rbegin()->first.size;
auto realSize = getAlignedSize( uint32_t( size ) );
castor::String stackTrace;
#if !defined( NDEBUG )
castor::String stackTrace;
castor::StringStream stream = castor::makeStringStream();
stream << castor::debug::Backtrace{ 20, 4 };
stackTrace = stream.str();
#endif
m_allocated.try_emplace( MemChunk{ offset, realSize, size }, stackTrace );
#else
m_allocated.try_emplace( MemChunk{ offset, realSize, size } );
#endif
return { offset / elemSize, realSize / elemSize, size };
}

Expand Down
Loading

0 comments on commit b7045c0

Please sign in to comment.