summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-18 16:35:32 +0100
committerGitHub <noreply@github.com>2022-01-18 16:35:32 +0100
commit45cb12955f823557a28f42d84d5142ee34934319 (patch)
tree6c1d8d8f67a347cbb317e7bacc2d5dcd126512b8 /scene/resources
parent01eefa2c508f45dc772a0f10cf4ad6d9b1f82645 (diff)
parentb6cfc55113609155ecbd5ada410c184776abadee (diff)
Merge pull request #56622 from Pineapple/scenestate-optimizations
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/packed_scene.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 402e67a0f1..f9a4eba978 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -175,14 +175,12 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
#endif
}
} else {
- Object *obj = nullptr;
+ //node belongs to this scene and must be created
+ Object *obj = ClassDB::instantiate(snames[n.type]);
- if (ClassDB::is_class_enabled(snames[n.type])) {
- //node belongs to this scene and must be created
- obj = ClassDB::instantiate(snames[n.type]);
- }
+ node = Object::cast_to<Node>(obj);
- if (!Object::cast_to<Node>(obj)) {
+ if (!node) {
if (obj) {
memdelete(obj);
obj = nullptr;
@@ -203,9 +201,9 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
if (!obj) {
obj = memnew(Node);
}
- }
- node = Object::cast_to<Node>(obj);
+ node = Object::cast_to<Node>(obj);
+ }
}
if (node) {