示例#1
0
static
TfToken
_GetMaterialsScopeName(const std::string& materialsScopeName)
{
    const TfToken defaultMaterialsScopeName = UsdUtilsGetMaterialsScopeName();

    if (TfGetEnvSetting(USD_FORCE_DEFAULT_MATERIALS_SCOPE_NAME)) {
        // If the env setting is set, make sure we don't allow the materials
        // scope name to be overridden by a parameter value.
        return defaultMaterialsScopeName;
    }

    if (SdfPath::IsValidIdentifier(materialsScopeName)) {
        return TfToken(materialsScopeName);
    }

    TF_CODING_ERROR(
        "'%s' value '%s' is not a valid identifier. Using default "
        "value of '%s' instead.",
        UsdMayaJobExportArgsTokens->materialsScopeName.GetText(),
        materialsScopeName.c_str(),
        defaultMaterialsScopeName.GetText());

    return defaultMaterialsScopeName;
}
示例#2
0
HdStGLSLProgramSharedPtr
HdStGLSLProgram::GetComputeProgram(
        TfToken const &shaderToken,
        HdStResourceRegistry *resourceRegistry)
{
    // Find the program from registry
    HdInstance<HdStGLSLProgram::ID, HdStGLSLProgramSharedPtr> programInstance;

    std::unique_lock<std::mutex> regLock = 
        resourceRegistry->RegisterGLSLProgram(
            HdStGLSLProgram::ComputeHash(shaderToken), &programInstance);

    if (programInstance.IsFirstInstance()) {
        // if not exists, create new one
        HdStGLSLProgramSharedPtr newProgram(
            new HdStGLSLProgram(HdTokens->computeShader));

        GlfGLSLFX glslfx(HdStPackageComputeShader());
        std::string version = "#version 430\n";
        if (!newProgram->CompileShader(
                GL_COMPUTE_SHADER, version + glslfx.GetSource(shaderToken))) {
            TF_CODING_ERROR("Fail to compile " + shaderToken.GetString());
            return HdStGLSLProgramSharedPtr();
        }
        if (!newProgram->Link()) {
            TF_CODING_ERROR("Fail to link " + shaderToken.GetString());
            return HdStGLSLProgramSharedPtr();
        }
        programInstance.SetValue(newProgram);
    }
    return programInstance.GetValue();
}
示例#3
0
文件: xformOp.cpp 项目: JT-a/USD
UsdGeomXformOp::UsdGeomXformOp(
    UsdPrim const& prim, 
    UsdGeomXformOp::Type const opType,
    UsdGeomXformOp::Precision const precision, 
    TfToken const &opSuffix,
    bool isInverseOp)
    : _opType(opType)
    , _isInverseOp(isInverseOp)
{
    // Determine the typeName of the xformOp attribute to be created.
    const SdfValueTypeName &typeName = GetValueTypeName(opType, precision);

    if (!typeName) { 
        TF_CODING_ERROR("Invalid xform-op: incompatible combination of "
            "opType (%s) and precision (%s).", 
            TfEnum::GetName(opType).c_str(),
            TfEnum::GetName(precision).c_str());
        return;
    } 

    TfToken attrName = UsdGeomXformOp::GetOpName(opType, opSuffix, 
        // isInverseOp is handled below
        /*isInverseOp*/ false);

    // attrName can never be empty.
    TF_VERIFY(!attrName.IsEmpty());

    // Create an  attribute in the xformOp: namespace with the
    // computed typeName.
    _attr = prim.CreateAttribute(attrName, typeName, /* custom */ false);

    // If a problem occurred, an error should already have been issued,
    // and _attr will be invalid, which is what we want
}
示例#4
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;
}
示例#5
0
文件: copyUtils.cpp 项目: lvxejay/USD
static
void _DoAddNewPrimSpec(
    const SdfLayerHandle& destLayer, const _SpecDataEntry& specData)
{
    // Need to determine whether this property is considered inert when
    // being initially created based on fields being copied in. This mimics
    // what's done in the SdfPrimSpec constructor.
    TfToken type;
    SdfSpecifier specifier = SdfSpecifierOver;
    for (const _FieldValuePair& fieldValue : specData.dataToCopy) {
        if (fieldValue.second.IsEmpty()) {
            continue;
        }

        if (fieldValue.first == SdfFieldKeys->TypeName) {
            type = fieldValue.second.Get<TfToken>();
        }
        else if (fieldValue.first == SdfFieldKeys->Specifier) {
            specifier = fieldValue.second.Get<SdfSpecifier>();
        }
    }

    const bool inert = (specifier == SdfSpecifierOver && type.IsEmpty());
    Sdf_ChildrenUtils<Sdf_PrimChildPolicy>::CreateSpec(
        destLayer, specData.dstPath, SdfSpecTypePrim,
        /* inert = */ inert);
}
示例#6
0
static std::vector<T>
_Vector(const VtDictionary& userArgs, const TfToken& key)
{
    // Check that vector exists.
    if (!VtDictionaryIsHolding<std::vector<VtValue>>(userArgs, key)) {
        TF_CODING_ERROR("Dictionary is missing required key '%s' or key is "
                "not vector type", key.GetText());
        return std::vector<T>();
    }

    // Check that vector is correctly-typed.
    std::vector<VtValue> vals =
            VtDictionaryGet<std::vector<VtValue>>(userArgs, key);
    if (!std::all_of(vals.begin(), vals.end(),
            [](const VtValue& v) { return v.IsHolding<T>(); })) {
        TF_CODING_ERROR("Vector at dictionary key '%s' contains elements of "
                "the wrong type", key.GetText());
        return std::vector<T>();
    }

    // Extract values.
    std::vector<T> result;
    for (const VtValue& v : vals) {
        result.push_back(v.UncheckedGet<T>());
    }
    return result;
}
示例#7
0
TfToken 
UsdGeomCollectionAPI::_GetCollectionPropertyName(
    const TfToken &baseName /* =TfToken() */) const
{
    return TfToken(UsdGeomTokens->collection.GetString() + ":" + 
                   _name.GetString() + 
                   (baseName.IsEmpty() ? "" : (":" + baseName.GetString())));
}
示例#8
0
/* virtual */
Hd_DefaultLightingShader::ID
Hd_DefaultLightingShader::ComputeHash() const
{
    TfToken glslfxFile = HdPackageDefaultLightingShader();

    size_t hash = glslfxFile.Hash();

    return (ID)hash;
}
/* virtual */
HdSt_FallbackLightingShader::ID
HdSt_FallbackLightingShader::ComputeHash() const
{
    TfToken glslfxFile = HdStPackageFallbackLightingShader();

    size_t hash = glslfxFile.Hash();

    return (ID)hash;
}
示例#10
0
void
UsdImagingGprimAdapter::_DiscoverPrimvars(UsdGeomGprim const& gprim,
                                          SdfPath const& cachePath, 
                                          UsdShadeShader const& shader,
                                          UsdTimeCode time,
                                          UsdImagingValueCache* valueCache)
{
    // TODO: It might be convenient to implicitly wire up PtexFaceOffset and
    // PtexFaceIndex primvars.
    
    TF_DEBUG(USDIMAGING_SHADERS).Msg("\t Looking for <%s> primvars at <%s>\n",
                            gprim.GetPrim().GetPath().GetText(),
                            shader.GetPrim().GetPath().GetText());
    for (UsdShadeParameter const& param : shader.GetParameters()) {
        UsdShadeShader source;
        TfToken outputName;
        if (param.GetConnectedSource(&source, &outputName)) {
            UsdAttribute attr = source.GetIdAttr();
            TfToken id;
            if (not attr or not attr.Get(&id)) {
                continue;
            }
            TF_DEBUG(USDIMAGING_SHADERS).Msg("\t\t Param <%s> connected <%s>(%s)\n",
                            param.GetAttr().GetName().GetText(),
                            source.GetPath().GetText(),
                            id.GetText());
            if (id == UsdHydraTokens->HwPrimvar_1) {
                TfToken t;
                VtValue v;
                UsdGeomPrimvar primvarAttr;
                if (UsdHydraPrimvar(source).GetVarnameAttr().Get(&t, 
                                            UsdTimeCode::Default())) {
                    primvarAttr = gprim.GetPrimvar(t);
                    if (primvarAttr.ComputeFlattened(&v, time)) {
                        TF_DEBUG(USDIMAGING_SHADERS).Msg("Found primvar %s\n",
                            t.GetText());

                        UsdImagingValueCache::PrimvarInfo primvar;
                        primvar.name = t;
                        primvar.interpolation = primvarAttr.GetInterpolation();
                        valueCache->GetPrimvar(cachePath, t) = v;
                        _MergePrimvar(primvar, &valueCache->GetPrimvars(cachePath));
                    } else {
                        TF_DEBUG(USDIMAGING_SHADERS).Msg(
                            "\t\t No primvar on <%s> named %s\n",
                            gprim.GetPath().GetText(),
                            t.GetText());

                    }
                }
            } else {
                // Recursively look for more primvars
                _DiscoverPrimvars(gprim, cachePath, source, time, valueCache);
            }
        }
    }
}
示例#11
0
UsdGeomXformOp
UsdGeomXformable::AddXformOp(
    UsdGeomXformOp::Type const opType,
    UsdGeomXformOp::Precision const precision,
    TfToken const &opSuffix,
    bool isInverseOp) const
{
    VtTokenArray xformOpOrder;
    _GetXformOpOrderValue(&xformOpOrder);

    // Check if the xformOp we're about to add already exists in xformOpOrder
    TfToken opName = UsdGeomXformOp::GetOpName(opType, opSuffix, isInverseOp);
    VtTokenArray::iterator it = std::find(xformOpOrder.begin(),
                                          xformOpOrder.end(), opName);
    if (it != xformOpOrder.end()) {
        TF_CODING_ERROR("The xformOp '%s' already exists in xformOpOrder [%s].",
                        opName.GetText(), TfStringify(xformOpOrder).c_str());
        return UsdGeomXformOp();
    }

    TfToken const &xformOpAttrName = UsdGeomXformOp::GetOpName(opType, opSuffix);
    UsdGeomXformOp result;
    if (UsdAttribute xformOpAttr = GetPrim().GetAttribute(xformOpAttrName)) {
        // Check if the attribute's typeName has the requested precision level.
        UsdGeomXformOp::Precision existingPrecision =
            UsdGeomXformOp::GetPrecisionFromValueTypeName(
                xformOpAttr.GetTypeName());

        if (existingPrecision != precision) {
            TF_CODING_ERROR("XformOp <%s> has typeName '%s' which does not "
                            "match the requested precision '%s'. Proceeding to "
                            "use existing typeName / precision.",
                            xformOpAttr.GetPath().GetText(),
                            xformOpAttr.GetTypeName().GetAsToken().GetText(),
                            TfEnum::GetName(precision).c_str());
        }

        result = UsdGeomXformOp(xformOpAttr, isInverseOp);
    } else {
        result = UsdGeomXformOp(GetPrim(), opType, precision, opSuffix,
                                isInverseOp);
    }

    if (result) {
        xformOpOrder.push_back(result.GetOpName());
        CreateXformOpOrderAttr().Set(xformOpOrder);
    } else {
        TF_CODING_ERROR("Unable to add xform op of type %s and precision %s on "
                        "prim at path <%s>. opSuffix=%s, isInverseOp=%d",
                        TfEnum::GetName(opType).c_str(), TfEnum::GetName(precision).c_str(),
                        GetPath().GetText(), opSuffix.GetText(), isInverseOp);
        return UsdGeomXformOp();
    }

    return result;
}
示例#12
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));
}
示例#13
0
UsdMayaAdaptor::SchemaAdaptor
UsdMayaAdaptor::ApplySchemaByName(
    const TfToken& schemaName,
    MDGModifier& modifier)
{
    if (!*this) {
        TF_CODING_ERROR("Adaptor is not valid");
        return SchemaAdaptor();
    }

    // Get the schema's TfType; its name should be registered as an alias.
    const TfType schemaType =
            TfType::Find<UsdSchemaBase>().FindDerivedByName(schemaName);

    // Make sure that this is an API schema. Only API schemas can be applied.
    if (!schemaType.IsA<UsdAPISchemaBase>()) {
        TF_CODING_ERROR("'%s' is not a registered API schema",
                schemaName.GetText());
        return SchemaAdaptor();
    }

    // Make sure that this is an "apply" schema.
    if (!UsdSchemaRegistry::GetInstance().IsAppliedAPISchema(schemaType)) {
        TF_CODING_ERROR("'%s' is not an applied API schema",
                schemaName.GetText());
        return SchemaAdaptor();
    }

    // Get the schema definition. If it's registered, there should be a def.
    SdfPrimSpecHandle primDef =
            UsdSchemaRegistry::GetInstance().GetPrimDefinition(schemaName);
    if (!primDef) {
        TF_CODING_ERROR("Can't find schema definition for name '%s'",
                schemaName.GetText());
        return SchemaAdaptor();
    }

    // Add to schema list (if not yet present).
    TfTokenVector currentSchemas = GetAppliedSchemas();
    if (std::find(currentSchemas.begin(), currentSchemas.end(), schemaName) ==
            currentSchemas.end()) {
        currentSchemas.push_back(schemaName);
        SetMetadata(
                UsdTokens->apiSchemas,
                _GetListOpForTokenVector(currentSchemas),
                modifier);
    }

    return SchemaAdaptor(_handle.object(), primDef);
}
/* static */
UsdSkelInbetweenShape
UsdSkelInbetweenShape::_Create(const UsdPrim& prim, const TfToken& name)
{
    if(TF_VERIFY(prim)) {
        TfToken attrName = _MakeNamespaced(name);

        if(!attrName.IsEmpty()) {
            return UsdSkelInbetweenShape(
                prim.CreateAttribute(attrName, SdfValueTypeNames->Point3fArray,
                                     /*custom*/ false, SdfVariabilityUniform));
        }
    }
    return UsdSkelInbetweenShape();
}
示例#15
0
/* virtual */
HdxSimpleLightingShader::ID
HdxSimpleLightingShader::ComputeHash() const
{
    HD_TRACE_FUNCTION();

    TfToken glslfxFile = HdxPackageSimpleLightingShader();
    size_t numLights = _useLighting ? _lightingContext->GetNumLightsUsed() : 0;
    bool useShadows = _useLighting ? _lightingContext->GetUseShadows() : false;

    size_t hash = glslfxFile.Hash();
    boost::hash_combine(hash, numLights);
    boost::hash_combine(hash, useShadows);

    return (ID)hash;
}
示例#16
0
文件: perfLog.cpp 项目: 400dama/USD
void
HdPerfLog::AddCacheHit(TfToken const& name,
                 SdfPath const& id,
                 TfToken const& tag)
{
    if (ARCH_LIKELY(not _enabled))
        return;
    _Lock lock(_mutex);
    _cacheMap[name].AddHit();
    TF_DEBUG(HD_CACHE_HITS).Msg("Cache hit: %s %s %s hits: %lu\n",
            name.GetText(),
            id.GetText(),
            tag.GetText(),
            _cacheMap[name].GetHits());
}
示例#17
0
文件: perfLog.cpp 项目: 400dama/USD
void
HdPerfLog::AddCacheMiss(TfToken const& name,
                  SdfPath const& id,
                  TfToken const& tag)
{
    if (ARCH_LIKELY(not _enabled))
        return;
    _Lock lock(_mutex);
    _cacheMap[name].AddMiss();
    TF_DEBUG(HD_CACHE_MISSES).Msg("Cache miss: %s %s %s Total misses: %lu\n",
            name.GetText(),
            id.GetText(),
            tag.GetText(),
            _cacheMap[name].GetMisses());
}
示例#18
0
文件: path.cpp 项目: lvxejay/USD
SdfPath
SdfPath::AppendProperty(TfToken const &propName) const {
    if (!IsValidNamespacedIdentifier(propName.GetString())) {
        //TF_WARN("Invalid property name.");
        return EmptyPath();
    }
    if (!IsPrimVariantSelectionPath() && 
        !IsPrimPath() && 
                (_pathNode != Sdf_PathNode::GetRelativeRootNode())) {
        TF_WARN("Can only append a property '%s' to a prim path (%s)",
                propName.GetText(), GetText());
        return EmptyPath();
    }
    return SdfPath(Sdf_PathNode::FindOrCreatePrimProperty(_pathNode, propName));
}
示例#19
0
文件: xformOp.cpp 项目: JT-a/USD
/* static */
TfToken 
UsdGeomXformOp::GetOpName(
    const Type opType, 
    const TfToken &opSuffix,
    bool isInverseOp)
{
    TfToken opName = _MakeNamespaced(GetOpTypeToken(opType));

    if (!opSuffix.IsEmpty())
        opName = TfToken(opName.GetString() + ":" + opSuffix.GetString());

    if (isInverseOp)
        opName = TfToken(_tokens->invertPrefix.GetString() + opName.GetString());

    return opName;
}
示例#20
0
static bool
_GetMetadataUnchecked(
    const MFnDependencyNode& node,
    const TfToken& key,
    VtValue* value)
{
    VtValue fallback = SdfSchema::GetInstance().GetFallback(key);
    if (fallback.IsEmpty()) {
        return false;
    }

    std::string mayaAttrName = _GetMayaAttrNameForMetadataKey(key);
    MPlug plug = node.findPlug(mayaAttrName.c_str());
    if (plug.isNull()) {
        return false;
    }

    TfType ty = fallback.GetType();
    VtValue result = UsdMayaWriteUtil::GetVtValue(plug, ty, TfToken());
    if (result.IsEmpty()) {
        TF_RUNTIME_ERROR(
                "Cannot convert plug '%s' into metadata '%s' (%s)",
                plug.name().asChar(),
                key.GetText(),
                ty.GetTypeName().c_str());
        return false;
    }

    *value = result;
    return true;
}
示例#21
0
static
bool
_TranslateUsdAttributeToPlug(
        const UsdAttribute& usdAttr,
        const MFnCamera& cameraFn,
        TfToken plugName,
        const PxrUsdMayaPrimReaderArgs& args,
        PxrUsdMayaPrimReaderContext* context,
        bool millimetersToInches=false)
{
    MStatus status;

    MPlug plug = cameraFn.findPlug(plugName.GetText(), true, &status);
    CHECK_MSTATUS_AND_RETURN(status, false);

    // First check for and translate animation if there is any.
    if (!_TranslateAnimatedUsdAttributeToPlug(usdAttr,
                                                 plug,
                                                 args,
                                                 context,
                                                 millimetersToInches)) {
        // If that fails, then try just setting a static value.
        UsdTimeCode timeCode = UsdTimeCode::EarliestTime();
        float attrValue;
        usdAttr.Get(&attrValue, timeCode);
        if (millimetersToInches) {
            attrValue = PxrUsdMayaUtil::ConvertMMToInches(attrValue);
        }
        status = plug.setFloat(attrValue);
        CHECK_MSTATUS_AND_RETURN(status, false);
    }

    return true;
}
示例#22
0
PXR_NAMESPACE_CLOSE_SCOPE

// ===================================================================== //
// Feel free to add custom code below this line. It will be preserved by
// the code generator.
//
// Just remember to wrap code in the appropriate delimiters:
// 'PXR_NAMESPACE_OPEN_SCOPE', 'PXR_NAMESPACE_CLOSE_SCOPE'.
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--

PXR_NAMESPACE_OPEN_SCOPE

UsdGeomPrimvar 
UsdGeomPrimvarsAPI::CreatePrimvar(const TfToken& attrName,
                                const SdfValueTypeName &typeName,
                                const TfToken& interpolation,
                                int elementSize) const
{
    const UsdPrim &prim = GetPrim();

    UsdGeomPrimvar primvar(prim, attrName, typeName);

    if (primvar){
        if (!interpolation.IsEmpty())
            primvar.SetInterpolation(interpolation);
        if (elementSize > 0)
            primvar.SetElementSize(elementSize);
    }
    // otherwise, errors have already been issued
    return primvar;
}
示例#23
0
static std::string
_GetRelPrefix(const TfToken& renderTarget)
{
    return TfStringPrintf("%s:%s", 
            renderTarget.GetText(),
            _tokens->interfaceRecipientsOf.GetText());
}
示例#24
0
static 
bool _GetMayaDictValue(const UsdAttribute& attr, const TfToken& key, T* outVal)
{
    VtValue data = attr.GetCustomDataByKey(_tokens->Maya);
    if (!data.IsEmpty()) {
        if (data.IsHolding<VtDictionary>()) {
            VtValue val;
            if (TfMapLookup(data.UncheckedGet<VtDictionary>(), key, &val)) {
                if (val.IsHolding<T>()) {
                    *outVal = val.UncheckedGet<T>();
                    return true;
                }
                else {
                    TF_WARN("Unexpected type for %s[%s] on <%s>.",
                            _tokens->Maya.GetText(),
                            key.GetText(),
                            attr.GetPath().GetText());
                }
            }
        }
        else {
            TF_WARN("Expected to get %s on <%s> to be a dictionary.",
                    _tokens->Maya.GetText(),
                    attr.GetPath().GetText());
        }
    }
    return false;
}
示例#25
0
文件: xformOp.cpp 项目: JT-a/USD
/* static */
UsdGeomXformOp::Type 
UsdGeomXformOp::GetOpTypeEnum(TfToken const &opTypeToken)
{
    if (opTypeToken == UsdGeomXformOpTypes->transform)
        return TypeTransform;
    else if (opTypeToken == UsdGeomXformOpTypes->translate)
        return TypeTranslate;
    // RotateXYZ is expected to be more common than the remaining ops.
    else if (opTypeToken == UsdGeomXformOpTypes->rotateXYZ)
        return TypeRotateXYZ;
    else if (opTypeToken == UsdGeomXformOpTypes->scale)
        return TypeScale;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateX)
        return TypeRotateX;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateY)
        return TypeRotateY;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateZ)
        return TypeRotateZ;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateXZY)
        return TypeRotateXZY;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateYXZ)
        return TypeRotateYXZ;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateYZX)
        return TypeRotateYZX;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateZXY)
        return TypeRotateZXY;
    else if (opTypeToken == UsdGeomXformOpTypes->rotateZYX)
        return TypeRotateZYX;
    else if (opTypeToken == UsdGeomXformOpTypes->orient)
        return TypeOrient;
    
    TF_CODING_ERROR("Invalid xform opType token %s.", opTypeToken.GetText());
    return TypeInvalid;
}
示例#26
0
void
Hd_PrimTypeIndex<PrimType>::RemovePrim(const TfToken    &typeId,
                                       const SdfPath    &primId,
                                       HdChangeTracker  &tracker,
                                       HdRenderDelegate *renderDelegate)
{
    HD_TRACE_FUNCTION();
    HF_MALLOC_TAG_FUNCTION();

    typename _TypeIndex::iterator typeIt = _index.find(typeId);
    if (typeIt ==_index.end()) {
        TF_CODING_ERROR("Unsupported prim type: %s", typeId.GetText());
        return;
    }

    _PrimTypeEntry &typeEntry = _entries[typeIt->second];

    typename _PrimMap::iterator primIt = typeEntry.primMap.find(primId);
    if (primIt == typeEntry.primMap.end()) {
        return;
    }

    _TrackerRemovePrim(tracker, primId);
    _PrimInfo &primInfo = primIt->second;
    _RenderDelegateDestroyPrim(renderDelegate, primInfo.prim);
    primInfo.prim = nullptr;

    typeEntry.primMap.erase(primIt);
    typeEntry.primIds.Remove(primId);
}
示例#27
0
 Hd_BindlessSamplerBufferSource(TfToken const &name, GLenum type, size_t value)
     : _name(name), _type(type), _value(value) {
     if (_value == 0) {
         TF_CODING_ERROR("Invalid texture handle: %s: %ld\n",
                         name.GetText(), value);
     }
 }
示例#28
0
/* static */
bool 
PxrUsdKatanaUsdInPluginRegistry::_DoFindKind(
        const TfToken& kind,
        std::string* opName,
        const _KindRegistry& reg)
{
    // can cache this if it becomes an issue.
    for (TfToken currKind = kind;
            not currKind.IsEmpty();
            currKind = KindRegistry::GetBaseKind(currKind)) {
        if (TfMapLookup(reg, currKind, opName)) {
            return true;
        }
    }

    return false;
}
示例#29
0
文件: xformOp.cpp 项目: JT-a/USD
static
TfToken
_MakeNamespaced(const TfToken& name)
{
    return _IsNamespaced(name) ? name : 
        TfToken(_tokens->xformOpPrefix.GetString() + 
                name.GetString());
}
示例#30
0
文件: primvar.cpp 项目: JT-a/USD
UsdGeomPrimvar::UsdGeomPrimvar(const UsdPrim& prim, 
                               const TfToken& baseName,
                               const SdfValueTypeName &typeName,
                               bool custom)
{
    TF_VERIFY(prim);

    TfToken attrName = _MakeNamespaced(baseName);

    if (!attrName.IsEmpty()){
        _attr = prim.CreateAttribute(attrName, typeName, custom);
    }
    // If a problem occurred, an error should already have been issued,
    // and _attr will be invalid, which is what we want

    _SetIdTargetRelName();
}