Skip to content

Commit

Permalink
分割結合でメッシュのindicesが3の倍数でなくなることがあるバグを修正 (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
linoal authored Dec 2, 2024
1 parent 55958cb commit 221e9a5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/granularity_convert/filter_by_city_obj_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,26 @@ namespace plateau::granularityConvert {
auto indices_id_transform = std::vector<long>();
dst_indices.reserve(src_indices.size());
indices_id_transform.reserve(src_indices.size());
for (auto src_index: src_indices) {
const auto next_id = vert_id_transform.at(src_index); // 削除頂点を詰めたあとの新たな頂点番号
if (next_id < 0) {
indices_id_transform.push_back(-1);

auto src_triangle_count = src_indices.size() / 3;
for(int tri=0; tri<src_triangle_count; tri++) {
unsigned int src_index[3] = {src_indices.at(tri*3), src_indices.at(tri*3+1), src_indices.at(tri*3+2)};
long next_id[3];
for(int i=0; i<3; i++){
next_id[i] = vert_id_transform.at(src_index[i]);
}
if(next_id[0] < 0 || next_id[1] < 0 || next_id[2] < 0) {
for(int i=0; i<3; i++) indices_id_transform.push_back(-1);
continue;
}
dst_indices.push_back(next_id);
indices_id_transform.push_back((long) dst_indices.size() - 1);
for(int i=0; i<3; i++) {
dst_indices.push_back((unsigned) next_id[i]);
indices_id_transform.push_back((long) dst_indices.size() - 1);
}
}



// SubMeshについて、元から削除部分を除いたvector<SubMesh>を生成します。
auto dst_sub_meshes = std::vector<SubMesh>();
for (const auto& src_sub_mesh: src_sub_meshes) {
Expand Down

0 comments on commit 221e9a5

Please sign in to comment.