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 Nov 25, 2024
1 parent f4f324b commit 0126c13
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
10 changes: 6 additions & 4 deletions src/Core/Containers/VariableSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ auto VariableSet::addVariableType() -> Utils::optional<VariableContainer<T>*> {
// used to visit the variableSet with a dynamic visitor
m_vtable->m_visitFunctions.emplace_back(
[]( const VariableSet& c, const DynamicVisitorBase& v )
-> std::pair<bool, std::function<void( DynamicVisitorBase&, std::any && )>> {
-> std::pair<bool, std::function<void( DynamicVisitorBase&, std::any&& )>> {
auto id = getVariableVisitTypeIndex<T>();
if ( v.accept( id ) ) {
auto& storage = c.getVariableStorage<T>();
Expand Down Expand Up @@ -887,9 +887,11 @@ struct VariableSet::DynamicVisitor::MakeVisitOperatorHelper<T, F, false> {
template <class T, class F>
inline auto VariableSet::DynamicVisitor::makeVisitorOperator( F& f )
-> OperatorsStorageType::value_type {
auto opBuilder = MakeVisitOperatorHelper < T, F,
std::is_invocable<F, const std::string&, T, std::any&&>::value ||
std::is_invocable<F, const std::string&, T&, std::any&&>::value > {};
auto opBuilder = MakeVisitOperatorHelper<
T,
F,
std::is_invocable<F, const std::string&, T, std::any&&>::value ||
std::is_invocable<F, const std::string&, T&, std::any&&>::value> {};
return opBuilder.makeOperator( f );
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Geometry/RayCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ bool RayCastCylinder( const Ray& r,
return true;
}
} // End if (distance between ray and cyl axis < radius)
} // End of else (ray not parallel to the cylinder.
} // End of else (ray not parallel to the cylinder.

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Utils/Attribs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void AttribBase::setName( const std::string& name ) {
m_name = name;
}

bool inline AttribBase::operator==( const AttribBase& rhs ) {
bool inline AttribBase::operator==( const AttribBase & rhs ) {
return m_name == rhs.getName();
}

Expand Down
12 changes: 9 additions & 3 deletions src/Core/Utils/Singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
TYPE( const TYPE& ) = delete; \
void operator=( const TYPE& ) = delete; \
struct Deleter { \
void operator()( TYPE* p ) const { delete p; } \
void operator()( TYPE* p ) const { \
delete p; \
} \
}; \
static std::unique_ptr<TYPE, Deleter> s_instance; \
\
Expand All @@ -33,8 +35,12 @@
s_instance = std::unique_ptr<TYPE, Deleter>( new TYPE( args... ), Deleter() ); \
return getInstance(); \
} \
inline static TYPE* getInstance() { return s_instance.get(); } \
inline static void destroyInstance() { s_instance.reset( nullptr ); }
inline static TYPE* getInstance() { \
return s_instance.get(); \
} \
inline static void destroyInstance() { \
s_instance.reset( nullptr ); \
}

/// Add this macro in the singleton cpp, followed by a semicolon.
// Limitations : TYPE cannot be a nested type
Expand Down
39 changes: 18 additions & 21 deletions src/Engine/Data/Mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,22 +373,19 @@ class MultiIndexedGeometry : public CoreGeometryDisplayable<T>
using LayerKeyType = std::pair<LayerSemanticCollection, std::string>;

using EntryType = std::pair<bool, VaoIndices*>;
struct RA_CORE_API KeyHash {
std::size_t operator()( const LayerKeyType& k ) const {
// Mix semantic collection into a single identifier string
std::ostringstream stream;
std::copy(
k.first.begin(), k.first.end(), std::ostream_iterator<std::string>( stream, "" ) );
std::string result = stream.str();
std::sort( result.begin(), result.end() );

// Combine with layer name hash
return std::hash<std::string> {}( result ) ^
( std::hash<std::string> {}( k.second ) << 1 );
}
};
std::unordered_map<LayerKeyType, EntryType, KeyHash> m_indices;
};
struct RA_CORE_API KeyHash { std::size_t operator()( const LayerKeyType& k ) const {
// Mix semantic collection into a single identifier string
std::ostringstream stream;
std::copy( k.first.begin(), k.first.end(), std::ostream_iterator<std::string>( stream, "" ) );
std::string result = stream.str();
std::sort( result.begin(), result.end() );

// Combine with layer name hash
return std::hash<std::string> {}( result ) ^ ( std::hash<std::string> {}( k.second ) << 1 );
}
}; // namespace Data
std::unordered_map<LayerKeyType, EntryType, KeyHash> m_indices;
}; // namespace Engine

/// LineMesh, own a Core::Geometry::LineMesh
class RA_ENGINE_API LineMesh : public IndexedGeometry<Core::Geometry::LineMesh>
Expand Down Expand Up @@ -587,8 +584,8 @@ template <typename I>
void IndexedAttribArrayDisplayable<I>::updateGL() {
if ( m_isDirty ) {
// Check that our dirty bits are consistent.
ON_ASSERT( bool dirtyTest = false; for ( const auto& d
: m_dataDirty ) { dirtyTest = dirtyTest || d; } );
ON_ASSERT( bool dirtyTest = false;
for ( const auto& d : m_dataDirty ) { dirtyTest = dirtyTest || d; } );
CORE_ASSERT( dirtyTest == m_isDirty, "Dirty flags inconsistency" );

if ( !m_indices ) {
Expand Down Expand Up @@ -841,8 +838,8 @@ template <typename CoreGeometry>
void CoreGeometryDisplayable<CoreGeometry>::updateGL() {
if ( m_isDirty ) {
// Check that our dirty bits are consistent.
ON_ASSERT( bool dirtyTest = false; for ( auto d
: m_dataDirty ) { dirtyTest = dirtyTest || d; } );
ON_ASSERT( bool dirtyTest = false;
for ( auto d : m_dataDirty ) { dirtyTest = dirtyTest || d; } );
CORE_ASSERT( dirtyTest == m_isDirty, "Dirty flags inconsistency" );
CORE_ASSERT( !( m_mesh.vertices().empty() ), "No vertex." );

Expand Down Expand Up @@ -1133,6 +1130,6 @@ inline void GeneralMesh<Core::Geometry::QuadMesh>::triangulate() {
}
}

} // namespace Data
} // namespace Ra
} // namespace Engine
} // namespace Ra

0 comments on commit 0126c13

Please sign in to comment.