summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/import/resource_importer_scene.cpp51
-rw-r--r--editor/import/resource_importer_scene.h1
2 files changed, 15 insertions, 37 deletions
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 4eba609c0d..c6ef9b61d7 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -376,15 +376,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
memdelete(p_node);
p_node = col;
- int idx = 0;
- for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape3D *cshape = memnew(CollisionShape3D);
- cshape->set_shape(E->get());
- col->add_child(cshape);
-
- cshape->set_owner(col->get_owner());
- idx++;
- }
+ _add_shapes(col, shapes);
}
}
@@ -443,15 +435,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
rigid_body->add_child(mi);
mi->set_owner(rigid_body->get_owner());
- int idx = 0;
- for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape3D *cshape = memnew(CollisionShape3D);
- cshape->set_shape(E->get());
- rigid_body->add_child(cshape);
-
- cshape->set_owner(p_node->get_owner());
- idx++;
- }
+ _add_shapes(rigid_body, shapes);
}
} else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<EditorSceneImporterMeshNode3D>(p_node)) {
@@ -489,16 +473,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
mi->add_child(col);
col->set_owner(mi->get_owner());
- int idx = 0;
- for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape3D *cshape = memnew(CollisionShape3D);
- cshape->set_shape(E->get());
- col->add_child(cshape);
-
- cshape->set_owner(p_node->get_owner());
-
- idx++;
- }
+ _add_shapes(col, shapes);
}
}
@@ -546,15 +521,7 @@ Node *ResourceImporterScene::_pre_fix_node(Node *p_node, Node *p_root, Map<Ref<E
p_node->add_child(col);
col->set_owner(p_node->get_owner());
- int idx = 0;
- for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
- CollisionShape3D *cshape = memnew(CollisionShape3D);
- cshape->set_shape(E->get());
- col->add_child(cshape);
-
- cshape->set_owner(p_node->get_owner());
- idx++;
- }
+ _add_shapes(col, shapes);
}
}
}
@@ -1300,6 +1267,16 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
}
}
+void ResourceImporterScene::_add_shapes(Node *p_node, const List<Ref<Shape3D>> &p_shapes) {
+ for (const List<Ref<Shape3D>>::Element *E = p_shapes.front(); E; E = E->next()) {
+ CollisionShape3D *cshape = memnew(CollisionShape3D);
+ cshape->set_shape(E->get());
+ p_node->add_child(cshape);
+
+ cshape->set_owner(p_node->get_owner());
+ }
+}
+
Node *ResourceImporterScene::pre_import(const String &p_source_file) {
Ref<EditorSceneImporter> importer;
String ext = p_source_file.get_extension().to_lower();
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 36573779f2..6c6af57c4c 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -120,6 +120,7 @@ class ResourceImporterScene : public ResourceImporter {
void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner);
void _generate_meshes(Node *p_node, const Dictionary &p_mesh_data, bool p_generate_lods, bool p_create_shadow_meshes, LightBakeMode p_light_bake_mode, float p_lightmap_texel_size, const Vector<uint8_t> &p_src_lightmap_cache, Vector<uint8_t> &r_dst_lightmap_cache);
+ void _add_shapes(Node *p_node, const List<Ref<Shape3D>> &p_shapes);
public:
static ResourceImporterScene *get_singleton() { return singleton; }