Skip to content

Commit

Permalink
EditScopeAlgo : Register renderPass:enabled in optionRegistry
Browse files Browse the repository at this point in the history
We'll require a more general way of registering default values for options
in the upcoming Render Pass Editor, but this allows us to test the existing
functionality with a "first party" `renderPass:` option (and fix a bug while
we're at it).
  • Loading branch information
murraystevenson committed Dec 14, 2023
1 parent 6130c75 commit 9d36932
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
37 changes: 37 additions & 0 deletions python/GafferSceneUITest/OptionInspectorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,43 @@ def testReadOnlyMetadataSignalling( self ) :
Gaffer.MetadataAlgo.setReadOnly( editScope, True )
self.assertEqual( len( cs ), 2 ) # Change affects the result of `inspect().editable()`

def testRegisteredOption( self ) :

standardOptions = GafferScene.StandardOptions()

editScope = Gaffer.EditScope()
editScope.setup( standardOptions["out"] )
editScope["in"].setInput( standardOptions["out"] )

# Inspecting the "renderPass:enabled" option without an active EditScope
# returns `None` as we have no upstream nodes capable of editing it.

self.assertIsNone( self.__inspect( editScope["out"], "renderPass:enabled" ) )

# Providing an EditScope allows the option edit to take place.

inspection = self.__inspect( editScope["out"], "renderPass:enabled", editScope )
edit = inspection.acquireEdit()
self.assertEqual(
edit,
GafferScene.EditScopeAlgo.acquireOptionEdit(
editScope, "renderPass:enabled", createIfNecessary = False
)
)

edit["enabled"].setValue( True )

# With the tweak in place in `editScope`, force the history to be checked again
# to make sure we get the right source back.

self.__assertExpectedResult(
self.__inspect( editScope["out"], "renderPass:enabled", editScope ),
source = edit,
sourceType = GafferSceneUI.Private.Inspector.Result.SourceType.EditScope,
editable = True,
edit = edit
)

def testRenderPassValues( self ) :

options = GafferScene.StandardOptions()
Expand Down
6 changes: 4 additions & 2 deletions src/GafferScene/EditScopeAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ CreatableRegistry g_attributeRegistry {
};

/// Entry keys for `g_optionRegistry` should not include the "option:" prefix.
CreatableRegistry g_optionRegistry;
CreatableRegistry g_optionRegistry {
{ "renderPass:enabled", new BoolData( true ) },
};

// Pruning
// =======
Expand Down Expand Up @@ -1146,7 +1148,7 @@ ConstObjectPtr optionValue( const ScenePlug *scene, const std::string &option )

if( !result )
{
CreatableRegistry::const_iterator registeredOption = g_optionRegistry.find( g_optionPrefix + option );
CreatableRegistry::const_iterator registeredOption = g_optionRegistry.find( option );
if( registeredOption != g_optionRegistry.end() )
{
return registeredOption->second;
Expand Down

0 comments on commit 9d36932

Please sign in to comment.