Skip to content

Commit d57bca5

Browse files
committed
Make all numbers prime
The prime numbers are modified based on the ACM Transactions on Graphics paper: "Real-time 3D reconstruction at scale using voxel hashing" Signed-off-by: Benedikt Mersch <[email protected]>
1 parent f4cdcd6 commit d57bca5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

nanovdb/nanovdb/NanoVDB.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,8 +1134,10 @@ class Coord
11341134

11351135
/// @brief Return a hash key derived from the existing coordinates.
11361136
/// @details For details on this hash function please see the VDB paper.
1137+
/// The prime numbers are modified based on the ACM Transactions on Graphics paper:
1138+
/// "Real-time 3D reconstruction at scale using voxel hashing"
11371139
template<int Log2N = 3 + 4 + 5>
1138-
__hostdev__ uint32_t hash() const { return ((1 << Log2N) - 1) & (mVec[0] * 73856093 ^ mVec[1] * 19349663 ^ mVec[2] * 83492791); }
1140+
__hostdev__ uint32_t hash() const { return ((1 << Log2N) - 1) & (mVec[0] * 73856093 ^ mVec[1] * 19349669 ^ mVec[2] * 83492791); }
11391141

11401142
/// @brief Return the octant of this Coord
11411143
//__hostdev__ size_t octant() const { return (uint32_t(mVec[0])>>31) | ((uint32_t(mVec[1])>>31)<<1) | ((uint32_t(mVec[2])>>31)<<2); }

openvdb/openvdb/math/Coord.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,15 @@ class Coord
224224

225225
/// @brief Return a hash value for this coordinate
226226
/// @note Log2N is the binary logarithm of the hash table size.
227-
/// @details The hash function is taken from the SIGGRAPH paper:
227+
/// @details The hash function is originally taken from the SIGGRAPH paper:
228228
/// "VDB: High-resolution sparse volumes with dynamic topology"
229+
/// and the prime numbers are modified based on the ACM Transactions on Graphics paper:
230+
/// "Real-time 3D reconstruction at scale using voxel hashing"
229231
template<int Log2N = 20>
230232
size_t hash() const
231233
{
232234
const uint32_t* vec = reinterpret_cast<const uint32_t*>(mVec.data());
233-
return ((1<<Log2N)-1) & (vec[0]*73856093 ^ vec[1]*19349663 ^ vec[2]*83492791);
235+
return ((1<<Log2N)-1) & (vec[0]*73856093 ^ vec[1]*19349669 ^ vec[2]*83492791);
234236
}
235237

236238
private:

0 commit comments

Comments
 (0)