OpenVDB: nanovdb/PNanoVDB.h Source File

OpenVDB 12.1.1

Loading...
Searching...
No Matches
PNanoVDB.h
Go to the documentation of this file.
1
2// Copyright Contributors to the OpenVDB Project
3// SPDX-License-Identifier: Apache-2.0
4
5/*!
6 \file nanovdb/PNanoVDB.h
7
8 \author Andrew Reidmeyer
9
10 \brief This file is a portable (e.g. pointer-less) C99/GLSL/HLSL port
11 of NanoVDB.h, which is compatible with most graphics APIs.
12*/
13
14#ifndef NANOVDB_PNANOVDB_H_HAS_BEEN_INCLUDED
15#define NANOVDB_PNANOVDB_H_HAS_BEEN_INCLUDED
16
17// ------------------------------------------------ Configuration -----------------------------------------------------------
18
19// platforms
20//#define PNANOVDB_C
21//#define PNANOVDB_HLSL
22//#define PNANOVDB_GLSL
23
24// addressing mode
25// PNANOVDB_ADDRESS_32
26// PNANOVDB_ADDRESS_64
27#if defined(PNANOVDB_C)
28#ifndef PNANOVDB_ADDRESS_32
29#define PNANOVDB_ADDRESS_64
30#endif
31#elif defined(PNANOVDB_HLSL)
32#ifndef PNANOVDB_ADDRESS_64
33#define PNANOVDB_ADDRESS_32
34#endif
35#elif defined(PNANOVDB_GLSL)
36#ifndef PNANOVDB_ADDRESS_64
37#define PNANOVDB_ADDRESS_32
38#endif
39#endif
40
41// bounds checking
42//#define PNANOVDB_BUF_BOUNDS_CHECK
43
44// enable HDDA by default on HLSL/GLSL, make explicit on C
45#if defined(PNANOVDB_C)
46//#define PNANOVDB_HDDA
47#ifdef PNANOVDB_HDDA
48#ifndef PNANOVDB_CMATH
49#define PNANOVDB_CMATH
50#endif
51#endif
52#elif defined(PNANOVDB_HLSL)
53#define PNANOVDB_HDDA
54#elif defined(PNANOVDB_GLSL)
55#define PNANOVDB_HDDA
56#endif
57
58#ifdef PNANOVDB_CMATH
59#ifndef __CUDACC_RTC__
60#include <math.h>
61#endif
62#endif
63
64// ------------------------------------------------ Buffer -----------------------------------------------------------
65
66#if defined(PNANOVDB_BUF_CUSTOM)
67// NOP
68#elif defined(PNANOVDB_C)
69#define PNANOVDB_BUF_C
70#elif defined(PNANOVDB_HLSL)
71#define PNANOVDB_BUF_HLSL
72#elif defined(PNANOVDB_GLSL)
73#define PNANOVDB_BUF_GLSL
74#endif
75
76#if defined(PNANOVDB_BUF_C)
77#ifndef __CUDACC_RTC__
78#include <stdint.h>
79#endif
80#if defined(__CUDACC__)
81#define PNANOVDB_BUF_FORCE_INLINE static __host__ __device__ __forceinline__
82#elif defined(_WIN32)
83#define PNANOVDB_BUF_FORCE_INLINE static inline __forceinline
84#else
85#define PNANOVDB_BUF_FORCE_INLINE static inline __attribute__((always_inline))
86#endif
87typedef struct pnanovdb_buf_t
88{
89 uint32_t* data;
90#ifdef PNANOVDB_BUF_BOUNDS_CHECK
91 uint64_t size_in_words;
92#endif
93}pnanovdb_buf_t;
94PNANOVDB_BUF_FORCE_INLINE pnanovdb_buf_t pnanovdb_make_buf(uint32_t* data, uint64_t size_in_words)
95{
96 pnanovdb_buf_t ret;
97 ret.data = data;
98#ifdef PNANOVDB_BUF_BOUNDS_CHECK
99 ret.size_in_words = size_in_words;
100#endif
101 return ret;
102}
103#if defined(PNANOVDB_ADDRESS_32)
104PNANOVDB_BUF_FORCE_INLINE uint32_t pnanovdb_buf_read_uint32(pnanovdb_buf_t buf, uint32_t byte_offset)
105{
106 uint32_t wordaddress = (byte_offset >> 2u);
107#ifdef PNANOVDB_BUF_BOUNDS_CHECK
108 return wordaddress < buf.size_in_words ? buf.data[wordaddress] : 0u;
109#else
110 return buf.data[wordaddress];
111#endif
112}
113PNANOVDB_BUF_FORCE_INLINE uint64_t pnanovdb_buf_read_uint64(pnanovdb_buf_t buf, uint32_t byte_offset)
114{
115 uint64_t* data64 = (uint64_t*)buf.data;
116 uint32_t wordaddress64 = (byte_offset >> 3u);
117#ifdef PNANOVDB_BUF_BOUNDS_CHECK
118 uint64_t size_in_words64 = buf.size_in_words >> 1u;
119 return wordaddress64 < size_in_words64 ? data64[wordaddress64] : 0llu;
120#else
121 return data64[wordaddress64];
122#endif
123}
124PNANOVDB_BUF_FORCE_INLINE void pnanovdb_buf_write_uint32(pnanovdb_buf_t buf, uint32_t byte_offset, uint32_t value)
125{
126 uint32_t wordaddress = (byte_offset >> 2u);
127#ifdef PNANOVDB_BUF_BOUNDS_CHECK
128 if (wordaddress < buf.size_in_words)
129 {
130 buf.data[wordaddress] = value;
131}
132#else
133 buf.data[wordaddress] = value;
134#endif
135}
136PNANOVDB_BUF_FORCE_INLINE void pnanovdb_buf_write_uint64(pnanovdb_buf_t buf, uint32_t byte_offset, uint64_t value)
137{
138 uint64_t* data64 = (uint64_t*)buf.data;
139 uint32_t wordaddress64 = (byte_offset >> 3u);
140#ifdef PNANOVDB_BUF_BOUNDS_CHECK
141 uint64_t size_in_words64 = buf.size_in_words >> 1u;
142 if (wordaddress64 < size_in_words64)
143 {
144 data64[wordaddress64] = value;
145 }
146#else
147 data64[wordaddress64] = value;
148#endif
149}
150#elif defined(PNANOVDB_ADDRESS_64)
151PNANOVDB_BUF_FORCE_INLINE uint32_t pnanovdb_buf_read_uint32(pnanovdb_buf_t buf, uint64_t byte_offset)
152{
153 uint64_t wordaddress = (byte_offset >> 2u);
154#ifdef PNANOVDB_BUF_BOUNDS_CHECK
155 return wordaddress < buf.size_in_words ? buf.data[wordaddress] : 0u;
156#else
157 return buf.data[wordaddress];
158#endif
159}
160PNANOVDB_BUF_FORCE_INLINE uint64_t pnanovdb_buf_read_uint64(pnanovdb_buf_t buf, uint64_t byte_offset)
161{
162 uint64_t* data64 = (uint64_t*)buf.data;
163 uint64_t wordaddress64 = (byte_offset >> 3u);
164#ifdef PNANOVDB_BUF_BOUNDS_CHECK
165 uint64_t size_in_words64 = buf.size_in_words >> 1u;
166 return wordaddress64 < size_in_words64 ? data64[wordaddress64] : 0llu;
167#else
168 return data64[wordaddress64];
169#endif
170}
171PNANOVDB_BUF_FORCE_INLINE void pnanovdb_buf_write_uint32(pnanovdb_buf_t buf, uint64_t byte_offset, uint32_t value)
172{
173 uint64_t wordaddress = (byte_offset >> 2u);
174#ifdef PNANOVDB_BUF_BOUNDS_CHECK
175 if (wordaddress < buf.size_in_words)
176 {
177 buf.data[wordaddress] = value;
178 }
179#else
180 buf.data[wordaddress] = value;
181#endif
182}
183PNANOVDB_BUF_FORCE_INLINE void pnanovdb_buf_write_uint64(pnanovdb_buf_t buf, uint64_t byte_offset, uint64_t value)
184{
185 uint64_t* data64 = (uint64_t*)buf.data;
186 uint64_t wordaddress64 = (byte_offset >> 3u);
187#ifdef PNANOVDB_BUF_BOUNDS_CHECK
188 uint64_t size_in_words64 = buf.size_in_words >> 1u;
189 if (wordaddress64 < size_in_words64)
190 {
191 data64[wordaddress64] = value;
192 }
193#else
194 data64[wordaddress64] = value;
195#endif
196}
197#endif
198typedef uint32_t pnanovdb_grid_type_t;
199#define PNANOVDB_GRID_TYPE_GET(grid_typeIn, nameIn) pnanovdb_grid_type_constants[grid_typeIn].nameIn
200#elif defined(PNANOVDB_BUF_HLSL)
201#if defined(PNANOVDB_BUF_HLSL_RW)
202#if defined(PNANOVDB_BUF_HLSL_64)
203#define pnanovdb_buf_t RWStructuredBuffer<uint2>
204#else
205#define pnanovdb_buf_t RWStructuredBuffer<uint>
206#endif
207#else
208#if defined(PNANOVDB_BUF_HLSL_64)
209#define pnanovdb_buf_t StructuredBuffer<uint2>
210#else
211#define pnanovdb_buf_t StructuredBuffer<uint>
212#endif
213#endif
214#if defined(PNANOVDB_ADDRESS_32)
215uint pnanovdb_buf_read_uint32(pnanovdb_buf_t buf, uint byte_offset)
216{
217#if defined(PNANOVDB_BUF_HLSL_64)
218 uint2 val = buf[(byte_offset >> 3u)];
219 return ((byte_offset & 4u) == 0u) ? val.x : val.y;
220#else
221 return buf[(byte_offset >> 2u)];
222#endif
223}
224uint2 pnanovdb_buf_read_uint64(pnanovdb_buf_t buf, uint byte_offset)
225{
226 uint2 ret;
227#if defined(PNANOVDB_BUF_HLSL_64)
228 ret = buf[(byte_offset >> 3u)];
229#else
230 ret.x = pnanovdb_buf_read_uint32(buf, byte_offset + 0u);
231 ret.y = pnanovdb_buf_read_uint32(buf, byte_offset + 4u);
232#endif
233 return ret;
234}
235void pnanovdb_buf_write_uint32(pnanovdb_buf_t buf, uint byte_offset, uint value)
236{
237 // NOP, by default no write in HLSL
238#if defined(PNANOVDB_BUF_HLSL_RW)
239#if defined(PNANOVDB_BUF_HLSL_64)
240 if ((byte_offset & 4u) == 0u) {buf[(byte_offset >> 3u)].x = value;}
241 else {buf[(byte_offset >> 3u)].y = value;}
242#else
243 buf[(byte_offset >> 2u)] = value;
244#endif
245#endif
246}
247void pnanovdb_buf_write_uint64(pnanovdb_buf_t buf, uint byte_offset, uint2 value)
248{
249 // NOP, by default no write in HLSL
250#if defined(PNANOVDB_BUF_HLSL_RW)
251#if defined(PNANOVDB_BUF_HLSL_64)
252 buf[(byte_offset >> 3u)] = value;
253#else
254 pnanovdb_buf_write_uint32(buf, byte_offset + 0u, value.x);
255 pnanovdb_buf_write_uint32(buf, byte_offset + 4u, value.y);
256#endif
257#endif
258}
259#elif defined(PNANOVDB_ADDRESS_64)
260uint pnanovdb_buf_read_uint32(pnanovdb_buf_t buf, uint64_t byte_offset)
261{
262#if defined(PNANOVDB_BUF_HLSL_64)
263 uint2 val = buf[uint(byte_offset >> 3u)];
264 return ((uint(byte_offset) & 4u) == 0u) ? val.x : val.y;
265#else
266 return buf[uint(byte_offset >> 2u)];
267#endif
268}
269uint64_t pnanovdb_buf_read_uint64(pnanovdb_buf_t buf, uint64_t byte_offset)
270{
271 uint64_t ret;
272#if defined(PNANOVDB_BUF_HLSL_64)
273 uint2 raw = buf[uint(byte_offset >> 3u)];
274 ret = uint64_t(raw.x) | (uint64_t(raw.y) << 32u);
275#else
276 ret = pnanovdb_buf_read_uint32(buf, byte_offset + 0u);
277 ret = ret | (uint64_t(pnanovdb_buf_read_uint32(buf, byte_offset + 4u)) << 32u);
278#endif
279 return ret;
280}
281void pnanovdb_buf_write_uint32(pnanovdb_buf_t buf, uint64_t byte_offset, uint value)
282{
283 // NOP, by default no write in HLSL
284#if defined(PNANOVDB_BUF_HLSL_RW)
285#if defined(PNANOVDB_BUF_HLSL_64)
286 if ((byte_offset & 4u) == 0u) {buf[uint(byte_offset >> 3u)].x = value;}
287 else {buf[uint(byte_offset >> 3u)].y = value;}
288#else
289 buf[uint(byte_offset >> 2u)] = value;
290#endif
291#endif
292}
293void pnanovdb_buf_write_uint64(pnanovdb_buf_t buf, uint64_t byte_offset, uint64_t value)
294{
295 // NOP, by default no write in HLSL
296#if defined(PNANOVDB_BUF_HLSL_RW)
297#if defined(PNANOVDB_BUF_HLSL_64)
298 uint2 raw = uint2(uint(value), uint(value >> 32u));
299 buf[uint(byte_offset >> 3u)] = raw;
300#else
301 pnanovdb_buf_write_uint32(buf, byte_offset + 0u, uint(value));
302 pnanovdb_buf_write_uint32(buf, byte_offset + 4u, uint(value >> 32u));
303#endif
304#endif
305}
306#endif
307#define pnanovdb_grid_type_t uint
308#define PNANOVDB_GRID_TYPE_GET(grid_typeIn, nameIn) pnanovdb_grid_type_constants[grid_typeIn].nameIn
309#elif defined(PNANOVDB_BUF_GLSL)
310struct pnanovdb_buf_t
311{
312 uint unused; // to satisfy min struct size?
313};
314uint pnanovdb_buf_read_uint32(pnanovdb_buf_t buf, uint byte_offset)
315{
316 return pnanovdb_buf_data[(byte_offset >> 2u)];
317}
318uvec2 pnanovdb_buf_read_uint64(pnanovdb_buf_t buf, uint byte_offset)
319{
320 uvec2 ret;
321 ret.x = pnanovdb_buf_read_uint32(buf, byte_offset + 0u);
322 ret.y = pnanovdb_buf_read_uint32(buf, byte_offset + 4u);
323 return ret;
324}
325void pnanovdb_buf_write_uint32(pnanovdb_buf_t buf, uint byte_offset, uint value)
326{
327 // NOP, by default no write in HLSL
328}
329void pnanovdb_buf_write_uint64(pnanovdb_buf_t buf, uint byte_offset, uvec2 value)
330{
331 // NOP, by default no write in HLSL
332}
333#define pnanovdb_grid_type_t uint
334#define PNANOVDB_GRID_TYPE_GET(grid_typeIn, nameIn) pnanovdb_grid_type_constants[grid_typeIn].nameIn
335#endif
336
337// ------------------------------------------------ Basic Types -----------------------------------------------------------
338
339// force inline
340#if defined(PNANOVDB_C)
341#if defined(__CUDACC__)
342#define PNANOVDB_FORCE_INLINE static __host__ __device__ __forceinline__
343#elif defined(_WIN32)
344#define PNANOVDB_FORCE_INLINE static inline __forceinline
345#else
346#define PNANOVDB_FORCE_INLINE static inline __attribute__((always_inline))
347#endif
348#elif defined(PNANOVDB_HLSL)
349#define PNANOVDB_FORCE_INLINE
350#elif defined(PNANOVDB_GLSL)
351#define PNANOVDB_FORCE_INLINE
352#endif
353
354// struct typedef, static const, inout
355#if defined(PNANOVDB_C)
356#define PNANOVDB_STRUCT_TYPEDEF(X) typedef struct X X;
357#if defined(__CUDA_ARCH__)
358#define PNANOVDB_STATIC_CONST constexpr __constant__
359#else
360#define PNANOVDB_STATIC_CONST static const
361#endif
362#define PNANOVDB_INOUT(X) X*
363#define PNANOVDB_IN(X) const X*
364#define PNANOVDB_DEREF(X) (*X)
365#define PNANOVDB_REF(X) &X
366#elif defined(PNANOVDB_HLSL)
367#define PNANOVDB_STRUCT_TYPEDEF(X)
368#define PNANOVDB_STATIC_CONST static const
369#define PNANOVDB_INOUT(X) inout X
370#define PNANOVDB_IN(X) X
371#define PNANOVDB_DEREF(X) X
372#define PNANOVDB_REF(X) X
373#elif defined(PNANOVDB_GLSL)
374#define PNANOVDB_STRUCT_TYPEDEF(X)
375#define PNANOVDB_STATIC_CONST const
376#define PNANOVDB_INOUT(X) inout X
377#define PNANOVDB_IN(X) X
378#define PNANOVDB_DEREF(X) X
379#define PNANOVDB_REF(X) X
380#endif
381
382// basic types, type conversion
383#if defined(PNANOVDB_C)
384#define PNANOVDB_NATIVE_64
385#ifndef __CUDACC_RTC__
386#include <stdint.h>
387#endif
388#if !defined(PNANOVDB_MEMCPY_CUSTOM)
389#ifndef __CUDACC_RTC__
390#include <string.h>
391#endif
392#define pnanovdb_memcpy memcpy
393#endif
394typedef uint32_t pnanovdb_uint32_t;
395typedef int32_t pnanovdb_int32_t;
396typedef int32_t pnanovdb_bool_t;
397#define PNANOVDB_FALSE 0
398#define PNANOVDB_TRUE 1
399typedef uint64_t pnanovdb_uint64_t;
400typedef int64_t pnanovdb_int64_t;
401typedef struct pnanovdb_coord_t
402{
403 pnanovdb_int32_t x, y, z;
404}pnanovdb_coord_t;
405typedef struct pnanovdb_vec3_t
406{
407 float x, y, z;
408}pnanovdb_vec3_t;
409typedef struct pnanovdb_uvec4_t
410{
411 pnanovdb_uint32_t x, y, z, w;
412}pnanovdb_uvec4_t;
413typedef struct pnanovdb_ivec4_t
414{
415 pnanovdb_int32_t x, y, z, w;
416}pnanovdb_ivec4_t;
417typedef struct pnanovdb_vec4_t
418{
419 float x, y, z, w;
420}pnanovdb_vec4_t;
421PNANOVDB_FORCE_INLINE pnanovdb_int32_t pnanovdb_uint32_as_int32(pnanovdb_uint32_t v) { return (pnanovdb_int32_t)v; }
422PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_uint64_as_int64(pnanovdb_uint64_t v) { return (pnanovdb_int64_t)v; }
423PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_int64_as_uint64(pnanovdb_int64_t v) { return (pnanovdb_uint64_t)v; }
424PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_int32_as_uint32(pnanovdb_int32_t v) { return (pnanovdb_uint32_t)v; }
425PNANOVDB_FORCE_INLINE float pnanovdb_uint32_as_float(pnanovdb_uint32_t v) { float vf; pnanovdb_memcpy(&vf, &v, sizeof(vf)); return vf; }
426PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_float_as_uint32(float v) { pnanovdb_uint32_t vu; pnanovdb_memcpy(&vu, &v, sizeof(vu)); return vu; }
427PNANOVDB_FORCE_INLINE double pnanovdb_uint64_as_double(pnanovdb_uint64_t v) { double vf; pnanovdb_memcpy(&vf, &v, sizeof(vf)); return vf; }
428PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_double_as_uint64(double v) { pnanovdb_uint64_t vu; pnanovdb_memcpy(&vu, &v, sizeof(vu)); return vu; }
429PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint64_low(pnanovdb_uint64_t v) { return (pnanovdb_uint32_t)v; }
430PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint64_high(pnanovdb_uint64_t v) { return (pnanovdb_uint32_t)(v >> 32u); }
431PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint32_as_uint64(pnanovdb_uint32_t x, pnanovdb_uint32_t y) { return ((pnanovdb_uint64_t)x) | (((pnanovdb_uint64_t)y) << 32u); }
432PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint32_as_uint64_low(pnanovdb_uint32_t x) { return ((pnanovdb_uint64_t)x); }
433PNANOVDB_FORCE_INLINE pnanovdb_int32_t pnanovdb_uint64_is_equal(pnanovdb_uint64_t a, pnanovdb_uint64_t b) { return a == b; }
434PNANOVDB_FORCE_INLINE pnanovdb_int32_t pnanovdb_int64_is_zero(pnanovdb_int64_t a) { return a == 0; }
435#ifdef PNANOVDB_CMATH
436PNANOVDB_FORCE_INLINE float pnanovdb_floor(float v) { return floorf(v); }
437#endif
438PNANOVDB_FORCE_INLINE pnanovdb_int32_t pnanovdb_float_to_int32(float v) { return (pnanovdb_int32_t)v; }
439PNANOVDB_FORCE_INLINE float pnanovdb_int32_to_float(pnanovdb_int32_t v) { return (float)v; }
440PNANOVDB_FORCE_INLINE float pnanovdb_uint32_to_float(pnanovdb_uint32_t v) { return (float)v; }
441PNANOVDB_FORCE_INLINE float pnanovdb_min(float a, float b) { return a < b ? a : b; }
442PNANOVDB_FORCE_INLINE float pnanovdb_max(float a, float b) { return a > b ? a : b; }
443#elif defined(PNANOVDB_HLSL)
444typedef uint pnanovdb_uint32_t;
445typedef int pnanovdb_int32_t;
446typedef bool pnanovdb_bool_t;
447#define PNANOVDB_FALSE false
448#define PNANOVDB_TRUE true
449typedef int3 pnanovdb_coord_t;
450typedef float3 pnanovdb_vec3_t;
451typedef uint4 pnanovdb_uvec4_t;
452typedef int4 pnanovdb_ivec4_t;
453typedef float4 pnanovdb_vec4_t;
454pnanovdb_int32_t pnanovdb_uint32_as_int32(pnanovdb_uint32_t v) { return int(v); }
455pnanovdb_uint32_t pnanovdb_int32_as_uint32(pnanovdb_int32_t v) { return uint(v); }
456float pnanovdb_uint32_as_float(pnanovdb_uint32_t v) { return asfloat(v); }
457pnanovdb_uint32_t pnanovdb_float_as_uint32(float v) { return asuint(v); }
458float pnanovdb_floor(float v) { return floor(v); }
459pnanovdb_int32_t pnanovdb_float_to_int32(float v) { return int(v); }
460float pnanovdb_int32_to_float(pnanovdb_int32_t v) { return float(v); }
461float pnanovdb_uint32_to_float(pnanovdb_uint32_t v) { return float(v); }
462float pnanovdb_min(float a, float b) { return min(a, b); }
463float pnanovdb_max(float a, float b) { return max(a, b); }
464#if defined(PNANOVDB_ADDRESS_32)
465typedef uint2 pnanovdb_uint64_t;
466typedef int2 pnanovdb_int64_t;
467pnanovdb_int64_t pnanovdb_uint64_as_int64(pnanovdb_uint64_t v) { return int2(v); }
468pnanovdb_uint64_t pnanovdb_int64_as_uint64(pnanovdb_int64_t v) { return uint2(v); }
469double pnanovdb_uint64_as_double(pnanovdb_uint64_t v) { return asdouble(v.x, v.y); }
470pnanovdb_uint64_t pnanovdb_double_as_uint64(double v) { uint2 ret; asuint(v, ret.x, ret.y); return ret; }
471pnanovdb_uint32_t pnanovdb_uint64_low(pnanovdb_uint64_t v) { return v.x; }
472pnanovdb_uint32_t pnanovdb_uint64_high(pnanovdb_uint64_t v) { return v.y; }
473pnanovdb_uint64_t pnanovdb_uint32_as_uint64(pnanovdb_uint32_t x, pnanovdb_uint32_t y) { return uint2(x, y); }
474pnanovdb_uint64_t pnanovdb_uint32_as_uint64_low(pnanovdb_uint32_t x) { return uint2(x, 0); }
475bool pnanovdb_uint64_is_equal(pnanovdb_uint64_t a, pnanovdb_uint64_t b) { return (a.x == b.x) && (a.y == b.y); }
476bool pnanovdb_int64_is_zero(pnanovdb_int64_t a) { return a.x == 0 && a.y == 0; }
477#else
478typedef uint64_t pnanovdb_uint64_t;
479typedef int64_t pnanovdb_int64_t;
480pnanovdb_int64_t pnanovdb_uint64_as_int64(pnanovdb_uint64_t v) { return int64_t(v); }
481pnanovdb_uint64_t pnanovdb_int64_as_uint64(pnanovdb_int64_t v) { return uint64_t(v); }
482double pnanovdb_uint64_as_double(pnanovdb_uint64_t v) { return asdouble(uint(v), uint(v >> 32u)); }
483pnanovdb_uint64_t pnanovdb_double_as_uint64(double v) { uint2 ret; asuint(v, ret.x, ret.y); return uint64_t(ret.x) + (uint64_t(ret.y) << 32u); }
484pnanovdb_uint32_t pnanovdb_uint64_low(pnanovdb_uint64_t v) { return uint(v); }
485pnanovdb_uint32_t pnanovdb_uint64_high(pnanovdb_uint64_t v) { return uint(v >> 32u); }
486pnanovdb_uint64_t pnanovdb_uint32_as_uint64(pnanovdb_uint32_t x, pnanovdb_uint32_t y) { return uint64_t(x) + (uint64_t(y) << 32u); }
487pnanovdb_uint64_t pnanovdb_uint32_as_uint64_low(pnanovdb_uint32_t x) { return uint64_t(x); }
488bool pnanovdb_uint64_is_equal(pnanovdb_uint64_t a, pnanovdb_uint64_t b) { return a == b; }
489bool pnanovdb_int64_is_zero(pnanovdb_int64_t a) { return a == 0; }
490#endif
491#elif defined(PNANOVDB_GLSL)
492#define pnanovdb_uint32_t uint
493#define pnanovdb_int32_t int
494#define pnanovdb_bool_t bool
495#define PNANOVDB_FALSE false
496#define PNANOVDB_TRUE true
497#define pnanovdb_uint64_t uvec2
498#define pnanovdb_int64_t ivec2
499#define pnanovdb_coord_t ivec3
500#define pnanovdb_vec3_t vec3
501#define pnanovdb_uvec4_t uvec4
502#define pnanovdb_ivec4_t ivec4
503#define pnanovdb_vec4_t vec4
504pnanovdb_int32_t pnanovdb_uint32_as_int32(pnanovdb_uint32_t v) { return int(v); }
505pnanovdb_int64_t pnanovdb_uint64_as_int64(pnanovdb_uint64_t v) { return ivec2(v); }
506pnanovdb_uint64_t pnanovdb_int64_as_uint64(pnanovdb_int64_t v) { return uvec2(v); }
507pnanovdb_uint32_t pnanovdb_int32_as_uint32(pnanovdb_int32_t v) { return uint(v); }
508float pnanovdb_uint32_as_float(pnanovdb_uint32_t v) { return uintBitsToFloat(v); }
509pnanovdb_uint32_t pnanovdb_float_as_uint32(float v) { return floatBitsToUint(v); }
510double pnanovdb_uint64_as_double(pnanovdb_uint64_t v) { return packDouble2x32(uvec2(v.x, v.y)); }
511pnanovdb_uint64_t pnanovdb_double_as_uint64(double v) { return unpackDouble2x32(v); }
512pnanovdb_uint32_t pnanovdb_uint64_low(pnanovdb_uint64_t v) { return v.x; }
513pnanovdb_uint32_t pnanovdb_uint64_high(pnanovdb_uint64_t v) { return v.y; }
514pnanovdb_uint64_t pnanovdb_uint32_as_uint64(pnanovdb_uint32_t x, pnanovdb_uint32_t y) { return uvec2(x, y); }
515pnanovdb_uint64_t pnanovdb_uint32_as_uint64_low(pnanovdb_uint32_t x) { return uvec2(x, 0); }
516bool pnanovdb_uint64_is_equal(pnanovdb_uint64_t a, pnanovdb_uint64_t b) { return (a.x == b.x) && (a.y == b.y); }
517bool pnanovdb_int64_is_zero(pnanovdb_int64_t a) { return a.x == 0 && a.y == 0; }
518float pnanovdb_floor(float v) { return floor(v); }
519pnanovdb_int32_t pnanovdb_float_to_int32(float v) { return int(v); }
520float pnanovdb_int32_to_float(pnanovdb_int32_t v) { return float(v); }
521float pnanovdb_uint32_to_float(pnanovdb_uint32_t v) { return float(v); }
522float pnanovdb_min(float a, float b) { return min(a, b); }
523float pnanovdb_max(float a, float b) { return max(a, b); }
524#endif
525
526// ------------------------------------------------ Coord/Vec3 Utilties -----------------------------------------------------------
527
528#if defined(PNANOVDB_C)
529PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_vec3_uniform(float a)
530{
531 pnanovdb_vec3_t v;
532 v.x = a;
533 v.y = a;
534 v.z = a;
535 return v;
536}
537PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_vec3_add(const pnanovdb_vec3_t a, const pnanovdb_vec3_t b)
538{
539 pnanovdb_vec3_t v;
540 v.x = a.x + b.x;
541 v.y = a.y + b.y;
542 v.z = a.z + b.z;
543 return v;
544}
545PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_vec3_sub(const pnanovdb_vec3_t a, const pnanovdb_vec3_t b)
546{
547 pnanovdb_vec3_t v;
548 v.x = a.x - b.x;
549 v.y = a.y - b.y;
550 v.z = a.z - b.z;
551 return v;
552}
553PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_vec3_mul(const pnanovdb_vec3_t a, const pnanovdb_vec3_t b)
554{
555 pnanovdb_vec3_t v;
556 v.x = a.x * b.x;
557 v.y = a.y * b.y;
558 v.z = a.z * b.z;
559 return v;
560}
561PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_vec3_div(const pnanovdb_vec3_t a, const pnanovdb_vec3_t b)
562{
563 pnanovdb_vec3_t v;
564 v.x = a.x / b.x;
565 v.y = a.y / b.y;
566 v.z = a.z / b.z;
567 return v;
568}
569PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_vec3_min(const pnanovdb_vec3_t a, const pnanovdb_vec3_t b)
570{
571 pnanovdb_vec3_t v;
572 v.x = a.x < b.x ? a.x : b.x;
573 v.y = a.y < b.y ? a.y : b.y;
574 v.z = a.z < b.z ? a.z : b.z;
575 return v;
576}
577PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_vec3_max(const pnanovdb_vec3_t a, const pnanovdb_vec3_t b)
578{
579 pnanovdb_vec3_t v;
580 v.x = a.x > b.x ? a.x : b.x;
581 v.y = a.y > b.y ? a.y : b.y;
582 v.z = a.z > b.z ? a.z : b.z;
583 return v;
584}
585PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_coord_to_vec3(const pnanovdb_coord_t coord)
586{
587 pnanovdb_vec3_t v;
588 v.x = pnanovdb_int32_to_float(coord.x);
589 v.y = pnanovdb_int32_to_float(coord.y);
590 v.z = pnanovdb_int32_to_float(coord.z);
591 return v;
592}
593PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_coord_uniform(const pnanovdb_int32_t a)
594{
595 pnanovdb_coord_t v;
596 v.x = a;
597 v.y = a;
598 v.z = a;
599 return v;
600}
601PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_coord_add(pnanovdb_coord_t a, pnanovdb_coord_t b)
602{
603 pnanovdb_coord_t v;
604 v.x = a.x + b.x;
605 v.y = a.y + b.y;
606 v.z = a.z + b.z;
607 return v;
608}
609PNANOVDB_FORCE_INLINE pnanovdb_uvec4_t pnanovdb_uvec4_add(pnanovdb_uvec4_t a, pnanovdb_uvec4_t b)
610{
611 pnanovdb_uvec4_t ret;
612 ret.x = a.x + b.x;
613 ret.y = a.y + b.y;
614 ret.z = a.z + b.z;
615 ret.w = a.w + b.w;
616 return ret;
617}
618
619PNANOVDB_FORCE_INLINE pnanovdb_uvec4_t pnanovdb_uvec4_sub(pnanovdb_uvec4_t a, pnanovdb_uvec4_t b)
620{
621 pnanovdb_uvec4_t ret;
622 ret.x = a.x - b.x;
623 ret.y = a.y - b.y;
624 ret.z = a.z - b.z;
625 ret.w = a.w - b.w;
626 return ret;
627}
628
629PNANOVDB_FORCE_INLINE pnanovdb_vec4_t pnanovdb_vec4_add(pnanovdb_vec4_t a, pnanovdb_vec4_t b)
630{
631 pnanovdb_vec4_t ret;
632 ret.x = a.x + b.x;
633 ret.y = a.y + b.y;
634 ret.z = a.z + b.z;
635 ret.w = a.w + b.w;
636 return ret;
637}
638#elif defined(PNANOVDB_HLSL)
639pnanovdb_vec3_t pnanovdb_vec3_uniform(float a) { return float3(a, a, a); }
640pnanovdb_vec3_t pnanovdb_vec3_add(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a + b; }
641pnanovdb_vec3_t pnanovdb_vec3_sub(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a - b; }
642pnanovdb_vec3_t pnanovdb_vec3_mul(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a * b; }
643pnanovdb_vec3_t pnanovdb_vec3_div(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a / b; }
644pnanovdb_vec3_t pnanovdb_vec3_min(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return min(a, b); }
645pnanovdb_vec3_t pnanovdb_vec3_max(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return max(a, b); }
646pnanovdb_vec3_t pnanovdb_coord_to_vec3(pnanovdb_coord_t coord) { return float3(coord); }
647pnanovdb_coord_t pnanovdb_coord_uniform(pnanovdb_int32_t a) { return int3(a, a, a); }
648pnanovdb_coord_t pnanovdb_coord_add(pnanovdb_coord_t a, pnanovdb_coord_t b) { return a + b; }
649pnanovdb_uvec4_t pnanovdb_uvec4_add(pnanovdb_uvec4_t a, pnanovdb_uvec4_t b) { return a + b; }
650pnanovdb_uvec4_t pnanovdb_uvec4_sub(pnanovdb_uvec4_t a, pnanovdb_uvec4_t b) { return a - b; }
651pnanovdb_vec4_t pnanovdb_vec4_add(pnanovdb_vec4_t a, pnanovdb_vec4_t b) { return a + b; }
652#elif defined(PNANOVDB_GLSL)
653pnanovdb_vec3_t pnanovdb_vec3_uniform(float a) { return vec3(a, a, a); }
654pnanovdb_vec3_t pnanovdb_vec3_add(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a + b; }
655pnanovdb_vec3_t pnanovdb_vec3_sub(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a - b; }
656pnanovdb_vec3_t pnanovdb_vec3_mul(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a * b; }
657pnanovdb_vec3_t pnanovdb_vec3_div(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return a / b; }
658pnanovdb_vec3_t pnanovdb_vec3_min(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return min(a, b); }
659pnanovdb_vec3_t pnanovdb_vec3_max(pnanovdb_vec3_t a, pnanovdb_vec3_t b) { return max(a, b); }
660pnanovdb_vec3_t pnanovdb_coord_to_vec3(const pnanovdb_coord_t coord) { return vec3(coord); }
661pnanovdb_coord_t pnanovdb_coord_uniform(pnanovdb_int32_t a) { return ivec3(a, a, a); }
662pnanovdb_coord_t pnanovdb_coord_add(pnanovdb_coord_t a, pnanovdb_coord_t b) { return a + b; }
663pnanovdb_uvec4_t pnanovdb_uvec4_add(pnanovdb_uvec4_t a, pnanovdb_uvec4_t b) { return a + b; }
664pnanovdb_uvec4_t pnanovdb_uvec4_sub(pnanovdb_uvec4_t a, pnanovdb_uvec4_t b) { return a - b; }
665pnanovdb_vec4_t pnanovdb_vec4_add(pnanovdb_vec4_t a, pnanovdb_vec4_t b) { return a + b; }
666#endif
667
668// ------------------------------------------------ Uint64 Utils -----------------------------------------------------------
669
670PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint32_countbits(pnanovdb_uint32_t value)
671{
672#if defined(PNANOVDB_C)
673#if defined(_MSC_VER) && (_MSC_VER >= 1928) && defined(PNANOVDB_USE_INTRINSICS)
674 return __popcnt(value);
675#elif (defined(__GNUC__) || defined(__clang__)) && defined(PNANOVDB_USE_INTRINSICS)
676 return __builtin_popcount(value);
677#else
678 value = value - ((value >> 1) & 0x55555555);
679 value = (value & 0x33333333) + ((value >> 2) & 0x33333333);
680 value = (value + (value >> 4)) & 0x0F0F0F0F;
681 return (value * 0x01010101) >> 24;
682#endif
683#elif defined(PNANOVDB_HLSL)
684 return countbits(value);
685#elif defined(PNANOVDB_GLSL)
686 return bitCount(value);
687#endif
688}
689
690PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint64_countbits(pnanovdb_uint64_t value)
691{
692 return pnanovdb_uint32_countbits(pnanovdb_uint64_low(value)) + pnanovdb_uint32_countbits(pnanovdb_uint64_high(value));
693}
694
695#if defined(PNANOVDB_ADDRESS_32)
696PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_offset(pnanovdb_uint64_t a, pnanovdb_uint32_t b)
697{
698 pnanovdb_uint32_t low = pnanovdb_uint64_low(a);
699 pnanovdb_uint32_t high = pnanovdb_uint64_high(a);
700 low += b;
701 if (low < b)
702 {
703 high += 1u;
704 }
705 return pnanovdb_uint32_as_uint64(low, high);
706}
707
708PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_uint64_diff(pnanovdb_uint64_t a, pnanovdb_uint64_t b)
709{
710 pnanovdb_uint32_t low = pnanovdb_uint64_low(a);
711 pnanovdb_uint32_t high = pnanovdb_uint64_high(a);
712 low -= pnanovdb_uint64_low(b);
713 if (low > pnanovdb_uint64_low(a))
714 {
715 high -= 1u;
716 }
717 high -= pnanovdb_uint64_high(b);
718 return pnanovdb_uint64_as_int64(pnanovdb_uint32_as_uint64(low, high));
719}
720
721PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_dec(pnanovdb_uint64_t a)
722{
723 pnanovdb_uint32_t low = pnanovdb_uint64_low(a);
724 pnanovdb_uint32_t high = pnanovdb_uint64_high(a);
725 if (low == 0u)
726 {
727 high -= 1u;
728 }
729 low -= 1u;
730 return pnanovdb_uint32_as_uint64(low, high);
731}
732
733PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint64_to_uint32_lsr(pnanovdb_uint64_t a, pnanovdb_uint32_t b)
734{
735 pnanovdb_uint32_t low = pnanovdb_uint64_low(a);
736 pnanovdb_uint32_t high = pnanovdb_uint64_high(a);
737 return (b >= 32u) ?
738 (high >> (b - 32)) :
739 ((low >> b) | ((b > 0) ? (high << (32u - b)) : 0u));
740}
741
742PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_bit_mask(pnanovdb_uint32_t bit_idx)
743{
744 pnanovdb_uint32_t mask_low = bit_idx < 32u ? 1u << bit_idx : 0u;
745 pnanovdb_uint32_t mask_high = bit_idx >= 32u ? 1u << (bit_idx - 32u) : 0u;
746 return pnanovdb_uint32_as_uint64(mask_low, mask_high);
747}
748
749PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_and(pnanovdb_uint64_t a, pnanovdb_uint64_t b)
750{
751 return pnanovdb_uint32_as_uint64(
752 pnanovdb_uint64_low(a) & pnanovdb_uint64_low(b),
753 pnanovdb_uint64_high(a) & pnanovdb_uint64_high(b)
754 );
755}
756
757PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_uint64_any_bit(pnanovdb_uint64_t a)
758{
759 return pnanovdb_uint64_low(a) != 0u || pnanovdb_uint64_high(a) != 0u;
760}
761
762#else
763PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_offset(pnanovdb_uint64_t a, pnanovdb_uint32_t b)
764{
765 return a + b;
766}
767
768PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_uint64_diff(pnanovdb_uint64_t a, pnanovdb_uint64_t b)
769{
770 return pnanovdb_uint64_as_int64(a - b);
771}
772
773PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_dec(pnanovdb_uint64_t a)
774{
775 return a - 1u;
776}
777
778PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint64_to_uint32_lsr(pnanovdb_uint64_t a, pnanovdb_uint32_t b)
779{
780 return pnanovdb_uint64_low(a >> b);
781}
782
783PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_bit_mask(pnanovdb_uint32_t bit_idx)
784{
785 return 1llu << bit_idx;
786}
787
788PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_and(pnanovdb_uint64_t a, pnanovdb_uint64_t b)
789{
790 return a & b;
791}
792
793PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_uint64_any_bit(pnanovdb_uint64_t a)
794{
795 return a != 0llu;
796}
797#endif
798
799// ------------------------------------------------ Address Type -----------------------------------------------------------
800
801#if defined(PNANOVDB_ADDRESS_32)
802struct pnanovdb_address_t
803{
804 pnanovdb_uint32_t byte_offset;
805};
806PNANOVDB_STRUCT_TYPEDEF(pnanovdb_address_t)
807
808PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset(pnanovdb_address_t address, pnanovdb_uint32_t byte_offset)
809{
810 pnanovdb_address_t ret = address;
811 ret.byte_offset += byte_offset;
812 return ret;
813}
814PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset_neg(pnanovdb_address_t address, pnanovdb_uint32_t byte_offset)
815{
816 pnanovdb_address_t ret = address;
817 ret.byte_offset -= byte_offset;
818 return ret;
819}
820PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset_product(pnanovdb_address_t address, pnanovdb_uint32_t byte_offset, pnanovdb_uint32_t multiplier)
821{
822 pnanovdb_address_t ret = address;
823 ret.byte_offset += byte_offset * multiplier;
824 return ret;
825}
826PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset64(pnanovdb_address_t address, pnanovdb_uint64_t byte_offset)
827{
828 pnanovdb_address_t ret = address;
829 // lose high bits on 32-bit
830 ret.byte_offset += pnanovdb_uint64_low(byte_offset);
831 return ret;
832}
833PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset64_product(pnanovdb_address_t address, pnanovdb_uint64_t byte_offset, pnanovdb_uint32_t multiplier)
834{
835 pnanovdb_address_t ret = address;
836 ret.byte_offset += pnanovdb_uint64_low(byte_offset) * multiplier;
837 return ret;
838}
839PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_address_diff(pnanovdb_address_t a, pnanovdb_address_t b)
840{
841 return pnanovdb_uint64_diff(pnanovdb_uint32_as_uint64_low(a.byte_offset),pnanovdb_uint32_as_uint64_low(b.byte_offset));
842}
843PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_address_mask(pnanovdb_address_t address, pnanovdb_uint32_t mask)
844{
845 return address.byte_offset & mask;
846}
847PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_mask_inv(pnanovdb_address_t address, pnanovdb_uint32_t mask)
848{
849 pnanovdb_address_t ret = address;
850 ret.byte_offset &= (~mask);
851 return ret;
852}
853PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_null()
854{
855 pnanovdb_address_t ret = { 0 };
856 return ret;
857}
858PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_address_is_null(pnanovdb_address_t address)
859{
860 return address.byte_offset == 0u;
861}
862PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_address_in_interval(pnanovdb_address_t address, pnanovdb_address_t min_address, pnanovdb_address_t max_address)
863{
864 return address.byte_offset >= min_address.byte_offset && address.byte_offset < max_address.byte_offset;
865}
866PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_add(pnanovdb_address_t a, pnanovdb_address_t b)
867{
868 pnanovdb_address_t sum = a;
869 sum.byte_offset += b.byte_offset;
870 return sum;
871}
872#elif defined(PNANOVDB_ADDRESS_64)
873struct pnanovdb_address_t
874{
875 pnanovdb_uint64_t byte_offset;
876};
877PNANOVDB_STRUCT_TYPEDEF(pnanovdb_address_t)
878
879PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset(pnanovdb_address_t address, pnanovdb_uint32_t byte_offset)
880{
881 pnanovdb_address_t ret = address;
882 ret.byte_offset += byte_offset;
883 return ret;
884}
885PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset_neg(pnanovdb_address_t address, pnanovdb_uint32_t byte_offset)
886{
887 pnanovdb_address_t ret = address;
888 ret.byte_offset -= byte_offset;
889 return ret;
890}
891PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset_product(pnanovdb_address_t address, pnanovdb_uint32_t byte_offset, pnanovdb_uint32_t multiplier)
892{
893 pnanovdb_address_t ret = address;
894 ret.byte_offset += pnanovdb_uint32_as_uint64_low(byte_offset) * pnanovdb_uint32_as_uint64_low(multiplier);
895 return ret;
896}
897PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset64(pnanovdb_address_t address, pnanovdb_uint64_t byte_offset)
898{
899 pnanovdb_address_t ret = address;
900 ret.byte_offset += byte_offset;
901 return ret;
902}
903PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_offset64_product(pnanovdb_address_t address, pnanovdb_uint64_t byte_offset, pnanovdb_uint32_t multiplier)
904{
905 pnanovdb_address_t ret = address;
906 ret.byte_offset += byte_offset * pnanovdb_uint32_as_uint64_low(multiplier);
907 return ret;
908}
909PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_address_diff(pnanovdb_address_t a, pnanovdb_address_t b)
910{
911 return pnanovdb_uint64_diff(a.byte_offset, b.byte_offset);
912}
913PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_address_mask(pnanovdb_address_t address, pnanovdb_uint32_t mask)
914{
915 return pnanovdb_uint64_low(address.byte_offset) & mask;
916}
917PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_mask_inv(pnanovdb_address_t address, pnanovdb_uint32_t mask)
918{
919 pnanovdb_address_t ret = address;
920 ret.byte_offset &= (~pnanovdb_uint32_as_uint64_low(mask));
921 return ret;
922}
923PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_null()
924{
925 pnanovdb_address_t ret = { 0 };
926 return ret;
927}
928PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_address_is_null(pnanovdb_address_t address)
929{
930 return address.byte_offset == 0llu;
931}
932PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_address_in_interval(pnanovdb_address_t address, pnanovdb_address_t min_address, pnanovdb_address_t max_address)
933{
934 return address.byte_offset >= min_address.byte_offset && address.byte_offset < max_address.byte_offset;
935}
936PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_address_add(pnanovdb_address_t a, pnanovdb_address_t b)
937{
938 pnanovdb_address_t sum = a;
939 sum.byte_offset += b.byte_offset;
940 return sum;
941}
942#endif
943
944// ------------------------------------------------ High Level Buffer Read -----------------------------------------------------------
945
946PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_read_uint32(pnanovdb_buf_t buf, pnanovdb_address_t address)
947{
948 return pnanovdb_buf_read_uint32(buf, address.byte_offset);
949}
950PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_read_uint64(pnanovdb_buf_t buf, pnanovdb_address_t address)
951{
952 return pnanovdb_buf_read_uint64(buf, address.byte_offset);
953}
954PNANOVDB_FORCE_INLINE pnanovdb_int32_t pnanovdb_read_int32(pnanovdb_buf_t buf, pnanovdb_address_t address)
955{
956 return pnanovdb_uint32_as_int32(pnanovdb_read_uint32(buf, address));
957}
958PNANOVDB_FORCE_INLINE float pnanovdb_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address)
959{
960 return pnanovdb_uint32_as_float(pnanovdb_read_uint32(buf, address));
961}
962PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_read_int64(pnanovdb_buf_t buf, pnanovdb_address_t address)
963{
964 return pnanovdb_uint64_as_int64(pnanovdb_read_uint64(buf, address));
965}
966PNANOVDB_FORCE_INLINE double pnanovdb_read_double(pnanovdb_buf_t buf, pnanovdb_address_t address)
967{
968 return pnanovdb_uint64_as_double(pnanovdb_read_uint64(buf, address));
969}
970PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_read_coord(pnanovdb_buf_t buf, pnanovdb_address_t address)
971{
972 pnanovdb_coord_t ret;
973 ret.x = pnanovdb_uint32_as_int32(pnanovdb_read_uint32(buf, pnanovdb_address_offset(address, 0u)));
974 ret.y = pnanovdb_uint32_as_int32(pnanovdb_read_uint32(buf, pnanovdb_address_offset(address, 4u)));
975 ret.z = pnanovdb_uint32_as_int32(pnanovdb_read_uint32(buf, pnanovdb_address_offset(address, 8u)));
976 return ret;
977}
978PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_read_vec3(pnanovdb_buf_t buf, pnanovdb_address_t address)
979{
980 pnanovdb_vec3_t ret;
981 ret.x = pnanovdb_read_float(buf, pnanovdb_address_offset(address, 0u));
982 ret.y = pnanovdb_read_float(buf, pnanovdb_address_offset(address, 4u));
983 ret.z = pnanovdb_read_float(buf, pnanovdb_address_offset(address, 8u));
984 return ret;
985}
986
987PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_read_uint16(pnanovdb_buf_t buf, pnanovdb_address_t address)
988{
989 pnanovdb_uint32_t raw = pnanovdb_read_uint32(buf, pnanovdb_address_mask_inv(address, 3u));
990 return (raw >> (pnanovdb_address_mask(address, 2) << 3));
991}
992PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_read_uint8(pnanovdb_buf_t buf, pnanovdb_address_t address)
993{
994 pnanovdb_uint32_t raw = pnanovdb_read_uint32(buf, pnanovdb_address_mask_inv(address, 3u));
995 return (raw >> (pnanovdb_address_mask(address, 3) << 3)) & 255;
996}
997PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_read_vec3u16(pnanovdb_buf_t buf, pnanovdb_address_t address)
998{
999 pnanovdb_vec3_t ret;
1000 const float scale = 1.f / 65535.f;
1001 ret.x = scale * pnanovdb_uint32_to_float(pnanovdb_read_uint16(buf, pnanovdb_address_offset(address, 0u))) - 0.5f;
1002 ret.y = scale * pnanovdb_uint32_to_float(pnanovdb_read_uint16(buf, pnanovdb_address_offset(address, 2u))) - 0.5f;
1003 ret.z = scale * pnanovdb_uint32_to_float(pnanovdb_read_uint16(buf, pnanovdb_address_offset(address, 4u))) - 0.5f;
1004 return ret;
1005}
1006PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_read_vec3u8(pnanovdb_buf_t buf, pnanovdb_address_t address)
1007{
1008 pnanovdb_vec3_t ret;
1009 const float scale = 1.f / 255.f;
1010 ret.x = scale * pnanovdb_uint32_to_float(pnanovdb_read_uint8(buf, pnanovdb_address_offset(address, 0u))) - 0.5f;
1011 ret.y = scale * pnanovdb_uint32_to_float(pnanovdb_read_uint8(buf, pnanovdb_address_offset(address, 1u))) - 0.5f;
1012 ret.z = scale * pnanovdb_uint32_to_float(pnanovdb_read_uint8(buf, pnanovdb_address_offset(address, 2u))) - 0.5f;
1013 return ret;
1014}
1015
1016PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_read_bit(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_uint32_t bit_offset)
1017{
1018 pnanovdb_address_t word_address = pnanovdb_address_mask_inv(address, 3u);
1019 pnanovdb_uint32_t bit_index = (pnanovdb_address_mask(address, 3u) << 3u) + bit_offset;
1020 pnanovdb_uint32_t value_word = pnanovdb_buf_read_uint32(buf, word_address.byte_offset);
1021 return ((value_word >> bit_index) & 1) != 0u;
1022}
1023
1024#if defined(PNANOVDB_C)
1025PNANOVDB_FORCE_INLINE short pnanovdb_read_half(pnanovdb_buf_t buf, pnanovdb_address_t address)
1026{
1027 pnanovdb_uint32_t raw = pnanovdb_read_uint32(buf, address);
1028 return (short)(raw >> (pnanovdb_address_mask(address, 2) << 3));
1029}
1030#elif defined(PNANOVDB_HLSL)
1031PNANOVDB_FORCE_INLINE float pnanovdb_read_half(pnanovdb_buf_t buf, pnanovdb_address_t address)
1032{
1033 pnanovdb_uint32_t raw = pnanovdb_read_uint32(buf, address);
1034 return f16tof32(raw >> (pnanovdb_address_mask(address, 2) << 3));
1035}
1036#elif defined(PNANOVDB_GLSL)
1037PNANOVDB_FORCE_INLINE float pnanovdb_read_half(pnanovdb_buf_t buf, pnanovdb_address_t address)
1038{
1039 pnanovdb_uint32_t raw = pnanovdb_read_uint32(buf, address);
1040 return unpackHalf2x16(raw >> (pnanovdb_address_mask(address, 2) << 3)).x;
1041}
1042#endif
1043
1044// ------------------------------------------------ High Level Buffer Write -----------------------------------------------------------
1045
1046PNANOVDB_FORCE_INLINE void pnanovdb_write_uint32(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_uint32_t value)
1047{
1048 pnanovdb_buf_write_uint32(buf, address.byte_offset, value);
1049}
1050PNANOVDB_FORCE_INLINE void pnanovdb_write_uint64(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_uint64_t value)
1051{
1052 pnanovdb_buf_write_uint64(buf, address.byte_offset, value);
1053}
1054PNANOVDB_FORCE_INLINE void pnanovdb_write_int32(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_int32_t value)
1055{
1056 pnanovdb_write_uint32(buf, address, pnanovdb_int32_as_uint32(value));
1057}
1058PNANOVDB_FORCE_INLINE void pnanovdb_write_int64(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_int64_t value)
1059{
1060 pnanovdb_buf_write_uint64(buf, address.byte_offset, pnanovdb_int64_as_uint64(value));
1061}
1062PNANOVDB_FORCE_INLINE void pnanovdb_write_float(pnanovdb_buf_t buf, pnanovdb_address_t address, float value)
1063{
1064 pnanovdb_write_uint32(buf, address, pnanovdb_float_as_uint32(value));
1065}
1066PNANOVDB_FORCE_INLINE void pnanovdb_write_double(pnanovdb_buf_t buf, pnanovdb_address_t address, double value)
1067{
1068 pnanovdb_write_uint64(buf, address, pnanovdb_double_as_uint64(value));
1069}
1070PNANOVDB_FORCE_INLINE void pnanovdb_write_coord(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) value)
1071{
1072 pnanovdb_write_uint32(buf, pnanovdb_address_offset(address, 0u), pnanovdb_int32_as_uint32(PNANOVDB_DEREF(value).x));
1073 pnanovdb_write_uint32(buf, pnanovdb_address_offset(address, 4u), pnanovdb_int32_as_uint32(PNANOVDB_DEREF(value).y));
1074 pnanovdb_write_uint32(buf, pnanovdb_address_offset(address, 8u), pnanovdb_int32_as_uint32(PNANOVDB_DEREF(value).z));
1075}
1076PNANOVDB_FORCE_INLINE void pnanovdb_write_vec3(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_vec3_t) value)
1077{
1078 pnanovdb_write_float(buf, pnanovdb_address_offset(address, 0u), PNANOVDB_DEREF(value).x);
1079 pnanovdb_write_float(buf, pnanovdb_address_offset(address, 4u), PNANOVDB_DEREF(value).y);
1080 pnanovdb_write_float(buf, pnanovdb_address_offset(address, 8u), PNANOVDB_DEREF(value).z);
1081}
1082
1083// ------------------------------------------------ Core Structures -----------------------------------------------------------
1084
1085#define PNANOVDB_MAGIC_NUMBER 0x304244566f6e614eUL// "NanoVDB0" in hex - little endian (uint64_t)
1086#define PNANOVDB_MAGIC_GRID 0x314244566f6e614eUL// "NanoVDB1" in hex - little endian (uint64_t)
1087#define PNANOVDB_MAGIC_FILE 0x324244566f6e614eUL// "NanoVDB2" in hex - little endian (uint64_t)
1088
1089#define PNANOVDB_MAJOR_VERSION_NUMBER 32// reflects changes to the ABI
1090#define PNANOVDB_MINOR_VERSION_NUMBER 8// reflects changes to the API but not ABI
1091#define PNANOVDB_PATCH_VERSION_NUMBER 0// reflects bug-fixes with no ABI or API changes
1092
1093#define PNANOVDB_GRID_TYPE_UNKNOWN 0
1094#define PNANOVDB_GRID_TYPE_FLOAT 1
1095#define PNANOVDB_GRID_TYPE_DOUBLE 2
1096#define PNANOVDB_GRID_TYPE_INT16 3
1097#define PNANOVDB_GRID_TYPE_INT32 4
1098#define PNANOVDB_GRID_TYPE_INT64 5
1099#define PNANOVDB_GRID_TYPE_VEC3F 6
1100#define PNANOVDB_GRID_TYPE_VEC3D 7
1101#define PNANOVDB_GRID_TYPE_MASK 8
1102#define PNANOVDB_GRID_TYPE_HALF 9
1103#define PNANOVDB_GRID_TYPE_UINT32 10
1104#define PNANOVDB_GRID_TYPE_BOOLEAN 11
1105#define PNANOVDB_GRID_TYPE_RGBA8 12
1106#define PNANOVDB_GRID_TYPE_FP4 13
1107#define PNANOVDB_GRID_TYPE_FP8 14
1108#define PNANOVDB_GRID_TYPE_FP16 15
1109#define PNANOVDB_GRID_TYPE_FPN 16
1110#define PNANOVDB_GRID_TYPE_VEC4F 17
1111#define PNANOVDB_GRID_TYPE_VEC4D 18
1112#define PNANOVDB_GRID_TYPE_INDEX 19
1113#define PNANOVDB_GRID_TYPE_ONINDEX 20
1114#define PNANOVDB_GRID_TYPE_INDEXMASK 21
1115#define PNANOVDB_GRID_TYPE_ONINDEXMASK 22
1116#define PNANOVDB_GRID_TYPE_POINTINDEX 23
1117#define PNANOVDB_GRID_TYPE_VEC3U8 24
1118#define PNANOVDB_GRID_TYPE_VEC3U16 25
1119#define PNANOVDB_GRID_TYPE_UINT8 26
1120#define PNANOVDB_GRID_TYPE_END 27
1121
1122#define PNANOVDB_GRID_TYPE_CAP 32
1123
1124#define PNANOVDB_GRID_CLASS_UNKNOWN 0
1125#define PNANOVDB_GRID_CLASS_LEVEL_SET 1 // narrow band level set, e.g. SDF
1126#define PNANOVDB_GRID_CLASS_FOG_VOLUME 2 // fog volume, e.g. density
1127#define PNANOVDB_GRID_CLASS_STAGGERED 3 // staggered MAC grid, e.g. velocity
1128#define PNANOVDB_GRID_CLASS_POINT_INDEX 4 // point index grid
1129#define PNANOVDB_GRID_CLASS_POINT_DATA 5 // point data grid
1130#define PNANOVDB_GRID_CLASS_TOPOLOGY 6 // grid with active states only (no values)
1131#define PNANOVDB_GRID_CLASS_VOXEL_VOLUME 7 // volume of geometric cubes, e.g. minecraft
1132#define PNANOVDB_GRID_CLASS_INDEX_GRID 8 // grid whose values are offsets, e.g. into an external array
1133#define PNANOVDB_GRID_CLASS_TENSOR_GRID 9 // grid which can have extra metadata and features
1134#define PNANOVDB_GRID_CLASS_END 10
1135
1136#define PNANOVDB_GRID_FLAGS_HAS_LONG_GRID_NAME (1 << 0)
1137#define PNANOVDB_GRID_FLAGS_HAS_BBOX (1 << 1)
1138#define PNANOVDB_GRID_FLAGS_HAS_MIN_MAX (1 << 2)
1139#define PNANOVDB_GRID_FLAGS_HAS_AVERAGE (1 << 3)
1140#define PNANOVDB_GRID_FLAGS_HAS_STD_DEVIATION (1 << 4)
1141#define PNANOVDB_GRID_FLAGS_IS_BREADTH_FIRST (1 << 5)
1142#define PNANOVDB_GRID_FLAGS_END (1 << 6)
1143
1144#define PNANOVDB_LEAF_TYPE_DEFAULT 0
1145#define PNANOVDB_LEAF_TYPE_LITE 1
1146#define PNANOVDB_LEAF_TYPE_FP 2
1147#define PNANOVDB_LEAF_TYPE_INDEX 3
1148#define PNANOVDB_LEAF_TYPE_INDEXMASK 4
1149#define PNANOVDB_LEAF_TYPE_POINTINDEX 5
1150
1151// BuildType = Unknown, float, double, int16_t, int32_t, int64_t, Vec3f, Vec3d, Mask, ...
1152// bit count of values in leaf nodes, i.e. 8*sizeof(*nanovdb::LeafNode<BuildType>::mValues) or zero if no values are stored
1153PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_value_strides_bits[PNANOVDB_GRID_TYPE_CAP] = { 0, 32, 64, 16, 32, 64, 96, 192, 0, 16, 32, 1, 32, 4, 8, 16, 0, 128, 256, 0, 0, 0, 0, 16, 24, 48, 8, 0 };
1154// bit count of the Tile union in InternalNodes, i.e. 8*sizeof(nanovdb::InternalData::Tile)
1155PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_table_strides_bits[PNANOVDB_GRID_TYPE_CAP] = { 64, 64, 64, 64, 64, 64, 128, 192, 64, 64, 64, 64, 64, 64, 64, 64, 64, 128, 256, 64, 64, 64, 64, 64, 64, 64, 64, 64 };
1156// bit count of min/max values, i.e. 8*sizeof(nanovdb::LeafData::mMinimum) or zero if no min/max exists
1157PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_minmax_strides_bits[PNANOVDB_GRID_TYPE_CAP] = { 0, 32, 64, 16, 32, 64, 96, 192, 8, 16, 32, 8, 32, 32, 32, 32, 32, 128, 256, 64, 64, 64, 64, 64, 24, 48, 8, 0 };
1158// bit alignment of the value type, controlled by the smallest native type, which is why it is always 0, 8, 16, 32, or 64, e.g. for Vec3f it is 32
1159PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_minmax_aligns_bits[PNANOVDB_GRID_TYPE_CAP] = { 0, 32, 64, 16, 32, 64, 32, 64, 8, 16, 32, 8, 32, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 64, 8, 16, 8, 0 };
1160// bit alignment of the stats (avg/std-dev) types, e.g. 8*sizeof(nanovdb::LeafData::mAverage)
1161PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_stat_strides_bits[PNANOVDB_GRID_TYPE_CAP] = { 0, 32, 64, 32, 32, 64, 32, 64, 8, 32, 32, 8, 32, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 64, 32, 32, 32, 0 };
1162// one of the 4 leaf types defined above, e.g. PNANOVDB_LEAF_TYPE_INDEX = 3
1163PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_leaf_type[PNANOVDB_GRID_TYPE_CAP] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 2, 2, 2, 2, 0, 0, 3, 3, 4, 4, 5, 0, 0, 0, 0 };
1164
1165 struct pnanovdb_map_t
1166{
1167 float matf[9];
1168 float invmatf[9];
1169 float vecf[3];
1170 float taperf;
1171 double matd[9];
1172 double invmatd[9];
1173 double vecd[3];
1174 double taperd;
1175};
1176PNANOVDB_STRUCT_TYPEDEF(pnanovdb_map_t)
1177struct pnanovdb_map_handle_t { pnanovdb_address_t address; };
1178PNANOVDB_STRUCT_TYPEDEF(pnanovdb_map_handle_t)
1179
1180#define PNANOVDB_MAP_SIZE 264
1181
1182#define PNANOVDB_MAP_OFF_MATF 0
1183#define PNANOVDB_MAP_OFF_INVMATF 36
1184#define PNANOVDB_MAP_OFF_VECF 72
1185#define PNANOVDB_MAP_OFF_TAPERF 84
1186#define PNANOVDB_MAP_OFF_MATD 88
1187#define PNANOVDB_MAP_OFF_INVMATD 160
1188#define PNANOVDB_MAP_OFF_VECD 232
1189#define PNANOVDB_MAP_OFF_TAPERD 256
1190
1191PNANOVDB_FORCE_INLINE float pnanovdb_map_get_matf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1192 return pnanovdb_read_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_MATF + 4u * index));
1193}
1194PNANOVDB_FORCE_INLINE float pnanovdb_map_get_invmatf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1195 return pnanovdb_read_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_INVMATF + 4u * index));
1196}
1197PNANOVDB_FORCE_INLINE float pnanovdb_map_get_vecf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1198 return pnanovdb_read_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_VECF + 4u * index));
1199}
1200PNANOVDB_FORCE_INLINE float pnanovdb_map_get_taperf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1201 return pnanovdb_read_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_TAPERF));
1202}
1203PNANOVDB_FORCE_INLINE double pnanovdb_map_get_matd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1204 return pnanovdb_read_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_MATD + 8u * index));
1205}
1206PNANOVDB_FORCE_INLINE double pnanovdb_map_get_invmatd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1207 return pnanovdb_read_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_INVMATD + 8u * index));
1208}
1209PNANOVDB_FORCE_INLINE double pnanovdb_map_get_vecd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1210 return pnanovdb_read_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_VECD + 8u * index));
1211}
1212PNANOVDB_FORCE_INLINE double pnanovdb_map_get_taperd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index) {
1213 return pnanovdb_read_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_TAPERD));
1214}
1215
1216PNANOVDB_FORCE_INLINE void pnanovdb_map_set_matf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float matf) {
1217 pnanovdb_write_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_MATF + 4u * index), matf);
1218}
1219PNANOVDB_FORCE_INLINE void pnanovdb_map_set_invmatf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float invmatf) {
1220 pnanovdb_write_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_INVMATF + 4u * index), invmatf);
1221}
1222PNANOVDB_FORCE_INLINE void pnanovdb_map_set_vecf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float vecf) {
1223 pnanovdb_write_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_VECF + 4u * index), vecf);
1224}
1225PNANOVDB_FORCE_INLINE void pnanovdb_map_set_taperf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float taperf) {
1226 pnanovdb_write_float(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_TAPERF), taperf);
1227}
1228PNANOVDB_FORCE_INLINE void pnanovdb_map_set_matd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double matd) {
1229 pnanovdb_write_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_MATD + 8u * index), matd);
1230}
1231PNANOVDB_FORCE_INLINE void pnanovdb_map_set_invmatd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double invmatd) {
1232 pnanovdb_write_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_INVMATD + 8u * index), invmatd);
1233}
1234PNANOVDB_FORCE_INLINE void pnanovdb_map_set_vecd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double vecd) {
1235 pnanovdb_write_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_VECD + 8u * index), vecd);
1236}
1237PNANOVDB_FORCE_INLINE void pnanovdb_map_set_taperd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double taperd) {
1238 pnanovdb_write_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_MAP_OFF_TAPERD), taperd);
1239}
1240
1241 struct pnanovdb_grid_t
1242{
1243 pnanovdb_uint64_t magic; // 8 bytes, 0
1244 pnanovdb_uint64_t checksum; // 8 bytes, 8
1245 pnanovdb_uint32_t version; // 4 bytes, 16
1246 pnanovdb_uint32_t flags; // 4 bytes, 20
1247 pnanovdb_uint32_t grid_index; // 4 bytes, 24
1248 pnanovdb_uint32_t grid_count; // 4 bytes, 28
1249 pnanovdb_uint64_t grid_size; // 8 bytes, 32
1250 pnanovdb_uint32_t grid_name[256 / 4]; // 256 bytes, 40
1251 pnanovdb_map_t map; // 264 bytes, 296
1252 double world_bbox[6]; // 48 bytes, 560
1253 double voxel_size[3]; // 24 bytes, 608
1254 pnanovdb_uint32_t grid_class; // 4 bytes, 632
1255 pnanovdb_uint32_t grid_type; // 4 bytes, 636
1256 pnanovdb_int64_t blind_metadata_offset; // 8 bytes, 640
1257 pnanovdb_uint32_t blind_metadata_count; // 4 bytes, 648
1258 pnanovdb_uint32_t data0; // 4 bytes, 652
1259 pnanovdb_uint64_t data1; // 8 bytes, 656
1260 pnanovdb_uint64_t data2; // 8 bytes, 664
1261};
1262PNANOVDB_STRUCT_TYPEDEF(pnanovdb_grid_t)
1263struct pnanovdb_grid_handle_t { pnanovdb_address_t address; };
1264PNANOVDB_STRUCT_TYPEDEF(pnanovdb_grid_handle_t)
1265
1266#define PNANOVDB_GRID_SIZE 672
1267
1268#define PNANOVDB_GRID_OFF_MAGIC 0
1269#define PNANOVDB_GRID_OFF_CHECKSUM 8
1270#define PNANOVDB_GRID_OFF_VERSION 16
1271#define PNANOVDB_GRID_OFF_FLAGS 20
1272#define PNANOVDB_GRID_OFF_GRID_INDEX 24
1273#define PNANOVDB_GRID_OFF_GRID_COUNT 28
1274#define PNANOVDB_GRID_OFF_GRID_SIZE 32
1275#define PNANOVDB_GRID_OFF_GRID_NAME 40
1276#define PNANOVDB_GRID_OFF_MAP 296
1277#define PNANOVDB_GRID_OFF_WORLD_BBOX 560
1278#define PNANOVDB_GRID_OFF_VOXEL_SIZE 608
1279#define PNANOVDB_GRID_OFF_GRID_CLASS 632
1280#define PNANOVDB_GRID_OFF_GRID_TYPE 636
1281#define PNANOVDB_GRID_OFF_BLIND_METADATA_OFFSET 640
1282#define PNANOVDB_GRID_OFF_BLIND_METADATA_COUNT 648
1283#define PNANOVDB_GRID_OFF_DATA0 652
1284#define PNANOVDB_GRID_OFF_DATA1 656
1285#define PNANOVDB_GRID_OFF_DATA2 664
1286
1287PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_magic(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1288 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_MAGIC));
1289}
1290PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_checksum(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1291 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_CHECKSUM));
1292}
1293PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_version(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1294 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_VERSION));
1295}
1296PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_flags(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1297 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_FLAGS));
1298}
1299PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_index(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1300 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_INDEX));
1301}
1302PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1303 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_COUNT));
1304}
1305PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_grid_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1306 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_SIZE));
1307}
1308PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_name(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index) {
1309 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_NAME + 4u * index));
1310}
1311PNANOVDB_FORCE_INLINE pnanovdb_map_handle_t pnanovdb_grid_get_map(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1312 pnanovdb_map_handle_t ret;
1313 ret.address = pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_MAP);
1314 return ret;
1315}
1316PNANOVDB_FORCE_INLINE double pnanovdb_grid_get_world_bbox(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index) {
1317 return pnanovdb_read_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_WORLD_BBOX + 8u * index));
1318}
1319PNANOVDB_FORCE_INLINE double pnanovdb_grid_get_voxel_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index) {
1320 return pnanovdb_read_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_VOXEL_SIZE + 8u * index));
1321}
1322PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_class(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1323 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_CLASS));
1324}
1325PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_type(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1326 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_TYPE));
1327}
1328PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_grid_get_blind_metadata_offset(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1329 return pnanovdb_read_int64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_BLIND_METADATA_OFFSET));
1330}
1331PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_blind_metadata_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1332 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_BLIND_METADATA_COUNT));
1333}
1334PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_data0(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1335 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_DATA0));
1336}
1337PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_data1(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1338 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_DATA1));
1339}
1340PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_data2(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p) {
1341 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_DATA2));
1342}
1343
1344PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_magic(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t magic) {
1345 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_MAGIC), magic);
1346}
1347PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_checksum(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t checksum) {
1348 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_CHECKSUM), checksum);
1349}
1350PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_version(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t version) {
1351 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_VERSION), version);
1352}
1353PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_flags(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t flags) {
1354 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_FLAGS), flags);
1355}
1356PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_index(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_index) {
1357 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_INDEX), grid_index);
1358}
1359PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_count) {
1360 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_COUNT), grid_count);
1361}
1362PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t grid_size) {
1363 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_SIZE), grid_size);
1364}
1365PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_name(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index, pnanovdb_uint32_t grid_name) {
1366 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_NAME + 4u * index), grid_name);
1367}
1368PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_world_bbox(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index, double world_bbox) {
1369 pnanovdb_write_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_WORLD_BBOX + 8u * index), world_bbox);
1370}
1371PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_voxel_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index, double voxel_size) {
1372 pnanovdb_write_double(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_VOXEL_SIZE + 8u * index), voxel_size);
1373}
1374PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_class(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_class) {
1375 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_CLASS), grid_class);
1376}
1377PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_type(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_type) {
1378 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_GRID_TYPE), grid_type);
1379}
1380PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_blind_metadata_offset(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t blind_metadata_offset) {
1381 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_BLIND_METADATA_OFFSET), blind_metadata_offset);
1382}
1383PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_blind_metadata_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t metadata_count) {
1384 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_BLIND_METADATA_COUNT), metadata_count);
1385}
1386PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_data0(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t data0) {
1387 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_DATA0), data0);
1388}
1389PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_data1(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t data1) {
1390 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_DATA1), data1);
1391}
1392PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_data2(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t data2) {
1393 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRID_OFF_DATA2), data2);
1394}
1395
1396PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_make_version(pnanovdb_uint32_t major, pnanovdb_uint32_t minor, pnanovdb_uint32_t patch_num)
1397{
1398 return (major << 21u) | (minor << 10u) | patch_num;
1399}
1400
1401PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_version_get_major(pnanovdb_uint32_t version)
1402{
1403 return (version >> 21u) & ((1u << 11u) - 1u);
1404}
1405PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_version_get_minor(pnanovdb_uint32_t version)
1406{
1407 return (version >> 10u) & ((1u << 11u) - 1u);
1408}
1409PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_version_get_patch(pnanovdb_uint32_t version)
1410{
1411 return version & ((1u << 10u) - 1u);
1412}
1413
1414#define PNANOVDB_GRIDBLINDMETADATA_CLASS_UNKNOWN 0
1415#define PNANOVDB_GRIDBLINDMETADATA_CLASS_INDEX_ARRAY 1
1416#define PNANOVDB_GRIDBLINDMETADATA_CLASS_ATTRIBUTE_ARRAY 2
1417#define PNANOVDB_GRIDBLINDMETADATA_CLASS_GRID_NAME 3
1418#define PNANOVDB_GRIDBLINDMETADATA_CLASS_CHANNEL_ARRAY 4
1419#define PNANOVDB_GRIDBLINDMETADATA_CLASS_END 5
1420
1421#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_UNKNOWN 0
1422#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_POINT_POSITION 1
1423#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_POINT_COLOR 2
1424#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_POINT_NORMAL 3
1425#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_POINT_RADIUS 4
1426#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_POINT_VELOCITY 5
1427#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_POINT_ID 6
1428#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_WORLD_COORDS 7
1429#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_GRID_COORDS 8
1430#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_VOXEL_COORDS 9
1431#define PNANOVDB_GRIDBLINDMETADATA_SEMANTIC_END 10
1432
1433 struct pnanovdb_gridblindmetadata_t
1434{
1435 pnanovdb_int64_t data_offset; // 8 bytes, 0
1436 pnanovdb_uint64_t value_count; // 8 bytes, 8
1437 pnanovdb_uint32_t value_size; // 4 bytes, 16
1438 pnanovdb_uint32_t semantic; // 4 bytes, 20
1439 pnanovdb_uint32_t data_class; // 4 bytes, 24
1440 pnanovdb_uint32_t data_type; // 4 bytes, 28
1441 pnanovdb_uint32_t name[256 / 4]; // 256 bytes, 32
1442};
1443PNANOVDB_STRUCT_TYPEDEF(pnanovdb_gridblindmetadata_t)
1444struct pnanovdb_gridblindmetadata_handle_t { pnanovdb_address_t address; };
1445PNANOVDB_STRUCT_TYPEDEF(pnanovdb_gridblindmetadata_handle_t)
1446
1447#define PNANOVDB_GRIDBLINDMETADATA_SIZE 288
1448
1449#define PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_OFFSET 0
1450#define PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_COUNT 8
1451#define PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_SIZE 16
1452#define PNANOVDB_GRIDBLINDMETADATA_OFF_SEMANTIC 20
1453#define PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_CLASS 24
1454#define PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_TYPE 28
1455#define PNANOVDB_GRIDBLINDMETADATA_OFF_NAME 32
1456
1457PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_gridblindmetadata_get_data_offset(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p) {
1458 return pnanovdb_read_int64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_OFFSET));
1459}
1460PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_gridblindmetadata_get_value_count(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p) {
1461 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_COUNT));
1462}
1463PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_value_size(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p) {
1464 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_SIZE));
1465}
1466PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_semantic(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p) {
1467 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_SEMANTIC));
1468}
1469PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_data_class(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p) {
1470 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_CLASS));
1471}
1472PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_data_type(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p) {
1473 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_TYPE));
1474}
1475PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_name(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t index) {
1476 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_NAME + 4u * index));
1477}
1478
1479PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_data_offset(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_int64_t data_offset) {
1480 pnanovdb_write_int64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_OFFSET), data_offset);
1481}
1482PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_value_count(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint64_t value_count) {
1483 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_COUNT), value_count);
1484}
1485PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_value_size(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t value_size) {
1486 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_SIZE), value_size);
1487}
1488PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_semantic(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t semantic) {
1489 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_SEMANTIC), semantic);
1490}
1491PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_data_class(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t data_class) {
1492 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_CLASS), data_class);
1493}
1494PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_data_type(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t data_type) {
1495 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_TYPE), data_type);
1496}
1497PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_name(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t index, pnanovdb_uint32_t name) {
1498 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_GRIDBLINDMETADATA_OFF_NAME + 4u * index), name);
1499}
1500
1501 struct pnanovdb_tree_t
1502{
1503 pnanovdb_uint64_t node_offset_leaf;
1504 pnanovdb_uint64_t node_offset_lower;
1505 pnanovdb_uint64_t node_offset_upper;
1506 pnanovdb_uint64_t node_offset_root;
1507 pnanovdb_uint32_t node_count_leaf;
1508 pnanovdb_uint32_t node_count_lower;
1509 pnanovdb_uint32_t node_count_upper;
1510 pnanovdb_uint32_t tile_count_lower;
1511 pnanovdb_uint32_t tile_count_upper;
1512 pnanovdb_uint32_t tile_count_root;
1513 pnanovdb_uint64_t voxel_count;
1514};
1515PNANOVDB_STRUCT_TYPEDEF(pnanovdb_tree_t)
1516struct pnanovdb_tree_handle_t { pnanovdb_address_t address; };
1517PNANOVDB_STRUCT_TYPEDEF(pnanovdb_tree_handle_t)
1518
1519#define PNANOVDB_TREE_SIZE 64
1520
1521#define PNANOVDB_TREE_OFF_NODE_OFFSET_LEAF 0
1522#define PNANOVDB_TREE_OFF_NODE_OFFSET_LOWER 8
1523#define PNANOVDB_TREE_OFF_NODE_OFFSET_UPPER 16
1524#define PNANOVDB_TREE_OFF_NODE_OFFSET_ROOT 24
1525#define PNANOVDB_TREE_OFF_NODE_COUNT_LEAF 32
1526#define PNANOVDB_TREE_OFF_NODE_COUNT_LOWER 36
1527#define PNANOVDB_TREE_OFF_NODE_COUNT_UPPER 40
1528#define PNANOVDB_TREE_OFF_TILE_COUNT_LOWER 44
1529#define PNANOVDB_TREE_OFF_TILE_COUNT_UPPER 48
1530#define PNANOVDB_TREE_OFF_TILE_COUNT_ROOT 52
1531#define PNANOVDB_TREE_OFF_VOXEL_COUNT 56
1532
1533PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1534 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_LEAF));
1535}
1536PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1537 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_LOWER));
1538}
1539PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1540 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_UPPER));
1541}
1542PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1543 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_ROOT));
1544}
1545PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_node_count_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1546 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_COUNT_LEAF));
1547}
1548PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_node_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1549 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_COUNT_LOWER));
1550}
1551PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_node_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1552 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_COUNT_UPPER));
1553}
1554PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_tile_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1555 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_TILE_COUNT_LOWER));
1556}
1557PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_tile_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1558 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_TILE_COUNT_UPPER));
1559}
1560PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_tile_count_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1561 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_TILE_COUNT_ROOT));
1562}
1563PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_voxel_count(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p) {
1564 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_VOXEL_COUNT));
1565}
1566
1567PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_leaf) {
1568 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_LEAF), node_offset_leaf);
1569}
1570PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_lower) {
1571 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_LOWER), node_offset_lower);
1572}
1573PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_upper) {
1574 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_UPPER), node_offset_upper);
1575}
1576PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_root) {
1577 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_OFFSET_ROOT), node_offset_root);
1578}
1579PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_count_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t node_count_leaf) {
1580 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_COUNT_LEAF), node_count_leaf);
1581}
1582PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t node_count_lower) {
1583 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_COUNT_LOWER), node_count_lower);
1584}
1585PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t node_count_upper) {
1586 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_NODE_COUNT_UPPER), node_count_upper);
1587}
1588PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_tile_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t tile_count_lower) {
1589 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_TILE_COUNT_LOWER), tile_count_lower);
1590}
1591PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_tile_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t tile_count_upper) {
1592 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_TILE_COUNT_UPPER), tile_count_upper);
1593}
1594PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_tile_count_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t tile_count_root) {
1595 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_TILE_COUNT_ROOT), tile_count_root);
1596}
1597PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_voxel_count(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t voxel_count) {
1598 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_TREE_OFF_VOXEL_COUNT), voxel_count);
1599}
1600
1601 struct pnanovdb_root_t
1602{
1603 pnanovdb_coord_t bbox_min;
1604 pnanovdb_coord_t bbox_max;
1605 pnanovdb_uint32_t table_size;
1606 pnanovdb_uint32_t pad1; // background can start here
1607 // background, min, max
1608};
1609PNANOVDB_STRUCT_TYPEDEF(pnanovdb_root_t)
1610struct pnanovdb_root_handle_t { pnanovdb_address_t address; };
1611PNANOVDB_STRUCT_TYPEDEF(pnanovdb_root_handle_t)
1612
1613#define PNANOVDB_ROOT_BASE_SIZE 28
1614
1615#define PNANOVDB_ROOT_OFF_BBOX_MIN 0
1616#define PNANOVDB_ROOT_OFF_BBOX_MAX 12
1617#define PNANOVDB_ROOT_OFF_TABLE_SIZE 24
1618
1619PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_root_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_root_handle_t p) {
1620 return pnanovdb_read_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_OFF_BBOX_MIN));
1621}
1622PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_root_get_bbox_max(pnanovdb_buf_t buf, pnanovdb_root_handle_t p) {
1623 return pnanovdb_read_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_OFF_BBOX_MAX));
1624}
1625PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_root_get_tile_count(pnanovdb_buf_t buf, pnanovdb_root_handle_t p) {
1626 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_OFF_TABLE_SIZE));
1627}
1628
1629PNANOVDB_FORCE_INLINE void pnanovdb_root_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_root_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min) {
1630 pnanovdb_write_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_OFF_BBOX_MIN), bbox_min);
1631}
1632PNANOVDB_FORCE_INLINE void pnanovdb_root_set_bbox_max(pnanovdb_buf_t buf, pnanovdb_root_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_max) {
1633 pnanovdb_write_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_OFF_BBOX_MAX), bbox_max);
1634}
1635PNANOVDB_FORCE_INLINE void pnanovdb_root_set_tile_count(pnanovdb_buf_t buf, pnanovdb_root_handle_t p, pnanovdb_uint32_t tile_count) {
1636 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_OFF_TABLE_SIZE), tile_count);
1637}
1638
1639 struct pnanovdb_root_tile_t
1640{
1641 pnanovdb_uint64_t key;
1642 pnanovdb_int64_t child; // signed byte offset from root to the child node, 0 means it is a constant tile, so use value
1643 pnanovdb_uint32_t state;
1644 pnanovdb_uint32_t pad1; // value can start here
1645 // value
1646};
1647PNANOVDB_STRUCT_TYPEDEF(pnanovdb_root_tile_t)
1648struct pnanovdb_root_tile_handle_t { pnanovdb_address_t address; };
1649PNANOVDB_STRUCT_TYPEDEF(pnanovdb_root_tile_handle_t)
1650
1651#define PNANOVDB_ROOT_TILE_BASE_SIZE 20
1652
1653#define PNANOVDB_ROOT_TILE_OFF_KEY 0
1654#define PNANOVDB_ROOT_TILE_OFF_CHILD 8
1655#define PNANOVDB_ROOT_TILE_OFF_STATE 16
1656
1657PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_tile_get_key(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p) {
1658 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_TILE_OFF_KEY));
1659}
1660PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_root_tile_get_child(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p) {
1661 return pnanovdb_read_int64(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_TILE_OFF_CHILD));
1662}
1663PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_root_tile_get_state(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p) {
1664 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_TILE_OFF_STATE));
1665}
1666
1667PNANOVDB_FORCE_INLINE void pnanovdb_root_tile_set_key(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p, pnanovdb_uint64_t key) {
1668 pnanovdb_write_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_TILE_OFF_KEY), key);
1669}
1670PNANOVDB_FORCE_INLINE void pnanovdb_root_tile_set_child(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p, pnanovdb_int64_t child) {
1671 pnanovdb_write_int64(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_TILE_OFF_CHILD), child);
1672}
1673PNANOVDB_FORCE_INLINE void pnanovdb_root_tile_set_state(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p, pnanovdb_uint32_t state) {
1674 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_ROOT_TILE_OFF_STATE), state);
1675}
1676
1677 struct pnanovdb_upper_t
1678{
1679 pnanovdb_coord_t bbox_min;
1680 pnanovdb_coord_t bbox_max;
1681 pnanovdb_uint64_t flags;
1682 pnanovdb_uint32_t value_mask[1024];
1683 pnanovdb_uint32_t child_mask[1024];
1684 // min, max
1685 // alignas(32) pnanovdb_uint32_t table[];
1686};
1687PNANOVDB_STRUCT_TYPEDEF(pnanovdb_upper_t)
1688struct pnanovdb_upper_handle_t { pnanovdb_address_t address; };
1689PNANOVDB_STRUCT_TYPEDEF(pnanovdb_upper_handle_t)
1690
1691#define PNANOVDB_UPPER_TABLE_COUNT 32768
1692#define PNANOVDB_UPPER_BASE_SIZE 8224
1693
1694#define PNANOVDB_UPPER_OFF_BBOX_MIN 0
1695#define PNANOVDB_UPPER_OFF_BBOX_MAX 12
1696#define PNANOVDB_UPPER_OFF_FLAGS 24
1697#define PNANOVDB_UPPER_OFF_VALUE_MASK 32
1698#define PNANOVDB_UPPER_OFF_CHILD_MASK 4128
1699
1700PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_upper_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p) {
1701 return pnanovdb_read_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_BBOX_MIN));
1702}
1703PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_upper_get_bbox_max(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p) {
1704 return pnanovdb_read_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_BBOX_MAX));
1705}
1706PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_upper_get_flags(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p) {
1707 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_FLAGS));
1708}
1709PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_upper_get_value_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index) {
1710 pnanovdb_uint32_t value = pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_VALUE_MASK + 4u * (bit_index >> 5u)));
1711 return ((value >> (bit_index & 31u)) & 1) != 0u;
1712}
1713PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_upper_get_child_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index) {
1714 pnanovdb_uint32_t value = pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_CHILD_MASK + 4u * (bit_index >> 5u)));
1715 return ((value >> (bit_index & 31u)) & 1) != 0u;
1716}
1717
1718PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min) {
1719 pnanovdb_write_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_BBOX_MIN), bbox_min);
1720}
1721PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_bbox_max(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_max) {
1722 pnanovdb_write_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_BBOX_MAX), bbox_max);
1723}
1724PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_value_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value) {
1725 pnanovdb_address_t addr = pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_VALUE_MASK + 4u * (bit_index >> 5u));
1726 pnanovdb_uint32_t valueMask = pnanovdb_read_uint32(buf, addr);
1727 if (!value) { valueMask &= ~(1u << (bit_index & 31u)); }
1728 if (value) valueMask |= (1u << (bit_index & 31u));
1729 pnanovdb_write_uint32(buf, addr, valueMask);
1730}
1731PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_child_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value) {
1732 pnanovdb_address_t addr = pnanovdb_address_offset(p.address, PNANOVDB_UPPER_OFF_CHILD_MASK + 4u * (bit_index >> 5u));
1733 pnanovdb_uint32_t valueMask = pnanovdb_read_uint32(buf, addr);
1734 if (!value) { valueMask &= ~(1u << (bit_index & 31u)); }
1735 if (value) valueMask |= (1u << (bit_index & 31u));
1736 pnanovdb_write_uint32(buf, addr, valueMask);
1737}
1738
1739 struct pnanovdb_lower_t
1740{
1741 pnanovdb_coord_t bbox_min;
1742 pnanovdb_coord_t bbox_max;
1743 pnanovdb_uint64_t flags;
1744 pnanovdb_uint32_t value_mask[128];
1745 pnanovdb_uint32_t child_mask[128];
1746 // min, max
1747 // alignas(32) pnanovdb_uint32_t table[];
1748};
1749PNANOVDB_STRUCT_TYPEDEF(pnanovdb_lower_t)
1750struct pnanovdb_lower_handle_t { pnanovdb_address_t address; };
1751PNANOVDB_STRUCT_TYPEDEF(pnanovdb_lower_handle_t)
1752
1753#define PNANOVDB_LOWER_TABLE_COUNT 4096
1754#define PNANOVDB_LOWER_BASE_SIZE 1056
1755
1756#define PNANOVDB_LOWER_OFF_BBOX_MIN 0
1757#define PNANOVDB_LOWER_OFF_BBOX_MAX 12
1758#define PNANOVDB_LOWER_OFF_FLAGS 24
1759#define PNANOVDB_LOWER_OFF_VALUE_MASK 32
1760#define PNANOVDB_LOWER_OFF_CHILD_MASK 544
1761
1762PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_lower_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p) {
1763 return pnanovdb_read_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_BBOX_MIN));
1764}
1765PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_lower_get_bbox_max(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p) {
1766 return pnanovdb_read_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_BBOX_MAX));
1767}
1768PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_lower_get_flags(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p) {
1769 return pnanovdb_read_uint64(buf, pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_FLAGS));
1770}
1771PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_lower_get_value_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index) {
1772 pnanovdb_uint32_t value = pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_VALUE_MASK + 4u * (bit_index >> 5u)));
1773 return ((value >> (bit_index & 31u)) & 1) != 0u;
1774}
1775PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_lower_get_child_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index) {
1776 pnanovdb_uint32_t value = pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_CHILD_MASK + 4u * (bit_index >> 5u)));
1777 return ((value >> (bit_index & 31u)) & 1) != 0u;
1778}
1779
1780PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min) {
1781 pnanovdb_write_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_BBOX_MIN), bbox_min);
1782}
1783PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_bbox_max(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_max) {
1784 pnanovdb_write_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_BBOX_MAX), bbox_max);
1785}
1786PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_value_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value) {
1787 pnanovdb_address_t addr = pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_VALUE_MASK + 4u * (bit_index >> 5u));
1788 pnanovdb_uint32_t valueMask = pnanovdb_read_uint32(buf, addr);
1789 if (!value) { valueMask &= ~(1u << (bit_index & 31u)); }
1790 if (value) valueMask |= (1u << (bit_index & 31u));
1791 pnanovdb_write_uint32(buf, addr, valueMask);
1792}
1793PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_child_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value) {
1794 pnanovdb_address_t addr = pnanovdb_address_offset(p.address, PNANOVDB_LOWER_OFF_CHILD_MASK + 4u * (bit_index >> 5u));
1795 pnanovdb_uint32_t valueMask = pnanovdb_read_uint32(buf, addr);
1796 if (!value) { valueMask &= ~(1u << (bit_index & 31u)); }
1797 if (value) valueMask |= (1u << (bit_index & 31u));
1798 pnanovdb_write_uint32(buf, addr, valueMask);
1799}
1800
1801 struct pnanovdb_leaf_t
1802{
1803 pnanovdb_coord_t bbox_min;
1804 pnanovdb_uint32_t bbox_dif_and_flags;
1805 pnanovdb_uint32_t value_mask[16];
1806 // min, max
1807 // alignas(32) pnanovdb_uint32_t values[];
1808};
1809PNANOVDB_STRUCT_TYPEDEF(pnanovdb_leaf_t)
1810struct pnanovdb_leaf_handle_t { pnanovdb_address_t address; };
1811PNANOVDB_STRUCT_TYPEDEF(pnanovdb_leaf_handle_t)
1812
1813#define PNANOVDB_LEAF_TABLE_COUNT 512
1814#define PNANOVDB_LEAF_BASE_SIZE 80
1815
1816#define PNANOVDB_LEAF_OFF_BBOX_MIN 0
1817#define PNANOVDB_LEAF_OFF_BBOX_DIF_AND_FLAGS 12
1818#define PNANOVDB_LEAF_OFF_VALUE_MASK 16
1819
1820#define PNANOVDB_LEAF_TABLE_NEG_OFF_BBOX_DIF_AND_FLAGS 84
1821#define PNANOVDB_LEAF_TABLE_NEG_OFF_MINIMUM 16
1822#define PNANOVDB_LEAF_TABLE_NEG_OFF_QUANTUM 12
1823
1824PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_leaf_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p) {
1825 return pnanovdb_read_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_LEAF_OFF_BBOX_MIN));
1826}
1827PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_get_bbox_dif_and_flags(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p) {
1828 return pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_LEAF_OFF_BBOX_DIF_AND_FLAGS));
1829}
1830PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_get_value_mask(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, pnanovdb_uint32_t bit_index) {
1831 pnanovdb_uint32_t value = pnanovdb_read_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 4u * (bit_index >> 5u)));
1832 return ((value >> (bit_index & 31u)) & 1) != 0u;
1833}
1834
1835PNANOVDB_FORCE_INLINE void pnanovdb_leaf_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min) {
1836 pnanovdb_write_coord(buf, pnanovdb_address_offset(p.address, PNANOVDB_LEAF_OFF_BBOX_MIN), bbox_min);
1837}
1838PNANOVDB_FORCE_INLINE void pnanovdb_leaf_set_bbox_dif_and_flags(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, pnanovdb_uint32_t bbox_dif_and_flags) {
1839 pnanovdb_write_uint32(buf, pnanovdb_address_offset(p.address, PNANOVDB_LEAF_OFF_BBOX_DIF_AND_FLAGS), bbox_dif_and_flags);
1840}
1841PNANOVDB_FORCE_INLINE void pnanovdb_leaf_set_value_mask(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value) {
1842 pnanovdb_address_t addr = pnanovdb_address_offset(p.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 4u * (bit_index >> 5u));
1843 pnanovdb_uint32_t valueMask = pnanovdb_read_uint32(buf, addr);
1844 if (!value) { valueMask &= ~(1u << (bit_index & 31u)); }
1845 if (value) valueMask |= (1u << (bit_index & 31u));
1846 pnanovdb_write_uint32(buf, addr, valueMask);
1847}
1848
1849 struct pnanovdb_grid_type_constants_t
1850{
1851 pnanovdb_uint32_t root_off_background;
1852 pnanovdb_uint32_t root_off_min;
1853 pnanovdb_uint32_t root_off_max;
1854 pnanovdb_uint32_t root_off_ave;
1855 pnanovdb_uint32_t root_off_stddev;
1856 pnanovdb_uint32_t root_size;
1857 pnanovdb_uint32_t value_stride_bits;
1858 pnanovdb_uint32_t table_stride;
1859 pnanovdb_uint32_t root_tile_off_value;
1860 pnanovdb_uint32_t root_tile_size;
1861 pnanovdb_uint32_t upper_off_min;
1862 pnanovdb_uint32_t upper_off_max;
1863 pnanovdb_uint32_t upper_off_ave;
1864 pnanovdb_uint32_t upper_off_stddev;
1865 pnanovdb_uint32_t upper_off_table;
1866 pnanovdb_uint32_t upper_size;
1867 pnanovdb_uint32_t lower_off_min;
1868 pnanovdb_uint32_t lower_off_max;
1869 pnanovdb_uint32_t lower_off_ave;
1870 pnanovdb_uint32_t lower_off_stddev;
1871 pnanovdb_uint32_t lower_off_table;
1872 pnanovdb_uint32_t lower_size;
1873 pnanovdb_uint32_t leaf_off_min;
1874 pnanovdb_uint32_t leaf_off_max;
1875 pnanovdb_uint32_t leaf_off_ave;
1876 pnanovdb_uint32_t leaf_off_stddev;
1877 pnanovdb_uint32_t leaf_off_table;
1878 pnanovdb_uint32_t leaf_size;
1879};
1880PNANOVDB_STRUCT_TYPEDEF(pnanovdb_grid_type_constants_t)
1881
1882// The following table with offsets will nedd to be updates as new GridTypes are added in NanoVDB.h
1883PNANOVDB_STATIC_CONST pnanovdb_grid_type_constants_t pnanovdb_grid_type_constants[PNANOVDB_GRID_TYPE_CAP] =
1884{
1885{28, 28, 28, 28, 28, 32, 0, 8, 20, 32, 8224, 8224, 8224, 8224, 8224, 270368, 1056, 1056, 1056, 1056, 1056, 33824, 80, 80, 80, 80, 96, 96},
1886{28, 32, 36, 40, 44, 64, 32, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 80, 84, 88, 92, 96, 2144},
1887{32, 40, 48, 56, 64, 96, 64, 8, 24, 32, 8224, 8232, 8240, 8248, 8256, 270400, 1056, 1064, 1072, 1080, 1088, 33856, 80, 88, 96, 104, 128, 4224},
1888{28, 30, 32, 36, 40, 64, 16, 8, 20, 32, 8224, 8226, 8228, 8232, 8256, 270400, 1056, 1058, 1060, 1064, 1088, 33856, 80, 82, 84, 88, 96, 1120},
1889{28, 32, 36, 40, 44, 64, 32, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 80, 84, 88, 92, 96, 2144},
1890{32, 40, 48, 56, 64, 96, 64, 8, 24, 32, 8224, 8232, 8240, 8248, 8256, 270400, 1056, 1064, 1072, 1080, 1088, 33856, 80, 88, 96, 104, 128, 4224},
1891{28, 40, 52, 64, 68, 96, 96, 16, 20, 32, 8224, 8236, 8248, 8252, 8256, 532544, 1056, 1068, 1080, 1084, 1088, 66624, 80, 92, 104, 108, 128, 6272},
1892{32, 56, 80, 104, 112, 128, 192, 24, 24, 64, 8224, 8248, 8272, 8280, 8288, 794720, 1056, 1080, 1104, 1112, 1120, 99424, 80, 104, 128, 136, 160, 12448},
1893{28, 29, 30, 31, 32, 64, 0, 8, 20, 32, 8224, 8225, 8226, 8227, 8256, 270400, 1056, 1057, 1058, 1059, 1088, 33856, 80, 80, 80, 80, 96, 96},
1894{28, 30, 32, 36, 40, 64, 16, 8, 20, 32, 8224, 8226, 8228, 8232, 8256, 270400, 1056, 1058, 1060, 1064, 1088, 33856, 80, 82, 84, 88, 96, 1120},
1895{28, 32, 36, 40, 44, 64, 32, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 80, 84, 88, 92, 96, 2144},
1896{28, 29, 30, 31, 32, 64, 1, 8, 20, 32, 8224, 8225, 8226, 8227, 8256, 270400, 1056, 1057, 1058, 1059, 1088, 33856, 80, 80, 80, 80, 96, 160},
1897{28, 32, 36, 40, 44, 64, 32, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 80, 84, 88, 92, 96, 2144},
1898{28, 32, 36, 40, 44, 64, 0, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 88, 90, 92, 94, 96, 352},
1899{28, 32, 36, 40, 44, 64, 0, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 88, 90, 92, 94, 96, 608},
1900{28, 32, 36, 40, 44, 64, 0, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 88, 90, 92, 94, 96, 1120},
1901{28, 32, 36, 40, 44, 64, 0, 8, 20, 32, 8224, 8228, 8232, 8236, 8256, 270400, 1056, 1060, 1064, 1068, 1088, 33856, 88, 90, 92, 94, 96, 96},
1902{28, 44, 60, 76, 80, 96, 128, 16, 20, 64, 8224, 8240, 8256, 8260, 8288, 532576, 1056, 1072, 1088, 1092, 1120, 66656, 80, 96, 112, 116, 128, 8320},
1903{32, 64, 96, 128, 136, 160, 256, 32, 24, 64, 8224, 8256, 8288, 8296, 8320, 1056896, 1056, 1088, 1120, 1128, 1152, 132224, 80, 112, 144, 152, 160, 16544},
1904{32, 40, 48, 56, 64, 96, 0, 8, 24, 32, 8224, 8232, 8240, 8248, 8256, 270400, 1056, 1064, 1072, 1080, 1088, 33856, 80, 80, 80, 80, 80, 96},
1905{32, 40, 48, 56, 64, 96, 0, 8, 24, 32, 8224, 8232, 8240, 8248, 8256, 270400, 1056, 1064, 1072, 1080, 1088, 33856, 80, 80, 80, 80, 80, 96},
1906{32, 40, 48, 56, 64, 96, 0, 8, 24, 32, 8224, 8232, 8240, 8248, 8256, 270400, 1056, 1064, 1072, 1080, 1088, 33856, 80, 80, 80, 80, 80, 160},
1907{32, 40, 48, 56, 64, 96, 0, 8, 24, 32, 8224, 8232, 8240, 8248, 8256, 270400, 1056, 1064, 1072, 1080, 1088, 33856, 80, 80, 80, 80, 80, 160},
1908{32, 40, 48, 56, 64, 96, 16, 8, 24, 32, 8224, 8232, 8240, 8248, 8256, 270400, 1056, 1064, 1072, 1080, 1088, 33856, 80, 88, 96, 96, 96, 1120},
1909{28, 31, 34, 40, 44, 64, 24, 8, 20, 32, 8224, 8227, 8232, 8236, 8256, 270400, 1056, 1059, 1064, 1068, 1088, 33856, 80, 83, 88, 92, 96, 1632},
1910{28, 34, 40, 48, 52, 64, 48, 8, 20, 32, 8224, 8230, 8236, 8240, 8256, 270400, 1056, 1062, 1068, 1072, 1088, 33856, 80, 86, 92, 96, 128, 3200},
1911{28, 29, 30, 32, 36, 64, 8, 8, 20, 32, 8224, 8225, 8228, 8232, 8256, 270400, 1056, 1057, 1060, 1064, 1088, 33856, 80, 81, 84, 88, 96, 608},
1912{28, 28, 28, 28, 28, 32, 0, 8, 20, 32, 8224, 8224, 8224, 8224, 8224, 270368, 1056, 1056, 1056, 1056, 1056, 33824, 80, 80, 80, 80, 96, 96},
1913};
1914
1915// ------------------------------------------------ Basic Lookup -----------------------------------------------------------
1916
1917PNANOVDB_FORCE_INLINE pnanovdb_gridblindmetadata_handle_t pnanovdb_grid_get_gridblindmetadata(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, pnanovdb_uint32_t index)
1918{
1919 pnanovdb_gridblindmetadata_handle_t meta = { grid.address };
1920 pnanovdb_uint64_t byte_offset = pnanovdb_grid_get_blind_metadata_offset(buf, grid);
1921 meta.address = pnanovdb_address_offset64(meta.address, byte_offset);
1922 meta.address = pnanovdb_address_offset_product(meta.address, PNANOVDB_GRIDBLINDMETADATA_SIZE, index);
1923 return meta;
1924}
1925
1926PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_grid_get_gridblindmetadata_value_address(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, pnanovdb_uint32_t index)
1927{
1928 pnanovdb_gridblindmetadata_handle_t meta = pnanovdb_grid_get_gridblindmetadata(buf, grid, index);
1929 pnanovdb_int64_t byte_offset = pnanovdb_gridblindmetadata_get_data_offset(buf, meta);
1930 pnanovdb_address_t address = pnanovdb_address_offset64(meta.address, pnanovdb_int64_as_uint64(byte_offset));
1931 return address;
1932}
1933
1934PNANOVDB_FORCE_INLINE pnanovdb_tree_handle_t pnanovdb_grid_get_tree(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid)
1935{
1936 pnanovdb_tree_handle_t tree = { grid.address };
1937 tree.address = pnanovdb_address_offset(tree.address, PNANOVDB_GRID_SIZE);
1938 return tree;
1939}
1940
1941PNANOVDB_FORCE_INLINE pnanovdb_root_handle_t pnanovdb_tree_get_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t tree)
1942{
1943 pnanovdb_root_handle_t root = { tree.address };
1944 pnanovdb_uint64_t byte_offset = pnanovdb_tree_get_node_offset_root(buf, tree);
1945 root.address = pnanovdb_address_offset64(root.address, byte_offset);
1946 return root;
1947}
1948
1949PNANOVDB_FORCE_INLINE pnanovdb_root_tile_handle_t pnanovdb_root_get_tile(pnanovdb_grid_type_t grid_type, pnanovdb_root_handle_t root, pnanovdb_uint32_t n)
1950{
1951 pnanovdb_root_tile_handle_t tile = { root.address };
1952 tile.address = pnanovdb_address_offset(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_size));
1953 tile.address = pnanovdb_address_offset_product(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_size), n);
1954 return tile;
1955}
1956
1957PNANOVDB_FORCE_INLINE pnanovdb_root_tile_handle_t pnanovdb_root_get_tile_zero(pnanovdb_grid_type_t grid_type, pnanovdb_root_handle_t root)
1958{
1959 pnanovdb_root_tile_handle_t tile = { root.address };
1960 tile.address = pnanovdb_address_offset(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_size));
1961 return tile;
1962}
1963
1964PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_root_tile_get_child_mask(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t tile)
1965{
1966 return !pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile));
1967}
1968
1969PNANOVDB_FORCE_INLINE pnanovdb_upper_handle_t pnanovdb_root_get_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, pnanovdb_root_tile_handle_t tile)
1970{
1971 pnanovdb_upper_handle_t upper = { root.address };
1972 upper.address = pnanovdb_address_offset64(upper.address, pnanovdb_int64_as_uint64(pnanovdb_root_tile_get_child(buf, tile)));
1973 return upper;
1974}
1975
1976PNANOVDB_FORCE_INLINE void pnanovdb_root_set_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, pnanovdb_root_tile_handle_t tile, pnanovdb_upper_handle_t upper)
1977{
1978 pnanovdb_root_tile_set_child(buf, tile, pnanovdb_address_diff(upper.address, root.address));
1979}
1980
1981PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_coord_to_key(PNANOVDB_IN(pnanovdb_coord_t) ijk)
1982{
1983#if defined(PNANOVDB_NATIVE_64)
1984 pnanovdb_uint64_t iu = pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).x) >> 12u;
1985 pnanovdb_uint64_t ju = pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).y) >> 12u;
1986 pnanovdb_uint64_t ku = pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).z) >> 12u;
1987 return (ku) | (ju << 21u) | (iu << 42u);
1988#else
1989 pnanovdb_uint32_t iu = pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).x) >> 12u;
1990 pnanovdb_uint32_t ju = pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).y) >> 12u;
1991 pnanovdb_uint32_t ku = pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).z) >> 12u;
1992 pnanovdb_uint32_t key_x = ku | (ju << 21);
1993 pnanovdb_uint32_t key_y = (iu << 10) | (ju >> 11);
1994 return pnanovdb_uint32_as_uint64(key_x, key_y);
1995#endif
1996}
1997
1998PNANOVDB_FORCE_INLINE pnanovdb_root_tile_handle_t pnanovdb_root_find_tile(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk)
1999{
2000 pnanovdb_uint32_t tile_count = pnanovdb_uint32_as_int32(pnanovdb_root_get_tile_count(buf, root));
2001 pnanovdb_root_tile_handle_t tile = pnanovdb_root_get_tile_zero(grid_type, root);
2002 pnanovdb_uint64_t key = pnanovdb_coord_to_key(ijk);
2003 for (pnanovdb_uint32_t i = 0u; i < tile_count; i++)
2004 {
2005 if (pnanovdb_uint64_is_equal(key, pnanovdb_root_tile_get_key(buf, tile)))
2006 {
2007 return tile;
2008 }
2009 tile.address = pnanovdb_address_offset(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_size));
2010 }
2011 pnanovdb_root_tile_handle_t null_handle = { pnanovdb_address_null() };
2012 return null_handle;
2013}
2014
2015// ----------------------------- Grid Type Safe Set ---------------------------------------
2016
2017PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_first_gridblindmetadata(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_gridblindmetadata_handle_t gridblindmetadata) {
2018 pnanovdb_grid_set_blind_metadata_offset(buf, p, pnanovdb_address_diff(gridblindmetadata.address, p.address));
2019}
2020
2021// ----------------------------- Tree Type Safe Set ---------------------------------------
2022
2023PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_leaf_handle_t leaf) {
2024 pnanovdb_tree_set_node_offset_leaf(buf, p, pnanovdb_address_diff(leaf.address, p.address));
2025}
2026PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_lower_handle_t lower) {
2027 pnanovdb_tree_set_node_offset_lower(buf, p, pnanovdb_address_diff(lower.address, p.address));
2028}
2029PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_upper_handle_t upper) {
2030 pnanovdb_tree_set_node_offset_upper(buf, p, pnanovdb_address_diff(upper.address, p.address));
2031}
2032PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_root_handle_t root) {
2033 pnanovdb_tree_set_node_offset_root(buf, p, pnanovdb_address_diff(root.address, p.address));
2034}
2035
2036// ----------------------------- Leaf Node ---------------------------------------
2037
2038PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
2039{
2040 return (((PNANOVDB_DEREF(ijk).x & 7) >> 0) << (2 * 3)) +
2041 (((PNANOVDB_DEREF(ijk).y & 7) >> 0) << (3)) +
2042 ((PNANOVDB_DEREF(ijk).z & 7) >> 0);
2043}
2044
2045PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
2046{
2047 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, leaf_off_min);
2048 return pnanovdb_address_offset(node.address, byte_offset);
2049}
2050
2051PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
2052{
2053 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, leaf_off_max);
2054 return pnanovdb_address_offset(node.address, byte_offset);
2055}
2056
2057PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
2058{
2059 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, leaf_off_ave);
2060 return pnanovdb_address_offset(node.address, byte_offset);
2061}
2062
2063PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
2064{
2065 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, leaf_off_stddev);
2066 return pnanovdb_address_offset(node.address, byte_offset);
2067}
2068
2069PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_table_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node, pnanovdb_uint32_t n)
2070{
2071 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, leaf_off_table) + ((PNANOVDB_GRID_TYPE_GET(grid_type, value_stride_bits) * n) >> 3u);
2072 return pnanovdb_address_offset(node.address, byte_offset);
2073}
2074
2075PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2076{
2077 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2078 return pnanovdb_leaf_get_table_address(grid_type, buf, leaf, n);
2079}
2080
2081// ----------------------------- Leaf FP Types Specialization ---------------------------------------
2082
2083PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t value_log_bits)
2084{
2085 // value_log_bits // 2 3 4
2086 pnanovdb_uint32_t value_bits = 1u << value_log_bits; // 4 8 16
2087 pnanovdb_uint32_t value_mask = (1u << value_bits) - 1u; // 0xF 0xFF 0xFFFF
2088 pnanovdb_uint32_t values_per_word_bits = 5u - value_log_bits; // 3 2 1
2089 pnanovdb_uint32_t values_per_word_mask = (1u << values_per_word_bits) - 1u; // 7 3 1
2090
2091 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2092 float minimum = pnanovdb_read_float(buf, pnanovdb_address_offset_neg(address, PNANOVDB_LEAF_TABLE_NEG_OFF_MINIMUM));
2093 float quantum = pnanovdb_read_float(buf, pnanovdb_address_offset_neg(address, PNANOVDB_LEAF_TABLE_NEG_OFF_QUANTUM));
2094 pnanovdb_uint32_t raw = pnanovdb_read_uint32(buf, pnanovdb_address_offset(address, ((n >> values_per_word_bits) << 2u)));
2095 pnanovdb_uint32_t value_compressed = (raw >> ((n & values_per_word_mask) << value_log_bits)) & value_mask;
2096 return pnanovdb_uint32_to_float(value_compressed) * quantum + minimum;
2097}
2098
2099PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp4_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2100{
2101 return pnanovdb_leaf_fp_read_float(buf, address, ijk, 2u);
2102}
2103
2104PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp8_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2105{
2106 return pnanovdb_leaf_fp_read_float(buf, address, ijk, 3u);
2107}
2108
2109PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp16_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2110{
2111 return pnanovdb_leaf_fp_read_float(buf, address, ijk, 4u);
2112}
2113
2114PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fpn_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2115{
2116 pnanovdb_uint32_t bbox_dif_and_flags = pnanovdb_read_uint32(buf, pnanovdb_address_offset_neg(address, PNANOVDB_LEAF_TABLE_NEG_OFF_BBOX_DIF_AND_FLAGS));
2117 pnanovdb_uint32_t flags = bbox_dif_and_flags >> 24u;
2118 pnanovdb_uint32_t value_log_bits = flags >> 5; // b = 0, 1, 2, 3, 4 corresponding to 1, 2, 4, 8, 16 bits
2119 return pnanovdb_leaf_fp_read_float(buf, address, ijk, value_log_bits);
2120}
2121
2122// ----------------------------- Leaf Index Specialization ---------------------------------------
2123
2124PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_index_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2125{
2126 return (pnanovdb_leaf_get_bbox_dif_and_flags(buf, leaf) & (1u << 28u)) != 0u;
2127}
2128
2129PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
2130{
2131 return pnanovdb_uint64_offset(pnanovdb_read_uint64(buf, min_address), 512u);
2132}
2133
2134PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
2135{
2136 return pnanovdb_uint64_offset(pnanovdb_read_uint64(buf, max_address), 513u);
2137}
2138
2139PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
2140{
2141 return pnanovdb_uint64_offset(pnanovdb_read_uint64(buf, ave_address), 514u);
2142}
2143
2144PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
2145{
2146 return pnanovdb_uint64_offset(pnanovdb_read_uint64(buf, dev_address), 515u);
2147}
2148
2149PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2150{
2151 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2152 pnanovdb_uint64_t offset = pnanovdb_read_uint64(buf, value_address);
2153 return pnanovdb_uint64_offset(offset, n);
2154}
2155
2156// ----------------------------- Leaf IndexMask Specialization ---------------------------------------
2157
2158PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_indexmask_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2159{
2160 return pnanovdb_leaf_index_has_stats(buf, leaf);
2161}
2162PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
2163{
2164 return pnanovdb_leaf_index_get_min_index(buf, min_address);
2165}
2166PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
2167{
2168 return pnanovdb_leaf_index_get_max_index(buf, max_address);
2169}
2170PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
2171{
2172 return pnanovdb_leaf_index_get_ave_index(buf, ave_address);
2173}
2174PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
2175{
2176 return pnanovdb_leaf_index_get_dev_index(buf, dev_address);
2177}
2178PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2179{
2180 return pnanovdb_leaf_index_get_value_index(buf, value_address, ijk);
2181}
2182PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_indexmask_get_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n)
2183{
2184 pnanovdb_uint32_t word_idx = n >> 5;
2185 pnanovdb_uint32_t bit_idx = n & 31;
2186 pnanovdb_uint32_t val_mask =
2187 pnanovdb_read_uint32(buf, pnanovdb_address_offset(leaf.address, 96u + 4u * word_idx));
2188 return (val_mask & (1u << bit_idx)) != 0u;
2189}
2190PNANOVDB_FORCE_INLINE void pnanovdb_leaf_indexmask_set_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n, pnanovdb_bool_t v)
2191{
2192 pnanovdb_uint32_t word_idx = n >> 5;
2193 pnanovdb_uint32_t bit_idx = n & 31;
2194 pnanovdb_uint32_t val_mask =
2195 pnanovdb_read_uint32(buf, pnanovdb_address_offset(leaf.address, 96u + 4u * word_idx));
2196 if (v)
2197 {
2198 val_mask = val_mask | (1u << bit_idx);
2199 }
2200 else
2201 {
2202 val_mask = val_mask & ~(1u << bit_idx);
2203 }
2204 pnanovdb_write_uint32(buf, pnanovdb_address_offset(leaf.address, 96u + 4u * word_idx), val_mask);
2205}
2206
2207// ----------------------------- Leaf OnIndex Specialization ---------------------------------------
2208
2209PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_onindex_get_value_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2210{
2211 pnanovdb_uint64_t val_mask = pnanovdb_read_uint64(buf, pnanovdb_address_offset(leaf.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 8u * 7u));
2212 pnanovdb_uint64_t prefix_sum = pnanovdb_read_uint64(
2213 buf, pnanovdb_address_offset(leaf.address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table) + 8u));
2214 return pnanovdb_uint64_countbits(val_mask) + (pnanovdb_uint64_to_uint32_lsr(prefix_sum, 54u) & 511u);
2215}
2216
2217PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_last_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2218{
2219 return pnanovdb_uint64_offset(
2220 pnanovdb_read_uint64(buf, pnanovdb_address_offset(leaf.address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table))),
2221 pnanovdb_leaf_onindex_get_value_count(buf, leaf) - 1u);
2222}
2223
2224PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_onindex_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2225{
2226 return (pnanovdb_leaf_get_bbox_dif_and_flags(buf, leaf) & (1u << 28u)) != 0u;
2227}
2228
2229PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
2230{
2231 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(min_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2232 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2233 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2234 {
2235 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 1u);
2236 }
2237 return idx;
2238}
2239
2240PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
2241{
2242 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(max_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2243 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2244 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2245 {
2246 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 2u);
2247 }
2248 return idx;
2249}
2250
2251PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
2252{
2253 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(ave_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2254 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2255 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2256 {
2257 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 3u);
2258 }
2259 return idx;
2260}
2261
2262PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
2263{
2264 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(dev_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2265 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2266 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2267 {
2268 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 4u);
2269 }
2270 return idx;
2271}
2272
2273PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2274{
2275 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2276 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(value_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2277
2278 pnanovdb_uint32_t word_idx = n >> 6u;
2279 pnanovdb_uint32_t bit_idx = n & 63u;
2280 pnanovdb_uint64_t val_mask = pnanovdb_read_uint64(buf, pnanovdb_address_offset(leaf.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 8u * word_idx));
2281 pnanovdb_uint64_t mask = pnanovdb_uint64_bit_mask(bit_idx);
2282 pnanovdb_uint64_t value_index = pnanovdb_uint32_as_uint64_low(0u);
2283 if (pnanovdb_uint64_any_bit(pnanovdb_uint64_and(val_mask, mask)))
2284 {
2285 pnanovdb_uint32_t sum = 0u;
2286 sum += pnanovdb_uint64_countbits(pnanovdb_uint64_and(val_mask, pnanovdb_uint64_dec(mask)));
2287 if (word_idx > 0u)
2288 {
2289 pnanovdb_uint64_t prefix_sum = pnanovdb_read_uint64(buf, pnanovdb_address_offset(value_address, 8u));
2290 sum += pnanovdb_uint64_to_uint32_lsr(prefix_sum, 9u * (word_idx - 1u)) & 511u;
2291 }
2292 pnanovdb_uint64_t offset = pnanovdb_read_uint64(buf, value_address);
2293 value_index = pnanovdb_uint64_offset(offset, sum);
2294 }
2295 return value_index;
2296}
2297
2298// ----------------------------- Leaf OnIndexMask Specialization ---------------------------------------
2299
2300PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_onindexmask_get_value_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2301{
2302 return pnanovdb_leaf_onindex_get_value_count(buf, leaf);
2303}
2304PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_last_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2305{
2306 return pnanovdb_leaf_onindex_get_last_offset(buf, leaf);
2307}
2308PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_onindexmask_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2309{
2310 return pnanovdb_leaf_onindex_has_stats(buf, leaf);
2311}
2312PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
2313{
2314 return pnanovdb_leaf_onindex_get_min_index(buf, min_address);
2315}
2316PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
2317{
2318 return pnanovdb_leaf_onindex_get_max_index(buf, max_address);
2319}
2320PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
2321{
2322 return pnanovdb_leaf_onindex_get_ave_index(buf, ave_address);
2323}
2324PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
2325{
2326 return pnanovdb_leaf_onindex_get_dev_index(buf, dev_address);
2327}
2328PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2329{
2330 return pnanovdb_leaf_onindex_get_value_index(buf, value_address, ijk);
2331}
2332PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_onindexmask_get_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n)
2333{
2334 pnanovdb_uint32_t word_idx = n >> 5;
2335 pnanovdb_uint32_t bit_idx = n & 31;
2336 pnanovdb_uint32_t val_mask =
2337 pnanovdb_read_uint32(buf, pnanovdb_address_offset(leaf.address, 96u + 4u * word_idx));
2338 return (val_mask & (1u << bit_idx)) != 0u;
2339}
2340PNANOVDB_FORCE_INLINE void pnanovdb_leaf_onindexmask_set_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n, pnanovdb_bool_t v)
2341{
2342 pnanovdb_uint32_t word_idx = n >> 5;
2343 pnanovdb_uint32_t bit_idx = n & 31;
2344 pnanovdb_uint32_t val_mask =
2345 pnanovdb_read_uint32(buf, pnanovdb_address_offset(leaf.address, 96u + 4u * word_idx));
2346 if (v)
2347 {
2348 val_mask = val_mask | (1u << bit_idx);
2349 }
2350 else
2351 {
2352 val_mask = val_mask & ~(1u << bit_idx);
2353 }
2354 pnanovdb_write_uint32(buf, pnanovdb_address_offset(leaf.address, 96u + 4u * word_idx), val_mask);
2355}
2356
2357// ----------------------------- Leaf PointIndex Specialization ---------------------------------------
2358
2359PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2360{
2361 return pnanovdb_read_uint64(buf, pnanovdb_leaf_get_min_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf));
2362}
2363PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_point_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2364{
2365 return pnanovdb_read_uint64(buf, pnanovdb_leaf_get_max_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf));
2366}
2367PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_first(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2368{
2369 return pnanovdb_uint64_offset(pnanovdb_leaf_pointindex_get_offset(buf, leaf),
2370 (i == 0u ? 0u : pnanovdb_read_uint16(buf, pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i - 1u))));
2371}
2372PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_last(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2373{
2374 return pnanovdb_uint64_offset(pnanovdb_leaf_pointindex_get_offset(buf, leaf),
2375 pnanovdb_read_uint16(buf, pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i)));
2376}
2377PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_value(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2378{
2379 return pnanovdb_uint32_as_uint64_low(pnanovdb_read_uint16(buf, pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i)));
2380}
2381PNANOVDB_FORCE_INLINE void pnanovdb_leaf_pointindex_set_value_only(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i, pnanovdb_uint32_t value)
2382{
2383 pnanovdb_address_t addr = pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i);
2384 pnanovdb_uint32_t raw32 = pnanovdb_read_uint32(buf, pnanovdb_address_mask_inv(addr, 3u));
2385 if ((i & 1) == 0u)
2386 {
2387 raw32 = (raw32 & 0xFFFF0000) | (value & 0x0000FFFF);
2388 }
2389 else
2390 {
2391 raw32 = (raw32 & 0x0000FFFF) | (value << 16u);
2392 }
2393 pnanovdb_write_uint32(buf, addr, raw32);
2394}
2395PNANOVDB_FORCE_INLINE void pnanovdb_leaf_pointindex_set_on(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2396{
2397 pnanovdb_uint32_t word_idx = i >> 5;
2398 pnanovdb_uint32_t bit_idx = i & 31;
2399 pnanovdb_address_t addr = pnanovdb_address_offset(leaf.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 4u * word_idx);
2400 pnanovdb_uint32_t val_mask = pnanovdb_read_uint32(buf, addr);
2401 val_mask = val_mask | (1u << bit_idx);
2402 pnanovdb_write_uint32(buf, addr, val_mask);
2403}
2404PNANOVDB_FORCE_INLINE void pnanovdb_leaf_pointindex_set_value(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i, pnanovdb_uint32_t value)
2405{
2406 pnanovdb_leaf_pointindex_set_on(buf, leaf, i);
2407 pnanovdb_leaf_pointindex_set_value_only(buf, leaf, i, value);
2408}
2409
2410// ------------------------------------------------ Lower Node -----------------------------------------------------------
2411
2412PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_lower_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
2413{
2414 return (((PNANOVDB_DEREF(ijk).x & 127) >> 3) << (2 * 4)) +
2415 (((PNANOVDB_DEREF(ijk).y & 127) >> 3) << (4)) +
2416 ((PNANOVDB_DEREF(ijk).z & 127) >> 3);
2417}
2418
2419PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
2420{
2421 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_min);
2422 return pnanovdb_address_offset(node.address, byte_offset);
2423}
2424
2425PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
2426{
2427 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_max);
2428 return pnanovdb_address_offset(node.address, byte_offset);
2429}
2430
2431PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
2432{
2433 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_ave);
2434 return pnanovdb_address_offset(node.address, byte_offset);
2435}
2436
2437PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
2438{
2439 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_stddev);
2440 return pnanovdb_address_offset(node.address, byte_offset);
2441}
2442
2443PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_table_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node, pnanovdb_uint32_t n)
2444{
2445 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_table) + PNANOVDB_GRID_TYPE_GET(grid_type, table_stride) * n;
2446 return pnanovdb_address_offset(node.address, byte_offset);
2447}
2448
2449PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_lower_get_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node, pnanovdb_uint32_t n)
2450{
2451 pnanovdb_address_t table_address = pnanovdb_lower_get_table_address(grid_type, buf, node, n);
2452 return pnanovdb_read_int64(buf, table_address);
2453}
2454
2455PNANOVDB_FORCE_INLINE pnanovdb_leaf_handle_t pnanovdb_lower_get_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, pnanovdb_uint32_t n)
2456{
2457 pnanovdb_leaf_handle_t leaf = { lower.address };
2458 leaf.address = pnanovdb_address_offset64(leaf.address, pnanovdb_int64_as_uint64(pnanovdb_lower_get_table_child(grid_type, buf, lower, n)));
2459 return leaf;
2460}
2461
2462PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
2463{
2464 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
2465 pnanovdb_address_t value_address;
2466 if (pnanovdb_lower_get_child_mask(buf, lower, n))
2467 {
2468 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
2469 value_address = pnanovdb_leaf_get_value_address(grid_type, buf, child, ijk);
2470 PNANOVDB_DEREF(level) = 0u;
2471 }
2472 else
2473 {
2474 value_address = pnanovdb_lower_get_table_address(grid_type, buf, lower, n);
2475 PNANOVDB_DEREF(level) = 1u;
2476 }
2477 return value_address;
2478}
2479
2480PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2481{
2482 pnanovdb_uint32_t level;
2483 return pnanovdb_lower_get_value_address_and_level(grid_type, buf, lower, ijk, PNANOVDB_REF(level));
2484}
2485
2486PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node, pnanovdb_uint32_t n, pnanovdb_int64_t child)
2487{
2488 pnanovdb_address_t table_address = pnanovdb_lower_get_table_address(grid_type, buf, node, n);
2489 pnanovdb_write_int64(buf, table_address, child);
2490}
2491
2492PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, pnanovdb_uint32_t n, pnanovdb_leaf_handle_t leaf)
2493{
2494 pnanovdb_lower_set_table_child(grid_type, buf, lower, n, pnanovdb_address_diff(leaf.address, lower.address));
2495}
2496
2497// ------------------------------------------------ Upper Node -----------------------------------------------------------
2498
2499PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_upper_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
2500{
2501 return (((PNANOVDB_DEREF(ijk).x & 4095) >> 7) << (2 * 5)) +
2502 (((PNANOVDB_DEREF(ijk).y & 4095) >> 7) << (5)) +
2503 ((PNANOVDB_DEREF(ijk).z & 4095) >> 7);
2504}
2505
2506PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
2507{
2508 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_min);
2509 return pnanovdb_address_offset(node.address, byte_offset);
2510}
2511
2512PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
2513{
2514 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_max);
2515 return pnanovdb_address_offset(node.address, byte_offset);
2516}
2517
2518PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
2519{
2520 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_ave);
2521 return pnanovdb_address_offset(node.address, byte_offset);
2522}
2523
2524PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
2525{
2526 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_stddev);
2527 return pnanovdb_address_offset(node.address, byte_offset);
2528}
2529
2530PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_table_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node, pnanovdb_uint32_t n)
2531{
2532 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_table) + PNANOVDB_GRID_TYPE_GET(grid_type, table_stride) * n;
2533 return pnanovdb_address_offset(node.address, byte_offset);
2534}
2535
2536PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_upper_get_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node, pnanovdb_uint32_t n)
2537{
2538 pnanovdb_address_t bufAddress = pnanovdb_upper_get_table_address(grid_type, buf, node, n);
2539 return pnanovdb_read_int64(buf, bufAddress);
2540}
2541
2542PNANOVDB_FORCE_INLINE pnanovdb_lower_handle_t pnanovdb_upper_get_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, pnanovdb_uint32_t n)
2543{
2544 pnanovdb_lower_handle_t lower = { upper.address };
2545 lower.address = pnanovdb_address_offset64(lower.address, pnanovdb_int64_as_uint64(pnanovdb_upper_get_table_child(grid_type, buf, upper, n)));
2546 return lower;
2547}
2548
2549PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
2550{
2551 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
2552 pnanovdb_address_t value_address;
2553 if (pnanovdb_upper_get_child_mask(buf, upper, n))
2554 {
2555 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
2556 value_address = pnanovdb_lower_get_value_address_and_level(grid_type, buf, child, ijk, level);
2557 }
2558 else
2559 {
2560 value_address = pnanovdb_upper_get_table_address(grid_type, buf, upper, n);
2561 PNANOVDB_DEREF(level) = 2u;
2562 }
2563 return value_address;
2564}
2565
2566PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2567{
2568 pnanovdb_uint32_t level;
2569 return pnanovdb_upper_get_value_address_and_level(grid_type, buf, upper, ijk, PNANOVDB_REF(level));
2570}
2571
2572PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node, pnanovdb_uint32_t n, pnanovdb_int64_t child)
2573{
2574 pnanovdb_address_t bufAddress = pnanovdb_upper_get_table_address(grid_type, buf, node, n);
2575 pnanovdb_write_int64(buf, bufAddress, child);
2576}
2577
2578PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, pnanovdb_uint32_t n, pnanovdb_lower_handle_t lower)
2579{
2580 pnanovdb_upper_set_table_child(grid_type, buf, upper, n, pnanovdb_address_diff(lower.address, upper.address));
2581}
2582
2583// ------------------------------------------------ Root -----------------------------------------------------------
2584
2585PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_background_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
2586{
2587 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_background);
2588 return pnanovdb_address_offset(root.address, byte_offset);
2589}
2590
2591PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
2592{
2593 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_min);
2594 return pnanovdb_address_offset(root.address, byte_offset);
2595}
2596
2597PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
2598{
2599 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_max);
2600 return pnanovdb_address_offset(root.address, byte_offset);
2601}
2602
2603PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
2604{
2605 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_ave);
2606 return pnanovdb_address_offset(root.address, byte_offset);
2607}
2608
2609PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
2610{
2611 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_stddev);
2612 return pnanovdb_address_offset(root.address, byte_offset);
2613}
2614
2615PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_tile_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t root_tile)
2616{
2617 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_off_value);
2618 return pnanovdb_address_offset(root_tile.address, byte_offset);
2619}
2620
2621PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
2622{
2623 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
2624 pnanovdb_address_t ret;
2625 if (pnanovdb_address_is_null(tile.address))
2626 {
2627 ret = pnanovdb_address_offset(root.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_off_background));
2628 PNANOVDB_DEREF(level) = 4u;
2629 }
2630 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
2631 {
2632 ret = pnanovdb_address_offset(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_off_value));
2633 PNANOVDB_DEREF(level) = 3u;
2634 }
2635 else
2636 {
2637 pnanovdb_upper_handle_t child = pnanovdb_root_get_child(grid_type, buf, root, tile);
2638 ret = pnanovdb_upper_get_value_address_and_level(grid_type, buf, child, ijk, level);
2639 }
2640 return ret;
2641}
2642
2643PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2644{
2645 pnanovdb_uint32_t level;
2646 return pnanovdb_root_get_value_address_and_level(grid_type, buf, root, ijk, PNANOVDB_REF(level));
2647}
2648
2649PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_bit(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) bit_index)
2650{
2651 pnanovdb_uint32_t level;
2652 pnanovdb_address_t address = pnanovdb_root_get_value_address_and_level(grid_type, buf, root, ijk, PNANOVDB_REF(level));
2653 PNANOVDB_DEREF(bit_index) = level == 0u ? pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).x & 7) : 0u;
2654 return address;
2655}
2656
2657PNANOVDB_FORCE_INLINE float pnanovdb_root_fp4_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
2658{
2659 float ret;
2660 if (level == 0)
2661 {
2662 ret = pnanovdb_leaf_fp4_read_float(buf, address, ijk);
2663 }
2664 else
2665 {
2666 ret = pnanovdb_read_float(buf, address);
2667 }
2668 return ret;
2669}
2670
2671PNANOVDB_FORCE_INLINE float pnanovdb_root_fp8_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
2672{
2673 float ret;
2674 if (level == 0)
2675 {
2676 ret = pnanovdb_leaf_fp8_read_float(buf, address, ijk);
2677 }
2678 else
2679 {
2680 ret = pnanovdb_read_float(buf, address);
2681 }
2682 return ret;
2683}
2684
2685PNANOVDB_FORCE_INLINE float pnanovdb_root_fp16_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
2686{
2687 float ret;
2688 if (level == 0)
2689 {
2690 ret = pnanovdb_leaf_fp16_read_float(buf, address, ijk);
2691 }
2692 else
2693 {
2694 ret = pnanovdb_read_float(buf, address);
2695 }
2696 return ret;
2697}
2698
2699PNANOVDB_FORCE_INLINE float pnanovdb_root_fpn_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
2700{
2701 float ret;
2702 if (level == 0)
2703 {
2704 ret = pnanovdb_leaf_fpn_read_float(buf, address, ijk);
2705 }
2706 else
2707 {
2708 ret = pnanovdb_read_float(buf, address);
2709 }
2710 return ret;
2711}
2712
2713PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_index_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
2714{
2715 pnanovdb_uint64_t ret;
2716 if (level == 0)
2717 {
2718 ret = pnanovdb_leaf_index_get_value_index(buf, address, ijk);
2719 }
2720 else
2721 {
2722 ret = pnanovdb_read_uint64(buf, address);
2723 }
2724 return ret;
2725}
2726
2727PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_onindex_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
2728{
2729 pnanovdb_uint64_t ret;
2730 if (level == 0)
2731 {
2732 ret = pnanovdb_leaf_onindex_get_value_index(buf, address, ijk);
2733 }
2734 else
2735 {
2736 ret = pnanovdb_read_uint64(buf, address);
2737 }
2738 return ret;
2739}
2740
2741PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_pointindex_get_point_range(
2742 pnanovdb_buf_t buf,
2743 pnanovdb_address_t value_address,
2744 PNANOVDB_IN(pnanovdb_coord_t) ijk,
2745 pnanovdb_uint32_t level,
2746 PNANOVDB_INOUT(pnanovdb_uint64_t)range_begin,
2747 PNANOVDB_INOUT(pnanovdb_uint64_t)range_end
2748)
2749{
2750 pnanovdb_uint32_t local_range_begin = 0u;
2751 pnanovdb_uint32_t local_range_end = 0u;
2752 pnanovdb_uint64_t offset = pnanovdb_uint32_as_uint64_low(0u);
2753 if (level == 0)
2754 {
2755 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2756 // recover leaf address
2757 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(value_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_POINTINDEX, leaf_off_table) + 2u * n) };
2758 if (n > 0u)
2759 {
2760 local_range_begin = pnanovdb_read_uint16(buf, pnanovdb_address_offset_neg(value_address, 2u));
2761 }
2762 local_range_end = pnanovdb_read_uint16(buf, value_address);
2763 offset = pnanovdb_leaf_pointindex_get_offset(buf, leaf);
2764 }
2765 PNANOVDB_DEREF(range_begin) = pnanovdb_uint64_offset(offset, local_range_begin);
2766 PNANOVDB_DEREF(range_end) = pnanovdb_uint64_offset(offset, local_range_end);
2767 return pnanovdb_uint32_as_uint64_low(local_range_end - local_range_begin);
2768}
2769
2770PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_pointindex_get_point_address_range(
2771 pnanovdb_buf_t buf,
2772 pnanovdb_grid_type_t value_type,
2773 pnanovdb_address_t value_address,
2774 pnanovdb_address_t blindmetadata_value_address,
2775 PNANOVDB_IN(pnanovdb_coord_t) ijk,
2776 pnanovdb_uint32_t level,
2777 PNANOVDB_INOUT(pnanovdb_address_t)address_begin,
2778 PNANOVDB_INOUT(pnanovdb_address_t)address_end
2779)
2780{
2781 pnanovdb_uint64_t range_begin;
2782 pnanovdb_uint64_t range_end;
2783 pnanovdb_uint64_t range_size = pnanovdb_root_pointindex_get_point_range(buf, value_address, ijk, level, PNANOVDB_REF(range_begin), PNANOVDB_REF(range_end));
2784
2785 pnanovdb_uint32_t stride = 12u; // vec3f
2786 if (value_type == PNANOVDB_GRID_TYPE_VEC3U8)
2787 {
2788 stride = 3u;
2789 }
2790 else if (value_type == PNANOVDB_GRID_TYPE_VEC3U16)
2791 {
2792 stride = 6u;
2793 }
2794 PNANOVDB_DEREF(address_begin) = pnanovdb_address_offset64_product(blindmetadata_value_address, range_begin, stride);
2795 PNANOVDB_DEREF(address_end) = pnanovdb_address_offset64_product(blindmetadata_value_address, range_end, stride);
2796 return range_size;
2797}
2798
2799// ------------------------------------------------ ReadAccessor -----------------------------------------------------------
2800
2801 struct pnanovdb_readaccessor_t
2802{
2803 pnanovdb_coord_t key;
2804 pnanovdb_leaf_handle_t leaf;
2805 pnanovdb_lower_handle_t lower;
2806 pnanovdb_upper_handle_t upper;
2807 pnanovdb_root_handle_t root;
2808};
2809PNANOVDB_STRUCT_TYPEDEF(pnanovdb_readaccessor_t)
2810
2811PNANOVDB_FORCE_INLINE void pnanovdb_readaccessor_init(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, pnanovdb_root_handle_t root)
2812{
2813 PNANOVDB_DEREF(acc).key.x = 0x7FFFFFFF;
2814 PNANOVDB_DEREF(acc).key.y = 0x7FFFFFFF;
2815 PNANOVDB_DEREF(acc).key.z = 0x7FFFFFFF;
2816 PNANOVDB_DEREF(acc).leaf.address = pnanovdb_address_null();
2817 PNANOVDB_DEREF(acc).lower.address = pnanovdb_address_null();
2818 PNANOVDB_DEREF(acc).upper.address = pnanovdb_address_null();
2819 PNANOVDB_DEREF(acc).root = root;
2820}
2821
2822PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached0(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
2823{
2824 if (pnanovdb_address_is_null(PNANOVDB_DEREF(acc).leaf.address)) { return PNANOVDB_FALSE; }
2825 if ((dirty & ~((1u << 3) - 1u)) != 0)
2826 {
2827 PNANOVDB_DEREF(acc).leaf.address = pnanovdb_address_null();
2828 return PNANOVDB_FALSE;
2829 }
2830 return PNANOVDB_TRUE;
2831}
2832PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached1(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
2833{
2834 if (pnanovdb_address_is_null(PNANOVDB_DEREF(acc).lower.address)) { return PNANOVDB_FALSE; }
2835 if ((dirty & ~((1u << 7) - 1u)) != 0)
2836 {
2837 PNANOVDB_DEREF(acc).lower.address = pnanovdb_address_null();
2838 return PNANOVDB_FALSE;
2839 }
2840 return PNANOVDB_TRUE;
2841}
2842PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached2(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
2843{
2844 if (pnanovdb_address_is_null(PNANOVDB_DEREF(acc).upper.address)) { return PNANOVDB_FALSE; }
2845 if ((dirty & ~((1u << 12) - 1u)) != 0)
2846 {
2847 PNANOVDB_DEREF(acc).upper.address = pnanovdb_address_null();
2848 return PNANOVDB_FALSE;
2849 }
2850 return PNANOVDB_TRUE;
2851}
2852PNANOVDB_FORCE_INLINE int pnanovdb_readaccessor_computedirty(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2853{
2854 return (PNANOVDB_DEREF(ijk).x ^ PNANOVDB_DEREF(acc).key.x) | (PNANOVDB_DEREF(ijk).y ^ PNANOVDB_DEREF(acc).key.y) | (PNANOVDB_DEREF(ijk).z ^ PNANOVDB_DEREF(acc).key.z);
2855}
2856
2857PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
2858{
2859 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2860 return pnanovdb_leaf_get_table_address(grid_type, buf, leaf, n);
2861}
2862
2863PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address_and_level_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
2864{
2865 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
2866 pnanovdb_address_t value_address;
2867 if (pnanovdb_lower_get_child_mask(buf, lower, n))
2868 {
2869 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
2870 PNANOVDB_DEREF(acc).leaf = child;
2871 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2872 value_address = pnanovdb_leaf_get_value_address_and_cache(grid_type, buf, child, ijk, acc);
2873 PNANOVDB_DEREF(level) = 0u;
2874 }
2875 else
2876 {
2877 value_address = pnanovdb_lower_get_table_address(grid_type, buf, lower, n);
2878 PNANOVDB_DEREF(level) = 1u;
2879 }
2880 return value_address;
2881}
2882
2883PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
2884{
2885 pnanovdb_uint32_t level;
2886 return pnanovdb_lower_get_value_address_and_level_and_cache(grid_type, buf, lower, ijk, acc, PNANOVDB_REF(level));
2887}
2888
2889PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address_and_level_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
2890{
2891 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
2892 pnanovdb_address_t value_address;
2893 if (pnanovdb_upper_get_child_mask(buf, upper, n))
2894 {
2895 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
2896 PNANOVDB_DEREF(acc).lower = child;
2897 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2898 value_address = pnanovdb_lower_get_value_address_and_level_and_cache(grid_type, buf, child, ijk, acc, level);
2899 }
2900 else
2901 {
2902 value_address = pnanovdb_upper_get_table_address(grid_type, buf, upper, n);
2903 PNANOVDB_DEREF(level) = 2u;
2904 }
2905 return value_address;
2906}
2907
2908PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
2909{
2910 pnanovdb_uint32_t level;
2911 return pnanovdb_upper_get_value_address_and_level_and_cache(grid_type, buf, upper, ijk, acc, PNANOVDB_REF(level));
2912}
2913
2914PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_and_level_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
2915{
2916 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
2917 pnanovdb_address_t ret;
2918 if (pnanovdb_address_is_null(tile.address))
2919 {
2920 ret = pnanovdb_address_offset(root.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_off_background));
2921 PNANOVDB_DEREF(level) = 4u;
2922 }
2923 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
2924 {
2925 ret = pnanovdb_address_offset(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_off_value));
2926 PNANOVDB_DEREF(level) = 3u;
2927 }
2928 else
2929 {
2930 pnanovdb_upper_handle_t child = pnanovdb_root_get_child(grid_type, buf, root, tile);
2931 PNANOVDB_DEREF(acc).upper = child;
2932 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2933 ret = pnanovdb_upper_get_value_address_and_level_and_cache(grid_type, buf, child, ijk, acc, level);
2934 }
2935 return ret;
2936}
2937
2938PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
2939{
2940 pnanovdb_uint32_t level;
2941 return pnanovdb_root_get_value_address_and_level_and_cache(grid_type, buf, root, ijk, acc, PNANOVDB_REF(level));
2942}
2943
2944PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_readaccessor_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
2945{
2946 int dirty = pnanovdb_readaccessor_computedirty(acc, ijk);
2947
2948 pnanovdb_address_t value_address;
2949 if (pnanovdb_readaccessor_iscached0(acc, dirty))
2950 {
2951 value_address = pnanovdb_leaf_get_value_address_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).leaf, ijk, acc);
2952 PNANOVDB_DEREF(level) = 0u;
2953 }
2954 else if (pnanovdb_readaccessor_iscached1(acc, dirty))
2955 {
2956 value_address = pnanovdb_lower_get_value_address_and_level_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).lower, ijk, acc, level);
2957 }
2958 else if (pnanovdb_readaccessor_iscached2(acc, dirty))
2959 {
2960 value_address = pnanovdb_upper_get_value_address_and_level_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).upper, ijk, acc, level);
2961 }
2962 else
2963 {
2964 value_address = pnanovdb_root_get_value_address_and_level_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).root, ijk, acc, level);
2965 }
2966 return value_address;
2967}
2968
2969PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_readaccessor_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2970{
2971 pnanovdb_uint32_t level;
2972 return pnanovdb_readaccessor_get_value_address_and_level(grid_type, buf, acc, ijk, PNANOVDB_REF(level));
2973}
2974
2975PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_readaccessor_get_value_address_bit(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) bit_index)
2976{
2977 pnanovdb_uint32_t level;
2978 pnanovdb_address_t address = pnanovdb_readaccessor_get_value_address_and_level(grid_type, buf, acc, ijk, PNANOVDB_REF(level));
2979 PNANOVDB_DEREF(bit_index) = level == 0u ? pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).x & 7) : 0u;
2980 return address;
2981}
2982
2983// ------------------------------------------------ ReadAccessor GetDim -----------------------------------------------------------
2984
2985PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
2986{
2987 return 1u;
2988}
2989
2990PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_lower_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
2991{
2992 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
2993 pnanovdb_uint32_t ret;
2994 if (pnanovdb_lower_get_child_mask(buf, lower, n))
2995 {
2996 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
2997 PNANOVDB_DEREF(acc).leaf = child;
2998 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2999 ret = pnanovdb_leaf_get_dim_and_cache(grid_type, buf, child, ijk, acc);
3000 }
3001 else
3002 {
3003 ret = (1u << (3u)); // node 0 dim
3004 }
3005 return ret;
3006}
3007
3008PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_upper_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
3009{
3010 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
3011 pnanovdb_uint32_t ret;
3012 if (pnanovdb_upper_get_child_mask(buf, upper, n))
3013 {
3014 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
3015 PNANOVDB_DEREF(acc).lower = child;
3016 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
3017 ret = pnanovdb_lower_get_dim_and_cache(grid_type, buf, child, ijk, acc);
3018 }
3019 else
3020 {
3021 ret = (1u << (4u + 3u)); // node 1 dim
3022 }
3023 return ret;
3024}
3025
3026PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_root_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
3027{
3028 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
3029 pnanovdb_uint32_t ret;
3030 if (pnanovdb_address_is_null(tile.address))
3031 {
3032 ret = 1u << (5u + 4u + 3u); // background, node 2 dim
3033 }
3034 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
3035 {
3036 ret = 1u << (5u + 4u + 3u); // tile value, node 2 dim
3037 }
3038 else
3039 {
3040 pnanovdb_upper_handle_t child = pnanovdb_root_get_child(grid_type, buf, root, tile);
3041 PNANOVDB_DEREF(acc).upper = child;
3042 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
3043 ret = pnanovdb_upper_get_dim_and_cache(grid_type, buf, child, ijk, acc);
3044 }
3045 return ret;
3046}
3047
3048PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_readaccessor_get_dim(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
3049{
3050 int dirty = pnanovdb_readaccessor_computedirty(acc, ijk);
3051
3052 pnanovdb_uint32_t dim;
3053 if (pnanovdb_readaccessor_iscached0(acc, dirty))
3054 {
3055 dim = pnanovdb_leaf_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).leaf, ijk, acc);
3056 }
3057 else if (pnanovdb_readaccessor_iscached1(acc, dirty))
3058 {
3059 dim = pnanovdb_lower_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).lower, ijk, acc);
3060 }
3061 else if (pnanovdb_readaccessor_iscached2(acc, dirty))
3062 {
3063 dim = pnanovdb_upper_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).upper, ijk, acc);
3064 }
3065 else
3066 {
3067 dim = pnanovdb_root_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).root, ijk, acc);
3068 }
3069 return dim;
3070}
3071
3072// ------------------------------------------------ ReadAccessor IsActive -----------------------------------------------------------
3073
3074PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
3075{
3076 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
3077 return pnanovdb_leaf_get_value_mask(buf, leaf, n);
3078}
3079
3080PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_lower_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
3081{
3082 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
3083 pnanovdb_bool_t is_active;
3084 if (pnanovdb_lower_get_child_mask(buf, lower, n))
3085 {
3086 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
3087 PNANOVDB_DEREF(acc).leaf = child;
3088 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
3089 is_active = pnanovdb_leaf_is_active_and_cache(grid_type, buf, child, ijk, acc);
3090 }
3091 else
3092 {
3093 is_active = pnanovdb_lower_get_value_mask(buf, lower, n);
3094 }
3095 return is_active;
3096}
3097
3098PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_upper_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
3099{
3100 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
3101 pnanovdb_bool_t is_active;
3102 if (pnanovdb_upper_get_child_mask(buf, upper, n))
3103 {
3104 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
3105 PNANOVDB_DEREF(acc).lower = child;
3106 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
3107 is_active = pnanovdb_lower_is_active_and_cache(grid_type, buf, child, ijk, acc);
3108 }
3109 else
3110 {
3111 is_active = pnanovdb_upper_get_value_mask(buf, upper, n);
3112 }
3113 return is_active;
3114}
3115
3116PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_root_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
3117{
3118 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
3119 pnanovdb_bool_t is_active;
3120 if (pnanovdb_address_is_null(tile.address))
3121 {
3122 is_active = PNANOVDB_FALSE; // background
3123 }
3124 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
3125 {
3126 pnanovdb_uint32_t state = pnanovdb_root_tile_get_state(buf, tile);
3127 is_active = state != 0u; // tile value
3128 }
3129 else
3130 {
3131 pnanovdb_upper_handle_t child = pnanovdb_root_get_child(grid_type, buf, root, tile);
3132 PNANOVDB_DEREF(acc).upper = child;
3133 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
3134 is_active = pnanovdb_upper_is_active_and_cache(grid_type, buf, child, ijk, acc);
3135 }
3136 return is_active;
3137}
3138
3139PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_is_active(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
3140{
3141 int dirty = pnanovdb_readaccessor_computedirty(acc, ijk);
3142
3143 pnanovdb_bool_t is_active;
3144 if (pnanovdb_readaccessor_iscached0(acc, dirty))
3145 {
3146 is_active = pnanovdb_leaf_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).leaf, ijk, acc);
3147 }
3148 else if (pnanovdb_readaccessor_iscached1(acc, dirty))
3149 {
3150 is_active = pnanovdb_lower_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).lower, ijk, acc);
3151 }
3152 else if (pnanovdb_readaccessor_iscached2(acc, dirty))
3153 {
3154 is_active = pnanovdb_upper_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).upper, ijk, acc);
3155 }
3156 else
3157 {
3158 is_active = pnanovdb_root_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).root, ijk, acc);
3159 }
3160 return is_active;
3161}
3162
3163// ------------------------------------------------ Map Transforms -----------------------------------------------------------
3164
3165PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
3166{
3167 pnanovdb_vec3_t dst;
3168 float sx = PNANOVDB_DEREF(src).x;
3169 float sy = PNANOVDB_DEREF(src).y;
3170 float sz = PNANOVDB_DEREF(src).z;
3171 dst.x = sx * pnanovdb_map_get_matf(buf, map, 0) + sy * pnanovdb_map_get_matf(buf, map, 1) + sz * pnanovdb_map_get_matf(buf, map, 2) + pnanovdb_map_get_vecf(buf, map, 0);
3172 dst.y = sx * pnanovdb_map_get_matf(buf, map, 3) + sy * pnanovdb_map_get_matf(buf, map, 4) + sz * pnanovdb_map_get_matf(buf, map, 5) + pnanovdb_map_get_vecf(buf, map, 1);
3173 dst.z = sx * pnanovdb_map_get_matf(buf, map, 6) + sy * pnanovdb_map_get_matf(buf, map, 7) + sz * pnanovdb_map_get_matf(buf, map, 8) + pnanovdb_map_get_vecf(buf, map, 2);
3174 return dst;
3175}
3176
3177PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_inverse(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
3178{
3179 pnanovdb_vec3_t dst;
3180 float sx = PNANOVDB_DEREF(src).x - pnanovdb_map_get_vecf(buf, map, 0);
3181 float sy = PNANOVDB_DEREF(src).y - pnanovdb_map_get_vecf(buf, map, 1);
3182 float sz = PNANOVDB_DEREF(src).z - pnanovdb_map_get_vecf(buf, map, 2);
3183 dst.x = sx * pnanovdb_map_get_invmatf(buf, map, 0) + sy * pnanovdb_map_get_invmatf(buf, map, 1) + sz * pnanovdb_map_get_invmatf(buf, map, 2);
3184 dst.y = sx * pnanovdb_map_get_invmatf(buf, map, 3) + sy * pnanovdb_map_get_invmatf(buf, map, 4) + sz * pnanovdb_map_get_invmatf(buf, map, 5);
3185 dst.z = sx * pnanovdb_map_get_invmatf(buf, map, 6) + sy * pnanovdb_map_get_invmatf(buf, map, 7) + sz * pnanovdb_map_get_invmatf(buf, map, 8);
3186 return dst;
3187}
3188
3189PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_jacobi(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
3190{
3191 pnanovdb_vec3_t dst;
3192 float sx = PNANOVDB_DEREF(src).x;
3193 float sy = PNANOVDB_DEREF(src).y;
3194 float sz = PNANOVDB_DEREF(src).z;
3195 dst.x = sx * pnanovdb_map_get_matf(buf, map, 0) + sy * pnanovdb_map_get_matf(buf, map, 1) + sz * pnanovdb_map_get_matf(buf, map, 2);
3196 dst.y = sx * pnanovdb_map_get_matf(buf, map, 3) + sy * pnanovdb_map_get_matf(buf, map, 4) + sz * pnanovdb_map_get_matf(buf, map, 5);
3197 dst.z = sx * pnanovdb_map_get_matf(buf, map, 6) + sy * pnanovdb_map_get_matf(buf, map, 7) + sz * pnanovdb_map_get_matf(buf, map, 8);
3198 return dst;
3199}
3200
3201PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_inverse_jacobi(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
3202{
3203 pnanovdb_vec3_t dst;
3204 float sx = PNANOVDB_DEREF(src).x;
3205 float sy = PNANOVDB_DEREF(src).y;
3206 float sz = PNANOVDB_DEREF(src).z;
3207 dst.x = sx * pnanovdb_map_get_invmatf(buf, map, 0) + sy * pnanovdb_map_get_invmatf(buf, map, 1) + sz * pnanovdb_map_get_invmatf(buf, map, 2);
3208 dst.y = sx * pnanovdb_map_get_invmatf(buf, map, 3) + sy * pnanovdb_map_get_invmatf(buf, map, 4) + sz * pnanovdb_map_get_invmatf(buf, map, 5);
3209 dst.z = sx * pnanovdb_map_get_invmatf(buf, map, 6) + sy * pnanovdb_map_get_invmatf(buf, map, 7) + sz * pnanovdb_map_get_invmatf(buf, map, 8);
3210 return dst;
3211}
3212
3213PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_world_to_indexf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
3214{
3215 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3216 return pnanovdb_map_apply_inverse(buf, map, src);
3217}
3218
3219PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_index_to_worldf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
3220{
3221 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3222 return pnanovdb_map_apply(buf, map, src);
3223}
3224
3225PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_world_to_index_dirf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
3226{
3227 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3228 return pnanovdb_map_apply_inverse_jacobi(buf, map, src);
3229}
3230
3231PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_index_to_world_dirf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
3232{
3233 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3234 return pnanovdb_map_apply_jacobi(buf, map, src);
3235}
3236
3237// ------------------------------------------------ DitherLUT -----------------------------------------------------------
3238
3239// This table was generated with
3240/**************
3241
3242static constexpr inline uint32
3243SYSwang_inthash(uint32 key)
3244{
3245 // From http://www.concentric.net/~Ttwang/tech/inthash.htm
3246 key += ~(key << 16);
3247 key ^= (key >> 5);
3248 key += (key << 3);
3249 key ^= (key >> 13);
3250 key += ~(key << 9);
3251 key ^= (key >> 17);
3252 return key;
3253}
3254
3255static void
3256ut_initDitherR(float *pattern, float offset,
3257 int x, int y, int z, int res, int goalres)
3258{
3259 // These offsets are designed to maximize the difference between
3260 // dither values in nearby voxels within a given 2x2x2 cell, without
3261 // producing axis-aligned artifacts. The are organized in row-major
3262 // order.
3263 static const float theDitherOffset[] = {0,4,6,2,5,1,3,7};
3264 static const float theScale = 0.125F;
3265 int key = (((z << res) + y) << res) + x;
3266
3267 if (res == goalres)
3268 {
3269 pattern[key] = offset;
3270 return;
3271 }
3272
3273 // Randomly flip (on each axis) the dithering patterns used by the
3274 // subcells. This key is xor'd with the subcell index below before
3275 // looking up in the dither offset list.
3276 key = SYSwang_inthash(key) & 7;
3277
3278 x <<= 1;
3279 y <<= 1;
3280 z <<= 1;
3281
3282 offset *= theScale;
3283 for (int i = 0; i < 8; i++)
3284 ut_initDitherR(pattern, offset+theDitherOffset[i ^ key]*theScale,
3285 x+(i&1), y+((i&2)>>1), z+((i&4)>>2), res+1, goalres);
3286}
3287
3288// This is a compact algorithm that accomplishes essentially the same thing
3289// as ut_initDither() above. We should eventually switch to use this and
3290// clean the dead code.
3291static fpreal32 *
3292ut_initDitherRecursive(int goalres)
3293{
3294 const int nfloat = 1 << (goalres*3);
3295 float *pattern = new float[nfloat];
3296 ut_initDitherR(pattern, 1.0F, 0, 0, 0, 0, goalres);
3297
3298 // This has built an even spacing from 1/nfloat to 1.0.
3299 // however, our dither pattern should be 1/(nfloat+1) to nfloat/(nfloat+1)
3300 // So we do a correction here. Note that the earlier calculations are
3301 // done with powers of 2 so are exact, so it does make sense to delay
3302 // the renormalization to this pass.
3303 float correctionterm = nfloat / (nfloat+1.0F);
3304 for (int i = 0; i < nfloat; i++)
3305 pattern[i] *= correctionterm;
3306 return pattern;
3307}
3308
3309 theDitherMatrix = ut_initDitherRecursive(3);
3310
3311 for (int i = 0; i < 512/8; i ++)
3312 {
3313 for (int j = 0; j < 8; j ++)
3314 std::cout << theDitherMatrix[i*8+j] << "f, ";
3315 std::cout << std::endl;
3316 }
3317
3318 **************/
3319
3320PNANOVDB_STATIC_CONST float pnanovdb_dither_lut[512] =
3321{
3322 0.14425f, 0.643275f, 0.830409f, 0.331384f, 0.105263f, 0.604289f, 0.167641f, 0.666667f,
3323 0.892788f, 0.393762f, 0.0818713f, 0.580897f, 0.853801f, 0.354776f, 0.916179f, 0.417154f,
3324 0.612086f, 0.11306f, 0.79922f, 0.300195f, 0.510721f, 0.0116959f, 0.947368f, 0.448343f,
3325 0.362573f, 0.861598f, 0.0506823f, 0.549708f, 0.261209f, 0.760234f, 0.19883f, 0.697856f,
3326 0.140351f, 0.639376f, 0.576998f, 0.0779727f, 0.522417f, 0.0233918f, 0.460039f, 0.959064f,
3327 0.888889f, 0.389864f, 0.327485f, 0.826511f, 0.272904f, 0.77193f, 0.709552f, 0.210526f,
3328 0.483431f, 0.982456f, 0.296296f, 0.795322f, 0.116959f, 0.615984f, 0.0545809f, 0.553606f,
3329 0.732943f, 0.233918f, 0.545809f, 0.0467836f, 0.865497f, 0.366472f, 0.803119f, 0.304094f,
3330 0.518519f, 0.0194932f, 0.45614f, 0.955166f, 0.729045f, 0.230019f, 0.54191f, 0.042885f,
3331 0.269006f, 0.768031f, 0.705653f, 0.206628f, 0.479532f, 0.978558f, 0.292398f, 0.791423f,
3332 0.237817f, 0.736842f, 0.424951f, 0.923977f, 0.136452f, 0.635478f, 0.323587f, 0.822612f,
3333 0.986355f, 0.487329f, 0.674464f, 0.175439f, 0.88499f, 0.385965f, 0.573099f, 0.0740741f,
3334 0.51462f, 0.0155945f, 0.202729f, 0.701754f, 0.148148f, 0.647174f, 0.834308f, 0.335283f,
3335 0.265107f, 0.764133f, 0.951267f, 0.452242f, 0.896686f, 0.397661f, 0.08577f, 0.584795f,
3336 0.8577f, 0.358674f, 0.920078f, 0.421053f, 0.740741f, 0.241715f, 0.678363f, 0.179337f,
3337 0.109162f, 0.608187f, 0.17154f, 0.670565f, 0.491228f, 0.990253f, 0.42885f, 0.927875f,
3338 0.0662768f, 0.565302f, 0.62768f, 0.128655f, 0.183236f, 0.682261f, 0.744639f, 0.245614f,
3339 0.814815f, 0.315789f, 0.378168f, 0.877193f, 0.931774f, 0.432749f, 0.495127f, 0.994152f,
3340 0.0350877f, 0.534113f, 0.97076f, 0.471735f, 0.214425f, 0.71345f, 0.526316f, 0.0272904f,
3341 0.783626f, 0.2846f, 0.222222f, 0.721248f, 0.962963f, 0.463938f, 0.276803f, 0.775828f,
3342 0.966862f, 0.467836f, 0.405458f, 0.904483f, 0.0701754f, 0.569201f, 0.881092f, 0.382066f,
3343 0.218324f, 0.717349f, 0.654971f, 0.155945f, 0.818713f, 0.319688f, 0.132554f, 0.631579f,
3344 0.0623782f, 0.561404f, 0.748538f, 0.249513f, 0.912281f, 0.413255f, 0.974659f, 0.475634f,
3345 0.810916f, 0.311891f, 0.499025f, 0.998051f, 0.163743f, 0.662768f, 0.226121f, 0.725146f,
3346 0.690058f, 0.191033f, 0.00389864f, 0.502924f, 0.557505f, 0.0584795f, 0.120858f, 0.619883f,
3347 0.440546f, 0.939571f, 0.752437f, 0.253411f, 0.307992f, 0.807018f, 0.869396f, 0.37037f,
3348 0.658869f, 0.159844f, 0.346979f, 0.846004f, 0.588694f, 0.0896686f, 0.152047f, 0.651072f,
3349 0.409357f, 0.908382f, 0.596491f, 0.0974659f, 0.339181f, 0.838207f, 0.900585f, 0.401559f,
3350 0.34308f, 0.842105f, 0.779727f, 0.280702f, 0.693957f, 0.194932f, 0.25731f, 0.756335f,
3351 0.592593f, 0.0935673f, 0.0311891f, 0.530214f, 0.444444f, 0.94347f, 0.506823f, 0.00779727f,
3352 0.68616f, 0.187135f, 0.124756f, 0.623782f, 0.288499f, 0.787524f, 0.350877f, 0.849903f,
3353 0.436647f, 0.935673f, 0.873294f, 0.374269f, 0.538012f, 0.0389864f, 0.60039f, 0.101365f,
3354 0.57115f, 0.0721248f, 0.758285f, 0.259259f, 0.719298f, 0.220273f, 0.532164f, 0.0331384f,
3355 0.321637f, 0.820663f, 0.00974659f, 0.508772f, 0.469786f, 0.968811f, 0.282651f, 0.781676f,
3356 0.539961f, 0.0409357f, 0.727096f, 0.22807f, 0.500975f, 0.00194932f, 0.563353f, 0.0643275f,
3357 0.290448f, 0.789474f, 0.477583f, 0.976608f, 0.251462f, 0.750487f, 0.31384f, 0.812865f,
3358 0.94152f, 0.442495f, 0.879142f, 0.380117f, 0.37232f, 0.871345f, 0.309942f, 0.808967f,
3359 0.192982f, 0.692008f, 0.130604f, 0.62963f, 0.621832f, 0.122807f, 0.559454f, 0.0604289f,
3360 0.660819f, 0.161793f, 0.723197f, 0.224172f, 0.403509f, 0.902534f, 0.840156f, 0.341131f,
3361 0.411306f, 0.910331f, 0.473684f, 0.97271f, 0.653021f, 0.153996f, 0.0916179f, 0.590643f,
3362 0.196881f, 0.695906f, 0.384016f, 0.883041f, 0.0955166f, 0.594542f, 0.157895f, 0.65692f,
3363 0.945419f, 0.446394f, 0.633528f, 0.134503f, 0.844055f, 0.345029f, 0.906433f, 0.407407f,
3364 0.165692f, 0.664717f, 0.103314f, 0.602339f, 0.126706f, 0.625731f, 0.189084f, 0.688109f,
3365 0.91423f, 0.415205f, 0.851852f, 0.352827f, 0.875244f, 0.376218f, 0.937622f, 0.438596f,
3366 0.317739f, 0.816764f, 0.255361f, 0.754386f, 0.996101f, 0.497076f, 0.933723f, 0.434698f,
3367 0.567251f, 0.0682261f, 0.504873f, 0.00584795f, 0.247563f, 0.746589f, 0.185185f, 0.684211f,
3368 0.037037f, 0.536062f, 0.0994152f, 0.598441f, 0.777778f, 0.278752f, 0.465887f, 0.964912f,
3369 0.785575f, 0.28655f, 0.847953f, 0.348928f, 0.0292398f, 0.528265f, 0.7154f, 0.216374f,
3370 0.39961f, 0.898636f, 0.961014f, 0.461988f, 0.0487329f, 0.547758f, 0.111111f, 0.610136f,
3371 0.649123f, 0.150097f, 0.212476f, 0.711501f, 0.797271f, 0.298246f, 0.859649f, 0.360624f,
3372 0.118908f, 0.617934f, 0.0565302f, 0.555556f, 0.329435f, 0.82846f, 0.516569f, 0.0175439f,
3373 0.867446f, 0.368421f, 0.805068f, 0.306043f, 0.578947f, 0.079922f, 0.267057f, 0.766082f,
3374 0.270955f, 0.76998f, 0.707602f, 0.208577f, 0.668616f, 0.169591f, 0.606238f, 0.107212f,
3375 0.520468f, 0.0214425f, 0.45809f, 0.957115f, 0.419103f, 0.918129f, 0.356725f, 0.855751f,
3376 0.988304f, 0.489279f, 0.426901f, 0.925926f, 0.450292f, 0.949318f, 0.512671f, 0.0136452f,
3377 0.239766f, 0.738791f, 0.676413f, 0.177388f, 0.699805f, 0.20078f, 0.263158f, 0.762183f,
3378 0.773879f, 0.274854f, 0.337232f, 0.836257f, 0.672515f, 0.173489f, 0.734893f, 0.235867f,
3379 0.0253411f, 0.524366f, 0.586745f, 0.0877193f, 0.423002f, 0.922027f, 0.48538f, 0.984405f,
3380 0.74269f, 0.243665f, 0.680312f, 0.181287f, 0.953216f, 0.454191f, 0.1423f, 0.641326f,
3381 0.493177f, 0.992203f, 0.430799f, 0.929825f, 0.204678f, 0.703704f, 0.890838f, 0.391813f,
3382 0.894737f, 0.395712f, 0.0838207f, 0.582846f, 0.0448343f, 0.54386f, 0.231969f, 0.730994f,
3383 0.146199f, 0.645224f, 0.832359f, 0.333333f, 0.793372f, 0.294347f, 0.980507f, 0.481481f,
3384 0.364522f, 0.863548f, 0.80117f, 0.302144f, 0.824561f, 0.325536f, 0.138402f, 0.637427f,
3385 0.614035f, 0.11501f, 0.0526316f, 0.551657f, 0.0760234f, 0.575049f, 0.88694f, 0.387914f,
3386};
3387
3388PNANOVDB_FORCE_INLINE float pnanovdb_dither_lookup(pnanovdb_bool_t enabled, int offset)
3389{
3390 return enabled ? pnanovdb_dither_lut[offset & 511] : 0.5f;
3391}
3392
3393// ------------------------------------------------ HDDA -----------------------------------------------------------
3394
3395#ifdef PNANOVDB_HDDA
3396
3397// Comment out to disable this explicit round-off check
3398#define PNANOVDB_ENFORCE_FORWARD_STEPPING
3399
3400#define PNANOVDB_HDDA_FLOAT_MAX 1e38f
3401
3402struct pnanovdb_hdda_t
3403{
3404 pnanovdb_int32_t dim;
3405 float tmin;
3406 float tmax;
3407 pnanovdb_coord_t voxel;
3408 pnanovdb_coord_t step;
3409 pnanovdb_vec3_t delta;
3410 pnanovdb_vec3_t next;
3411};
3412PNANOVDB_STRUCT_TYPEDEF(pnanovdb_hdda_t)
3413
3414PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_hdda_pos_to_ijk(PNANOVDB_IN(pnanovdb_vec3_t) pos)
3415{
3416 pnanovdb_coord_t voxel;
3417 voxel.x = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).x));
3418 voxel.y = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).y));
3419 voxel.z = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).z));
3420 return voxel;
3421}
3422
3423PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_hdda_pos_to_voxel(PNANOVDB_IN(pnanovdb_vec3_t) pos, int dim)
3424{
3425 pnanovdb_coord_t voxel;
3426 voxel.x = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).x)) & (~(dim - 1));
3427 voxel.y = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).y)) & (~(dim - 1));
3428 voxel.z = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).z)) & (~(dim - 1));
3429 return voxel;
3430}
3431
3432PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_hdda_ray_start(PNANOVDB_IN(pnanovdb_vec3_t) origin, float tmin, PNANOVDB_IN(pnanovdb_vec3_t) direction)
3433{
3434 pnanovdb_vec3_t pos = pnanovdb_vec3_add(
3435 pnanovdb_vec3_mul(PNANOVDB_DEREF(direction), pnanovdb_vec3_uniform(tmin)),
3436 PNANOVDB_DEREF(origin)
3437 );
3438 return pos;
3439}
3440
3441PNANOVDB_FORCE_INLINE void pnanovdb_hdda_init(PNANOVDB_INOUT(pnanovdb_hdda_t) hdda, PNANOVDB_IN(pnanovdb_vec3_t) origin, float tmin, PNANOVDB_IN(pnanovdb_vec3_t) direction, float tmax, int dim)
3442{
3443 PNANOVDB_DEREF(hdda).dim = dim;
3444 PNANOVDB_DEREF(hdda).tmin = tmin;
3445 PNANOVDB_DEREF(hdda).tmax = tmax;
3446
3447 pnanovdb_vec3_t pos = pnanovdb_hdda_ray_start(origin, tmin, direction);
3448 pnanovdb_vec3_t dir_inv = pnanovdb_vec3_div(pnanovdb_vec3_uniform(1.f), PNANOVDB_DEREF(direction));
3449
3450 PNANOVDB_DEREF(hdda).voxel = pnanovdb_hdda_pos_to_voxel(PNANOVDB_REF(pos), dim);
3451
3452 // x
3453 if (PNANOVDB_DEREF(direction).x == 0.f)
3454 {
3455 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_HDDA_FLOAT_MAX;
3456 PNANOVDB_DEREF(hdda).step.x = 0;
3457 PNANOVDB_DEREF(hdda).delta.x = 0.f;
3458 }
3459 else if (dir_inv.x > 0.f)
3460 {
3461 PNANOVDB_DEREF(hdda).step.x = 1;
3462 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.x + dim - pos.x) * dir_inv.x;
3463 PNANOVDB_DEREF(hdda).delta.x = dir_inv.x;
3464 }
3465 else
3466 {
3467 PNANOVDB_DEREF(hdda).step.x = -1;
3468 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.x - pos.x) * dir_inv.x;
3469 PNANOVDB_DEREF(hdda).delta.x = -dir_inv.x;
3470 }
3471
3472 // y
3473 if (PNANOVDB_DEREF(direction).y == 0.f)
3474 {
3475 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_HDDA_FLOAT_MAX;
3476 PNANOVDB_DEREF(hdda).step.y = 0;
3477 PNANOVDB_DEREF(hdda).delta.y = 0.f;
3478 }
3479 else if (dir_inv.y > 0.f)
3480 {
3481 PNANOVDB_DEREF(hdda).step.y = 1;
3482 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.y + dim - pos.y) * dir_inv.y;
3483 PNANOVDB_DEREF(hdda).delta.y = dir_inv.y;
3484 }
3485 else
3486 {
3487 PNANOVDB_DEREF(hdda).step.y = -1;
3488 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.y - pos.y) * dir_inv.y;
3489 PNANOVDB_DEREF(hdda).delta.y = -dir_inv.y;
3490 }
3491
3492 // z
3493 if (PNANOVDB_DEREF(direction).z == 0.f)
3494 {
3495 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_HDDA_FLOAT_MAX;
3496 PNANOVDB_DEREF(hdda).step.z = 0;
3497 PNANOVDB_DEREF(hdda).delta.z = 0.f;
3498 }
3499 else if (dir_inv.z > 0.f)
3500 {
3501 PNANOVDB_DEREF(hdda).step.z = 1;
3502 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.z + dim - pos.z) * dir_inv.z;
3503 PNANOVDB_DEREF(hdda).delta.z = dir_inv.z;
3504 }
3505 else
3506 {
3507 PNANOVDB_DEREF(hdda).step.z = -1;
3508 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.z - pos.z) * dir_inv.z;
3509 PNANOVDB_DEREF(hdda).delta.z = -dir_inv.z;
3510 }
3511}
3512
3513PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_hdda_update(PNANOVDB_INOUT(pnanovdb_hdda_t) hdda, PNANOVDB_IN(pnanovdb_vec3_t) origin, PNANOVDB_IN(pnanovdb_vec3_t) direction, int dim)
3514{
3515 if (PNANOVDB_DEREF(hdda).dim == dim)
3516 {
3517 return PNANOVDB_FALSE;
3518 }
3519
3520 // compute valid voxel range
3521 pnanovdb_coord_t voxel_max = {
3522 (PNANOVDB_DEREF(hdda).voxel.x + PNANOVDB_DEREF(hdda).dim - 1) & (~(dim - 1)),
3523 (PNANOVDB_DEREF(hdda).voxel.y + PNANOVDB_DEREF(hdda).dim - 1) & (~(dim - 1)),
3524 (PNANOVDB_DEREF(hdda).voxel.z + PNANOVDB_DEREF(hdda).dim - 1) & (~(dim - 1))
3525 };
3526 pnanovdb_coord_t voxel_min = {
3527 PNANOVDB_DEREF(hdda).voxel.x & (~(dim - 1)),
3528 PNANOVDB_DEREF(hdda).voxel.y & (~(dim - 1)),
3529 PNANOVDB_DEREF(hdda).voxel.z & (~(dim - 1))
3530 };
3531
3532 PNANOVDB_DEREF(hdda).dim = dim;
3533
3534 pnanovdb_vec3_t pos = pnanovdb_vec3_add(
3535 pnanovdb_vec3_mul(PNANOVDB_DEREF(direction), pnanovdb_vec3_uniform(PNANOVDB_DEREF(hdda).tmin)),
3536 PNANOVDB_DEREF(origin)
3537 );
3538 pnanovdb_vec3_t dir_inv = pnanovdb_vec3_div(pnanovdb_vec3_uniform(1.f), PNANOVDB_DEREF(direction));
3539
3540 PNANOVDB_DEREF(hdda).voxel = pnanovdb_hdda_pos_to_voxel(PNANOVDB_REF(pos), dim);
3541
3542 // clamp voxel to valid range
3543 PNANOVDB_DEREF(hdda).voxel.x = PNANOVDB_DEREF(hdda).voxel.x < voxel_max.x ? PNANOVDB_DEREF(hdda).voxel.x : voxel_max.x;
3544 PNANOVDB_DEREF(hdda).voxel.y = PNANOVDB_DEREF(hdda).voxel.y < voxel_max.y ? PNANOVDB_DEREF(hdda).voxel.y : voxel_max.y;
3545 PNANOVDB_DEREF(hdda).voxel.z = PNANOVDB_DEREF(hdda).voxel.z < voxel_max.z ? PNANOVDB_DEREF(hdda).voxel.z : voxel_max.z;
3546 PNANOVDB_DEREF(hdda).voxel.x = PNANOVDB_DEREF(hdda).voxel.x > voxel_min.x ? PNANOVDB_DEREF(hdda).voxel.x : voxel_min.x;
3547 PNANOVDB_DEREF(hdda).voxel.y = PNANOVDB_DEREF(hdda).voxel.y > voxel_min.y ? PNANOVDB_DEREF(hdda).voxel.y : voxel_min.y;
3548 PNANOVDB_DEREF(hdda).voxel.z = PNANOVDB_DEREF(hdda).voxel.z > voxel_min.z ? PNANOVDB_DEREF(hdda).voxel.z : voxel_min.z;
3549
3550 if (PNANOVDB_DEREF(hdda).step.x != 0)
3551 {
3552 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.x - pos.x) * dir_inv.x;
3553 if (PNANOVDB_DEREF(hdda).step.x > 0)
3554 {
3555 PNANOVDB_DEREF(hdda).next.x += dim * dir_inv.x;
3556 }
3557 }
3558 if (PNANOVDB_DEREF(hdda).step.y != 0)
3559 {
3560 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.y - pos.y) * dir_inv.y;
3561 if (PNANOVDB_DEREF(hdda).step.y > 0)
3562 {
3563 PNANOVDB_DEREF(hdda).next.y += dim * dir_inv.y;
3564 }
3565 }
3566 if (PNANOVDB_DEREF(hdda).step.z != 0)
3567 {
3568 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.z - pos.z) * dir_inv.z;
3569 if (PNANOVDB_DEREF(hdda).step.z > 0)
3570 {
3571 PNANOVDB_DEREF(hdda).next.z += dim * dir_inv.z;
3572 }
3573 }
3574
3575 return PNANOVDB_TRUE;
3576}
3577
3578PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_hdda_step(PNANOVDB_INOUT(pnanovdb_hdda_t) hdda)
3579{
3580 pnanovdb_bool_t ret;
3581 if (PNANOVDB_DEREF(hdda).next.x < PNANOVDB_DEREF(hdda).next.y && PNANOVDB_DEREF(hdda).next.x < PNANOVDB_DEREF(hdda).next.z)
3582 {
3583#ifdef PNANOVDB_ENFORCE_FORWARD_STEPPING
3584 if (PNANOVDB_DEREF(hdda).next.x <= PNANOVDB_DEREF(hdda).tmin)
3585 {
3586 PNANOVDB_DEREF(hdda).next.x += PNANOVDB_DEREF(hdda).tmin - 0.999999f * PNANOVDB_DEREF(hdda).next.x + 1.0e-6f;
3587 }
3588#endif
3589 PNANOVDB_DEREF(hdda).tmin = PNANOVDB_DEREF(hdda).next.x;
3590 PNANOVDB_DEREF(hdda).next.x += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).delta.x;
3591 PNANOVDB_DEREF(hdda).voxel.x += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).step.x;
3592 ret = PNANOVDB_DEREF(hdda).tmin <= PNANOVDB_DEREF(hdda).tmax;
3593 }
3594 else if (PNANOVDB_DEREF(hdda).next.y < PNANOVDB_DEREF(hdda).next.z)
3595 {
3596#ifdef PNANOVDB_ENFORCE_FORWARD_STEPPING
3597 if (PNANOVDB_DEREF(hdda).next.y <= PNANOVDB_DEREF(hdda).tmin)
3598 {
3599 PNANOVDB_DEREF(hdda).next.y += PNANOVDB_DEREF(hdda).tmin - 0.999999f * PNANOVDB_DEREF(hdda).next.y + 1.0e-6f;
3600 }
3601#endif
3602 PNANOVDB_DEREF(hdda).tmin = PNANOVDB_DEREF(hdda).next.y;
3603 PNANOVDB_DEREF(hdda).next.y += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).delta.y;
3604 PNANOVDB_DEREF(hdda).voxel.y += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).step.y;
3605 ret = PNANOVDB_DEREF(hdda).tmin <= PNANOVDB_DEREF(hdda).tmax;
3606 }
3607 else
3608 {
3609#ifdef PNANOVDB_ENFORCE_FORWARD_STEPPING
3610 if (PNANOVDB_DEREF(hdda).next.z <= PNANOVDB_DEREF(hdda).tmin)
3611 {
3612 PNANOVDB_DEREF(hdda).next.z += PNANOVDB_DEREF(hdda).tmin - 0.999999f * PNANOVDB_DEREF(hdda).next.z + 1.0e-6f;
3613 }
3614#endif
3615 PNANOVDB_DEREF(hdda).tmin = PNANOVDB_DEREF(hdda).next.z;
3616 PNANOVDB_DEREF(hdda).next.z += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).delta.z;
3617 PNANOVDB_DEREF(hdda).voxel.z += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).step.z;
3618 ret = PNANOVDB_DEREF(hdda).tmin <= PNANOVDB_DEREF(hdda).tmax;
3619 }
3620 return ret;
3621}
3622
3623PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_hdda_ray_clip(
3624 PNANOVDB_IN(pnanovdb_vec3_t) bbox_min,
3625 PNANOVDB_IN(pnanovdb_vec3_t) bbox_max,
3626 PNANOVDB_IN(pnanovdb_vec3_t) origin, PNANOVDB_INOUT(float) tmin,
3627 PNANOVDB_IN(pnanovdb_vec3_t) direction, PNANOVDB_INOUT(float) tmax
3628)
3629{
3630 pnanovdb_vec3_t dir_inv = pnanovdb_vec3_div(pnanovdb_vec3_uniform(1.f), PNANOVDB_DEREF(direction));
3631 pnanovdb_vec3_t t0 = pnanovdb_vec3_mul(pnanovdb_vec3_sub(PNANOVDB_DEREF(bbox_min), PNANOVDB_DEREF(origin)), dir_inv);
3632 pnanovdb_vec3_t t1 = pnanovdb_vec3_mul(pnanovdb_vec3_sub(PNANOVDB_DEREF(bbox_max), PNANOVDB_DEREF(origin)), dir_inv);
3633 pnanovdb_vec3_t tmin3 = pnanovdb_vec3_min(t0, t1);
3634 pnanovdb_vec3_t tmax3 = pnanovdb_vec3_max(t0, t1);
3635 float tnear = pnanovdb_max(tmin3.x, pnanovdb_max(tmin3.y, tmin3.z));
3636 float tfar = pnanovdb_min(tmax3.x, pnanovdb_min(tmax3.y, tmax3.z));
3637 pnanovdb_bool_t hit = tnear <= tfar;
3638 PNANOVDB_DEREF(tmin) = pnanovdb_max(PNANOVDB_DEREF(tmin), tnear);
3639 PNANOVDB_DEREF(tmax) = pnanovdb_min(PNANOVDB_DEREF(tmax), tfar);
3640 return hit;
3641}
3642
3643PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_hdda_zero_crossing(
3644 pnanovdb_grid_type_t grid_type,
3645 pnanovdb_buf_t buf,
3646 PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc,
3647 PNANOVDB_IN(pnanovdb_vec3_t) origin, float tmin,
3648 PNANOVDB_IN(pnanovdb_vec3_t) direction, float tmax,
3649 PNANOVDB_INOUT(float) thit,
3650 PNANOVDB_INOUT(float) v
3651)
3652{
3653 pnanovdb_coord_t bbox_min = pnanovdb_root_get_bbox_min(buf, PNANOVDB_DEREF(acc).root);
3654 pnanovdb_coord_t bbox_max = pnanovdb_root_get_bbox_max(buf, PNANOVDB_DEREF(acc).root);
3655 pnanovdb_vec3_t bbox_minf = pnanovdb_coord_to_vec3(bbox_min);
3656 pnanovdb_vec3_t bbox_maxf = pnanovdb_coord_to_vec3(pnanovdb_coord_add(bbox_max, pnanovdb_coord_uniform(1)));
3657
3658 pnanovdb_bool_t hit = pnanovdb_hdda_ray_clip(PNANOVDB_REF(bbox_minf), PNANOVDB_REF(bbox_maxf), origin, PNANOVDB_REF(tmin), direction, PNANOVDB_REF(tmax));
3659 if (!hit || tmax > 1.0e20f)
3660 {
3661 return PNANOVDB_FALSE;
3662 }
3663
3664 pnanovdb_vec3_t pos = pnanovdb_hdda_ray_start(origin, tmin, direction);
3665 pnanovdb_coord_t ijk = pnanovdb_hdda_pos_to_ijk(PNANOVDB_REF(pos));
3666
3667 pnanovdb_address_t address = pnanovdb_readaccessor_get_value_address(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk));
3668 float v0 = pnanovdb_read_float(buf, address);
3669
3670 pnanovdb_int32_t dim = pnanovdb_uint32_as_int32(pnanovdb_readaccessor_get_dim(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk)));
3671 pnanovdb_hdda_t hdda;
3672 pnanovdb_hdda_init(PNANOVDB_REF(hdda), origin, tmin, direction, tmax, dim);
3673 while (pnanovdb_hdda_step(PNANOVDB_REF(hdda)))
3674 {
3675 pnanovdb_vec3_t pos_start = pnanovdb_hdda_ray_start(origin, hdda.tmin + 1.0001f, direction);
3676 ijk = pnanovdb_hdda_pos_to_ijk(PNANOVDB_REF(pos_start));
3677 dim = pnanovdb_uint32_as_int32(pnanovdb_readaccessor_get_dim(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk)));
3678 pnanovdb_hdda_update(PNANOVDB_REF(hdda), origin, direction, dim);
3679 if (hdda.dim > 1 || !pnanovdb_readaccessor_is_active(grid_type, buf, acc, PNANOVDB_REF(ijk)))
3680 {
3681 continue;
3682 }
3683 while (pnanovdb_hdda_step(PNANOVDB_REF(hdda)) && pnanovdb_readaccessor_is_active(grid_type, buf, acc, PNANOVDB_REF(hdda.voxel)))
3684 {
3685 ijk = hdda.voxel;
3686 pnanovdb_address_t address = pnanovdb_readaccessor_get_value_address(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk));
3687 PNANOVDB_DEREF(v) = pnanovdb_read_float(buf, address);
3688 if (PNANOVDB_DEREF(v) * v0 < 0.f)
3689 {
3690 PNANOVDB_DEREF(thit) = hdda.tmin;
3691 return PNANOVDB_TRUE;
3692 }
3693 }
3694 }
3695 return PNANOVDB_FALSE;
3696}
3697
3698#endif
3699
3700#endif // end of NANOVDB_PNANOVDB_H_HAS_BEEN_INCLUDED
pnanovdb_version_get_minor
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_version_get_minor(pnanovdb_uint32_t version)
Definition PNanoVDB.h:1405
pnanovdb_tree_set_tile_count_root
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_tile_count_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t tile_count_root)
Definition PNanoVDB.h:1594
PNANOVDB_GRID_OFF_VERSION
#define PNANOVDB_GRID_OFF_VERSION
Definition PNanoVDB.h:1270
pnanovdb_readaccessor_get_value_address_and_level
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_readaccessor_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
Definition PNanoVDB.h:2944
pnanovdb_gridblindmetadata_get_semantic
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_semantic(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p)
Definition PNanoVDB.h:1466
pnanovdb_root_get_value_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2643
pnanovdb_leaf_set_value_mask
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_set_value_mask(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value)
Definition PNanoVDB.h:1841
PNANOVDB_UPPER_OFF_VALUE_MASK
#define PNANOVDB_UPPER_OFF_VALUE_MASK
Definition PNanoVDB.h:1697
pnanovdb_map_get_matf
PNANOVDB_FORCE_INLINE float pnanovdb_map_get_matf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1191
PNANOVDB_TREE_OFF_NODE_COUNT_LOWER
#define PNANOVDB_TREE_OFF_NODE_COUNT_LOWER
Definition PNanoVDB.h:1526
PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_COUNT
#define PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_COUNT
Definition PNanoVDB.h:1450
pnanovdb_gridblindmetadata_get_data_offset
PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_gridblindmetadata_get_data_offset(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p)
Definition PNanoVDB.h:1457
pnanovdb_dither_lut
PNANOVDB_STATIC_CONST float pnanovdb_dither_lut[512]
Definition PNanoVDB.h:3320
pnanovdb_gridblindmetadata_get_value_size
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_value_size(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p)
Definition PNanoVDB.h:1463
pnanovdb_root_tile_get_state
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_root_tile_get_state(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p)
Definition PNanoVDB.h:1663
pnanovdb_root_get_tile_count
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_root_get_tile_count(pnanovdb_buf_t buf, pnanovdb_root_handle_t p)
Definition PNanoVDB.h:1625
pnanovdb_read_coord
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_read_coord(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:970
pnanovdb_lower_set_value_mask
PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_value_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value)
Definition PNanoVDB.h:1786
PNANOVDB_UPPER_OFF_FLAGS
#define PNANOVDB_UPPER_OFF_FLAGS
Definition PNanoVDB.h:1696
PNANOVDB_GRID_TYPE_CAP
#define PNANOVDB_GRID_TYPE_CAP
Definition PNanoVDB.h:1122
PNANOVDB_GRID_TYPE_FLOAT
#define PNANOVDB_GRID_TYPE_FLOAT
Definition PNanoVDB.h:1094
pnanovdb_map_get_invmatf
PNANOVDB_FORCE_INLINE float pnanovdb_map_get_invmatf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1194
pnanovdb_dither_lookup
PNANOVDB_FORCE_INLINE float pnanovdb_dither_lookup(pnanovdb_bool_t enabled, int offset)
Definition PNanoVDB.h:3388
pnanovdb_uint64_dec
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_dec(pnanovdb_uint64_t a)
Definition PNanoVDB.h:773
pnanovdb_leaf_indexmask_get_ave_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
Definition PNanoVDB.h:2170
pnanovdb_leaf_indexmask_get_dev_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
Definition PNanoVDB.h:2174
pnanovdb_leaf_index_get_max_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
Definition PNanoVDB.h:2134
pnanovdb_root_onindex_get_value_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_onindex_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
Definition PNanoVDB.h:2727
pnanovdb_grid_set_blind_metadata_offset
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_blind_metadata_offset(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t blind_metadata_offset)
Definition PNanoVDB.h:1380
pnanovdb_gridblindmetadata_get_data_type
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_data_type(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p)
Definition PNanoVDB.h:1472
pnanovdb_root_get_stddev_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:2609
pnanovdb_lower_get_value_mask
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_lower_get_value_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index)
Definition PNanoVDB.h:1771
PNANOVDB_GRID_OFF_BLIND_METADATA_OFFSET
#define PNANOVDB_GRID_OFF_BLIND_METADATA_OFFSET
Definition PNanoVDB.h:1281
PNANOVDB_MAP_OFF_MATF
#define PNANOVDB_MAP_OFF_MATF
Definition PNanoVDB.h:1182
pnanovdb_upper_get_flags
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_upper_get_flags(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p)
Definition PNanoVDB.h:1706
pnanovdb_leaf_coord_to_offset
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2038
PNANOVDB_ROOT_OFF_BBOX_MIN
#define PNANOVDB_ROOT_OFF_BBOX_MIN
Definition PNanoVDB.h:1615
pnanovdb_lower_get_stddev_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
Definition PNanoVDB.h:2437
pnanovdb_leaf_onindexmask_get_value_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2328
pnanovdb_root_tile_get_value_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_tile_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t root_tile)
Definition PNanoVDB.h:2615
pnanovdb_grid_set_flags
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_flags(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t flags)
Definition PNanoVDB.h:1353
pnanovdb_grid_type_value_strides_bits
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_value_strides_bits[32]
Definition PNanoVDB.h:1153
pnanovdb_upper_is_active_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_upper_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:3098
pnanovdb_uint64_bit_mask
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_bit_mask(pnanovdb_uint32_t bit_idx)
Definition PNanoVDB.h:783
pnanovdb_gridblindmetadata_get_name
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_name(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1475
pnanovdb_root_is_active_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_root_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:3116
PNANOVDB_ROOT_TILE_OFF_CHILD
#define PNANOVDB_ROOT_TILE_OFF_CHILD
Definition PNanoVDB.h:1654
pnanovdb_tree_set_node_count_lower
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t node_count_lower)
Definition PNanoVDB.h:1582
pnanovdb_uint64_to_uint32_lsr
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint64_to_uint32_lsr(pnanovdb_uint64_t a, pnanovdb_uint32_t b)
Definition PNanoVDB.h:778
pnanovdb_lower_get_value_address_and_level_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address_and_level_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
Definition PNanoVDB.h:2863
pnanovdb_grid_set_grid_size
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t grid_size)
Definition PNanoVDB.h:1362
PNANOVDB_GRID_OFF_GRID_COUNT
#define PNANOVDB_GRID_OFF_GRID_COUNT
Definition PNanoVDB.h:1273
pnanovdb_grid_get_grid_class
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_class(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1322
pnanovdb_tree_get_node_offset_lower
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1536
pnanovdb_grid_set_checksum
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_checksum(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t checksum)
Definition PNanoVDB.h:1347
pnanovdb_lower_get_value_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2480
pnanovdb_uint64_any_bit
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_uint64_any_bit(pnanovdb_uint64_t a)
Definition PNanoVDB.h:793
PNANOVDB_LEAF_OFF_VALUE_MASK
#define PNANOVDB_LEAF_OFF_VALUE_MASK
Definition PNanoVDB.h:1818
pnanovdb_grid_type_table_strides_bits
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_table_strides_bits[32]
Definition PNanoVDB.h:1155
pnanovdb_lower_get_bbox_max
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_lower_get_bbox_max(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p)
Definition PNanoVDB.h:1765
pnanovdb_tree_get_tile_count_lower
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_tile_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1554
pnanovdb_read_vec3u8
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_read_vec3u8(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:1006
PNANOVDB_GRID_OFF_DATA2
#define PNANOVDB_GRID_OFF_DATA2
Definition PNanoVDB.h:1285
pnanovdb_tree_set_node_offset_leaf
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_leaf)
Definition PNanoVDB.h:1567
pnanovdb_leaf_set_bbox_min
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min)
Definition PNanoVDB.h:1835
pnanovdb_tree_set_first_root
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:2032
pnanovdb_leaf_pointindex_get_point_count
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_point_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2363
pnanovdb_lower_get_value_address_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:2883
pnanovdb_read_bit
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_read_bit(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_uint32_t bit_offset)
Definition PNanoVDB.h:1016
pnanovdb_root_get_bbox_max
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_root_get_bbox_max(pnanovdb_buf_t buf, pnanovdb_root_handle_t p)
Definition PNanoVDB.h:1622
pnanovdb_root_get_value_address_and_level
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
Definition PNanoVDB.h:2621
pnanovdb_write_float
PNANOVDB_FORCE_INLINE void pnanovdb_write_float(pnanovdb_buf_t buf, pnanovdb_address_t address, float value)
Definition PNanoVDB.h:1062
pnanovdb_leaf_pointindex_set_on
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_pointindex_set_on(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
Definition PNanoVDB.h:2395
pnanovdb_gridblindmetadata_set_value_size
PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_value_size(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t value_size)
Definition PNanoVDB.h:1485
pnanovdb_leaf_get_value_mask
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_get_value_mask(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, pnanovdb_uint32_t bit_index)
Definition PNanoVDB.h:1830
PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_SIZE
#define PNANOVDB_GRIDBLINDMETADATA_OFF_VALUE_SIZE
Definition PNanoVDB.h:1451
pnanovdb_grid_set_blind_metadata_count
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_blind_metadata_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t metadata_count)
Definition PNanoVDB.h:1383
pnanovdb_root_set_tile_count
PNANOVDB_FORCE_INLINE void pnanovdb_root_set_tile_count(pnanovdb_buf_t buf, pnanovdb_root_handle_t p, pnanovdb_uint32_t tile_count)
Definition PNanoVDB.h:1635
PNANOVDB_MAP_OFF_VECD
#define PNANOVDB_MAP_OFF_VECD
Definition PNanoVDB.h:1188
pnanovdb_lower_get_value_address_and_level
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
Definition PNanoVDB.h:2462
pnanovdb_tree_set_voxel_count
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_voxel_count(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t voxel_count)
Definition PNanoVDB.h:1597
PNANOVDB_ROOT_OFF_TABLE_SIZE
#define PNANOVDB_ROOT_OFF_TABLE_SIZE
Definition PNanoVDB.h:1617
pnanovdb_leaf_get_bbox_min
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_leaf_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p)
Definition PNanoVDB.h:1824
PNANOVDB_LEAF_OFF_BBOX_DIF_AND_FLAGS
#define PNANOVDB_LEAF_OFF_BBOX_DIF_AND_FLAGS
Definition PNanoVDB.h:1817
pnanovdb_lower_set_child
PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, pnanovdb_uint32_t n, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2492
pnanovdb_uint64_offset
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_offset(pnanovdb_uint64_t a, pnanovdb_uint32_t b)
Definition PNanoVDB.h:763
pnanovdb_gridblindmetadata_get_value_count
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_gridblindmetadata_get_value_count(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p)
Definition PNanoVDB.h:1460
pnanovdb_grid_get_gridblindmetadata
PNANOVDB_FORCE_INLINE pnanovdb_gridblindmetadata_handle_t pnanovdb_grid_get_gridblindmetadata(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1917
pnanovdb_root_get_dim_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_root_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:3026
pnanovdb_upper_get_bbox_max
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_upper_get_bbox_max(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p)
Definition PNanoVDB.h:1703
PNANOVDB_LOWER_OFF_FLAGS
#define PNANOVDB_LOWER_OFF_FLAGS
Definition PNanoVDB.h:1758
pnanovdb_grid_get_version
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_version(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1293
pnanovdb_readaccessor_get_value_address_bit
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_readaccessor_get_value_address_bit(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) bit_index)
Definition PNanoVDB.h:2975
pnanovdb_map_get_taperf
PNANOVDB_FORCE_INLINE float pnanovdb_map_get_taperf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1200
pnanovdb_leaf_get_dim_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:2985
pnanovdb_leaf_onindexmask_get_max_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
Definition PNanoVDB.h:2316
pnanovdb_grid_set_version
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_version(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t version)
Definition PNanoVDB.h:1350
pnanovdb_map_set_taperd
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_taperd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double taperd)
Definition PNanoVDB.h:1237
pnanovdb_tree_get_node_offset_root
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1542
pnanovdb_tree_get_node_offset_leaf
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1533
pnanovdb_uint64_and
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_and(pnanovdb_uint64_t a, pnanovdb_uint64_t b)
Definition PNanoVDB.h:788
pnanovdb_lower_get_min_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
Definition PNanoVDB.h:2419
pnanovdb_tree_set_first_lower
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_lower_handle_t lower)
Definition PNanoVDB.h:2026
pnanovdb_map_apply
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3165
pnanovdb_leaf_onindex_get_ave_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
Definition PNanoVDB.h:2251
pnanovdb_grid_type_minmax_strides_bits
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_minmax_strides_bits[32]
Definition PNanoVDB.h:1157
pnanovdb_leaf_onindex_get_last_offset
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_last_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2217
pnanovdb_upper_get_stddev_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
Definition PNanoVDB.h:2524
PNANOVDB_GRID_TYPE_ONINDEX
#define PNANOVDB_GRID_TYPE_ONINDEX
Definition PNanoVDB.h:1113
pnanovdb_uint32_countbits
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint32_countbits(pnanovdb_uint32_t value)
Definition PNanoVDB.h:670
pnanovdb_grid_world_to_index_dirf
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_world_to_index_dirf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3225
pnanovdb_lower_get_table_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_table_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2443
pnanovdb_leaf_indexmask_get_value_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2178
pnanovdb_leaf_pointindex_get_last
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_last(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
Definition PNanoVDB.h:2372
pnanovdb_write_double
PNANOVDB_FORCE_INLINE void pnanovdb_write_double(pnanovdb_buf_t buf, pnanovdb_address_t address, double value)
Definition PNanoVDB.h:1066
pnanovdb_lower_get_flags
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_lower_get_flags(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p)
Definition PNanoVDB.h:1768
pnanovdb_grid_index_to_worldf
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_index_to_worldf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3219
pnanovdb_grid_type_stat_strides_bits
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_stat_strides_bits[32]
Definition PNanoVDB.h:1161
pnanovdb_upper_get_value_mask
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_upper_get_value_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index)
Definition PNanoVDB.h:1709
pnanovdb_tree_set_tile_count_lower
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_tile_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t tile_count_lower)
Definition PNanoVDB.h:1588
pnanovdb_leaf_onindexmask_get_min_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
Definition PNanoVDB.h:2312
pnanovdb_map_set_invmatd
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_invmatd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double invmatd)
Definition PNanoVDB.h:1231
pnanovdb_root_get_child
PNANOVDB_FORCE_INLINE pnanovdb_upper_handle_t pnanovdb_root_get_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, pnanovdb_root_tile_handle_t tile)
Definition PNanoVDB.h:1969
pnanovdb_uint64_countbits
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_uint64_countbits(pnanovdb_uint64_t value)
Definition PNanoVDB.h:690
PNANOVDB_GRID_OFF_GRID_INDEX
#define PNANOVDB_GRID_OFF_GRID_INDEX
Definition PNanoVDB.h:1272
pnanovdb_grid_get_blind_metadata_count
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_blind_metadata_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1331
pnanovdb_lower_coord_to_offset
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_lower_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2412
pnanovdb_leaf_pointindex_set_value
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_pointindex_set_value(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i, pnanovdb_uint32_t value)
Definition PNanoVDB.h:2404
PNANOVDB_UPPER_OFF_BBOX_MIN
#define PNANOVDB_UPPER_OFF_BBOX_MIN
Definition PNanoVDB.h:1694
pnanovdb_grid_set_data1
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_data1(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t data1)
Definition PNanoVDB.h:1389
pnanovdb_lower_get_table_child
PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_lower_get_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2449
PNANOVDB_GRID_OFF_MAP
#define PNANOVDB_GRID_OFF_MAP
Definition PNanoVDB.h:1276
PNANOVDB_LOWER_OFF_BBOX_MIN
#define PNANOVDB_LOWER_OFF_BBOX_MIN
Definition PNanoVDB.h:1756
pnanovdb_root_tile_set_child
PNANOVDB_FORCE_INLINE void pnanovdb_root_tile_set_child(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p, pnanovdb_int64_t child)
Definition PNanoVDB.h:1670
pnanovdb_tree_set_node_offset_root
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_root)
Definition PNanoVDB.h:1576
pnanovdb_leaf_fp16_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp16_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2109
pnanovdb_grid_set_grid_type
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_type(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_type)
Definition PNanoVDB.h:1377
pnanovdb_readaccessor_iscached2
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached2(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
Definition PNanoVDB.h:2842
PNANOVDB_GRIDBLINDMETADATA_OFF_SEMANTIC
#define PNANOVDB_GRIDBLINDMETADATA_OFF_SEMANTIC
Definition PNanoVDB.h:1452
PNANOVDB_GRID_OFF_WORLD_BBOX
#define PNANOVDB_GRID_OFF_WORLD_BBOX
Definition PNanoVDB.h:1277
PNANOVDB_TREE_OFF_NODE_OFFSET_UPPER
#define PNANOVDB_TREE_OFF_NODE_OFFSET_UPPER
Definition PNanoVDB.h:1523
pnanovdb_grid_set_data0
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_data0(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t data0)
Definition PNanoVDB.h:1386
pnanovdb_tree_get_voxel_count
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_voxel_count(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1563
pnanovdb_grid_get_map
PNANOVDB_FORCE_INLINE pnanovdb_map_handle_t pnanovdb_grid_get_map(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1311
pnanovdb_leaf_get_value_address_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:2857
PNANOVDB_LOWER_OFF_VALUE_MASK
#define PNANOVDB_LOWER_OFF_VALUE_MASK
Definition PNanoVDB.h:1759
pnanovdb_tree_set_first_leaf
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2023
pnanovdb_map_get_matd
PNANOVDB_FORCE_INLINE double pnanovdb_map_get_matd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1203
pnanovdb_root_get_tile_zero
PNANOVDB_FORCE_INLINE pnanovdb_root_tile_handle_t pnanovdb_root_get_tile_zero(pnanovdb_grid_type_t grid_type, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:1957
pnanovdb_write_int32
PNANOVDB_FORCE_INLINE void pnanovdb_write_int32(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_int32_t value)
Definition PNanoVDB.h:1054
PNANOVDB_ROOT_OFF_BBOX_MAX
#define PNANOVDB_ROOT_OFF_BBOX_MAX
Definition PNanoVDB.h:1616
pnanovdb_write_uint64
PNANOVDB_FORCE_INLINE void pnanovdb_write_uint64(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_uint64_t value)
Definition PNanoVDB.h:1050
PNANOVDB_UPPER_OFF_CHILD_MASK
#define PNANOVDB_UPPER_OFF_CHILD_MASK
Definition PNanoVDB.h:1698
pnanovdb_leaf_onindex_get_max_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
Definition PNanoVDB.h:2240
pnanovdb_grid_type_minmax_aligns_bits
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_minmax_aligns_bits[32]
Definition PNanoVDB.h:1159
pnanovdb_tree_set_tile_count_upper
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_tile_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t tile_count_upper)
Definition PNanoVDB.h:1591
pnanovdb_grid_type_constants
PNANOVDB_STATIC_CONST pnanovdb_grid_type_constants_t pnanovdb_grid_type_constants[32]
Definition PNanoVDB.h:1883
pnanovdb_tree_get_tile_count_root
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_tile_count_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1560
PNANOVDB_MAP_OFF_VECF
#define PNANOVDB_MAP_OFF_VECF
Definition PNanoVDB.h:1184
pnanovdb_lower_set_bbox_max
PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_bbox_max(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_max)
Definition PNanoVDB.h:1783
PNANOVDB_GRID_TYPE_VEC3U16
#define PNANOVDB_GRID_TYPE_VEC3U16
Definition PNanoVDB.h:1118
pnanovdb_uint64_diff
PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_uint64_diff(pnanovdb_uint64_t a, pnanovdb_uint64_t b)
Definition PNanoVDB.h:768
pnanovdb_root_set_bbox_min
PNANOVDB_FORCE_INLINE void pnanovdb_root_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_root_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min)
Definition PNanoVDB.h:1629
pnanovdb_make_version
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_make_version(pnanovdb_uint32_t major, pnanovdb_uint32_t minor, pnanovdb_uint32_t patch_num)
Definition PNanoVDB.h:1396
pnanovdb_upper_get_value_address_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:2908
pnanovdb_grid_set_grid_index
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_index(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_index)
Definition PNanoVDB.h:1356
PNANOVDB_TREE_OFF_VOXEL_COUNT
#define PNANOVDB_TREE_OFF_VOXEL_COUNT
Definition PNanoVDB.h:1531
pnanovdb_write_vec3
PNANOVDB_FORCE_INLINE void pnanovdb_write_vec3(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_vec3_t) value)
Definition PNanoVDB.h:1076
pnanovdb_map_set_invmatf
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_invmatf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float invmatf)
Definition PNanoVDB.h:1219
pnanovdb_upper_set_table_child
PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node, pnanovdb_uint32_t n, pnanovdb_int64_t child)
Definition PNanoVDB.h:2572
pnanovdb_lower_set_table_child
PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node, pnanovdb_uint32_t n, pnanovdb_int64_t child)
Definition PNanoVDB.h:2486
pnanovdb_map_set_vecf
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_vecf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float vecf)
Definition PNanoVDB.h:1222
pnanovdb_leaf_fp4_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp4_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2099
pnanovdb_root_get_value_address_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:2938
pnanovdb_upper_get_value_address_and_level
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address_and_level(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
Definition PNanoVDB.h:2549
pnanovdb_leaf_pointindex_get_value
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_value(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
Definition PNanoVDB.h:2377
PNANOVDB_GRID_TYPE_POINTINDEX
#define PNANOVDB_GRID_TYPE_POINTINDEX
Definition PNanoVDB.h:1116
pnanovdb_grid_get_data2
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_data2(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1340
PNANOVDB_LEAF_TABLE_NEG_OFF_QUANTUM
#define PNANOVDB_LEAF_TABLE_NEG_OFF_QUANTUM
Definition PNanoVDB.h:1822
pnanovdb_upper_get_dim_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_upper_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:3008
pnanovdb_root_tile_get_child_mask
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_root_tile_get_child_mask(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t tile)
Definition PNanoVDB.h:1964
pnanovdb_readaccessor_iscached1
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached1(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
Definition PNanoVDB.h:2832
pnanovdb_read_uint16
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_read_uint16(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:987
pnanovdb_leaf_onindexmask_get_dev_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
Definition PNanoVDB.h:2324
pnanovdb_upper_get_table_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_table_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2530
PNANOVDB_MAP_OFF_TAPERF
#define PNANOVDB_MAP_OFF_TAPERF
Definition PNanoVDB.h:1185
PNANOVDB_TREE_OFF_NODE_OFFSET_LEAF
#define PNANOVDB_TREE_OFF_NODE_OFFSET_LEAF
Definition PNanoVDB.h:1521
pnanovdb_root_pointindex_get_point_range
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_pointindex_get_point_range(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level, PNANOVDB_INOUT(pnanovdb_uint64_t) range_begin, PNANOVDB_INOUT(pnanovdb_uint64_t) range_end)
Definition PNanoVDB.h:2741
pnanovdb_grid_get_magic
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_magic(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1287
pnanovdb_leaf_fp8_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp8_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2104
pnanovdb_grid_get_blind_metadata_offset
PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_grid_get_blind_metadata_offset(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1328
pnanovdb_tree_get_node_count_leaf
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_node_count_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1545
pnanovdb_grid_get_checksum
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_checksum(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1290
pnanovdb_tree_set_node_offset_lower
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_lower)
Definition PNanoVDB.h:1570
pnanovdb_root_tile_set_key
PNANOVDB_FORCE_INLINE void pnanovdb_root_tile_set_key(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p, pnanovdb_uint64_t key)
Definition PNanoVDB.h:1667
pnanovdb_read_uint32
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_read_uint32(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:946
PNANOVDB_GRID_OFF_CHECKSUM
#define PNANOVDB_GRID_OFF_CHECKSUM
Definition PNanoVDB.h:1269
PNANOVDB_MAP_OFF_INVMATD
#define PNANOVDB_MAP_OFF_INVMATD
Definition PNanoVDB.h:1187
pnanovdb_grid_set_data2
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_data2(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t data2)
Definition PNanoVDB.h:1392
pnanovdb_tree_set_node_count_leaf
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_count_leaf(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t node_count_leaf)
Definition PNanoVDB.h:1579
PNANOVDB_TREE_OFF_NODE_OFFSET_ROOT
#define PNANOVDB_TREE_OFF_NODE_OFFSET_ROOT
Definition PNanoVDB.h:1524
PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_CLASS
#define PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_CLASS
Definition PNanoVDB.h:1453
pnanovdb_grid_get_grid_index
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_index(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1299
pnanovdb_upper_get_value_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2566
PNANOVDB_LEAF_TABLE_NEG_OFF_MINIMUM
#define PNANOVDB_LEAF_TABLE_NEG_OFF_MINIMUM
Definition PNanoVDB.h:1821
pnanovdb_lower_set_child_mask
PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_child_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value)
Definition PNanoVDB.h:1793
pnanovdb_lower_get_bbox_min
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_lower_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p)
Definition PNanoVDB.h:1762
pnanovdb_version_get_major
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_version_get_major(pnanovdb_uint32_t version)
Definition PNanoVDB.h:1401
PNANOVDB_GRID_OFF_DATA1
#define PNANOVDB_GRID_OFF_DATA1
Definition PNanoVDB.h:1284
pnanovdb_grid_get_gridblindmetadata_value_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_grid_get_gridblindmetadata_value_address(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1926
pnanovdb_grid_get_grid_name
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_name(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1308
pnanovdb_tree_get_node_count_upper
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_node_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1551
pnanovdb_grid_get_data1
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_data1(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1337
pnanovdb_lower_get_ave_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
Definition PNanoVDB.h:2431
PNANOVDB_GRID_OFF_GRID_TYPE
#define PNANOVDB_GRID_OFF_GRID_TYPE
Definition PNanoVDB.h:1280
pnanovdb_root_get_min_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:2591
pnanovdb_upper_set_child_mask
PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_child_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value)
Definition PNanoVDB.h:1731
PNANOVDB_MAP_OFF_INVMATF
#define PNANOVDB_MAP_OFF_INVMATF
Definition PNanoVDB.h:1183
pnanovdb_root_fp8_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_root_fp8_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
Definition PNanoVDB.h:2671
pnanovdb_read_int32
PNANOVDB_FORCE_INLINE pnanovdb_int32_t pnanovdb_read_int32(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:954
PNANOVDB_GRID_SIZE
#define PNANOVDB_GRID_SIZE
Definition PNanoVDB.h:1266
pnanovdb_leaf_onindex_get_min_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
Definition PNanoVDB.h:2229
pnanovdb_map_set_taperf
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_taperf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float taperf)
Definition PNanoVDB.h:1225
PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_OFFSET
#define PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_OFFSET
Definition PNanoVDB.h:1449
PNANOVDB_ROOT_TILE_OFF_KEY
#define PNANOVDB_ROOT_TILE_OFF_KEY
Definition PNanoVDB.h:1653
PNANOVDB_TREE_OFF_NODE_OFFSET_LOWER
#define PNANOVDB_TREE_OFF_NODE_OFFSET_LOWER
Definition PNanoVDB.h:1522
pnanovdb_upper_get_value_address_and_level_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_value_address_and_level_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
Definition PNanoVDB.h:2889
pnanovdb_leaf_is_active_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:3074
pnanovdb_lower_set_bbox_min
PNANOVDB_FORCE_INLINE void pnanovdb_lower_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min)
Definition PNanoVDB.h:1780
pnanovdb_tree_get_node_offset_upper
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_tree_get_node_offset_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1539
pnanovdb_leaf_indexmask_get_mask_bit
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_indexmask_get_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2182
pnanovdb_grid_set_magic
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_magic(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint64_t magic)
Definition PNanoVDB.h:1344
pnanovdb_readaccessor_is_active
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_is_active(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:3139
PNANOVDB_UPPER_OFF_BBOX_MAX
#define PNANOVDB_UPPER_OFF_BBOX_MAX
Definition PNanoVDB.h:1695
pnanovdb_map_set_vecd
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_vecd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double vecd)
Definition PNanoVDB.h:1234
pnanovdb_lower_get_max_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_lower_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t node)
Definition PNanoVDB.h:2425
pnanovdb_map_set_matd
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_matd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, double matd)
Definition PNanoVDB.h:1228
PNANOVDB_MAP_OFF_MATD
#define PNANOVDB_MAP_OFF_MATD
Definition PNanoVDB.h:1186
PNANOVDB_LOWER_OFF_BBOX_MAX
#define PNANOVDB_LOWER_OFF_BBOX_MAX
Definition PNanoVDB.h:1757
pnanovdb_root_set_child
PNANOVDB_FORCE_INLINE void pnanovdb_root_set_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, pnanovdb_root_tile_handle_t tile, pnanovdb_upper_handle_t upper)
Definition PNanoVDB.h:1976
pnanovdb_lower_get_dim_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_lower_get_dim_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:2990
pnanovdb_write_uint32
PNANOVDB_FORCE_INLINE void pnanovdb_write_uint32(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_uint32_t value)
Definition PNanoVDB.h:1046
pnanovdb_tree_get_node_count_lower
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_node_count_lower(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1548
pnanovdb_readaccessor_get_dim
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_readaccessor_get_dim(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:3048
pnanovdb_upper_set_bbox_max
PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_bbox_max(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_max)
Definition PNanoVDB.h:1721
pnanovdb_map_apply_jacobi
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_jacobi(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3189
pnanovdb_tree_get_root
PNANOVDB_FORCE_INLINE pnanovdb_root_handle_t pnanovdb_tree_get_root(pnanovdb_buf_t buf, pnanovdb_tree_handle_t tree)
Definition PNanoVDB.h:1941
pnanovdb_grid_set_grid_class
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_class(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_class)
Definition PNanoVDB.h:1374
PNANOVDB_GRID_OFF_GRID_CLASS
#define PNANOVDB_GRID_OFF_GRID_CLASS
Definition PNanoVDB.h:1279
pnanovdb_read_double
PNANOVDB_FORCE_INLINE double pnanovdb_read_double(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:966
pnanovdb_grid_get_data0
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_data0(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1334
pnanovdb_readaccessor_get_value_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_readaccessor_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2969
pnanovdb_root_get_bbox_min
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_root_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_root_handle_t p)
Definition PNanoVDB.h:1619
pnanovdb_root_fp16_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_root_fp16_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
Definition PNanoVDB.h:2685
pnanovdb_grid_get_grid_count
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1302
pnanovdb_root_get_background_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_background_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:2585
pnanovdb_leaf_indexmask_get_max_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
Definition PNanoVDB.h:2166
pnanovdb_grid_set_grid_name
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_name(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index, pnanovdb_uint32_t grid_name)
Definition PNanoVDB.h:1365
pnanovdb_read_int64
PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_read_int64(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:962
pnanovdb_map_get_vecd
PNANOVDB_FORCE_INLINE double pnanovdb_map_get_vecd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1209
pnanovdb_map_get_invmatd
PNANOVDB_FORCE_INLINE double pnanovdb_map_get_invmatd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1206
pnanovdb_root_tile_get_key
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_tile_get_key(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p)
Definition PNanoVDB.h:1657
pnanovdb_upper_set_child
PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, pnanovdb_uint32_t n, pnanovdb_lower_handle_t lower)
Definition PNanoVDB.h:2578
pnanovdb_map_apply_inverse_jacobi
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_inverse_jacobi(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3201
pnanovdb_root_fpn_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_root_fpn_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
Definition PNanoVDB.h:2699
pnanovdb_read_vec3
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_read_vec3(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:978
pnanovdb_leaf_onindex_get_value_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2273
pnanovdb_lower_is_active_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_lower_is_active_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc)
Definition PNanoVDB.h:3080
PNANOVDB_GRID_OFF_DATA0
#define PNANOVDB_GRID_OFF_DATA0
Definition PNanoVDB.h:1283
pnanovdb_grid_set_first_gridblindmetadata
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_first_gridblindmetadata(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_gridblindmetadata_handle_t gridblindmetadata)
Definition PNanoVDB.h:2017
pnanovdb_leaf_pointindex_set_value_only
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_pointindex_set_value_only(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i, pnanovdb_uint32_t value)
Definition PNanoVDB.h:2381
pnanovdb_readaccessor_computedirty
PNANOVDB_FORCE_INLINE int pnanovdb_readaccessor_computedirty(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2852
PNANOVDB_GRIDBLINDMETADATA_OFF_NAME
#define PNANOVDB_GRIDBLINDMETADATA_OFF_NAME
Definition PNanoVDB.h:1455
pnanovdb_leaf_onindexmask_get_mask_bit
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_onindexmask_get_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2332
pnanovdb_gridblindmetadata_set_semantic
PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_semantic(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t semantic)
Definition PNanoVDB.h:1488
pnanovdb_tree_set_node_count_upper
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint32_t node_count_upper)
Definition PNanoVDB.h:1585
pnanovdb_lower_get_child_mask
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_lower_get_child_mask(pnanovdb_buf_t buf, pnanovdb_lower_handle_t p, pnanovdb_uint32_t bit_index)
Definition PNanoVDB.h:1775
pnanovdb_root_set_bbox_max
PNANOVDB_FORCE_INLINE void pnanovdb_root_set_bbox_max(pnanovdb_buf_t buf, pnanovdb_root_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_max)
Definition PNanoVDB.h:1632
pnanovdb_leaf_get_value_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_value_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2075
PNANOVDB_GRID_OFF_GRID_NAME
#define PNANOVDB_GRID_OFF_GRID_NAME
Definition PNanoVDB.h:1275
pnanovdb_leaf_indexmask_has_stats
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_indexmask_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2158
pnanovdb_leaf_index_get_min_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
Definition PNanoVDB.h:2129
PNANOVDB_TREE_OFF_NODE_COUNT_LEAF
#define PNANOVDB_TREE_OFF_NODE_COUNT_LEAF
Definition PNanoVDB.h:1525
pnanovdb_upper_get_child
PNANOVDB_FORCE_INLINE pnanovdb_lower_handle_t pnanovdb_upper_get_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t upper, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2542
pnanovdb_map_get_taperd
PNANOVDB_FORCE_INLINE double pnanovdb_map_get_taperd(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1212
pnanovdb_upper_get_table_child
PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_upper_get_table_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2536
pnanovdb_leaf_get_max_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
Definition PNanoVDB.h:2051
pnanovdb_leaf_onindex_get_dev_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
Definition PNanoVDB.h:2262
pnanovdb_upper_set_bbox_min
PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_bbox_min(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, PNANOVDB_IN(pnanovdb_coord_t) bbox_min)
Definition PNanoVDB.h:1718
PNANOVDB_GRID_OFF_VOXEL_SIZE
#define PNANOVDB_GRID_OFF_VOXEL_SIZE
Definition PNanoVDB.h:1278
pnanovdb_grid_world_to_indexf
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_world_to_indexf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3213
pnanovdb_write_coord
PNANOVDB_FORCE_INLINE void pnanovdb_write_coord(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) value)
Definition PNanoVDB.h:1070
pnanovdb_read_uint64
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_read_uint64(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:950
pnanovdb_gridblindmetadata_get_data_class
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_gridblindmetadata_get_data_class(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p)
Definition PNanoVDB.h:1469
pnanovdb_grid_index_to_world_dirf
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_grid_index_to_world_dirf(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3231
pnanovdb_map_apply_inverse
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_inverse(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
Definition PNanoVDB.h:3177
pnanovdb_gridblindmetadata_set_value_count
PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_value_count(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint64_t value_count)
Definition PNanoVDB.h:1482
pnanovdb_tree_get_tile_count_upper
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_tree_get_tile_count_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p)
Definition PNanoVDB.h:1557
pnanovdb_upper_get_child_mask
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_upper_get_child_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index)
Definition PNanoVDB.h:1713
pnanovdb_leaf_onindex_has_stats
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_onindex_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2224
pnanovdb_upper_get_ave_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
Definition PNanoVDB.h:2518
PNANOVDB_GRID_OFF_MAGIC
#define PNANOVDB_GRID_OFF_MAGIC
Definition PNanoVDB.h:1268
PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_TYPE
#define PNANOVDB_GRIDBLINDMETADATA_OFF_DATA_TYPE
Definition PNanoVDB.h:1454
pnanovdb_grid_get_grid_size
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_grid_get_grid_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1305
pnanovdb_leaf_get_table_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_table_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2069
PNANOVDB_LEAF_OFF_BBOX_MIN
#define PNANOVDB_LEAF_OFF_BBOX_MIN
Definition PNanoVDB.h:1816
pnanovdb_grid_set_voxel_size
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_voxel_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index, double voxel_size)
Definition PNanoVDB.h:1371
pnanovdb_leaf_onindexmask_get_value_count
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_onindexmask_get_value_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2300
pnanovdb_upper_get_min_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
Definition PNanoVDB.h:2506
pnanovdb_root_get_value_address_bit
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_bit(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_uint32_t) bit_index)
Definition PNanoVDB.h:2649
pnanovdb_lower_get_child
PNANOVDB_FORCE_INLINE pnanovdb_leaf_handle_t pnanovdb_lower_get_child(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_lower_handle_t lower, pnanovdb_uint32_t n)
Definition PNanoVDB.h:2455
pnanovdb_leaf_pointindex_get_offset
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2359
pnanovdb_read_uint8
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_read_uint8(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:992
pnanovdb_upper_get_bbox_min
PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_upper_get_bbox_min(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p)
Definition PNanoVDB.h:1700
pnanovdb_gridblindmetadata_set_data_type
PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_data_type(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t data_type)
Definition PNanoVDB.h:1494
pnanovdb_read_vec3u16
PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_read_vec3u16(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:997
pnanovdb_upper_set_value_mask
PNANOVDB_FORCE_INLINE void pnanovdb_upper_set_value_mask(pnanovdb_buf_t buf, pnanovdb_upper_handle_t p, pnanovdb_uint32_t bit_index, pnanovdb_bool_t value)
Definition PNanoVDB.h:1724
pnanovdb_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address)
Definition PNanoVDB.h:958
pnanovdb_coord_to_key
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_coord_to_key(PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:1981
pnanovdb_tree_set_first_upper
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_first_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_upper_handle_t upper)
Definition PNanoVDB.h:2029
pnanovdb_map_set_matf
PNANOVDB_FORCE_INLINE void pnanovdb_map_set_matf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index, float matf)
Definition PNanoVDB.h:1216
pnanovdb_readaccessor_iscached0
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached0(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
Definition PNanoVDB.h:2822
PNANOVDB_GRID_OFF_BLIND_METADATA_COUNT
#define PNANOVDB_GRID_OFF_BLIND_METADATA_COUNT
Definition PNanoVDB.h:1282
PNANOVDB_LEAF_TABLE_NEG_OFF_BBOX_DIF_AND_FLAGS
#define PNANOVDB_LEAF_TABLE_NEG_OFF_BBOX_DIF_AND_FLAGS
Definition PNanoVDB.h:1820
pnanovdb_leaf_onindexmask_has_stats
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_onindexmask_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2308
pnanovdb_leaf_get_bbox_dif_and_flags
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_get_bbox_dif_and_flags(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p)
Definition PNanoVDB.h:1827
pnanovdb_root_pointindex_get_point_address_range
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_pointindex_get_point_address_range(pnanovdb_buf_t buf, pnanovdb_grid_type_t value_type, pnanovdb_address_t value_address, pnanovdb_address_t blindmetadata_value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level, PNANOVDB_INOUT(pnanovdb_address_t) address_begin, PNANOVDB_INOUT(pnanovdb_address_t) address_end)
Definition PNanoVDB.h:2770
PNANOVDB_TREE_OFF_TILE_COUNT_UPPER
#define PNANOVDB_TREE_OFF_TILE_COUNT_UPPER
Definition PNanoVDB.h:1529
pnanovdb_leaf_get_stddev_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_stddev_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
Definition PNanoVDB.h:2063
PNANOVDB_TREE_OFF_TILE_COUNT_LOWER
#define PNANOVDB_TREE_OFF_TILE_COUNT_LOWER
Definition PNanoVDB.h:1528
pnanovdb_leaf_onindexmask_get_last_offset
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_last_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2304
pnanovdb_root_get_max_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:2597
pnanovdb_grid_set_grid_count
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_grid_count(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t grid_count)
Definition PNanoVDB.h:1359
pnanovdb_grid_get_world_bbox
PNANOVDB_FORCE_INLINE double pnanovdb_grid_get_world_bbox(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1316
pnanovdb_root_tile_get_child
PNANOVDB_FORCE_INLINE pnanovdb_int64_t pnanovdb_root_tile_get_child(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p)
Definition PNanoVDB.h:1660
pnanovdb_leaf_pointindex_get_first
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_first(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
Definition PNanoVDB.h:2367
pnanovdb_leaf_get_min_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_min_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
Definition PNanoVDB.h:2045
pnanovdb_root_get_ave_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:2603
pnanovdb_grid_type_leaf_type
PNANOVDB_STATIC_CONST pnanovdb_uint32_t pnanovdb_grid_type_leaf_type[32]
Definition PNanoVDB.h:1163
pnanovdb_write_int64
PNANOVDB_FORCE_INLINE void pnanovdb_write_int64(pnanovdb_buf_t buf, pnanovdb_address_t address, pnanovdb_int64_t value)
Definition PNanoVDB.h:1058
PNANOVDB_MAP_OFF_TAPERD
#define PNANOVDB_MAP_OFF_TAPERD
Definition PNanoVDB.h:1189
pnanovdb_upper_get_max_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_upper_get_max_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_upper_handle_t node)
Definition PNanoVDB.h:2512
PNANOVDB_GRID_OFF_GRID_SIZE
#define PNANOVDB_GRID_OFF_GRID_SIZE
Definition PNanoVDB.h:1274
pnanovdb_leaf_indexmask_get_min_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_indexmask_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
Definition PNanoVDB.h:2162
pnanovdb_grid_get_flags
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_flags(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1296
pnanovdb_leaf_index_get_value_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t value_address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2149
pnanovdb_leaf_set_bbox_dif_and_flags
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_set_bbox_dif_and_flags(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t p, pnanovdb_uint32_t bbox_dif_and_flags)
Definition PNanoVDB.h:1838
pnanovdb_root_index_get_value_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_index_get_value_index(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
Definition PNanoVDB.h:2713
pnanovdb_grid_get_voxel_size
PNANOVDB_FORCE_INLINE double pnanovdb_grid_get_voxel_size(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1319
pnanovdb_gridblindmetadata_set_data_offset
PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_data_offset(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_int64_t data_offset)
Definition PNanoVDB.h:1479
PNANOVDB_TREE_OFF_NODE_COUNT_UPPER
#define PNANOVDB_TREE_OFF_NODE_COUNT_UPPER
Definition PNanoVDB.h:1527
pnanovdb_root_get_value_address_and_level_and_cache
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_root_get_value_address_and_level_and_cache(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk, PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_INOUT(pnanovdb_uint32_t) level)
Definition PNanoVDB.h:2914
pnanovdb_gridblindmetadata_set_data_class
PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_data_class(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t data_class)
Definition PNanoVDB.h:1491
PNANOVDB_GRID_TYPE_VEC3U8
#define PNANOVDB_GRID_TYPE_VEC3U8
Definition PNanoVDB.h:1117
pnanovdb_grid_set_world_bbox
PNANOVDB_FORCE_INLINE void pnanovdb_grid_set_world_bbox(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p, pnanovdb_uint32_t index, double world_bbox)
Definition PNanoVDB.h:1368
PNANOVDB_TREE_OFF_TILE_COUNT_ROOT
#define PNANOVDB_TREE_OFF_TILE_COUNT_ROOT
Definition PNanoVDB.h:1530
PNANOVDB_ROOT_TILE_OFF_STATE
#define PNANOVDB_ROOT_TILE_OFF_STATE
Definition PNanoVDB.h:1655
pnanovdb_tree_set_node_offset_upper
PNANOVDB_FORCE_INLINE void pnanovdb_tree_set_node_offset_upper(pnanovdb_buf_t buf, pnanovdb_tree_handle_t p, pnanovdb_uint64_t node_offset_upper)
Definition PNanoVDB.h:1573
pnanovdb_leaf_onindex_get_value_count
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_onindex_get_value_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2209
PNANOVDB_GRIDBLINDMETADATA_SIZE
#define PNANOVDB_GRIDBLINDMETADATA_SIZE
Definition PNanoVDB.h:1447
pnanovdb_leaf_index_has_stats
PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_index_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
Definition PNanoVDB.h:2124
pnanovdb_grid_get_tree
PNANOVDB_FORCE_INLINE pnanovdb_tree_handle_t pnanovdb_grid_get_tree(pnanovdb_buf_t buf, pnanovdb_grid_handle_t grid)
Definition PNanoVDB.h:1934
pnanovdb_map_get_vecf
PNANOVDB_FORCE_INLINE float pnanovdb_map_get_vecf(pnanovdb_buf_t buf, pnanovdb_map_handle_t p, pnanovdb_uint32_t index)
Definition PNanoVDB.h:1197
pnanovdb_upper_coord_to_offset
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_upper_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2499
pnanovdb_root_get_tile
PNANOVDB_FORCE_INLINE pnanovdb_root_tile_handle_t pnanovdb_root_get_tile(pnanovdb_grid_type_t grid_type, pnanovdb_root_handle_t root, pnanovdb_uint32_t n)
Definition PNanoVDB.h:1949
pnanovdb_root_tile_set_state
PNANOVDB_FORCE_INLINE void pnanovdb_root_tile_set_state(pnanovdb_buf_t buf, pnanovdb_root_tile_handle_t p, pnanovdb_uint32_t state)
Definition PNanoVDB.h:1673
pnanovdb_leaf_index_get_ave_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
Definition PNanoVDB.h:2139
pnanovdb_leaf_onindexmask_set_mask_bit
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_onindexmask_set_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n, pnanovdb_bool_t v)
Definition PNanoVDB.h:2340
pnanovdb_grid_get_grid_type
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_grid_get_grid_type(pnanovdb_buf_t buf, pnanovdb_grid_handle_t p)
Definition PNanoVDB.h:1325
pnanovdb_leaf_indexmask_set_mask_bit
PNANOVDB_FORCE_INLINE void pnanovdb_leaf_indexmask_set_mask_bit(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t n, pnanovdb_bool_t v)
Definition PNanoVDB.h:2190
pnanovdb_leaf_index_get_dev_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_index_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
Definition PNanoVDB.h:2144
pnanovdb_readaccessor_init
PNANOVDB_FORCE_INLINE void pnanovdb_readaccessor_init(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, pnanovdb_root_handle_t root)
Definition PNanoVDB.h:2811
pnanovdb_leaf_fp_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fp_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t value_log_bits)
Definition PNanoVDB.h:2083
pnanovdb_gridblindmetadata_set_name
PNANOVDB_FORCE_INLINE void pnanovdb_gridblindmetadata_set_name(pnanovdb_buf_t buf, pnanovdb_gridblindmetadata_handle_t p, pnanovdb_uint32_t index, pnanovdb_uint32_t name)
Definition PNanoVDB.h:1497
pnanovdb_leaf_get_ave_address
PNANOVDB_FORCE_INLINE pnanovdb_address_t pnanovdb_leaf_get_ave_address(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_leaf_handle_t node)
Definition PNanoVDB.h:2057
pnanovdb_leaf_onindexmask_get_ave_index
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindexmask_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
Definition PNanoVDB.h:2320
pnanovdb_leaf_fpn_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_leaf_fpn_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:2114
pnanovdb_version_get_patch
PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_version_get_patch(pnanovdb_uint32_t version)
Definition PNanoVDB.h:1409
PNANOVDB_LOWER_OFF_CHILD_MASK
#define PNANOVDB_LOWER_OFF_CHILD_MASK
Definition PNanoVDB.h:1760
PNANOVDB_GRID_OFF_FLAGS
#define PNANOVDB_GRID_OFF_FLAGS
Definition PNanoVDB.h:1271
pnanovdb_root_find_tile
PNANOVDB_FORCE_INLINE pnanovdb_root_tile_handle_t pnanovdb_root_find_tile(pnanovdb_grid_type_t grid_type, pnanovdb_buf_t buf, pnanovdb_root_handle_t root, PNANOVDB_IN(pnanovdb_coord_t) ijk)
Definition PNanoVDB.h:1998
pnanovdb_root_fp4_read_float
PNANOVDB_FORCE_INLINE float pnanovdb_root_fp4_read_float(pnanovdb_buf_t buf, pnanovdb_address_t address, PNANOVDB_IN(pnanovdb_coord_t) ijk, pnanovdb_uint32_t level)
Definition PNanoVDB.h:2657
openvdb::v12_1::tools::composite::max
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition Composite.h:110
openvdb::v12_1::tools::composite::min
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition Composite.h:106
pnanovdb_grid_handle_t
Definition PNanoVDB.h:1263
pnanovdb_grid_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1263
pnanovdb_grid_t
Definition PNanoVDB.h:1242
pnanovdb_grid_t::magic
pnanovdb_uint64_t magic
Definition PNanoVDB.h:1243
pnanovdb_grid_t::grid_class
pnanovdb_uint32_t grid_class
Definition PNanoVDB.h:1254
pnanovdb_grid_t::voxel_size
double voxel_size[3]
Definition PNanoVDB.h:1253
pnanovdb_grid_t::grid_index
pnanovdb_uint32_t grid_index
Definition PNanoVDB.h:1247
pnanovdb_grid_t::grid_size
pnanovdb_uint64_t grid_size
Definition PNanoVDB.h:1249
pnanovdb_grid_t::grid_type
pnanovdb_uint32_t grid_type
Definition PNanoVDB.h:1255
pnanovdb_grid_t::version
pnanovdb_uint32_t version
Definition PNanoVDB.h:1245
pnanovdb_grid_t::data0
pnanovdb_uint32_t data0
Definition PNanoVDB.h:1258
pnanovdb_grid_t::blind_metadata_offset
pnanovdb_int64_t blind_metadata_offset
Definition PNanoVDB.h:1256
pnanovdb_grid_t::world_bbox
double world_bbox[6]
Definition PNanoVDB.h:1252
pnanovdb_grid_t::data1
pnanovdb_uint64_t data1
Definition PNanoVDB.h:1259
pnanovdb_grid_t::flags
pnanovdb_uint32_t flags
Definition PNanoVDB.h:1246
pnanovdb_grid_t::data2
pnanovdb_uint64_t data2
Definition PNanoVDB.h:1260
pnanovdb_grid_t::blind_metadata_count
pnanovdb_uint32_t blind_metadata_count
Definition PNanoVDB.h:1257
pnanovdb_grid_t::checksum
pnanovdb_uint64_t checksum
Definition PNanoVDB.h:1244
pnanovdb_grid_t::map
pnanovdb_map_t map
Definition PNanoVDB.h:1251
pnanovdb_grid_t::grid_count
pnanovdb_uint32_t grid_count
Definition PNanoVDB.h:1248
pnanovdb_grid_t::grid_name
pnanovdb_uint32_t grid_name[256/4]
Definition PNanoVDB.h:1250
pnanovdb_grid_type_constants_t
Definition PNanoVDB.h:1850
pnanovdb_grid_type_constants_t::leaf_off_stddev
pnanovdb_uint32_t leaf_off_stddev
Definition PNanoVDB.h:1876
pnanovdb_grid_type_constants_t::leaf_off_ave
pnanovdb_uint32_t leaf_off_ave
Definition PNanoVDB.h:1875
pnanovdb_grid_type_constants_t::upper_off_min
pnanovdb_uint32_t upper_off_min
Definition PNanoVDB.h:1861
pnanovdb_grid_type_constants_t::leaf_size
pnanovdb_uint32_t leaf_size
Definition PNanoVDB.h:1878
pnanovdb_grid_type_constants_t::root_size
pnanovdb_uint32_t root_size
Definition PNanoVDB.h:1856
pnanovdb_grid_type_constants_t::leaf_off_table
pnanovdb_uint32_t leaf_off_table
Definition PNanoVDB.h:1877
pnanovdb_grid_type_constants_t::upper_off_max
pnanovdb_uint32_t upper_off_max
Definition PNanoVDB.h:1862
pnanovdb_grid_type_constants_t::upper_off_ave
pnanovdb_uint32_t upper_off_ave
Definition PNanoVDB.h:1863
pnanovdb_grid_type_constants_t::table_stride
pnanovdb_uint32_t table_stride
Definition PNanoVDB.h:1858
pnanovdb_grid_type_constants_t::upper_off_table
pnanovdb_uint32_t upper_off_table
Definition PNanoVDB.h:1865
pnanovdb_grid_type_constants_t::root_tile_size
pnanovdb_uint32_t root_tile_size
Definition PNanoVDB.h:1860
pnanovdb_grid_type_constants_t::leaf_off_min
pnanovdb_uint32_t leaf_off_min
Definition PNanoVDB.h:1873
pnanovdb_grid_type_constants_t::lower_size
pnanovdb_uint32_t lower_size
Definition PNanoVDB.h:1872
pnanovdb_grid_type_constants_t::lower_off_min
pnanovdb_uint32_t lower_off_min
Definition PNanoVDB.h:1867
pnanovdb_grid_type_constants_t::upper_size
pnanovdb_uint32_t upper_size
Definition PNanoVDB.h:1866
pnanovdb_grid_type_constants_t::value_stride_bits
pnanovdb_uint32_t value_stride_bits
Definition PNanoVDB.h:1857
pnanovdb_grid_type_constants_t::root_off_min
pnanovdb_uint32_t root_off_min
Definition PNanoVDB.h:1852
pnanovdb_grid_type_constants_t::root_tile_off_value
pnanovdb_uint32_t root_tile_off_value
Definition PNanoVDB.h:1859
pnanovdb_grid_type_constants_t::root_off_ave
pnanovdb_uint32_t root_off_ave
Definition PNanoVDB.h:1854
pnanovdb_grid_type_constants_t::lower_off_stddev
pnanovdb_uint32_t lower_off_stddev
Definition PNanoVDB.h:1870
pnanovdb_grid_type_constants_t::root_off_stddev
pnanovdb_uint32_t root_off_stddev
Definition PNanoVDB.h:1855
pnanovdb_grid_type_constants_t::root_off_background
pnanovdb_uint32_t root_off_background
Definition PNanoVDB.h:1851
pnanovdb_grid_type_constants_t::root_off_max
pnanovdb_uint32_t root_off_max
Definition PNanoVDB.h:1853
pnanovdb_grid_type_constants_t::lower_off_table
pnanovdb_uint32_t lower_off_table
Definition PNanoVDB.h:1871
pnanovdb_grid_type_constants_t::lower_off_max
pnanovdb_uint32_t lower_off_max
Definition PNanoVDB.h:1868
pnanovdb_grid_type_constants_t::leaf_off_max
pnanovdb_uint32_t leaf_off_max
Definition PNanoVDB.h:1874
pnanovdb_grid_type_constants_t::upper_off_stddev
pnanovdb_uint32_t upper_off_stddev
Definition PNanoVDB.h:1864
pnanovdb_grid_type_constants_t::lower_off_ave
pnanovdb_uint32_t lower_off_ave
Definition PNanoVDB.h:1869
pnanovdb_gridblindmetadata_handle_t
Definition PNanoVDB.h:1444
pnanovdb_gridblindmetadata_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1444
pnanovdb_gridblindmetadata_t
Definition PNanoVDB.h:1434
pnanovdb_gridblindmetadata_t::data_offset
pnanovdb_int64_t data_offset
Definition PNanoVDB.h:1435
pnanovdb_gridblindmetadata_t::value_count
pnanovdb_uint64_t value_count
Definition PNanoVDB.h:1436
pnanovdb_gridblindmetadata_t::name
pnanovdb_uint32_t name[256/4]
Definition PNanoVDB.h:1441
pnanovdb_gridblindmetadata_t::value_size
pnanovdb_uint32_t value_size
Definition PNanoVDB.h:1437
pnanovdb_gridblindmetadata_t::data_type
pnanovdb_uint32_t data_type
Definition PNanoVDB.h:1440
pnanovdb_gridblindmetadata_t::data_class
pnanovdb_uint32_t data_class
Definition PNanoVDB.h:1439
pnanovdb_gridblindmetadata_t::semantic
pnanovdb_uint32_t semantic
Definition PNanoVDB.h:1438
pnanovdb_leaf_handle_t
Definition PNanoVDB.h:1810
pnanovdb_leaf_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1810
pnanovdb_leaf_t
Definition PNanoVDB.h:1802
pnanovdb_leaf_t::value_mask
pnanovdb_uint32_t value_mask[16]
Definition PNanoVDB.h:1805
pnanovdb_leaf_t::bbox_dif_and_flags
pnanovdb_uint32_t bbox_dif_and_flags
Definition PNanoVDB.h:1804
pnanovdb_leaf_t::bbox_min
pnanovdb_coord_t bbox_min
Definition PNanoVDB.h:1803
pnanovdb_lower_handle_t
Definition PNanoVDB.h:1750
pnanovdb_lower_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1750
pnanovdb_lower_t
Definition PNanoVDB.h:1740
pnanovdb_lower_t::child_mask
pnanovdb_uint32_t child_mask[128]
Definition PNanoVDB.h:1745
pnanovdb_lower_t::flags
pnanovdb_uint64_t flags
Definition PNanoVDB.h:1743
pnanovdb_lower_t::value_mask
pnanovdb_uint32_t value_mask[128]
Definition PNanoVDB.h:1744
pnanovdb_lower_t::bbox_max
pnanovdb_coord_t bbox_max
Definition PNanoVDB.h:1742
pnanovdb_lower_t::bbox_min
pnanovdb_coord_t bbox_min
Definition PNanoVDB.h:1741
pnanovdb_map_handle_t
Definition PNanoVDB.h:1177
pnanovdb_map_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1177
pnanovdb_map_t
Definition PNanoVDB.h:1166
pnanovdb_map_t::matd
double matd[9]
Definition PNanoVDB.h:1171
pnanovdb_map_t::vecd
double vecd[3]
Definition PNanoVDB.h:1173
pnanovdb_map_t::taperf
float taperf
Definition PNanoVDB.h:1170
pnanovdb_map_t::invmatd
double invmatd[9]
Definition PNanoVDB.h:1172
pnanovdb_map_t::matf
float matf[9]
Definition PNanoVDB.h:1167
pnanovdb_map_t::taperd
double taperd
Definition PNanoVDB.h:1174
pnanovdb_map_t::invmatf
float invmatf[9]
Definition PNanoVDB.h:1168
pnanovdb_map_t::vecf
float vecf[3]
Definition PNanoVDB.h:1169
pnanovdb_readaccessor_t
Definition PNanoVDB.h:2802
pnanovdb_readaccessor_t::upper
pnanovdb_upper_handle_t upper
Definition PNanoVDB.h:2806
pnanovdb_readaccessor_t::root
pnanovdb_root_handle_t root
Definition PNanoVDB.h:2807
pnanovdb_readaccessor_t::key
pnanovdb_coord_t key
Definition PNanoVDB.h:2803
pnanovdb_readaccessor_t::lower
pnanovdb_lower_handle_t lower
Definition PNanoVDB.h:2805
pnanovdb_readaccessor_t::leaf
pnanovdb_leaf_handle_t leaf
Definition PNanoVDB.h:2804
pnanovdb_root_handle_t
Definition PNanoVDB.h:1610
pnanovdb_root_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1610
pnanovdb_root_t
Definition PNanoVDB.h:1602
pnanovdb_root_t::table_size
pnanovdb_uint32_t table_size
Definition PNanoVDB.h:1605
pnanovdb_root_t::bbox_max
pnanovdb_coord_t bbox_max
Definition PNanoVDB.h:1604
pnanovdb_root_t::pad1
pnanovdb_uint32_t pad1
Definition PNanoVDB.h:1606
pnanovdb_root_t::bbox_min
pnanovdb_coord_t bbox_min
Definition PNanoVDB.h:1603
pnanovdb_root_tile_handle_t
Definition PNanoVDB.h:1648
pnanovdb_root_tile_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1648
pnanovdb_root_tile_t
Definition PNanoVDB.h:1640
pnanovdb_root_tile_t::key
pnanovdb_uint64_t key
Definition PNanoVDB.h:1641
pnanovdb_root_tile_t::state
pnanovdb_uint32_t state
Definition PNanoVDB.h:1643
pnanovdb_root_tile_t::child
pnanovdb_int64_t child
Definition PNanoVDB.h:1642
pnanovdb_root_tile_t::pad1
pnanovdb_uint32_t pad1
Definition PNanoVDB.h:1644
pnanovdb_tree_handle_t
Definition PNanoVDB.h:1516
pnanovdb_tree_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1516
pnanovdb_tree_t
Definition PNanoVDB.h:1502
pnanovdb_tree_t::node_count_leaf
pnanovdb_uint32_t node_count_leaf
Definition PNanoVDB.h:1507
pnanovdb_tree_t::tile_count_lower
pnanovdb_uint32_t tile_count_lower
Definition PNanoVDB.h:1510
pnanovdb_tree_t::node_offset_upper
pnanovdb_uint64_t node_offset_upper
Definition PNanoVDB.h:1505
pnanovdb_tree_t::node_offset_root
pnanovdb_uint64_t node_offset_root
Definition PNanoVDB.h:1506
pnanovdb_tree_t::node_offset_leaf
pnanovdb_uint64_t node_offset_leaf
Definition PNanoVDB.h:1503
pnanovdb_tree_t::voxel_count
pnanovdb_uint64_t voxel_count
Definition PNanoVDB.h:1513
pnanovdb_tree_t::tile_count_upper
pnanovdb_uint32_t tile_count_upper
Definition PNanoVDB.h:1511
pnanovdb_tree_t::node_offset_lower
pnanovdb_uint64_t node_offset_lower
Definition PNanoVDB.h:1504
pnanovdb_tree_t::tile_count_root
pnanovdb_uint32_t tile_count_root
Definition PNanoVDB.h:1512
pnanovdb_tree_t::node_count_upper
pnanovdb_uint32_t node_count_upper
Definition PNanoVDB.h:1509
pnanovdb_tree_t::node_count_lower
pnanovdb_uint32_t node_count_lower
Definition PNanoVDB.h:1508
pnanovdb_upper_handle_t
Definition PNanoVDB.h:1688
pnanovdb_upper_handle_t::address
pnanovdb_address_t address
Definition PNanoVDB.h:1688
pnanovdb_upper_t
Definition PNanoVDB.h:1678
pnanovdb_upper_t::flags
pnanovdb_uint64_t flags
Definition PNanoVDB.h:1681
pnanovdb_upper_t::value_mask
pnanovdb_uint32_t value_mask[1024]
Definition PNanoVDB.h:1682
pnanovdb_upper_t::bbox_max
pnanovdb_coord_t bbox_max
Definition PNanoVDB.h:1680
pnanovdb_upper_t::child_mask
pnanovdb_uint32_t child_mask[1024]
Definition PNanoVDB.h:1683
pnanovdb_upper_t::bbox_min
pnanovdb_coord_t bbox_min
Definition PNanoVDB.h:1679