Пример #1
0
 private void WriteInternal <T>(SdfPath path,
                                T sample,
                                UsdTimeCode timeCode) where T : SampleBase
 {
     pxr.UsdPrim prim;
     lock (m_stageLock) {
         // TODO(jcowles): there is a potential issue here if the cache gets out of sync with the
         // underlying USD scene. The correct fix is to listen for change processing events and
         // clear the cache accordingly.
         prim = GetUsdPrim(path);
         if (!prim.IsValid())
         {
             if (WriteMode == WriteModes.Define)
             {
                 prim = m_stage.DefinePrim(path, new TfToken(Reflect.GetSchema(typeof(T))));
             }
             else
             {
                 prim = m_stage.OverridePrim(path);
             }
             if (prim == null || !prim)
             {
                 throw new Exception("Failed to "
                                     + (WriteMode == WriteModes.Define ? "define" : "override") + " prim: " + path);
             }
             m_primMap.Add(path, prim);
         }
     }
     m_usdIo.Serialize(sample, prim, timeCode);
 }
Пример #2
0
 private void WriteInternal <T>(SdfPath path,
                                T sample,
                                UsdTimeCode timeCode) where T : SampleBase
 {
     pxr.UsdPrim prim;
     lock (m_stageLock) {
         // TODO(jcowles): there is a potential issue here if the cache gets out of sync with the
         // underlying USD scene. The correct fix is to listen for change processing events and
         // clear the cache accordingly.
         if (!m_primMap.TryGetValue(path, out prim))
         {
             prim = m_stage.DefinePrim(path, new TfToken(Reflect.GetSchema(typeof(T))));
             if (!prim)
             {
                 return;
             }
             m_primMap.Add(path, prim);
         }
     }
     m_usdIo.Serialize(sample, prim, timeCode);
 }