Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/geode/basic/sparse_attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@

[[nodiscard]] bool has_value( index_t element ) const override
{
if( value( element ) == default_values_.no_value )
if constexpr( std::is_floating_point_v< T > )
{
return false;
if( std::isnan( default_values_.no_value ) )
{
return std::isnan( value( element ) );
}
}
return true;
return value( element ) != default_values_.no_value;
}

void set_value( index_t element, T value )
Expand Down Expand Up @@ -131,10 +134,10 @@
: ReadOnlyAttribute< T >( name, std::move( properties ) ),
default_values_( std::move( default_values ) )
{
values_.reserve( 10 );

Check warning on line 137 in include/geode/basic/sparse_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/sparse_attribute.hpp:137:30 [cppcoreguidelines-avoid-magic-numbers]

10 is a magic number; consider replacing it with a named constant
}

SparseAttribute( std::string_view name )

Check warning on line 140 in include/geode/basic/sparse_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/sparse_attribute.hpp:140:9 [google-explicit-constructor]

single-argument constructors must be marked explicit to avoid unintentional implicit conversions
: ReadOnlyAttribute< T >( name, AttributeProperties{} )
{
}
Expand All @@ -161,7 +164,7 @@
archive.ext( attribute.values_,
bitsery::ext::StdMap{
attribute.values_.max_size() },
[]( Archive& archive2, index_t& i, T& item ) {

Check warning on line 167 in include/geode/basic/sparse_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/sparse_attribute.hpp:167:62 [readability-identifier-length]

parameter name 'i' is too short, expected at least 3 characters
archive2.value4b( i );
archive2( item );
} );
Expand All @@ -175,12 +178,12 @@
archive.ext( attribute.values_,
bitsery::ext::StdMap{
attribute.values_.max_size() },
[]( Archive& archive2, index_t& i, T& item ) {

Check warning on line 181 in include/geode/basic/sparse_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/sparse_attribute.hpp:181:65 [readability-identifier-length]

parameter name 'i' is too short, expected at least 3 characters
archive2.value4b( i );
archive2( item );
} );
} } } );
values_.reserve( 10 );

Check warning on line 186 in include/geode/basic/sparse_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/sparse_attribute.hpp:186:30 [cppcoreguidelines-avoid-magic-numbers]

10 is a magic number; consider replacing it with a named constant
}

void resize(
Expand Down Expand Up @@ -296,7 +299,7 @@
};
IdentifierBuilder builder{ *attribute };
builder.set_id( this->id() );
for( const auto& [in, outs] : old2new_mapping.in2out_map() )

Check warning on line 302 in include/geode/basic/sparse_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/sparse_attribute.hpp:302:31 [readability-identifier-length]

variable name 'in' is too short, expected at least 3 characters
{
if( value( in ) != default_values_.default_value )
{
Expand Down Expand Up @@ -326,7 +329,7 @@
void import( const GenericMapping< index_t >& old2new_mapping,
const ReadOnlyAttribute< T >& from )
{
for( const auto& [in, outs] : old2new_mapping.in2out_map() )

Check warning on line 332 in include/geode/basic/sparse_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/sparse_attribute.hpp:332:31 [readability-identifier-length]

variable name 'in' is too short, expected at least 3 characters
{
if( from.value( in ) != default_values_.default_value )
{
Expand Down
15 changes: 7 additions & 8 deletions include/geode/basic/variable_attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@

[[nodiscard]] bool has_value( index_t element ) const override
{
if( values_[element] == default_values_.no_value )
if constexpr( std::is_floating_point_v< T > )
{
return false;
if( std::isnan( default_values_.no_value ) )
{
return !std::isnan( value( element ) );
}
}
return true;
return values_[element] != default_values_.no_value;
}

void set_value( index_t element, T value )
Expand Down Expand Up @@ -123,10 +126,10 @@
: ReadOnlyAttribute< T >( name, std::move( properties ) ),
default_values_( std::move( default_values ) )
{
values_.reserve( 10 );

Check warning on line 129 in include/geode/basic/variable_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/variable_attribute.hpp:129:30 [cppcoreguidelines-avoid-magic-numbers]

10 is a magic number; consider replacing it with a named constant
}

VariableAttribute( std::string_view name )

Check warning on line 132 in include/geode/basic/variable_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/variable_attribute.hpp:132:9 [google-explicit-constructor]

single-argument constructors must be marked explicit to avoid unintentional implicit conversions
: ReadOnlyAttribute< T >( name, AttributeProperties{} ) {};

VariableAttribute()
Expand Down Expand Up @@ -164,7 +167,7 @@
archive2( item );
} );
} } } );
values_.reserve( 10 );

Check warning on line 170 in include/geode/basic/variable_attribute.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/basic/variable_attribute.hpp:170:30 [cppcoreguidelines-avoid-magic-numbers]

10 is a magic number; consider replacing it with a named constant
}

void resize(
Expand Down Expand Up @@ -342,11 +345,7 @@

[[nodiscard]] bool has_value( index_t element ) const override
{
if( value( element ) == default_values_.no_value )
{
return false;
}
return true;
return value( element ) != default_values_.no_value;
}

void set_value( index_t element, bool value )
Expand Down
6 changes: 6 additions & 0 deletions include/geode/model/mixin/core/component_mesh_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ namespace geode
&& element_id == other.element_id;
}

[[nodiscard]] bool operator!=( const ComponentMeshElement& other ) const
{
return component_id != other.component_id
|| element_id != other.element_id;
}

template < typename Archive >
void serialize( Archive& serializer )
{
Expand Down
Loading