18 using Vector3u = Eigen::Vector3<uint32_t>;
52 MUDA_GENERIC
bool is_phantom()
const {
return ctlbit.home != ctlbit.pass; }
54 MUDA_GENERIC
bool is_home()
const {
return ctlbit.home == ctlbit.pass; }
56 MUDA_GENERIC
void set_as_phantom(
const Vector3u& home_ijk,
const Vector3u& cell_ijk)
58 ctlbit.pass = pass_type(cell_ijk);
59 ctlbit.home = pass_type(home_ijk);
62 MUDA_GENERIC
void set_as_home(
const Vector3u& ijk)
66 ctlbit.home = pass_type(ijk);
67 ctlbit.pass = ctlbit.home;
68 ctlbit.overlap |= (1 << ctlbit.home);
71 MUDA_GENERIC
void set_overlap(
const Vector3u& ijk)
73 ctlbit.overlap |= (1 << pass_type(ijk));
76 MUDA_GENERIC
static U32 pass_type(
const Vector3u& ijk)
78 return (((U32)ijk(0) % 2) << 2) | (((U32)ijk(1) % 2) << 1)
79 | (((U32)ijk(2) % 2) << 0);
85 if(l.is_phantom() && r.is_phantom())
92 U32 pass = l.ctlbit.pass;
93 U32 common_overlap = l.ctlbit.overlap & r.ctlbit.overlap;
95 for(U32 i = 0; i < 2; ++i)
97 U32 encode_home = (1 << arr[i]->ctlbit.home);
98 if(arr[i]->ctlbit.home < pass && (common_overlap & encode_home))
111 using Vector3 = Eigen::Vector<Float, 3>;
112 using Vector3i = Eigen::Vector<int, 3>;
113 using Vector3u = Eigen::Vector<uint32_t, 3>;
114 using U32 = uint32_t;
117 Float cell_size = 0.0f;
118 Vector3 coord_min = Vector3::Zero();
123 : cell_size(cell_size)
124 , coord_min(coord_min)
128 MUDA_GENERIC U32 hash_cell(
const Vector3& xyz)
const
130 return hash_cell(cell(xyz));
133 MUDA_GENERIC U32 hash_cell(
const Vector3u& ijk)
const
135 return Hash()(ijk) % 0x40000000;
138 MUDA_GENERIC Vector3u cell(
const Vector3& xyz)
const
142 for(
int i = 0; i < 3; ++i)
143 ret(i) = (xyz(i) - coord_min(i)) / cell_size;
146 MUDA_GENERIC Vector3 coord(
const Vector3u& ijk)
const
150 for(
int i = 0; i < 3; ++i)
151 ret(i) = ijk(i) * cell_size + coord_min(i);
155 MUDA_GENERIC Vector3 cell_center_coord(
const Vector3u& ijk)
const
159 for(
int i = 0; i < 3; ++i)
160 ret(i) = (ijk(i) + 0.5f) * cell_size + coord_min(i);
172 using U32 = uint32_t;
174 using Vector3u = Eigen::Vector3<U32>;
175 using Vector3i = Eigen::Vector3<I32>;
176 using Vector3 = Eigen::Vector3f;
199 size_t pairListOffset = 0;
208 bool empty_level =
false;
216 template <
typename Pred>
231 void calculate_hash_table_basic_info();
233 void setup_hash_table();
235 void fill_hash_cells();
237 void count_object_per_cell();
239 template <
typename Pred>
242 template <
typename Pred>
243 void simple_count_collision_pairs(Pred&& pred);
246 int totalCollisionPairCount);
248 template <
typename Pred>
252 template <
typename Pred>
253 void balanced_setup_collision_pairs(
bool append,