コード例 #1
0
void OBJ_SceneCacheTransform::expandHierarchy( const SceneInterface *scene )
{
	if ( !scene )
	{
		return;
	}

	Parameters params;
	params.geometryType = getGeometryType();
	params.depth = (Depth)evalInt( pDepth.getToken(), 0, 0 );
	params.hierarchy = (Hierarchy)evalInt( pHierarchy.getToken(), 0, 0 );
	params.tagGroups = getTagGroups();
	getAttributeFilter( params.attributeFilter );
	getAttributeCopy( params.attributeCopy );
	getShapeFilter( params.shapeFilter );
	getTagFilter( params.tagFilterStr );
	getTagFilter( params.tagFilter );
	getFullPathName( params.fullPathName );

	if ( params.hierarchy == FlatGeometry )
	{
		// Collapse first, in case the immediate object was already created on during parent expansion
		collapseHierarchy();
		doExpandObject( scene, this, params );
		setInt( pExpanded.getToken(), 0, 0, 1 );
		return;
	}

	OBJ_Node *rootNode = this;
	if ( scene->hasObject() )
	{
		Parameters rootParams( params );
		rootParams.hierarchy = SubNetworks;
		rootParams.depth = Children;
		OBJ_Node *objNode = doExpandObject( scene, this, rootParams );
		if ( params.hierarchy == Parenting )
		{
			rootNode = objNode;
		}
	}
	else if ( params.hierarchy == Parenting )
	{
		/// \todo: this is terrible. can we use the subnet input instead?
		rootNode = reinterpret_cast<OBJ_Node*>( createNode( "geo", "TMP" ) );
	}

	if ( params.hierarchy == Parenting )
	{
		rootNode->setIndirectInput( 0, this->getParentInput( 0 ) );
	}

	UT_Interrupt *progress = UTgetInterrupt();
	if ( !progress->opStart( ( "Expand Hierarchy for " + getPath() ).c_str() ) )
	{
		return;
	}

	doExpandChildren( scene, rootNode, params );
	setInt( pExpanded.getToken(), 0, 0, 1 );

	if ( params.hierarchy == Parenting && !scene->hasObject() )
	{
		destroyNode( rootNode );
	}

	progress->opEnd();
}