@@ -1121,17 +1121,22 @@ bool SceneShapeSubSceneOverride::requiresUpdate(const MSubSceneContainer& contai
11211121 {
11221122 allInvisibleByFilter = true ;
11231123
1124- MObject component;
1125- MSelectionList viewSelectedSet ;
1126- view.filteredObjectList ( viewSelectedSet );
1124+ // Create a selection list of the dagPaths which are visible after the view is filtered
1125+ MSelectionList visibleList ;
1126+ view.filteredObjectList ( visibleList );
11271127
1128- for ( size_t i = 0 ; i < dagPaths.length (); ++i )
1128+ // Create a selection list with all of our dag paths
1129+ MSelectionList dagPathList;
1130+ for ( const auto &dagPath : dagPaths )
11291131 {
1130- if ( viewSelectedSet.hasItemPartly ( dagPaths[i], component ) )
1131- {
1132- allInvisibleByFilter = false ;
1133- break ;
1134- }
1132+ dagPathList.add ( dagPath );
1133+ }
1134+
1135+ // Intersect the two lists to determine if any of our dag paths remain unfiltered
1136+ visibleList.intersect ( dagPathList, true );
1137+ if ( !visibleList.isEmpty () )
1138+ {
1139+ allInvisibleByFilter = false ;
11351140 }
11361141 }
11371142
@@ -1360,22 +1365,31 @@ void SceneShapeSubSceneOverride::update( MSubSceneContainer& container, const MF
13601365 M3dView view;
13611366 MString panelName;
13621367 MSelectionList viewSelectedSet;
1363- MObject component;
13641368 frameContext.renderingDestination ( panelName );
13651369 M3dView::getM3dViewFromModelPanel ( panelName, view );
13661370 view.filteredObjectList ( viewSelectedSet );
13671371
13681372 bool allInvisibleByFilter = false ;
1369- if ( view.viewIsFiltered () )
1373+ if ( view.viewIsFiltered () )
13701374 {
13711375 allInvisibleByFilter = true ;
1372- for ( auto &instance : m_instances )
1376+
1377+ // Create a selection list of the dagPaths which are visible after the view is filtered
1378+ MSelectionList visibleList;
1379+ view.filteredObjectList ( visibleList );
1380+
1381+ // Create a selection list with all of our dag paths
1382+ MSelectionList dagPathList;
1383+ for ( const auto &instance : m_instances )
13731384 {
1374- if ( viewSelectedSet.hasItemPartly ( instance.path , component ) )
1375- {
1376- allInvisibleByFilter = false ;
1377- break ;
1378- }
1385+ dagPathList.add ( instance.path );
1386+ }
1387+
1388+ // Intersect the two lists to determine if any of our dag paths remain unfiltered
1389+ visibleList.intersect ( dagPathList, true );
1390+ if ( !visibleList.isEmpty () )
1391+ {
1392+ allInvisibleByFilter = false ;
13791393 }
13801394 }
13811395
@@ -1404,6 +1418,16 @@ void SceneShapeSubSceneOverride::visitSceneLocations( const SceneInterface *scen
14041418 return ;
14051419 }
14061420
1421+ // respect visibility attribute
1422+ if ( sceneInterface->hasAttribute ( SceneInterface::visibilityName ) )
1423+ {
1424+ ConstBoolDataPtr vis = runTimeCast<const BoolData>( sceneInterface->readAttribute ( SceneInterface::visibilityName, m_time ) );
1425+ if ( vis && !vis->readable () )
1426+ {
1427+ return ;
1428+ }
1429+ }
1430+
14071431 MMatrix accumulatedMatrix;
14081432 if ( !isRoot )
14091433 {
@@ -1430,7 +1454,6 @@ void SceneShapeSubSceneOverride::visitSceneLocations( const SceneInterface *scen
14301454 }
14311455
14321456 // Now handle current location.
1433-
14341457 if ( isRoot )
14351458 {
14361459 // override relative location for root as it would otherwise be empty
@@ -1469,16 +1492,6 @@ void SceneShapeSubSceneOverride::visitSceneLocations( const SceneInterface *scen
14691492 return ;
14701493 }
14711494
1472- // respect visibility attribute
1473- if ( sceneInterface->hasAttribute ( " scene:visible" ) )
1474- {
1475- ConstBoolDataPtr vis = runTimeCast<const BoolData>( sceneInterface->readAttribute ( " scene:visible" , m_time ) );
1476- if ( vis && !vis->readable () )
1477- {
1478- return ;
1479- }
1480- }
1481-
14821495 IECore::ConstObjectPtr object = sceneInterface->readObject ( m_time );
14831496 if ( !objectCanBeRendered ( object ) )
14841497 {
@@ -1924,16 +1937,15 @@ void SceneShapeSubSceneOverride::collectInstances( Instances &instances ) const
19241937 MDagPathArray dagPaths;
19251938 dagNode.getAllPaths (dagPaths);
19261939 size_t numInstances = dagPaths.length ();
1927-
19281940 instances.reserve ( numInstances );
1941+
19291942 for ( size_t pathIndex = 0 ; pathIndex < numInstances; ++pathIndex )
19301943 {
19311944 MDagPath& path = dagPaths[pathIndex];
19321945 MMatrix matrix = path.inclusiveMatrix ();
19331946 bool pathSelected = isPathSelected ( selectionList, path );
19341947 bool componentMode = componentsSelectable ( path );
1935- MFnDagNode nodeFn ( path );
1936- bool visible = path.isVisible ();
1948+ bool visible = IECoreMaya::SceneShapeInterface::isVisible ( path );
19371949
19381950 instances.emplace_back ( matrix, pathSelected, componentMode, path, visible );
19391951 }
0 commit comments