GafferScene::ConstPathMatcherDataPtr Duplicate::computeBranchSet( const ScenePath &parentPath, const IECore::InternedString &setName, const Gaffer::Context *context ) const { ConstPathMatcherDataPtr inputSetData = inPlug()->set( setName ); const PathMatcher &inputSet = inputSetData->readable(); if( inputSet.isEmpty() ) { return outPlug()->setPlug()->defaultValue(); } PathMatcher subTree = inputSet.subTree( targetPlug()->getValue() ); if( subTree.isEmpty() ) { return outPlug()->setPlug()->defaultValue(); } ConstInternedStringVectorDataPtr childNamesData = childNamesPlug()->getValue(); const vector<InternedString> &childNames = childNamesData->readable(); PathMatcherDataPtr resultData = new PathMatcherData; PathMatcher &result = resultData->writable(); ScenePath prefix( 1 ); for( vector<InternedString>::const_iterator it = childNames.begin(), eIt = childNames.end(); it != eIt; ++it ) { prefix.back() = *it; result.addPaths( subTree, prefix ); } return resultData; }
bool SceneGadget::objectAt( const IECore::LineSegment3f &lineInGadgetSpace, GafferScene::ScenePlug::ScenePath &path ) const { std::vector<IECoreGL::HitRecord> selection; { ViewportGadget::SelectionScope selectionScope( lineInGadgetSpace, this, selection, IECoreGL::Selector::IDRender ); renderScene(); } if( !selection.size() ) { return false; } float depthMin = selection[0].depthMin; unsigned int name = selection[0].name; for( const auto &i : selection ) { if( i.depthMin < depthMin ) { depthMin = i.depthMin; name = i.name; } } PathMatcher paths = convertSelection( new UIntVectorData( { name } ) ); if( paths.isEmpty() ) { return false; } path = *PathMatcher::Iterator( paths.begin() ); return true; }