Skip to content

Commit

Permalink
Merge pull request #5621 from johnhaddon/expandHeaderVariables
Browse files Browse the repository at this point in the history
RendererAlgo : Expand string substitutions in context image metadata
  • Loading branch information
johnhaddon authored Jan 11, 2024
2 parents 2ae8094 + b0056b2 commit a797760
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----
Expand Down
2 changes: 2 additions & 0 deletions python/GafferSceneTest/InteractiveRenderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 ):

Expand Down
6 changes: 5 additions & 1 deletion src/GafferScene/RendererAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const StringData *>( data.get() )->readable() )
);
break;
default :
IECore::msg(
IECore::Msg::Debug,
Expand Down

0 comments on commit a797760

Please sign in to comment.