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

VDBObject : Don't bake in automatic metadata when querying metadata #1423

Open
wants to merge 2 commits into
base: RB-10.5
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
10.5.x.x (relative to 10.5.9.0)
========

Fixes
-----

VDBObject : metadata() now just returns existing metadata, without modifying it.


10.5.9.x (relative to 10.5.8.0)
Expand Down
2 changes: 1 addition & 1 deletion include/IECoreVDB/VDBObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class IECOREVDB_API VDBObject : public IECoreScene::VisibleRenderable
Imath::Box3f bound() const override;
void render( IECoreScene::Renderer *renderer ) const override;

IECore::CompoundObjectPtr metadata( const std::string &name );
IECore::CompoundObjectPtr metadata( const std::string &name ) const;

//! Are the grids in this VDBObject unmodified from the vdb file in filename?
//! Useful for passing VDB objects to renders by filename instead of memory buffer
Expand Down
27 changes: 17 additions & 10 deletions src/IECoreVDB/VDBObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,23 @@ namespace
template<typename T>
Imath::Box<Imath::Vec3<T> > worldBound( const openvdb::GridBase *grid, float padding = 0.50f )
{
openvdb::Vec3i min = grid->metaValue<openvdb::Vec3i>( grid->META_FILE_BBOX_MIN );
openvdb::Vec3i max = grid->metaValue<openvdb::Vec3i>( grid->META_FILE_BBOX_MAX );
openvdb::CoordBBox vdbBbox;
try
{
vdbBbox.min() = openvdb::Coord( grid->metaValue<openvdb::Vec3i>( grid->META_FILE_BBOX_MIN ) );
vdbBbox.max() = openvdb::Coord( grid->metaValue<openvdb::Vec3i>( grid->META_FILE_BBOX_MAX ) );
}
catch( ... )
{
// If we don't have metadata available, then hopefully it's because the vdb was freshly created and
// hasn't been saved to file yet, which should mean it's fully loaded, and we can call
// evalActiveVoxelBoundingBox.
// \todo : Can we guarantee that every VDB either is loaded, or has metadata?
vdbBbox = grid->evalActiveVoxelBoundingBox();
}

openvdb::Vec3d offset = openvdb::Vec3d( padding );
openvdb::BBoxd indexBounds = openvdb::BBoxd( min - offset, max + offset );
openvdb::BBoxd indexBounds = openvdb::BBoxd( vdbBbox.min() - offset, vdbBbox.max() + offset );
openvdb::BBoxd worldBounds = grid->transform().indexToWorld( indexBounds );
openvdb::Vec3d minBB = worldBounds.min();
openvdb::Vec3d maxBB = worldBounds.max();
Expand Down Expand Up @@ -199,7 +211,7 @@ void VDBObject::render( IECoreScene::Renderer *renderer ) const
{
}

IECore::CompoundObjectPtr VDBObject::metadata( const std::string &name )
IECore::CompoundObjectPtr VDBObject::metadata( const std::string &name ) const
{
CompoundObjectPtr metadata = new CompoundObject();

Expand All @@ -216,12 +228,7 @@ IECore::CompoundObjectPtr VDBObject::metadata( const std::string &name )
}
else
{
openvdb::GridBase::Ptr tmpGrid = findGrid ( name );
if ( tmpGrid )
{
tmpGrid->addStatsMetadata();
}
grid = tmpGrid;
grid = findGrid ( name );
}

if( !grid )
Expand Down
Loading