Skip to content

Commit

Permalink
GafferScene : Exclude peripheral hash processes in history
Browse files Browse the repository at this point in the history
Fixes GafferHQ#3647. It surfaced a case where an hash process for a transform
plug unrelated to one passed to a `SceneAlgo::history` query was
surfaced in the results, leading to incorrect tool behaviour.

Fixes
-----

- SceneAlgo : Fixed bug that caused unrelated processes to appear in
  plug histories (GafferHQ#3647).
  • Loading branch information
tomc-cinesite committed Feb 24, 2020
1 parent 41efed6 commit a104271
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
38 changes: 38 additions & 0 deletions python/GafferSceneUITest/TranslateToolTest.py
Expand Up @@ -648,6 +648,44 @@ def testSelectionRefersToFirstPublicPlug( self ) :
view["in"].setInput( box["out"] )
self.assertEqual( tool.selection()[0].scene, box["out"] )

def testSelectionRefersToCorrectPlug( self ) :

script = Gaffer.ScriptNode()

script["sphere"] = GafferScene.Sphere()
script["cube"] = GafferScene.Cube()
script["freeze"] = GafferScene.FreezeTransform()
script["freezeFilter"] = GafferScene.PathFilter()
script["freezeFilter"]["paths"].setValue( IECore.StringVectorData( [ "/sphere" ] ) )
script["freeze"]["in"].setInput( script["sphere"]["out"] )
script["freeze"]["filter"].setInput( script["freezeFilter"]["out"] )
script["instancer"] = GafferScene.Instancer()
script["instancerFilter"] = GafferScene.PathFilter()
script["instancerFilter"]["paths"].setValue( IECore.StringVectorData( [ "/sphere" ] ) )
script["instancer"]["in"].setInput( script["freeze"]["out"] )
script["instancer"]["prototypes"].setInput( script["cube"]["out"] )
script["instancer"]["filter"].setInput( script["instancerFilter"]["out"] )
script["subTree"] = GafferScene.SubTree()
script["subTree"]["root"].setValue( "/sphere/instances" )
script["subTree"]["in"].setInput( script["instancer"]["out"] )
script["plane"] = GafferScene.Plane()
script["group"] = GafferScene.Group()
script["group"]["in"][0].setInput( script["subTree"]["out"] )
script["group"]["in"][1].setInput( script["plane"]["out"] )

view = GafferSceneUI.SceneView()

tool = GafferSceneUI.TranslateTool( view )
tool["active"].setValue( True )
self.assertEqual( tool.selection(), [] )

view["in"].setInput( script["group"]["out"] )
self.assertEqual( tool.selection(), [] )

GafferSceneUI.ContextAlgo.setSelectedPaths( view.getContext(), IECore.PathMatcher( [ "/group/plane" ] ) )
self.assertEqual( len( tool.selection() ), 1 )
self.assertEqual( tool.selection()[0].transformPlug, script["plane"]["transform"] )

def testLastSelectedObjectWithSharedTransformPlug( self ) :

script = Gaffer.ScriptNode()
Expand Down
8 changes: 7 additions & 1 deletion src/GafferScene/SceneAlgo.cpp
Expand Up @@ -421,7 +421,13 @@ SceneAlgo::History::Ptr historyWalk( const CapturedProcess *process, InternedStr

for( const auto &p : process->children )
{
historyWalk( p.get(), scenePlugChildName, parent );
// Parents may spawn other processes in support of the requested plug.
// We don't want these to show up in history output, so we only include
// ones that are directly in service of the requested plug.
if( runTimeCast<const ScenePlug>( p->plug->parent() ) && p->plug->getName() == scenePlugChildName )
{
historyWalk( p.get(), scenePlugChildName, parent );
}
}

return result;
Expand Down

0 comments on commit a104271

Please sign in to comment.