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

Pixar Mesh write translator/utilities refactoring #420

Merged
merged 47 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0a2e072
Refactored _GetDagPath, _GetDagPathMap and moved them under UsdMayaUt…
Apr 10, 2020
f87dae6
Rename meshUtil to meshReadUtils.
Apr 10, 2020
4fe993e
- Initial commit to introduce TranslatorMeshWrite class ( this class …
Apr 10, 2020
b67e5e2
- Remove meshWriter_Subdiv and start using UsdMayaMeshUtil::assignSub…
Apr 10, 2020
8b94425
Created utility functions for writing Maya mesh data to USD:
Apr 10, 2020
a0ee49c
Create utility functions for writing out UVSets as Vec2f Primvars.
Apr 10, 2020
4160201
Removed meshWriter_Skin and created a new utility namespace (UsdMayaJ…
Apr 10, 2020
5c8f3a6
Removed meshWriter_Primvars and created a new utility for writing col…
Apr 10, 2020
331aee4
Start using UsdMayaWriteUtil::SetAttribute utilities in all writers:
Apr 10, 2020
9750303
Created utility functions for writing Maya mesh data to USD:
Apr 10, 2020
9c0ade6
Address feedback: use getDagPath() in UsdMayaWriteJobContext::CreateP…
May 25, 2020
1e492f2
Address feedbacks.
May 27, 2020
80f2240
Address feedback ( Matt ).
May 27, 2020
2b1e304
Address feedback ( Rob ).
May 27, 2020
9f2d55a
Address feedback: remove unnecessary try/catch.
May 27, 2020
45f0f51
Address feedback: rename wrapMeshUtil to wrapMeshWriteUtils
May 27, 2020
8e3a0ac
address feedback.
May 27, 2020
b7a202b
address feedback: make sure to handle both DAG nodes or DG nodes.
May 27, 2020
a02159c
Address feedback:
May 27, 2020
4ca16c0
Address feedback: use VtVec3fArray, VtIntArray, VtFloatArray instead …
May 27, 2020
ab0a321
Address feedback: return early if the status is false.
May 27, 2020
b5ec789
Merge pull request #421 from Autodesk/sabrih/MAYA-101460/pxr_mesh_wri…
HamedSabri-adsk May 28, 2020
25a5c20
Merge branch 'sabrih/MAYA-101460/pxr_mesh_write_part3' into sabrih/MA…
May 28, 2020
812adf6
Merge branch 'sabrih/MAYA-101460/pxr_mesh_write_part1' into sabrih/MA…
HamedSabri-adsk May 28, 2020
9b138b3
Merge pull request #423 from Autodesk/sabrih/MAYA-101460/pxr_mesh_wri…
HamedSabri-adsk May 28, 2020
9cb5880
Merge branch 'sabrih/MAYA-101460/pxr_mesh_write_part5' into sabrih/MA…
May 28, 2020
d5426d3
Address feedbacks:
May 28, 2020
047a097
Merge branch 'sabrih/MAYA-101460/pxr_mesh_write_part6' into sabrih/MA…
May 28, 2020
c1682b3
post merge fixes.
May 28, 2020
2d15079
address feedback:
May 29, 2020
2ea47fd
Merge pull request #426 from Autodesk/sabrih/MAYA-101460/pxr_mesh_wri…
HamedSabri-adsk May 29, 2020
35c0c0f
Address feedback: add parameter names in a function prototype
May 29, 2020
12ad434
address feedback: replace Default with Unauthored
May 29, 2020
5a64848
Address feedback: use VtVec3fArray, VtIntArray, VtFloatArray instead …
May 29, 2020
f7f193b
address feedback: fix the comments pointing at the old function names.
May 29, 2020
a7ccad1
address feedback: remove changes that were accidentally pulled into t…
May 29, 2020
6a4686e
Merge branch 'sabrih/MAYA-101460/pxr_mesh_write_part8' into sabrih/MA…
May 29, 2020
5ecb68c
Fix post merge!
May 29, 2020
062ac5a
Add feedback: refactor SetAttribute termplate functions.
Jun 1, 2020
21850e1
Merge branch 'sabrih/MAYA-101460/pxr_mesh_write_part9' into sabrih/MA…
Jun 1, 2020
39c824f
Merge branch 'dev' into sabrih/MAYA-101460/pxr_mesh_write_part1
Jun 1, 2020
d891b7e
Address feedback: swap the last 2 arguments passed to SetAttribute te…
Jun 1, 2020
a520d00
Fix python binding.
Jun 5, 2020
53dd501
Merge branch 'dev' into sabrih/MAYA-101460/pxr_mesh_write_part1
Jun 10, 2020
5803a46
comment out the logics in wrapMeshWriteUtils. This code is not used a…
Jun 11, 2020
be3c545
Revert "comment out the logics in wrapMeshWriteUtils. This code is no…
Jun 11, 2020
7a1f16a
Merge branch 'dev' into sabrih/MAYA-101460/pxr_mesh_write_part1
Jun 30, 2020
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
47 changes: 2 additions & 45 deletions lib/mayaUsd/fileio/primUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,56 +22,13 @@

PXR_NAMESPACE_OPEN_SCOPE

static
MDagPath
_GetDagPath(const MFnDependencyNode& depNodeFn, const bool reportError = true)
{
try {
const MFnDagNode& dagNodeFn =
dynamic_cast<const MFnDagNode&>(depNodeFn);

MStatus status;
const MDagPath dagPath = dagNodeFn.dagPath(&status);
if (status == MS::kSuccess) {
const bool dagPathIsValid = dagPath.isValid(&status);
if (status == MS::kSuccess && dagPathIsValid) {
return dagPath;
}
}

if (reportError) {
TF_CODING_ERROR(
"Invalid MDagPath for MFnDagNode '%s'. Verify that it was "
"constructed using an MDagPath.",
dagNodeFn.fullPathName().asChar());
}
}
catch (const std::bad_cast& /* e */) {
// This is not a DAG node, so it can't have a DAG path.
}

return MDagPath();
}

static
UsdMayaUtil::MDagPathMap<SdfPath>
_GetDagPathMap(const MFnDependencyNode& depNodeFn, const SdfPath& usdPath)
{
const MDagPath dagPath = _GetDagPath(depNodeFn, /* reportError = */ false);
if (dagPath.isValid()) {
return UsdMayaUtil::MDagPathMap<SdfPath>({ {dagPath, usdPath} });
}

return UsdMayaUtil::MDagPathMap<SdfPath>({});
}

UsdMayaPrimUpdater::UsdMayaPrimUpdater(
const MFnDependencyNode& depNodeFn,
const SdfPath& usdPath) :
_dagPath(_GetDagPath(depNodeFn)),
_dagPath(UsdMayaUtil::getDagPath(depNodeFn)),
_mayaObject(depNodeFn.object()),
_usdPath(usdPath),
_baseDagToUsdPaths(_GetDagPathMap(depNodeFn, usdPath))
_baseDagToUsdPaths(UsdMayaUtil::getDagPathMap(depNodeFn, usdPath))
{
}

Expand Down
48 changes: 2 additions & 46 deletions lib/mayaUsd/fileio/primWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,50 +58,6 @@ TF_DEFINE_PRIVATE_TOKENS(
(USD_inheritClassNames)
);


static
MDagPath
_GetDagPath(const MFnDependencyNode& depNodeFn, const bool reportError = true)
{
try {
const MFnDagNode& dagNodeFn =
dynamic_cast<const MFnDagNode&>(depNodeFn);

MStatus status;
const MDagPath dagPath = dagNodeFn.dagPath(&status);
if (status == MS::kSuccess) {
const bool dagPathIsValid = dagPath.isValid(&status);
if (status == MS::kSuccess && dagPathIsValid) {
return dagPath;
}
}

if (reportError) {
TF_CODING_ERROR(
"Invalid MDagPath for MFnDagNode '%s'. Verify that it was "
"constructed using an MDagPath.",
dagNodeFn.fullPathName().asChar());
}
}
catch (const std::bad_cast& /* e */) {
// This is not a DAG node, so it can't have a DAG path.
}

return MDagPath();
}

static
UsdMayaUtil::MDagPathMap<SdfPath>
_GetDagPathMap(const MFnDependencyNode& depNodeFn, const SdfPath& usdPath)
{
const MDagPath dagPath = _GetDagPath(depNodeFn, /* reportError = */ false);
if (dagPath.isValid()) {
return UsdMayaUtil::MDagPathMap<SdfPath>({{dagPath, usdPath}});
}

return UsdMayaUtil::MDagPathMap<SdfPath>({});
}

static
bool
_IsAnimated(const UsdMayaJobExportArgs& args, const MObject& obj)
Expand All @@ -118,10 +74,10 @@ UsdMayaPrimWriter::UsdMayaPrimWriter(
const SdfPath& usdPath,
UsdMayaWriteJobContext& jobCtx) :
_writeJobCtx(jobCtx),
_dagPath(_GetDagPath(depNodeFn)),
_dagPath(UsdMayaUtil::getDagPath(depNodeFn)),
_mayaObject(depNodeFn.object()),
_usdPath(usdPath),
_baseDagToUsdPaths(_GetDagPathMap(depNodeFn, usdPath)),
_baseDagToUsdPaths(UsdMayaUtil::getDagPathMap(depNodeFn, usdPath)),
_exportVisibility(jobCtx.GetArgs().exportVisibility),
_hasAnimCurves(_IsAnimated(jobCtx.GetArgs(), depNodeFn.object()))
{
Expand Down
13 changes: 4 additions & 9 deletions lib/mayaUsd/fileio/writeJobContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,16 +476,10 @@ UsdMayaWriteJobContext::CreatePrimWriter(
SdfPath writePath = usdPath;

try {
const MFnDagNode& dagNodeFn =
dynamic_cast<const MFnDagNode&>(depNodeFn);
const MDagPath dagPath =
UsdMayaUtil::getDagPath(depNodeFn, /* reportError = */ false);

MStatus status;
const MDagPath dagPath = dagNodeFn.dagPath(&status);
if (status != MS::kSuccess || !dagPath.isValid()) {
TF_CODING_ERROR(
"Invalid MDagPath for MFnDagNode '%s'. Verify that it was "
"constructed using an MDagPath.",
dagNodeFn.fullPathName().asChar());
if (!dagPath.isValid()) {
return nullptr;
mattyjams marked this conversation as resolved.
Show resolved Hide resolved
}

Expand All @@ -498,6 +492,7 @@ UsdMayaWriteJobContext::CreatePrimWriter(
writePath = ConvertDagToUsdPath(dagPath);
}

const MFnDagNode dagNodeFn(dagPath);
const bool instanced = dagNodeFn.isInstanced(/* indirect = */ false);
if (mArgs.exportInstances && instanced && !forceUninstance) {
// Deal with instances -- we use a special internal writer for them.
Expand Down
41 changes: 41 additions & 0 deletions lib/mayaUsd/utils/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2029,3 +2029,44 @@ UsdMayaUtil::convert(const std::string& str)
{
return MString(str.data(), static_cast<int>(str.size()));
}

MDagPath
UsdMayaUtil::getDagPath(const MFnDependencyNode& depNodeFn, const bool reportError)
{
try {
const MFnDagNode& dagNodeFn =
dynamic_cast<const MFnDagNode&>(depNodeFn);

MStatus status;
const MDagPath dagPath = dagNodeFn.dagPath(&status);
if (status == MS::kSuccess) {
const bool dagPathIsValid = dagPath.isValid(&status);
if (status == MS::kSuccess && dagPathIsValid) {
return dagPath;
}
}

if (reportError) {
TF_CODING_ERROR(
"Invalid MDagPath for MFnDagNode '%s'. Verify that it was "
"constructed using an MDagPath.",
dagNodeFn.fullPathName().asChar());
}
}
catch (const std::bad_cast& /* e */) {
// This is not a DAG node, so it can't have a DAG path.
}

return MDagPath();
}

UsdMayaUtil::MDagPathMap<SdfPath>
UsdMayaUtil::getDagPathMap(const MFnDependencyNode& depNodeFn, const SdfPath& usdPath)
{
const MDagPath dagPath = UsdMayaUtil::getDagPath(depNodeFn, /* reportError = */ false);
if (dagPath.isValid()) {
return UsdMayaUtil::MDagPathMap<SdfPath>({{dagPath, usdPath}});
}

return UsdMayaUtil::MDagPathMap<SdfPath>({});
}
8 changes: 6 additions & 2 deletions lib/mayaUsd/utils/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,14 @@ MString convert(const TfToken& token);
MAYAUSD_CORE_PUBLIC
std::string convert(const MString&);

} // namespace UsdMayaUtil
MAYAUSD_CORE_PUBLIC
MDagPath getDagPath(const MFnDependencyNode& depNodeFn, const bool reportError = true);
mattyjams marked this conversation as resolved.
Show resolved Hide resolved

MAYAUSD_CORE_PUBLIC
MDagPathMap<SdfPath> getDagPathMap(const MFnDependencyNode& depNodeFn, const SdfPath& usdPath);

} // namespace UsdMayaUtil

PXR_NAMESPACE_CLOSE_SCOPE


#endif