Skip to content

Commit c3f473c

Browse files
committed
最小地物単位でのテクスチャ結合の高速化
1 parent 2c3d94e commit c3f473c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/texture/texture_packer.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,27 @@ namespace plateau::texture {
8787
for (int index = 0; index < sub_meshes.size(); ) { // TODO continue前やループ末尾の++indexはこのforの(括弧)内に移動できるのでは?
8888

8989
auto& sub_mesh = sub_meshes[index];
90-
const auto& tex_url = sub_mesh.getTexturePath();
90+
const auto& tex_url = std::filesystem::u8path(sub_mesh.getTexturePath()).make_preferred().u8string();
9191
if (tex_url.empty()) {
9292
sub_mesh_list.push_back(sub_mesh);
9393
++index;
9494
continue;
9595
}
9696

97+
// すでにパック済みならばそれを利用
98+
AtlasInfo packed_info = AtlasInfo::empty();
99+
TextureAtlasCanvas* packed_atlas_canvas_ptr = nullptr;
100+
if(isTexturePacked(tex_url, packed_atlas_canvas_ptr, packed_info)) {
101+
if(packed_atlas_canvas_ptr != nullptr) {
102+
SubMesh new_sub_mesh = sub_mesh;
103+
new_sub_mesh.setTexturePath(packed_atlas_canvas_ptr->getSaveFilePath());
104+
updateUVOfSubMesh(mesh, sub_mesh, packed_info);
105+
sub_mesh_list.push_back(new_sub_mesh);
106+
++index;
107+
continue;
108+
}
109+
}
110+
97111

98112
bool texture_load_succeed = false;
99113
auto image = TextureImageBase::tryCreateFromFile(tex_url, canvas_height_, texture_load_succeed);
@@ -112,20 +126,6 @@ namespace plateau::texture {
112126
continue;
113127
}
114128

115-
// すでにパック済みならばそれを利用
116-
AtlasInfo packed_info = AtlasInfo::empty();
117-
TextureAtlasCanvas* packed_atlas_canvas_ptr = nullptr;
118-
if(isTexturePacked(tex_url, packed_atlas_canvas_ptr, packed_info)) {
119-
if(packed_atlas_canvas_ptr != nullptr) {
120-
SubMesh new_sub_mesh = sub_mesh;
121-
new_sub_mesh.setTexturePath(packed_atlas_canvas_ptr->getSaveFilePath());
122-
updateUVOfSubMesh(mesh, sub_mesh, packed_info);
123-
sub_mesh_list.push_back(new_sub_mesh);
124-
++index;
125-
continue;
126-
}
127-
}
128-
129129
// canvasのどれかにパックできるか確認
130130
int target_canvas_id = -1;
131131
AtlasInfo info = AtlasInfo::empty();

0 commit comments

Comments
 (0)