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

MAYA-107839 [GitHub 800] USD: exporting the attached maya file using … #2158

Merged
merged 3 commits into from
Mar 8, 2022
Merged
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
21 changes: 17 additions & 4 deletions lib/mayaUsd/fileio/writeJobContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,23 @@ bool UsdMayaWriteJobContext::IsMergedTransform(const MDagPath& path) const

// Any transform with multiple (non-intermediate) shapes below is
// non-mergeable.
unsigned int numberOfShapesDirectlyBelow = 0u;
path.numberOfShapesDirectlyBelow(numberOfShapesDirectlyBelow);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I translated the code of numberOfShapesDirectlyBelow in OpenMaya code and stop if there is more than one shape instead of going through all the shapes to count them since it is not necessary saving 1/2 of the export time,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Yves. Can you add in a comment saying that you expanded out the implementation of MDagPath::numberOfShapesDirectlyBelow() to cut down the time by half. Otherwise, someone will come in and replace your code with numberOfShapesDirectlyBelow().

if (numberOfShapesDirectlyBelow != 1) {
// Expanded out the implementation of MDagPath::numberOfShapesDirectlyBelow() to cut down
// the time by half.
unsigned int numShapes = 0;
const auto childCount = path.childCount();
for (auto child = decltype(childCount) { 0 }; child < childCount; ++child) {
const auto dagObj = path.child(child);
MFnDagNode dagNode(dagObj);
if (dagNode.isIntermediateObject() || dagNode.isIntermediateObject()) {
continue;
}
if (dagObj.hasFn(MFn::kShape)) {
numShapes++;
if (numShapes > 1)
return false;
}
}
if (numShapes != 1) {
return false;
}

Expand All @@ -132,7 +146,6 @@ bool UsdMayaWriteJobContext::IsMergedTransform(const MDagPath& path) const
// For efficiency reasons, since (# exportable children <= # children),
// check the total child count first before checking whether they're
// exportable.
const unsigned int childCount = path.childCount();
if (childCount != 1) {
MDagPath childDag(path);
unsigned int numExportableChildren = 0u;
Expand Down