diff --git a/Changes.md b/Changes.md index fd076cf672..a2080b11fe 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Fixes ----- - Cycles : Fixed rendering of shaders written with `IECOREUSD_WRITE_CONFORMANT_OSL_SHADERS=1`. +- BoxIO : Fixed `noduleLayout:section` metadata when BoxIn/BoxOut are set up from a plug of the opposite direction. This could result in EditScope nodes created immediately downstream of a Box having their `in` plug at the bottom of the node rather than the top. 1.6.21.5 (relative to 1.6.21.4) ======== diff --git a/python/GafferTest/BoxInTest.py b/python/GafferTest/BoxInTest.py index 8f0f161dd1..a60b262f57 100644 --- a/python/GafferTest/BoxInTest.py +++ b/python/GafferTest/BoxInTest.py @@ -220,6 +220,20 @@ def testNoduleSectionMetadata( self ) : self.assertEqual( Gaffer.Metadata.value( s["b"]["i"].promotedPlug(), "noduleLayout:section" ), "left" ) self.assertEqual( Gaffer.Metadata.value( s["b"]["i"].plug(), "noduleLayout:section" ), "right" ) + def testNoduleSectionMetadataFromOutPlug( self ) : + + s = Gaffer.ScriptNode() + s["n"] = GafferTest.AddNode() + + Gaffer.Metadata.registerValue( s["n"]["sum"], "noduleLayout:section", "bottom" ) + + s["b"] = Gaffer.Box() + s["b"]["i"] = Gaffer.BoxIn() + s["b"]["i"].setup( s["n"]["sum"] ) + + self.assertEqual( Gaffer.Metadata.value( s["b"]["i"].promotedPlug(), "noduleLayout:section" ), "top" ) + self.assertIsNone( Gaffer.Metadata.value( s["b"]["i"].plug(), "noduleLayout:section" ) ) + def testPromotedPlugRemovalDeletesBoxIn( self ) : s = Gaffer.ScriptNode() diff --git a/python/GafferTest/BoxOutTest.py b/python/GafferTest/BoxOutTest.py index 1d702c3e87..5ab500a69e 100644 --- a/python/GafferTest/BoxOutTest.py +++ b/python/GafferTest/BoxOutTest.py @@ -178,6 +178,20 @@ def testNoduleSectionMetadata( self ) : self.assertEqual( Gaffer.Metadata.value( s["b"]["o"].promotedPlug(), "noduleLayout:section" ), "right" ) self.assertEqual( Gaffer.Metadata.value( s["b"]["o"].plug(), "noduleLayout:section" ), "left" ) + def testNoduleSectionMetadataFromInPlug( self ) : + + s = Gaffer.ScriptNode() + s["n"] = GafferTest.AddNode() + + Gaffer.Metadata.registerValue( s["n"]["op1"], "noduleLayout:section", "top" ) + + s["b"] = Gaffer.Box() + s["b"]["o"] = Gaffer.BoxOut() + s["b"]["o"].setup( s["n"]["op1"] ) + + self.assertEqual( Gaffer.Metadata.value( s["b"]["o"].promotedPlug(), "noduleLayout:section" ), "bottom" ) + self.assertIsNone( Gaffer.Metadata.value( s["b"]["o"].plug(), "noduleLayout:section" ) ) + def testPromotedPlugRemovalDeletesBoxOut( self ) : s = Gaffer.ScriptNode() diff --git a/python/GafferTest/EditScopeTest.py b/python/GafferTest/EditScopeTest.py index 6c8bc43797..654c6abaee 100644 --- a/python/GafferTest/EditScopeTest.py +++ b/python/GafferTest/EditScopeTest.py @@ -189,5 +189,33 @@ def testSerialisation( self ) : self.assertEqual( p2["variables"][0]["value"].getValue(), p["variables"][0]["value"].getValue() ) self.assertEqual( s2["e"]["out"].getValue(), s["e"]["out"].getValue() ) + def testSetupFromOutPlugWithSectionMetadata( self ) : + + s = Gaffer.ScriptNode() + s["b"] = Gaffer.Box() + s["b"]["n"] = GafferTest.AddNode() + Gaffer.BoxIO.promote( s["b"]["n"]["sum"] ) + Gaffer.Metadata.registerValue( s["b"]["sum"], "noduleLayout:section", "bottom" ) + + s["e"] = Gaffer.EditScope() + s["e"].setup( s["b"]["sum"] ) + + self.assertEqual( Gaffer.Metadata.value( s["e"]["in"], "noduleLayout:section" ), "top" ) + self.assertEqual( Gaffer.Metadata.value( s["e"]["out"], "noduleLayout:section" ), "bottom" ) + + def testSetupFromInPlugWithSectionMetadata( self ) : + + s = Gaffer.ScriptNode() + s["b"] = Gaffer.Box() + s["b"]["n"] = GafferTest.AddNode() + Gaffer.BoxIO.promote( s["b"]["n"]["op1"] ) + Gaffer.Metadata.registerValue( s["b"]["op1"], "noduleLayout:section", "top" ) + + s["e"] = Gaffer.EditScope() + s["e"].setup( s["b"]["op1"] ) + + self.assertEqual( Gaffer.Metadata.value( s["e"]["in"], "noduleLayout:section" ), "top" ) + self.assertEqual( Gaffer.Metadata.value( s["e"]["out"], "noduleLayout:section" ), "bottom" ) + if __name__ == "__main__": unittest.main() diff --git a/src/Gaffer/BoxIO.cpp b/src/Gaffer/BoxIO.cpp index 4605cfe135..69b6466a41 100644 --- a/src/Gaffer/BoxIO.cpp +++ b/src/Gaffer/BoxIO.cpp @@ -244,7 +244,7 @@ void BoxIO::setup( const Plug *plug ) ); setupNoduleSectionMetadata( - m_direction == Plug::In ? outPlugInternal() : inPlugInternal(), + plug->direction() == Plug::In ? outPlugInternal() : inPlugInternal(), plug );