Skip to content

Commit d9a8ea4

Browse files
IECore::MurmurHash::append : Fix bug with Imath::Box in GCC
1 parent f40127a commit d9a8ea4

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

include/IECore/MurmurHash.inl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ inline void murmurHashAppend( MurmurHash &h, const Imath::Matrix44<T> &data )
347347
template<typename T>
348348
inline void murmurHashAppend( MurmurHash &h, const Imath::Box<T> &data )
349349
{
350-
h.append( &data.min, 2 );
350+
h.append( data.min );
351+
h.append( data.max );
351352
}
352353

353354
template<typename T>

test/IECore/MurmurHashTest.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,35 @@ struct MurmurHashTest
6969
// many elements in it - currently, I'm seeing a max occupancy of 8.
7070
BOOST_CHECK( maxBucketOccupancy < 16 );
7171
}
72+
73+
void testAllElementsOfImathBoxes()
74+
{
75+
Imath::Box3i ref( Imath::V3i( 123, 456, 789 ), Imath::V3i( 10123, 10456, 10789 ) );
76+
std::unordered_set< IECore::MurmurHash > set;
77+
78+
for( int i = 0; i < 6; i++ )
79+
{
80+
for( int j = 0; j < 32; j++ )
81+
{
82+
int bitToFlip = 1 << j;
83+
Imath::Box3i q = ref;
84+
if( i >= 3 )
85+
{
86+
q.max[i - 3] = bitToFlip ^ q.max[i - 3];
87+
}
88+
else
89+
{
90+
q.min[i] = bitToFlip ^ q.min[i];
91+
}
92+
93+
IECore::MurmurHash h;
94+
h.append( q );
95+
set.insert( h );
96+
}
97+
}
98+
99+
BOOST_CHECK( set.size() == ( 6 * 32 ) );
100+
}
72101
};
73102

74103

@@ -80,6 +109,7 @@ struct MurmurHashTestSuite : public boost::unit_test::test_suite
80109
boost::shared_ptr<MurmurHashTest> instance( new MurmurHashTest() );
81110

82111
add( BOOST_CLASS_TEST_CASE( &MurmurHashTest::testUnorderedSet, instance ) );
112+
add( BOOST_CLASS_TEST_CASE( &MurmurHashTest::testAllElementsOfImathBoxes, instance ) );
83113
}
84114
};
85115

0 commit comments

Comments
 (0)