mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #102559 from stuartcarnie/sgc/fix_previews
Editor: Fix AtlasTexture editor previews for compressed textures
This commit is contained in:
commit
794b9395a8
2 changed files with 21 additions and 1 deletions
|
@ -100,6 +100,13 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const Ref<Resource> &p_from,
|
||||||
return Ref<Texture2D>();
|
return Ref<Texture2D>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (atlas->is_compressed()) {
|
||||||
|
atlas = atlas->duplicate();
|
||||||
|
if (atlas->decompress() != OK) {
|
||||||
|
return Ref<Texture2D>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!tex_atlas->get_region().has_area()) {
|
if (!tex_atlas->get_region().has_area()) {
|
||||||
return Ref<Texture2D>();
|
return Ref<Texture2D>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,8 +132,21 @@ static Image::Format get_texture_2d_format(const Ref<Texture2D> &p_texture) {
|
||||||
|
|
||||||
static int get_texture_mipmaps_count(const Ref<Texture2D> &p_texture) {
|
static int get_texture_mipmaps_count(const Ref<Texture2D> &p_texture) {
|
||||||
ERR_FAIL_COND_V(p_texture.is_null(), -1);
|
ERR_FAIL_COND_V(p_texture.is_null(), -1);
|
||||||
|
|
||||||
// We are having to download the image only to get its mipmaps count. It would be nice if we didn't have to.
|
// We are having to download the image only to get its mipmaps count. It would be nice if we didn't have to.
|
||||||
Ref<Image> image = p_texture->get_image();
|
Ref<Image> image;
|
||||||
|
Ref<AtlasTexture> at = p_texture;
|
||||||
|
if (at.is_valid()) {
|
||||||
|
// The AtlasTexture tries to obtain the region from the atlas as an image,
|
||||||
|
// which will fail if it is a compressed format.
|
||||||
|
Ref<Texture2D> atlas = at->get_atlas();
|
||||||
|
if (atlas.is_valid()) {
|
||||||
|
image = atlas->get_image();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
image = p_texture->get_image();
|
||||||
|
}
|
||||||
|
|
||||||
if (image.is_valid()) {
|
if (image.is_valid()) {
|
||||||
return image->get_mipmap_count();
|
return image->get_mipmap_count();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue