From 0f7cdc8f26609238ff5fda4cf1c8f409fb33336c Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Fri, 27 Oct 2023 12:20:29 -0400 Subject: [PATCH] Context : Fix vectors of `GeometricTypedData` --- Changes.md | 1 + include/Gaffer/Context.inl | 16 ++++++++++++++ python/GafferTest/ContextTest.py | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/Changes.md b/Changes.md index 55e383e8d38..9b02fbb6bf1 100644 --- a/Changes.md +++ b/Changes.md @@ -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) ======= diff --git a/include/Gaffer/Context.inl b/include/Gaffer/Context.inl index 9c473f9fd78..14686d4bbb0 100644 --- a/include/Gaffer/Context.inl +++ b/include/Gaffer/Context.inl @@ -82,6 +82,22 @@ struct DataTraits > }; +template +struct DataTraits > > +{ + + using DataType = IECore::GeometricTypedData>>; + +}; + +template +struct DataTraits > > +{ + + using DataType = IECore::GeometricTypedData>>; + +}; + } // namespace Detail inline Context::Value::Value() diff --git a/python/GafferTest/ContextTest.py b/python/GafferTest/ContextTest.py index 78ce2750731..44ee027ea2f 100644 --- a/python/GafferTest/ContextTest.py +++ b/python/GafferTest/ContextTest.py @@ -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 ) ) @@ -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 ) ) @@ -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 ) ) @@ -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()