Skip to content

Commit cce10e0

Browse files
committed
Merge pull request #109181 from nikitalita/gltf-dedupe-images
Dedupe images during GLTF Export
2 parents b33c3de + 7fcc7e1 commit cce10e0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

modules/gltf/gltf_document.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,9 +4339,12 @@ GLTFTextureIndex GLTFDocument::_set_texture(Ref<GLTFState> p_state, Ref<Texture2
43394339
Ref<GLTFTexture> gltf_texture;
43404340
gltf_texture.instantiate();
43414341
ERR_FAIL_COND_V(p_texture->get_image().is_null(), -1);
4342-
GLTFImageIndex gltf_src_image_i = p_state->images.size();
4343-
p_state->images.push_back(p_texture);
4344-
p_state->source_images.push_back(p_texture->get_image());
4342+
GLTFImageIndex gltf_src_image_i = p_state->images.find(p_texture);
4343+
if (gltf_src_image_i == -1) {
4344+
gltf_src_image_i = p_state->images.size();
4345+
p_state->images.push_back(p_texture);
4346+
p_state->source_images.push_back(p_texture->get_image());
4347+
}
43454348
gltf_texture->set_src_image(gltf_src_image_i);
43464349
gltf_texture->set_sampler(_set_sampler_for_mode(p_state, p_filter_mode, p_repeats));
43474350
GLTFTextureIndex gltf_texture_i = p_state->textures.size();

0 commit comments

Comments
 (0)