Skip to content

Commit

Permalink
IECoreArnold::VDBAlgo : Don't depend on metadata to render
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed Jun 27, 2024
1 parent 52a98f6 commit 660f97a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
1.4.x.x (relative to 1.4.8.0)
=======

Fixes
-----

- IECoreArnold::VDBAlgo : Fixed failure to render when metadata not present.

1.4.8.0 (relative to 1.4.7.0)
=======
Expand Down
27 changes: 6 additions & 21 deletions src/IECoreArnold/VDBAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,17 @@ 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<std::string> gridNames = vdbObject->gridNames();
try
{
for( const std::string& gridName : gridNames )
{
openvdb::GridBase::ConstPtr grid = vdbObject->findGrid( gridName );
totalSizeBytes += grid->metaValue<int64_t>( "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<UCharVectorDataSink> memoryStream( sink );

openvdb::io::Stream vdbStream( memoryStream );

std::vector<std::string> gridNames = vdbObject->gridNames();
for( const std::string& gridName : gridNames )
{
gridsToWrite.push_back( vdbObject->findGrid( gridName ) );
}
vdbStream.write( gridsToWrite );

return buffer;
Expand Down

0 comments on commit 660f97a

Please sign in to comment.