Skip to content

Commit

Permalink
Merge branch '1.3_maintenance' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Sep 20, 2023
2 parents bb1cd1e + d29eda3 commit 0f8b259
Show file tree
Hide file tree
Showing 10 changed files with 559 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main/installDependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

# Determine default archive URL.

defaultURL = "https://github.com/ImageEngine/cortex/releases/download/10.5.1.0/cortex-10.5.1.0-{platform}-python3.{extension}".format(
defaultURL = "https://github.com/ImageEngine/cortex/releases/download/10.5.2.0/cortex-10.5.2.0-{platform}-python3.{extension}".format(
platform = { "darwin" : "osx", "win32" : "windows" }.get( sys.platform, "linux" ),
extension = "tar.gz" if sys.platform != "win32" else "zip"
)
Expand Down
25 changes: 23 additions & 2 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ Breaking Changes

- Dispatcher : Removed `createMatching()` method.

1.3.x.x (relative to 1.3.2.0)
1.3.x.x (relative to 1.3.3.0)
=======


1.3.3.0 (relative to 1.3.2.0)
=======

Features
Expand All @@ -21,19 +25,30 @@ Features
Improvements
------------

- SceneReader : Added support for reading from in-memory USD stages using a filename of the form `stageCache:{id}.usd` where `{id}` specifies a stage which has been inserted in the `UsdUtilsStageCache`.
- Resample, Resize, Blur, ImageTransform : Improved performance, resulting in a 3x speedup in an obscure case, and a 5-10% speedup in more common cases.
- ImageSampler : Added `interpolate` plug to control interpolation. Previously created ImageSamplers are unaffected, but interpolation is off by default for newly created ImageSamplers.
- 3Delight :
- Moved shaders to `3Delight/Shader` menu and removed outdated shaders from the menu.
- Shaders (including light shaders) are only loaded from the `osl` subdirectory of the 3Delight installation.
- Primitive variables named `uv` are now automatically renamed `st` for compatibility with the `uvCoord` shader's expectation.
- Added a default `uvCoord` shader during internal shader network preprocessing to shader parameters that do not have an input connection.
- SetEditor : Added columns for controlling the Visible Set membership of set members. These allow the current members of a set to be included or excluded from the Visible Set by clicking within the Set Editor's Inclusions and Exclusions columns.

Fixes
-----

- SceneReader :
- Fixed handling of invalid values on the following USD attributes :
- PointBased : `positions`, `normals`, `velocities`, `accelerations`.
- Curves : `widths`.
- PointInstancer : `ids`, `protoIndices`, `orientations`, `scales`, `velocities`, `accelerations`, `angularVelocities`.
- Points : `ids`, `widths`.
Invalid values are now ignored with a warning, instead of loading as invalid primitive variables.
- Fixed treatment of unconnected material outputs. If they were "authored" but not connected to a source, they were incorrectly being treated as valid attributes, and were being loaded as empty ShaderNetworks which caused problems elsewhere.
- 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 All @@ -43,11 +58,13 @@ API
- Added `findAllWithAttribute()` method, for finding all scene locations with a particular attribute.
- ThreadState : Added `process()` method.
- Process : Added const overload for `handleException()` method. The non-const version will be removed in future.
- ContextMonitor : Added `Statistics::variableHashes()` method, allowing introspection of specific variable values.

Build
-----

- MacOS : Fixed compilation with Clang 13.
- Cortex : Updated to version 10.5.2.0.

1.3.2.0 (relative to 1.3.1.0)
=======
Expand Down Expand Up @@ -368,7 +385,11 @@ Build
- USD : Updated to version 23.05.
- ZLib : Added version 1.2.13.

1.2.10.x (relative to 1.2.10.2)
1.2.10.x (relative to 1.2.10.3)
========


1.2.10.3 (relative to 1.2.10.2)
========

Fixes
Expand Down
6 changes: 5 additions & 1 deletion include/Gaffer/ContextMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ class GAFFER_API ContextMonitor : public Monitor
struct GAFFER_API Statistics
{

using CountingMap = boost::unordered_map<IECore::MurmurHash, size_t>;

size_t numUniqueContexts() const;
std::vector<IECore::InternedString> variableNames() const;
size_t numUniqueValues( IECore::InternedString variableName ) const;
/// Maps from the `Context::variableHash()` for each unique value to
/// the number of times that value appeared.
const CountingMap &variableHashes( IECore::InternedString variableName ) const;

Statistics & operator += ( const Context *rhs );
Statistics & operator += ( const Statistics &rhs );
Expand All @@ -86,7 +91,6 @@ class GAFFER_API ContextMonitor : public Monitor
private :

using ContextSet = boost::unordered_set<IECore::MurmurHash>;
using CountingMap = boost::unordered_map<IECore::MurmurHash, size_t>;
using VariableMap = std::map<IECore::InternedString, CountingMap>;

ContextSet m_contexts;
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()
54 changes: 36 additions & 18 deletions python/GafferSceneUI/SetEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ def __init__( self, scriptNode, **kw ) :
GafferUI.BasicPathFilterWidget( emptySetFilter )

self.__setMembersColumn = GafferUI.StandardPathColumn( "Members", "setPath:memberCount" )
self.__includedSetMembersColumn = _GafferSceneUI._SetEditor.VisibleSetInclusionsColumn( scriptNode.context() )
self.__excludedSetMembersColumn = _GafferSceneUI._SetEditor.VisibleSetExclusionsColumn( scriptNode.context() )
self.__pathListing = GafferUI.PathListingWidget(
Gaffer.DictPath( {}, "/" ), # temp till we make a SetPath
columns = [
_GafferSceneUI._SetEditor.SetNameColumn(),
self.__setMembersColumn,
self.__includedSetMembersColumn,
self.__excludedSetMembersColumn,
],
selectionMode = GafferUI.PathListingWidget.SelectionMode.Rows,
displayMode = GafferUI.PathListingWidget.DisplayMode.Tree,
Expand Down Expand Up @@ -164,23 +168,29 @@ def __selectedSetNames( self ) :
def __dragBegin( self, widget, event ) :

path = self.__pathListing.pathAt( imath.V2f( event.line.p0.x, event.line.p0.y ) )
column = self.__pathListing.columnAt( imath.V2f( event.line.p0.x, event.line.p0.y ) )
selection = self.__pathListing.getSelection()

setNames = []
if selection.match( str( path ) ) & IECore.PathMatcher.Result.ExactMatch :
if column == self.__setMembersColumn :
GafferUI.Pointer.setCurrent( "paths" )
return IECore.StringVectorData( self.__getSetMembers().paths() )
else :
selectedSetNames = self.__selectedSetNames()
if len( selectedSetNames ) > 0 :
GafferUI.Pointer.setCurrent( "paths" )
return IECore.StringVectorData( selectedSetNames )
else :
# prevent the path itself from being dragged
return IECore.StringVectorData()
setNames = self.__selectedSetNames()
else :
setName = path.property( "setPath:setName" )
if setName is not None :
setNames.append( setName )

return None
if len( setNames ) == 0 :
# prevent the path itself from being dragged
return IECore.StringVectorData()

GafferUI.Pointer.setCurrent( "paths" )
column = self.__pathListing.columnAt( imath.V2f( event.line.p0.x, event.line.p0.y ) )
if column == self.__setMembersColumn :
return IECore.StringVectorData( self.__getSetMembers( setNames ).paths() )
elif column == self.__includedSetMembersColumn :
return IECore.StringVectorData( self.__getIncludedSetMembers( setNames ).paths() )
elif column == self.__excludedSetMembersColumn :
return IECore.StringVectorData( self.__getExcludedSetMembers( setNames ).paths() )
else :
return IECore.StringVectorData( setNames )

def __keyPressSignal( self, widget, event ) :

Expand Down Expand Up @@ -240,29 +250,37 @@ def __copySelectedSetNames( self, *unused ) :

self.__plug.ancestor( Gaffer.ApplicationRoot ).setClipboardContents( data )

def __getSetMembers( self, *unused ) :
def __getSetMembers( self, setNames, *unused ) :

result = IECore.PathMatcher()

if self.__plug is None :
return result

with Gaffer.Context( self.getContext() ) :
for setName in self.__selectedSetNames() :
for setName in setNames :
result.addPaths( self.__plug.set( setName ).value )

return result

def __getIncludedSetMembers( self, setNames, *unused ) :

return self.__getSetMembers( setNames ).intersection( ContextAlgo.getVisibleSet( self.getContext() ).inclusions )

def __getExcludedSetMembers( self, setNames, *unused ) :

return self.__getSetMembers( setNames ).intersection( ContextAlgo.getVisibleSet( self.getContext() ).exclusions )

def __selectSetMembers( self, *unused ) :

ContextAlgo.setSelectedPaths( self.getContext(), self.__getSetMembers() )
ContextAlgo.setSelectedPaths( self.getContext(), self.__getSetMembers( self.__selectedSetNames() ) )

def __copySetMembers( self, *unused ) :

data = IECore.StringVectorData()

if self.__plug is not None :
data.extend( self.__getSetMembers().paths() )
data.extend( self.__getSetMembers( self.__selectedSetNames() ).paths() )

self.__plug.ancestor( Gaffer.ApplicationRoot ).setClipboardContents( data )

Expand Down
26 changes: 26 additions & 0 deletions python/GafferTest/ContextMonitorTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,31 @@ def testRoot( self ) :
self.assertFalse( a1["sum"] in m.allStatistics() )
self.assertTrue( a2["sum"] in m.allStatistics() )

def testVariableHashes( self ) :

node = GafferTest.AddNode()

context1 = Gaffer.Context()
context1["test"] = 10

context2 = Gaffer.Context()
context2["test"] = 20

with Gaffer.ContextMonitor() as monitor :

with context1 :
node["sum"].getValue()

with context2 :
node["sum"].getValue()

statistics = monitor.plugStatistics( node["sum"] )
hashes = statistics.variableHashes( "test" )
self.assertEqual( len( hashes ), 2 )
self.assertEqual( hashes.get( context1.variableHash( "test" ) ), 2 ) # A hash and a compute
self.assertEqual( hashes.get( context2.variableHash( "test" ) ), 1 ) # Just a hash

self.assertEqual( statistics.variableHashes( "nonExistentVariable" ), {} )

if __name__ == "__main__":
unittest.main()
11 changes: 11 additions & 0 deletions src/Gaffer/ContextMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ using namespace IECore;
using namespace Gaffer;

static ContextMonitor::Statistics g_emptyStatistics;
static ContextMonitor::Statistics::CountingMap g_emptyCountingMap;

//////////////////////////////////////////////////////////////////////////
// ContextMonitor::Statistics
Expand Down Expand Up @@ -75,6 +76,16 @@ size_t ContextMonitor::Statistics::numUniqueValues( IECore::InternedString varia
return 0;
}

const ContextMonitor::Statistics::CountingMap &ContextMonitor::Statistics::variableHashes( IECore::InternedString variableName ) const
{
VariableMap::const_iterator it = m_variables.find( variableName );
if( it != m_variables.end() )
{
return it->second;
}
return g_emptyCountingMap;
}

ContextMonitor::Statistics & ContextMonitor::Statistics::operator += ( const Context *context )
{
m_contexts.insert( context->hash() );
Expand Down
11 changes: 11 additions & 0 deletions src/GafferModule/MonitorBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ list contextMonitorVariableNames( const ContextMonitor::Statistics &s )
return result;
}

dict contextMonitorVariableHashes( const ContextMonitor::Statistics &s, IECore::InternedString variableName )
{
dict result;
for( const auto &[hash, count] : s.variableHashes( variableName ) )
{
result[hash] = count;
}
return result;
}

void annotateWrapper1( Node &root, const PerformanceMonitor &monitor, bool persistent )
{
IECorePython::ScopedGILRelease gilRelease;
Expand Down Expand Up @@ -299,6 +309,7 @@ void GafferModule::bindMonitor()
.def( "numUniqueContexts", &ContextMonitor::Statistics::numUniqueContexts )
.def( "variableNames", &contextMonitorVariableNames )
.def( "numUniqueValues", &ContextMonitor::Statistics::numUniqueValues )
.def( "variableHashes", &contextMonitorVariableHashes )
.def( self == self )
.def( self != self )
;
Expand Down
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

0 comments on commit 0f8b259

Please sign in to comment.