Skip to content

Commit

Permalink
InteractiveRender : Fixed context used to get default renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Mar 18, 2024
1 parent bb50865 commit ba5feee
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -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)
========
Expand Down
37 changes: 37 additions & 0 deletions python/GafferSceneTest/InteractiveRenderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
3 changes: 3 additions & 0 deletions src/GafferScene/InteractiveRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ba5feee

Please sign in to comment.