Skip to content
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: 2 additions & 2 deletions openvdb/openvdb/io/Archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ getFormatVersion(std::ios_base& is)
void
checkFormatVersion(std::ios_base& is)
{
if (getFormatVersion(is) < OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION ) {
if (getFormatVersion(is) < OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX ) {
OPENVDB_THROW(IoError,
"VDB file version < 222 (NODE_MASK_COMPRESSION) is no longer supported. "
"VDB file version < 221 (FLOAT_FRUSTUM_BBOX) is no longer supported. "
"To read older VDB files, please use VDB 12.x or older and then write "
"them out again to produce files that are compatible with 13.0 and above.");
}
Expand Down
20 changes: 11 additions & 9 deletions openvdb/openvdb/io/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,17 @@ readCompressedValues(std::istream& is, ValueT* destBuf, Index destCount,

int8_t metadata = NO_MASK_AND_ALL_VALS;

// Read the flag that specifies what, if any, additional metadata
// (selection mask and/or inactive value(s)) is saved.
if (seek && !maskCompressed) {
is.seekg(/*bytes=*/1, std::ios_base::cur);
} else if (seek && delayLoadMeta) {
metadata = delayLoadMeta->getMask(leafIndex);
is.seekg(/*bytes=*/1, std::ios_base::cur);
} else {
is.read(reinterpret_cast<char*>(&metadata), /*bytes=*/1);
if (getFormatVersion(is) >= OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION) {
// Read the flag that specifies what, if any, additional metadata
// (selection mask and/or inactive value(s)) is saved.
if (seek && !maskCompressed) {
is.seekg(/*bytes=*/1, std::ios_base::cur);
} else if (seek && delayLoadMeta) {
metadata = delayLoadMeta->getMask(leafIndex);
is.seekg(/*bytes=*/1, std::ios_base::cur);
} else {
is.read(reinterpret_cast<char*>(&metadata), /*bytes=*/1);
}
}

ValueT background = zeroVal<ValueT>();
Expand Down
8 changes: 4 additions & 4 deletions openvdb/openvdb/io/File.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ File::readAllGridMetadata()
OPENVDB_THROW(IoError, filename() << " is not open for reading");
}

if (fileVersion() < OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION) {
if (fileVersion() < OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX) {
OPENVDB_THROW(IoError,
"VDB file version < 222 (NODE_MASK_COMPRESSION) is no longer supported.");
"VDB file version < 221 (FLOAT_FRUSTUM_BBOX) is no longer supported.");
}

GridPtrVecPtr ret(new GridPtrVec);
Expand Down Expand Up @@ -560,9 +560,9 @@ File::readGridMetadata(const Name& name)
OPENVDB_THROW(IoError, filename() << " is not open for reading.");
}

if (fileVersion() < OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION) {
if (fileVersion() < OPENVDB_FILE_VERSION_FLOAT_FRUSTUM_BBOX) {
OPENVDB_THROW(IoError,
"VDB file version < 222 (NODE_MASK_COMPRESSION) is no longer supported.");
"VDB file version < 221 (FLOAT_FRUSTUM_BBOX) is no longer supported.");
}

GridBase::ConstPtr ret;
Expand Down
16 changes: 13 additions & 3 deletions openvdb/openvdb/tree/InternalNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,9 @@ InternalNode<ChildT, Log2Dim>::readTopology(std::istream& is, bool fromHalf)
mChildMask.load(is);
mValueMask.load(is);

const Index numValues = NUM_VALUES;
const bool oldVersion =
(io::getFormatVersion(is) < OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION);
const Index numValues = (oldVersion ? mChildMask.countOff() : NUM_VALUES);
{
// Read in (and uncompress, if necessary) all of this node's values
// into a contiguous array.
Expand All @@ -2435,8 +2437,16 @@ InternalNode<ChildT, Log2Dim>::readTopology(std::istream& is, bool fromHalf)
io::readCompressedValues(is, values, numValues, mValueMask, fromHalf);

// Copy values from the array into this node's table.
for (ValueAllIter iter = this->beginValueAll(); iter; ++iter) {
mNodes[iter.pos()].setValue(values[iter.pos()]);
if (oldVersion) {
Index n = 0;
for (ValueAllIter iter = this->beginValueAll(); iter; ++iter) {
mNodes[iter.pos()].setValue(values[n++]);
}
OPENVDB_ASSERT(n == numValues);
} else {
for (ValueAllIter iter = this->beginValueAll(); iter; ++iter) {
mNodes[iter.pos()].setValue(values[iter.pos()]);
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions openvdb/openvdb/tree/LeafNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,13 @@ LeafNode<T,Log2Dim>::readBuffers(std::istream& is, const CoordBBox& clipBBox, bo
}

int8_t numBuffers = 1;
if (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION) {
// Read in the origin.
is.read(reinterpret_cast<char*>(&mOrigin), sizeof(Coord::ValueType) * 3);

// Read in the number of buffers, which should now always be one.
is.read(reinterpret_cast<char*>(&numBuffers), sizeof(int8_t));
}

CoordBBox nodeBBox = this->getNodeBoundingBox();
if (!clipBBox.hasOverlap(nodeBBox)) {
Expand Down
Loading