NVIDIA / gvdb-voxels

Sparse volume compute and rendering on NVIDIA GPUs
Other
672 stars 144 forks source link

[FIX] fix the data structure for lasted nanovdb #107

Closed lyd405121 closed 3 years ago

lyd405121 commented 3 years ago
  1. the griddata volsize change
  2. the worldbox change
NBickford-NV commented 3 years ago

Hi lyd405121! Thanks for the pull request! For legal reasons, it looks like we can't accept pull requests outside of NVIDIA (sorry, this is from the legal department). I'll try to integrate these fixes in a separate commit, though.

I'll probably try to fix the mVoxelSize setting as well - the code in this pull request sets the NanoVDB voxel size to {1, 0, 0}, which would represent a voxel that is squished along the y and z axes. I think the correct code is kind of complicated, so this is understandable: this section of the code is based on NanoVDB's OpenToNanoVDB.h, which now uses OpenVDB's AffineMap::voxelsize. Looking at the implementation of AffineMap from lines 634-636 of https://www.openvdb.org/documentation/doxygen/Maps_8h_source.html, I think the correct code is probably something like

nanovdb::Vec3d mapAtLoc = gridData->applyMap(nanovdb::Vec3d(0, 0, 0));
gridData->mVoxelSize = Vec3R(
  (gridData->applyMap(nanovdb::Vec3d(1, 0, 0)) - mapAtLoc).length(),
  (gridData->applyMap(nanovdb::Vec3d(0, 1, 0)) - mapAtLoc).length(),
  (gridData->applyMap(nanovdb::Vec3d(0, 0, 1)) - mapAtLoc).length(),
);

Thanks again for the pull request!

lyd405121 commented 3 years ago

Get it!

Thanks for reviewing it

NBickford-NV commented 3 years ago

Should be fixed now - please see commit https://github.com/NVIDIA/gvdb-voxels/commit/38df47671f7798477c4171f8ea5800f21b7ae658.