From 6fa4270d71c0cdefef18eaa80b9c6db40430c2e6 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Sat, 5 Aug 2023 16:52:51 -0700 Subject: [PATCH] Use image index instead of texture index for source_images (cherry picked from commit f67b6c158ce780641d9174e75441a5ca0ee92444) --- modules/gltf/gltf_document.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 00bf3e58b04..c3c7a4c4b0d 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -3385,10 +3385,11 @@ Ref GLTFDocument::_get_texture(Ref p_state, const GLTFText const GLTFImageIndex image = p_state->textures[p_texture]->get_src_image(); ERR_FAIL_INDEX_V(image, p_state->images.size(), Ref()); if (GLTFState::GLTFHandleBinary(p_state->handle_binary_image) == GLTFState::GLTFHandleBinary::HANDLE_BINARY_EMBED_AS_BASISU) { + ERR_FAIL_INDEX_V(image, p_state->source_images.size(), Ref()); Ref portable_texture; portable_texture.instantiate(); portable_texture->set_keep_compressed_buffer(true); - Ref new_img = p_state->source_images[p_texture]->duplicate(); + Ref new_img = p_state->source_images[image]->duplicate(); ERR_FAIL_COND_V(new_img.is_null(), Ref()); new_img->generate_mipmaps(); if (p_texture_types) {