Skip to content
Merged
Show file tree
Hide file tree
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
34 changes: 18 additions & 16 deletions lib/mayaUsd/fileio/utils/meshReadUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ MIntArray getMayaFaceVertexAssignmentIds(
bool isPrimitiveLeftHanded(const UsdGeomMesh& mesh)
{
TfToken orientation;
if (!mesh.GetOrientationAttr().Get(&orientation)) {
if (!mesh.GetOrientationAttr().Get(&orientation, UsdTimeCode::EarliestTime())) {
return false;
}

Expand All @@ -255,7 +255,7 @@ bool assignUVSetPrimvarToMesh(
const TfToken& primvarName = primvar.GetPrimvarName();

VtVec2fArray uvValues;
if (!primvar.Get(&uvValues) || uvValues.empty()) {
if (!primvar.Get(&uvValues, UsdTimeCode::EarliestTime()) || uvValues.empty()) {
TF_WARN(
"Could not read UV values from primvar '%s' on mesh: %s",
primvarName.GetText(),
Expand Down Expand Up @@ -329,7 +329,7 @@ bool assignUVSetPrimvarToMesh(
}

VtIntArray assignmentIndices;
if (primvar.GetIndices(&assignmentIndices)) {
if (primvar.GetIndices(&assignmentIndices, UsdTimeCode::EarliestTime())) {
if (unauthoredValuesIndex >= 0) {
// Since the unauthored value was removed above, we need to fix up
// the assignment indices to replace any index equal to the
Expand Down Expand Up @@ -419,23 +419,23 @@ bool assignColorSetPrimvarToMesh(

if (typeName == SdfValueTypeNames->FloatArray) {
colorRep = MFnMesh::kAlpha;
if (!primvar.Get(&alphaArray) || alphaArray.empty()) {
if (!primvar.Get(&alphaArray, UsdTimeCode::EarliestTime()) || alphaArray.empty()) {
status = MS::kFailure;
} else {
numValues = alphaArray.size();
}
} else if (
typeName == SdfValueTypeNames->Float3Array || typeName == SdfValueTypeNames->Color3fArray) {
colorRep = MFnMesh::kRGB;
if (!primvar.Get(&rgbArray) || rgbArray.empty()) {
if (!primvar.Get(&rgbArray, UsdTimeCode::EarliestTime()) || rgbArray.empty()) {
status = MS::kFailure;
} else {
numValues = rgbArray.size();
}
} else if (
typeName == SdfValueTypeNames->Float4Array || typeName == SdfValueTypeNames->Color4fArray) {
colorRep = MFnMesh::kRGBA;
if (!primvar.Get(&rgbaArray) || rgbaArray.empty()) {
if (!primvar.Get(&rgbaArray, UsdTimeCode::EarliestTime()) || rgbaArray.empty()) {
status = MS::kFailure;
} else {
numValues = rgbaArray.size();
Expand All @@ -460,7 +460,7 @@ bool assignColorSetPrimvarToMesh(

VtIntArray assignmentIndices;
int unauthoredValuesIndex = -1;
if (primvar.GetIndices(&assignmentIndices)) {
if (primvar.GetIndices(&assignmentIndices, UsdTimeCode::EarliestTime())) {
// The primvar IS indexed, so the indices array is what determines the
// number of color values.
numValues = assignmentIndices.size();
Expand Down Expand Up @@ -613,7 +613,7 @@ bool assignConstantPrimvarToMesh(const UsdGeomPrimvar& primvar, MFnMesh& meshFn)
}

VtValue primvarData;
primvar.Get(&primvarData);
primvar.Get(&primvarData, UsdTimeCode::EarliestTime());

MStatus status { MS::kSuccess };
MPlug plug = meshFn.findPlug(
Expand Down Expand Up @@ -769,7 +769,7 @@ void UsdMayaMeshReadUtils::assignInvisibleFaces(const UsdGeomMesh& mesh, const M

// Set Holes
VtIntArray holeIndices;
mesh.GetHoleIndicesAttr().Get(&holeIndices); // not animatable
mesh.GetHoleIndicesAttr().Get(&holeIndices, UsdTimeCode::EarliestTime()); // not animatable
if (!holeIndices.empty()) {
MUintArray mayaHoleIndices;
mayaHoleIndices.setLength(holeIndices.size());
Expand Down Expand Up @@ -813,8 +813,10 @@ MStatus UsdMayaMeshReadUtils::assignSubDivTagsToMesh(
// Vert Creasing
VtIntArray subdCornerIndices;
VtFloatArray subdCornerSharpnesses;
mesh.GetCornerIndicesAttr().Get(&subdCornerIndices); // not animatable
mesh.GetCornerSharpnessesAttr().Get(&subdCornerSharpnesses); // not animatable
mesh.GetCornerIndicesAttr().Get(
&subdCornerIndices, UsdTimeCode::EarliestTime()); // not animatable
mesh.GetCornerSharpnessesAttr().Get(
&subdCornerSharpnesses, UsdTimeCode::EarliestTime()); // not animatable
if (!subdCornerIndices.empty()) {
if (subdCornerIndices.size() == subdCornerSharpnesses.size()) {
statusOK.clear();
Expand Down Expand Up @@ -875,9 +877,9 @@ MStatus UsdMayaMeshReadUtils::assignSubDivTagsToMesh(
VtIntArray subdCreaseLengths;
VtIntArray subdCreaseIndices;
VtFloatArray subdCreaseSharpnesses;
mesh.GetCreaseLengthsAttr().Get(&subdCreaseLengths);
mesh.GetCreaseIndicesAttr().Get(&subdCreaseIndices);
mesh.GetCreaseSharpnessesAttr().Get(&subdCreaseSharpnesses);
mesh.GetCreaseLengthsAttr().Get(&subdCreaseLengths, UsdTimeCode::EarliestTime());
mesh.GetCreaseIndicesAttr().Get(&subdCreaseIndices, UsdTimeCode::EarliestTime());
mesh.GetCreaseSharpnessesAttr().Get(&subdCreaseSharpnesses, UsdTimeCode::EarliestTime());
if (!subdCreaseLengths.empty()) {
if (subdCreaseLengths.size() == subdCreaseSharpnesses.size()) {
MUintArray mayaCreaseEdgeIds;
Expand Down Expand Up @@ -1060,7 +1062,7 @@ MStatus UsdMayaMeshReadUtils::getComponentTags(
// Get the indices out of the subset
VtIntArray faceIndices;
UsdAttribute indicesAttribute = ss.GetIndicesAttr();
indicesAttribute.Get(&faceIndices);
indicesAttribute.Get(&faceIndices, UsdTimeCode::EarliestTime());

MFnSingleIndexedComponent compFn;
MObject faceComp = compFn.create(MFn::kMeshPolygonComponent, &status);
Expand All @@ -1079,7 +1081,7 @@ MStatus UsdMayaMeshReadUtils::getComponentTags(
JsObject subsetRoundtripData;

TfToken familyName;
ss.GetFamilyNameAttr().Get(&familyName);
ss.GetFamilyNameAttr().Get(&familyName, UsdTimeCode::EarliestTime());
if (familyName != UsdMayaGeomSubsetTokens->ComponentTagFamilyName) {
subsetRoundtripData[ss.GetFamilyNameAttr().GetBaseName()]
= JsValue(familyName.GetString());
Expand Down
1 change: 1 addition & 0 deletions test/lib/usd/translators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ set(TEST_SCRIPT_FILES
testUsdImportInstances.py
testUsdImportLight.py
testUsdImportMayaReference.py
testUsdImportAlembicReference.py
testUsdImportMesh.py
testUsdImportPointCache.py
testUsdImportPreviewSurface.py
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#usda 1.0
(
defaultPrim = "root"
metersPerUnit = 0.01
upAxis = "Y"
)

def Xform "root" (
prepend apiSchemas = ["GeomModelAPI"]
)
{
def Mesh "refer" (
prepend references = @./cone.abc@
)
{
}
}

60 changes: 60 additions & 0 deletions test/lib/usd/translators/testUsdImportAlembicReference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env mayapy
#
# Copyright 2026 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from pxr import UsdGeom

import mayaUsd.lib as mayaUsdLib

from maya import cmds
from maya import standalone

import os
import unittest

import fixturesUtils

class testUsdImportAlembicReference(unittest.TestCase):

@classmethod
def setUpClass(cls):
inputPath = fixturesUtils.readOnlySetUpClass(__file__)

usdFile = os.path.join(inputPath, "UsdImportAlembicReferenceTest", "referencing-cone.usda")
cmds.usdImport(file=usdFile, shadingMode=[['none', 'default'], ])

@classmethod
def tearDownClass(cls):
standalone.uninitialize()

def verifyUVSet(self, mesh):
self.assertTrue(cmds.objExists(mesh))
self.assertEqual(cmds.getAttr(mesh + ".uvSet", size=True), 1)
self.assertEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetName"), "st")
self.assertEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetPoints", size=True), 42)
self.assertAlmostEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetPoints[0]")[0][0], 0.73776429, places=6)
self.assertAlmostEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetPoints[0]")[0][1], 0.1727457, places=6)
self.assertAlmostEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetPoints[1]")[0][0], 0.70225441, places=6)
self.assertAlmostEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetPoints[1]")[0][1], 0.103053599, places=6)
self.assertAlmostEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetPoints[41]")[0][0], 0.5, places=6)
self.assertAlmostEqual(cmds.getAttr(mesh + ".uvSet[0].uvSetPoints[41]")[0][1], 1.0, places=6)

def testImportPoly(self):
self.verifyUVSet('refer')


if __name__ == '__main__':
unittest.main(verbosity=2)
Loading