34 #include <sandbox/linalg/vector.h> 35 #include <sandbox/linalg/bbox.h> 41 struct Indexed_leaf_bvh_tag;
42 struct Compact_bvh_tag;
43 struct Compact_bvh_3d_tag;
53 typedef Indexed_leaf_bvh_tag Tag;
56 const static uint32 kLeaf = (1u << 31u);
57 const static uint32 kInternal = 0x00000000u;
58 const static uint32 kInvalid = uint32(-1);
68 SANDBOX_HOST_DEVICE
Bvh_node(
const Type type,
const uint32 index,
const uint32 skip_node);
72 SANDBOX_HOST_DEVICE
void set_type(
const Type type);
76 SANDBOX_HOST_DEVICE
void set_index(
const uint32 index);
80 SANDBOX_HOST_DEVICE
bool is_leaf()
const {
return (m_packed_data & kLeaf) != 0u; }
83 SANDBOX_HOST_DEVICE uint32 get_index()
const {
return m_packed_data & (~kLeaf); }
86 SANDBOX_HOST_DEVICE uint32 get_leaf_index()
const {
return m_packed_data & (~kLeaf); }
90 SANDBOX_HOST_DEVICE uint32 get_child_count()
const {
return 2u; }
94 SANDBOX_HOST_DEVICE uint32 get_child(
const uint32 i)
const {
return get_index() + i; }
100 static SANDBOX_HOST_DEVICE uint32 packed_data(
const Type type,
const uint32 index)
102 return (uint32(type) | index);
108 static SANDBOX_HOST_DEVICE
void set_type(uint32& packed_data,
const Type type)
110 packed_data &= ~kLeaf;
111 packed_data |= uint32(type);
117 static SANDBOX_HOST_DEVICE
void set_index(uint32& packed_data,
const uint32 index)
119 packed_data &= kLeaf;
120 packed_data |= index;
122 static SANDBOX_HOST_DEVICE
bool is_leaf(
const uint32 packed_data) {
return (packed_data & kLeaf) != 0u; }
123 static SANDBOX_HOST_DEVICE uint32 get_index(
const uint32 packed_data) {
return packed_data & (~kLeaf); }
125 uint32 m_packed_data;
134 typedef Compact_bvh_tag Tag;
136 const static uint32 kLeaf = (1u << 31u);
137 const static uint32 kInternal = 0x00000000u;
138 const static uint32 kInvalid = uint32(-1);
148 SANDBOX_HOST_DEVICE
Bvh_node(
const Type type,
const uint32 index,
const uint32 range_size);
152 SANDBOX_HOST_DEVICE
void set_type(
const Type type);
156 SANDBOX_HOST_DEVICE
void set_index(
const uint32 index);
160 SANDBOX_HOST_DEVICE
void set_range_size(
const uint32 range_size) { m_data = range_size; }
164 SANDBOX_HOST_DEVICE
bool is_leaf()
const {
return (m_packed_data & kLeaf) != 0u; }
167 SANDBOX_HOST_DEVICE uint32 get_index()
const {
return m_packed_data & (~kLeaf); }
170 SANDBOX_HOST_DEVICE uint32 get_leaf_index()
const {
return m_packed_data & (~kLeaf); }
173 SANDBOX_HOST_DEVICE uint32 get_range_size()
const {
return m_data; }
177 SANDBOX_HOST_DEVICE uint32 get_child_count()
const {
return 2u; }
181 SANDBOX_HOST_DEVICE uint32 get_child(
const uint32 i)
const {
return get_index() + i; }
187 static SANDBOX_HOST_DEVICE uint32 packed_data(
const Type type,
const uint32 index)
189 return (uint32(type) | index);
195 static SANDBOX_HOST_DEVICE
void set_type(uint32& packed_data,
const Type type)
197 packed_data &= ~kLeaf;
198 packed_data |= uint32(type);
204 static SANDBOX_HOST_DEVICE
void set_index(uint32& packed_data,
const uint32 index)
206 packed_data &= kLeaf;
207 packed_data |= index;
209 static SANDBOX_HOST_DEVICE
bool is_leaf(
const uint32 packed_data) {
return (packed_data & kLeaf) != 0u; }
210 static SANDBOX_HOST_DEVICE uint32 get_index(
const uint32 packed_data) {
return packed_data & (~kLeaf); }
212 uint32 m_packed_data;
222 typedef Compact_bvh_3d_tag Tag;
234 #include <sandbox/bvh/bvh3d_inline.h> SANDBOX_HOST_DEVICE Bvh_node()
Definition: bvh3d.h:142
SANDBOX_HOST_DEVICE Bvh_node()
Definition: bvh3d.h:62
SANDBOX_HOST_DEVICE bool is_leaf() const
Definition: bvh3d.h:164
SANDBOX_HOST_DEVICE void set_range_size(const uint32 range_size)
Definition: bvh3d.h:160
static SANDBOX_HOST_DEVICE void set_index(uint32 &packed_data, const uint32 index)
Definition: bvh3d.h:204
SANDBOX_HOST_DEVICE bool is_leaf() const
Definition: bvh3d.h:80
static SANDBOX_HOST_DEVICE void set_type(uint32 &packed_data, const Type type)
Definition: bvh3d.h:195
static SANDBOX_HOST_DEVICE void set_index(uint32 &packed_data, const uint32 index)
Definition: bvh3d.h:117
static SANDBOX_HOST_DEVICE void set_type(uint32 &packed_data, const Type type)
Definition: bvh3d.h:108