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 NURBS curves with rational (weighted) CVs are not properly transferred to/from USD #3435

Open
jbherdman opened this issue Nov 2, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jbherdman
Copy link

Describe the bug
Maya NURBS curves with rational (weighted) CVs are not properly transferred to/from USD.

Steps to reproduce
Steps to reproduce the behavior:

  1. See the attached Maya scene in nurbs_curve_weights.ma. This scene contains two NURBS curves that only differ by the presence of non-default 'weights' on the CVs.
  2. Export the scene to USD. The necessary pointWeights attribute is not present in the USD file.

Expected behavior
Here is a hand-edited example containing the USD file exported from Maya, but with the expected pointWeights attribute added in: nurbs_curve_weights_fixed.usda

The original scene should easily round-trip through USD (setting the pointWeights on export, and reading them back on import).

Attachments
Here is an image showing the attached sample-scene. The NURBS curve with weighted CVs is highlighted. Other than the CV weights, the two curves are identical (although offset by one unit in the Z direction for testing purposes).
highlighted_has_cv_weights

Additional context
In roughly this block of the USD-importing code:

size_t mayaNumVertices = curveVertexCounts[curveIndex];
MPointArray mayaPoints(mayaNumVertices);
for (size_t i = 0; i < mayaNumVertices; i++) {
size_t ipos = i + indexOffset;
mayaPoints.set(i, points[ipos][0], points[ipos][1], points[ipos][2]);
}
double* knots = _curveKnots.data();
MDoubleArray mayaKnots(knots, _curveKnots.size());
MFnNurbsCurve::Form mayaCurveForm = MFnNurbsCurve::kOpen; // HARDCODED
bool mayaCurveCreate2D = false;
bool mayaCurveCreateRational = true;

We can see from this code that a "rational" curve is already being created. The call to mayaPoints.set() on line 219 just needs to be augmented to pass in the USD weights. Those would need to be extracted earlier via a call to curves.GetPointWeightsAttr().

Similarly, for export to USD, the weights embedded in the MPointArray would need to be extracted and sent to primSchema.GetPointWeightsAttr() in the body of this method:

bool PxrUsdTranslators_NurbsCurveWriter::writeNurbsCurveAttrs(

@jbherdman jbherdman added the bug Something isn't working label Nov 2, 2023
@github-project-automation github-project-automation bot moved this to Needs triage in maya-usd Nov 8, 2023
@Autodesk Autodesk deleted a comment from maya-usd-git-sync bot Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Needs triage
Development

No branches or pull requests

2 participants