|
|
@ -21,9 +21,8 @@ void build_tetrahedron_and_adjacency(const scene_bg_mesh_info_t& |
|
|
flat_hash_map<uint32_t, std::vector<uint32_t>>& reverse_vertex_adjacency, |
|
|
flat_hash_map<uint32_t, std::vector<uint32_t>>& reverse_vertex_adjacency, |
|
|
btree_map<uint32_t, std::vector<uint32_t>>& vertex_to_tet_mapping) |
|
|
btree_map<uint32_t, std::vector<uint32_t>>& vertex_to_tet_mapping) |
|
|
{ |
|
|
{ |
|
|
scene_bg_mesh_info_t culled_scene_bg_mesh_info = scene_bg_mesh_info; |
|
|
auto res = scene_bg_mesh_info.grid_resolution - 1; |
|
|
culled_scene_bg_mesh_info.vert_resolution -= Eigen::Vector<uint64_t, 3>::Ones(); |
|
|
tetrahedrons.reserve(res * res * res * 5); |
|
|
tetrahedrons.reserve((culled_scene_bg_mesh_info.vert_resolution.array() - 1).prod() * 5); |
|
|
|
|
|
|
|
|
|
|
|
auto insert_or_compare_vertex_adjacency = [&](uint32_t src, uint32_t dst) { |
|
|
auto insert_or_compare_vertex_adjacency = [&](uint32_t src, uint32_t dst) { |
|
|
reverse_vertex_adjacency[dst].reserve(reverse_vertex_adjacency[dst].size() + 3); |
|
|
reverse_vertex_adjacency[dst].reserve(reverse_vertex_adjacency[dst].size() + 3); |
|
|
@ -32,16 +31,16 @@ void build_tetrahedron_and_adjacency(const scene_bg_mesh_info_t& |
|
|
reverse_vertex_adjacency[dst].emplace_back(src); |
|
|
reverse_vertex_adjacency[dst].emplace_back(src); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
for (size_t i = 0; i < pos_hash_max(culled_scene_bg_mesh_info); i += 2) { |
|
|
for (size_t i = 0; i < scene_bg_mesh_info.grid_count(); i += 2) { |
|
|
auto [x, y, z] = get_grid_pos(i, culled_scene_bg_mesh_info); |
|
|
auto [x, y, z] = scene_bg_mesh_info.invert_hash_grid(i); |
|
|
auto v0 = hash_vert_pos(x, y, z, scene_bg_mesh_info); |
|
|
auto v0 = scene_bg_mesh_info.hash_grid_pos(x, y, z); |
|
|
auto v1 = hash_increment_x(v0, scene_bg_mesh_info); // +yz
|
|
|
auto v1 = scene_bg_mesh_info.hash_grid_pos(x + 1, y, z); |
|
|
auto v2 = hash_increment_y(v1, scene_bg_mesh_info); // +yz+z
|
|
|
auto v2 = scene_bg_mesh_info.hash_grid_pos(x + 1, y + 1, z); |
|
|
auto v3 = hash_increment_y(v0, scene_bg_mesh_info); // +z
|
|
|
auto v3 = scene_bg_mesh_info.hash_grid_pos(x, y + 1, z); |
|
|
auto v4 = hash_increment_z(v0, scene_bg_mesh_info); // +1
|
|
|
auto v4 = scene_bg_mesh_info.hash_grid_pos(x, y, z + 1); |
|
|
auto v5 = hash_increment_x(v4, scene_bg_mesh_info); // +yz+1
|
|
|
auto v5 = scene_bg_mesh_info.hash_grid_pos(x + 1, y, z + 1); |
|
|
auto v6 = hash_increment_y(v5, scene_bg_mesh_info); // +yz+z+1
|
|
|
auto v6 = scene_bg_mesh_info.hash_grid_pos(x + 1, y + 1, z + 1); |
|
|
auto v7 = hash_increment_y(v4, scene_bg_mesh_info); // +z+1
|
|
|
auto v7 = scene_bg_mesh_info.hash_grid_pos(x, y + 1, z + 1); |
|
|
// vertex lexigraphical ordering: v0, v4, v3, v1, v7, v5, v2, v6
|
|
|
// vertex lexigraphical ordering: v0, v4, v3, v1, v7, v5, v2, v6
|
|
|
|
|
|
|
|
|
tetrahedrons.emplace_back(std::array{v4, v3, v1, v6}); |
|
|
tetrahedrons.emplace_back(std::array{v4, v3, v1, v6}); |
|
|
@ -59,16 +58,16 @@ void build_tetrahedron_and_adjacency(const scene_bg_mesh_info_t& |
|
|
insert_or_compare_vertex_adjacency(v7, v4); |
|
|
insert_or_compare_vertex_adjacency(v7, v4); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (size_t i = 1; i < pos_hash_max(culled_scene_bg_mesh_info); i += 2) { |
|
|
for (size_t i = 1; i < scene_bg_mesh_info.grid_count(); i += 2) { |
|
|
auto [x, y, z] = get_grid_pos(i, culled_scene_bg_mesh_info); |
|
|
auto [x, y, z] = scene_bg_mesh_info.invert_hash_grid(i); |
|
|
auto v0 = hash_vert_pos(x, y, z, scene_bg_mesh_info); |
|
|
auto v0 = scene_bg_mesh_info.hash_grid_pos(x, y, z); |
|
|
auto v1 = hash_increment_x(v0, scene_bg_mesh_info); |
|
|
auto v1 = scene_bg_mesh_info.hash_grid_pos(x + 1, y, z); |
|
|
auto v2 = hash_increment_y(v1, scene_bg_mesh_info); |
|
|
auto v2 = scene_bg_mesh_info.hash_grid_pos(x + 1, y + 1, z); |
|
|
auto v3 = hash_increment_y(v0, scene_bg_mesh_info); |
|
|
auto v3 = scene_bg_mesh_info.hash_grid_pos(x, y + 1, z); |
|
|
auto v4 = hash_increment_z(v0, scene_bg_mesh_info); |
|
|
auto v4 = scene_bg_mesh_info.hash_grid_pos(x, y, z + 1); |
|
|
auto v5 = hash_increment_x(v4, scene_bg_mesh_info); |
|
|
auto v5 = scene_bg_mesh_info.hash_grid_pos(x + 1, y, z + 1); |
|
|
auto v6 = hash_increment_y(v5, scene_bg_mesh_info); |
|
|
auto v6 = scene_bg_mesh_info.hash_grid_pos(x + 1, y + 1, z + 1); |
|
|
auto v7 = hash_increment_y(v4, scene_bg_mesh_info); |
|
|
auto v7 = scene_bg_mesh_info.hash_grid_pos(x, y + 1, z + 1); |
|
|
// vertex lexigraphical ordering: v0, v4, v3, v1, v7, v5, v2, v6
|
|
|
// vertex lexigraphical ordering: v0, v4, v3, v1, v7, v5, v2, v6
|
|
|
|
|
|
|
|
|
tetrahedrons.emplace_back(std::array{v0, v7, v5, v2}); |
|
|
tetrahedrons.emplace_back(std::array{v0, v7, v5, v2}); |
|
|
|