Skip to content

Commit 6eec66f

Browse files
authored
Merge pull request #1387 from ImageEngine/RB-10.5
Merge RB-10.5 to main
2 parents aae1162 + 6103e34 commit 6eec66f

File tree

4 files changed

+20
-74
lines changed

4 files changed

+20
-74
lines changed

Changes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
10.5.x.x (relative to 10.5.1.0)
22
========
33

4+
Breaking Changes
5+
----------------
6+
- IECoreMaya : Maya meshes converted from Cortex data no longer have normals set explicitly and instead relies on Maya to calculate them.
7+
8+
Fixes
9+
---
10+
- ToMayaMeshConverter : No longer locks normals set on the Mesh from the scc.
411

512
10.5.1.0 (relative to 10.5.0.0)
613
========

src/IECoreMaya/ToMayaMeshConverter.cpp

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ void ToMayaMeshConverter::addUVSet( MFnMesh &fnMesh, const MIntArray &polygonCou
183183

184184
bool ToMayaMeshConverter::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const
185185
{
186+
// Note: Normals are not set on the Mesh from the scc as by setting them
187+
// explicitly we are implying they should be locked which is not
188+
// supported, instead we rely on Maya computing the normals everytime
189+
186190
MStatus s;
187191

188192
IECoreScene::ConstMeshPrimitivePtr mesh = IECore::runTimeCast<const IECoreScene::MeshPrimitive>( from );
@@ -263,79 +267,6 @@ bool ToMayaMeshConverter::doConversion( IECore::ConstObjectPtr from, MObject &to
263267
return false;
264268
}
265269

266-
it = mesh->variables.find("N");
267-
if ( it != mesh->variables.end() )
268-
{
269-
if (it->second.interpolation == IECoreScene::PrimitiveVariable::FaceVarying )
270-
{
271-
/// \todo Employ some M*Array converters to simplify this
272-
MVectorArray vertexNormalsArray;
273-
IECore::ConstV3fVectorDataPtr n = IECore::runTimeCast<const IECore::V3fVectorData>(it->second.data);
274-
if (n)
275-
{
276-
IECoreScene::PrimitiveVariable::IndexedView<Imath::V3f> normalView = IECoreScene::PrimitiveVariable::IndexedView<Imath::V3f>( it->second );
277-
vertexNormalsArray.setLength( normalView.size() );
278-
279-
size_t i = 0;
280-
for(const auto& normal : normalView)
281-
{
282-
vertexNormalsArray[i++] = IECore::convert<MVector, Imath::V3f>( normal );
283-
}
284-
}
285-
else
286-
{
287-
IECore::ConstV3dVectorDataPtr n = IECore::runTimeCast<const IECore::V3dVectorData>(it->second.data);
288-
if (n)
289-
{
290-
IECoreScene::PrimitiveVariable::IndexedView<Imath::V3d> normalView = IECoreScene::PrimitiveVariable::IndexedView<Imath::V3d>( it->second );
291-
vertexNormalsArray.setLength( normalView.size() );
292-
293-
size_t i = 0;
294-
for(const auto& normal : normalView)
295-
{
296-
vertexNormalsArray[i++] = IECore::convert<MVector, Imath::V3d>( normal );
297-
}
298-
}
299-
else
300-
{
301-
IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", boost::format( "PrimitiveVariable \"N\" has unsupported type \"%s\"." ) % it->second.data->typeName() );
302-
}
303-
}
304-
305-
if ( vertexNormalsArray.length() )
306-
{
307-
MStatus status;
308-
MItMeshPolygon itPolygon( mObj, &status );
309-
if( status != MS::kSuccess )
310-
{
311-
IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "Failed to create mesh iterator" );
312-
}
313-
314-
unsigned v = 0;
315-
MIntArray vertexIds;
316-
MIntArray faceIds;
317-
318-
for ( ; !itPolygon.isDone(); itPolygon.next() )
319-
{
320-
for ( v=0; v < itPolygon.polygonVertexCount(); ++v )
321-
{
322-
faceIds.append( itPolygon.index() );
323-
vertexIds.append( itPolygon.vertexIndex( v ) );
324-
}
325-
}
326-
327-
if( !fnMesh.setFaceVertexNormals( vertexNormalsArray, faceIds, vertexIds ) )
328-
{
329-
IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "Setting normals failed" );
330-
}
331-
}
332-
}
333-
else
334-
{
335-
IECore::msg( IECore::Msg::Warning, "ToMayaMeshConverter::doConversion", "PrimitiveVariable \"N\" has unsupported interpolation (expected FaceVarying)." );
336-
}
337-
}
338-
339270
/// Add UV sets
340271
for ( it = mesh->variables.begin(); it != mesh->variables.end(); ++it )
341272
{

test/IECoreMaya/ParameterisedHolder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ def testMeshParameterIOProblem( self ) :
286286
op = fnOP.getOp()
287287

288288
mesh = IECoreScene.MeshPrimitive.createBox( imath.Box3f( imath.V3f( -2, -2, -2 ), imath.V3f( 2, 3, 4 ) ) )
289-
mesh[ "N" ] = IECoreScene.PrimitiveVariable( mesh[ "N" ].interpolation, mesh[ "N" ].expandedData() )
290289
op.parameters()[ "input" ].setValue( mesh )
291290
fnOP.setNodeValues()
292291

@@ -301,7 +300,13 @@ def testMeshParameterIOProblem( self ) :
301300
op = fnOP.getOp()
302301

303302
mesh2 = op.parameters()["input"].getValue()
303+
304304
self.assertTrue( mesh2.arePrimitiveVariablesValid() )
305+
# The ToMayaMeshConverter relies on Maya to calculate the normals
306+
# whereas createBox uses indexed normals so we cannot include them
307+
# in the comparison otherwise they will never be the same
308+
del mesh[ "N" ]
309+
del mesh2[ "N" ]
305310
self.assertEqual( mesh2, mesh )
306311

307312
def testOpHolder( self ) :

test/IECoreMaya/ToMayaMeshConverterTest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ def testNormals( self ) :
308308
self.assertAlmostEqual( origNormal[j], normal3f[j], 6 )
309309
self.assertAlmostEqual( origNormal[j], normal3d[j], 6 )
310310

311+
# normals should always be unlocked when reading from scc
312+
self.assertFalse( any( maya.cmds.polyNormalPerVertex( newSphere+".vtx[*]", query=True, allLocked=True ) ) )
313+
311314
def testSetMeshInterpolation( self ) :
312315

313316
sphere = maya.cmds.polySphere( subdivisionsX=10, subdivisionsY=5, constructionHistory=False )

0 commit comments

Comments
 (0)