Skip to content

Commit

Permalink
Merge pull request #2864 from Autodesk/bailp/MAYA-127478/wrong-root-f…
Browse files Browse the repository at this point in the history
…ilename

MAYA-127478 fix bulk save of root layer filename
  • Loading branch information
seando-adsk authored Feb 16, 2023
2 parents 60a8001 + 521931a commit 1767b35
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/mayaUsd/nodes/layerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ class LayerDatabase : public TfWeakBase
void saveUsdLayerToMayaFile(SdfLayerRefPtr layer, bool asAnonymous);
void clearProxies();
bool hasDirtyLayer() const;
void refreshProxiesToSave();

std::map<std::string, SdfLayerRefPtr> _idToLayer;
TfNotice::Key _onStageSetKey;
Expand Down Expand Up @@ -520,6 +521,27 @@ bool LayerDatabase::getProxiesToSave(bool isExport)

bool LayerDatabase::saveInteractionRequired() { return _proxiesToSave.size() > 0; }

static void refreshSavingInfo(StageSavingInfo& info)
{
MFnDependencyNode fn;
MObject mobj = info.dagPath.node();
fn.setObject(mobj);
if (!fn.isFromReferencedFile() && LayerDatabase::instance().supportedNodeType(fn.typeId())) {
MayaUsdProxyShapeBase* pShape = static_cast<MayaUsdProxyShapeBase*>(fn.userNode());
info.stage = pShape ? pShape->getUsdStage() : nullptr;
}
}

void LayerDatabase::refreshProxiesToSave()
{
for (StageSavingInfo& info : _proxiesToSave) {
refreshSavingInfo(info);
}
for (StageSavingInfo& info : _internalProxiesToSave) {
refreshSavingInfo(info);
}
}

bool LayerDatabase::saveUsd(bool isExport)
{
BatchSaveResult result = MayaUsd::kNotHandled;
Expand Down Expand Up @@ -555,6 +577,12 @@ bool LayerDatabase::saveUsd(bool isExport)
return true;
}

// After the potentially partial save, we need to refresh the stages
// to be saved because the saving might have modified the proxy shape
// attributes and we need to re-evaluate these nodes so that the stages
// are re-created with the new attribute values if needed.
refreshProxiesToSave();

if (MayaUsd::utils::kSaveToUSDFiles == opt) {
result = saveUsdToUsdFiles();
} else {
Expand Down Expand Up @@ -781,6 +809,9 @@ void LayerDatabase::convertAnonymousLayers(

convertAnonymousLayersRecursive(root, proxyName, stage);

// Note: retrieve root again since it may have been changed by the call
// to convertAnonymousLayersRecursive
root = stage->GetRootLayer();
if (root->IsAnonymous()) {
PXR_NS::SdfFileFormat::FileFormatArguments args;
std::string newFileName = MayaUsd::utils::generateUniqueFileName(proxyName);
Expand Down

0 comments on commit 1767b35

Please sign in to comment.