20#define NANOVDB_USE_SINGLE_ROOT_KEY
21#define NANOVDB_DATA_ALIGNMENT 32
27template<
typename DstT,
typename SrcT>
50template<u
int32_t LOG2DIM>
struct Mask {
63template<
typename TreeT>
struct alignas(NANOVDB_DATA_ALIGNMENT)
Grid {
72 char mGridName[MaxNameSize];
85 return *
reinterpret_cast<const ccl_global TreeT *
>(
this + 1);
91template<
typename RootT>
struct alignas(NANOVDB_DATA_ALIGNMENT)
Tree {
102 return *
reinterpret_cast<const ccl_global RootT *
>(
103 mNodeOffset[3] ? PtrAdd<uint8_t>(
this, mNodeOffset[3]) :
nullptr);
109template<
typename ChildT>
struct alignas(NANOVDB_DATA_ALIGNMENT)
RootNode {
113#ifdef NANOVDB_USE_SINGLE_ROOT_KEY
125 return ijk & ~ChildT
::MASK;
137 struct alignas(NANOVDB_DATA_ALIGNMENT)
Tile {
146 const auto key = CoordToKey(ijk);
160 return PtrAdd<ChildT>(
this,
tile->child);
168template<
typename ChildT, const u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
188 alignas(32)
Tile mTable[1u << (3 * Log2Dim)];
192 return PtrAdd<ChildT>(
this, mTable[n].child);
204 return (((ijk.
x &
MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) |
205 (((ijk.
y &
MASK) >> ChildT::TOTAL) << (LOG2DIM)) | ((ijk.
z &
MASK) >> ChildT::TOTAL);
211template<
typename ValueT, const u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafData {
234template<u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafFnBase {
249template<u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp16, LOG2DIM> {
266template<u
int32_t LOG2DIM>
struct alignas(NANOVDB_DATA_ALIGNMENT)
LeafData<
FpN, LOG2DIM> {
274 const int b = base.
mFlags >> 5;
276 code >>= (i & ((32 >>
b) - 1)) <<
b;
277 code &= (1 << (1 <<
b)) - 1;
284template<
typename BuildT, const u
int32_t Log2Dim = 3>
301 return ((ijk.
x &
MASK) << (2 * LOG2DIM)) | ((ijk.
y &
MASK) << LOG2DIM) | (ijk.
z &
MASK);
306 return data.getValue(offset);
311 return getValue(CoordToOffset(ijk));
340 if (
tile ==
nullptr) {
341 return mRoot->mBackground;
343 if (
tile->child == 0) {
348 const uint32_t upper_n = upper->CoordToOffset(ijk);
349 if (upper->mChildMask.isOff(upper_n)) {
350 return upper->mTable[upper_n].value;
353 const ccl_global auto *lower = upper->getChild(upper_n);
354 const uint32_t lower_n = lower->CoordToOffset(ijk);
355 if (lower->mChildMask.isOff(lower_n)) {
356 return lower->mTable[lower_n].value;
372 mutable const ccl_global void *mNode[3] = {
nullptr,
nullptr,
nullptr};
381 return (ijk.
x &
int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL].
x &&
382 (ijk.
y &
int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL].
y &&
383 (ijk.
z &
int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL].
z;
387 const Coord ijk)
const
390 if (
tile->child != 0) {
393 return getValueAndCache(*child, ijk);
397 return node.mBackground;
401 const Coord ijk)
const
403 return node.getValue(ijk);
406 template<
typename NodeT>
408 const Coord ijk)
const
411 if (
node.mChildMask.isOff(n)) {
412 return node.mTable[n].value;
416 return getValueAndCache(*child, ijk);
421 if (isCached<LeafT>(ijk)) {
424 if (isCached<LowerT>(ijk)) {
427 if (isCached<UpperT>(ijk)) {
430 return getValueAndCache(*mRoot, ijk);
433 template<
typename NodeT>
436 mKeys[NodeT::LEVEL] = ijk & ~NodeT
::MASK;
437 mNode[NodeT::LEVEL] =
node;
void BLI_kdtree_nd_ insert(KDTree *tree, int index, const float co[KD_DIMS]) ATTR_NONNULL(1
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
typename RootT::ValueType ValueType
ccl_device_inline_method ValueType getValueAndCache(const ccl_global RootT &node, const Coord ijk) const
ccl_device_inline_method ValueType getValueAndCache(const ccl_global LeafT &node, const Coord ijk) const
ccl_device_inline_method CachedReadAccessor(const ccl_global RootT &root)
ccl_device_inline_method bool isCached(const Coord ijk) const
ccl_device_inline_method void insert(const Coord ijk, const ccl_global NodeT *node) const
ccl_device_inline_method ValueType getValue(const Coord ijk) const
ccl_device_inline_method ValueType getValueAndCache(const ccl_global NodeT &node, const Coord ijk) const
typename RootT::ValueType ValueType
ccl_device_inline_method ValueType getValue(const Coord ijk) const
ccl_device_inline_method ReadAccessor(const ccl_global RootT &root)
#define CCL_NAMESPACE_END
#define ccl_static_constexpr
#define ccl_device_inline_method
const ccl_global KernelWorkTile * tile
const ccl_device ccl_global DstT * PtrAdd(const ccl_global SrcT *p, int64_t offset)
unsigned __int64 uint64_t
ccl_device_inline_method Coord operator&(int32_t n) const
ccl_device_inline_method Coord(int32_t x, int32_t y, int32_t z)
ccl_device_inline_method Coord(int32_t n)
const ccl_device_inline_method ccl_global TreeT & tree() const ccl_global
typename TreeT::BuildType BuildType
const ccl_device_inline_method ccl_global ChildT * getChild(const uint32_t n) const ccl_global
Mask< Log2Dim > mValueMask
typename ChildT::ValueType ValueType
Mask< Log2Dim > mChildMask
static ccl_device_inline_method uint32_t CoordToOffset(const Coord ijk)
typename ChildT::BuildType BuildType
ccl_device_inline_method float getValue(const uint32_t i) const ccl_global
LeafFnBase< LOG2DIM > base
ccl_device_inline_method float getValue(const uint32_t i) const ccl_global
LeafFnBase< LOG2DIM > base
ccl_device_inline_method ValueType getValue(const uint32_t i) const ccl_global
Mask< LOG2DIM > mValueMask
Mask< LOG2DIM > mValueMask
typename DataType::BuildType BuildType
typename DataType::ValueType ValueType
static ccl_device_inline_method uint32_t CoordToOffset(const Coord ijk)
ccl_device_inline_method ValueType getValue(const Coord ijk) const ccl_global
ccl_device_inline_method ValueType getValue(const uint32_t offset) const ccl_global
ccl_device_inline_method bool isOff(const uint32_t n) const ccl_global
ccl_static_constexpr uint32_t SIZE
ccl_static_constexpr uint32_t WORD_COUNT
uint64_t mWords[WORD_COUNT]
static ccl_device_inline_method uint64_t CoordToKey(const Coord ijk)
typename ChildT::ValueType ValueType
typename ChildT::BuildType BuildType
const ccl_device_inline_method ccl_global ChildT * getChild(const ccl_global Tile *tile) const ccl_global
const ccl_device_inline_method ccl_global Tile * probeTile(const Coord ijk) const ccl_global
const ccl_device_inline_method ccl_global RootT & root() const ccl_global
typename RootT::ValueType ValueType
typename RootT::BuildType BuildType