From ad6e346b5407fc19e5dba10251de60df3d7a98f6 Mon Sep 17 00:00:00 2001 From: Samuel Liu Date: Mon, 16 Sep 2024 10:05:02 -0400 Subject: [PATCH] Revert "Merge pull request #3881 from Autodesk/samuelliu-adsk/EMSUSD-986/edit_as_maya_moves_prim" This reverts commit 7142fb994a75789e6bc74708d2b0e18d93fdf9de, reversing changes made to 4d98e1399034e5c8cf61cb7ca83d68a44c0fdb99. --- lib/mayaUsd/fileio/jobs/readJob.cpp | 26 ++++--------------- lib/mayaUsd/fileio/jobs/readJob.h | 7 +++-- lib/mayaUsd/fileio/primReaderContext.cpp | 5 ---- lib/mayaUsd/fileio/primReaderContext.h | 10 ------- lib/mayaUsd/fileio/primUpdaterManager.cpp | 9 +++---- .../translators/translatorXformable.cpp | 4 --- .../lib/usdMaya/readJobWithSceneAssembly.cpp | 7 ++--- .../lib/usdMaya/readJobWithSceneAssembly.h | 3 +-- 8 files changed, 15 insertions(+), 56 deletions(-) diff --git a/lib/mayaUsd/fileio/jobs/readJob.cpp b/lib/mayaUsd/fileio/jobs/readJob.cpp index 5c08eb3dca..7e8266938e 100644 --- a/lib/mayaUsd/fileio/jobs/readJob.cpp +++ b/lib/mayaUsd/fileio/jobs/readJob.cpp @@ -191,7 +191,7 @@ UsdMaya_ReadJob::UsdMaya_ReadJob( UsdMaya_ReadJob::~UsdMaya_ReadJob() { } -bool UsdMaya_ReadJob::Read(std::vector* addedDagPaths, const bool resetXform) +bool UsdMaya_ReadJob::Read(std::vector* addedDagPaths) { // When we are called from PrimUpdaterManager we should already have // a computation scope. If we are called from elsewhere don't show any @@ -408,9 +408,7 @@ bool UsdMaya_ReadJob::Read(std::vector* addedDagPaths, const bool rese } } - // Pass the flag resetXform to DoImport to fix the issue that when edit as Maya on prototype - // prims we have duplicated transforms - DoImport(range, usdRootPrim, resetXform); + DoImport(range, usdRootPrim); progressBar.advance(); // NOTE: (yliangsiew) Storage to later pass on to `PostImport` for import chasers. @@ -487,12 +485,9 @@ bool UsdMaya_ReadJob::Read(std::vector* addedDagPaths, const bool rese return (status == MS::kSuccess); } -bool UsdMaya_ReadJob::DoImport( - UsdPrimRange& rootRange, - const UsdPrim& usdRootPrim, - const bool resetXform) +bool UsdMaya_ReadJob::DoImport(UsdPrimRange& rootRange, const UsdPrim& usdRootPrim) { - return _DoImport(rootRange, usdRootPrim, resetXform); + return _DoImport(rootRange, usdRootPrim); } bool UsdMaya_ReadJob::OverridePrimReader( @@ -511,7 +506,6 @@ void UsdMaya_ReadJob::_DoImportPrimIt( UsdMayaPrimReaderContext& readCtx, _PrimReaderMap& primReaderMap) { - const bool resetXform = readCtx.GetForceResetXform(); const UsdPrim& prim = *primIt; // The iterator will hit each prim twice. IsPostVisit tells us if // this is the pre-visit (Read) step or post-visit (PostReadSubtree) @@ -521,9 +515,7 @@ void UsdMaya_ReadJob::_DoImportPrimIt( // specified one. auto primReaderIt = primReaderMap.find(prim.GetPath()); if (primReaderIt != primReaderMap.end()) { - const bool resetXform = readCtx.GetForceResetXform(); primReaderIt->second->PostReadSubtree(readCtx); - readCtx.SetForceResetXform(resetXform); } } else { // This is the normal Read step (pre-visit). @@ -538,7 +530,6 @@ void UsdMaya_ReadJob::_DoImportPrimIt( UsdMayaPrimReaderSharedPtr primReader = factoryFn(args); if (primReader) { TempNodeTrackerScope scope(readCtx); - readCtx.SetForceResetXform(resetXform); primReader->Read(readCtx); if (primReader->HasPostReadSubtree()) { primReaderMap[prim.GetPath()] = primReader; @@ -612,13 +603,11 @@ void UsdMaya_ReadJob::_ImportPrototype( UsdMayaPrimReaderContext& readCtx) { _PrimReaderMap primReaderMap; - const bool resetXform = readCtx.GetForceResetXform(); const UsdPrimRange range = UsdPrimRange::PreAndPostVisit(prototype); for (auto primIt = range.begin(); primIt != range.end(); ++primIt) { const UsdPrim& prim = *primIt; UsdMayaPrimReaderContext readCtx(&mNewNodeRegistry); readCtx.SetTimeSampleMultiplier(mTimeSampleMultiplier); - readCtx.SetForceResetXform(resetXform); if (prim.IsInstance()) { _DoImportInstanceIt(primIt, usdRootPrim, readCtx, primReaderMap); } else { @@ -627,10 +616,7 @@ void UsdMaya_ReadJob::_ImportPrototype( } } -bool UsdMaya_ReadJob::_DoImport( - UsdPrimRange& rootRange, - const UsdPrim& usdRootPrim, - const bool resetXform) +bool UsdMaya_ReadJob::_DoImport(UsdPrimRange& rootRange, const UsdPrim& usdRootPrim) { const bool buildInstances = mArgs.importInstances; @@ -655,7 +641,6 @@ bool UsdMaya_ReadJob::_DoImport( const UsdPrim& prim = *primIt; UsdMayaPrimReaderContext readCtx(&mNewNodeRegistry); readCtx.SetTimeSampleMultiplier(mTimeSampleMultiplier); - readCtx.SetForceResetXform(resetXform); if (buildInstances && prim.IsInstance()) { _DoImportInstanceIt(primIt, usdRootPrim, readCtx, primReaderMap); @@ -672,7 +657,6 @@ bool UsdMaya_ReadJob::_DoImport( MDGModifier deletePrototypeMod; UsdMayaPrimReaderContext readCtx(&mNewNodeRegistry); readCtx.SetTimeSampleMultiplier(mTimeSampleMultiplier); - readCtx.SetForceResetXform(resetXform); auto prototypes = usdRootPrim.GetStage()->GetPrototypes(); const int loopSize = prototypes.size(); diff --git a/lib/mayaUsd/fileio/jobs/readJob.h b/lib/mayaUsd/fileio/jobs/readJob.h index ca79a61c90..7215d01149 100644 --- a/lib/mayaUsd/fileio/jobs/readJob.h +++ b/lib/mayaUsd/fileio/jobs/readJob.h @@ -49,7 +49,7 @@ class UsdMaya_ReadJob /// Reads the USD stage specified by the job file name and prim path. /// Newly-created DAG paths are inserted into the vector \p addedDagPaths. MAYAUSD_CORE_PUBLIC - bool Read(std::vector* addedDagPaths, const bool resetXform = false); + bool Read(std::vector* addedDagPaths); /// Redoes a previous Read() operation after Undo() has been called. /// If Undo() hasn't been called, does nothing. @@ -77,8 +77,7 @@ class UsdMaya_ReadJob using _PrimReaderMap = std::unordered_map; MAYAUSD_CORE_PUBLIC - virtual bool - DoImport(UsdPrimRange& range, const UsdPrim& usdRootPrim, const bool isEdityAsMaya = false); + virtual bool DoImport(UsdPrimRange& range, const UsdPrim& usdRootPrim); // Hook for derived classes to override the prim reader. Returns true if // override was done, false otherwise. Implementation in this class @@ -94,7 +93,7 @@ class UsdMaya_ReadJob // Engine method for DoImport(). Covers the functionality of a regular // usdImport. MAYAUSD_CORE_PUBLIC - bool _DoImport(UsdPrimRange& range, const UsdPrim& usdRootPrim, const bool resetXform = false); + bool _DoImport(UsdPrimRange& range, const UsdPrim& usdRootPrim); // Hook for derived classes to perform processing before import. // Method in this class is a no-op. diff --git a/lib/mayaUsd/fileio/primReaderContext.cpp b/lib/mayaUsd/fileio/primReaderContext.cpp index 614c01cf73..3687c5324e 100644 --- a/lib/mayaUsd/fileio/primReaderContext.cpp +++ b/lib/mayaUsd/fileio/primReaderContext.cpp @@ -22,7 +22,6 @@ PXR_NAMESPACE_OPEN_SCOPE UsdMayaPrimReaderContext::UsdMayaPrimReaderContext(ObjectRegistry* pathNodeMap) : _prune(false) , _timeSampleMultiplier(1.0) - , _resetXform(false) , _pathNodeMap(pathNodeMap) { } @@ -96,8 +95,4 @@ void UsdMayaPrimReaderContext::SetTimeSampleMultiplier(double multiplier) _timeSampleMultiplier = multiplier; }; -void UsdMayaPrimReaderContext::SetForceResetXform(bool resetXform) { _resetXform = resetXform; }; - -bool UsdMayaPrimReaderContext::GetForceResetXform() const { return _resetXform; }; - PXR_NAMESPACE_CLOSE_SCOPE diff --git a/lib/mayaUsd/fileio/primReaderContext.h b/lib/mayaUsd/fileio/primReaderContext.h index ea9b149ed6..f242a5d144 100644 --- a/lib/mayaUsd/fileio/primReaderContext.h +++ b/lib/mayaUsd/fileio/primReaderContext.h @@ -94,21 +94,11 @@ class UsdMayaPrimReaderContext MAYAUSD_CORE_PUBLIC void SetTimeSampleMultiplier(double multiplier); - /// \brief Set the if we are importing as edit as Maya - MAYAUSD_CORE_PUBLIC - void SetForceResetXform(bool resetXform); - - /// \Get the if we are importing as edit as Maya - MAYAUSD_CORE_PUBLIC - bool GetForceResetXform() const; - ~UsdMayaPrimReaderContext() { } private: bool _prune; double _timeSampleMultiplier; - // Added a boolean for - bool _resetXform; // used to keep track of prims that are created. // for undo/redo diff --git a/lib/mayaUsd/fileio/primUpdaterManager.cpp b/lib/mayaUsd/fileio/primUpdaterManager.cpp index 09e930bd27..b87acb32ea 100644 --- a/lib/mayaUsd/fileio/primUpdaterManager.cpp +++ b/lib/mayaUsd/fileio/primUpdaterManager.cpp @@ -294,8 +294,7 @@ using PullImportPaths = std::vector>; PullImportPaths pullImport( const Ufe::Path& ufePulledPath, const UsdPrim& pulledPrim, - const UsdMayaPrimUpdaterContext& context, - const bool resetXform = false) + const UsdMayaPrimUpdaterContext& context) { MayaUsd::ProgressBarScope progressBar(9); @@ -333,7 +332,7 @@ PullImportPaths pullImport( std::vector addedDagPaths; // Execute the command, which can succeed but import nothing. - bool success = readJob->Read(&addedDagPaths, resetXform); + bool success = readJob->Read(&addedDagPaths); if (!success || addedDagPaths.size() == 0) { TF_WARN("Nothing to edit in the selection."); return PullImportPaths(); @@ -1285,7 +1284,7 @@ bool PrimUpdaterManager::editAsMaya(const Ufe::Path& path, const VtDictionary& u // each, for per-prim customization. // 1) Perform the import - PullImportPaths importedPaths = pullImport(path, pulledPrim, context, true); + PullImportPaths importedPaths = pullImport(path, pulledPrim, context); if (importedPaths.empty()) { return false; } @@ -1630,7 +1629,7 @@ std::vector PrimUpdaterManager::duplicate( context._pullExtras.initRecursive(Ufe::Hierarchy::createItem(srcPath)); progressBar.advance(); - PullImportPaths importedPaths = pullImport(srcPath, srcPrim, context, true); + PullImportPaths importedPaths = pullImport(srcPath, srcPrim, context); progressBar.advance(); scopeIt.end(); diff --git a/lib/mayaUsd/fileio/translators/translatorXformable.cpp b/lib/mayaUsd/fileio/translators/translatorXformable.cpp index 01eee69fac..6107b54f63 100644 --- a/lib/mayaUsd/fileio/translators/translatorXformable.cpp +++ b/lib/mayaUsd/fileio/translators/translatorXformable.cpp @@ -602,10 +602,6 @@ void UsdMayaTranslatorXformable::Read( "Unable to successfully decompose matrix at USD prim <%s>", xformSchema.GetPath().GetText()); } - if (context->GetForceResetXform()) { - // This is to solve the issue that when edit as maya on an instanced prim it moves away - resetsXformStack = true; - } } if (resetsXformStack) { diff --git a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp index 4b33904fe6..f80c3590ab 100644 --- a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp +++ b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp @@ -31,13 +31,10 @@ UsdMaya_ReadJobWithSceneAssembly::UsdMaya_ReadJobWithSceneAssembly( UsdMaya_ReadJobWithSceneAssembly::~UsdMaya_ReadJobWithSceneAssembly() { } -bool UsdMaya_ReadJobWithSceneAssembly::DoImport( - UsdPrimRange& rootRange, - const UsdPrim& usdRootPrim, - const bool resetXform) +bool UsdMaya_ReadJobWithSceneAssembly::DoImport(UsdPrimRange& rootRange, const UsdPrim& usdRootPrim) { return mArgs.importWithProxyShapes ? _DoImportWithProxies(rootRange) - : _DoImport(rootRange, usdRootPrim, resetXform); + : _DoImport(rootRange, usdRootPrim); } bool UsdMaya_ReadJobWithSceneAssembly::OverridePrimReader( diff --git a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h index 9ec1ac7f47..c7945feb93 100644 --- a/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h +++ b/plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h @@ -33,8 +33,7 @@ class UsdMaya_ReadJobWithSceneAssembly : public UsdMaya_ReadJob ~UsdMaya_ReadJobWithSceneAssembly(); private: - bool DoImport(UsdPrimRange& range, const UsdPrim& usdRootPrim, const bool resetXform = false) - override; + bool DoImport(UsdPrimRange& range, const UsdPrim& usdRootPrim) override; bool OverridePrimReader( const UsdPrim& usdRootPrim, const UsdPrim& prim,