Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MeshToLevelSet Rendering Fixes #5923

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading