|
23 | 23 | #include <pxr/usd/usd/payloads.h> |
24 | 24 | #include <pxr/usd/usd/references.h> |
25 | 25 | #include <pxr/usd/usd/stage.h> |
| 26 | +#include <pxr/usd/usd/usdFileFormat.h> |
26 | 27 | #include <pxr/usd/usd/variantSets.h> |
27 | 28 | #include <pxr/usd/usdGeom/gprim.h> |
28 | 29 |
|
@@ -79,13 +80,26 @@ void cacheMayaReference(const PXR_NS::VtDictionary& context, PXR_NS::VtDictionar |
79 | 80 | if (dstLayerPath.empty() || dstPrimName.empty()) |
80 | 81 | return; |
81 | 82 |
|
| 83 | + // Determine the file format |
| 84 | + PXR_NS::SdfLayer::FileFormatArguments fileFormatArgs; |
| 85 | + PXR_NS::SdfFileFormatConstPtr fileFormat; |
| 86 | + |
| 87 | + auto fileFormatExtension |
| 88 | + = PXR_NS::VtDictionaryGet<std::string>(context, "defaultUSDFormat", PXR_NS::VtDefault = ""); |
| 89 | + if (fileFormatExtension.size() > 0) { |
| 90 | + fileFormatArgs[PXR_NS::UsdUsdFileFormatTokens->FormatArg] = fileFormatExtension; |
| 91 | + auto dummyFilename = std::string("a.") + fileFormatExtension; |
| 92 | + fileFormat = PXR_NS::SdfFileFormat::FindByExtension(dummyFilename, fileFormatArgs); |
| 93 | + } |
| 94 | + |
82 | 95 | // Prepare the layer |
83 | 96 | PXR_NS::SdfPath dstPrimPath |
84 | 97 | = PXR_NS::SdfPath(dstPrimName).MakeAbsolutePath(PXR_NS::SdfPath::AbsoluteRootPath()); |
85 | | - PXR_NS::SdfLayerRefPtr tmpLayer = PXR_NS::SdfLayer::CreateAnonymous(); |
| 98 | + PXR_NS::SdfLayerRefPtr tmpLayer |
| 99 | + = PXR_NS::SdfLayer::CreateAnonymous("", fileFormat, fileFormatArgs); |
86 | 100 | SdfJustCreatePrimInLayer(tmpLayer, dstPrimPath); |
87 | 101 |
|
88 | | - tmpLayer->Export(dstLayerPath); |
| 102 | + tmpLayer->Export(dstLayerPath, "", fileFormatArgs); |
89 | 103 | PXR_NS::SdfLayerRefPtr dstLayer = PXR_NS::SdfLayer::FindOrOpen(dstLayerPath); |
90 | 104 | if (!dstLayer) |
91 | 105 | return; |
|
0 commit comments