Merge pull request #86950 from jsjtxietian/fix-compress-image-error

Fix wrong fail condition in compressed texture's `_set_data`
This commit is contained in:
Rémi Verschelde 2024-01-08 14:53:43 +01:00
commit 84e205b5a1
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 3 additions and 3 deletions

View File

@ -75,7 +75,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) {
uint32_t mipsize = decode_uint32(data); uint32_t mipsize = decode_uint32(data);
data += 4; data += 4;
data_size -= 4; data_size -= 4;
ERR_FAIL_COND(mipsize < data_size); ERR_FAIL_COND(mipsize > data_size);
Ref<Image> img = loader_func == nullptr Ref<Image> img = loader_func == nullptr
? memnew(Image(data, data_size)) ? memnew(Image(data, data_size))
: Ref<Image>(loader_func(data, data_size)); : Ref<Image>(loader_func(data, data_size));
@ -89,7 +89,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) {
data_size -= mipsize; data_size -= mipsize;
} }
image = Ref<Image>(memnew(Image(size.width, size.height, mipmap_count > 1, format, image_data))); image = Ref<Image>(memnew(Image(size.width, size.height, mipmaps, format, image_data)));
} break; } break;
case COMPRESSION_MODE_BASIS_UNIVERSAL: { case COMPRESSION_MODE_BASIS_UNIVERSAL: {
@ -100,7 +100,7 @@ void PortableCompressedTexture2D::_set_data(const Vector<uint8_t> &p_data) {
case COMPRESSION_MODE_S3TC: case COMPRESSION_MODE_S3TC:
case COMPRESSION_MODE_ETC2: case COMPRESSION_MODE_ETC2:
case COMPRESSION_MODE_BPTC: { case COMPRESSION_MODE_BPTC: {
image = Ref<Image>(memnew(Image(size.width, size.height, mipmap_count > 1, format, p_data.slice(20)))); image = Ref<Image>(memnew(Image(size.width, size.height, mipmaps, format, p_data.slice(20))));
} break; } break;
} }
ERR_FAIL_COND(image.is_null()); ERR_FAIL_COND(image.is_null());