コード例 #1
0
ファイル: prim.cpp プロジェクト: mplanck/USD
PcpPrimIndex 
UsdPrim::ComputeExpandedPrimIndex() const
{
    // Get the prim index path to compute from the index stored in the prim
    // data. This ensures we get consistent behavior when dealing with 
    // instancing and instance proxies.
    const PcpPrimIndex& cachedPrimIndex = _Prim()->GetPrimIndex();
    if (!cachedPrimIndex.IsValid()) {
        return PcpPrimIndex();
    }
    
    const SdfPath& primIndexPath = cachedPrimIndex.GetPath();
    PcpCache* cache = _GetStage()->_GetPcpCache();
    
    PcpPrimIndexOutputs outputs;
    PcpComputePrimIndex(
        primIndexPath, cache->GetLayerStack(),
        cache->GetPrimIndexInputs().Cull(false), 
        &outputs);

    _GetStage()->_ReportPcpErrors(
        outputs.allErrors, 
        TfStringPrintf(
            "Computing expanded prim index for <%s>", GetPath().GetText()));
    
    return outputs.primIndex;
}
コード例 #2
0
ファイル: interfaceAttribute.cpp プロジェクト: 400dama/USD
static std::string
_GetRelPrefix(const TfToken& renderTarget)
{
    return TfStringPrintf("%s:%s", 
            renderTarget.GetText(),
            _tokens->interfaceRecipientsOf.GetText());
}
コード例 #3
0
ファイル: primData.cpp プロジェクト: JT-a/USD
std::string
Usd_DescribePrimData(const Usd_PrimData *p)
{
    if (!p)
        return "null prim";

    return TfStringPrintf(
        "%s%sprim <%s> %s",
        Usd_IsDead(p) ? "expired " : (p->_flags[Usd_PrimActiveFlag] ?
                                      "" : "inactive "),
        p->_typeName.IsEmpty() ? "" :
            TfStringPrintf("'%s' ", p->_typeName.GetText()).c_str(),
        p->_path.GetText(),
        p->_stage ? TfStringPrintf(
            "on stage %s", UsdDescribe(p->_stage).c_str()).c_str() : "");
}
コード例 #4
0
std::string
NdrProperty::GetInfoString() const
{
    return TfStringPrintf(
        "%s (type: '%s'); %s",
        _name.GetText(), _type.GetText(), _isOutput ? "output" : "input"
    );
}
コード例 #5
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorMutedAssetPath::ToString() const
{
    return TfStringPrintf("Asset @%s@ was muted for %s on prim %s.",
                          resolvedAssetPath.c_str(), 
                          TfEnum::GetDisplayName(arcType).c_str(), 
                          TfStringify(site).c_str());
}
コード例 #6
0
ファイル: adaptor.cpp プロジェクト: PixarAnimationStudios/USD
PXR_NAMESPACE_OPEN_SCOPE

static std::string
_GetMayaAttrNameForMetadataKey(const TfToken& key)
{
    return TfStringPrintf("USD_%s",
            TfMakeValidIdentifier(key.GetString()).c_str());
}
コード例 #7
0
ファイル: streamOut.cpp プロジェクト: 400dama/USD
std::ostream &
Vt_StreamOutGeneric(std::type_info const &type,
                    void const *addr,
                    std::ostream &stream)
{
    return stream <<
        TfStringPrintf("<'%s' @ %p>", ArchGetDemangled(type).c_str(), addr);
}
コード例 #8
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInvalidAssetPath::ToString() const
{
    return TfStringPrintf("Could not open asset @%s@ for %s on prim %s.",
                          resolvedAssetPath.c_str(), 
                          TfEnum::GetDisplayName(arcType).c_str(), 
                          TfStringify(site).c_str());
}
コード例 #9
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInternalAssetPath::ToString() const
{
    return TfStringPrintf("Ignoring %s path on prim <%s> because asset @%s@ "
                          "is internal.",
                          TfEnum::GetDisplayName(arcType).c_str(), 
                          site.path.GetText(), resolvedAssetPath.c_str()); 
}
コード例 #10
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInvalidPrimPath::ToString() const
{
    return TfStringPrintf("Invalid %s path <%s> on prim %s "
                          "-- must be a root prim path.", 
                          TfEnum::GetDisplayName(arcType).c_str(), 
                          primPath.GetText(),
                          TfStringify(site).c_str());
}
コード例 #11
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInvalidSublayerOffset::ToString() const
{
    return TfStringPrintf("Invalid sublayer offset %s in sublayer @%s@ of "
                          "layer @%s@. Using no offset instead.", 
                          TfStringify(offset).c_str(), 
                          sublayer->GetIdentifier().c_str(), 
                          layer->GetIdentifier().c_str());
}
コード例 #12
0
ファイル: animQuery.cpp プロジェクト: lvxejay/USD
std::string
UsdSkelAnimQuery::GetDescription() const
{
    if(_impl) {
        return TfStringPrintf("UsdSkelAnimQuery <%s>",
                              _impl->GetPrim().GetPath().GetText());
    }
    return "invalid UsdSkelAnimQuery";
}
コード例 #13
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInvalidReferenceOffset::ToString() const
{
    return TfStringPrintf("Invalid reference offset %s at %s on "
                          "asset path '%s'. Using no offset instead.", 
                          TfStringify(offset).c_str(),
                          TfStringify(PcpSite(layer, sourcePath)).c_str(),
                          assetPath.c_str());
}
コード例 #14
0
ファイル: mesh.cpp プロジェクト: mplanck/USD
// For now, this is only used by the mesh op.  If this logic needs to be
// accessed elsewhere, it should move down into usdKatana.
static void 
_CreateFaceSetsFromFaceSetAPI(
        const UsdPrim& prim,
        const PxrUsdKatanaUsdInPrivateData &data,
        FnKat::GeolibCookInterface& interface)
{
    UsdGeomFaceSetAPI faceSet = UsdShadeMaterial::GetMaterialFaceSet(prim);
    bool isPartition = faceSet.GetIsPartition();;
    if (!isPartition) {
        TF_WARN("Found face set on prim <%s> that is not a partition.", 
                prim.GetPath().GetText());
        // continue here?
    }

    const double currentTime = data.GetCurrentTime();

    VtIntArray faceCounts, faceIndices;
    faceSet.GetFaceCounts(&faceCounts, currentTime);
    faceSet.GetFaceIndices(&faceIndices, currentTime);

    SdfPathVector bindingTargets;
    faceSet.GetBindingTargets(&bindingTargets);

    size_t faceSetIdxStart = 0;
    for(size_t faceSetIdx = 0; faceSetIdx < faceCounts.size(); ++faceSetIdx) {
        size_t faceCount = faceCounts[faceSetIdx];

        FnKat::GroupBuilder faceSetAttrs;

        faceSetAttrs.set("type", FnKat::StringAttribute("faceset"));
        faceSetAttrs.set("materialAssign", FnKat::StringAttribute(
            PxrUsdKatanaUtils::ConvertUsdMaterialPathToKatLocation(
                bindingTargets[faceSetIdx], data)));

        FnKat::IntBuilder facesBuilder;
        {
            std::vector<int> faceIndicesVec(faceCount);
            for (size_t faceIndicesIdx = 0; faceIndicesIdx < faceCount; ++faceIndicesIdx)
            {
                faceIndicesVec[faceIndicesIdx] = 
                    faceIndices[faceSetIdxStart + faceIndicesIdx];
            }
            faceSetIdxStart += faceCount;
            facesBuilder.set(faceIndicesVec);
        }
        faceSetAttrs.set("geometry.faces", facesBuilder.build());

        std::string faceSetName = TfStringPrintf("faceset_%zu", faceSetIdx);

        FnKat::GroupBuilder staticSceneCreateAttrs;
        staticSceneCreateAttrs.set("a", faceSetAttrs.build());
        interface.createChild(
            faceSetName,
            "StaticSceneCreate",
            staticSceneCreateAttrs.build());
    }
}
コード例 #15
0
ファイル: skeletonQuery.cpp プロジェクト: rodeofx/USD
std::string
UsdSkelSkeletonQuery::GetDescription() const
{
    if(IsValid()) {
        return TfStringPrintf(
            "UsdSkelSkeletonQuery (skel = <%s>, anim = <%s>)",
            GetPrim().GetPath().GetText(),
            _animQuery.GetPrim().GetPath().GetText());
    }
    return "invalid UsdSkelSkeletonQuery";
}
コード例 #16
0
ファイル: interfaceAttribute.cpp プロジェクト: 400dama/USD
/* static */ TfToken
UsdShadeInterfaceAttribute::_GetName(
        const TfToken& interfaceAttrName)
{
    if (TfStringStartsWith(interfaceAttrName, _tokens->interface)) {
        return interfaceAttrName;
    }
    
    return TfToken(TfStringPrintf("%s%s",
            _tokens->interface.GetText(),
            interfaceAttrName.GetText()));
}
コード例 #17
0
ファイル: writeUtil.cpp プロジェクト: MWDD/USD
/* static */
UsdAttribute PxrUsdMayaWriteUtil::GetOrCreateUsdRiAttribute(
        const MPlug& attrPlug,
        const UsdPrim& usdPrim,
        const std::string& attrName,
        const std::string& nameSpace,
        const bool translateMayaDoubleToUsdSinglePrecision)
{
    UsdAttribute usdAttr;

    if (!usdPrim) {
        return usdAttr;
    }

    MObject attrObj(attrPlug.attribute());

    TfToken riAttrNameToken(attrName);
    if (riAttrNameToken.IsEmpty()) {
        MGlobal::displayError(
            TfStringPrintf("Invalid UsdRi attribute name '%s' for Maya plug '%s'",
                           attrName.c_str(),
                           attrPlug.name().asChar()).c_str());
        return usdAttr;
    }

    UsdRiStatements riStatements(usdPrim);
    if (!riStatements) {
        return usdAttr;
    }

    // See if a UsdRi attribute with this name already exists. If so, return it.
    // XXX: There isn't currently API for looking for a specific UsdRi attribute
    // by name, so we have to get them all and then see if one matches.
    const std::vector<UsdProperty>& riAttrs = riStatements.GetRiAttributes(nameSpace);
    TF_FOR_ALL(iter, riAttrs) {
        if (iter->GetBaseName() == riAttrNameToken) {
            // Re-get the attribute from the prim so we can return it as a
            // UsdAttribute rather than a UsdProperty.
            return usdPrim.GetAttribute(iter->GetName());
        }
    }

    const SdfValueTypeName& typeName =
        PxrUsdMayaWriteUtil::GetUsdTypeName(attrPlug,
                                            translateMayaDoubleToUsdSinglePrecision);
    if (typeName) {
        usdAttr = riStatements.CreateRiAttribute(riAttrNameToken,
                                                 typeName.GetType(),
                                                 nameSpace);
    }

    return usdAttr;
}
コード例 #18
0
ファイル: topology.cpp プロジェクト: lvxejay/USD
bool
UsdSkelTopology::Validate(std::string* reason) const
{
    TRACE_FUNCTION();

    if(!TF_VERIFY(GetNumJoints() == 0 || _parentIndicesData))
        return false;

    for(size_t i = 0; i < GetNumJoints(); ++i) {
        int parent = _parentIndicesData[i];
        if(parent >= 0) {   
            if(ARCH_UNLIKELY(static_cast<size_t>(parent) >= i)) {
                if(static_cast<size_t>(parent) == i) {
                    if(reason) {
                        *reason = TfStringPrintf(
                            "Joint %zu has itself as its parent.", i);
                    }
                    return false;
                }

                if(reason) {
                    *reason = TfStringPrintf(
                        "Joint %zu has mis-ordered parent %d. Joints are "
                        "expected to be ordered with parent joints always "
                        "coming before children.", i, parent);

                    // XXX: Note that this ordering restriction is a schema
                    // requirement primarily because it simplifies hierarchy
                    // evaluation (see UsdSkelConcatJointTransforms)
                    // But a nice side effect for validation purposes is that
                    // it also ensures that topology is non-cyclic.
                }
                return false;
            }
        }
    }
    return true;
}
コード例 #19
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInvalidInstanceTargetPath::ToString() const
{
    TF_VERIFY(ownerSpecType == SdfSpecTypeAttribute ||
              ownerSpecType == SdfSpecTypeRelationship);
    return TfStringPrintf(
        "The %s <%s> from <%s> in layer @%s@ is authored in a class "
        "but refers to an instance of that class.  Ignoring.",
        (ownerSpecType == SdfSpecTypeAttribute
            ? "attribute connection"
            : "relationship target"),
        targetPath.GetText(),
        owningPath.GetText(),
        layer->GetIdentifier().c_str());
}
コード例 #20
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInconsistentAttributeType::ToString() const
{
    return TfStringPrintf(
        "The attribute <%s> has specs with inconsistent value types.  "
        "The defining spec is @%s@<%s> with value type '%s'.  "
        "The conflicting spec is @%s@<%s> with value type '%s'.  " 
        "The conflicting spec will be ignored.",
        rootSite.path.GetString().c_str(),
        definingLayerIdentifier.c_str(),
        definingSpecPath.GetString().c_str(),
        definingValueType.GetText(),
        conflictingLayerIdentifier.c_str(),
        conflictingSpecPath.GetString().c_str(),
        conflictingValueType.GetText());
}
コード例 #21
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInconsistentAttributeVariability::ToString() const
{
    return TfStringPrintf(
        "The attribute <%s> has specs with inconsistent variability.  "
        "The defining spec is @%s@<%s> with variability '%s'.  The "
        "conflicting spec is @%s@<%s> with variability '%s'.  The "
        "conflicting variability will be ignored.",
        rootSite.path.GetString().c_str(),
        definingLayerIdentifier.c_str(),
        definingSpecPath.GetString().c_str(),
        TfEnum::GetName(definingVariability).c_str(),
        conflictingLayerIdentifier.c_str(),
        conflictingSpecPath.GetString().c_str(),
        TfEnum::GetName(conflictingVariability).c_str());
}
コード例 #22
0
ファイル: parserHelpers.cpp プロジェクト: JT-a/USD
inline VtValue
MakeScalarValueTemplate(vector<unsigned int> const &,
                        vector<Value> const &vars, size_t &index,
                        string *errStrPtr) {
    T t;
    size_t origIndex = index;
    try {
        MakeScalarValueImpl(&t, vars, index);
    } catch (const boost::bad_get &) {
        *errStrPtr = TfStringPrintf("Failed to parse value (at sub-part %zd "
                                    "if there are multiple parts)",
                                    (index - origIndex) - 1);
        return VtValue();
    }
    return VtValue(t);
}
コード例 #23
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInvalidTargetPath::ToString() const
{
    TF_VERIFY(ownerSpecType == SdfSpecTypeAttribute ||
              ownerSpecType == SdfSpecTypeRelationship);
    return TfStringPrintf(
        "The %s <%s> from <%s> in layer @%s@ is invalid.  This may be "
        "because the path is the pre-relocated source path of a "
        "relocated prim.  Ignoring.",
        (ownerSpecType == SdfSpecTypeAttribute
            ? "attribute connection"
            : "relationship target"),
        targetPath.GetText(),
        owningPath.GetText(),
        layer->GetIdentifier().c_str());
}
コード例 #24
0
ファイル: value.cpp プロジェクト: 400dama/USD
static bool
_CheckType(
    const JsValue::Type& heldType,
    const JsValue::Type& requestedType,
    std::string* whyNot)
{
    if (heldType != requestedType) {
        if (whyNot) {
            *whyNot = TfStringPrintf(
                "Attempt to get %s from value holding %s",
                _GetTypeName(requestedType).c_str(),
                _GetTypeName(heldType).c_str());
        }
        return false;
    }
    return true;
}
コード例 #25
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInvalidExternalTargetPath::ToString() const
{
    TF_VERIFY(ownerSpecType == SdfSpecTypeAttribute ||
              ownerSpecType == SdfSpecTypeRelationship);
    return TfStringPrintf("The %s <%s> from <%s> in layer @%s@ refers "
                          "to a path outside the scope of the %s from <%s>.  "
                          "Ignoring.",
                          (ownerSpecType == SdfSpecTypeAttribute
                           ? "attribute connection"
                           : "relationship target"),
                          targetPath.GetText(), 
                          owningPath.GetText(),
                          layer->GetIdentifier().c_str(),
                          TfEnum::GetDisplayName(TfEnum(ownerArcType)).c_str(),
                          ownerIntroPath.GetText());
}
コード例 #26
0
ファイル: writeUtil.cpp プロジェクト: MWDD/USD
/* static */
UsdGeomPrimvar PxrUsdMayaWriteUtil::GetOrCreatePrimvar(
        const MPlug& attrPlug,
        UsdGeomImageable& imageable,
        const std::string& primvarName,
        const TfToken& interpolation,
        const int elementSize,
        const bool custom,
        const bool translateMayaDoubleToUsdSinglePrecision)
{
    UsdGeomPrimvar primvar;

    if (!imageable) {
        return primvar;
    }

    MObject attrObj(attrPlug.attribute());

    TfToken primvarNameToken(primvarName);
    if (primvarNameToken.IsEmpty()) {
        MGlobal::displayError(
            TfStringPrintf("Invalid primvar name '%s' for Maya plug '%s'",
                           primvarName.c_str(),
                           attrPlug.name().asChar()).c_str());
        return primvar;
    }

    // See if the primvar already exists. If so, return it.
    primvar = imageable.GetPrimvar(primvarNameToken);
    if (primvar) {
        return primvar;
    }

    const SdfValueTypeName& typeName =
        PxrUsdMayaWriteUtil::GetUsdTypeName(attrPlug,
                                            translateMayaDoubleToUsdSinglePrecision);
    if (typeName) {
        primvar = imageable.CreatePrimvar(primvarNameToken,
                                          typeName,
                                          interpolation,
                                          elementSize,
                                          custom);
    }

    return primvar;
}
コード例 #27
0
ファイル: errors.cpp プロジェクト: JT-a/USD
// virtual
std::string
PcpErrorInconsistentPropertyType::ToString() const
{
    return TfStringPrintf(
        "The property <%s> has inconsistent spec types.  "
        "The defining spec is @%s@<%s> and is %s spec.  "
        "The conflicting spec is @%s@<%s> and is %s spec.  "
        "The conflicting spec will be ignored.",
        rootSite.path.GetString().c_str(),
        definingLayerIdentifier.c_str(),
        definingSpecPath.GetString().c_str(),
        (definingSpecType == SdfSpecTypeAttribute ? 
            "an attribute" : "a relationship"),
        conflictingLayerIdentifier.c_str(),
        conflictingSpecPath.GetString().c_str(),
        (conflictingSpecType == SdfSpecTypeAttribute ? 
            "an attribute" : "a relationship"));
}
コード例 #28
0
ファイル: writeUtil.cpp プロジェクト: MWDD/USD
/* static */
UsdAttribute
PxrUsdMayaWriteUtil::GetOrCreateUsdAttr(
        const MPlug& attrPlug,
        const UsdPrim& usdPrim,
        const std::string& attrName,
        const bool custom,
        const bool translateMayaDoubleToUsdSinglePrecision)
{
    UsdAttribute usdAttr;

    if (!usdPrim) {
        return usdAttr;
    }

    MObject attrObj(attrPlug.attribute());

    TfToken usdAttrNameToken(attrName);
    if (usdAttrNameToken.IsEmpty()) {
        MGlobal::displayError(
            TfStringPrintf("Invalid USD attribute name '%s' for Maya plug '%s'",
                           attrName.c_str(),
                           attrPlug.name().asChar()).c_str());
        return usdAttr;
    }

    // See if the USD attribute already exists. If so, return it.
    usdAttr = usdPrim.GetAttribute(usdAttrNameToken);
    if (usdAttr) {
        return usdAttr;
    }

    const SdfValueTypeName& typeName =
        PxrUsdMayaWriteUtil::GetUsdTypeName(attrPlug,
                                            translateMayaDoubleToUsdSinglePrecision);
    if (typeName) {
        usdAttr = usdPrim.CreateAttribute(usdAttrNameToken, typeName, custom);
    }

    return usdAttr;
}
コード例 #29
0
ファイル: batchRenderer.cpp プロジェクト: JT-a/USD
UsdMayaGLBatchRenderer::TaskDelegate::TaskDelegate(
    HdRenderIndex *renderIndex, SdfPath const& delegateID)
    : HdSceneDelegate(renderIndex, delegateID)
{
    _lightingContext = GlfSimpleLightingContext::New();

    // populate tasks in renderindex

    // create an unique namespace
    _rootId = delegateID.AppendChild(
        TfToken(TfStringPrintf("_UsdImaging_%p", this)));

    _simpleLightTaskId          = _rootId.AppendChild(_tokens->simpleLightTask);
    _cameraId                   = _rootId.AppendChild(_tokens->camera);

    // camera
    {
        // Since we're hardcoded to use HdStRenderDelegate, we expect to
        // have camera Sprims.
        TF_VERIFY(renderIndex->IsSprimTypeSupported(HdPrimTypeTokens->camera));

        renderIndex->InsertSprim(HdPrimTypeTokens->camera, this, _cameraId);
        _ValueCache &cache = _valueCacheMap[_cameraId];
        cache[HdStCameraTokens->worldToViewMatrix] = VtValue(GfMatrix4d(1.0));
        cache[HdStCameraTokens->projectionMatrix] = VtValue(GfMatrix4d(1.0));
        cache[HdStCameraTokens->windowPolicy] = VtValue();  // no window policy.
    }

    // simple lighting task (for Hydra native)
    {
        renderIndex->InsertTask<HdxSimpleLightTask>(this, _simpleLightTaskId);
        _ValueCache &cache = _valueCacheMap[_simpleLightTaskId];
        HdxSimpleLightTaskParams taskParams;
        taskParams.cameraPath = _cameraId;
        cache[HdTokens->params] = VtValue(taskParams);
        cache[HdTokens->children] = VtValue(SdfPathVector());
    }
}
コード例 #30
0
ファイル: usdInPluginRegistry.cpp プロジェクト: mplanck/USD
/* static */
bool 
PxrUsdKatanaUsdInPluginRegistry::_DoFindKind(
        const TfToken& kind,
        std::string* opName,
        const _KindRegistry& reg)
{
    // can cache this if it becomes an issue.
    TfToken currKind = kind;
    while (!currKind.IsEmpty()) {
        if (TfMapLookup(reg, currKind, opName)) {
            return true;
        }
        if (KindRegistry::HasKind(currKind)) {
            currKind = KindRegistry::GetBaseKind(currKind);
        }
        else {
            FnLogWarn(TfStringPrintf("Unknown kind: '%s'", currKind.GetText()));
            return false;
        }
    }

    return false;
}