From 1c20ba673720a1c71c4135ad4866dc1a5bb60288 Mon Sep 17 00:00:00 2001 From: Eric Mehl Date: Tue, 11 Jun 2024 16:03:57 -0400 Subject: [PATCH] LightEditor : Ignore Mute and Solo for blockers --- python/GafferSceneUI/LightEditor.py | 18 +++++++-- python/GafferSceneUITest/LightEditorTest.py | 39 +++++++++++++++++-- .../LightEditorBinding.cpp | 19 +++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/python/GafferSceneUI/LightEditor.py b/python/GafferSceneUI/LightEditor.py index a0c75a29bd..2c528e6bf6 100644 --- a/python/GafferSceneUI/LightEditor.py +++ b/python/GafferSceneUI/LightEditor.py @@ -277,9 +277,9 @@ def __updateColumns( self ) : sectionColumns += [ c( self.__settingsNode["in"], self.__settingsNode["editScope"] ) for c in section.values() ] nameColumn = self.__pathListing.getColumns()[0] - muteColumn = self.__pathListing.getColumns()[1] - soloColumn = self.__pathListing.getColumns()[2] - self.__pathListing.setColumns( [ nameColumn, muteColumn, soloColumn ] + sectionColumns ) + self.__muteColumn = self.__pathListing.getColumns()[1] + self.__soloColumn = self.__pathListing.getColumns()[2] + self.__pathListing.setColumns( [ nameColumn, self.__muteColumn, self.__soloColumn ] + sectionColumns ) def __settingsPlugSet( self, plug ) : @@ -366,12 +366,24 @@ def __editSelectedCells( self, pathListing, quickBoolean = True ) : inspectors = {} inspections = [] + with Gaffer.Context( self.getContext() ) as context : + lightSetMembers = self.__settingsNode["in"].set( "__lights" ).value + with Gaffer.Context( self.getContext() ) as context : for selection, column in zip( pathListing.getSelection(), pathListing.getColumns() ) : if not isinstance( column, _GafferSceneUI._LightEditorInspectorColumn ) : continue for pathString in selection.paths() : path = GafferScene.ScenePlug.stringToPath( pathString ) + + if ( + ( column == self.__muteColumn or column == self.__soloColumn ) and + not ( lightSetMembers.match( path ) & ( + IECore.PathMatcher.Result.ExactMatch | IECore.PathMatcher.Result.DescendantMatch + ) ) + ) : + continue + context["scene:path"] = path inspection = column.inspector().inspect() diff --git a/python/GafferSceneUITest/LightEditorTest.py b/python/GafferSceneUITest/LightEditorTest.py index 1927e20a97..c7c22cef3b 100644 --- a/python/GafferSceneUITest/LightEditorTest.py +++ b/python/GafferSceneUITest/LightEditorTest.py @@ -648,6 +648,9 @@ def testLightMuteAttribute( toggleCount, toggleLocation, newStates ) : editor = GafferSceneUI.LightEditor( script ) editor._LightEditor__settingsNode["editScope"].setInput( script["editScope"]["out"] ) + editor._LightEditor__updateColumns() + GafferSceneUI.LightEditor._LightEditor__updateColumns.flush( editor ) + widget = editor._LightEditor__pathListing self.setLightEditorMuteSelection( widget, togglePaths ) @@ -695,6 +698,9 @@ def testToggleContext( self ) : self.assertEqual( attr["gl:visualiser:scale"].value, 5.0 ) editor = GafferSceneUI.LightEditor( script ) + editor._LightEditor__updateColumns() + GafferSceneUI.LightEditor._LightEditor__updateColumns.flush( editor ) + widget = editor._LightEditor__pathListing editor.setNodeSet( Gaffer.StandardSet( [ script["custAttr"] ] ) ) self.setLightEditorMuteSelection( widget, ["/group/light"] ) @@ -730,12 +736,11 @@ def testShaderParameterEditScope( self ) : self.assertEqual( attributes["light"].shaders()["add"].parameters["a"].value, imath.Color3f( 0.0 ) ) self.assertEqual( attributes["light"].shaders()["__shader"].parameters["exposure"].value, 0.0 ) - with GafferUI.Window() as window : - editor = GafferSceneUI.LightEditor( script ) + editor = GafferSceneUI.LightEditor( script ) editor._LightEditor__settingsNode["editScope"].setInput( script["editScope"]["out"] ) - window.setVisible( True ) - self.waitForIdle( 1000 ) + editor._LightEditor__updateColumns() + GafferSceneUI.LightEditor._LightEditor__updateColumns.flush( editor ) editor.setNodeSet( Gaffer.StandardSet( [ script["editScope"] ] ) ) @@ -778,6 +783,32 @@ def testShaderParameterEditScope( self ) : self.assertEqual( attributes["light"].shaders()["add"].parameters["a"].value, imath.Color3f( 1.0, 0.5, 0.0 ) ) self.assertEqual( attributes["light"].shaders()["__shader"].parameters["exposure"].value, 2.0 ) + def testLightBlockerSoloDisabled( self ) : + + script = Gaffer.ScriptNode() + + script["blocker"] = GafferScene.Cube() + script["blocker"]["sets"].setValue( "__lightFilters" ) + + editor = GafferSceneUI.LightEditor( script ) + editor._LightEditor__updateColumns() + GafferSceneUI.LightEditor._LightEditor__updateColumns.flush( editor ) + + editor.setNodeSet( Gaffer.StandardSet( [ script["blocker"] ] ) ) + + widget = editor._LightEditor__pathListing + + columns = widget.getColumns() + for i, c in zip( range( 0, len( columns ) ), columns ) : + if isinstance( c, _GafferSceneUI._LightEditorSetMembershipColumn ) : + selection = [ IECore.PathMatcher() for i in range( 0, len( columns ) ) ] + selection[i].addPath( "/cube" ) + widget.setSelection( selection ) + + editor._LightEditor__editSelectedCells( widget ) + + self.assertTrue( script["blocker"]["out"].set( "soloLights" ).value.isEmpty() ) + if __name__ == "__main__" : unittest.main() diff --git a/src/GafferSceneUIModule/LightEditorBinding.cpp b/src/GafferSceneUIModule/LightEditorBinding.cpp index ea5260f9fa..ef7aaa17d9 100644 --- a/src/GafferSceneUIModule/LightEditorBinding.cpp +++ b/src/GafferSceneUIModule/LightEditorBinding.cpp @@ -79,6 +79,15 @@ namespace { ConstStringDataPtr g_emptyLocation = new StringData( "emptyLocation.png" ); +const InternedString g_lightSetName( "__lights" ); + +bool isLight( const ScenePath *scenePath, const Canceller *canceller ) +{ + ScenePlug::SetScope scope( scenePath->getContext(), &g_lightSetName ); + scope.setCanceller( canceller ); + ConstPathMatcherDataPtr lightsData = scenePath->getScene()->setPlug()->getValue(); + return lightsData->readable().match( scenePath->names() ) & PathMatcher::ExactMatch; +} class LocationNameColumn : public StandardPathColumn { @@ -289,6 +298,11 @@ class MuteColumn : public InspectorColumn return result; } + if( !isLight( scenePath, canceller ) ) + { + return CellData(); + } + if( auto value = runTimeCast( result.value ) ) { result.icon = value->readable() ? m_muteIconData : m_unMuteIconData; @@ -409,6 +423,11 @@ class SetMembershipColumn : public InspectorColumn return result; } + if( !isLight( scenePath, canceller ) ) + { + return CellData(); + } + std::string toolTip; if( auto toolTipData = runTimeCast( result.toolTip ) ) {