Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSUSD-986 - Revert edit as maya changes #3918

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions lib/mayaUsd/fileio/jobs/readJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ UsdMaya_ReadJob::UsdMaya_ReadJob(

UsdMaya_ReadJob::~UsdMaya_ReadJob() { }

bool UsdMaya_ReadJob::Read(std::vector<MDagPath>* addedDagPaths, const bool resetXform)
bool UsdMaya_ReadJob::Read(std::vector<MDagPath>* addedDagPaths)
{
// When we are called from PrimUpdaterManager we should already have
// a computation scope. If we are called from elsewhere don't show any
Expand Down Expand Up @@ -408,9 +408,7 @@ bool UsdMaya_ReadJob::Read(std::vector<MDagPath>* 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.
Expand Down Expand Up @@ -487,12 +485,9 @@ bool UsdMaya_ReadJob::Read(std::vector<MDagPath>* 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(
Expand All @@ -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)
Expand All @@ -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).
Expand All @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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;

Expand All @@ -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);
Expand All @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions lib/mayaUsd/fileio/jobs/readJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<MDagPath>* addedDagPaths, const bool resetXform = false);
bool Read(std::vector<MDagPath>* addedDagPaths);

/// Redoes a previous Read() operation after Undo() has been called.
/// If Undo() hasn't been called, does nothing.
Expand Down Expand Up @@ -77,8 +77,7 @@ class UsdMaya_ReadJob
using _PrimReaderMap = std::unordered_map<SdfPath, UsdMayaPrimReaderSharedPtr, SdfPath::Hash>;

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
Expand All @@ -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.
Expand Down
5 changes: 0 additions & 5 deletions lib/mayaUsd/fileio/primReaderContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ PXR_NAMESPACE_OPEN_SCOPE
UsdMayaPrimReaderContext::UsdMayaPrimReaderContext(ObjectRegistry* pathNodeMap)
: _prune(false)
, _timeSampleMultiplier(1.0)
, _resetXform(false)
, _pathNodeMap(pathNodeMap)
{
}
Expand Down Expand Up @@ -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
10 changes: 0 additions & 10 deletions lib/mayaUsd/fileio/primReaderContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions lib/mayaUsd/fileio/primUpdaterManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ using PullImportPaths = std::vector<std::pair<MDagPath, Ufe::Path>>;
PullImportPaths pullImport(
const Ufe::Path& ufePulledPath,
const UsdPrim& pulledPrim,
const UsdMayaPrimUpdaterContext& context,
const bool resetXform = false)
const UsdMayaPrimUpdaterContext& context)
{
MayaUsd::ProgressBarScope progressBar(9);

Expand Down Expand Up @@ -333,7 +332,7 @@ PullImportPaths pullImport(
std::vector<MDagPath> 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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -1630,7 +1629,7 @@ std::vector<Ufe::Path> 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();
Expand Down
4 changes: 0 additions & 4 deletions lib/mayaUsd/fileio/translators/translatorXformable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions plugin/pxr/maya/lib/usdMaya/readJobWithSceneAssembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down