Skip to content

IECoreMaya : FromMayaMeshConverter, respect "uv" parameter with multiple uvs #1043

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

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
23 changes: 11 additions & 12 deletions src/IECoreMaya/FromMayaMeshConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,20 +619,19 @@ IECoreScene::PrimitivePtr FromMayaMeshConverter::doPrimitiveConversion( MFnMesh

if( uvParameter()->getTypedValue() && currentUVSet.length() )
{
result->variables["uv"] = uvs( currentUVSet, verticesPerFaceData->readable() );
}

MStringArray uvSets;
fnMesh.getUVSetNames( uvSets );
for( unsigned int i=0; i<uvSets.length(); i++ )
{
if( uvSets[i] == currentUVSet )
MStringArray uvSets;
fnMesh.getUVSetNames( uvSets );
for( unsigned int i = 0; i < uvSets.length(); i++ )
{
// we've already converted these UVs above
continue;
if( uvSets[i] == currentUVSet )
{
result->variables["uv"] = uvs( currentUVSet, verticesPerFaceData->readable() );
}
else
{
result->variables[uvSets[i].asChar()] = uvs( uvSets[i], verticesPerFaceData->readable() );
}
}

result->variables[ uvSets[i].asChar() ] = uvs( uvSets[i], verticesPerFaceData->readable() );
}

bool convertColors = colorsParameter()->getTypedValue();
Expand Down
17 changes: 12 additions & 5 deletions test/IECoreMaya/FromMayaMeshConverterTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,21 +292,28 @@ def testExtraSTs( self ) :
converter = IECoreMaya.FromMayaShapeConverter.create( plane, IECoreScene.MeshPrimitive.staticTypeId() )
m = converter.convert()

self.assert_( "uv" in m )
self.assertIn( "uv", m )
# map1 is the default set
self.assert_( "map1" not in m )
self.assertNotIn( "map1", m )

maya.cmds.polyUVSet( plane, copy=True, uvSet="map1", newUVSet="map2" )

m = converter.convert()

self.assert_( "uv" in m )
self.assert_( "map1" not in m )
self.assert_( "map2" in m )
self.assertIn( "uv", m )
self.assertNotIn( "map1", m )
self.assertIn( "map2", m )

self.assertEqual( m["uv"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV )
self.assertEqual( m["map2"].data.getInterpretation(), IECore.GeometricData.Interpretation.UV )

# Test that all uvs are ignored when the uv parameter is False
converter["uv"].setTypedValue( False )
m = converter.convert()
self.assertNotIn( "uv", m )
self.assertNotIn( "map1", m )
self.assertNotIn( "map2", m )

def testManyUVConversionsFromPlug( self ) :

# load a mesh with indexed UVs
Expand Down