vdb-rs
vdb-rs copied to clipboard
compressed_count = 0 causes panic
Hi,
I tried to run the bevy example in the library. I'm using macOS 13.3 and ran the following command:
cargo run --example bevy ~/Downloads/TornadoLoopingVDB/TornadoLooping/TornadoVDB/tornado_0000.vdb
This produces the following error:
thread 'Compute Task Pool (5)' panicked at /Users/yorickdejong/vdb-rs/src/reader.rs:240:17:
assertion `left == right` failed
left: 0
right: 30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy::setup`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
It seems that the compressed count is 0, instead of 30:
fn read_compressed_data<T: Pod>(
reader: &mut R,
_archive: &ArchiveHeader,
gd: &GridDescriptor,
count: usize,
) -> Result<Vec<T>, ParseError> {
Ok(if gd.compression.contains(Compression::BLOSC) {
let num_compressed_bytes = reader.read_i64::<LittleEndian>()?;
let compressed_count = num_compressed_bytes / std::mem::size_of::<T>() as i64;
trace!("Reading blosc data, {} bytes", num_compressed_bytes);
if num_compressed_bytes <= 0 {
let mut data = vec![T::zeroed(); (-compressed_count) as usize];
reader.read_exact(cast_slice_mut(&mut data))?;
assert_eq!(-compressed_count as usize, count);
data
The vdb file can be downloaded from this link (it's the tornado): https://jangafx.com/software/embergen/download/free-vdb-animations/
This is supposed to mimic the code in https://github.com/AcademySoftwareFoundation/openvdb/blob/master/openvdb%2Fopenvdb%2Fio%2FCompression.cc pretty much exactly, if it doesn't then that's a bug.
Feel free to contribute a patch by opening a pull request!
Hi @Jasper-Bekkers,
Thanks, will open a pull request when I'm done with the patch
Best, Yorick