Skip to content

Commit

Permalink
Merge pull request ImageEngine#734 from donboie/USDBoolFix
Browse files Browse the repository at this point in the history
USDScene : fixed writing bool attributes.
  • Loading branch information
johnhaddon authored Mar 1, 2018
2 parents 0cf63a8 + bb5e4c7 commit 04635f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ typedef std::pair<pxr::VtValue, pxr::SdfValueTypeName> ValueAndType;
static std::map<IECore::TypeId, std::function< ValueAndType ( const IECore::Data* )> > ToUSDConverters =
{
{ IECore::BoolVectorDataTypeId, [] ( const IECore::Data *data ) -> ValueAndType { return std::make_pair( ToUSDArray<bool, bool, IECore::TypedData>().doConversion( data ), pxr::SdfValueTypeNames->BoolArray); } },
{ IECore::BoolDataTypeId, [] ( const IECore::Data *data ) -> ValueAndType { return std::make_pair ( ToUSD<bool, bool, IECore::TypedData>().doConversion(data) , pxr::SdfValueTypeNames->BoolArray); } },
{ IECore::BoolDataTypeId, [] ( const IECore::Data *data ) -> ValueAndType { return std::make_pair ( ToUSD<bool, bool, IECore::TypedData>().doConversion(data) , pxr::SdfValueTypeNames->Bool); } },

{ IECore::HalfVectorDataTypeId, [] ( const IECore::Data *data ) -> ValueAndType { return std::make_pair ( ToUSDArray<pxr::GfHalf, half, IECore::TypedData> ().doConversion(data) , pxr::SdfValueTypeNames->HalfArray); } },
{ IECore::HalfDataTypeId, [] ( const IECore::Data *data ) -> ValueAndType { return std::make_pair ( ToUSD<pxr::GfHalf, half, IECore::TypedData> ().doConversion(data) , pxr::SdfValueTypeNames->Half); } },
Expand Down
12 changes: 7 additions & 5 deletions contrib/IECoreUSD/test/IECoreUSD/USDSceneWriterTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,10 @@ def testCanWriteAttributes( self ) :
sceneWrite = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Write )
numberOneSon = sceneWrite.createChild( "nakamoto" )

numberOneSon.writeAttribute("s32", IECore.IntData(1), 0.0)
numberOneSon.writeAttribute("f32", IECore.FloatData(2.0), 0.0)
numberOneSon.writeAttribute("str", IECore.StringData("hey-ho"), 0.0)
numberOneSon.writeAttribute( "s32", IECore.IntData( 1 ), 0.0 )
numberOneSon.writeAttribute( "f32", IECore.FloatData( 2.0 ), 0.0 )
numberOneSon.writeAttribute( "str", IECore.StringData( "hey-ho" ), 0.0 )
numberOneSon.writeAttribute( "boo", IECore.BoolData( True ), 0.0 )

del numberOneSon
del sceneWrite
Expand All @@ -192,8 +193,9 @@ def testCanWriteAttributes( self ) :
sceneReadNumberOneSon = sceneRead.child("nakamoto")

self.assertEqual( sceneReadNumberOneSon.readAttribute( "s32", 0.0 ), IECore.IntData( 1 ) )
self.assertEqual( sceneReadNumberOneSon.readAttribute( "f32", 0.0 ), IECore.FloatData(2.0) )
self.assertEqual( sceneReadNumberOneSon.readAttribute( "str", 0.0 ), IECore.StringData("hey-ho") )
self.assertEqual( sceneReadNumberOneSon.readAttribute( "f32", 0.0 ), IECore.FloatData( 2.0 ) )
self.assertEqual( sceneReadNumberOneSon.readAttribute( "str", 0.0 ), IECore.StringData( "hey-ho" ) )
self.assertEqual( sceneReadNumberOneSon.readAttribute( "boo", 0.0 ), IECore.BoolData( True ) )

def testCanWritePoints ( self ):

Expand Down

0 comments on commit 04635f7

Please sign in to comment.