OpenVDB: nanovdb/PNanoVDB.h Source File

OpenVDB 13.0.0

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 9// 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 // retired - available for future use
1115//#define PNANOVDB_GRID_TYPE_ONINDEXMASK 22 // retired - available for future use
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 // retired - available for future use
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, 0, 0, 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, 0, 0, 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, 0, 0, 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, 0, 0, 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{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},
1907{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},
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 OnIndex Specialization ---------------------------------------
2157
2158PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_leaf_onindex_get_value_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2159{
2160 pnanovdb_uint64_t val_mask = pnanovdb_read_uint64(buf, pnanovdb_address_offset(leaf.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 8u * 7u));
2161 pnanovdb_uint64_t prefix_sum = pnanovdb_read_uint64(
2162 buf, pnanovdb_address_offset(leaf.address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table) + 8u));
2163 return pnanovdb_uint64_countbits(val_mask) + (pnanovdb_uint64_to_uint32_lsr(prefix_sum, 54u) & 511u);
2164}
2165
2166PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_last_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2167{
2168 return pnanovdb_uint64_offset(
2169 pnanovdb_read_uint64(buf, pnanovdb_address_offset(leaf.address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table))),
2170 pnanovdb_leaf_onindex_get_value_count(buf, leaf) - 1u);
2171}
2172
2173PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_leaf_onindex_has_stats(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2174{
2175 return (pnanovdb_leaf_get_bbox_dif_and_flags(buf, leaf) & (1u << 28u)) != 0u;
2176}
2177
2178PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_min_index(pnanovdb_buf_t buf, pnanovdb_address_t min_address)
2179{
2180 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(min_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2181 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2182 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2183 {
2184 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 1u);
2185 }
2186 return idx;
2187}
2188
2189PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_max_index(pnanovdb_buf_t buf, pnanovdb_address_t max_address)
2190{
2191 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(max_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2192 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2193 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2194 {
2195 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 2u);
2196 }
2197 return idx;
2198}
2199
2200PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_ave_index(pnanovdb_buf_t buf, pnanovdb_address_t ave_address)
2201{
2202 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(ave_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2203 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2204 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2205 {
2206 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 3u);
2207 }
2208 return idx;
2209}
2210
2211PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_onindex_get_dev_index(pnanovdb_buf_t buf, pnanovdb_address_t dev_address)
2212{
2213 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(dev_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2214 pnanovdb_uint64_t idx = pnanovdb_uint32_as_uint64_low(0u);
2215 if (pnanovdb_leaf_onindex_has_stats(buf, leaf))
2216 {
2217 idx = pnanovdb_uint64_offset(pnanovdb_leaf_onindex_get_last_offset(buf, leaf), 4u);
2218 }
2219 return idx;
2220}
2221
2222PNANOVDB_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)
2223{
2224 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2225 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(value_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_ONINDEX, leaf_off_table)) };
2226
2227 pnanovdb_uint32_t word_idx = n >> 6u;
2228 pnanovdb_uint32_t bit_idx = n & 63u;
2229 pnanovdb_uint64_t val_mask = pnanovdb_read_uint64(buf, pnanovdb_address_offset(leaf.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 8u * word_idx));
2230 pnanovdb_uint64_t mask = pnanovdb_uint64_bit_mask(bit_idx);
2231 pnanovdb_uint64_t value_index = pnanovdb_uint32_as_uint64_low(0u);
2232 if (pnanovdb_uint64_any_bit(pnanovdb_uint64_and(val_mask, mask)))
2233 {
2234 pnanovdb_uint32_t sum = 0u;
2235 sum += pnanovdb_uint64_countbits(pnanovdb_uint64_and(val_mask, pnanovdb_uint64_dec(mask)));
2236 if (word_idx > 0u)
2237 {
2238 pnanovdb_uint64_t prefix_sum = pnanovdb_read_uint64(buf, pnanovdb_address_offset(value_address, 8u));
2239 sum += pnanovdb_uint64_to_uint32_lsr(prefix_sum, 9u * (word_idx - 1u)) & 511u;
2240 }
2241 pnanovdb_uint64_t offset = pnanovdb_read_uint64(buf, value_address);
2242 value_index = pnanovdb_uint64_offset(offset, sum);
2243 }
2244 return value_index;
2245}
2246
2247// ----------------------------- Leaf PointIndex Specialization ---------------------------------------
2248
2249PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_offset(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2250{
2251 return pnanovdb_read_uint64(buf, pnanovdb_leaf_get_min_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf));
2252}
2253PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_point_count(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf)
2254{
2255 return pnanovdb_read_uint64(buf, pnanovdb_leaf_get_max_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf));
2256}
2257PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_first(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2258{
2259 return pnanovdb_uint64_offset(pnanovdb_leaf_pointindex_get_offset(buf, leaf),
2260 (i == 0u ? 0u : pnanovdb_read_uint16(buf, pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i - 1u))));
2261}
2262PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_last(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2263{
2264 return pnanovdb_uint64_offset(pnanovdb_leaf_pointindex_get_offset(buf, leaf),
2265 pnanovdb_read_uint16(buf, pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i)));
2266}
2267PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_leaf_pointindex_get_value(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2268{
2269 return pnanovdb_uint32_as_uint64_low(pnanovdb_read_uint16(buf, pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i)));
2270}
2271PNANOVDB_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)
2272{
2273 pnanovdb_address_t addr = pnanovdb_leaf_get_table_address(PNANOVDB_GRID_TYPE_POINTINDEX, buf, leaf, i);
2274 pnanovdb_uint32_t raw32 = pnanovdb_read_uint32(buf, pnanovdb_address_mask_inv(addr, 3u));
2275 if ((i & 1) == 0u)
2276 {
2277 raw32 = (raw32 & 0xFFFF0000) | (value & 0x0000FFFF);
2278 }
2279 else
2280 {
2281 raw32 = (raw32 & 0x0000FFFF) | (value << 16u);
2282 }
2283 pnanovdb_write_uint32(buf, addr, raw32);
2284}
2285PNANOVDB_FORCE_INLINE void pnanovdb_leaf_pointindex_set_on(pnanovdb_buf_t buf, pnanovdb_leaf_handle_t leaf, pnanovdb_uint32_t i)
2286{
2287 pnanovdb_uint32_t word_idx = i >> 5;
2288 pnanovdb_uint32_t bit_idx = i & 31;
2289 pnanovdb_address_t addr = pnanovdb_address_offset(leaf.address, PNANOVDB_LEAF_OFF_VALUE_MASK + 4u * word_idx);
2290 pnanovdb_uint32_t val_mask = pnanovdb_read_uint32(buf, addr);
2291 val_mask = val_mask | (1u << bit_idx);
2292 pnanovdb_write_uint32(buf, addr, val_mask);
2293}
2294PNANOVDB_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)
2295{
2296 pnanovdb_leaf_pointindex_set_on(buf, leaf, i);
2297 pnanovdb_leaf_pointindex_set_value_only(buf, leaf, i, value);
2298}
2299
2300// ------------------------------------------------ Lower Node -----------------------------------------------------------
2301
2302PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_lower_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
2303{
2304 return (((PNANOVDB_DEREF(ijk).x & 127) >> 3) << (2 * 4)) +
2305 (((PNANOVDB_DEREF(ijk).y & 127) >> 3) << (4)) +
2306 ((PNANOVDB_DEREF(ijk).z & 127) >> 3);
2307}
2308
2309PNANOVDB_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)
2310{
2311 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_min);
2312 return pnanovdb_address_offset(node.address, byte_offset);
2313}
2314
2315PNANOVDB_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)
2316{
2317 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_max);
2318 return pnanovdb_address_offset(node.address, byte_offset);
2319}
2320
2321PNANOVDB_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)
2322{
2323 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_ave);
2324 return pnanovdb_address_offset(node.address, byte_offset);
2325}
2326
2327PNANOVDB_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)
2328{
2329 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_stddev);
2330 return pnanovdb_address_offset(node.address, byte_offset);
2331}
2332
2333PNANOVDB_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)
2334{
2335 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, lower_off_table) + PNANOVDB_GRID_TYPE_GET(grid_type, table_stride) * n;
2336 return pnanovdb_address_offset(node.address, byte_offset);
2337}
2338
2339PNANOVDB_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)
2340{
2341 pnanovdb_address_t table_address = pnanovdb_lower_get_table_address(grid_type, buf, node, n);
2342 return pnanovdb_read_int64(buf, table_address);
2343}
2344
2345PNANOVDB_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)
2346{
2347 pnanovdb_leaf_handle_t leaf = { lower.address };
2348 leaf.address = pnanovdb_address_offset64(leaf.address, pnanovdb_int64_as_uint64(pnanovdb_lower_get_table_child(grid_type, buf, lower, n)));
2349 return leaf;
2350}
2351
2352PNANOVDB_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)
2353{
2354 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
2355 pnanovdb_address_t value_address;
2356 if (pnanovdb_lower_get_child_mask(buf, lower, n))
2357 {
2358 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
2359 value_address = pnanovdb_leaf_get_value_address(grid_type, buf, child, ijk);
2360 PNANOVDB_DEREF(level) = 0u;
2361 }
2362 else
2363 {
2364 value_address = pnanovdb_lower_get_table_address(grid_type, buf, lower, n);
2365 PNANOVDB_DEREF(level) = 1u;
2366 }
2367 return value_address;
2368}
2369
2370PNANOVDB_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)
2371{
2372 pnanovdb_uint32_t level;
2373 return pnanovdb_lower_get_value_address_and_level(grid_type, buf, lower, ijk, PNANOVDB_REF(level));
2374}
2375
2376PNANOVDB_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)
2377{
2378 pnanovdb_address_t table_address = pnanovdb_lower_get_table_address(grid_type, buf, node, n);
2379 pnanovdb_write_int64(buf, table_address, child);
2380}
2381
2382PNANOVDB_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)
2383{
2384 pnanovdb_lower_set_table_child(grid_type, buf, lower, n, pnanovdb_address_diff(leaf.address, lower.address));
2385}
2386
2387// ------------------------------------------------ Upper Node -----------------------------------------------------------
2388
2389PNANOVDB_FORCE_INLINE pnanovdb_uint32_t pnanovdb_upper_coord_to_offset(PNANOVDB_IN(pnanovdb_coord_t) ijk)
2390{
2391 return (((PNANOVDB_DEREF(ijk).x & 4095) >> 7) << (2 * 5)) +
2392 (((PNANOVDB_DEREF(ijk).y & 4095) >> 7) << (5)) +
2393 ((PNANOVDB_DEREF(ijk).z & 4095) >> 7);
2394}
2395
2396PNANOVDB_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)
2397{
2398 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_min);
2399 return pnanovdb_address_offset(node.address, byte_offset);
2400}
2401
2402PNANOVDB_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)
2403{
2404 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_max);
2405 return pnanovdb_address_offset(node.address, byte_offset);
2406}
2407
2408PNANOVDB_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)
2409{
2410 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_ave);
2411 return pnanovdb_address_offset(node.address, byte_offset);
2412}
2413
2414PNANOVDB_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)
2415{
2416 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_stddev);
2417 return pnanovdb_address_offset(node.address, byte_offset);
2418}
2419
2420PNANOVDB_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)
2421{
2422 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, upper_off_table) + PNANOVDB_GRID_TYPE_GET(grid_type, table_stride) * n;
2423 return pnanovdb_address_offset(node.address, byte_offset);
2424}
2425
2426PNANOVDB_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)
2427{
2428 pnanovdb_address_t bufAddress = pnanovdb_upper_get_table_address(grid_type, buf, node, n);
2429 return pnanovdb_read_int64(buf, bufAddress);
2430}
2431
2432PNANOVDB_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)
2433{
2434 pnanovdb_lower_handle_t lower = { upper.address };
2435 lower.address = pnanovdb_address_offset64(lower.address, pnanovdb_int64_as_uint64(pnanovdb_upper_get_table_child(grid_type, buf, upper, n)));
2436 return lower;
2437}
2438
2439PNANOVDB_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)
2440{
2441 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
2442 pnanovdb_address_t value_address;
2443 if (pnanovdb_upper_get_child_mask(buf, upper, n))
2444 {
2445 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
2446 value_address = pnanovdb_lower_get_value_address_and_level(grid_type, buf, child, ijk, level);
2447 }
2448 else
2449 {
2450 value_address = pnanovdb_upper_get_table_address(grid_type, buf, upper, n);
2451 PNANOVDB_DEREF(level) = 2u;
2452 }
2453 return value_address;
2454}
2455
2456PNANOVDB_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)
2457{
2458 pnanovdb_uint32_t level;
2459 return pnanovdb_upper_get_value_address_and_level(grid_type, buf, upper, ijk, PNANOVDB_REF(level));
2460}
2461
2462PNANOVDB_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)
2463{
2464 pnanovdb_address_t bufAddress = pnanovdb_upper_get_table_address(grid_type, buf, node, n);
2465 pnanovdb_write_int64(buf, bufAddress, child);
2466}
2467
2468PNANOVDB_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)
2469{
2470 pnanovdb_upper_set_table_child(grid_type, buf, upper, n, pnanovdb_address_diff(lower.address, upper.address));
2471}
2472
2473// ------------------------------------------------ Root -----------------------------------------------------------
2474
2475PNANOVDB_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)
2476{
2477 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_background);
2478 return pnanovdb_address_offset(root.address, byte_offset);
2479}
2480
2481PNANOVDB_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)
2482{
2483 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_min);
2484 return pnanovdb_address_offset(root.address, byte_offset);
2485}
2486
2487PNANOVDB_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)
2488{
2489 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_max);
2490 return pnanovdb_address_offset(root.address, byte_offset);
2491}
2492
2493PNANOVDB_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)
2494{
2495 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_ave);
2496 return pnanovdb_address_offset(root.address, byte_offset);
2497}
2498
2499PNANOVDB_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)
2500{
2501 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_off_stddev);
2502 return pnanovdb_address_offset(root.address, byte_offset);
2503}
2504
2505PNANOVDB_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)
2506{
2507 pnanovdb_uint32_t byte_offset = PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_off_value);
2508 return pnanovdb_address_offset(root_tile.address, byte_offset);
2509}
2510
2511PNANOVDB_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)
2512{
2513 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
2514 pnanovdb_address_t ret;
2515 if (pnanovdb_address_is_null(tile.address))
2516 {
2517 ret = pnanovdb_address_offset(root.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_off_background));
2518 PNANOVDB_DEREF(level) = 4u;
2519 }
2520 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
2521 {
2522 ret = pnanovdb_address_offset(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_off_value));
2523 PNANOVDB_DEREF(level) = 3u;
2524 }
2525 else
2526 {
2527 pnanovdb_upper_handle_t child = pnanovdb_root_get_child(grid_type, buf, root, tile);
2528 ret = pnanovdb_upper_get_value_address_and_level(grid_type, buf, child, ijk, level);
2529 }
2530 return ret;
2531}
2532
2533PNANOVDB_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)
2534{
2535 pnanovdb_uint32_t level;
2536 return pnanovdb_root_get_value_address_and_level(grid_type, buf, root, ijk, PNANOVDB_REF(level));
2537}
2538
2539PNANOVDB_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)
2540{
2541 pnanovdb_uint32_t level;
2542 pnanovdb_address_t address = pnanovdb_root_get_value_address_and_level(grid_type, buf, root, ijk, PNANOVDB_REF(level));
2543 PNANOVDB_DEREF(bit_index) = level == 0u ? pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).x & 7) : 0u;
2544 return address;
2545}
2546
2547PNANOVDB_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)
2548{
2549 float ret;
2550 if (level == 0)
2551 {
2552 ret = pnanovdb_leaf_fp4_read_float(buf, address, ijk);
2553 }
2554 else
2555 {
2556 ret = pnanovdb_read_float(buf, address);
2557 }
2558 return ret;
2559}
2560
2561PNANOVDB_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)
2562{
2563 float ret;
2564 if (level == 0)
2565 {
2566 ret = pnanovdb_leaf_fp8_read_float(buf, address, ijk);
2567 }
2568 else
2569 {
2570 ret = pnanovdb_read_float(buf, address);
2571 }
2572 return ret;
2573}
2574
2575PNANOVDB_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)
2576{
2577 float ret;
2578 if (level == 0)
2579 {
2580 ret = pnanovdb_leaf_fp16_read_float(buf, address, ijk);
2581 }
2582 else
2583 {
2584 ret = pnanovdb_read_float(buf, address);
2585 }
2586 return ret;
2587}
2588
2589PNANOVDB_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)
2590{
2591 float ret;
2592 if (level == 0)
2593 {
2594 ret = pnanovdb_leaf_fpn_read_float(buf, address, ijk);
2595 }
2596 else
2597 {
2598 ret = pnanovdb_read_float(buf, address);
2599 }
2600 return ret;
2601}
2602
2603PNANOVDB_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)
2604{
2605 pnanovdb_uint64_t ret;
2606 if (level == 0)
2607 {
2608 ret = pnanovdb_leaf_index_get_value_index(buf, address, ijk);
2609 }
2610 else
2611 {
2612 ret = pnanovdb_read_uint64(buf, address);
2613 }
2614 return ret;
2615}
2616
2617PNANOVDB_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)
2618{
2619 pnanovdb_uint64_t ret;
2620 if (level == 0)
2621 {
2622 ret = pnanovdb_leaf_onindex_get_value_index(buf, address, ijk);
2623 }
2624 else
2625 {
2626 ret = pnanovdb_read_uint64(buf, address);
2627 }
2628 return ret;
2629}
2630
2631PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_pointindex_get_point_range(
2632 pnanovdb_buf_t buf,
2633 pnanovdb_address_t value_address,
2634 PNANOVDB_IN(pnanovdb_coord_t) ijk,
2635 pnanovdb_uint32_t level,
2636 PNANOVDB_INOUT(pnanovdb_uint64_t)range_begin,
2637 PNANOVDB_INOUT(pnanovdb_uint64_t)range_end
2638)
2639{
2640 pnanovdb_uint32_t local_range_begin = 0u;
2641 pnanovdb_uint32_t local_range_end = 0u;
2642 pnanovdb_uint64_t offset = pnanovdb_uint32_as_uint64_low(0u);
2643 if (level == 0)
2644 {
2645 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2646 // recover leaf address
2647 pnanovdb_leaf_handle_t leaf = { pnanovdb_address_offset_neg(value_address, PNANOVDB_GRID_TYPE_GET(PNANOVDB_GRID_TYPE_POINTINDEX, leaf_off_table) + 2u * n) };
2648 if (n > 0u)
2649 {
2650 local_range_begin = pnanovdb_read_uint16(buf, pnanovdb_address_offset_neg(value_address, 2u));
2651 }
2652 local_range_end = pnanovdb_read_uint16(buf, value_address);
2653 offset = pnanovdb_leaf_pointindex_get_offset(buf, leaf);
2654 }
2655 PNANOVDB_DEREF(range_begin) = pnanovdb_uint64_offset(offset, local_range_begin);
2656 PNANOVDB_DEREF(range_end) = pnanovdb_uint64_offset(offset, local_range_end);
2657 return pnanovdb_uint32_as_uint64_low(local_range_end - local_range_begin);
2658}
2659
2660PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_root_pointindex_get_point_address_range(
2661 pnanovdb_buf_t buf,
2662 pnanovdb_grid_type_t value_type,
2663 pnanovdb_address_t value_address,
2664 pnanovdb_address_t blindmetadata_value_address,
2665 PNANOVDB_IN(pnanovdb_coord_t) ijk,
2666 pnanovdb_uint32_t level,
2667 PNANOVDB_INOUT(pnanovdb_address_t)address_begin,
2668 PNANOVDB_INOUT(pnanovdb_address_t)address_end
2669)
2670{
2671 pnanovdb_uint64_t range_begin;
2672 pnanovdb_uint64_t range_end;
2673 pnanovdb_uint64_t range_size = pnanovdb_root_pointindex_get_point_range(buf, value_address, ijk, level, PNANOVDB_REF(range_begin), PNANOVDB_REF(range_end));
2674
2675 pnanovdb_uint32_t stride = 12u; // vec3f
2676 if (value_type == PNANOVDB_GRID_TYPE_VEC3U8)
2677 {
2678 stride = 3u;
2679 }
2680 else if (value_type == PNANOVDB_GRID_TYPE_VEC3U16)
2681 {
2682 stride = 6u;
2683 }
2684 PNANOVDB_DEREF(address_begin) = pnanovdb_address_offset64_product(blindmetadata_value_address, range_begin, stride);
2685 PNANOVDB_DEREF(address_end) = pnanovdb_address_offset64_product(blindmetadata_value_address, range_end, stride);
2686 return range_size;
2687}
2688
2689// ------------------------------------------------ ReadAccessor -----------------------------------------------------------
2690
2691 struct pnanovdb_readaccessor_t
2692{
2693 pnanovdb_coord_t key;
2694 pnanovdb_leaf_handle_t leaf;
2695 pnanovdb_lower_handle_t lower;
2696 pnanovdb_upper_handle_t upper;
2697 pnanovdb_root_handle_t root;
2698};
2699PNANOVDB_STRUCT_TYPEDEF(pnanovdb_readaccessor_t)
2700
2701PNANOVDB_FORCE_INLINE void pnanovdb_readaccessor_init(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, pnanovdb_root_handle_t root)
2702{
2703 PNANOVDB_DEREF(acc).key.x = 0x7FFFFFFF;
2704 PNANOVDB_DEREF(acc).key.y = 0x7FFFFFFF;
2705 PNANOVDB_DEREF(acc).key.z = 0x7FFFFFFF;
2706 PNANOVDB_DEREF(acc).leaf.address = pnanovdb_address_null();
2707 PNANOVDB_DEREF(acc).lower.address = pnanovdb_address_null();
2708 PNANOVDB_DEREF(acc).upper.address = pnanovdb_address_null();
2709 PNANOVDB_DEREF(acc).root = root;
2710}
2711
2712PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached0(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
2713{
2714 if (pnanovdb_address_is_null(PNANOVDB_DEREF(acc).leaf.address)) { return PNANOVDB_FALSE; }
2715 if ((dirty & ~((1u << 3) - 1u)) != 0)
2716 {
2717 PNANOVDB_DEREF(acc).leaf.address = pnanovdb_address_null();
2718 return PNANOVDB_FALSE;
2719 }
2720 return PNANOVDB_TRUE;
2721}
2722PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached1(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
2723{
2724 if (pnanovdb_address_is_null(PNANOVDB_DEREF(acc).lower.address)) { return PNANOVDB_FALSE; }
2725 if ((dirty & ~((1u << 7) - 1u)) != 0)
2726 {
2727 PNANOVDB_DEREF(acc).lower.address = pnanovdb_address_null();
2728 return PNANOVDB_FALSE;
2729 }
2730 return PNANOVDB_TRUE;
2731}
2732PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_readaccessor_iscached2(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, int dirty)
2733{
2734 if (pnanovdb_address_is_null(PNANOVDB_DEREF(acc).upper.address)) { return PNANOVDB_FALSE; }
2735 if ((dirty & ~((1u << 12) - 1u)) != 0)
2736 {
2737 PNANOVDB_DEREF(acc).upper.address = pnanovdb_address_null();
2738 return PNANOVDB_FALSE;
2739 }
2740 return PNANOVDB_TRUE;
2741}
2742PNANOVDB_FORCE_INLINE int pnanovdb_readaccessor_computedirty(PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc, PNANOVDB_IN(pnanovdb_coord_t) ijk)
2743{
2744 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);
2745}
2746
2747PNANOVDB_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)
2748{
2749 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2750 return pnanovdb_leaf_get_table_address(grid_type, buf, leaf, n);
2751}
2752
2753PNANOVDB_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)
2754{
2755 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
2756 pnanovdb_address_t value_address;
2757 if (pnanovdb_lower_get_child_mask(buf, lower, n))
2758 {
2759 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
2760 PNANOVDB_DEREF(acc).leaf = child;
2761 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2762 value_address = pnanovdb_leaf_get_value_address_and_cache(grid_type, buf, child, ijk, acc);
2763 PNANOVDB_DEREF(level) = 0u;
2764 }
2765 else
2766 {
2767 value_address = pnanovdb_lower_get_table_address(grid_type, buf, lower, n);
2768 PNANOVDB_DEREF(level) = 1u;
2769 }
2770 return value_address;
2771}
2772
2773PNANOVDB_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)
2774{
2775 pnanovdb_uint32_t level;
2776 return pnanovdb_lower_get_value_address_and_level_and_cache(grid_type, buf, lower, ijk, acc, PNANOVDB_REF(level));
2777}
2778
2779PNANOVDB_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)
2780{
2781 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
2782 pnanovdb_address_t value_address;
2783 if (pnanovdb_upper_get_child_mask(buf, upper, n))
2784 {
2785 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
2786 PNANOVDB_DEREF(acc).lower = child;
2787 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2788 value_address = pnanovdb_lower_get_value_address_and_level_and_cache(grid_type, buf, child, ijk, acc, level);
2789 }
2790 else
2791 {
2792 value_address = pnanovdb_upper_get_table_address(grid_type, buf, upper, n);
2793 PNANOVDB_DEREF(level) = 2u;
2794 }
2795 return value_address;
2796}
2797
2798PNANOVDB_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)
2799{
2800 pnanovdb_uint32_t level;
2801 return pnanovdb_upper_get_value_address_and_level_and_cache(grid_type, buf, upper, ijk, acc, PNANOVDB_REF(level));
2802}
2803
2804PNANOVDB_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)
2805{
2806 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
2807 pnanovdb_address_t ret;
2808 if (pnanovdb_address_is_null(tile.address))
2809 {
2810 ret = pnanovdb_address_offset(root.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_off_background));
2811 PNANOVDB_DEREF(level) = 4u;
2812 }
2813 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
2814 {
2815 ret = pnanovdb_address_offset(tile.address, PNANOVDB_GRID_TYPE_GET(grid_type, root_tile_off_value));
2816 PNANOVDB_DEREF(level) = 3u;
2817 }
2818 else
2819 {
2820 pnanovdb_upper_handle_t child = pnanovdb_root_get_child(grid_type, buf, root, tile);
2821 PNANOVDB_DEREF(acc).upper = child;
2822 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2823 ret = pnanovdb_upper_get_value_address_and_level_and_cache(grid_type, buf, child, ijk, acc, level);
2824 }
2825 return ret;
2826}
2827
2828PNANOVDB_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)
2829{
2830 pnanovdb_uint32_t level;
2831 return pnanovdb_root_get_value_address_and_level_and_cache(grid_type, buf, root, ijk, acc, PNANOVDB_REF(level));
2832}
2833
2834PNANOVDB_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)
2835{
2836 int dirty = pnanovdb_readaccessor_computedirty(acc, ijk);
2837
2838 pnanovdb_address_t value_address;
2839 if (pnanovdb_readaccessor_iscached0(acc, dirty))
2840 {
2841 value_address = pnanovdb_leaf_get_value_address_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).leaf, ijk, acc);
2842 PNANOVDB_DEREF(level) = 0u;
2843 }
2844 else if (pnanovdb_readaccessor_iscached1(acc, dirty))
2845 {
2846 value_address = pnanovdb_lower_get_value_address_and_level_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).lower, ijk, acc, level);
2847 }
2848 else if (pnanovdb_readaccessor_iscached2(acc, dirty))
2849 {
2850 value_address = pnanovdb_upper_get_value_address_and_level_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).upper, ijk, acc, level);
2851 }
2852 else
2853 {
2854 value_address = pnanovdb_root_get_value_address_and_level_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).root, ijk, acc, level);
2855 }
2856 return value_address;
2857}
2858
2859PNANOVDB_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)
2860{
2861 pnanovdb_uint32_t level;
2862 return pnanovdb_readaccessor_get_value_address_and_level(grid_type, buf, acc, ijk, PNANOVDB_REF(level));
2863}
2864
2865PNANOVDB_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)
2866{
2867 pnanovdb_uint32_t level;
2868 pnanovdb_address_t address = pnanovdb_readaccessor_get_value_address_and_level(grid_type, buf, acc, ijk, PNANOVDB_REF(level));
2869 PNANOVDB_DEREF(bit_index) = level == 0u ? pnanovdb_int32_as_uint32(PNANOVDB_DEREF(ijk).x & 7) : 0u;
2870 return address;
2871}
2872
2873// ------------------------------------------------ ReadAccessor GetDim -----------------------------------------------------------
2874
2875PNANOVDB_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)
2876{
2877 return 1u;
2878}
2879
2880PNANOVDB_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)
2881{
2882 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
2883 pnanovdb_uint32_t ret;
2884 if (pnanovdb_lower_get_child_mask(buf, lower, n))
2885 {
2886 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
2887 PNANOVDB_DEREF(acc).leaf = child;
2888 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2889 ret = pnanovdb_leaf_get_dim_and_cache(grid_type, buf, child, ijk, acc);
2890 }
2891 else
2892 {
2893 ret = (1u << (3u)); // node 0 dim
2894 }
2895 return ret;
2896}
2897
2898PNANOVDB_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)
2899{
2900 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
2901 pnanovdb_uint32_t ret;
2902 if (pnanovdb_upper_get_child_mask(buf, upper, n))
2903 {
2904 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
2905 PNANOVDB_DEREF(acc).lower = child;
2906 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2907 ret = pnanovdb_lower_get_dim_and_cache(grid_type, buf, child, ijk, acc);
2908 }
2909 else
2910 {
2911 ret = (1u << (4u + 3u)); // node 1 dim
2912 }
2913 return ret;
2914}
2915
2916PNANOVDB_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)
2917{
2918 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
2919 pnanovdb_uint32_t ret;
2920 if (pnanovdb_address_is_null(tile.address))
2921 {
2922 ret = 1u << (5u + 4u + 3u); // background, node 2 dim
2923 }
2924 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
2925 {
2926 ret = 1u << (5u + 4u + 3u); // tile value, node 2 dim
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_dim_and_cache(grid_type, buf, child, ijk, acc);
2934 }
2935 return ret;
2936}
2937
2938PNANOVDB_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)
2939{
2940 int dirty = pnanovdb_readaccessor_computedirty(acc, ijk);
2941
2942 pnanovdb_uint32_t dim;
2943 if (pnanovdb_readaccessor_iscached0(acc, dirty))
2944 {
2945 dim = pnanovdb_leaf_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).leaf, ijk, acc);
2946 }
2947 else if (pnanovdb_readaccessor_iscached1(acc, dirty))
2948 {
2949 dim = pnanovdb_lower_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).lower, ijk, acc);
2950 }
2951 else if (pnanovdb_readaccessor_iscached2(acc, dirty))
2952 {
2953 dim = pnanovdb_upper_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).upper, ijk, acc);
2954 }
2955 else
2956 {
2957 dim = pnanovdb_root_get_dim_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).root, ijk, acc);
2958 }
2959 return dim;
2960}
2961
2962// ------------------------------------------------ ReadAccessor IsActive -----------------------------------------------------------
2963
2964PNANOVDB_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)
2965{
2966 pnanovdb_uint32_t n = pnanovdb_leaf_coord_to_offset(ijk);
2967 return pnanovdb_leaf_get_value_mask(buf, leaf, n);
2968}
2969
2970PNANOVDB_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)
2971{
2972 pnanovdb_uint32_t n = pnanovdb_lower_coord_to_offset(ijk);
2973 pnanovdb_bool_t is_active;
2974 if (pnanovdb_lower_get_child_mask(buf, lower, n))
2975 {
2976 pnanovdb_leaf_handle_t child = pnanovdb_lower_get_child(grid_type, buf, lower, n);
2977 PNANOVDB_DEREF(acc).leaf = child;
2978 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2979 is_active = pnanovdb_leaf_is_active_and_cache(grid_type, buf, child, ijk, acc);
2980 }
2981 else
2982 {
2983 is_active = pnanovdb_lower_get_value_mask(buf, lower, n);
2984 }
2985 return is_active;
2986}
2987
2988PNANOVDB_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)
2989{
2990 pnanovdb_uint32_t n = pnanovdb_upper_coord_to_offset(ijk);
2991 pnanovdb_bool_t is_active;
2992 if (pnanovdb_upper_get_child_mask(buf, upper, n))
2993 {
2994 pnanovdb_lower_handle_t child = pnanovdb_upper_get_child(grid_type, buf, upper, n);
2995 PNANOVDB_DEREF(acc).lower = child;
2996 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
2997 is_active = pnanovdb_lower_is_active_and_cache(grid_type, buf, child, ijk, acc);
2998 }
2999 else
3000 {
3001 is_active = pnanovdb_upper_get_value_mask(buf, upper, n);
3002 }
3003 return is_active;
3004}
3005
3006PNANOVDB_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)
3007{
3008 pnanovdb_root_tile_handle_t tile = pnanovdb_root_find_tile(grid_type, buf, root, ijk);
3009 pnanovdb_bool_t is_active;
3010 if (pnanovdb_address_is_null(tile.address))
3011 {
3012 is_active = PNANOVDB_FALSE; // background
3013 }
3014 else if (pnanovdb_int64_is_zero(pnanovdb_root_tile_get_child(buf, tile)))
3015 {
3016 pnanovdb_uint32_t state = pnanovdb_root_tile_get_state(buf, tile);
3017 is_active = state != 0u; // tile value
3018 }
3019 else
3020 {
3021 pnanovdb_upper_handle_t child = pnanovdb_root_get_child(grid_type, buf, root, tile);
3022 PNANOVDB_DEREF(acc).upper = child;
3023 PNANOVDB_DEREF(acc).key = PNANOVDB_DEREF(ijk);
3024 is_active = pnanovdb_upper_is_active_and_cache(grid_type, buf, child, ijk, acc);
3025 }
3026 return is_active;
3027}
3028
3029PNANOVDB_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)
3030{
3031 int dirty = pnanovdb_readaccessor_computedirty(acc, ijk);
3032
3033 pnanovdb_bool_t is_active;
3034 if (pnanovdb_readaccessor_iscached0(acc, dirty))
3035 {
3036 is_active = pnanovdb_leaf_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).leaf, ijk, acc);
3037 }
3038 else if (pnanovdb_readaccessor_iscached1(acc, dirty))
3039 {
3040 is_active = pnanovdb_lower_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).lower, ijk, acc);
3041 }
3042 else if (pnanovdb_readaccessor_iscached2(acc, dirty))
3043 {
3044 is_active = pnanovdb_upper_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).upper, ijk, acc);
3045 }
3046 else
3047 {
3048 is_active = pnanovdb_root_is_active_and_cache(grid_type, buf, PNANOVDB_DEREF(acc).root, ijk, acc);
3049 }
3050 return is_active;
3051}
3052
3053// ------------------------------------------------ Map Transforms -----------------------------------------------------------
3054
3055PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
3056{
3057 pnanovdb_vec3_t dst;
3058 float sx = PNANOVDB_DEREF(src).x;
3059 float sy = PNANOVDB_DEREF(src).y;
3060 float sz = PNANOVDB_DEREF(src).z;
3061 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);
3062 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);
3063 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);
3064 return dst;
3065}
3066
3067PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_inverse(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
3068{
3069 pnanovdb_vec3_t dst;
3070 float sx = PNANOVDB_DEREF(src).x - pnanovdb_map_get_vecf(buf, map, 0);
3071 float sy = PNANOVDB_DEREF(src).y - pnanovdb_map_get_vecf(buf, map, 1);
3072 float sz = PNANOVDB_DEREF(src).z - pnanovdb_map_get_vecf(buf, map, 2);
3073 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);
3074 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);
3075 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);
3076 return dst;
3077}
3078
3079PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_map_apply_jacobi(pnanovdb_buf_t buf, pnanovdb_map_handle_t map, PNANOVDB_IN(pnanovdb_vec3_t) src)
3080{
3081 pnanovdb_vec3_t dst;
3082 float sx = PNANOVDB_DEREF(src).x;
3083 float sy = PNANOVDB_DEREF(src).y;
3084 float sz = PNANOVDB_DEREF(src).z;
3085 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);
3086 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);
3087 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);
3088 return dst;
3089}
3090
3091PNANOVDB_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)
3092{
3093 pnanovdb_vec3_t dst;
3094 float sx = PNANOVDB_DEREF(src).x;
3095 float sy = PNANOVDB_DEREF(src).y;
3096 float sz = PNANOVDB_DEREF(src).z;
3097 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);
3098 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);
3099 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);
3100 return dst;
3101}
3102
3103PNANOVDB_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)
3104{
3105 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3106 return pnanovdb_map_apply_inverse(buf, map, src);
3107}
3108
3109PNANOVDB_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)
3110{
3111 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3112 return pnanovdb_map_apply(buf, map, src);
3113}
3114
3115PNANOVDB_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)
3116{
3117 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3118 return pnanovdb_map_apply_inverse_jacobi(buf, map, src);
3119}
3120
3121PNANOVDB_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)
3122{
3123 pnanovdb_map_handle_t map = pnanovdb_grid_get_map(buf, grid);
3124 return pnanovdb_map_apply_jacobi(buf, map, src);
3125}
3126
3127// ------------------------------------------------ DitherLUT -----------------------------------------------------------
3128
3129// This table was generated with
3130/**************
3131
3132static constexpr inline uint32
3133SYSwang_inthash(uint32 key)
3134{
3135 // From http://www.concentric.net/~Ttwang/tech/inthash.htm
3136 key += ~(key << 16);
3137 key ^= (key >> 5);
3138 key += (key << 3);
3139 key ^= (key >> 13);
3140 key += ~(key << 9);
3141 key ^= (key >> 17);
3142 return key;
3143}
3144
3145static void
3146ut_initDitherR(float *pattern, float offset,
3147 int x, int y, int z, int res, int goalres)
3148{
3149 // These offsets are designed to maximize the difference between
3150 // dither values in nearby voxels within a given 2x2x2 cell, without
3151 // producing axis-aligned artifacts. The are organized in row-major
3152 // order.
3153 static const float theDitherOffset[] = {0,4,6,2,5,1,3,7};
3154 static const float theScale = 0.125F;
3155 int key = (((z << res) + y) << res) + x;
3156
3157 if (res == goalres)
3158 {
3159 pattern[key] = offset;
3160 return;
3161 }
3162
3163 // Randomly flip (on each axis) the dithering patterns used by the
3164 // subcells. This key is xor'd with the subcell index below before
3165 // looking up in the dither offset list.
3166 key = SYSwang_inthash(key) & 7;
3167
3168 x <<= 1;
3169 y <<= 1;
3170 z <<= 1;
3171
3172 offset *= theScale;
3173 for (int i = 0; i < 8; i++)
3174 ut_initDitherR(pattern, offset+theDitherOffset[i ^ key]*theScale,
3175 x+(i&1), y+((i&2)>>1), z+((i&4)>>2), res+1, goalres);
3176}
3177
3178// This is a compact algorithm that accomplishes essentially the same thing
3179// as ut_initDither() above. We should eventually switch to use this and
3180// clean the dead code.
3181static fpreal32 *
3182ut_initDitherRecursive(int goalres)
3183{
3184 const int nfloat = 1 << (goalres*3);
3185 float *pattern = new float[nfloat];
3186 ut_initDitherR(pattern, 1.0F, 0, 0, 0, 0, goalres);
3187
3188 // This has built an even spacing from 1/nfloat to 1.0.
3189 // however, our dither pattern should be 1/(nfloat+1) to nfloat/(nfloat+1)
3190 // So we do a correction here. Note that the earlier calculations are
3191 // done with powers of 2 so are exact, so it does make sense to delay
3192 // the renormalization to this pass.
3193 float correctionterm = nfloat / (nfloat+1.0F);
3194 for (int i = 0; i < nfloat; i++)
3195 pattern[i] *= correctionterm;
3196 return pattern;
3197}
3198
3199 theDitherMatrix = ut_initDitherRecursive(3);
3200
3201 for (int i = 0; i < 512/8; i ++)
3202 {
3203 for (int j = 0; j < 8; j ++)
3204 std::cout << theDitherMatrix[i*8+j] << "f, ";
3205 std::cout << std::endl;
3206 }
3207
3208 **************/
3209
3210PNANOVDB_STATIC_CONST float pnanovdb_dither_lut[512] =
3211{
3212 0.14425f, 0.643275f, 0.830409f, 0.331384f, 0.105263f, 0.604289f, 0.167641f, 0.666667f,
3213 0.892788f, 0.393762f, 0.0818713f, 0.580897f, 0.853801f, 0.354776f, 0.916179f, 0.417154f,
3214 0.612086f, 0.11306f, 0.79922f, 0.300195f, 0.510721f, 0.0116959f, 0.947368f, 0.448343f,
3215 0.362573f, 0.861598f, 0.0506823f, 0.549708f, 0.261209f, 0.760234f, 0.19883f, 0.697856f,
3216 0.140351f, 0.639376f, 0.576998f, 0.0779727f, 0.522417f, 0.0233918f, 0.460039f, 0.959064f,
3217 0.888889f, 0.389864f, 0.327485f, 0.826511f, 0.272904f, 0.77193f, 0.709552f, 0.210526f,
3218 0.483431f, 0.982456f, 0.296296f, 0.795322f, 0.116959f, 0.615984f, 0.0545809f, 0.553606f,
3219 0.732943f, 0.233918f, 0.545809f, 0.0467836f, 0.865497f, 0.366472f, 0.803119f, 0.304094f,
3220 0.518519f, 0.0194932f, 0.45614f, 0.955166f, 0.729045f, 0.230019f, 0.54191f, 0.042885f,
3221 0.269006f, 0.768031f, 0.705653f, 0.206628f, 0.479532f, 0.978558f, 0.292398f, 0.791423f,
3222 0.237817f, 0.736842f, 0.424951f, 0.923977f, 0.136452f, 0.635478f, 0.323587f, 0.822612f,
3223 0.986355f, 0.487329f, 0.674464f, 0.175439f, 0.88499f, 0.385965f, 0.573099f, 0.0740741f,
3224 0.51462f, 0.0155945f, 0.202729f, 0.701754f, 0.148148f, 0.647174f, 0.834308f, 0.335283f,
3225 0.265107f, 0.764133f, 0.951267f, 0.452242f, 0.896686f, 0.397661f, 0.08577f, 0.584795f,
3226 0.8577f, 0.358674f, 0.920078f, 0.421053f, 0.740741f, 0.241715f, 0.678363f, 0.179337f,
3227 0.109162f, 0.608187f, 0.17154f, 0.670565f, 0.491228f, 0.990253f, 0.42885f, 0.927875f,
3228 0.0662768f, 0.565302f, 0.62768f, 0.128655f, 0.183236f, 0.682261f, 0.744639f, 0.245614f,
3229 0.814815f, 0.315789f, 0.378168f, 0.877193f, 0.931774f, 0.432749f, 0.495127f, 0.994152f,
3230 0.0350877f, 0.534113f, 0.97076f, 0.471735f, 0.214425f, 0.71345f, 0.526316f, 0.0272904f,
3231 0.783626f, 0.2846f, 0.222222f, 0.721248f, 0.962963f, 0.463938f, 0.276803f, 0.775828f,
3232 0.966862f, 0.467836f, 0.405458f, 0.904483f, 0.0701754f, 0.569201f, 0.881092f, 0.382066f,
3233 0.218324f, 0.717349f, 0.654971f, 0.155945f, 0.818713f, 0.319688f, 0.132554f, 0.631579f,
3234 0.0623782f, 0.561404f, 0.748538f, 0.249513f, 0.912281f, 0.413255f, 0.974659f, 0.475634f,
3235 0.810916f, 0.311891f, 0.499025f, 0.998051f, 0.163743f, 0.662768f, 0.226121f, 0.725146f,
3236 0.690058f, 0.191033f, 0.00389864f, 0.502924f, 0.557505f, 0.0584795f, 0.120858f, 0.619883f,
3237 0.440546f, 0.939571f, 0.752437f, 0.253411f, 0.307992f, 0.807018f, 0.869396f, 0.37037f,
3238 0.658869f, 0.159844f, 0.346979f, 0.846004f, 0.588694f, 0.0896686f, 0.152047f, 0.651072f,
3239 0.409357f, 0.908382f, 0.596491f, 0.0974659f, 0.339181f, 0.838207f, 0.900585f, 0.401559f,
3240 0.34308f, 0.842105f, 0.779727f, 0.280702f, 0.693957f, 0.194932f, 0.25731f, 0.756335f,
3241 0.592593f, 0.0935673f, 0.0311891f, 0.530214f, 0.444444f, 0.94347f, 0.506823f, 0.00779727f,
3242 0.68616f, 0.187135f, 0.124756f, 0.623782f, 0.288499f, 0.787524f, 0.350877f, 0.849903f,
3243 0.436647f, 0.935673f, 0.873294f, 0.374269f, 0.538012f, 0.0389864f, 0.60039f, 0.101365f,
3244 0.57115f, 0.0721248f, 0.758285f, 0.259259f, 0.719298f, 0.220273f, 0.532164f, 0.0331384f,
3245 0.321637f, 0.820663f, 0.00974659f, 0.508772f, 0.469786f, 0.968811f, 0.282651f, 0.781676f,
3246 0.539961f, 0.0409357f, 0.727096f, 0.22807f, 0.500975f, 0.00194932f, 0.563353f, 0.0643275f,
3247 0.290448f, 0.789474f, 0.477583f, 0.976608f, 0.251462f, 0.750487f, 0.31384f, 0.812865f,
3248 0.94152f, 0.442495f, 0.879142f, 0.380117f, 0.37232f, 0.871345f, 0.309942f, 0.808967f,
3249 0.192982f, 0.692008f, 0.130604f, 0.62963f, 0.621832f, 0.122807f, 0.559454f, 0.0604289f,
3250 0.660819f, 0.161793f, 0.723197f, 0.224172f, 0.403509f, 0.902534f, 0.840156f, 0.341131f,
3251 0.411306f, 0.910331f, 0.473684f, 0.97271f, 0.653021f, 0.153996f, 0.0916179f, 0.590643f,
3252 0.196881f, 0.695906f, 0.384016f, 0.883041f, 0.0955166f, 0.594542f, 0.157895f, 0.65692f,
3253 0.945419f, 0.446394f, 0.633528f, 0.134503f, 0.844055f, 0.345029f, 0.906433f, 0.407407f,
3254 0.165692f, 0.664717f, 0.103314f, 0.602339f, 0.126706f, 0.625731f, 0.189084f, 0.688109f,
3255 0.91423f, 0.415205f, 0.851852f, 0.352827f, 0.875244f, 0.376218f, 0.937622f, 0.438596f,
3256 0.317739f, 0.816764f, 0.255361f, 0.754386f, 0.996101f, 0.497076f, 0.933723f, 0.434698f,
3257 0.567251f, 0.0682261f, 0.504873f, 0.00584795f, 0.247563f, 0.746589f, 0.185185f, 0.684211f,
3258 0.037037f, 0.536062f, 0.0994152f, 0.598441f, 0.777778f, 0.278752f, 0.465887f, 0.964912f,
3259 0.785575f, 0.28655f, 0.847953f, 0.348928f, 0.0292398f, 0.528265f, 0.7154f, 0.216374f,
3260 0.39961f, 0.898636f, 0.961014f, 0.461988f, 0.0487329f, 0.547758f, 0.111111f, 0.610136f,
3261 0.649123f, 0.150097f, 0.212476f, 0.711501f, 0.797271f, 0.298246f, 0.859649f, 0.360624f,
3262 0.118908f, 0.617934f, 0.0565302f, 0.555556f, 0.329435f, 0.82846f, 0.516569f, 0.0175439f,
3263 0.867446f, 0.368421f, 0.805068f, 0.306043f, 0.578947f, 0.079922f, 0.267057f, 0.766082f,
3264 0.270955f, 0.76998f, 0.707602f, 0.208577f, 0.668616f, 0.169591f, 0.606238f, 0.107212f,
3265 0.520468f, 0.0214425f, 0.45809f, 0.957115f, 0.419103f, 0.918129f, 0.356725f, 0.855751f,
3266 0.988304f, 0.489279f, 0.426901f, 0.925926f, 0.450292f, 0.949318f, 0.512671f, 0.0136452f,
3267 0.239766f, 0.738791f, 0.676413f, 0.177388f, 0.699805f, 0.20078f, 0.263158f, 0.762183f,
3268 0.773879f, 0.274854f, 0.337232f, 0.836257f, 0.672515f, 0.173489f, 0.734893f, 0.235867f,
3269 0.0253411f, 0.524366f, 0.586745f, 0.0877193f, 0.423002f, 0.922027f, 0.48538f, 0.984405f,
3270 0.74269f, 0.243665f, 0.680312f, 0.181287f, 0.953216f, 0.454191f, 0.1423f, 0.641326f,
3271 0.493177f, 0.992203f, 0.430799f, 0.929825f, 0.204678f, 0.703704f, 0.890838f, 0.391813f,
3272 0.894737f, 0.395712f, 0.0838207f, 0.582846f, 0.0448343f, 0.54386f, 0.231969f, 0.730994f,
3273 0.146199f, 0.645224f, 0.832359f, 0.333333f, 0.793372f, 0.294347f, 0.980507f, 0.481481f,
3274 0.364522f, 0.863548f, 0.80117f, 0.302144f, 0.824561f, 0.325536f, 0.138402f, 0.637427f,
3275 0.614035f, 0.11501f, 0.0526316f, 0.551657f, 0.0760234f, 0.575049f, 0.88694f, 0.387914f,
3276};
3277
3278PNANOVDB_FORCE_INLINE float pnanovdb_dither_lookup(pnanovdb_bool_t enabled, int offset)
3279{
3280 return enabled ? pnanovdb_dither_lut[offset & 511] : 0.5f;
3281}
3282
3283// ------------------------------------------------ HDDA -----------------------------------------------------------
3284
3285#ifdef PNANOVDB_HDDA
3286
3287// Comment out to disable this explicit round-off check
3288#define PNANOVDB_ENFORCE_FORWARD_STEPPING
3289
3290#define PNANOVDB_HDDA_FLOAT_MAX 1e38f
3291
3292struct pnanovdb_hdda_t
3293{
3294 pnanovdb_int32_t dim;
3295 float tmin;
3296 float tmax;
3297 pnanovdb_coord_t voxel;
3298 pnanovdb_coord_t step;
3299 pnanovdb_vec3_t delta;
3300 pnanovdb_vec3_t next;
3301};
3302PNANOVDB_STRUCT_TYPEDEF(pnanovdb_hdda_t)
3303
3304PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_hdda_pos_to_ijk(PNANOVDB_IN(pnanovdb_vec3_t) pos)
3305{
3306 pnanovdb_coord_t voxel;
3307 voxel.x = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).x));
3308 voxel.y = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).y));
3309 voxel.z = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).z));
3310 return voxel;
3311}
3312
3313PNANOVDB_FORCE_INLINE pnanovdb_coord_t pnanovdb_hdda_pos_to_voxel(PNANOVDB_IN(pnanovdb_vec3_t) pos, int dim)
3314{
3315 pnanovdb_coord_t voxel;
3316 voxel.x = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).x)) & (~(dim - 1));
3317 voxel.y = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).y)) & (~(dim - 1));
3318 voxel.z = pnanovdb_float_to_int32(pnanovdb_floor(PNANOVDB_DEREF(pos).z)) & (~(dim - 1));
3319 return voxel;
3320}
3321
3322PNANOVDB_FORCE_INLINE pnanovdb_vec3_t pnanovdb_hdda_ray_start(PNANOVDB_IN(pnanovdb_vec3_t) origin, float tmin, PNANOVDB_IN(pnanovdb_vec3_t) direction)
3323{
3324 pnanovdb_vec3_t pos = pnanovdb_vec3_add(
3325 pnanovdb_vec3_mul(PNANOVDB_DEREF(direction), pnanovdb_vec3_uniform(tmin)),
3326 PNANOVDB_DEREF(origin)
3327 );
3328 return pos;
3329}
3330
3331PNANOVDB_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)
3332{
3333 PNANOVDB_DEREF(hdda).dim = dim;
3334 PNANOVDB_DEREF(hdda).tmin = tmin;
3335 PNANOVDB_DEREF(hdda).tmax = tmax;
3336
3337 pnanovdb_vec3_t pos = pnanovdb_hdda_ray_start(origin, tmin, direction);
3338 pnanovdb_vec3_t dir_inv = pnanovdb_vec3_div(pnanovdb_vec3_uniform(1.f), PNANOVDB_DEREF(direction));
3339
3340 PNANOVDB_DEREF(hdda).voxel = pnanovdb_hdda_pos_to_voxel(PNANOVDB_REF(pos), dim);
3341
3342 // x
3343 if (PNANOVDB_DEREF(direction).x == 0.f)
3344 {
3345 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_HDDA_FLOAT_MAX;
3346 PNANOVDB_DEREF(hdda).step.x = 0;
3347 PNANOVDB_DEREF(hdda).delta.x = 0.f;
3348 }
3349 else if (dir_inv.x > 0.f)
3350 {
3351 PNANOVDB_DEREF(hdda).step.x = 1;
3352 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.x + dim - pos.x) * dir_inv.x;
3353 PNANOVDB_DEREF(hdda).delta.x = dir_inv.x;
3354 }
3355 else
3356 {
3357 PNANOVDB_DEREF(hdda).step.x = -1;
3358 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.x - pos.x) * dir_inv.x;
3359 PNANOVDB_DEREF(hdda).delta.x = -dir_inv.x;
3360 }
3361
3362 // y
3363 if (PNANOVDB_DEREF(direction).y == 0.f)
3364 {
3365 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_HDDA_FLOAT_MAX;
3366 PNANOVDB_DEREF(hdda).step.y = 0;
3367 PNANOVDB_DEREF(hdda).delta.y = 0.f;
3368 }
3369 else if (dir_inv.y > 0.f)
3370 {
3371 PNANOVDB_DEREF(hdda).step.y = 1;
3372 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.y + dim - pos.y) * dir_inv.y;
3373 PNANOVDB_DEREF(hdda).delta.y = dir_inv.y;
3374 }
3375 else
3376 {
3377 PNANOVDB_DEREF(hdda).step.y = -1;
3378 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.y - pos.y) * dir_inv.y;
3379 PNANOVDB_DEREF(hdda).delta.y = -dir_inv.y;
3380 }
3381
3382 // z
3383 if (PNANOVDB_DEREF(direction).z == 0.f)
3384 {
3385 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_HDDA_FLOAT_MAX;
3386 PNANOVDB_DEREF(hdda).step.z = 0;
3387 PNANOVDB_DEREF(hdda).delta.z = 0.f;
3388 }
3389 else if (dir_inv.z > 0.f)
3390 {
3391 PNANOVDB_DEREF(hdda).step.z = 1;
3392 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.z + dim - pos.z) * dir_inv.z;
3393 PNANOVDB_DEREF(hdda).delta.z = dir_inv.z;
3394 }
3395 else
3396 {
3397 PNANOVDB_DEREF(hdda).step.z = -1;
3398 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.z - pos.z) * dir_inv.z;
3399 PNANOVDB_DEREF(hdda).delta.z = -dir_inv.z;
3400 }
3401}
3402
3403PNANOVDB_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)
3404{
3405 if (PNANOVDB_DEREF(hdda).dim == dim)
3406 {
3407 return PNANOVDB_FALSE;
3408 }
3409
3410 // compute valid voxel range
3411 pnanovdb_coord_t voxel_max = {
3412 (PNANOVDB_DEREF(hdda).voxel.x + PNANOVDB_DEREF(hdda).dim - 1) & (~(dim - 1)),
3413 (PNANOVDB_DEREF(hdda).voxel.y + PNANOVDB_DEREF(hdda).dim - 1) & (~(dim - 1)),
3414 (PNANOVDB_DEREF(hdda).voxel.z + PNANOVDB_DEREF(hdda).dim - 1) & (~(dim - 1))
3415 };
3416 pnanovdb_coord_t voxel_min = {
3417 PNANOVDB_DEREF(hdda).voxel.x & (~(dim - 1)),
3418 PNANOVDB_DEREF(hdda).voxel.y & (~(dim - 1)),
3419 PNANOVDB_DEREF(hdda).voxel.z & (~(dim - 1))
3420 };
3421
3422 PNANOVDB_DEREF(hdda).dim = dim;
3423
3424 pnanovdb_vec3_t pos = pnanovdb_vec3_add(
3425 pnanovdb_vec3_mul(PNANOVDB_DEREF(direction), pnanovdb_vec3_uniform(PNANOVDB_DEREF(hdda).tmin)),
3426 PNANOVDB_DEREF(origin)
3427 );
3428 pnanovdb_vec3_t dir_inv = pnanovdb_vec3_div(pnanovdb_vec3_uniform(1.f), PNANOVDB_DEREF(direction));
3429
3430 PNANOVDB_DEREF(hdda).voxel = pnanovdb_hdda_pos_to_voxel(PNANOVDB_REF(pos), dim);
3431
3432 // clamp voxel to valid range
3433 PNANOVDB_DEREF(hdda).voxel.x = PNANOVDB_DEREF(hdda).voxel.x < voxel_max.x ? PNANOVDB_DEREF(hdda).voxel.x : voxel_max.x;
3434 PNANOVDB_DEREF(hdda).voxel.y = PNANOVDB_DEREF(hdda).voxel.y < voxel_max.y ? PNANOVDB_DEREF(hdda).voxel.y : voxel_max.y;
3435 PNANOVDB_DEREF(hdda).voxel.z = PNANOVDB_DEREF(hdda).voxel.z < voxel_max.z ? PNANOVDB_DEREF(hdda).voxel.z : voxel_max.z;
3436 PNANOVDB_DEREF(hdda).voxel.x = PNANOVDB_DEREF(hdda).voxel.x > voxel_min.x ? PNANOVDB_DEREF(hdda).voxel.x : voxel_min.x;
3437 PNANOVDB_DEREF(hdda).voxel.y = PNANOVDB_DEREF(hdda).voxel.y > voxel_min.y ? PNANOVDB_DEREF(hdda).voxel.y : voxel_min.y;
3438 PNANOVDB_DEREF(hdda).voxel.z = PNANOVDB_DEREF(hdda).voxel.z > voxel_min.z ? PNANOVDB_DEREF(hdda).voxel.z : voxel_min.z;
3439
3440 if (PNANOVDB_DEREF(hdda).step.x != 0)
3441 {
3442 PNANOVDB_DEREF(hdda).next.x = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.x - pos.x) * dir_inv.x;
3443 if (PNANOVDB_DEREF(hdda).step.x > 0)
3444 {
3445 PNANOVDB_DEREF(hdda).next.x += dim * dir_inv.x;
3446 }
3447 }
3448 if (PNANOVDB_DEREF(hdda).step.y != 0)
3449 {
3450 PNANOVDB_DEREF(hdda).next.y = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.y - pos.y) * dir_inv.y;
3451 if (PNANOVDB_DEREF(hdda).step.y > 0)
3452 {
3453 PNANOVDB_DEREF(hdda).next.y += dim * dir_inv.y;
3454 }
3455 }
3456 if (PNANOVDB_DEREF(hdda).step.z != 0)
3457 {
3458 PNANOVDB_DEREF(hdda).next.z = PNANOVDB_DEREF(hdda).tmin + (PNANOVDB_DEREF(hdda).voxel.z - pos.z) * dir_inv.z;
3459 if (PNANOVDB_DEREF(hdda).step.z > 0)
3460 {
3461 PNANOVDB_DEREF(hdda).next.z += dim * dir_inv.z;
3462 }
3463 }
3464
3465 return PNANOVDB_TRUE;
3466}
3467
3468PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_hdda_step(PNANOVDB_INOUT(pnanovdb_hdda_t) hdda)
3469{
3470 pnanovdb_bool_t ret;
3471 if (PNANOVDB_DEREF(hdda).next.x < PNANOVDB_DEREF(hdda).next.y && PNANOVDB_DEREF(hdda).next.x < PNANOVDB_DEREF(hdda).next.z)
3472 {
3473#ifdef PNANOVDB_ENFORCE_FORWARD_STEPPING
3474 if (PNANOVDB_DEREF(hdda).next.x <= PNANOVDB_DEREF(hdda).tmin)
3475 {
3476 PNANOVDB_DEREF(hdda).next.x += PNANOVDB_DEREF(hdda).tmin - 0.999999f * PNANOVDB_DEREF(hdda).next.x + 1.0e-6f;
3477 }
3478#endif
3479 PNANOVDB_DEREF(hdda).tmin = PNANOVDB_DEREF(hdda).next.x;
3480 PNANOVDB_DEREF(hdda).next.x += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).delta.x;
3481 PNANOVDB_DEREF(hdda).voxel.x += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).step.x;
3482 ret = PNANOVDB_DEREF(hdda).tmin <= PNANOVDB_DEREF(hdda).tmax;
3483 }
3484 else if (PNANOVDB_DEREF(hdda).next.y < PNANOVDB_DEREF(hdda).next.z)
3485 {
3486#ifdef PNANOVDB_ENFORCE_FORWARD_STEPPING
3487 if (PNANOVDB_DEREF(hdda).next.y <= PNANOVDB_DEREF(hdda).tmin)
3488 {
3489 PNANOVDB_DEREF(hdda).next.y += PNANOVDB_DEREF(hdda).tmin - 0.999999f * PNANOVDB_DEREF(hdda).next.y + 1.0e-6f;
3490 }
3491#endif
3492 PNANOVDB_DEREF(hdda).tmin = PNANOVDB_DEREF(hdda).next.y;
3493 PNANOVDB_DEREF(hdda).next.y += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).delta.y;
3494 PNANOVDB_DEREF(hdda).voxel.y += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).step.y;
3495 ret = PNANOVDB_DEREF(hdda).tmin <= PNANOVDB_DEREF(hdda).tmax;
3496 }
3497 else
3498 {
3499#ifdef PNANOVDB_ENFORCE_FORWARD_STEPPING
3500 if (PNANOVDB_DEREF(hdda).next.z <= PNANOVDB_DEREF(hdda).tmin)
3501 {
3502 PNANOVDB_DEREF(hdda).next.z += PNANOVDB_DEREF(hdda).tmin - 0.999999f * PNANOVDB_DEREF(hdda).next.z + 1.0e-6f;
3503 }
3504#endif
3505 PNANOVDB_DEREF(hdda).tmin = PNANOVDB_DEREF(hdda).next.z;
3506 PNANOVDB_DEREF(hdda).next.z += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).delta.z;
3507 PNANOVDB_DEREF(hdda).voxel.z += PNANOVDB_DEREF(hdda).dim * PNANOVDB_DEREF(hdda).step.z;
3508 ret = PNANOVDB_DEREF(hdda).tmin <= PNANOVDB_DEREF(hdda).tmax;
3509 }
3510 return ret;
3511}
3512
3513PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_hdda_ray_clip(
3514 PNANOVDB_IN(pnanovdb_vec3_t) bbox_min,
3515 PNANOVDB_IN(pnanovdb_vec3_t) bbox_max,
3516 PNANOVDB_IN(pnanovdb_vec3_t) origin, PNANOVDB_INOUT(float) tmin,
3517 PNANOVDB_IN(pnanovdb_vec3_t) direction, PNANOVDB_INOUT(float) tmax
3518)
3519{
3520 pnanovdb_vec3_t dir_inv = pnanovdb_vec3_div(pnanovdb_vec3_uniform(1.f), PNANOVDB_DEREF(direction));
3521 pnanovdb_vec3_t t0 = pnanovdb_vec3_mul(pnanovdb_vec3_sub(PNANOVDB_DEREF(bbox_min), PNANOVDB_DEREF(origin)), dir_inv);
3522 pnanovdb_vec3_t t1 = pnanovdb_vec3_mul(pnanovdb_vec3_sub(PNANOVDB_DEREF(bbox_max), PNANOVDB_DEREF(origin)), dir_inv);
3523 pnanovdb_vec3_t tmin3 = pnanovdb_vec3_min(t0, t1);
3524 pnanovdb_vec3_t tmax3 = pnanovdb_vec3_max(t0, t1);
3525 float tnear = pnanovdb_max(tmin3.x, pnanovdb_max(tmin3.y, tmin3.z));
3526 float tfar = pnanovdb_min(tmax3.x, pnanovdb_min(tmax3.y, tmax3.z));
3527 pnanovdb_bool_t hit = tnear <= tfar;
3528 PNANOVDB_DEREF(tmin) = pnanovdb_max(PNANOVDB_DEREF(tmin), tnear);
3529 PNANOVDB_DEREF(tmax) = pnanovdb_min(PNANOVDB_DEREF(tmax), tfar);
3530 return hit;
3531}
3532
3533PNANOVDB_FORCE_INLINE pnanovdb_bool_t pnanovdb_hdda_zero_crossing(
3534 pnanovdb_grid_type_t grid_type,
3535 pnanovdb_buf_t buf,
3536 PNANOVDB_INOUT(pnanovdb_readaccessor_t) acc,
3537 PNANOVDB_IN(pnanovdb_vec3_t) origin, float tmin,
3538 PNANOVDB_IN(pnanovdb_vec3_t) direction, float tmax,
3539 PNANOVDB_INOUT(float) thit,
3540 PNANOVDB_INOUT(float) v
3541)
3542{
3543 pnanovdb_coord_t bbox_min = pnanovdb_root_get_bbox_min(buf, PNANOVDB_DEREF(acc).root);
3544 pnanovdb_coord_t bbox_max = pnanovdb_root_get_bbox_max(buf, PNANOVDB_DEREF(acc).root);
3545 pnanovdb_vec3_t bbox_minf = pnanovdb_coord_to_vec3(bbox_min);
3546 pnanovdb_vec3_t bbox_maxf = pnanovdb_coord_to_vec3(pnanovdb_coord_add(bbox_max, pnanovdb_coord_uniform(1)));
3547
3548 pnanovdb_bool_t hit = pnanovdb_hdda_ray_clip(PNANOVDB_REF(bbox_minf), PNANOVDB_REF(bbox_maxf), origin, PNANOVDB_REF(tmin), direction, PNANOVDB_REF(tmax));
3549 if (!hit || tmax > 1.0e20f)
3550 {
3551 return PNANOVDB_FALSE;
3552 }
3553
3554 pnanovdb_vec3_t pos = pnanovdb_hdda_ray_start(origin, tmin, direction);
3555 pnanovdb_coord_t ijk = pnanovdb_hdda_pos_to_ijk(PNANOVDB_REF(pos));
3556
3557 pnanovdb_address_t address = pnanovdb_readaccessor_get_value_address(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk));
3558 float v0 = pnanovdb_read_float(buf, address);
3559
3560 pnanovdb_int32_t dim = pnanovdb_uint32_as_int32(pnanovdb_readaccessor_get_dim(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk)));
3561 pnanovdb_hdda_t hdda;
3562 pnanovdb_hdda_init(PNANOVDB_REF(hdda), origin, tmin, direction, tmax, dim);
3563 while (pnanovdb_hdda_step(PNANOVDB_REF(hdda)))
3564 {
3565 pnanovdb_vec3_t pos_start = pnanovdb_hdda_ray_start(origin, hdda.tmin + 1.0001f, direction);
3566 ijk = pnanovdb_hdda_pos_to_ijk(PNANOVDB_REF(pos_start));
3567 dim = pnanovdb_uint32_as_int32(pnanovdb_readaccessor_get_dim(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk)));
3568 pnanovdb_hdda_update(PNANOVDB_REF(hdda), origin, direction, dim);
3569 if (hdda.dim > 1 || !pnanovdb_readaccessor_is_active(grid_type, buf, acc, PNANOVDB_REF(ijk)))
3570 {
3571 continue;
3572 }
3573 while (pnanovdb_hdda_step(PNANOVDB_REF(hdda)) && pnanovdb_readaccessor_is_active(grid_type, buf, acc, PNANOVDB_REF(hdda.voxel)))
3574 {
3575 ijk = hdda.voxel;
3576 pnanovdb_address_t address = pnanovdb_readaccessor_get_value_address(PNANOVDB_GRID_TYPE_FLOAT, buf, acc, PNANOVDB_REF(ijk));
3577 PNANOVDB_DEREF(v) = pnanovdb_read_float(buf, address);
3578 if (PNANOVDB_DEREF(v) * v0 < 0.f)
3579 {
3580 PNANOVDB_DEREF(thit) = hdda.tmin;
3581 return PNANOVDB_TRUE;
3582 }
3583 }
3584 }
3585 return PNANOVDB_FALSE;
3586}
3587
3588#endif
3589
3590#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:2834
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:2533
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:3210
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:3278
pnanovdb_uint64_dec
PNANOVDB_FORCE_INLINE pnanovdb_uint64_t pnanovdb_uint64_dec(pnanovdb_uint64_t a)
Definition PNanoVDB.h:773
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:2617
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:2499
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:2327
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:2505
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:2988
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:3006
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:2753
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:2370
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:2253
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:2773
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:2511
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:2285
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:2352
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:2382
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:2916
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:2865
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:2875
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:2309
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:3055
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:2200
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:2166
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:2414
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:3115
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:2333
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:2262
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:3109
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_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:2302
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:2294
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:2339
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:2732
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:2747
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:2189
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:2798
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:2462
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:2376
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:2828
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:2439
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:2267
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:2898
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:2722
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_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:2420
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:2631
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:2456
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:2321
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:2481
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:2561
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:2178
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:2779
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:2964
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_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:3029
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:2315
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:2880
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:2938
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:3079
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:2859
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:2575
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:2475
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:2468
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:3091
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:2589
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:2222
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:2970
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:2271
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:2742
PNANOVDB_GRIDBLINDMETADATA_OFF_NAME
#define PNANOVDB_GRIDBLINDMETADATA_OFF_NAME
Definition PNanoVDB.h:1455
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_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:2432
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:2426
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:2211
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:3103
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:3121
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:3067
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:2173
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:2408
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_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:2396
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:2539
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:2345
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:2249
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:2712
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_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:2660
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_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:2487
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:2257
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:2493
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:2402
PNANOVDB_GRID_OFF_GRID_SIZE
#define PNANOVDB_GRID_OFF_GRID_SIZE
Definition PNanoVDB.h:1274
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:2603
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:2804
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:2158
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:2389
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_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_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:2701
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_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:2547
openvdb::v13_0::tools::composite::max
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition Composite.h:110
openvdb::v13_0::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:2692
pnanovdb_readaccessor_t::upper
pnanovdb_upper_handle_t upper
Definition PNanoVDB.h:2696
pnanovdb_readaccessor_t::root
pnanovdb_root_handle_t root
Definition PNanoVDB.h:2697
pnanovdb_readaccessor_t::key
pnanovdb_coord_t key
Definition PNanoVDB.h:2693
pnanovdb_readaccessor_t::lower
pnanovdb_lower_handle_t lower
Definition PNanoVDB.h:2695
pnanovdb_readaccessor_t::leaf
pnanovdb_leaf_handle_t leaf
Definition PNanoVDB.h:2694
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