diff --git a/Changes.md b/Changes.md index 1d68a8d36d9..bfe77b0cefa 100644 --- a/Changes.md +++ b/Changes.md @@ -1,7 +1,10 @@ 1.3.x.x (relative to 1.3.14.0) ======= +Fixes +----- +- InteractiveRender : Fixed context used to evaluate scene globals when renderer is set to "Default". 1.3.14.0 (relative to 1.3.13.1) ======== diff --git a/python/GafferSceneTest/InteractiveRenderTest.py b/python/GafferSceneTest/InteractiveRenderTest.py index 6b9d82ea7d3..bf087855499 100644 --- a/python/GafferSceneTest/InteractiveRenderTest.py +++ b/python/GafferSceneTest/InteractiveRenderTest.py @@ -2199,6 +2199,43 @@ def testRendererOption( self ): image = IECoreImage.ImageDisplayDriver.storedImage( "testRendererOption" ) self.assertIsInstance( image, IECoreImage.ImagePrimitive ) + def testRendererOptionContext( self ): + + script = Gaffer.ScriptNode() + script["variables"].addChild( Gaffer.NameValuePlug( "defaultRendererVariable", self.renderer ) ) + + script["outputs"] = GafferScene.Outputs() + script["outputs"].addOutput( + "beauty", + IECoreScene.Output( + "test", + "ieDisplay", + "rgba", + { + "driverType" : "ImageDisplayDriver", + "handle" : "testRendererOptionContext", + } + ) + ) + + script["standardOptions"] = GafferScene.StandardOptions() + script["standardOptions"]["in"].setInput( script["outputs"]["out"] ) + script["standardOptions"]["options"]["defaultRenderer"]["enabled"].setValue( True ) + script["standardOptions"]["options"]["defaultRenderer"]["value"].setValue( "${defaultRendererVariable}" ) + + script["renderer"] = self._createInteractiveRender( useNodeClass = False ) + script["renderer"]["renderer"].setValue( "" ) + script["renderer"]["in"].setInput( script["standardOptions"]["out"] ) + + # Check that the globals are evaluated in the right context to provide + # the `defaultRendererVariable` and enable the render. + + script["renderer"]["state"].setValue( script["renderer"].State.Running ) + time.sleep( 1.0 ) + + image = IECoreImage.ImageDisplayDriver.storedImage( "testRendererOptionContext" ) + self.assertIsInstance( image, IECoreImage.ImagePrimitive ) + def tearDown( self ) : GafferSceneTest.SceneTestCase.tearDown( self ) diff --git a/src/GafferScene/InteractiveRender.cpp b/src/GafferScene/InteractiveRender.cpp index 57bb9d5d278..096a388a256 100644 --- a/src/GafferScene/InteractiveRender.cpp +++ b/src/GafferScene/InteractiveRender.cpp @@ -298,6 +298,9 @@ void InteractiveRender::plugSet( const Gaffer::Plug *plug ) void InteractiveRender::update() { + ConstContextPtr context = effectiveContext(); + Context::Scope scope( context.get() ); + const State requiredState = (State)statePlug()->getValue(); // Stop the current render if we've been asked to, or if