diff --git a/include/geode/basic/sparse_attribute.hpp b/include/geode/basic/sparse_attribute.hpp index c41b38dd8..8dcc14636 100644 --- a/include/geode/basic/sparse_attribute.hpp +++ b/include/geode/basic/sparse_attribute.hpp @@ -84,11 +84,14 @@ namespace geode [[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 ) diff --git a/include/geode/basic/variable_attribute.hpp b/include/geode/basic/variable_attribute.hpp index 57a2ab128..bc2d811e9 100644 --- a/include/geode/basic/variable_attribute.hpp +++ b/include/geode/basic/variable_attribute.hpp @@ -73,11 +73,14 @@ namespace geode [[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 ) @@ -342,11 +345,7 @@ namespace geode [[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 ) diff --git a/include/geode/model/mixin/core/component_mesh_element.hpp b/include/geode/model/mixin/core/component_mesh_element.hpp index c48014e0d..55ee4d4ce 100644 --- a/include/geode/model/mixin/core/component_mesh_element.hpp +++ b/include/geode/model/mixin/core/component_mesh_element.hpp @@ -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 ) {