Imath::Box3f Instancer::computeBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const { if( branchPath.size() <= 1 ) { // "/" or "/name" Box3f result; ConstV3fVectorDataPtr p = sourcePoints( parentPath ); if( p ) { ScenePath branchChildPath( branchPath ); if( branchChildPath.size() == 0 ) { branchChildPath.push_back( namePlug()->getValue() ); } BoundUnion unioner( this, branchChildPath, context, p.get() ); parallel_reduce( blocked_range<size_t>( 0, p->readable().size() ), unioner ); result = unioner.result(); } return result; } else { InstanceScope instanceScope( context, branchPath ); return instancePlug()->boundPlug()->getValue(); } }
Imath::M44f Instancer::computeBranchTransform( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const { if( branchPath.size() < 2 ) { // "/" or "/name" return M44f(); } else if( branchPath.size() == 2 ) { // "/name/instanceNumber" int index = instanceIndex( branchPath ); ConstV3fVectorDataPtr p = sourcePoints( parentPath ); return instanceTransform( p.get(), index ); } else { InstanceScope instanceScope( context, branchPath ); return instancePlug()->transformPlug()->getValue(); } }