From 7763dd6dfd74485b3abf4c5ae1550e33a51a051a Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:25:46 -0800 Subject: [PATCH 01/13] remove CompressibleUVSetsCube test case from testUsdExportUVSets test We'll no longer be applying any compression to UV sets when exporting from Maya to USD. --- .../UsdExportUVSetsTest_Float.ma | 85 ------------------- .../UsdExportUVSetsTest.ma | 85 ------------------- .../usd/translators/testUsdExportUVSets.py | 65 +------------- 3 files changed, 1 insertion(+), 234 deletions(-) diff --git a/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma b/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma index eba75196ad..19908c263c 100644 --- a/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma +++ b/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma @@ -326,90 +326,6 @@ createNode mesh -n "polySurfaceShape2" -p "OneAssignedFaceCube"; setAttr ".hfd" -type "dataPolyComponent" Index_Data Face 0 ; setAttr ".mgi" -type "string" "ID_41632452-941c-445a-8955-d85daaf8813f"; setAttr ".allowPerFaceDisplayColors" yes; -createNode transform -n "CompressibleUVSetsCube" -p "CubeMeshes"; - rename -uid "6BB5D8C0-0000-562B-57BB-88050000027F"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr ".t" -type "double3" -20 0 0 ; - setAttr ".rp" -type "double3" 0 0 5 ; - setAttr ".sp" -type "double3" 0 0 5 ; - setAttr ".allowPerFaceDisplayColors" yes; -createNode mesh -n "CompressibleUVSetsCubeShape" -p "CompressibleUVSetsCube"; - rename -uid "6BB5D8C0-0000-562B-57BB-880500000280"; - addAttr -ci true -sn "mgi" -ln "mayaGprimID" -dt "string"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr -k off ".v"; - setAttr -s 6 ".iog[0].og"; - setAttr ".iog[0].og[0].gcl" -type "componentList" 1 "f[2]"; - setAttr ".iog[0].og[1].gcl" -type "componentList" 1 "f[3]"; - setAttr ".iog[0].og[2].gcl" -type "componentList" 1 "f[4]"; - setAttr ".iog[0].og[3].gcl" -type "componentList" 1 "f[1]"; - setAttr ".iog[0].og[4].gcl" -type "componentList" 1 "f[5]"; - setAttr ".iog[0].og[5].gcl" -type "componentList" 1 "f[0]"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr -s 4 ".uvst"; - setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".uvst[1].uvsn" -type "string" "ConstantInterpSet"; - setAttr -s 22 ".uvst[1].uvsp[0:21]" -type "float2" 0.25 0.25 0.25 0.25 - 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 - 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 - 0.25 0.25 0.25 0.25 0.25 0.25; - setAttr ".uvst[2].uvsn" -type "string" "UniformInterpSet"; - setAttr -s 24 ".uvst[2].uvsp[0:23]" -type "float2" 0 0 0.1 0.1 0.2 0.2 - 0.30000001 0.30000001 0.40000001 0.40000001 0.5 0.5 0 0 0 0 0 0 0.1 0.1 0.1 0.1 0.1 - 0.1 0.2 0.2 0.2 0.2 0.2 0.2 0.30000001 0.30000001 0.30000001 0.30000001 0.30000001 - 0.30000001 0.40000001 0.40000001 0.40000001 0.40000001 0.40000001 0.40000001 0.5 - 0.5 0.5 0.5 0.5 0.5; - setAttr ".uvst[3].uvsn" -type "string" "VertexInterpSet"; - setAttr -s 8 ".uvst[3].uvsp[0:7]" -type "float2" 0 0 0.1 0.1 0.2 0.2 - 0.30000001 0.30000001 0.40000001 0.40000001 0.5 0.5 0.60000002 0.60000002 0.69999999 - 0.69999999; - setAttr ".cuvs" -type "string" "VertexInterpSet"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".ds" no; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; - setAttr -s 8 ".vt[0:7]" -5 -5 10 5 -5 10 -5 5 10 5 5 10 -5 5 0 5 5 0 - -5 -5 0 5 -5 0; - setAttr -s 12 ".ed[0:11]" 0 1 0 2 3 0 4 5 0 6 7 0 0 2 0 1 3 0 2 4 0 - 3 5 0 4 6 0 5 7 0 6 0 0 7 1 0; - setAttr -s 6 -ch 24 ".fc[0:5]" -type "polyFaces" - f 4 0 5 -2 -5 - mu 1 4 0 1 2 3 - mu 2 4 0 6 7 8 - mu 3 4 0 1 3 2 - f 4 1 7 -3 -7 - mu 1 4 4 5 6 7 - mu 2 4 1 9 10 11 - mu 3 4 2 3 5 4 - f 4 2 9 -4 -9 - mu 1 4 8 9 10 11 - mu 2 4 2 12 13 14 - mu 3 4 4 5 7 6 - f 4 3 11 -1 -11 - mu 1 4 12 13 14 0 - mu 2 4 3 15 16 17 - mu 3 4 6 7 1 0 - f 4 -12 -10 -8 -6 - mu 1 4 15 16 17 18 - mu 2 4 4 18 19 20 - mu 3 4 1 7 5 3 - f 4 10 4 6 8 - mu 1 4 19 0 20 21 - mu 2 4 5 21 22 23 - mu 3 4 6 0 2 4; - setAttr ".cd" -type "dataPolyComponent" Index_Data Edge 0 ; - setAttr ".cvd" -type "dataPolyComponent" Index_Data Vertex 0 ; - setAttr -s 4 ".pd"; - setAttr ".pd[0]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".pd[1]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".pd[2]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".pd[3]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".hfd" -type "dataPolyComponent" Index_Data Face 0 ; - setAttr ".mgi" -type "string" "ID_a46bf4f0-e7ae-46d4-8a18-42305fb119fe"; - setAttr ".allowPerFaceDisplayColors" yes; createNode transform -n "SharedFacesCube" -p "CubeMeshes"; rename -uid "6BB5D8C0-0000-562B-57BB-96820000028B"; addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" @@ -1747,7 +1663,6 @@ connectAttr "DefaultUVSetCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "EmptyDefaultUVSetCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "OneMissingFaceCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "OneAssignedFaceCubeShape.iog" "lambert2SG.dsm" -na; -connectAttr "CompressibleUVSetsCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "SharedFacesCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "lambert2SG.msg" "materialInfo1.sg"; connectAttr "Red.msg" "materialInfo1.m"; diff --git a/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma b/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma index eba75196ad..19908c263c 100644 --- a/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma +++ b/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma @@ -326,90 +326,6 @@ createNode mesh -n "polySurfaceShape2" -p "OneAssignedFaceCube"; setAttr ".hfd" -type "dataPolyComponent" Index_Data Face 0 ; setAttr ".mgi" -type "string" "ID_41632452-941c-445a-8955-d85daaf8813f"; setAttr ".allowPerFaceDisplayColors" yes; -createNode transform -n "CompressibleUVSetsCube" -p "CubeMeshes"; - rename -uid "6BB5D8C0-0000-562B-57BB-88050000027F"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr ".t" -type "double3" -20 0 0 ; - setAttr ".rp" -type "double3" 0 0 5 ; - setAttr ".sp" -type "double3" 0 0 5 ; - setAttr ".allowPerFaceDisplayColors" yes; -createNode mesh -n "CompressibleUVSetsCubeShape" -p "CompressibleUVSetsCube"; - rename -uid "6BB5D8C0-0000-562B-57BB-880500000280"; - addAttr -ci true -sn "mgi" -ln "mayaGprimID" -dt "string"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr -k off ".v"; - setAttr -s 6 ".iog[0].og"; - setAttr ".iog[0].og[0].gcl" -type "componentList" 1 "f[2]"; - setAttr ".iog[0].og[1].gcl" -type "componentList" 1 "f[3]"; - setAttr ".iog[0].og[2].gcl" -type "componentList" 1 "f[4]"; - setAttr ".iog[0].og[3].gcl" -type "componentList" 1 "f[1]"; - setAttr ".iog[0].og[4].gcl" -type "componentList" 1 "f[5]"; - setAttr ".iog[0].og[5].gcl" -type "componentList" 1 "f[0]"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr -s 4 ".uvst"; - setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".uvst[1].uvsn" -type "string" "ConstantInterpSet"; - setAttr -s 22 ".uvst[1].uvsp[0:21]" -type "float2" 0.25 0.25 0.25 0.25 - 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 - 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 - 0.25 0.25 0.25 0.25 0.25 0.25; - setAttr ".uvst[2].uvsn" -type "string" "UniformInterpSet"; - setAttr -s 24 ".uvst[2].uvsp[0:23]" -type "float2" 0 0 0.1 0.1 0.2 0.2 - 0.30000001 0.30000001 0.40000001 0.40000001 0.5 0.5 0 0 0 0 0 0 0.1 0.1 0.1 0.1 0.1 - 0.1 0.2 0.2 0.2 0.2 0.2 0.2 0.30000001 0.30000001 0.30000001 0.30000001 0.30000001 - 0.30000001 0.40000001 0.40000001 0.40000001 0.40000001 0.40000001 0.40000001 0.5 - 0.5 0.5 0.5 0.5 0.5; - setAttr ".uvst[3].uvsn" -type "string" "VertexInterpSet"; - setAttr -s 8 ".uvst[3].uvsp[0:7]" -type "float2" 0 0 0.1 0.1 0.2 0.2 - 0.30000001 0.30000001 0.40000001 0.40000001 0.5 0.5 0.60000002 0.60000002 0.69999999 - 0.69999999; - setAttr ".cuvs" -type "string" "VertexInterpSet"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".ds" no; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; - setAttr -s 8 ".vt[0:7]" -5 -5 10 5 -5 10 -5 5 10 5 5 10 -5 5 0 5 5 0 - -5 -5 0 5 -5 0; - setAttr -s 12 ".ed[0:11]" 0 1 0 2 3 0 4 5 0 6 7 0 0 2 0 1 3 0 2 4 0 - 3 5 0 4 6 0 5 7 0 6 0 0 7 1 0; - setAttr -s 6 -ch 24 ".fc[0:5]" -type "polyFaces" - f 4 0 5 -2 -5 - mu 1 4 0 1 2 3 - mu 2 4 0 6 7 8 - mu 3 4 0 1 3 2 - f 4 1 7 -3 -7 - mu 1 4 4 5 6 7 - mu 2 4 1 9 10 11 - mu 3 4 2 3 5 4 - f 4 2 9 -4 -9 - mu 1 4 8 9 10 11 - mu 2 4 2 12 13 14 - mu 3 4 4 5 7 6 - f 4 3 11 -1 -11 - mu 1 4 12 13 14 0 - mu 2 4 3 15 16 17 - mu 3 4 6 7 1 0 - f 4 -12 -10 -8 -6 - mu 1 4 15 16 17 18 - mu 2 4 4 18 19 20 - mu 3 4 1 7 5 3 - f 4 10 4 6 8 - mu 1 4 19 0 20 21 - mu 2 4 5 21 22 23 - mu 3 4 6 0 2 4; - setAttr ".cd" -type "dataPolyComponent" Index_Data Edge 0 ; - setAttr ".cvd" -type "dataPolyComponent" Index_Data Vertex 0 ; - setAttr -s 4 ".pd"; - setAttr ".pd[0]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".pd[1]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".pd[2]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".pd[3]" -type "dataPolyComponent" Index_Data UV 0 ; - setAttr ".hfd" -type "dataPolyComponent" Index_Data Face 0 ; - setAttr ".mgi" -type "string" "ID_a46bf4f0-e7ae-46d4-8a18-42305fb119fe"; - setAttr ".allowPerFaceDisplayColors" yes; createNode transform -n "SharedFacesCube" -p "CubeMeshes"; rename -uid "6BB5D8C0-0000-562B-57BB-96820000028B"; addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" @@ -1747,7 +1663,6 @@ connectAttr "DefaultUVSetCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "EmptyDefaultUVSetCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "OneMissingFaceCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "OneAssignedFaceCubeShape.iog" "lambert2SG.dsm" -na; -connectAttr "CompressibleUVSetsCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "SharedFacesCubeShape.iog" "lambert2SG.dsm" -na; connectAttr "lambert2SG.msg" "materialInfo1.sg"; connectAttr "Red.msg" "materialInfo1.m"; diff --git a/test/lib/usd/translators/testUsdExportUVSets.py b/test/lib/usd/translators/testUsdExportUVSets.py index d8b0ac4164..654c481c1d 100644 --- a/test/lib/usd/translators/testUsdExportUVSets.py +++ b/test/lib/usd/translators/testUsdExportUVSets.py @@ -129,8 +129,7 @@ def testExportDefaultUVSet(self): # These are the default UV values and indices that are exported for a # regular Maya polycube. If you just created a new cube and then # exported it to USD, these are the values and indices you would see - # for the default UV set 'map1'. The data here has already been - # merged/compressed. + # for the default UV set 'map1'. expectedValues = [ Gf.Vec2f(0.375, 0), Gf.Vec2f(0.625, 0), @@ -251,68 +250,6 @@ def testExportOneAssignedFaceUVSet(self): expectedIndices=expectedIndices, expectedUnauthoredValuesIndex=expectedUnauthoredValuesIndex) - def testExportCompressibleUVSets(self): - """ - Tests that UV sets on a cube mesh that can be compressed to constant, - uniform and vertex interpolations get exported correctly. - - Note that the actual values here don't really make sense as UV sets. - """ - usdCubeMesh = self._GetCubeUsdMesh('CompressibleUVSetsCube') - - uvSetName = 'ConstantInterpSet' - expectedValues = [ - Gf.Vec2f(0.25, 0.25) - ] - expectedIndices = [0] - expectedInterpolation = UsdGeom.Tokens.constant - - primvar = usdCubeMesh.GetPrimvar(uvSetName) - self._AssertUVPrimvar(primvar, - expectedValues=expectedValues, - expectedInterpolation=expectedInterpolation, - expectedIndices=expectedIndices) - - uvSetName = 'UniformInterpSet' - expectedValues = [ - Gf.Vec2f(0.0, 0.0), - Gf.Vec2f(0.1, 0.1), - Gf.Vec2f(0.2, 0.2), - Gf.Vec2f(0.3, 0.3), - Gf.Vec2f(0.4, 0.4), - Gf.Vec2f(0.5, 0.5) - ] - expectedIndices = [0, 1, 2, 3, 4, 5] - expectedInterpolation = UsdGeom.Tokens.uniform - - primvar = usdCubeMesh.GetPrimvar(uvSetName) - self._AssertUVPrimvar(primvar, - expectedValues=expectedValues, - expectedInterpolation=expectedInterpolation, - expectedIndices=expectedIndices) - - # The values here end up in a somewhat odd order because of how - # MItMeshFaceVertex visits vertices. - uvSetName = 'VertexInterpSet' - expectedValues = [ - Gf.Vec2f(0.0, 0.0), - Gf.Vec2f(0.1, 0.1), - Gf.Vec2f(0.3, 0.3), - Gf.Vec2f(0.2, 0.2), - Gf.Vec2f(0.5, 0.5), - Gf.Vec2f(0.4, 0.4), - Gf.Vec2f(0.7, 0.7), - Gf.Vec2f(0.6, 0.6) - ] - expectedIndices = [0, 1, 3, 2, 5, 4, 7, 6] - expectedInterpolation = UsdGeom.Tokens.vertex - - primvar = usdCubeMesh.GetPrimvar(uvSetName) - self._AssertUVPrimvar(primvar, - expectedValues=expectedValues, - expectedInterpolation=expectedInterpolation, - expectedIndices=expectedIndices) - def testExportSharedFacesUVSets(self): """ Tests that UV sets on a cube mesh that use the same UV ranges for From 25e721b14927af1f8ae9528fb9ac793e1fa24d9b Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:33:27 -0800 Subject: [PATCH 02/13] author UVs in Maya scenes for testUsdExportUVSets tests with the minimal number of values --- .../UsdExportUVSetsTest_Float.ma | 28 +++++++++---------- .../UsdExportUVSetsTest.ma | 28 +++++++++---------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma b/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma index 19908c263c..a226b9f05e 100644 --- a/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma +++ b/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma @@ -352,12 +352,10 @@ createNode mesh -n "SharedFacesCubeShape" -p "SharedFacesCube"; setAttr -s 3 ".uvst"; setAttr ".uvst[0].uvsn" -type "string" "map1"; setAttr ".uvst[1].uvsn" -type "string" "PairedFacesSet"; - setAttr -s 23 ".uvst[1].uvsp[0:22]" -type "float2" 0 0 0.5 0 0.5 0.5 - 0 0.5 0.5 0.5 1 0.5 1 1 0.5 1 0 0 0.5 0 0.5 0.5 0 0.5 0.5 0.5 1 0.5 1 1 0.5 1 0 0 - 0.5 0 0.5 0.5 0 0.5 0.5 0.5 1 0.5 1 1; + setAttr -s 7 ".uvst[1].uvsp[0:6]" -type "float2" 0 0 0.5 0 0.5 0.5 + 0 0.5 1 0.5 1 1 0.5 1; setAttr ".uvst[2].uvsn" -type "string" "AllFacesSharedSet"; - setAttr -s 24 ".uvst[2].uvsp[0:23]" -type "float2" 0 0 1 0 1 1 0 1 0 - 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1; + setAttr -s 4 ".uvst[2].uvsp[0:3]" -type "float2" 0 0 1 0 1 1 0 1; setAttr ".cuvs" -type "string" "PairedFacesSet"; setAttr ".dcc" -type "string" "Ambient+Diffuse"; setAttr ".ds" no; @@ -372,20 +370,20 @@ createNode mesh -n "SharedFacesCubeShape" -p "SharedFacesCube"; mu 1 4 0 1 2 3 mu 2 4 0 1 2 3 f 4 1 7 -3 -7 - mu 1 4 4 5 6 7 - mu 2 4 4 5 6 7 + mu 1 4 2 4 5 6 + mu 2 4 0 1 2 3 f 4 2 9 -4 -9 - mu 1 4 8 9 10 11 - mu 2 4 8 9 10 11 + mu 1 4 0 1 2 3 + mu 2 4 0 1 2 3 f 4 3 11 -1 -11 - mu 1 4 12 13 14 15 - mu 2 4 12 13 14 15 + mu 1 4 2 4 5 6 + mu 2 4 0 1 2 3 f 4 -12 -10 -8 -6 - mu 1 4 16 17 18 19 - mu 2 4 16 17 18 19 + mu 1 4 0 1 2 3 + mu 2 4 0 1 2 3 f 4 10 4 6 8 - mu 1 4 20 21 22 7 - mu 2 4 20 21 22 23; + mu 1 4 2 4 5 6 + mu 2 4 0 1 2 3; setAttr ".cd" -type "dataPolyComponent" Index_Data Edge 0 ; setAttr ".cvd" -type "dataPolyComponent" Index_Data Vertex 0 ; setAttr -s 3 ".pd"; diff --git a/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma b/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma index 19908c263c..a226b9f05e 100644 --- a/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma +++ b/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma @@ -352,12 +352,10 @@ createNode mesh -n "SharedFacesCubeShape" -p "SharedFacesCube"; setAttr -s 3 ".uvst"; setAttr ".uvst[0].uvsn" -type "string" "map1"; setAttr ".uvst[1].uvsn" -type "string" "PairedFacesSet"; - setAttr -s 23 ".uvst[1].uvsp[0:22]" -type "float2" 0 0 0.5 0 0.5 0.5 - 0 0.5 0.5 0.5 1 0.5 1 1 0.5 1 0 0 0.5 0 0.5 0.5 0 0.5 0.5 0.5 1 0.5 1 1 0.5 1 0 0 - 0.5 0 0.5 0.5 0 0.5 0.5 0.5 1 0.5 1 1; + setAttr -s 7 ".uvst[1].uvsp[0:6]" -type "float2" 0 0 0.5 0 0.5 0.5 + 0 0.5 1 0.5 1 1 0.5 1; setAttr ".uvst[2].uvsn" -type "string" "AllFacesSharedSet"; - setAttr -s 24 ".uvst[2].uvsp[0:23]" -type "float2" 0 0 1 0 1 1 0 1 0 - 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 1 0 1; + setAttr -s 4 ".uvst[2].uvsp[0:3]" -type "float2" 0 0 1 0 1 1 0 1; setAttr ".cuvs" -type "string" "PairedFacesSet"; setAttr ".dcc" -type "string" "Ambient+Diffuse"; setAttr ".ds" no; @@ -372,20 +370,20 @@ createNode mesh -n "SharedFacesCubeShape" -p "SharedFacesCube"; mu 1 4 0 1 2 3 mu 2 4 0 1 2 3 f 4 1 7 -3 -7 - mu 1 4 4 5 6 7 - mu 2 4 4 5 6 7 + mu 1 4 2 4 5 6 + mu 2 4 0 1 2 3 f 4 2 9 -4 -9 - mu 1 4 8 9 10 11 - mu 2 4 8 9 10 11 + mu 1 4 0 1 2 3 + mu 2 4 0 1 2 3 f 4 3 11 -1 -11 - mu 1 4 12 13 14 15 - mu 2 4 12 13 14 15 + mu 1 4 2 4 5 6 + mu 2 4 0 1 2 3 f 4 -12 -10 -8 -6 - mu 1 4 16 17 18 19 - mu 2 4 16 17 18 19 + mu 1 4 0 1 2 3 + mu 2 4 0 1 2 3 f 4 10 4 6 8 - mu 1 4 20 21 22 7 - mu 2 4 20 21 22 23; + mu 1 4 2 4 5 6 + mu 2 4 0 1 2 3; setAttr ".cd" -type "dataPolyComponent" Index_Data Edge 0 ; setAttr ".cvd" -type "dataPolyComponent" Index_Data Vertex 0 ; setAttr -s 3 ".pd"; From c48411944178b9d3624c54c96ce1664ddcbd1c67 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:41:33 -0800 Subject: [PATCH 03/13] change the mesh name in the "compressed" case of the testUsdImportUVSets test Exporting from Maya will no longer compress UV sets, so the mesh name was tweaked slightly and a comment was added to clarify that Meshes with compressed UV sets would have to come from somewhere else. --- .../UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda | 2 +- .../UsdImportUVSetsTest/UsdImportUVSetsTest.usda | 2 +- test/lib/usd/translators/testUsdImportUVSets.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda b/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda index a27af06aa9..46558b2045 100644 --- a/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda +++ b/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda @@ -84,7 +84,7 @@ def Xform "UsdImportUVSetsTest" ( uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] } - def Mesh "CompressibleUVSetsCube" + def Mesh "CompressedUVSetsCube" { float3[] extent = [(-5, -5, 0), (5, 5, 10)] int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] diff --git a/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda b/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda index a27af06aa9..46558b2045 100644 --- a/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda +++ b/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda @@ -84,7 +84,7 @@ def Xform "UsdImportUVSetsTest" ( uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] } - def Mesh "CompressibleUVSetsCube" + def Mesh "CompressedUVSetsCube" { float3[] extent = [(-5, -5, 0), (5, 5, 10)] int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] diff --git a/test/lib/usd/translators/testUsdImportUVSets.py b/test/lib/usd/translators/testUsdImportUVSets.py index 849e55e3c6..9039ea2d3d 100644 --- a/test/lib/usd/translators/testUsdImportUVSets.py +++ b/test/lib/usd/translators/testUsdImportUVSets.py @@ -225,14 +225,16 @@ def testImportOneAssignedFaceUVSet(self): self._AssertUVSet(mayaCubeMesh, self.defaultUVName, expectedValues, expectedNumValues=4) - def testImportCompressibleUVSets(self): + def testImportCompressedUVSets(self): """ Tests that UV sets on a USD cube mesh that were compressed to constant, uniform, and vertex interpolations are imported correctly. Note that the actual values here don't really make sense as UV sets. + We also do not perform any compression when exporting from Maya, so UV + sets like this would have to come from some other source. """ - mayaCubeMesh = self._GetMayaMesh('CompressibleUVSetsCubeShape') + mayaCubeMesh = self._GetMayaMesh('CompressedUVSetsCubeShape') # We should not see the default "map1" UV set: self.assertNotIn("map1", mayaCubeMesh.getUVSetNames()) From e6a532719d3f239a2704b785941c739568a95159 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:44:56 -0800 Subject: [PATCH 04/13] move tearDownClass() after setUpClass() in testUsdExportUVSets and testUsdImportUVSets --- test/lib/usd/translators/testUsdExportUVSets.py | 9 ++++----- test/lib/usd/translators/testUsdImportUVSets.py | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/test/lib/usd/translators/testUsdExportUVSets.py b/test/lib/usd/translators/testUsdExportUVSets.py index 654c481c1d..b7e5e897eb 100644 --- a/test/lib/usd/translators/testUsdExportUVSets.py +++ b/test/lib/usd/translators/testUsdExportUVSets.py @@ -56,11 +56,6 @@ def _AssertUVPrimvar(self, primvar, expectedUnauthoredValuesIndex) self.assertEqual(primvar.GetInterpolation(), expectedInterpolation) - - @classmethod - def tearDownClass(cls): - standalone.uninitialize() - @classmethod def setUpClass(cls): asFloat2 = mayaUsdLib.WriteUtil.WriteUVAsFloat2() @@ -94,6 +89,10 @@ def setUpClass(cls): cls._stage = Usd.Stage.Open(usdFilePath) + @classmethod + def tearDownClass(cls): + standalone.uninitialize() + def testStageOpens(self): self.assertTrue(self._stage) diff --git a/test/lib/usd/translators/testUsdImportUVSets.py b/test/lib/usd/translators/testUsdImportUVSets.py index 9039ea2d3d..9e8b855d9c 100644 --- a/test/lib/usd/translators/testUsdImportUVSets.py +++ b/test/lib/usd/translators/testUsdImportUVSets.py @@ -63,10 +63,6 @@ def _AssertUVSet(self, mesh, uvSetName, expectedValues, expectedNumValues=None): itMeshFV.next() fvi += 1 - @classmethod - def tearDownClass(cls): - standalone.uninitialize() - @classmethod def setUpClass(cls): cls.asFloat2 = mayaUsdLib.ReadUtil.ReadFloat2AsUV() @@ -83,6 +79,10 @@ def setUpClass(cls): cmds.usdImport(file=usdFile, shadingMode=[["none", "default"], ]) + @classmethod + def tearDownClass(cls): + standalone.uninitialize() + def _GetMayaMesh(self, meshName): selectionList = OM.MSelectionList() selectionList.add(meshName) From 82ae536ae6617b306ed9f8199c52a27777f60b64 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:50:01 -0800 Subject: [PATCH 05/13] re-implement UV set export to maintain UV shells and connectivity Previously when exporting UV sets to USD, we used the face vertex ordering imposed by MItMeshFaceVertex to effectively re-arrange all of the Maya mesh's UVs into face vertex order. We then further de-duplicated the UV values and compressed the indices array to a coarser interpolation if possible. All of this manipulation effectively destroyed any UV shell and connectivity information that was encoded in the Maya indexing, resulting in UV sets that were disconnected and difficult to work with if a Maya mesh was round-tripped out to USD and back in. Instead, we now translate the Maya mesh's UV values and assignment indices more or less directly, and we no longer apply any compression. This offers the best chance of maintaining the UV set's connectivity across round-trips. The net result in USD is the same (i.e. the array of UVs produced by doing primvar.ComputeFlattened() is the same as before), but the array values for the UV set primvar and its accompanying indices attribute may be different. --- lib/mayaUsd/fileio/utils/meshWriteUtils.cpp | 56 ++++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp b/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp index 047b019451..dfa32fbf3b 100644 --- a/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp +++ b/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp @@ -846,39 +846,46 @@ bool UsdMayaMeshWriteUtils::getMeshUVSetData( TfToken* interpolation, VtIntArray* assignmentIndices) { - MStatus status { MS::kSuccess }; - - // Sanity check first to make sure this UV set even has assigned values - // before we attempt to do anything with the data. + // Check first to make sure this UV set even has assigned values before we + // attempt to do anything with the data. We cannot directly use this data + // otherwise though since we need a uvId for every face vertex, and the + // returned uvIds MIntArray may be shorter than that if there are unmapped + // faces. MIntArray uvCounts, uvIds; - status = mesh.getAssignedUVs(uvCounts, uvIds, &uvSetName); - if (status != MS::kSuccess) { - return false; - } - if (uvCounts.length() == 0 || uvIds.length() == 0) { + MStatus status = mesh.getAssignedUVs(uvCounts, uvIds, &uvSetName); + CHECK_MSTATUS_AND_RETURN(status, false); + + if (uvCounts.length() == 0u || uvIds.length() == 0u) { return false; } - // using itFV.getUV() does not always give us the right answer, so - // instead, we have to use itFV.getUVIndex() and use that to index into the - // UV set. + // Transfer the UV values directly to USD, in the same order as they are in + // the Maya mesh. MFloatArray uArray; MFloatArray vArray; - mesh.getUVs(uArray, vArray, &uvSetName); + status = mesh.getUVs(uArray, vArray, &uvSetName); + CHECK_MSTATUS_AND_RETURN(status, false); + if (uArray.length() != vArray.length()) { return false; } - // We'll populate the assignment indices for every face vertex, but we'll - // only push values into the data if the face vertex has a value. All face - // vertices are initially unassigned/unauthored. - const unsigned int numFaceVertices = mesh.numFaceVertices(&status); uvArray->clear(); - assignmentIndices->assign((size_t)numFaceVertices, -1); + uvArray->reserve(static_cast(uArray.length())); + for (unsigned int uvId = 0u; uvId < uArray.length(); ++uvId) { + uvArray->emplace_back(uArray[uvId], vArray[uvId]); + } + + // Now iterate through all the face vertices and fill in the faceVarying + // assignmentIndices array, again in the same order as in the Maya mesh. + const unsigned int numFaceVertices = mesh.numFaceVertices(&status); + CHECK_MSTATUS_AND_RETURN(status, false); + + assignmentIndices->assign(static_cast(numFaceVertices), -1); *interpolation = UsdGeomTokens->faceVarying; MItMeshFaceVertex itFV(mesh.object()); - unsigned int fvi = 0; + unsigned int fvi = 0u; for (itFV.reset(); !itFV.isDone(); itFV.next(), ++fvi) { if (!itFV.hasUVs(uvSetName)) { // No UVs for this faceVertex, so leave it unassigned. @@ -887,17 +894,16 @@ bool UsdMayaMeshWriteUtils::getMeshUVSetData( int uvIndex; itFV.getUVIndex(uvIndex, &uvSetName); - if (uvIndex < 0 || static_cast(uvIndex) >= uArray.length()) { + if (uvIndex < 0 || static_cast(uvIndex) >= uArray.length()) { return false; } - GfVec2f value(uArray[uvIndex], vArray[uvIndex]); - uvArray->push_back(value); - (*assignmentIndices)[fvi] = uvArray->size() - 1; + (*assignmentIndices)[fvi] = uvIndex; } - UsdMayaUtil::MergeEquivalentIndexedValues(uvArray, assignmentIndices); - UsdMayaUtil::CompressFaceVaryingPrimvarIndices(mesh, interpolation, assignmentIndices); + // We do not merge indexed values or compress indices here in an effort to + // maintain the same UV shells and connectivity across export/import + // round-trips. return true; } From 5988d8c78010f52ac5780e16ebf455670f86c56d Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:55:02 -0800 Subject: [PATCH 06/13] apply workaround in testUsdExportUVSets to ensure that UV value arrays are of minimal length Although the UV sets on the "SharedFacesCubeShape" are stored in the Maya scene with a minimal number of UV values and UV shells, they seem to be expanded when the file is opened such that we end up with a UV value per face vertex rather than smaller arrays of UV values with only the indices being per face vertex. As a result, we have to reassign the UVs just before we export. --- .../usd/translators/testUsdExportUVSets.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/test/lib/usd/translators/testUsdExportUVSets.py b/test/lib/usd/translators/testUsdExportUVSets.py index b7e5e897eb..dfb34539cc 100644 --- a/test/lib/usd/translators/testUsdExportUVSets.py +++ b/test/lib/usd/translators/testUsdExportUVSets.py @@ -26,6 +26,7 @@ from maya import cmds from maya import standalone +from maya.api import OpenMaya as OM import os import unittest @@ -56,6 +57,13 @@ def _AssertUVPrimvar(self, primvar, expectedUnauthoredValuesIndex) self.assertEqual(primvar.GetInterpolation(), expectedInterpolation) + @staticmethod + def _GetMayaMesh(meshNodePath): + selectionList = OM.MSelectionList() + selectionList.add(meshNodePath) + mObj = selectionList.getDependNode(0) + return OM.MFnMesh(mObj) + @classmethod def setUpClass(cls): asFloat2 = mayaUsdLib.WriteUtil.WriteUVAsFloat2() @@ -79,6 +87,51 @@ def setUpClass(cls): cmds.select("box.map[0:299]", r=True) cmds.polyEditUV(u=1.0, v=1.0) + # XXX: Although the UV sets on the "SharedFacesCubeShape" are stored in + # the Maya scene with a minimal number of UV values and UV shells, they + # seem to be expanded when the file is opened such that we end up with + # a UV value per face vertex rather than these smaller arrays of UV + # values with only the indices being per face vertex. As a result, we + # have to reassign the UVs just before we export. + meshNodePath = 'SharedFacesCubeShape' + meshFn = testUsdExportUVSets._GetMayaMesh(meshNodePath) + + uvSetName = 'AllFacesSharedSet' + (uArray, vArray) = meshFn.getUVs(uvSetName) + (numUVShells, shellIndices) = meshFn.getUvShellsIds(uvSetName) + # These values are incorrect, in that they are not what's stored in the + # Maya scene, and not what we expect to export. We also use raw asserts + # here since we don't have an instance of unittest.TestCase yet. + assert(len(uArray) == 24) + assert(numUVShells == 6) + + # Fix up the "all shared" UV set. + meshFn.clearUVs(uvSetName) + meshFn.setUVs( + [0.0, 1.0, 1.0, 0.0], + [0.0, 0.0, 1.0, 1.0], + uvSetName) + meshFn.assignUVs([4, 4, 4, 4, 4, 4], [0, 1, 2, 3] * 6, uvSetName) + (numUVShells, shellIndices) = meshFn.getUvShellsIds(uvSetName) + assert(numUVShells == 1) + + uvSetName = 'PairedFacesSet' + (uArray, vArray) = meshFn.getUVs(uvSetName) + (numUVShells, shellIndices) = meshFn.getUvShellsIds(uvSetName) + # As above, these values are not what we expect. + assert(len(uArray) == 23) + assert(numUVShells == 5) + + # Fix up the "paired" UV set. + meshFn.clearUVs(uvSetName) + meshFn.setUVs( + [0.0, 0.5, 0.5, 0.0, 1.0, 1.0, 0.5], + [0.0, 0.0, 0.5, 0.5, 0.5, 1.0, 1.0], + uvSetName) + meshFn.assignUVs([4, 4, 4, 4, 4, 4], [0, 1, 2, 3, 2, 4, 5, 6] * 3, uvSetName) + (numUVShells, shellIndices) = meshFn.getUvShellsIds(uvSetName) + assert(numUVShells == 2) + usdFilePath = os.path.abspath('UsdExportUVSetsTest.usda') cmds.usdExport(mergeTransformAndShape=True, file=usdFilePath, From e7c0eebc6715b5ef6557b80347ead1ac3ad022ac Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:58:14 -0800 Subject: [PATCH 07/13] re-order expected UV values and indices in testUsdExportUVSets to account for new export behavior --- .../usd/translators/testUsdExportUVSets.py | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/test/lib/usd/translators/testUsdExportUVSets.py b/test/lib/usd/translators/testUsdExportUVSets.py index dfb34539cc..327e8d6a23 100644 --- a/test/lib/usd/translators/testUsdExportUVSets.py +++ b/test/lib/usd/translators/testUsdExportUVSets.py @@ -185,26 +185,26 @@ def testExportDefaultUVSet(self): expectedValues = [ Gf.Vec2f(0.375, 0), Gf.Vec2f(0.625, 0), - Gf.Vec2f(0.625, 0.25), Gf.Vec2f(0.375, 0.25), - Gf.Vec2f(0.625, 0.5), + Gf.Vec2f(0.625, 0.25), Gf.Vec2f(0.375, 0.5), - Gf.Vec2f(0.625, 0.75), + Gf.Vec2f(0.625, 0.5), Gf.Vec2f(0.375, 0.75), - Gf.Vec2f(0.625, 1), + Gf.Vec2f(0.625, 0.75), Gf.Vec2f(0.375, 1), + Gf.Vec2f(0.625, 1), Gf.Vec2f(0.875, 0), Gf.Vec2f(0.875, 0.25), Gf.Vec2f(0.125, 0), Gf.Vec2f(0.125, 0.25) ] expectedIndices = [ - 0, 1, 2, 3, - 3, 2, 4, 5, - 5, 4, 6, 7, - 7, 6, 8, 9, - 1, 10, 11, 2, - 12, 0, 3, 13] + 0, 1, 3, 2, + 2, 3, 5, 4, + 4, 5, 7, 6, + 6, 7, 9, 8, + 1, 10, 11, 3, + 12, 0, 2, 13] expectedInterpolation = UsdGeom.Tokens.faceVarying @@ -226,29 +226,29 @@ def testExportOneMissingFaceUVSet(self): usdCubeMesh = self._GetCubeUsdMesh('OneMissingFaceCube') expectedValues = [ - Gf.Vec2f(0.0, 0.0), + Gf.Vec2f(0, 0), Gf.Vec2f(0.375, 0), Gf.Vec2f(0.625, 0), - Gf.Vec2f(0.625, 0.25), Gf.Vec2f(0.375, 0.25), - Gf.Vec2f(0.625, 0.5), + Gf.Vec2f(0.625, 0.25), Gf.Vec2f(0.375, 0.5), + Gf.Vec2f(0.625, 0.5), Gf.Vec2f(0.375, 0.75), Gf.Vec2f(0.625, 0.75), - Gf.Vec2f(0.625, 1), Gf.Vec2f(0.375, 1), + Gf.Vec2f(0.625, 1), Gf.Vec2f(0.875, 0), Gf.Vec2f(0.875, 0.25), Gf.Vec2f(0.125, 0), Gf.Vec2f(0.125, 0.25) ] expectedIndices = [ - 1, 2, 3, 4, - 4, 3, 5, 6, + 1, 2, 4, 3, + 3, 4, 6, 5, 0, 0, 0, 0, - 7, 8, 9, 10, - 2, 11, 12, 3, - 13, 1, 4, 14 + 7, 8, 10, 9, + 2, 11, 12, 4, + 13, 1, 3, 14 ] expectedUnauthoredValuesIndex = 0 @@ -273,16 +273,16 @@ def testExportOneAssignedFaceUVSet(self): usdCubeMesh = self._GetCubeUsdMesh('OneAssignedFaceCube') expectedValues = [ - Gf.Vec2f(0.0, 0.0), + Gf.Vec2f(0, 0), Gf.Vec2f(0.375, 0.5), Gf.Vec2f(0.625, 0.5), - Gf.Vec2f(0.625, 0.75), - Gf.Vec2f(0.375, 0.75) + Gf.Vec2f(0.375, 0.75), + Gf.Vec2f(0.625, 0.75) ] expectedIndices = [ 0, 0, 0, 0, 0, 0, 0, 0, - 1, 2, 3, 4, + 1, 2, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 @@ -363,7 +363,8 @@ def testExportUvVersusUvIndexFromIterator(self): else: stPrimvar = brokenBoxMesh.GetPrimvar("map1").ComputeFlattened() - self.assertEqual(stPrimvar[0], Gf.Vec2f(1.0, 1.0)) + self.assertEqual(stPrimvar[0], Gf.Vec2f(1.0, 2.0)) + if __name__ == '__main__': unittest.main(verbosity=2) From c272570e9ecd293532b2c3106ebe3351518a82f0 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 15:59:54 -0800 Subject: [PATCH 08/13] freshen testUsdImportUVSets source USD files based on new export behavior --- .../UsdImportUVSetsTest_Float.usda | 20 +++++++++---------- .../UsdImportUVSetsTest.usda | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda b/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda index 46558b2045..ce5c8c913d 100644 --- a/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda +++ b/test/lib/usd/translators/UsdImportUVSetsFloatTest/UsdImportUVSetsTest_Float.usda @@ -28,10 +28,10 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.625, 0.5), (0.375, 0.5), (0.625, 0.75), (0.375, 0.75), (0.625, 1), (0.375, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( + texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.375, 0.25), (0.625, 0.25), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75), (0.375, 1), (0.625, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( interpolation = "faceVarying" ) - int[] primvars:st:indices = [0, 1, 2, 3, 3, 2, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 1, 10, 11, 2, 12, 0, 3, 13] + int[] primvars:st:indices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, 1, 10, 11, 3, 12, 0, 2, 13] double3 xformOp:translate = (0, 20, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] @@ -43,10 +43,10 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:map1 = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.625, 0.5), (0.375, 0.5), (0.625, 0.75), (0.375, 0.75), (0.625, 1), (0.375, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( + texCoord2f[] primvars:map1 = [(0.375, 0), (0.625, 0), (0.375, 0.25), (0.625, 0.25), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75), (0.375, 1), (0.625, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( interpolation = "faceVarying" ) - int[] primvars:map1:indices = [0, 1, 2, 3, 3, 2, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 1, 10, 11, 2, 12, 0, 3, 13] + int[] primvars:map1:indices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, 1, 10, 11, 3, 12, 0, 2, 13] double3 xformOp:translate = (0, 20, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] @@ -58,11 +58,11 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.625, 0.5), (0.375, 0.5), (0.375, 0.75), (0.625, 0.75), (0.625, 1), (0.375, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25), (-1e+30, -1e+30)] ( + texCoord2f[] primvars:st = [(0, 0), (0.375, 0), (0.625, 0), (0.375, 0.25), (0.625, 0.25), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75), (0.375, 1), (0.625, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( interpolation = "faceVarying" - unauthoredValuesIndex = 14 + unauthoredValuesIndex = 0 ) - int[] primvars:st:indices = [0, 1, 2, 3, 3, 2, 4, 5, 14, 14, 14, 14, 6, 7, 8, 9, 1, 10, 11, 2, 12, 0, 3, 13] + int[] primvars:st:indices = [1, 2, 4, 3, 3, 4, 6, 5, 0, 0, 0, 0, 7, 8, 10, 9, 2, 11, 12, 4, 13, 1, 3, 14] double3 xformOp:translate = (0, 40, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] @@ -74,11 +74,11 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:st = [(0.375, 0.5), (0.625, 0.5), (0.625, 0.75), (0.375, 0.75), (-1e+30, -1e+30)] ( + texCoord2f[] primvars:st = [(0, 0), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75)] ( interpolation = "faceVarying" - unauthoredValuesIndex = 4 + unauthoredValuesIndex = 0 ) - int[] primvars:st:indices = [4, 4, 4, 4, 4, 4, 4, 4, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4] + int[] primvars:st:indices = [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] double3 xformOp:translate = (0, 60, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] diff --git a/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda b/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda index 46558b2045..ce5c8c913d 100644 --- a/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda +++ b/test/lib/usd/translators/UsdImportUVSetsTest/UsdImportUVSetsTest.usda @@ -28,10 +28,10 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.625, 0.5), (0.375, 0.5), (0.625, 0.75), (0.375, 0.75), (0.625, 1), (0.375, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( + texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.375, 0.25), (0.625, 0.25), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75), (0.375, 1), (0.625, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( interpolation = "faceVarying" ) - int[] primvars:st:indices = [0, 1, 2, 3, 3, 2, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 1, 10, 11, 2, 12, 0, 3, 13] + int[] primvars:st:indices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, 1, 10, 11, 3, 12, 0, 2, 13] double3 xformOp:translate = (0, 20, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] @@ -43,10 +43,10 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:map1 = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.625, 0.5), (0.375, 0.5), (0.625, 0.75), (0.375, 0.75), (0.625, 1), (0.375, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( + texCoord2f[] primvars:map1 = [(0.375, 0), (0.625, 0), (0.375, 0.25), (0.625, 0.25), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75), (0.375, 1), (0.625, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( interpolation = "faceVarying" ) - int[] primvars:map1:indices = [0, 1, 2, 3, 3, 2, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 1, 10, 11, 2, 12, 0, 3, 13] + int[] primvars:map1:indices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, 1, 10, 11, 3, 12, 0, 2, 13] double3 xformOp:translate = (0, 20, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] @@ -58,11 +58,11 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.625, 0.5), (0.375, 0.5), (0.375, 0.75), (0.625, 0.75), (0.625, 1), (0.375, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25), (-1e+30, -1e+30)] ( + texCoord2f[] primvars:st = [(0, 0), (0.375, 0), (0.625, 0), (0.375, 0.25), (0.625, 0.25), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75), (0.375, 1), (0.625, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] ( interpolation = "faceVarying" - unauthoredValuesIndex = 14 + unauthoredValuesIndex = 0 ) - int[] primvars:st:indices = [0, 1, 2, 3, 3, 2, 4, 5, 14, 14, 14, 14, 6, 7, 8, 9, 1, 10, 11, 2, 12, 0, 3, 13] + int[] primvars:st:indices = [1, 2, 4, 3, 3, 4, 6, 5, 0, 0, 0, 0, 7, 8, 10, 9, 2, 11, 12, 4, 13, 1, 3, 14] double3 xformOp:translate = (0, 40, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] @@ -74,11 +74,11 @@ def Xform "UsdImportUVSetsTest" ( int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4] point3f[] points = [(-5, -5, 10), (5, -5, 10), (-5, 5, 10), (5, 5, 10), (-5, 5, 0), (5, 5, 0), (-5, -5, 0), (5, -5, 0)] - texCoord2f[] primvars:st = [(0.375, 0.5), (0.625, 0.5), (0.625, 0.75), (0.375, 0.75), (-1e+30, -1e+30)] ( + texCoord2f[] primvars:st = [(0, 0), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75)] ( interpolation = "faceVarying" - unauthoredValuesIndex = 4 + unauthoredValuesIndex = 0 ) - int[] primvars:st:indices = [4, 4, 4, 4, 4, 4, 4, 4, 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4] + int[] primvars:st:indices = [0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] double3 xformOp:translate = (0, 60, 0) float3 xformOp:translate:pivot = (0, 0, 5) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:translate:pivot", "!invert!xformOp:translate:pivot"] From daf5014b12aac747a19aedd870ca35da62f391c2 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 16:05:11 -0800 Subject: [PATCH 09/13] sync testUsdImportUVSets._GetMayaMesh() with its equivalent in testUsdExportUVSets --- .../usd/translators/testUsdImportUVSets.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/lib/usd/translators/testUsdImportUVSets.py b/test/lib/usd/translators/testUsdImportUVSets.py index 9e8b855d9c..163f90346b 100644 --- a/test/lib/usd/translators/testUsdImportUVSets.py +++ b/test/lib/usd/translators/testUsdImportUVSets.py @@ -83,11 +83,11 @@ def setUpClass(cls): def tearDownClass(cls): standalone.uninitialize() - def _GetMayaMesh(self, meshName): + @staticmethod + def _GetMayaMesh(meshNodePath): selectionList = OM.MSelectionList() - selectionList.add(meshName) + selectionList.add(meshNodePath) mObj = selectionList.getDependNode(0) - return OM.MFnMesh(mObj) def testImportNoUVSets(self): @@ -95,7 +95,7 @@ def testImportNoUVSets(self): Tests that importing a USD cube mesh with no UV set primvars results in the default 'map1' UV set on the Maya mesh being empty. """ - mayaCubeMesh = self._GetMayaMesh('NoUVSetsCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('NoUVSetsCubeShape') expectedValues = {} self._AssertUVSet(mayaCubeMesh, 'map1', expectedValues) @@ -104,7 +104,7 @@ def testImportDefaultUVSet(self): Tests that a USD cube mesh with the Maya default values for the default UV set (named 'st' in USD) gets imported correctly. """ - mayaCubeMesh = self._GetMayaMesh('DefaultUVSetCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('DefaultUVSetCubeShape') # These are the default UV values for a regular Maya polycube. expectedValues = { @@ -142,7 +142,7 @@ def testImportMap1UVSet(self): Tests that a USD cube mesh with the Maya default values for the default UV set (map1) gets imported correctly. """ - mayaCubeMesh = self._GetMayaMesh('Map1UVSetCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('Map1UVSetCubeShape') # These are the default UV values for a regular Maya polycube. expectedValues = { @@ -180,7 +180,7 @@ def testImportOneMissingFaceUVSet(self): Tests that a USD cube mesh with values for all but one face in the default UV set (named 'st' in USD) gets imported correctly. """ - mayaCubeMesh = self._GetMayaMesh('OneMissingFaceCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('OneMissingFaceCubeShape') expectedValues = { 0: Gf.Vec2f(0.375, 0), @@ -213,7 +213,7 @@ def testImportOneAssignedFaceUVSet(self): Tests that a USD cube mesh with values for only one face in the default UV set (named 'st' in USD) gets imported correctly. """ - mayaCubeMesh = self._GetMayaMesh('OneAssignedFaceCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('OneAssignedFaceCubeShape') expectedValues = { 8: Gf.Vec2f(0.375, 0.5), @@ -234,7 +234,7 @@ def testImportCompressedUVSets(self): We also do not perform any compression when exporting from Maya, so UV sets like this would have to come from some other source. """ - mayaCubeMesh = self._GetMayaMesh('CompressedUVSetsCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('CompressedUVSetsCubeShape') # We should not see the default "map1" UV set: self.assertNotIn("map1", mayaCubeMesh.getUVSetNames()) @@ -302,7 +302,7 @@ def testImportSharedFacesUVSets(self): Tests that UV sets on a USD cube mesh that use the same UV ranges for multiple faces are imported correctly. """ - mayaCubeMesh = self._GetMayaMesh('SharedFacesCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('SharedFacesCubeShape') # All six faces share the same range 0.0-1.0. uvSetName = 'AllFacesSharedSet' @@ -358,7 +358,7 @@ def testImportUVSetForMeshWithCreases(self): # translator caused a crash. cmds.file(usdFile, i=True) - mayaCubeMesh = self._GetMayaMesh('CreasedCubeShape') + mayaCubeMesh = testUsdImportUVSets._GetMayaMesh('CreasedCubeShape') # These are the default UV values for a regular Maya polycube. expectedValues = { @@ -391,5 +391,6 @@ def testImportUVSetForMeshWithCreases(self): self._AssertUVSet(mayaCubeMesh, self.defaultUVName, expectedValues, expectedNumValues=14) + if __name__ == '__main__': unittest.main(verbosity=2) From 4e523f9cfee688d7a26292f90d45b833711a77a4 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 16:06:49 -0800 Subject: [PATCH 10/13] simplify UV set import --- lib/mayaUsd/fileio/utils/meshReadUtils.cpp | 87 +++++++++------------- 1 file changed, 36 insertions(+), 51 deletions(-) diff --git a/lib/mayaUsd/fileio/utils/meshReadUtils.cpp b/lib/mayaUsd/fileio/utils/meshReadUtils.cpp index 5a7559fc93..855f0ce79a 100644 --- a/lib/mayaUsd/fileio/utils/meshReadUtils.cpp +++ b/lib/mayaUsd/fileio/utils/meshReadUtils.cpp @@ -190,7 +190,6 @@ bool assignUVSetPrimvarToMesh(const UsdGeomPrimvar& primvar, MFnMesh& meshFn, bo { const TfToken& primvarName = primvar.GetPrimvarName(); - // Get the raw data before applying any indexing. VtVec2fArray uvValues; if (!primvar.Get(&uvValues) || uvValues.empty()) { TF_WARN( @@ -200,53 +199,7 @@ bool assignUVSetPrimvarToMesh(const UsdGeomPrimvar& primvar, MFnMesh& meshFn, bo return false; } - // This is the number of UV values assuming the primvar is NOT indexed. - VtIntArray assignmentIndices; - if (primvar.GetIndices(&assignmentIndices)) { - // The primvar IS indexed, so the indices array is what determines the - // number of UV values. - int unauthoredValuesIndex = primvar.GetUnauthoredValuesIndex(); - - // Replace any index equal to unauthoredValuesIndex with -1. - if (unauthoredValuesIndex != -1) { - for (int& index : assignmentIndices) { - if (index == unauthoredValuesIndex) { - index = -1; - } - } - } - - // Furthermore, if unauthoredValuesIndex is valid for uvValues, then - // remove it from uvValues and shift the indices (we don't want to - // import the unauthored value into Maya, where it has no meaning). - if (unauthoredValuesIndex >= 0 - && static_cast(unauthoredValuesIndex) < uvValues.size()) { - // This moves [unauthoredValuesIndex + 1, end) to - // [unauthoredValuesIndex, end - 1), erasing the - // unauthoredValuesIndex. - std::move( - uvValues.begin() + unauthoredValuesIndex + 1, - uvValues.end(), - uvValues.begin() + unauthoredValuesIndex); - uvValues.pop_back(); - - for (int& index : assignmentIndices) { - if (index > unauthoredValuesIndex) { - index = index - 1; - } - } - } - } - - // Go through the UV data and add the U and V values to separate - // MFloatArrays. - MFloatArray uCoords; - MFloatArray vCoords; - for (const GfVec2f& v : uvValues) { - uCoords.append(v[0]); - vCoords.append(v[1]); - } - + // Determine the name to use for the Maya UV set. MStatus status { MS::kSuccess }; MString uvSetName(primvarName.GetText()); bool createUVSet = true; @@ -260,7 +213,7 @@ bool assignUVSetPrimvarToMesh(const UsdGeomPrimvar& primvar, MFnMesh& meshFn, bo // If map1 still exists, we rename and re-use it: MStringArray uvSetNames; meshFn.getUVSetNames(uvSetNames); - if (uvSetNames[0] == UsdMayaMeshPrimvarTokens->DefaultMayaTexcoordName.GetText()) { + if (uvSetNames[0u] == UsdMayaMeshPrimvarTokens->DefaultMayaTexcoordName.GetText()) { meshFn.renameUVSet( UsdMayaMeshPrimvarTokens->DefaultMayaTexcoordName.GetText(), uvSetName); createUVSet = false; @@ -287,8 +240,23 @@ bool assignUVSetPrimvarToMesh(const UsdGeomPrimvar& primvar, MFnMesh& meshFn, bo MString currentSet = meshFn.currentUVSetName(); meshFn.setCurrentUVSetName(currentSet); - // Create UVs on the mesh from the values we collected out of the primvar. - // We'll assign mesh components to these values below. + // Set the UVs on the mesh from the values we collected out of the primvar. + // We'll check whether there is an unauthored value in the primvar and skip + // it if so to ensure that we don't import it into Maya where it has no + // meaning. + const int unauthoredValuesIndex = primvar.GetUnauthoredValuesIndex(); + + MFloatArray uCoords; + MFloatArray vCoords; + + for (size_t uvId = 0u; uvId < uvValues.size(); ++uvId) { + if (unauthoredValuesIndex < 0 || uvId != static_cast(unauthoredValuesIndex)) { + const GfVec2f& v = uvValues[uvId]; + uCoords.append(v[0u]); + vCoords.append(v[1u]); + } + } + status = meshFn.setUVs(uCoords, vCoords, &uvSetName); if (status != MS::kSuccess) { TF_WARN( @@ -298,6 +266,23 @@ bool assignUVSetPrimvarToMesh(const UsdGeomPrimvar& primvar, MFnMesh& meshFn, bo return false; } + VtIntArray assignmentIndices; + if (primvar.GetIndices(&assignmentIndices)) { + 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 + // unauthored value index with -1, and decrement any index that was + // after the unauthored value index by 1. + for (int& index : assignmentIndices) { + if (index == unauthoredValuesIndex) { + index = -1; + } else if (index > unauthoredValuesIndex) { + index -= 1; + } + } + } + } + const TfToken& interpolation = primvar.GetInterpolation(); // Build an array of value assignments for each face vertex in the mesh. From ac5ef5501a83419ad9c1555c91bb87001a95aa61 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Thu, 11 Feb 2021 16:07:40 -0800 Subject: [PATCH 11/13] add validation of number of UV shells in testUsdImportUVSets --- .../usd/translators/testUsdImportUVSets.py | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/test/lib/usd/translators/testUsdImportUVSets.py b/test/lib/usd/translators/testUsdImportUVSets.py index 163f90346b..d86f0ae2d5 100644 --- a/test/lib/usd/translators/testUsdImportUVSets.py +++ b/test/lib/usd/translators/testUsdImportUVSets.py @@ -31,7 +31,8 @@ class testUsdImportUVSets(unittest.TestCase): - def _AssertUVSet(self, mesh, uvSetName, expectedValues, expectedNumValues=None): + def _AssertUVSet(self, mesh, uvSetName, expectedValues, + expectedNumValues=None, expectedNumUVShells=None): """ Verifies that the UV values for the uv set named uvSetName on the MFnMesh mesh match the values in expectedValues. expectedValues should @@ -63,6 +64,10 @@ def _AssertUVSet(self, mesh, uvSetName, expectedValues, expectedNumValues=None): itMeshFV.next() fvi += 1 + if expectedNumUVShells is not None: + (numUVShells, shellIndices) = mesh.getUvShellsIds(uvSetName) + self.assertEqual(expectedNumUVShells, numUVShells) + @classmethod def setUpClass(cls): cls.asFloat2 = mayaUsdLib.ReadUtil.ReadFloat2AsUV() @@ -135,7 +140,7 @@ def testImportDefaultUVSet(self): } self._AssertUVSet(mayaCubeMesh, self.defaultUVName, expectedValues, - expectedNumValues=14) + expectedNumValues=14, expectedNumUVShells=1) def testImportMap1UVSet(self): """ @@ -173,7 +178,7 @@ def testImportMap1UVSet(self): } self._AssertUVSet(mayaCubeMesh, "map1", expectedValues, - expectedNumValues=14) + expectedNumValues=14, expectedNumUVShells=1) def testImportOneMissingFaceUVSet(self): """ @@ -206,7 +211,7 @@ def testImportOneMissingFaceUVSet(self): } self._AssertUVSet(mayaCubeMesh, self.defaultUVName, expectedValues, - expectedNumValues=14) + expectedNumValues=14, expectedNumUVShells=2) def testImportOneAssignedFaceUVSet(self): """ @@ -223,7 +228,7 @@ def testImportOneAssignedFaceUVSet(self): } self._AssertUVSet(mayaCubeMesh, self.defaultUVName, expectedValues, - expectedNumValues=4) + expectedNumValues=4, expectedNumUVShells=1) def testImportCompressedUVSets(self): """ @@ -245,7 +250,7 @@ def testImportCompressedUVSets(self): for i in range(24): expectedValues[i] = Gf.Vec2f(0.25, 0.25) self._AssertUVSet(mayaCubeMesh, uvSetName, expectedValues, - expectedNumValues=1) + expectedNumValues=1, expectedNumUVShells=1) # All face vertices within the same face should have the same value. uvSetName = 'UniformInterpSet' @@ -263,7 +268,7 @@ def testImportCompressedUVSets(self): for i in range(20, 24): expectedValues[i] = Gf.Vec2f(0.5, 0.5) self._AssertUVSet(mayaCubeMesh, uvSetName, expectedValues, - expectedNumValues=6) + expectedNumValues=6, expectedNumUVShells=6) # All face vertices on the same mesh vertex (indices 0-7 for a cube) # should have the same value. @@ -295,7 +300,7 @@ def testImportCompressedUVSets(self): 23 : Gf.Vec2f(0.4, 0.4) } self._AssertUVSet(mayaCubeMesh, uvSetName, expectedValues, - expectedNumValues=8) + expectedNumValues=8, expectedNumUVShells=1) def testImportSharedFacesUVSets(self): """ @@ -316,7 +321,7 @@ def testImportSharedFacesUVSets(self): for i in range(3, 24, 4): expectedValues[i] = Gf.Vec2f(0.0, 1.0) self._AssertUVSet(mayaCubeMesh, uvSetName, expectedValues, - expectedNumValues=4) + expectedNumValues=4, expectedNumUVShells=1) # The faces alternate between ranges 0.0-0.5 and 0.5-1.0. uvSetName = 'PairedFacesSet' @@ -338,7 +343,7 @@ def testImportSharedFacesUVSets(self): for i in range(7, 24, 8): expectedValues[i] = Gf.Vec2f(0.5, 1.0) self._AssertUVSet(mayaCubeMesh, uvSetName, expectedValues, - expectedNumValues=7) + expectedNumValues=7, expectedNumUVShells=2) def testImportUVSetForMeshWithCreases(self): """ From b94de4fe8de195b963dbdedc6879dcbacaf3d7f3 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Fri, 12 Feb 2021 13:07:22 -0800 Subject: [PATCH 12/13] delete construction history to simplify OneMissingFaceCubeShape and OneAssignedFaceCubeShape --- .../UsdExportUVSetsTest_Float.ma | 77 ++----------------- .../UsdExportUVSetsTest.ma | 77 ++----------------- 2 files changed, 10 insertions(+), 144 deletions(-) diff --git a/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma b/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma index a226b9f05e..f162c2c7d2 100644 --- a/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma +++ b/test/lib/usd/translators/UsdExportUVSetsFloatTest/UsdExportUVSetsTest_Float.ma @@ -199,30 +199,6 @@ createNode mesh -n "OneMissingFaceCubeShape" -p "OneMissingFaceCube"; setAttr ".vir" yes; setAttr ".vif" yes; setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".cuvs" -type "string" "map1"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".ds" no; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; - setAttr ".mgi" -type "string" "ID_00dcb39c-ae2c-4239-b0d8-945f9db8e612"; - setAttr ".allowPerFaceDisplayColors" yes; -createNode mesh -n "polySurfaceShape1" -p "OneMissingFaceCube"; - rename -uid "415B68C0-0000-16E9-57B7-9C390000027F"; - addAttr -ci true -sn "mgi" -ln "mayaGprimID" -dt "string"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr -k off ".v"; - setAttr ".io" yes; - setAttr -s 6 ".iog[0].og"; - setAttr ".iog[0].og[0].gcl" -type "componentList" 1 "f[2]"; - setAttr ".iog[0].og[1].gcl" -type "componentList" 1 "f[3]"; - setAttr ".iog[0].og[2].gcl" -type "componentList" 1 "f[4]"; - setAttr ".iog[0].og[3].gcl" -type "componentList" 1 "f[1]"; - setAttr ".iog[0].og[4].gcl" -type "componentList" 1 "f[5]"; - setAttr ".iog[0].og[5].gcl" -type "componentList" 1 "f[0]"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr ".uvst[0].uvsn" -type "string" "map1"; setAttr -s 14 ".uvst[0].uvsp[0:13]" -type "float2" 0.375 0 0.625 0 0.375 0.25 0.625 0.25 0.375 0.5 0.625 0.5 0.375 0.75 0.625 0.75 0.375 1 0.625 1 0.875 0 0.875 0.25 0.125 0 0.125 0.25; @@ -241,7 +217,6 @@ createNode mesh -n "polySurfaceShape1" -p "OneMissingFaceCube"; f 4 1 7 -3 -7 mu 0 4 2 3 5 4 f 4 2 9 -4 -9 - mu 0 4 4 5 7 6 f 4 3 11 -1 -11 mu 0 4 6 7 9 8 f 4 -12 -10 -8 -6 @@ -271,33 +246,8 @@ createNode mesh -n "OneAssignedFaceCubeShape" -p "OneAssignedFaceCube"; setAttr ".vir" yes; setAttr ".vif" yes; setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".cuvs" -type "string" "map1"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".ds" no; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; - setAttr ".mgi" -type "string" "ID_f8c2d19a-0a4f-48e1-b29c-dc491b67c152"; - setAttr ".allowPerFaceDisplayColors" yes; -createNode mesh -n "polySurfaceShape2" -p "OneAssignedFaceCube"; - rename -uid "415B68C0-0000-16E9-57B7-9CCB00000286"; - addAttr -ci true -sn "mgi" -ln "mayaGprimID" -dt "string"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr -k off ".v"; - setAttr ".io" yes; - setAttr -s 6 ".iog[0].og"; - setAttr ".iog[0].og[0].gcl" -type "componentList" 1 "f[2]"; - setAttr ".iog[0].og[1].gcl" -type "componentList" 1 "f[3]"; - setAttr ".iog[0].og[2].gcl" -type "componentList" 1 "f[4]"; - setAttr ".iog[0].og[3].gcl" -type "componentList" 1 "f[1]"; - setAttr ".iog[0].og[4].gcl" -type "componentList" 1 "f[5]"; - setAttr ".iog[0].og[5].gcl" -type "componentList" 1 "f[0]"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr -s 14 ".uvst[0].uvsp[0:13]" -type "float2" 0.375 0 0.625 0 0.375 - 0.25 0.625 0.25 0.375 0.5 0.625 0.5 0.375 0.75 0.625 0.75 0.375 1 0.625 1 0.875 0 - 0.875 0.25 0.125 0 0.125 0.25; + setAttr -s 4 ".uvst[0].uvsp[0:3]" -type "float2" 0.375 0.5 0.625 0.5 + 0.375 0.75 0.625 0.75; setAttr ".cuvs" -type "string" "map1"; setAttr ".dcc" -type "string" "Ambient+Diffuse"; setAttr ".ds" no; @@ -309,17 +259,12 @@ createNode mesh -n "polySurfaceShape2" -p "OneAssignedFaceCube"; 3 5 0 4 6 0 5 7 0 6 0 0 7 1 0; setAttr -s 6 -ch 24 ".fc[0:5]" -type "polyFaces" f 4 0 5 -2 -5 - mu 0 4 0 1 3 2 f 4 1 7 -3 -7 - mu 0 4 2 3 5 4 f 4 2 9 -4 -9 - mu 0 4 4 5 7 6 + mu 0 4 0 1 3 2 f 4 3 11 -1 -11 - mu 0 4 6 7 9 8 f 4 -12 -10 -8 -6 - mu 0 4 1 10 11 3 - f 4 10 4 6 8 - mu 0 4 12 0 2 13; + f 4 10 4 6 8; setAttr ".cd" -type "dataPolyComponent" Index_Data Edge 0 ; setAttr ".cvd" -type "dataPolyComponent" Index_Data Vertex 0 ; setAttr ".pd[0]" -type "dataPolyComponent" Index_Data UV 0 ; @@ -1312,7 +1257,7 @@ createNode lambert -n "Red"; createNode shadingEngine -n "lambert2SG"; rename -uid "109AE860-0000-148A-5708-3FF300000264"; setAttr ".ihi" 0; - setAttr -s 6 ".dsm"; + setAttr -s 5 ".dsm"; setAttr ".ro" yes; createNode materialInfo -n "materialInfo1"; rename -uid "109AE860-0000-148A-5708-3FF300000265"; @@ -1380,14 +1325,6 @@ createNode nodeGraphEditorInfo -n "hyperShadePrimaryNodeEditorSavedTabsInfo"; setAttr ".tgi[0].tn" -type "string" "Untitled_1"; setAttr ".tgi[0].vl" -type "double2" -113.09523360123723 -455.97199742362869 ; setAttr ".tgi[0].vh" -type "double2" 571.428548722041 205.97200735773578 ; -createNode polyMapDel -n "polyMapDel1"; - rename -uid "415B68C0-0000-16E9-57B7-9C390000027E"; - setAttr ".uopa" yes; - setAttr ".ics" -type "componentList" 1 "f[2]"; -createNode polyMapDel -n "polyMapDel2"; - rename -uid "415B68C0-0000-16E9-57B7-9CCB00000285"; - setAttr ".uopa" yes; - setAttr ".ics" -type "componentList" 2 "f[0:1]" "f[3:5]"; createNode expression -n "BrokenUVs_C3d__HiddenInfoNode"; rename -uid "0D9708C0-0000-66E1-59DF-C01C0000028F"; addAttr -ci true -h true -sn "__pxSimNodeEmulate" -ln "__pxSimNodeEmulate" -min @@ -1632,8 +1569,6 @@ select -ne :defaultColorMgtGlobals; select -ne :hardwareRenderGlobals; setAttr ".ctrs" 256; setAttr ".btrs" 512; -connectAttr "polyMapDel1.out" "OneMissingFaceCubeShape.i"; -connectAttr "polyMapDel2.out" "OneAssignedFaceCubeShape.i"; relationship "link" ":lightLinker1" ":initialShadingGroup.message" ":defaultLightSet.message"; relationship "link" ":lightLinker1" ":initialParticleSE.message" ":defaultLightSet.message"; relationship "link" ":lightLinker1" "lambert2SG.message" ":defaultLightSet.message"; @@ -1679,8 +1614,6 @@ connectAttr "Magenta.msg" "materialInfo5.m"; connectAttr "Cyan.oc" "lambert7SG.ss"; connectAttr "lambert7SG.msg" "materialInfo6.sg"; connectAttr "Cyan.msg" "materialInfo6.m"; -connectAttr "polySurfaceShape1.o" "polyMapDel1.ip"; -connectAttr "polySurfaceShape2.o" "polyMapDel2.ip"; connectAttr ":time1.o" "BrokenUVs_C3d__HiddenInfoNode.tim"; connectAttr "layerManager.dli[4]" "BrokenUVs_Decimated.id"; connectAttr "layerManager.dli[5]" "BrokenUVs_Simulation.id"; diff --git a/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma b/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma index a226b9f05e..f162c2c7d2 100644 --- a/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma +++ b/test/lib/usd/translators/UsdExportUVSetsTest/UsdExportUVSetsTest.ma @@ -199,30 +199,6 @@ createNode mesh -n "OneMissingFaceCubeShape" -p "OneMissingFaceCube"; setAttr ".vir" yes; setAttr ".vif" yes; setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".cuvs" -type "string" "map1"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".ds" no; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; - setAttr ".mgi" -type "string" "ID_00dcb39c-ae2c-4239-b0d8-945f9db8e612"; - setAttr ".allowPerFaceDisplayColors" yes; -createNode mesh -n "polySurfaceShape1" -p "OneMissingFaceCube"; - rename -uid "415B68C0-0000-16E9-57B7-9C390000027F"; - addAttr -ci true -sn "mgi" -ln "mayaGprimID" -dt "string"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr -k off ".v"; - setAttr ".io" yes; - setAttr -s 6 ".iog[0].og"; - setAttr ".iog[0].og[0].gcl" -type "componentList" 1 "f[2]"; - setAttr ".iog[0].og[1].gcl" -type "componentList" 1 "f[3]"; - setAttr ".iog[0].og[2].gcl" -type "componentList" 1 "f[4]"; - setAttr ".iog[0].og[3].gcl" -type "componentList" 1 "f[1]"; - setAttr ".iog[0].og[4].gcl" -type "componentList" 1 "f[5]"; - setAttr ".iog[0].og[5].gcl" -type "componentList" 1 "f[0]"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr ".uvst[0].uvsn" -type "string" "map1"; setAttr -s 14 ".uvst[0].uvsp[0:13]" -type "float2" 0.375 0 0.625 0 0.375 0.25 0.625 0.25 0.375 0.5 0.625 0.5 0.375 0.75 0.625 0.75 0.375 1 0.625 1 0.875 0 0.875 0.25 0.125 0 0.125 0.25; @@ -241,7 +217,6 @@ createNode mesh -n "polySurfaceShape1" -p "OneMissingFaceCube"; f 4 1 7 -3 -7 mu 0 4 2 3 5 4 f 4 2 9 -4 -9 - mu 0 4 4 5 7 6 f 4 3 11 -1 -11 mu 0 4 6 7 9 8 f 4 -12 -10 -8 -6 @@ -271,33 +246,8 @@ createNode mesh -n "OneAssignedFaceCubeShape" -p "OneAssignedFaceCube"; setAttr ".vir" yes; setAttr ".vif" yes; setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr ".cuvs" -type "string" "map1"; - setAttr ".dcc" -type "string" "Ambient+Diffuse"; - setAttr ".ds" no; - setAttr ".covm[0]" 0 1 1; - setAttr ".cdvm[0]" 0 1 1; - setAttr ".mgi" -type "string" "ID_f8c2d19a-0a4f-48e1-b29c-dc491b67c152"; - setAttr ".allowPerFaceDisplayColors" yes; -createNode mesh -n "polySurfaceShape2" -p "OneAssignedFaceCube"; - rename -uid "415B68C0-0000-16E9-57B7-9CCB00000286"; - addAttr -ci true -sn "mgi" -ln "mayaGprimID" -dt "string"; - addAttr -ci true -sn "allowPerFaceDisplayColors" -ln "allowPerFaceDisplayColors" - -min 0 -max 1 -at "bool"; - setAttr -k off ".v"; - setAttr ".io" yes; - setAttr -s 6 ".iog[0].og"; - setAttr ".iog[0].og[0].gcl" -type "componentList" 1 "f[2]"; - setAttr ".iog[0].og[1].gcl" -type "componentList" 1 "f[3]"; - setAttr ".iog[0].og[2].gcl" -type "componentList" 1 "f[4]"; - setAttr ".iog[0].og[3].gcl" -type "componentList" 1 "f[1]"; - setAttr ".iog[0].og[4].gcl" -type "componentList" 1 "f[5]"; - setAttr ".iog[0].og[5].gcl" -type "componentList" 1 "f[0]"; - setAttr ".vir" yes; - setAttr ".vif" yes; - setAttr ".uvst[0].uvsn" -type "string" "map1"; - setAttr -s 14 ".uvst[0].uvsp[0:13]" -type "float2" 0.375 0 0.625 0 0.375 - 0.25 0.625 0.25 0.375 0.5 0.625 0.5 0.375 0.75 0.625 0.75 0.375 1 0.625 1 0.875 0 - 0.875 0.25 0.125 0 0.125 0.25; + setAttr -s 4 ".uvst[0].uvsp[0:3]" -type "float2" 0.375 0.5 0.625 0.5 + 0.375 0.75 0.625 0.75; setAttr ".cuvs" -type "string" "map1"; setAttr ".dcc" -type "string" "Ambient+Diffuse"; setAttr ".ds" no; @@ -309,17 +259,12 @@ createNode mesh -n "polySurfaceShape2" -p "OneAssignedFaceCube"; 3 5 0 4 6 0 5 7 0 6 0 0 7 1 0; setAttr -s 6 -ch 24 ".fc[0:5]" -type "polyFaces" f 4 0 5 -2 -5 - mu 0 4 0 1 3 2 f 4 1 7 -3 -7 - mu 0 4 2 3 5 4 f 4 2 9 -4 -9 - mu 0 4 4 5 7 6 + mu 0 4 0 1 3 2 f 4 3 11 -1 -11 - mu 0 4 6 7 9 8 f 4 -12 -10 -8 -6 - mu 0 4 1 10 11 3 - f 4 10 4 6 8 - mu 0 4 12 0 2 13; + f 4 10 4 6 8; setAttr ".cd" -type "dataPolyComponent" Index_Data Edge 0 ; setAttr ".cvd" -type "dataPolyComponent" Index_Data Vertex 0 ; setAttr ".pd[0]" -type "dataPolyComponent" Index_Data UV 0 ; @@ -1312,7 +1257,7 @@ createNode lambert -n "Red"; createNode shadingEngine -n "lambert2SG"; rename -uid "109AE860-0000-148A-5708-3FF300000264"; setAttr ".ihi" 0; - setAttr -s 6 ".dsm"; + setAttr -s 5 ".dsm"; setAttr ".ro" yes; createNode materialInfo -n "materialInfo1"; rename -uid "109AE860-0000-148A-5708-3FF300000265"; @@ -1380,14 +1325,6 @@ createNode nodeGraphEditorInfo -n "hyperShadePrimaryNodeEditorSavedTabsInfo"; setAttr ".tgi[0].tn" -type "string" "Untitled_1"; setAttr ".tgi[0].vl" -type "double2" -113.09523360123723 -455.97199742362869 ; setAttr ".tgi[0].vh" -type "double2" 571.428548722041 205.97200735773578 ; -createNode polyMapDel -n "polyMapDel1"; - rename -uid "415B68C0-0000-16E9-57B7-9C390000027E"; - setAttr ".uopa" yes; - setAttr ".ics" -type "componentList" 1 "f[2]"; -createNode polyMapDel -n "polyMapDel2"; - rename -uid "415B68C0-0000-16E9-57B7-9CCB00000285"; - setAttr ".uopa" yes; - setAttr ".ics" -type "componentList" 2 "f[0:1]" "f[3:5]"; createNode expression -n "BrokenUVs_C3d__HiddenInfoNode"; rename -uid "0D9708C0-0000-66E1-59DF-C01C0000028F"; addAttr -ci true -h true -sn "__pxSimNodeEmulate" -ln "__pxSimNodeEmulate" -min @@ -1632,8 +1569,6 @@ select -ne :defaultColorMgtGlobals; select -ne :hardwareRenderGlobals; setAttr ".ctrs" 256; setAttr ".btrs" 512; -connectAttr "polyMapDel1.out" "OneMissingFaceCubeShape.i"; -connectAttr "polyMapDel2.out" "OneAssignedFaceCubeShape.i"; relationship "link" ":lightLinker1" ":initialShadingGroup.message" ":defaultLightSet.message"; relationship "link" ":lightLinker1" ":initialParticleSE.message" ":defaultLightSet.message"; relationship "link" ":lightLinker1" "lambert2SG.message" ":defaultLightSet.message"; @@ -1679,8 +1614,6 @@ connectAttr "Magenta.msg" "materialInfo5.m"; connectAttr "Cyan.oc" "lambert7SG.ss"; connectAttr "lambert7SG.msg" "materialInfo6.sg"; connectAttr "Cyan.msg" "materialInfo6.m"; -connectAttr "polySurfaceShape1.o" "polyMapDel1.ip"; -connectAttr "polySurfaceShape2.o" "polyMapDel2.ip"; connectAttr ":time1.o" "BrokenUVs_C3d__HiddenInfoNode.tim"; connectAttr "layerManager.dli[4]" "BrokenUVs_Decimated.id"; connectAttr "layerManager.dli[5]" "BrokenUVs_Simulation.id"; From 6780fda93b047a6eb91ead50cbe2ca05c638bcb9 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Fri, 19 Feb 2021 09:48:02 -0800 Subject: [PATCH 13/13] fix compilation against core USD versions before 20.11 that do not have VtArray::emplace_back() VtArray did not gain emplace_back() until USD 20.11, and before that it's push_back() took a const reference parameter. --- lib/mayaUsd/fileio/utils/meshWriteUtils.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp b/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp index dfa32fbf3b..751b149d2c 100644 --- a/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp +++ b/lib/mayaUsd/fileio/utils/meshWriteUtils.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -873,7 +874,12 @@ bool UsdMayaMeshWriteUtils::getMeshUVSetData( uvArray->clear(); uvArray->reserve(static_cast(uArray.length())); for (unsigned int uvId = 0u; uvId < uArray.length(); ++uvId) { +#if PXR_VERSION >= 2011 uvArray->emplace_back(uArray[uvId], vArray[uvId]); +#else + GfVec2f value(uArray[uvId], vArray[uvId]); + uvArray->push_back(value); +#endif } // Now iterate through all the face vertices and fill in the faceVarying