bool
SdfNamespaceEdit_Namespace::_IsDeadspace(const SdfPath& path) const
{
    SdfPathSet::iterator i = _deadspace.upper_bound(path);
    if (i == _deadspace.begin()) {
        return false;
    }
    return path.HasPrefix(*--i);
}
Beispiel #2
0
 void    GetUnloaded(const UnorderedPathSet& paths, SdfPathSet& unloaded)
         {
             for(const auto& path : paths) {
                 if(!IsLoaded(path))
                     unloaded.insert(path);
             }
         }
Beispiel #3
0
    bool    LoadIfNeeded(ScopedLock& lock, const UnorderedPathSet& paths,
                         const UsdStageRefPtr& stage, bool haveLock)
            {
                UT_ASSERT(stage);

                SdfPathSet unloaded;
                GetUnloaded(paths, unloaded);

                if(unloaded.size() == 0)
                    return false;

                if(!haveLock)
                    lock.UpgradeToWriter();
                
                Load(unloaded, stage);
                return true;
            }
void
SdfNamespaceEdit_Namespace::_RemoveDeadspace(const SdfPath& path)
{
    // Never remove the absolute root path.
    if (!TF_VERIFY(path != SdfPath::AbsoluteRootPath())) {
        return;
    }

    // Find the extent of the subtree with path as a prefix.
    SdfPathSet::iterator i = _deadspace.lower_bound(path);
    SdfPathSet::iterator n = i;
    while (n != _deadspace.end() && n->HasPrefix(path)) {
        ++n;
    }

    // Remove the subtree.
    _deadspace.erase(i, n);
}
void
SdfNamespaceEdit_Namespace::_AddDeadspace(const SdfPath& path)
{
    // Never add the absolute root path.
    if (!TF_VERIFY(path != SdfPath::AbsoluteRootPath())) {
        return;
    }

    _RemoveDeadspace(path);
    _deadspace.insert(path);
}
PxrUsdMayaShadingModeExportContext::AssignmentVector
PxrUsdMayaShadingModeExportContext::GetAssignments() const
{
    AssignmentVector ret;

    MStatus status;
    MFnDependencyNode seDepNode(_shadingEngine, &status);
    if (!status) {
        return ret;
    }

    MPlug dsmPlug = seDepNode.findPlug("dagSetMembers", true, &status);
    if (!status) {
        return ret;
    }

    SdfPathSet seenBoundPrimPaths;
    for (unsigned int i = 0; i < dsmPlug.numConnectedElements(); i++) {
        MPlug dsmElemPlug(dsmPlug.connectionByPhysicalIndex(i));
        MStatus status = MS::kFailure;
        MFnDagNode dagNode(PxrUsdMayaUtil::GetConnected(dsmElemPlug).node(), &status);
        if (!status) {
            continue;
        }

        MDagPath dagPath;
        if (!dagNode.getPath(dagPath))
            continue;

        SdfPath usdPath = PxrUsdMayaUtil::MDagPathToUsdPath(dagPath, 
            _mergeTransformAndShape);

        // If _overrideRootPath is not empty, replace the root namespace with it
        if (!_overrideRootPath.IsEmpty() ) {
            usdPath = usdPath.ReplacePrefix(usdPath.GetPrefixes()[0], _overrideRootPath);
        }
        
        // If this path has already been processed, skip it.
        if (!seenBoundPrimPaths.insert(usdPath).second)
            continue;

        // If the bound prim's path is not below a bindable root, skip it.
        if (SdfPathFindLongestPrefix(_bindableRoots.begin(), 
            _bindableRoots.end(), usdPath) == _bindableRoots.end()) {
            continue;
        }

        MObjectArray sgObjs, compObjs;
        // Assuming that instancing is not involved.
        status = dagNode.getConnectedSetsAndMembers(0, sgObjs, compObjs, true);
        if (!status)
            continue;

        for (size_t j = 0; j < sgObjs.length(); j++) {
            // If the shading group isn't the one we're interested in, skip it.
            if (sgObjs[j] != _shadingEngine)
                continue;

            VtIntArray faceIndices;
            if (!compObjs[j].isNull()) {
                MItMeshPolygon faceIt(dagPath, compObjs[j]);
                faceIndices.reserve(faceIt.count());
                for ( faceIt.reset() ; !faceIt.isDone() ; faceIt.next() ) {
                    faceIndices.push_back(faceIt.index());
                }
            }
            ret.push_back(std::make_pair(usdPath, faceIndices));
        }
    }
    return ret;
}