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-114297 MAYA-114300 Job context UI #1842

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions lib/mayaUsd/commands/baseExportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MSyntax MayaUSDExportCommand::createSyntax()
MSyntax syntax;

// These flags correspond to entries in
// UsdMayaJobExportArgs::GetDefaultDictionary.
// UsdMayaJobExportArgs::GetGuideDictionary.
syntax.addFlag(
kMergeTransformAndShapeFlag,
UsdMayaJobExportArgsTokens->mergeTransformAndShape.GetText(),
Expand Down Expand Up @@ -245,7 +245,7 @@ MStatus MayaUSDExportCommand::doIt(const MArgList& args)

// Read all of the dictionary args first.
const VtDictionary userArgs = UsdMayaUtil::GetDictionaryFromArgDatabase(
argData, UsdMayaJobExportArgs::GetDefaultDictionary());
argData, UsdMayaJobExportArgs::GetGuideDictionary());
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function works best if the dictionary passed contains fully typed values. The "Default" dictionary has a tendency to contain empty vectors for args that take a list, and this does not provide enough information about what goes into the list (especially chaserArgs where the contents are themselves vectors). The newly introduced "Guide" dictionary provides all the information for proper parsing.


// Now read all of the other args that are specific to this command.
bool append = false;
Expand Down
4 changes: 2 additions & 2 deletions lib/mayaUsd/commands/baseImportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MSyntax MayaUSDImportCommand::createSyntax()
MSyntax syntax;

// These flags correspond to entries in
// UsdMayaJobImportArgs::GetDefaultDictionary.
// UsdMayaJobImportArgs::GetGuideDictionary.
syntax.addFlag(
kShadingModeFlag,
UsdMayaJobImportArgsTokens->shadingMode.GetText(),
Expand Down Expand Up @@ -136,7 +136,7 @@ MStatus MayaUSDImportCommand::doIt(const MArgList& args)

// Get dictionary values.
const VtDictionary userArgs = UsdMayaUtil::GetDictionaryFromArgDatabase(
argData, UsdMayaJobImportArgs::GetDefaultDictionary());
argData, UsdMayaJobImportArgs::GetGuideDictionary());

std::string mFileName;
if (argData.isFlagSet(kFileFlag)) {
Expand Down
97 changes: 97 additions & 0 deletions lib/mayaUsd/fileio/jobs/jobArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,69 @@ const VtDictionary& UsdMayaJobExportArgs::GetDefaultDictionary()
return d;
}

const VtDictionary& UsdMayaJobExportArgs::GetGuideDictionary()
{
static VtDictionary d;
static std::once_flag once;

std::call_once(once, []() {
// Common types:
const auto _boolean = VtValue(false);
const auto _string = VtValue(std::string());
const auto _stringVector = VtValue(std::vector<VtValue>({ _string }));
const auto _stringTriplet = VtValue(std::vector<VtValue>({ _string, _string, _string }));
const auto _stringTripletVector = VtValue(std::vector<VtValue>({ _stringTriplet }));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The value is not important. Only the type.


// Provide guide types for the parser:
d[UsdMayaJobExportArgsTokens->chaser] = _stringVector;
d[UsdMayaJobExportArgsTokens->chaserArgs] = _stringTripletVector;
d[UsdMayaJobExportArgsTokens->compatibility] = _string;
d[UsdMayaJobExportArgsTokens->defaultCameras] = _boolean;
d[UsdMayaJobExportArgsTokens->defaultMeshScheme] = _string;
d[UsdMayaJobExportArgsTokens->defaultUSDFormat] = _string;
d[UsdMayaJobExportArgsTokens->eulerFilter] = _boolean;
d[UsdMayaJobExportArgsTokens->exportCollectionBasedBindings] = _boolean;
d[UsdMayaJobExportArgsTokens->exportColorSets] = _boolean;
d[UsdMayaJobExportArgsTokens->exportDisplayColor] = _boolean;
d[UsdMayaJobExportArgsTokens->exportInstances] = _boolean;
d[UsdMayaJobExportArgsTokens->exportMaterialCollections] = _boolean;
d[UsdMayaJobExportArgsTokens->exportReferenceObjects] = _boolean;
d[UsdMayaJobExportArgsTokens->exportRefsAsInstanceable] = _boolean;
d[UsdMayaJobExportArgsTokens->exportRoots] = _stringVector;
d[UsdMayaJobExportArgsTokens->exportSkin] = _string;
d[UsdMayaJobExportArgsTokens->exportSkels] = _string;
d[UsdMayaJobExportArgsTokens->exportBlendShapes] = _boolean;
d[UsdMayaJobExportArgsTokens->exportUVs] = _boolean;
d[UsdMayaJobExportArgsTokens->exportVisibility] = _boolean;
d[UsdMayaJobExportArgsTokens->exportComponentTags] = _boolean;
d[UsdMayaJobExportArgsTokens->file] = _string;
d[UsdMayaJobExportArgsTokens->filterTypes] = _stringVector;
d[UsdMayaJobExportArgsTokens->ignoreWarnings] = _boolean;
d[UsdMayaJobExportArgsTokens->kind] = _string;
d[UsdMayaJobExportArgsTokens->materialCollectionsPath] = _string;
d[UsdMayaJobExportArgsTokens->materialsScopeName] = _string;
d[UsdMayaJobExportArgsTokens->melPerFrameCallback] = _string;
d[UsdMayaJobExportArgsTokens->melPostCallback] = _string;
d[UsdMayaJobExportArgsTokens->mergeTransformAndShape] = _boolean;
d[UsdMayaJobExportArgsTokens->normalizeNurbs] = _boolean;
d[UsdMayaJobExportArgsTokens->parentScope] = _string;
d[UsdMayaJobExportArgsTokens->pythonPerFrameCallback] = _string;
d[UsdMayaJobExportArgsTokens->pythonPostCallback] = _string;
d[UsdMayaJobExportArgsTokens->renderableOnly] = _boolean;
d[UsdMayaJobExportArgsTokens->renderLayerMode] = _string;
d[UsdMayaJobExportArgsTokens->shadingMode] = _string;
d[UsdMayaJobExportArgsTokens->convertMaterialsTo] = _stringVector;
d[UsdMayaJobExportArgsTokens->apiSchema] = _stringVector;
d[UsdMayaJobExportArgsTokens->jobContext] = _stringVector;
d[UsdMayaJobExportArgsTokens->stripNamespaces] = _boolean;
d[UsdMayaJobExportArgsTokens->verbose] = _boolean;
d[UsdMayaJobExportArgsTokens->staticSingleSample] = _boolean;
d[UsdMayaJobExportArgsTokens->geomSidedness] = _string;
});

return d;
}

std::string UsdMayaJobExportArgs::GetResolvedFileName() const
{
MFileObject fileObj;
Expand Down Expand Up @@ -896,6 +959,40 @@ const VtDictionary& UsdMayaJobImportArgs::GetDefaultDictionary()
return d;
}

/* static */
const VtDictionary& UsdMayaJobImportArgs::GetGuideDictionary()
{
static VtDictionary d;
static std::once_flag once;
std::call_once(once, []() {
// Common types:
const auto _boolean = VtValue(false);
const auto _string = VtValue(std::string());
const auto _stringVector = VtValue(std::vector<VtValue>({ _string }));
const auto _stringTuplet = VtValue(std::vector<VtValue>({ _string, _string, _string }));
const auto _stringTriplet = VtValue(std::vector<VtValue>({ _string, _string, _string }));
const auto _stringTupletVector = VtValue(std::vector<VtValue>({ _stringTuplet }));
const auto _stringTripletVector = VtValue(std::vector<VtValue>({ _stringTriplet }));

// Provide guide types for the parser:
d[UsdMayaJobImportArgsTokens->assemblyRep] = _string;
d[UsdMayaJobImportArgsTokens->apiSchema] = _stringVector;
d[UsdMayaJobImportArgsTokens->excludePrimvar] = _stringVector;
d[UsdMayaJobImportArgsTokens->jobContext] = _stringVector;
d[UsdMayaJobImportArgsTokens->metadata] = _stringVector;
d[UsdMayaJobImportArgsTokens->shadingMode] = _stringTupletVector;
d[UsdMayaJobImportArgsTokens->preferredMaterial] = _string;
d[UsdMayaJobImportArgsTokens->importInstances] = _boolean;
d[UsdMayaJobImportArgsTokens->importUSDZTextures] = _boolean;
d[UsdMayaJobImportArgsTokens->importUSDZTexturesFilePath] = _string;
d[UsdMayaJobImportArgsTokens->useAsAnimationCache] = _boolean;
d[UsdMayaJobExportArgsTokens->chaser] = _stringVector;
d[UsdMayaJobExportArgsTokens->chaserArgs] = _stringTripletVector;
});

return d;
}

const std::string UsdMayaJobImportArgs::GetImportUSDZTexturesFilePath(const VtDictionary& userArgs)
{
if (!_Boolean(userArgs, UsdMayaJobImportArgsTokens->importUSDZTextures))
Expand Down
12 changes: 12 additions & 0 deletions lib/mayaUsd/fileio/jobs/jobArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ struct UsdMayaJobExportArgs
MAYAUSD_CORE_PUBLIC
static const VtDictionary& GetDefaultDictionary();

/// Gets the guide dictionary for UsdMayaJobExportArgs.
///
/// Used in GetDictionaryFromArgDatabase() to deduce the type of an argument.
MAYAUSD_CORE_PUBLIC
static const VtDictionary& GetGuideDictionary();

/// Returns the resolved file name of the final export location
MAYAUSD_CORE_PUBLIC
std::string GetResolvedFileName() const;
Expand Down Expand Up @@ -321,6 +327,12 @@ struct UsdMayaJobImportArgs
MAYAUSD_CORE_PUBLIC
static const VtDictionary& GetDefaultDictionary();

/// Gets the guide dictionary for UsdMayaJobImportArgs.
///
/// Used in GetDictionaryFromArgDatabase() to deduce the type of an argument.
MAYAUSD_CORE_PUBLIC
static const VtDictionary& GetGuideDictionary();

MAYAUSD_CORE_PUBLIC
static const std::string GetImportUSDZTexturesFilePath(const VtDictionary& userArgs);

Expand Down
4 changes: 4 additions & 0 deletions lib/mayaUsd/utils/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,10 @@ std::pair<bool, std::string> UsdMayaUtil::ValueToArgument(const VtValue& value)
{
if (value.IsHolding<bool>()) {
return std::make_pair(true, std::string(value.Get<bool>() ? "1" : "0"));
} else if (value.IsHolding<int>()) {
return std::make_pair(true, std::to_string(value.Get<int>()));
} else if (value.IsHolding<float>()) {
return std::make_pair(true, std::to_string(value.Get<float>()));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We have int and float values in the args: startTime, endTime, frameStride, so we need a way to unparse them.

} else if (value.IsHolding<std::string>()) {
return std::make_pair(true, value.Get<std::string>());
} else if (value.IsHolding<std::vector<VtValue>>()) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/adsk/plugin/exportTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ MStatus UsdMayaExportTranslator::writer(
userArgs[argName] = UsdMayaUtil::ParseArgumentValue(
argName,
theOption[1].asChar(),
PXR_NS::UsdMayaJobExportArgs::GetDefaultDictionary());
PXR_NS::UsdMayaJobExportArgs::GetGuideDictionary());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/adsk/plugin/importTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ MStatus UsdMayaImportTranslator::reader(
importData.setRootPrimPath(theOption[1].asChar());
} else {
userArgs[argName] = UsdMayaUtil::ParseArgumentValue(
argName, theOption[1].asChar(), UsdMayaJobImportArgs::GetDefaultDictionary());
argName, theOption[1].asChar(), UsdMayaJobImportArgs::GetGuideDictionary());
}
}
}
Expand Down
Loading