Skip to content

Commit

Permalink
LightEditor : Ignore Mute and Solo for blockers
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmehl committed Jun 13, 2024
1 parent ab3ab3b commit 1c20ba6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 7 deletions.
18 changes: 15 additions & 3 deletions python/GafferSceneUI/LightEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) :

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

Expand Down
39 changes: 35 additions & 4 deletions python/GafferSceneUITest/LightEditorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )

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

Expand Down Expand Up @@ -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()
19 changes: 19 additions & 0 deletions src/GafferSceneUIModule/LightEditorBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -289,6 +298,11 @@ class MuteColumn : public InspectorColumn
return result;
}

if( !isLight( scenePath, canceller ) )
{
return CellData();
}

if( auto value = runTimeCast<const BoolData>( result.value ) )
{
result.icon = value->readable() ? m_muteIconData : m_unMuteIconData;
Expand Down Expand Up @@ -409,6 +423,11 @@ class SetMembershipColumn : public InspectorColumn
return result;
}

if( !isLight( scenePath, canceller ) )
{
return CellData();
}

std::string toolTip;
if( auto toolTipData = runTimeCast<const StringData>( result.toolTip ) )
{
Expand Down

0 comments on commit 1c20ba6

Please sign in to comment.