From ea1b3b59faf2e7618cf07a498da17374dc836cab Mon Sep 17 00:00:00 2001 From: Daniel Dresser Date: Tue, 25 Jun 2024 15:32:56 -0700 Subject: [PATCH] IECoreArnold::VDBAlgo : Don't depend on metadata to render --- Changes.md | 1 + src/IECoreArnold/VDBAlgo.cpp | 28 +++++++--------------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/Changes.md b/Changes.md index 067ffdd7a01..3550d87f0e9 100644 --- a/Changes.md +++ b/Changes.md @@ -25,6 +25,7 @@ Fixes - OpenColorIO : Fixed the display transform used to show colours in popups. - SceneInspector : Fixed "Show History" menu items. - ImageGadget : Fixed loading of non-8-bit images. Among other things, this fixes the display of 16 bit node icons in the GraphEditor. +- Arnold : Fixed rendering of VDB volumes without `file_mem_bytes` metadata. API --- diff --git a/src/IECoreArnold/VDBAlgo.cpp b/src/IECoreArnold/VDBAlgo.cpp index 04f902dfc7d..17b771a0f7c 100644 --- a/src/IECoreArnold/VDBAlgo.cpp +++ b/src/IECoreArnold/VDBAlgo.cpp @@ -87,32 +87,18 @@ struct UCharVectorDataSink UCharVectorDataPtr createMemoryBuffer(const IECoreVDB::VDBObject* vdbObject) { - // estimate the size of the memory required to hand the VDB to arnold. - // This is required so we can reserve the right amount of space in the output - // buffer. - int64_t totalSizeBytes = 0; - openvdb::GridCPtrVec gridsToWrite; - std::vector gridNames = vdbObject->gridNames(); - try - { - for( const std::string& gridName : gridNames ) - { - openvdb::GridBase::ConstPtr grid = vdbObject->findGrid( gridName ); - totalSizeBytes += grid->metaValue( "file_mem_bytes" ); - gridsToWrite.push_back( grid ); - } - } - catch( const std::exception & ) - { - IECore::msg( IECore::MessageHandler::Warning, "VDBObject::memoryBuffer", "Unable to estimate vdb size." ); - } - IECore::UCharVectorDataPtr buffer = new IECore::UCharVectorData(); - buffer->writable().reserve( totalSizeBytes ); UCharVectorDataSink sink( buffer.get() ); boost::iostreams::stream memoryStream( sink ); openvdb::io::Stream vdbStream( memoryStream ); + + openvdb::GridCPtrVec gridsToWrite; + std::vector gridNames = vdbObject->gridNames(); + for( const std::string& gridName : gridNames ) + { + gridsToWrite.push_back( vdbObject->findGrid( gridName ) ); + } vdbStream.write( gridsToWrite ); return buffer;