Skip to content

Commit 28ba120

Browse files
committed
Merge pull request #434 from johnhaddon/alembicFaceSets
AlembicInput : Fixed bug where face sets were treated as children.
2 parents 9ee46f2 + b457b9d commit 28ba120

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

contrib/IECoreAlembic/src/IECoreAlembic/AlembicInput.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,19 @@ IECore::ObjectPtr AlembicInput::objectAtTime( double time, IECore::TypeId result
402402

403403
size_t AlembicInput::numChildren() const
404404
{
405+
if(
406+
!IXform::matches( m_data->object.getMetaData() ) &&
407+
m_data->object.getParent()
408+
)
409+
{
410+
// not a transform, and not the top of the archive.
411+
// we want to ignore any children, because they won't
412+
// be something we consider part of the hierarchy -
413+
// alembic implements face sets as objects parented to
414+
// a mesh for instance, whereas we would just think
415+
// of them as a property of the mesh.
416+
return 0;
417+
}
405418
return m_data->object.getNumChildren();
406419
}
407420

@@ -421,7 +434,7 @@ IECore::StringVectorDataPtr AlembicInput::childNames() const
421434
{
422435
StringVectorDataPtr resultData = new StringVectorData;
423436
std::vector<std::string> &resultVector = resultData->writable();
424-
size_t numChildren = m_data->object.getNumChildren();
437+
size_t numChildren = this->numChildren();
425438
for( size_t i=0; i<numChildren; i++ )
426439
{
427440
resultVector.push_back( m_data->object.getChildHeader( i ).getName() );

contrib/IECoreAlembic/test/IECoreAlembic/AlembicInputTest.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,18 @@ def testCamera( self ) :
449449

450450
c = a.child( "persp" ).child( "perspShape" ).objectAtTime( 0 )
451451
self.failUnless( isinstance( c, IECore.Camera ) )
452-
452+
453+
def testHierarchyIgnoresShadingGroups( self ) :
454+
455+
a = IECoreAlembic.AlembicInput( os.path.dirname( __file__ ) + "/data/sphereWithShadingGroups.abc" )
456+
self.assertEqual( a.numChildren(), 1 )
457+
self.assertEqual( a.childNames(), IECore.StringVectorData( [ "pSphere1" ] ) )
458+
459+
g = a.child( "pSphere1" )
460+
m = g.child( "pSphereShape1" )
461+
462+
self.assertEqual( m.numChildren(), 0 )
463+
self.assertEqual( m.childNames(), IECore.StringVectorData() )
464+
453465
if __name__ == "__main__":
454466
unittest.main()
Binary file not shown.

0 commit comments

Comments
 (0)