-
Notifications
You must be signed in to change notification settings - Fork 201
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-113077: componentTag IO to files #1755
Changes from 7 commits
bb4cab0
3325430
c03e716
9c725a3
c1ebcca
b7293f2
a5a6352
c096e95
9789ffe
56d22ac
2d94aca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,16 @@ | |
#include <pxr/usd/usdGeom/mesh.h> | ||
#include <pxr/usd/usdGeom/pointBased.h> | ||
#include <pxr/usd/usdGeom/primvar.h> | ||
#include <pxr/usd/usdGeom/subset.h> | ||
#include <pxr/usd/usdGeom/tokens.h> | ||
#include <pxr/usd/usdUtils/pipeline.h> | ||
|
||
#include <maya/MBoundingBox.h> | ||
#include <maya/MFnAttribute.h> | ||
#include <maya/MFnGeometryData.h> | ||
#include <maya/MFnMesh.h> | ||
#include <maya/MFnSet.h> | ||
#include <maya/MFnSingleIndexedComponent.h> | ||
#include <maya/MGlobal.h> | ||
#include <maya/MIntArray.h> | ||
#include <maya/MItDependencyGraph.h> | ||
|
@@ -1369,4 +1372,53 @@ bool UsdMayaMeshWriteUtils::getMeshColorSetData( | |
return true; | ||
} | ||
|
||
MStatus UsdMayaMeshWriteUtils::exportComponentTags(UsdGeomMesh& primSchema, MObject obj) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why to even make this method available for older versions of Maya? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted to change Hans code as little as possible, but I can move the #ifdef out and #ifdef atthe caller site too instead of having a do-nothing function in older versions of Maya. |
||
{ | ||
MStatus status { MS::kSuccess }; | ||
|
||
#if MAYA_API_VERSION >= 20220000 | ||
|
||
MFnDependencyNode dNode(obj, &status); | ||
CHECK_MSTATUS_AND_RETURN_IT(status); | ||
|
||
const MFnDependencyNode depNodeFn(obj, &status); | ||
MPlug outShp = depNodeFn.findPlug("outMesh", &status); | ||
CHECK_MSTATUS_AND_RETURN_IT(status); | ||
|
||
MDataHandle geomDataHandle = outShp.asMDataHandle(); | ||
MObject geomObj = geomDataHandle.data(); | ||
if (geomObj.hasFn(MFn::kGeometryData)) { | ||
TfToken componentTagFamilyName("componentTag"); | ||
MFnGeometryData fnGeomData(geomObj); | ||
MStringArray keys; | ||
status = fnGeomData.componentTags(keys); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This status doesn't seem to be checked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and it is not the only one, there are others a bit below. In all cases, the code seems to rely on the returned data (for example the set of keys) to be empty. Of course, that could cause silent failures. I'll add more early returns. |
||
for (unsigned int i = 0; i < keys.length(); ++i) { | ||
MFnGeometryData::ComponentTagCategory ctg | ||
= fnGeomData.componentTagCategory(keys[i], &status); | ||
if (ctg == MFnGeometryData::ComponentTagCategory::kFaces) { | ||
MObject contents = fnGeomData.componentTagContents(keys[i], &status); | ||
if (contents.hasFn(MFn::kSingleIndexedComponent)) { | ||
MFnSingleIndexedComponent fnSingleIndexedComponent(contents, &status); | ||
MIntArray curIndices; | ||
status = fnSingleIndexedComponent.getElements(curIndices); | ||
VtIntArray indices; | ||
indices.reserve(curIndices.length()); | ||
for (unsigned int j = 0; j < curIndices.length(); ++j) | ||
indices.push_back(curIndices[j]); | ||
UsdGeomSubset ss = UsdGeomSubset::CreateGeomSubset( | ||
primSchema, | ||
TfToken(keys[i].asChar()), | ||
UsdGeomTokens->face, | ||
indices, | ||
componentTagFamilyName); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif | ||
|
||
return status; | ||
} | ||
|
||
PXR_NAMESPACE_CLOSE_SCOPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to make this method available in older versions of Maya?