summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-06 22:52:49 +0200
committerGitHub <noreply@github.com>2020-07-06 22:52:49 +0200
commitb00e8ffb22256c7815a577c30f5294ca4dbdaf42 (patch)
tree527184d675b99fb912db933a77396248d8dd4625 /editor
parentb5a73c9e5c9ddb45b14424fb787fea67f695a85b (diff)
parent6c8a9b7690c77bb3822ed90657267541a532568b (diff)
Merge pull request #40163 from pycbouh/fix-saving-empty-scene
Improve scene preview generation for empty scenes and disabled features
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 74c516caeb..454170647f 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1225,20 +1225,25 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
_find_node_types(editor_data.get_edited_scene_root(), c2d, c3d);
- bool is2d;
- if (c3d < c2d) {
- is2d = true;
- } else {
- is2d = false;
- }
save.step(TTR("Creating Thumbnail"), 1);
//current view?
Ref<Image> img;
- if (is2d) {
+ // If neither 3D or 2D nodes are present, make a 1x1 black texture.
+ // We cannot fallback on the 2D editor, because it may not have been used yet,
+ // which would result in an invalid texture.
+ if (c3d == 0 && c2d == 0) {
+ img.instance();
+ img->create(1, 1, 0, Image::FORMAT_RGB8);
+ } else if (c3d < c2d) {
img = scene_root->get_texture()->get_data();
} else {
- img = Node3DEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data();
+ // The 3D editor may be disabled as a feature, but scenes can still be opened.
+ // This check prevents the preview from regenerating in case those scenes are then saved.
+ Ref<EditorFeatureProfile> profile = feature_profile_manager->get_current_profile();
+ if (!profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D)) {
+ img = Node3DEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data();
+ }
}
if (img.is_valid()) {