11 #define CNANOVDB_DATA_ALIGNMENT 32 12 #define CNANOVDB_ALIGNMENT_PADDING(x, n) (-(x) & ((n)-1)) 14 #define USE_SINGLE_ROOT_KEY 16 #ifdef __OPENCL_VERSION__ 18 #define CNANOVDB_GLOBAL __global 19 #define RESTRICT restrict 22 typedef unsigned long uint64_t;
24 typedef unsigned int uint32_t;
26 typedef short int16_t;
27 typedef unsigned short uint16_t;
28 typedef unsigned char uint8_t;
32 #define CNANOVDB_GLOBAL 33 #define RESTRICT __restrict 55 #define DEFINEMASK_int(LOG2DIM, SIZE) \ 58 uint64_t mWords[SIZE >> 6]; \ 59 } cnanovdb_mask##LOG2DIM; \ 61 static void cnanovdb_mask##LOG2DIM##_clear(CNANOVDB_GLOBAL cnanovdb_mask##LOG2DIM *RESTRICT mask) \ 62 { for (uint32_t i = 0; i < (SIZE >> 6); i++) mask->mWords[i] = 0; } \ 64 static bool cnanovdb_mask##LOG2DIM##_isOn(const CNANOVDB_GLOBAL cnanovdb_mask##LOG2DIM *RESTRICT mask, uint32_t n) \ 65 { return 0 != (mask->mWords[n >> 6] & (((uint64_t)(1)) << (n & 63))); } \ 68 #define DEFINEMASK(LOG2DIM) \ 69 DEFINEMASK_int(LOG2DIM, (1U << (3*LOG2DIM))) 71 #define INSTANTIATE(LOG2DIM) \ 103 if (a->mVec[0] < b->
mVec[0])
105 if (a->mVec[0] > b->
mVec[0])
107 if (a->mVec[1] < b->
mVec[1])
109 if (a->mVec[1] > b->
mVec[1])
111 if (a->mVec[2] < b->
mVec[2])
113 if (a->mVec[2] > b->
mVec[2])
118 #ifdef USE_SINGLE_ROOT_KEY 123 #if defined(AVOID_64BIT_SHIFT) 124 uint2 key = (uint2)( ((uint32_t)ijk->mVec[2]) >> 12, 0) |
125 (uint2)((((uint32_t)ijk->mVec[1]) >> 12) << 21,
126 ((uint32_t)ijk->mVec[1]) >> 23) |
127 (uint2)(0, (((uint32_t)ijk->mVec[0]) >> 12) << 10);
128 return *(uint64_t *)&key;
130 return ((uint64_t) (((uint32_t)ijk->mVec[2]) >> 12)) |
131 (((uint64_t) (((uint32_t)ijk->mVec[1]) >> 12)) << 21) |
132 (((uint64_t) (((uint32_t)ijk->mVec[0]) >> 12)) << 42);
139 key->mVec[0] = ijk->mVec[0] & ~((1u << 12) - 1u);
140 key->mVec[1] = ijk->mVec[1] & ~((1u << 12) - 1u);
141 key->mVec[2] = ijk->mVec[2] & ~((1u << 12) - 1u);
148 float sx = src->
mVec[0];
149 float sy = src->
mVec[1];
150 float sz = src->
mVec[2];
151 dst->
mVec[0] = sx * map->mMatF[0] + sy * map->mMatF[1] + sz * map->mMatF[2] + map->mVecF[0];
152 dst->
mVec[1] = sx * map->mMatF[3] + sy * map->mMatF[4] + sz * map->mMatF[5] + map->mVecF[1];
153 dst->
mVec[2] = sx * map->mMatF[6] + sy * map->mMatF[7] + sz * map->mMatF[8] + map->mVecF[2];
159 float sx = src->
mVec[0] - map->mVecF[0];
160 float sy = src->
mVec[1] - map->mVecF[1];
161 float sz = src->
mVec[2] - map->mVecF[2];
162 dst->
mVec[0] = sx * map->mInvMatF[0] + sy * map->mInvMatF[1] + sz * map->mInvMatF[2];
163 dst->
mVec[1] = sx * map->mInvMatF[3] + sy * map->mInvMatF[4] + sz * map->mInvMatF[5];
164 dst->
mVec[2] = sx * map->mInvMatF[6] + sy * map->mInvMatF[7] + sz * map->mInvMatF[8];
170 float sx = src->
mVec[0];
171 float sy = src->
mVec[1];
172 float sz = src->
mVec[2];
173 dst->
mVec[0] = sx * map->mMatF[0] + sy * map->mMatF[1] + sz * map->mMatF[2];
174 dst->
mVec[1] = sx * map->mMatF[3] + sy * map->mMatF[4] + sz * map->mMatF[5];
175 dst->
mVec[2] = sx * map->mMatF[6] + sy * map->mMatF[7] + sz * map->mMatF[8];
181 float sx = src->
mVec[0];
182 float sy = src->
mVec[1];
183 float sz = src->
mVec[2];
184 dst->
mVec[0] = sx * map->mInvMatF[0] + sy * map->mInvMatF[1] + sz * map->mInvMatF[2];
185 dst->
mVec[1] = sx * map->mInvMatF[3] + sy * map->mInvMatF[4] + sz * map->mInvMatF[5];
186 dst->
mVec[2] = sx * map->mInvMatF[6] + sy * map->mInvMatF[7] + sz * map->mInvMatF[8];
192 float sx = src->
mVec[0];
193 float sy = src->
mVec[1];
194 float sz = src->
mVec[2];
195 dst->
mVec[0] = sx * map->mInvMatF[0] + sy * map->mInvMatF[3] + sz * map->mInvMatF[6];
196 dst->
mVec[1] = sx * map->mInvMatF[1] + sy * map->mInvMatF[4] + sz * map->mInvMatF[7];
197 dst->
mVec[2] = sx * map->mInvMatF[2] + sy * map->mInvMatF[5] + sz * map->mInvMatF[8];
224 double mVoxelSize[3];
277 #define CREATE_TILEENTRY(VALUETYPE, SUFFIX) \ 282 } cnanovdb_tileentry##SUFFIX; \ 295 acc->mNode[childlevel] = node;
296 acc->mKey.mVec[0] = ijk->mVec[0];
297 acc->mKey.mVec[1] = ijk->mVec[1];
298 acc->mKey.mVec[2] = ijk->mVec[2];
301 #define CREATE_LEAF_NODE_int(LEVEL, LOG2DIM, CHILDTOTAL, TOTAL, MASK, VALUETYPE, STATSTYPE, SUFFIX) \ 304 cnanovdb_coord mBBox_min; \ 305 uint8_t mBBoxDif[3]; \ 307 cnanovdb_mask##LOG2DIM mValueMask; \ 308 VALUETYPE mMinimum; \ 309 VALUETYPE mMaximum; \ 310 STATSTYPE mAverage; \ 311 STATSTYPE mStdDevi; \ 312 uint32_t _reserved[ CNANOVDB_ALIGNMENT_PADDING(sizeof(cnanovdb_mask##LOG2DIM)+2*sizeof(VALUETYPE)+2*sizeof(STATSTYPE)+sizeof(cnanovdb_coord)+sizeof(uint8_t[3])+sizeof(uint8_t), CNANOVDB_DATA_ALIGNMENT)/4]; \ 313 VALUETYPE mVoxels[1u << (3*LOG2DIM)]; \ 314 } cnanovdb_node##LEVEL##SUFFIX; \ 317 cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(const cnanovdb_coord *RESTRICT ijk) \ 319 return ( ( ( ijk->mVec[0] & MASK ) >> CHILDTOTAL ) << ( 2 * LOG2DIM ) ) + \ 320 ( ( ( ijk->mVec[1] & MASK ) >> CHILDTOTAL ) << ( LOG2DIM ) ) + \ 321 ( ( ijk->mVec[2] & MASK ) >> CHILDTOTAL ); \ 325 cnanovdb_node##LEVEL##SUFFIX##_getValue(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk) \ 327 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 328 return node->mVoxels[n]; \ 332 cnanovdb_node##LEVEL##SUFFIX##_getValueAndCache(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk, cnanovdb_readaccessor *RESTRICT acc) \ 335 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 336 return node->mVoxels[n]; \ 340 cnanovdb_node##LEVEL##SUFFIX##_isActive(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk) \ 342 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 343 if (cnanovdb_mask##LOG2DIM##_isOn(&node->mValueMask, n)) \ 349 cnanovdb_node##LEVEL##SUFFIX##_isActiveAndCache(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk, cnanovdb_readaccessor *RESTRICT acc) \ 352 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 353 if (cnanovdb_mask##LOG2DIM##_isOn(&node->mValueMask, n)) \ 358 static const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX * \ 359 cnanovdb_tree_getNode##LEVEL##SUFFIX(const CNANOVDB_GLOBAL cnanovdb_treedata *RESTRICT tree, uint64_t i) \ 361 const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *basenode = (const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *)((CNANOVDB_GLOBAL uint8_t *)(tree) + tree->mNodeOffset[LEVEL]); \ 362 return basenode + i; \ 367 #define CREATE_LEAF_NODE(LEVEL, LOG2DIM, TOTAL, VALUETYPE, STATSTYPE, SUFFIX) \ 368 CREATE_LEAF_NODE_int(LEVEL, LOG2DIM, (TOTAL-LOG2DIM), TOTAL, ((1u << TOTAL) - 1u), VALUETYPE, STATSTYPE, SUFFIX) 370 #define CREATE_INTERNAL_NODE_int(CHILDLEVEL, LEVEL, LOG2DIM, CHILDTOTAL, TOTAL, MASK, VALUETYPE, STATSTYPE, SUFFIX) \ 373 cnanovdb_coord mBBox_min, mBBox_max; \ 376 cnanovdb_mask##LOG2DIM mValueMask, mChildMask; \ 377 VALUETYPE mMinimum, mMaximum; \ 378 STATSTYPE mAverage, mStdDevi; \ 379 uint8_t _reserved[CNANOVDB_ALIGNMENT_PADDING(sizeof(cnanovdb_mask##LOG2DIM)+sizeof(VALUETYPE)*2+sizeof(STATSTYPE)*2+sizeof(cnanovdb_coord)*2+sizeof(int32_t)+sizeof(uint32_t), CNANOVDB_DATA_ALIGNMENT)]; \ 380 cnanovdb_tileentry##SUFFIX mTable[1u << (3*LOG2DIM)]; \ 381 } cnanovdb_node##LEVEL##SUFFIX; \ 384 cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(const cnanovdb_coord *RESTRICT ijk) \ 386 return ( ( ( ijk->mVec[0] & MASK ) >> CHILDTOTAL ) << ( 2 * LOG2DIM ) ) + \ 387 ( ( ( ijk->mVec[1] & MASK ) >> CHILDTOTAL ) << ( LOG2DIM ) ) + \ 388 ( ( ijk->mVec[2] & MASK ) >> CHILDTOTAL ); \ 391 static const CNANOVDB_GLOBAL cnanovdb_node##CHILDLEVEL##SUFFIX * \ 392 cnanovdb_node##LEVEL##SUFFIX##_getChild(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, uint32_t n) \ 394 const CNANOVDB_GLOBAL cnanovdb_node##CHILDLEVEL##SUFFIX *childnode = (const CNANOVDB_GLOBAL cnanovdb_node##CHILDLEVEL##SUFFIX *)( ((CNANOVDB_GLOBAL uint8_t *)node) + node->mTable[n].child); \ 399 cnanovdb_node##LEVEL##SUFFIX##_getValue(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk) \ 401 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 402 if (cnanovdb_mask##LOG2DIM##_isOn(&node->mChildMask, n)) \ 404 const CNANOVDB_GLOBAL cnanovdb_node##CHILDLEVEL##SUFFIX *child = cnanovdb_node##LEVEL##SUFFIX##_getChild(node, n); \ 405 return cnanovdb_node##CHILDLEVEL##SUFFIX##_getValue(child, ijk); \ 407 return node->mTable[n].value; \ 411 cnanovdb_node##LEVEL##SUFFIX##_getValueAndCache(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk, cnanovdb_readaccessor *RESTRICT acc) \ 413 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 414 if (cnanovdb_mask##LOG2DIM##_isOn(&node->mChildMask, n)) \ 416 const CNANOVDB_GLOBAL cnanovdb_node##CHILDLEVEL##SUFFIX *child = cnanovdb_node##LEVEL##SUFFIX##_getChild(node, n); \ 417 cnanovdb_readaccessor_insert(acc, CHILDLEVEL, child, ijk); \ 418 return cnanovdb_node##CHILDLEVEL##SUFFIX##_getValueAndCache(child, ijk, acc); \ 420 return node->mTable[n].value; \ 424 cnanovdb_node##LEVEL##SUFFIX##_isActive(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk) \ 426 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 427 if (cnanovdb_mask##LOG2DIM##_isOn(&node->mChildMask, n)) \ 429 const CNANOVDB_GLOBAL cnanovdb_node##CHILDLEVEL##SUFFIX *child = cnanovdb_node##LEVEL##SUFFIX##_getChild(node, n); \ 430 return cnanovdb_node##CHILDLEVEL##SUFFIX##_isActive(child, ijk); \ 432 return cnanovdb_mask##LOG2DIM##_isOn(&node->mValueMask, n) ? true : false; \ 436 cnanovdb_node##LEVEL##SUFFIX##_isActiveAndCache(const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *RESTRICT node, const cnanovdb_coord *RESTRICT ijk, cnanovdb_readaccessor *RESTRICT acc) \ 438 uint32_t n = cnanovdb_node##LEVEL##SUFFIX##_CoordToOffset(ijk); \ 439 if (cnanovdb_mask##LOG2DIM##_isOn(&node->mChildMask, n)) \ 441 const CNANOVDB_GLOBAL cnanovdb_node##CHILDLEVEL##SUFFIX *child = cnanovdb_node##LEVEL##SUFFIX##_getChild(node, n); \ 442 cnanovdb_readaccessor_insert(acc, CHILDLEVEL, child, ijk); \ 443 return cnanovdb_node##CHILDLEVEL##SUFFIX##_isActiveAndCache(child, ijk, acc); \ 445 return cnanovdb_mask##LOG2DIM##_isOn(&node->mValueMask, n) ? true : false; \ 448 static const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX * \ 449 cnanovdb_tree_getNode##LEVEL##SUFFIX(const CNANOVDB_GLOBAL cnanovdb_treedata *RESTRICT tree, uint64_t i) \ 451 const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *basenode = (const CNANOVDB_GLOBAL cnanovdb_node##LEVEL##SUFFIX *)((CNANOVDB_GLOBAL uint8_t *)(tree) + tree->mNodeOffset[LEVEL]); \ 452 return basenode + i; \ 457 #define CREATE_INTERNAL_NODE(CHILDLEVEL, LEVEL, LOG2DIM, TOTAL, VALUETYPE, STATSTYPE, SUFFIX) \ 458 CREATE_INTERNAL_NODE_int(CHILDLEVEL, LEVEL, LOG2DIM, (TOTAL-LOG2DIM), TOTAL, ((1u << TOTAL) - 1u), VALUETYPE, STATSTYPE, SUFFIX) 461 #ifdef USE_SINGLE_ROOT_KEY 462 #define DEFINE_KEY(KEY) \ 464 #define KEYSIZE sizeof(uint64_t) 466 #define KEYSEARCH(SUFFIX) \ 468 key = cnanovdb_coord_to_key(ijk); \ 470 for (int i = low; i < high; i++) \ 472 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *tile = tiles + i; \ 473 if (tile->key == key) \ 478 #define DEFINE_KEY(KEY) \ 480 #define KEYSIZE sizeof(cnanovdb_coord) 481 #define KEYSEARCH(SUFFIX) \ 482 cnanovdb_coord key; \ 483 cnanovdb_coord_to_key(&key, ijk); \ 485 while (low != high) \ 487 int32_t mid = low + (( high - low ) >> 1 ); \ 488 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *tile = tiles + mid; \ 490 int keycmp = cnanovdb_coord_compare(&tile->key, &key); \ 505 #define CREATE_ROOTDATA(VALUETYPE, STATSTYPE, SUFFIX) \ 512 uint8_t _reserved[CNANOVDB_ALIGNMENT_PADDING(sizeof(KEYSIZE)+sizeof(VALUETYPE)+sizeof(int64_t)+sizeof(uint32_t), CNANOVDB_DATA_ALIGNMENT)]; \ 513 } cnanovdb_rootdata_tile##SUFFIX; \ 517 cnanovdb_coord mBBox_min, mBBox_max; \ 518 uint32_t mTableSize; \ 519 VALUETYPE mBackground; \ 520 VALUETYPE mMinimum, mMaximum; \ 521 STATSTYPE mAverage, mStdDevi; \ 522 uint32_t _reserved[CNANOVDB_ALIGNMENT_PADDING(sizeof(cnanovdb_coord)*2+sizeof(uint32_t)+sizeof(VALUETYPE)*3+sizeof(STATSTYPE)*2, CNANOVDB_DATA_ALIGNMENT)/4]; \ 523 } cnanovdb_rootdata##SUFFIX; \ 525 static const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX * \ 526 cnanovdb_treedata_root##SUFFIX(const CNANOVDB_GLOBAL cnanovdb_treedata *RESTRICT treedata) \ 528 return (const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *) ((const CNANOVDB_GLOBAL uint8_t *)(treedata) + treedata->mNodeOffset[ROOT_LEVEL]); \ 531 static const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX * \ 532 cnanovdb_rootdata##SUFFIX##_getTile(const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *RESTRICT rootdata, uint32_t n) \ 534 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *basetile = (const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *) (rootdata + 1); \ 535 return basetile + n; \ 538 static const CNANOVDB_GLOBAL cnanovdb_node2##SUFFIX * \ 539 cnanovdb_rootdata##SUFFIX##_getChild(const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *RESTRICT rootdata, const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *RESTRICT tile) \ 541 CNANOVDB_GLOBAL cnanovdb_node2##SUFFIX *basenode = (CNANOVDB_GLOBAL cnanovdb_node2##SUFFIX *) (((CNANOVDB_GLOBAL uint8_t *) rootdata) + tile->child); \ 545 static const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX * \ 546 cnanovdb_rootdata##SUFFIX##_findTile(const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *RESTRICT rootdata, const cnanovdb_coord *RESTRICT ijk) \ 548 int32_t low = 0, high = rootdata->mTableSize; \ 549 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *tiles = cnanovdb_rootdata##SUFFIX##_getTile(rootdata, 0); \ 556 cnanovdb_rootdata##SUFFIX##_getValue(const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *RESTRICT rootdata, const cnanovdb_coord *RESTRICT ijk) \ 558 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *tile = cnanovdb_rootdata##SUFFIX##_findTile(rootdata, ijk); \ 560 return rootdata->mBackground; \ 561 if (tile->child == 0) \ 562 return tile->value; \ 563 return cnanovdb_node2##SUFFIX##_getValue( cnanovdb_rootdata##SUFFIX##_getChild(rootdata, tile), ijk ); \ 567 cnanovdb_rootdata##SUFFIX##_getValueAndCache(const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *RESTRICT rootdata, const cnanovdb_coord *RESTRICT ijk, cnanovdb_readaccessor *RESTRICT acc) \ 569 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *tile = cnanovdb_rootdata##SUFFIX##_findTile(rootdata, ijk); \ 571 return rootdata->mBackground; \ 572 if (tile->child == 0) \ 573 return tile->value; \ 574 const CNANOVDB_GLOBAL cnanovdb_node2##SUFFIX *child = cnanovdb_rootdata##SUFFIX##_getChild(rootdata, tile); \ 575 cnanovdb_readaccessor_insert(acc, 2, child, ijk); \ 576 return cnanovdb_node2##SUFFIX##_getValueAndCache( child, ijk, acc ); \ 580 cnanovdb_rootdata##SUFFIX##_isActive(const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *RESTRICT rootdata, const cnanovdb_coord *RESTRICT ijk) \ 582 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *tile = cnanovdb_rootdata##SUFFIX##_findTile(rootdata, ijk); \ 585 if (tile->child == 0) \ 586 return tile->state; \ 587 return cnanovdb_node2##SUFFIX##_isActive( cnanovdb_rootdata##SUFFIX##_getChild(rootdata, tile), ijk ); \ 591 cnanovdb_rootdata##SUFFIX##_isActiveAndCache(const CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *RESTRICT rootdata, const cnanovdb_coord *RESTRICT ijk, cnanovdb_readaccessor *RESTRICT acc) \ 593 const CNANOVDB_GLOBAL cnanovdb_rootdata_tile##SUFFIX *tile = cnanovdb_rootdata##SUFFIX##_findTile(rootdata, ijk); \ 596 if (tile->child == 0) \ 597 return tile->state; \ 598 const CNANOVDB_GLOBAL cnanovdb_node2##SUFFIX *child = cnanovdb_rootdata##SUFFIX##_getChild(rootdata, tile); \ 599 cnanovdb_readaccessor_insert(acc, 2, child, ijk); \ 600 return cnanovdb_node2##SUFFIX##_isActiveAndCache( child, ijk, acc ); \ 609 acc->mNode[0] = acc->mNode[1] = acc->mNode[2] = 0;
610 acc->mNode[3] = rootdata;
613 #define DEFINE_ISCACHED(LEVEL, MASK) \ 615 cnanovdb_readaccessor_isCached##LEVEL(cnanovdb_readaccessor *RESTRICT acc, int32_t dirty) \ 617 if (!acc->mNode[LEVEL]) \ 621 acc->mNode[LEVEL] = 0; \ 635 return (ijk->mVec[0] ^ acc->mKey.mVec[0]) |
636 (ijk->mVec[1] ^ acc->mKey.mVec[1]) |
637 (ijk->mVec[2] ^ acc->mKey.mVec[2]);
640 #define CREATE_ACCESSOR(VALUETYPE, SUFFIX) \ 642 cnanovdb_readaccessor_getValue##SUFFIX(cnanovdb_readaccessor *RESTRICT acc, const cnanovdb_coord *RESTRICT ijk) \ 644 int32_t dirty = cnanovdb_readaccessor_computeDirty(acc, ijk); \ 646 if (cnanovdb_readaccessor_isCached0(acc, dirty)) \ 647 return cnanovdb_node0##SUFFIX##_getValue( ((CNANOVDB_GLOBAL cnanovdb_node0##SUFFIX *) acc->mNode[0]), ijk); \ 648 if (cnanovdb_readaccessor_isCached1(acc, dirty)) \ 649 return cnanovdb_node1##SUFFIX##_getValueAndCache( ((CNANOVDB_GLOBAL cnanovdb_node1##SUFFIX *) acc->mNode[1]), ijk, acc); \ 650 if (cnanovdb_readaccessor_isCached2(acc, dirty)) \ 651 return cnanovdb_node2##SUFFIX##_getValueAndCache( ((CNANOVDB_GLOBAL cnanovdb_node2##SUFFIX *) acc->mNode[2]), ijk, acc); \ 653 return cnanovdb_rootdata##SUFFIX##_getValueAndCache( ((CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *)acc->mNode[3]), ijk, acc); \ 657 cnanovdb_readaccessor_isActive##SUFFIX(cnanovdb_readaccessor *RESTRICT acc, const cnanovdb_coord *RESTRICT ijk) \ 659 int32_t dirty = cnanovdb_readaccessor_computeDirty(acc, ijk); \ 661 if (cnanovdb_readaccessor_isCached0(acc, dirty)) \ 662 return cnanovdb_node0##SUFFIX##_isActive( ((CNANOVDB_GLOBAL cnanovdb_node0##SUFFIX *) acc->mNode[0]), ijk); \ 663 if (cnanovdb_readaccessor_isCached1(acc, dirty)) \ 664 return cnanovdb_node1##SUFFIX##_isActiveAndCache( ((CNANOVDB_GLOBAL cnanovdb_node1##SUFFIX *) acc->mNode[1]), ijk, acc); \ 665 if (cnanovdb_readaccessor_isCached2(acc, dirty)) \ 666 return cnanovdb_node2##SUFFIX##_isActiveAndCache( ((CNANOVDB_GLOBAL cnanovdb_node2##SUFFIX *) acc->mNode[2]), ijk, acc); \ 668 return cnanovdb_rootdata##SUFFIX##_isActiveAndCache( ((CNANOVDB_GLOBAL cnanovdb_rootdata##SUFFIX *)acc->mNode[3]), ijk, acc); \ 673 #define CREATE_GRIDTYPE(VALUETYPE, STATSTYPE, SUFFIX) \ 674 CREATE_TILEENTRY(VALUETYPE, SUFFIX) \ 675 CREATE_LEAF_NODE(0, 3, 3, VALUETYPE, STATSTYPE, SUFFIX) \ 676 CREATE_INTERNAL_NODE(0, 1, 4, 7, VALUETYPE, STATSTYPE, SUFFIX) \ 677 CREATE_INTERNAL_NODE(1, 2, 5, 12, VALUETYPE, STATSTYPE, SUFFIX) \ 678 CREATE_ROOTDATA(VALUETYPE, STATSTYPE, SUFFIX) \ 679 CREATE_ACCESSOR(VALUETYPE, SUFFIX) \ 690 if (grid->mMagic != 0x304244566f6e614eUL && grid->mMagic != 0x314244566f6e614eUL)
Definition: CNanoVDB.h:42
Definition: CNanoVDB.h:46
#define INSTANTIATE(LOG2DIM)
Definition: CNanoVDB.h:71
Definition: CNanoVDB.h:43
static void cnanovdb_map_applyInverseJacobi(cnanovdb_Vec3F *dst, const cnanovdb_map *__restrict map, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:179
static int cnanovdb_griddata_validF3(const cnanovdb_griddata *__restrict grid)
Definition: CNanoVDB.h:706
uint64_t mGridSize
Definition: CNanoVDB.h:220
static void cnanovdb_griddata_worldToIndexDir(cnanovdb_Vec3F *dst, const cnanovdb_griddata *__restrict grid, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:245
static int cnanovdb_coord_compare(const cnanovdb_coord *a, const cnanovdb_coord *b)
Definition: CNanoVDB.h:101
void cnanovdb_readaccessor_init(cnanovdb_readaccessor *__restrict acc, const void *__restrict rootdata)
Definition: CNanoVDB.h:606
uint32_t mGridIndex
Definition: CNanoVDB.h:218
Definition: CNanoVDB.h:78
Definition: CNanoVDB.h:212
static void cnanovdb_map_applyJacobi(cnanovdb_Vec3F *dst, const cnanovdb_map *__restrict map, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:168
uint32_t mGridType
Definition: CNanoVDB.h:226
Definition: CNanoVDB.h:40
cnanovdb_GridType
Definition: CNanoVDB.h:38
Definition: CNanoVDB.h:41
static void cnanovdb_griddata_indexToWorld(cnanovdb_Vec3F *dst, const cnanovdb_griddata *__restrict grid, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:239
Definition: CNanoVDB.h:95
Definition: CNanoVDB.h:262
int32_t cnanovdb_readaccessor_computeDirty(const cnanovdb_readaccessor *__restrict acc, const cnanovdb_coord *__restrict ijk)
Definition: CNanoVDB.h:633
#define CREATE_GRIDTYPE(VALUETYPE, STATSTYPE, SUFFIX)
Definition: CNanoVDB.h:673
Definition: CNanoVDB.h:48
float mVec[3]
Definition: CNanoVDB.h:92
uint64_t mVoxelCount
Definition: CNanoVDB.h:267
static void cnanovdb_griddata_applyIJT(cnanovdb_Vec3F *dst, const cnanovdb_griddata *__restrict grid, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:257
#define CNANOVDB_GLOBAL
Definition: CNanoVDB.h:32
uint32_t mGridCount
Definition: CNanoVDB.h:219
static void cnanovdb_map_applyIJT(cnanovdb_Vec3F *dst, const cnanovdb_map *__restrict map, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:190
#define RESTRICT
Definition: CNanoVDB.h:33
#define DEFINE_ISCACHED(LEVEL, MASK)
Definition: CNanoVDB.h:613
Definition: CNanoVDB.h:50
uint32_t mGridClass
Definition: CNanoVDB.h:225
#define ROOT_LEVEL
Definition: CNanoVDB.h:53
uint64_t mBlindMetadataOffset
Definition: CNanoVDB.h:227
Definition: CNanoVDB.h:285
static void cnanovdb_griddata_worldToIndex(cnanovdb_Vec3F *dst, const cnanovdb_griddata *__restrict grid, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:233
static int cnanovdb_griddata_valid(const cnanovdb_griddata *__restrict grid)
Definition: CNanoVDB.h:686
#define CNANOVDB_ALIGNMENT_PADDING(x, n)
Definition: CNanoVDB.h:12
cnanovdb_coord mKey
Definition: CNanoVDB.h:287
#define CNANOVDB_DATA_ALIGNMENT
Definition: CNanoVDB.h:11
uint32_t mVersion
Definition: CNanoVDB.h:216
uint64_t mMagic
Definition: CNanoVDB.h:214
Definition: CNanoVDB.h:90
int32_t mVec[3]
Definition: CNanoVDB.h:97
static uint64_t cnanovdb_coord_to_key(const cnanovdb_coord *__restrict ijk)
Definition: CNanoVDB.h:120
float mTaperF
Definition: CNanoVDB.h:83
cnanovdb_map mMap
Definition: CNanoVDB.h:222
static void cnanovdb_map_apply(cnanovdb_Vec3F *dst, const cnanovdb_map *__restrict map, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:146
Definition: CNanoVDB.h:47
Definition: CNanoVDB.h:44
static const cnanovdb_treedata * cnanovdb_griddata_tree(const cnanovdb_griddata *__restrict griddata)
Definition: CNanoVDB.h:272
int32_t mBlindMetadataCount
Definition: CNanoVDB.h:228
static void cnanovdb_griddata_indexToWorldDir(cnanovdb_Vec3F *dst, const cnanovdb_griddata *__restrict grid, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:251
uint32_t mFlags
Definition: CNanoVDB.h:217
Definition: CNanoVDB.h:49
static void cnanovdb_map_applyInverse(cnanovdb_Vec3F *dst, const cnanovdb_map *__restrict map, const cnanovdb_Vec3F *src)
Definition: CNanoVDB.h:157
double mTaperD
Definition: CNanoVDB.h:87
uint64_t mChecksum
Definition: CNanoVDB.h:215
static void cnanovdb_readaccessor_insert(cnanovdb_readaccessor *__restrict acc, int childlevel, const void *__restrict node, const cnanovdb_coord *__restrict ijk)
Definition: CNanoVDB.h:293
Definition: CNanoVDB.h:45
static int cnanovdb_griddata_validF(const cnanovdb_griddata *__restrict grid)
Definition: CNanoVDB.h:696