コード例 #1
0
UsdGeomPrimvar
UsdGeomPrimvarsAPI::FindPrimvarWithInheritance(const TfToken &name,
                                               const std::vector<UsdGeomPrimvar>
                                               &inheritedFromAncestors) const
{
    TRACE_FUNCTION();

    const UsdPrim &prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("FindPrimvarWithInheritance called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return UsdGeomPrimvar();
    }
    const TfToken attrName = UsdGeomPrimvar::_MakeNamespaced(name);
    UsdGeomPrimvar  pv = GetPrimvar(attrName);
    if (pv.HasAuthoredValue()){
        return pv;
    }
    
    for (UsdGeomPrimvar const &inherited : inheritedFromAncestors) {
        if (inherited.GetName() == attrName){
            return inherited;
        }
    }

    return pv;
}
コード例 #2
0
bool
UsdGeomPrimvarsAPI::HasPossiblyInheritedPrimvar(const TfToken &name) const
{
    TRACE_FUNCTION();

    UsdPrim prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("HasPossiblyInheritedPrimvar called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return false;
    }
    UsdGeomPrimvar  pv = GetPrimvar(name);
    if (pv.HasAuthoredValue()){
        return true;
    }

    const TfToken attrName = UsdGeomPrimvar::_MakeNamespaced(name);
    if (attrName.IsEmpty()) {
        return false;
    }
    for (prim = prim.GetParent(); prim && !prim.IsPseudoRoot();
         prim = prim.GetParent()) {
        UsdAttribute attr = prim.GetAttribute(attrName);
        if (attr.HasAuthoredValue() && UsdGeomPrimvar::IsPrimvar(attr)) {
            // Only constant primvars can be inherited.
            // Non-constant interpolation blocks inheritance.
            return UsdGeomPrimvar(attr).GetInterpolation()
                == UsdGeomTokens->constant;
        }
    }
    return false;
}
コード例 #3
0
UsdGeomPrimvar 
UsdGeomPrimvarsAPI::FindPrimvarWithInheritance(const TfToken &name) const
{
    TRACE_FUNCTION();

    const TfToken attrName = UsdGeomPrimvar::_MakeNamespaced(name);
    UsdPrim prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("FindPrimvarWithInheritance called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return UsdGeomPrimvar();
    }
    UsdGeomPrimvar  localPv = GetPrimvar(name);
    if (localPv.HasAuthoredValue()){
        return localPv;
    }
    
    for (prim = prim.GetParent(); prim && !prim.IsPseudoRoot();
         prim = prim.GetParent()) {
        UsdAttribute attr = prim.GetAttribute(attrName);
        if (attr.HasAuthoredValue()) {
            if (UsdGeomPrimvar pv = UsdGeomPrimvar(attr)) {
                // Only constant primvars can be inherited.
                if (pv.GetInterpolation() == UsdGeomTokens->constant) {
                    return pv;
                } else {
                    // Non-constant interpolation blocks inheritance.
                    return UsdGeomPrimvar();
                }
            }
        }
    }
    return localPv;
}
コード例 #4
0
bool
UsdGeomPrimvarsAPI::HasPrimvar(const TfToken &name) const
{
    TfToken primvarName = UsdGeomPrimvar::_MakeNamespaced(name, /* quiet */true);
    const UsdPrim &prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("HasPrimvar called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return false;
    }
    return primvarName.IsEmpty() ? false : 
        UsdGeomPrimvar::IsPrimvar(prim.GetAttribute(primvarName));
}
コード例 #5
0
std::vector<UsdGeomPrimvar> 
UsdGeomPrimvarsAPI::GetPrimvarsWithValues() const
{
    const UsdPrim &prim = GetPrim();
    if (!prim){
        TF_CODING_ERROR("Called GetPrimvarsWithValues on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return std::vector<UsdGeomPrimvar>();
    }
    return _MakePrimvars(prim.GetAuthoredPropertiesInNamespace(
                             UsdGeomPrimvar::_GetNamespacePrefix()),
                         [](UsdGeomPrimvar const &pv) { return pv.HasValue(); });
}
コード例 #6
0
ファイル: primData.cpp プロジェクト: 400dama/USD
std::string
Usd_DescribePrimData(const Usd_PrimData *p)
{
    if (not 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() : "");
}
コード例 #7
0
std::vector<UsdGeomPrimvar>
UsdGeomPrimvarsAPI::FindInheritablePrimvars() const
{
    TRACE_FUNCTION();
    // Assume the number of primvars is relatively bounded and
    // just use a vector to accumulate primvars up to the root prim.
    std::vector<UsdGeomPrimvar> primvars;
    const UsdPrim &prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("FindInheritablePrimvars called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return primvars;
    }

    TfToken const& prefix = UsdGeomPrimvar::_GetNamespacePrefix();
    _RecurseForInheritablePrimvars(prim, prefix, &primvars);

    return primvars;
}
コード例 #8
0
std::vector<UsdGeomPrimvar> 
UsdGeomPrimvarsAPI::FindIncrementallyInheritablePrimvars(
    const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const
{
    TRACE_FUNCTION();

    std::vector<UsdGeomPrimvar> primvars;
    const UsdPrim &prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("FindIncrementallyInheritablePrimvars called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return primvars;
    }

    TfToken const& prefix = UsdGeomPrimvar::_GetNamespacePrefix();
    _AddPrimToInheritedPrimvars(prim, prefix, 
                                &inheritedFromAncestors, 
                                &primvars, /* acceptAll = */ false);
    return primvars;
}
コード例 #9
0
std::vector<UsdGeomPrimvar> 
UsdGeomPrimvarsAPI::FindPrimvarsWithInheritance(
        const std::vector<UsdGeomPrimvar> &inheritedFromAncestors) const
{
    TRACE_FUNCTION();

    std::vector<UsdGeomPrimvar> primvars;
    const UsdPrim &prim = GetPrim();
    if (!prim) {
        TF_CODING_ERROR("FindPrimvarsWithInheritance called on invalid prim: %s", 
                        UsdDescribe(prim).c_str());
        return primvars;
    }

    TfToken const& prefix = UsdGeomPrimvar::_GetNamespacePrefix();
    _AddPrimToInheritedPrimvars(prim, prefix, 
                                &inheritedFromAncestors, 
                                &primvars, 
                                /* acceptAll = */ true);

    // If this prim contributed no primvars, then `primvars` won't have
    // gotten a copy of `inheritedFromAncestors`, so ensure we compensate
    return primvars.empty() ? inheritedFromAncestors : primvars;
}