mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Merge pull request #97979 from BlueCube3310/fix-thumb-gen
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
🔗 GHA / 🪲 Godot CPP (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
🔗 GHA / 🪲 Godot CPP (push) Has been cancelled
Fix crash when creating thumbnails for 3d textures
This commit is contained in:
commit
92e51fca72
@ -112,9 +112,13 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const Ref<Resource> &p_from,
|
||||
return Ref<Texture2D>();
|
||||
}
|
||||
|
||||
const int mid_depth = (tex_3d->get_depth() - 1) / 2;
|
||||
|
||||
Vector<Ref<Image>> data = tex_3d->get_data();
|
||||
if (data.size() != tex_3d->get_depth()) {
|
||||
return Ref<Texture2D>();
|
||||
}
|
||||
|
||||
// Use the middle slice for the thumbnail.
|
||||
const int mid_depth = (tex_3d->get_depth() - 1) / 2;
|
||||
if (!data.is_empty() && data[mid_depth].is_valid()) {
|
||||
img = data[mid_depth]->duplicate();
|
||||
}
|
||||
@ -124,6 +128,7 @@ Ref<Texture2D> EditorTexturePreviewPlugin::generate(const Ref<Resource> &p_from,
|
||||
return Ref<Texture2D>();
|
||||
}
|
||||
|
||||
// Use the middle slice for the thumbnail.
|
||||
const int mid_layer = (tex_lyr->get_layers() - 1) / 2;
|
||||
|
||||
Ref<Image> data = tex_lyr->get_layer_data(mid_layer);
|
||||
|
Loading…
Reference in New Issue
Block a user