Skip to content

Commit

Permalink
Context : Fix vectors of GeometricTypedData
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Oct 27, 2023
1 parent cabe4ab commit 0f7cdc8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Fixes
- Fixed a bug preventing anything except strings from being copied and pasted.
- Fixed likely cause of crash when resizing Spreadsheet column width (#5296).
- Reference : Fixed rare reloading error.
- Context : Fixed bug preventing the retrieval of `V2iVectorData`, `V2fVectorData`, `V3iVectorData` and `V3fVectorData` from a context.

1.3.5.0 (relative to 1.3.4.0)
=======
Expand Down
16 changes: 16 additions & 0 deletions include/Gaffer/Context.inl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ struct DataTraits<Imath::Vec3<T> >

};

template<typename T>
struct DataTraits<std::vector<Imath::Vec2<T> > >
{

using DataType = IECore::GeometricTypedData<std::vector<Imath::Vec2<T>>>;

};

template<typename T>
struct DataTraits<std::vector<Imath::Vec3<T> > >
{

using DataType = IECore::GeometricTypedData<std::vector<Imath::Vec3<T>>>;

};

} // namespace Detail

inline Context::Value::Value()
Expand Down
36 changes: 36 additions & 0 deletions python/GafferTest/ContextTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def testTypes( self ) :
self.assertIsInstance( c["v2i"], imath.V2i )
self.assertNotEqual( compare, c.hash() )

c["v2iv"] = IECore.V2iVectorData( [ imath.V2i( 1, 2 ), imath.V2i( 3, 4 ) ] )
self.assertEqual( c["v2iv"], IECore.V2iVectorData( [ imath.V2i( 1, 2 ), imath.V2i( 3, 4 ) ] ) )
self.assertEqual( c.get( "v2iv" ), IECore.V2iVectorData( [ imath.V2i( 1, 2 ), imath.V2i( 3, 4 ) ] ) )
compare = c.hash()
c.set( "v2iv", IECore.V2iVectorData( [ imath.V2i( 5, 6 ), imath.V2i( 7, 8 ) ] ) )
self.assertEqual( c["v2iv"], IECore.V2iVectorData( [ imath.V2i( 5, 6 ), imath.V2i( 7, 8 ) ] ) )
self.assertIsInstance( c["v2iv"], IECore.V2iVectorData )
self.assertNotEqual( compare, c.hash() )

c["v3i"] = imath.V3i( 1, 2, 3 )
self.assertEqual( c["v3i"], imath.V3i( 1, 2, 3 ) )
self.assertEqual( c.get( "v3i" ), imath.V3i( 1, 2, 3 ) )
Expand All @@ -146,6 +155,15 @@ def testTypes( self ) :
self.assertIsInstance( c["v3i"], imath.V3i )
self.assertNotEqual( compare, c.hash() )

c["v3iv"] = IECore.V3iVectorData( [ imath.V3i( 1, 2, 3 ), imath.V3i( 4, 5, 6 ) ] )
self.assertEqual( c["v3iv"], IECore.V3iVectorData( [ imath.V3i( 1, 2, 3 ), imath.V3i( 4, 5, 6 ) ] ) )
self.assertEqual( c.get( "v3iv" ), IECore.V3iVectorData( [ imath.V3i( 1, 2, 3 ), imath.V3i( 4, 5, 6 ) ] ) )
compare = c.hash()
c.set( "v3iv", IECore.V3iVectorData( [ imath.V3i( 7, 8, 9 ), imath.V3i( 10, 11, 12 ) ] ) )
self.assertEqual( c["v3iv"], IECore.V3iVectorData( [ imath.V3i( 7, 8, 9 ), imath.V3i( 10, 11, 12 ) ] ) )
self.assertIsInstance( c["v3iv"], IECore.V3iVectorData )
self.assertNotEqual( compare, c.hash() )

c["v2f"] = imath.V2f( 1, 2 )
self.assertEqual( c["v2f"], imath.V2f( 1, 2 ) )
self.assertEqual( c.get( "v2f" ), imath.V2f( 1, 2 ) )
Expand All @@ -155,6 +173,15 @@ def testTypes( self ) :
self.assertIsInstance( c["v2f"], imath.V2f )
self.assertNotEqual( compare, c.hash() )

c["v2fv"] = IECore.V2fVectorData( [ imath.V2f( 1, 2 ), imath.V2f( 3, 4 ) ] )
self.assertEqual( c["v2fv"], IECore.V2fVectorData( [ imath.V2f( 1, 2 ), imath.V2f( 3, 4 ) ] ) )
self.assertEqual( c.get( "v2fv" ), IECore.V2fVectorData( [ imath.V2f( 1, 2 ), imath.V2f( 3, 4 ) ] ) )
compare = c.hash()
c.set( "v2fv", IECore.V2fVectorData( [ imath.V2f( 5, 6 ), imath.V2f( 7, 8 ) ] ) )
self.assertEqual( c["v2fv"], IECore.V2fVectorData( [ imath.V2f( 5, 6 ), imath.V2f( 7, 8 ) ] ) )
self.assertIsInstance( c["v2fv"], IECore.V2fVectorData )
self.assertNotEqual( compare, c.hash() )

c["v3f"] = imath.V3f( 1, 2, 3 )
self.assertEqual( c["v3f"], imath.V3f( 1, 2, 3 ) )
self.assertEqual( c.get( "v3f" ), imath.V3f( 1, 2, 3 ) )
Expand All @@ -164,6 +191,15 @@ def testTypes( self ) :
self.assertIsInstance( c["v3f"], imath.V3f )
self.assertNotEqual( compare, c.hash() )

c["v3fv"] = IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ] )
self.assertEqual( c["v3fv"], IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ] ) )
self.assertEqual( c.get( "v3fv" ), IECore.V3fVectorData( [ imath.V3f( 1, 2, 3 ), imath.V3f( 4, 5, 6 ) ] ) )
compare = c.hash()
c.set( "v3fv", IECore.V3fVectorData( [ imath.V3f( 7, 8, 9 ), imath.V3f( 10, 11, 12 ) ] ) )
self.assertEqual( c["v3fv"], IECore.V3fVectorData( [ imath.V3f( 7, 8, 9 ), imath.V3f( 10, 11, 12 ) ] ) )
self.assertIsInstance( c["v3fv"], IECore.V3fVectorData )
self.assertNotEqual( compare, c.hash() )

def testSwitchTypes( self ) :

c = Gaffer.Context()
Expand Down

0 comments on commit 0f7cdc8

Please sign in to comment.