From 8d069c3f5ca014f779ef3a45a850d6dbdfa0afb3 Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Mon, 8 Jan 2024 12:53:18 +0800 Subject: [PATCH] Fix wrong fail contion in compressed texture and some clean up (cherry picked from commit 6a3b63eb3616aa71ac9e1866ff6f502b37af8779) --- scene/resources/portable_compressed_texture.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scene/resources/portable_compressed_texture.cpp b/scene/resources/portable_compressed_texture.cpp index a61799c7d64..ace1eb8d81e 100644 --- a/scene/resources/portable_compressed_texture.cpp +++ b/scene/resources/portable_compressed_texture.cpp @@ -63,7 +63,7 @@ void PortableCompressedTexture2D::_set_data(const Vector &p_data) { uint32_t mipsize = decode_uint32(data); data += 4; data_size -= 4; - ERR_FAIL_COND(mipsize < data_size); + ERR_FAIL_COND(mipsize > data_size); Ref img = memnew(Image(data, data_size)); ERR_FAIL_COND(img->is_empty()); if (img->get_format() != format) { // May happen due to webp/png in the tiny mipmaps. @@ -75,7 +75,7 @@ void PortableCompressedTexture2D::_set_data(const Vector &p_data) { data_size -= mipsize; } - image = Ref(memnew(Image(size.width, size.height, mipmap_count > 1, format, image_data))); + image = Ref(memnew(Image(size.width, size.height, mipmaps, format, image_data))); } break; case COMPRESSION_MODE_BASIS_UNIVERSAL: { @@ -86,7 +86,7 @@ void PortableCompressedTexture2D::_set_data(const Vector &p_data) { case COMPRESSION_MODE_S3TC: case COMPRESSION_MODE_ETC2: case COMPRESSION_MODE_BPTC: { - image = Ref(memnew(Image(size.width, size.height, mipmap_count > 1, format, p_data.slice(20)))); + image = Ref(memnew(Image(size.width, size.height, mipmaps, format, p_data.slice(20)))); } break; } ERR_FAIL_COND(image.is_null());