Skip to content

Commit

Permalink
Merge pull request #5923 from danieldresser-ie/levelSetFix
Browse files Browse the repository at this point in the history
MeshToLevelSet Rendering Fixes
  • Loading branch information
johnhaddon authored Jul 9, 2024
2 parents f963611 + ea1b3b5 commit 73ad0fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down
28 changes: 7 additions & 21 deletions src/IECoreArnold/VDBAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 );

openvdb::GridCPtrVec gridsToWrite;
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 73ad0fd

Please sign in to comment.