コード例 #1
0
ファイル: primWrapper.cpp プロジェクト: mplanck/USD
bool
GusdPrimWrapper::updatePrimvarFromGTPrim( 
    const GT_AttributeListHandle& gtAttrs,
    const GusdGT_AttrFilter&      primvarFilter,
    const TfToken&                interpolation,
    UsdTimeCode                   time )
{
    UsdGeomImageable prim( getUsdPrimForWrite() );
    const GT_AttributeMapHandle attrMapHandle = gtAttrs->getMap();

    for(GT_AttributeMap::const_names_iterator mapIt=attrMapHandle->begin();
            !mapIt.atEnd(); ++mapIt) {

        if(!primvarFilter.matches(mapIt.name())) 
            continue;

        const int attrIndex = attrMapHandle->get(mapIt.name());
        const GT_Owner owner = attrMapHandle->getOriginalOwner(attrIndex);
        GT_DataArrayHandle attrData = gtAttrs->get(attrIndex);

        TfToken name( mapIt.name() );

        updatePrimvarFromGTPrim( 
                    TfToken( name ),
                    owner, 
                    interpolation, 
                    time, 
                    attrData );
    }
    return true;
}
コード例 #2
0
bool
GusdPrimWrapper::updatePrimvarFromGTPrim( 
    const GT_AttributeListHandle& gtAttrs,
    const GusdGT_AttrFilter&      primvarFilter,
    const TfToken&                interpolation,
    UsdTimeCode                   time )
{
    UsdGeomImageable prim( getUsdPrim() );
    const GT_AttributeMapHandle attrMapHandle = gtAttrs->getMap();

    for(GT_AttributeMap::const_names_iterator mapIt=attrMapHandle->begin();
            !mapIt.atEnd(); ++mapIt) {

#if SYS_VERSION_FULL_INT < 0x11000000
        string attrname = mapIt.name();
#else
        string attrname = mapIt->first.toStdString();
#endif

        if(!primvarFilter.matches(attrname)) 
            continue;

        const int attrIndex = attrMapHandle->get(attrname);
        const GT_Owner owner = attrMapHandle->getOriginalOwner(attrIndex);
        GT_DataArrayHandle attrData = gtAttrs->get(attrIndex);

#if SYS_VERSION_FULL_INT >= 0x11050000
        // Decode Houdini geometry attribute names to get back the original
        // USD primvar name. This allows round tripping of namespaced
        // primvars from USD -> Houdini -> USD.
        UT_StringHolder name = UT_VarEncode::decode(attrname);
#else
        UT_StringHolder name = attrname;
#endif

        updatePrimvarFromGTPrim( 
                    TfToken( name.toStdString() ),
                    owner, 
                    interpolation, 
                    time, 
                    attrData );
    }
    return true;
}