diff --git a/Changes b/Changes index 0809c3567e..21295522f5 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,10 @@ 10.5.x.x (relative to 10.5.9.3) ======== +Fixes +----- +- USDScene : Fixed crash loading a Volume with an empty field. 10.5.9.3 (relative to 10.5.9.2) ======== diff --git a/contrib/IECoreUSD/src/IECoreUSD/VolumeAlgo.cpp b/contrib/IECoreUSD/src/IECoreUSD/VolumeAlgo.cpp index 4984065721..02d6c9155e 100644 --- a/contrib/IECoreUSD/src/IECoreUSD/VolumeAlgo.cpp +++ b/contrib/IECoreUSD/src/IECoreUSD/VolumeAlgo.cpp @@ -98,8 +98,11 @@ IECore::ObjectPtr readVolume( pxr::UsdVolVolume &volume, pxr::UsdTimeCode time, continue; } - ConstDataPtr fieldFileNameData = DataAlgo::fromUSD( fieldAsset.GetFilePathAttr(), time ); - const std::string fieldFileName = static_cast( fieldFileNameData.get() )->readable(); + std::string fieldFileName; + if( auto fieldFileNameData = runTimeCast( DataAlgo::fromUSD( fieldAsset.GetFilePathAttr(), time ) ) ) + { + fieldFileName = fieldFileNameData->readable(); + } if( fileName.empty() ) { diff --git a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py index 9e944f9ab2..8f0f53e98a 100644 --- a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py +++ b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py @@ -4398,5 +4398,12 @@ def testUsdVolVolumeSlashes( self ) : self.assertNotIn( "\\", vdbObject.fileName() ) self.assertTrue( pathlib.Path( vdbObject.fileName() ).is_file() ) + @unittest.skipIf( not haveVDB, "No IECoreVDB" ) + def testUsdVolVolumeWithEmptyField( self ) : + + fileName = os.path.dirname( __file__ ) + "/data/volumeWithEmptyField.usda" + root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read ) + self.assertIsNone( root.child( "volume" ).readObject( 0 ) ) + if __name__ == "__main__": unittest.main() diff --git a/contrib/IECoreUSD/test/IECoreUSD/data/volumeWithEmptyField.usda b/contrib/IECoreUSD/test/IECoreUSD/data/volumeWithEmptyField.usda new file mode 100644 index 0000000000..173bdfbd56 --- /dev/null +++ b/contrib/IECoreUSD/test/IECoreUSD/data/volumeWithEmptyField.usda @@ -0,0 +1,11 @@ +#usda 1.0 + +def Volume "volume" +{ + custom rel field:density = + + def OpenVDBAsset "density" + { + } +} +