From b0056b28ac653ce78ac13c09d0dbc3f74913da33 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 10 Jan 2024 10:51:12 +0000 Subject: [PATCH] RendererAlgo : Expand string substitutions in context image metadata --- Changes.md | 1 + python/GafferSceneTest/InteractiveRenderTest.py | 2 ++ src/GafferScene/RendererAlgo.cpp | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index 108c14084c0..d61e95dbc2a 100644 --- a/Changes.md +++ b/Changes.md @@ -16,6 +16,7 @@ Improvements - OpenColorIOContext : Added file browser for `config` plug. - Layouts : Added the ability to load layouts containing editors that aren't currently available. This allows layouts containing new editors introduced in Gaffer 1.4 to be loaded in Gaffer 1.3. - LightTool : Changed the color of the non-highlighted handles to orange and the highlighted handles to cyan for consistency with other highlight colors. +- Outputs : Variable substitutions are now applied to `gaffer:context:*` image metadata values. This is needed when the value of a context variable contains references to other variables, with the default value for `project:rootDirectory` being one example. Fixes ----- diff --git a/python/GafferSceneTest/InteractiveRenderTest.py b/python/GafferSceneTest/InteractiveRenderTest.py index 85f28effdf2..29943726666 100644 --- a/python/GafferSceneTest/InteractiveRenderTest.py +++ b/python/GafferSceneTest/InteractiveRenderTest.py @@ -118,6 +118,7 @@ def testMetadata( self ) : s = Gaffer.ScriptNode() s["variables"].addChild( Gaffer.NameValuePlug( "a", "A", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) ) + s["variables"].addChild( Gaffer.NameValuePlug( "b", "${a}", flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) ) s["s"] = GafferScene.Sphere() @@ -148,6 +149,7 @@ def testMetadata( self ) : self.assertEqual( headers["gaffer:version"], IECore.StringData( Gaffer.About.versionString() ) ) self.assertEqual( headers["gaffer:sourceScene"], IECore.StringData( "r.__adaptedIn" ) ) self.assertEqual( headers["gaffer:context:a"], IECore.StringData( "A" ) ) + self.assertEqual( headers["gaffer:context:b"], IECore.StringData( "A" ) ) def testAddAndRemoveOutput( self ): diff --git a/src/GafferScene/RendererAlgo.cpp b/src/GafferScene/RendererAlgo.cpp index 44017f7ac85..11e28812d5e 100644 --- a/src/GafferScene/RendererAlgo.cpp +++ b/src/GafferScene/RendererAlgo.cpp @@ -1605,12 +1605,16 @@ ConstOutputPtr addGafferOutputParameters( const Output *output, const ScenePlug case IECore::BoolDataTypeId : case IECore::IntDataTypeId : case IECore::FloatDataTypeId : - case IECore::StringDataTypeId : case IECore::V3fDataTypeId : case IECore::Color3fDataTypeId : case IECore::Color4fDataTypeId : param->writable()["header:gaffer:context:" + name.string()] = data; break; + case IECore::StringDataTypeId : + param->writable()["header:gaffer:context:" + name.string()] = new StringData( + context->substitute( static_cast( data.get() )->readable() ) + ); + break; default : IECore::msg( IECore::Msg::Debug,