Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OptionTweaks : Allow multiple tweaks to the same option #5464

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Fixes

- DispatchDialogue : Changed the button label for the results display from "Ok" to "Close".
- Viewer : Fixed display of infinite values in the pixel inspectors. These were being incorrectly displayed as `nan` instead of `inf`.
- OptionTweaks : Fixed bug that prevented multiple tweaks being made to the same option in one node.

API
---
Expand Down
9 changes: 9 additions & 0 deletions python/GafferSceneTest/OptionTweaksTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ def testCreateMode( self ) :

self.assertEqual( tweaks["out"]["globals"].getValue()["option:test"], IECore.IntData( 10 ) )

def testChainedTweaks( self ) :

tweaks = GafferScene.OptionTweaks()

tweaks["tweaks"].addChild( Gaffer.TweakPlug( "test", 1, Gaffer.TweakPlug.Mode.Create ) )
tweaks["tweaks"].addChild( Gaffer.TweakPlug( "test", 10, Gaffer.TweakPlug.Mode.Multiply ) )
tweaks["tweaks"].addChild( Gaffer.TweakPlug( "test", 2, Gaffer.TweakPlug.Mode.Add ) )

self.assertEqual( tweaks["out"].globals()["option:test"].value, 12 )

if __name__ == "__main__" :
unittest.main()
6 changes: 2 additions & 4 deletions src/GafferScene/OptionTweaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@ IECore::ConstCompoundObjectPtr OptionTweaks::computeProcessedGlobals(
CompoundObjectPtr result = new CompoundObject();
result->members() = inputGlobals->members();

const CompoundObject *source = inputGlobals.get();

tweaksPlug->applyTweaks(
[&source]( const std::string &valueName )
[&result]( const std::string &valueName )
{
return source->member<Data>( g_namePrefix + valueName );
return result->member<Data>( g_namePrefix + valueName );
},
[&result]( const std::string &valueName, DataPtr newData )
{
Expand Down
Loading