Skip to content

Commit

Permalink
Merge branch '0.58_maintenance' into 0.59_maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Dec 10, 2020
2 parents ff763fd + bdb4fe6 commit 9488cba
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 27 deletions.
15 changes: 15 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
Fixes
-----

- Viewer : Fixed bug that caused the Inspector to edit the wrong node when SetFilters were in use.
- Widget : Fixed incorrect `ButtonEvent` coordinate origin for mouse signals under certain widget configurations.

API
---

- M33fVectorDataPlug : Added new plug type for specifying arrays of 3x3 matrices.
- PlugAlgo : `extraDataFromPlug()` now supports M33fPlug and M33fVectorDataPlug.
- FilterPlug : Added `match` method to evaluate the filter for the specified `ScenePlug`.

0.59.0.0
========
Expand Down Expand Up @@ -170,6 +172,19 @@ Build
- OpenSSL 1.1.1h
- See https://github.com/GafferHQ/dependencies/releases/tag/2.1.1 for full details.

0.58.6.x (relative to 0.58.6.0)
========

Fixes
-----

- Viewer : Fixed bug that caused the Inspector to edit the wrong node when SetFilters were in use.

API
---

- FilterPlug : Added `match` method to evaluate the filter for the specified `ScenePlug`.

0.58.6.0 (relative to 0.58.5.2)
========

Expand Down
2 changes: 1 addition & 1 deletion include/GafferScene/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GAFFERSCENE_API Filter : public Gaffer::ComputeNode
/// > where `input` is a child of a ScenePlug that will later be provided to `computeMatch()`.
void affects( const Gaffer::Plug *input, AffectedPlugsContainer &outputs ) const override;

/// \deprecated Use FilterPlug::SceneScope instead.
/// \deprecated Use FilterPlug::SceneScope or FilterPlug::match instead.
static void setInputScene( Gaffer::Context *context, const ScenePlug *scenePlug );
/// \deprecated
static const ScenePlug *getInputScene( const Gaffer::Context *context );
Expand Down
4 changes: 4 additions & 0 deletions include/GafferScene/FilterPlug.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class GAFFERSCENE_API FilterPlug : public Gaffer::IntPlug
/// usage, see `FilteredSceneProcessor::affects()`.
void sceneAffects( const Gaffer::Plug *scenePlugChild, Gaffer::DependencyNode::AffectedPlugsContainer &outputs ) const;

/// Evaluates the filter for the specified scene plug. Should be used in preference to
/// singular calls to getValue(), as it ensures a suitable SceneScope before evaluating the filter.
unsigned match( const ScenePlug *scene ) const;

/// Name of a context variable used to provide the input
/// scene to the filter
static const IECore::InternedString inputSceneContextName;
Expand Down
32 changes: 32 additions & 0 deletions python/GafferSceneTest/FilterPlugTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import GafferScene
import GafferSceneTest

import IECore

class FilterPlugTest( GafferSceneTest.SceneTestCase ) :

def testAcceptsInput( self ) :
Expand All @@ -62,5 +64,35 @@ def testAcceptsInput( self ) :
dot.setup( Gaffer.IntPlug() )
self.assertFalse( filterPlug1.acceptsInput( dot["out"] ) )

def testMatch( self ) :

p = GafferScene.FilterPlug()

with self.assertRaises( Exception ) :
p.match( None )

c = GafferScene.Cube()
c["sets"].setValue( "cubeSet" )

ctx = Gaffer.Context()
ctx[ "scene:path" ] = IECore.InternedStringVectorData( [ "cube" ] )
with ctx :

f = GafferScene.SetFilter()
p.setInput( f["out"] )

f["setExpression"].setValue( "cubeSet" )
self.assertEqual( p.match( c["out"] ), IECore.PathMatcher.Result.ExactMatch )
f["setExpression"].setValue( "otherSet" )
self.assertEqual( p.match( c["out"] ), IECore.PathMatcher.Result.NoMatch )

f = GafferScene.PathFilter()
p.setInput( f["out"] )

f["paths"].setValue( IECore.StringVectorData( [ "/cube" ] ) )
self.assertEqual( p.match( c["out"] ), IECore.PathMatcher.Result.ExactMatch )
f["paths"].setValue( IECore.StringVectorData( [ "/other" ] ) )
self.assertEqual( p.match( c["out"] ), IECore.PathMatcher.Result.NoMatch )

if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion python/GafferSceneUI/_SceneViewInspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ def __editFromSceneNode( self, attributeHistory ) :
if not node["enabled"].getValue() :
return None

if "filter" in node and not ( node["filter"].getValue() & IECore.PathMatcher.Result.ExactMatch ) :
if "filter" in node and not ( node["filter"].match( attributeHistory.scene ) & IECore.PathMatcher.Result.ExactMatch ) :
return None

if isinstance( node, ( GafferScene.Light, GafferScene.LightFilter ) ) :
Expand Down
6 changes: 6 additions & 0 deletions src/GafferScene/FilterPlug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ void FilterPlug::sceneAffects( const Gaffer::Plug *scenePlugChild, Gaffer::Depen
}
}

unsigned FilterPlug::match( const ScenePlug *scene ) const
{
FilterPlug::SceneScope scope( Context::current(), scene );
return getValue();
}

FilterPlug::SceneScope::SceneScope( const Gaffer::Context *context, const ScenePlug *scenePlug )
: EditableScope( context )
{
Expand Down
21 changes: 4 additions & 17 deletions src/GafferScene/SceneAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,19 +415,6 @@ SceneAlgo::History::Ptr historyWalk( const CapturedProcess *process, InternedStr
return result;
}

/// \todo It's error prone to have to use SceneScope like this. Consider
/// improvements to the FilterPlug so that you're forced to pass a scene
/// somehow. The use of the context to provide the input scene is questionable
/// anyway, and we don't tend to cache evaluations for `Filter.out`. So perhaps
/// Filters shouldn't even be ComputeNodes, and FilterPlug shouldn't be an
/// IntPlug, and instead we should pass a scene directly to some sort of
/// `FilterPlug::match( const ScenePlug *scene )` method?
int filterResult( const FilterPlug *filter, const ScenePlug *scene )
{
FilterPlug::SceneScope scope( Context::current(), scene );
return filter->getValue();
}

void addGenericAttributePredecessors( const SceneAlgo::History::Predecessors &source, SceneAlgo::AttributeHistory *destination )
{
for( auto &h : source )
Expand All @@ -443,7 +430,7 @@ void addCopyAttributesPredecessors( const CopyAttributes *copyAttributes, const
{
const ScenePlug *sourceScene = copyAttributes->inPlug();
if(
( filterResult( copyAttributes->filterPlug(), copyAttributes->inPlug() ) & PathMatcher::ExactMatch ) &&
( copyAttributes->filterPlug()->match( copyAttributes->inPlug() ) & PathMatcher::ExactMatch ) &&
StringAlgo::matchMultiple( destination->attributeName, copyAttributes->attributesPlug()->getValue() )
)
{
Expand Down Expand Up @@ -486,7 +473,7 @@ void addShuffleAttributesPredecessors( const ShuffleAttributes *shuffleAttribute
// has come from.

InternedString sourceAttributeName = destination->attributeName;
if( filterResult( shuffleAttributes->filterPlug(), shuffleAttributes->inPlug() ) & PathMatcher::ExactMatch )
if( shuffleAttributes->filterPlug()->match( shuffleAttributes->inPlug() ) & PathMatcher::ExactMatch )
{
auto inputAttributes = shuffleAttributes->inPlug()->attributesPlug()->getValue();
map<InternedString, InternedString> shuffledNames;
Expand Down Expand Up @@ -554,7 +541,7 @@ SceneProcessor *objectTweaksWalk( const SceneAlgo::History *h )
if( h->scene == tweaks->outPlug() )
{
Context::Scope contextScope( h->context.get() );
if( filterResult( tweaks->filterPlug(), tweaks->inPlug() ) & PathMatcher::ExactMatch )
if( tweaks->filterPlug()->match( tweaks->inPlug() ) & PathMatcher::ExactMatch )
{
return tweaks;
}
Expand All @@ -581,7 +568,7 @@ ShaderTweaks *shaderTweaksWalk( const SceneAlgo::AttributeHistory *h )
Context::Scope contextScope( h->context.get() );
if(
StringAlgo::matchMultiple( h->attributeName, tweaks->shaderPlug()->getValue() ) &&
( filterResult( tweaks->filterPlug(), tweaks->inPlug() ) & PathMatcher::ExactMatch )
( tweaks->filterPlug()->match( tweaks->inPlug() ) & PathMatcher::ExactMatch )
)
{
return tweaks;
Expand Down
8 changes: 8 additions & 0 deletions src/GafferSceneModule/FilterBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ ScenePlugPtr getInputScene( const Gaffer::Context *context )
return const_cast<ScenePlug *>( Filter::getInputScene( context ) );
}

int match( const FilterPlug &plug, const ScenePlug &scene )
{
IECorePython::ScopedGILRelease r;
return plug.match( &scene );
}


} // namespace

void GafferSceneModule::bindFilter()
Expand Down Expand Up @@ -95,6 +102,7 @@ void GafferSceneModule::bindFilter()
)
)
)
.def( "match", &match )
;

GafferBindings::DependencyNodeClass<PathFilter>();
Expand Down
10 changes: 2 additions & 8 deletions src/GafferSceneUI/TransformTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ M44f signOnlyScaling( const M44f &m )
return result;
}

int filterResult( const FilterPlug *filter, const ScenePlug *scene )
{
FilterPlug::SceneScope scope( Context::current(), scene );
return filter->getValue();
}

// Similar to `plug->source()`, but able to traverse through
// Spreadsheet outputs to find the appropriate input row.
V3fPlug *spreadsheetAwareSource( V3fPlug *plug, std::string &failureReason )
Expand Down Expand Up @@ -294,7 +288,7 @@ void TransformTool::Selection::initFromSceneNode( const GafferScene::SceneAlgo::
{
if(
history->scene == constraint->outPlug() &&
( filterResult( constraint->filterPlug(), constraint->inPlug() ) & PathMatcher::ExactMatch )
( constraint->filterPlug()->match( constraint->inPlug() ) & PathMatcher::ExactMatch )
)
{
m_aimConstraint = true;
Expand Down Expand Up @@ -326,7 +320,7 @@ void TransformTool::Selection::initFromSceneNode( const GafferScene::SceneAlgo::
{
if(
history->scene == transform->outPlug() &&
( filterResult( transform->filterPlug(), transform->inPlug() ) & PathMatcher::ExactMatch )
( transform->filterPlug()->match( transform->inPlug() ) & PathMatcher::ExactMatch )
)
{
transformPlug = const_cast<TransformPlug *>( transform->transformPlug() );
Expand Down

0 comments on commit 9488cba

Please sign in to comment.