Browse Source

remove duplicate codes

V2-integral
Zhicheng Wang 5 days ago
parent
commit
e0d2500971
  1. 50
      blobtree_structure/src/baked_blobtree.cpp

50
blobtree_structure/src/baked_blobtree.cpp

@ -89,31 +89,31 @@ baked_blobtree_t::baked_blobtree_t(const blobtree_t& tree) noexcept
assert(this->leaf_indices.front() == 0);
// step 3: sort & remove duplicates of subfaces
{
stl_vector_mp<uint32_t> old_to_new_mapping(this->subfaces.size());
{
stl_vector_mp<uint32_t> subface_indices(this->subfaces.size());
std::iota(subface_indices.begin(), subface_indices.end(), 0);
std::sort(subface_indices.begin(), subface_indices.end(), [this](uint32_t lhs, uint32_t rhs) {
return this->subfaces[lhs].object_ptr < this->subfaces[rhs].object_ptr;
});
for (uint32_t new_index = 0; new_index < subface_indices.size(); ++new_index) {
const auto old_index = subface_indices[new_index];
old_to_new_mapping[old_index] = new_index;
}
}
stl_vector_mp<object_with_index_mapping<subface>> temp_subfaces(this->subfaces.size());
for (size_t i = 0; i < this->subfaces.size(); ++i) {
auto& subface = this->subfaces[i];
auto& new_subface = temp_subfaces[old_to_new_mapping[i]];
new_subface = std::move(subface);
}
std::swap(this->subfaces, temp_subfaces);
for (auto& primitive : this->primitives) {
auto& primitive_mapping = primitive.index_mapping;
for (auto& index : primitive_mapping) { index = old_to_new_mapping[index]; }
}
}
// {
// stl_vector_mp<uint32_t> old_to_new_mapping(this->subfaces.size());
// {
// stl_vector_mp<uint32_t> subface_indices(this->subfaces.size());
// std::iota(subface_indices.begin(), subface_indices.end(), 0);
// std::sort(subface_indices.begin(), subface_indices.end(), [this](uint32_t lhs, uint32_t rhs) {
// return this->subfaces[lhs].object_ptr < this->subfaces[rhs].object_ptr;
// });
// for (uint32_t new_index = 0; new_index < subface_indices.size(); ++new_index) {
// const auto old_index = subface_indices[new_index];
// old_to_new_mapping[old_index] = new_index;
// }
// }
// stl_vector_mp<object_with_index_mapping<subface>> temp_subfaces(this->subfaces.size());
// for (size_t i = 0; i < this->subfaces.size(); ++i) {
// auto& subface = this->subfaces[i];
// auto& new_subface = temp_subfaces[old_to_new_mapping[i]];
// new_subface = std::move(subface);
// }
// std::swap(this->subfaces, temp_subfaces);
// for (auto& primitive : this->primitives) {
// auto& primitive_mapping = primitive.index_mapping;
// for (auto& index : primitive_mapping) { index = old_to_new_mapping[index]; }
// }
// }
// merge subfaces: basically a specialization of std::unique
{
auto current_iter = this->subfaces.begin();

Loading…
Cancel
Save