diff options
Diffstat (limited to 'editor/import')
-rw-r--r-- | editor/import/editor_import_collada.cpp | 78 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 50 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.h | 24 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.cpp | 8 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 130 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.h | 4 |
6 files changed, 147 insertions, 147 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index f7da8c27f9..e67dd37b88 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -33,12 +33,12 @@ #include "core/os/os.h" #include "editor/editor_node.h" #include "editor/import/collada.h" -#include "scene/3d/camera.h" -#include "scene/3d/light.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/path.h" -#include "scene/3d/skeleton.h" -#include "scene/3d/spatial.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/light_3d.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/node_3d.h" +#include "scene/3d/path_3d.h" +#include "scene/3d/skeleton_3d.h" #include "scene/animation/animation_player.h" #include "scene/resources/animation.h" #include "scene/resources/packed_scene.h" @@ -47,13 +47,13 @@ struct ColladaImport { Collada collada; - Spatial *scene; + Node3D *scene; Vector<Ref<Animation>> animations; struct NodeMap { //String path; - Spatial *node; + Node3D *node; int bone; List<int> anim_tracks; @@ -76,17 +76,17 @@ struct ColladaImport { Map<String, Ref<ArrayMesh>> mesh_cache; Map<String, Ref<Curve3D>> curve_cache; Map<String, Ref<Material>> material_cache; - Map<Collada::Node *, Skeleton *> skeleton_map; + Map<Collada::Node *, Skeleton3D *> skeleton_map; - Map<Skeleton *, Map<String, int>> skeleton_bone_map; + Map<Skeleton3D *, Map<String, int>> skeleton_bone_map; Set<String> valid_animated_nodes; Vector<int> valid_animated_properties; Map<String, bool> bones_with_animation; - Error _populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent); + Error _populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent); Error _create_scene_skeletons(Collada::Node *p_node); - Error _create_scene(Collada::Node *p_node, Spatial *p_parent); + Error _create_scene(Collada::Node *p_node, Node3D *p_parent); Error _create_resources(Collada::Node *p_node, bool p_use_compression); Error _create_material(const String &p_target); Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes = Vector<Ref<ArrayMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false); @@ -110,7 +110,7 @@ struct ColladaImport { } }; -Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) { +Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) { if (p_node->type != Collada::Node::TYPE_JOINT) return OK; @@ -174,7 +174,7 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { if (p_node->type == Collada::Node::TYPE_SKELETON) { - Skeleton *sk = memnew(Skeleton); + Skeleton3D *sk = memnew(Skeleton3D); int bone = 0; for (int i = 0; i < p_node->children.size(); i++) { @@ -193,15 +193,15 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { return OK; } -Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { +Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) { - Spatial *node = NULL; + Node3D *node = NULL; switch (p_node->type) { case Collada::Node::TYPE_NODE: { - node = memnew(Spatial); + node = memnew(Node3D); } break; case Collada::Node::TYPE_JOINT: { @@ -223,7 +223,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { if (!bool(GLOBAL_DEF("collada/use_ambient", false))) return OK; //well, it's an ambient light.. - Light *l = memnew(DirectionalLight); + Light3D *l = memnew(DirectionalLight3D); //l->set_color(Light::COLOR_AMBIENT,ld.color); //l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0)); //l->set_color(Light::COLOR_SPECULAR,Color(0,0,0)); @@ -232,7 +232,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { } else if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) { //well, it's an ambient light.. - Light *l = memnew(DirectionalLight); + Light3D *l = memnew(DirectionalLight3D); /* if (found_ambient) //use it here l->set_color(Light::COLOR_AMBIENT,ambient); @@ -243,12 +243,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { node = l; } else { - Light *l; + Light3D *l; if (ld.mode == Collada::LightData::MODE_OMNI) - l = memnew(OmniLight); + l = memnew(OmniLight3D); else { - l = memnew(SpotLight); + l = memnew(SpotLight3D); //l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle); //l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp); } @@ -262,13 +262,13 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { } else { - node = memnew(Spatial); + node = memnew(Node3D); } } break; case Collada::Node::TYPE_CAMERA: { Collada::NodeCamera *cam = static_cast<Collada::NodeCamera *>(p_node); - Camera *camera = memnew(Camera); + Camera3D *camera = memnew(Camera3D); if (collada.state.camera_data_map.has(cam->camera)) { @@ -280,12 +280,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { if (cd.orthogonal.y_mag) { - camera->set_keep_aspect_mode(Camera::KEEP_HEIGHT); + camera->set_keep_aspect_mode(Camera3D::KEEP_HEIGHT); camera->set_orthogonal(cd.orthogonal.y_mag * 2.0, cd.z_near, cd.z_far); } else if (!cd.orthogonal.y_mag && cd.orthogonal.x_mag) { - camera->set_keep_aspect_mode(Camera::KEEP_WIDTH); + camera->set_keep_aspect_mode(Camera3D::KEEP_WIDTH); camera->set_orthogonal(cd.orthogonal.x_mag * 2.0, cd.z_near, cd.z_far); } @@ -314,17 +314,17 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { if (collada.state.curve_data_map.has(ng->source)) { - node = memnew(Path); + node = memnew(Path3D); } else { //mesh since nothing else - node = memnew(MeshInstance); + node = memnew(MeshInstance3D); //Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); } } break; case Collada::Node::TYPE_SKELETON: { ERR_FAIL_COND_V(!skeleton_map.has(p_node), ERR_CANT_CREATE); - Skeleton *sk = skeleton_map[p_node]; + Skeleton3D *sk = skeleton_map[p_node]; node = sk; } break; } @@ -1010,12 +1010,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) { - Spatial *node = node_map[p_node->id].node; + Node3D *node = node_map[p_node->id].node; Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node); - if (Object::cast_to<Path>(node)) { + if (Object::cast_to<Path3D>(node)) { - Path *path = Object::cast_to<Path>(node); + Path3D *path = Object::cast_to<Path3D>(node); if (curve_cache.has(ng->source)) { @@ -1083,11 +1083,11 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres } } - if (Object::cast_to<MeshInstance>(node)) { + if (Object::cast_to<MeshInstance3D>(node)) { Collada::NodeGeometry *ng2 = static_cast<Collada::NodeGeometry *>(p_node); - MeshInstance *mi = Object::cast_to<MeshInstance>(node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node); ERR_FAIL_COND_V(!mi, ERR_BUG); @@ -1114,7 +1114,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres String skname = skeletons[0]; ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA); NodeMap nmsk = node_map[skname]; - Skeleton *sk = Object::cast_to<Skeleton>(nmsk.node); + Skeleton3D *sk = Object::cast_to<Skeleton3D>(nmsk.node); ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA); ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA); Map<String, int> &bone_remap_map = skeleton_bone_map[sk]; @@ -1265,7 +1265,7 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t ERR_FAIL_COND_V(!collada.state.visual_scene_map.has(collada.state.root_visual_scene), ERR_INVALID_DATA); Collada::VisualScene &vs = collada.state.visual_scene_map[collada.state.root_visual_scene]; - scene = memnew(Spatial); // root + scene = memnew(Node3D); // root //determine what's going on with the lights for (int i = 0; i < vs.root_nodes.size(); i++) { @@ -1530,7 +1530,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones String path = scene->get_path_to(nm.node); if (nm.bone >= 0) { - Skeleton *sk = static_cast<Skeleton *>(nm.node); + Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node); String name = sk->get_bone_name(nm.bone); path = path + ":" + name; } @@ -1621,7 +1621,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones if (nm.bone >= 0) { //make bone transform relative to rest (in case of skeleton) - Skeleton *sk = Object::cast_to<Skeleton>(nm.node); + Skeleton3D *sk = Object::cast_to<Skeleton3D>(nm.node); if (sk) { xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform; @@ -1662,7 +1662,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones NodeMap &nm = node_map[E->key()]; String path = scene->get_path_to(nm.node); ERR_CONTINUE(nm.bone < 0); - Skeleton *sk = static_cast<Skeleton *>(nm.node); + Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node); String name = sk->get_bone_name(nm.bone); path = path + ":" + name; diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 398fc9ff49..208dc8fc26 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -37,9 +37,9 @@ #include "core/os/file_access.h" #include "core/os/os.h" #include "modules/regex/regex.h" -#include "scene/3d/bone_attachment.h" -#include "scene/3d/camera.h" -#include "scene/3d/mesh_instance.h" +#include "scene/3d/bone_attachment_3d.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/mesh_instance_3d.h" #include "scene/animation/animation_player.h" #include "scene/resources/surface_tool.h" @@ -2108,7 +2108,7 @@ Error EditorSceneImporterGLTF::_create_skeletons(GLTFState &state) { GLTFSkeleton &gltf_skeleton = state.skeletons.write[skel_i]; - Skeleton *skeleton = memnew(Skeleton); + Skeleton3D *skeleton = memnew(Skeleton3D); gltf_skeleton.godot_skeleton = skeleton; // Make a unique name, no gltf node represents this skeleton @@ -2485,12 +2485,12 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) { } } -BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index) { +BoneAttachment3D *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; const GLTFNode *bone_node = state.nodes[gltf_node->parent]; - BoneAttachment *bone_attachment = memnew(BoneAttachment); + BoneAttachment3D *bone_attachment = memnew(BoneAttachment3D); print_verbose("glTF: Creating bone attachment for: " + gltf_node->name); ERR_FAIL_COND_V(!bone_node->joint, nullptr); @@ -2500,12 +2500,12 @@ BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &st return bone_attachment; } -MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { +MeshInstance3D *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; ERR_FAIL_INDEX_V(gltf_node->mesh, state.meshes.size(), nullptr); - MeshInstance *mi = memnew(MeshInstance); + MeshInstance3D *mi = memnew(MeshInstance3D); print_verbose("glTF: Creating mesh for: " + gltf_node->name); GLTFMesh &mesh = state.meshes.write[gltf_node->mesh]; @@ -2522,12 +2522,12 @@ MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, return mi; } -Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { +Camera3D *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; ERR_FAIL_INDEX_V(gltf_node->camera, state.cameras.size(), nullptr); - Camera *camera = memnew(Camera); + Camera3D *camera = memnew(Camera3D); print_verbose("glTF: Creating camera for: " + gltf_node->name); const GLTFCamera &c = state.cameras[gltf_node->camera]; @@ -2540,26 +2540,26 @@ Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_ return camera; } -Spatial *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { +Node3D *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; - Spatial *spatial = memnew(Spatial); + Node3D *spatial = memnew(Node3D); print_verbose("glTF: Creating spatial for: " + gltf_node->name); return spatial; } -void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index) { +void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index) { const GLTFNode *gltf_node = state.nodes[node_index]; - Spatial *current_node = nullptr; + Node3D *current_node = nullptr; // Is our parent a skeleton - Skeleton *active_skeleton = Object::cast_to<Skeleton>(scene_parent); + Skeleton3D *active_skeleton = Object::cast_to<Skeleton3D>(scene_parent); if (gltf_node->skeleton >= 0) { - Skeleton *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton; + Skeleton3D *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton; if (active_skeleton != skeleton) { ERR_FAIL_COND_MSG(active_skeleton != nullptr, "glTF: Generating scene detected direct parented Skeletons"); @@ -2577,7 +2577,7 @@ void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene // If we have an active skeleton, and the node is node skinned, we need to create a bone attachment if (current_node == nullptr && active_skeleton != nullptr && gltf_node->skin < 0) { - BoneAttachment *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index); + BoneAttachment3D *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index); scene_parent->add_child(bone_attachment); bone_attachment->set_owner(scene_root); @@ -2776,7 +2776,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye const GLTFNode *node = state.nodes[E->key()]; if (node->skeleton >= 0) { - const Skeleton *sk = Object::cast_to<Skeleton>(state.scene_nodes.find(node_index)->get()); + const Skeleton3D *sk = Object::cast_to<Skeleton3D>(state.scene_nodes.find(node_index)->get()); ERR_FAIL_COND(sk == nullptr); const String path = ap->get_parent()->get_path_to(sk); @@ -2853,7 +2853,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye xform.basis.set_quat_scale(rot, scale); xform.origin = pos; - const Skeleton *skeleton = state.skeletons[node->skeleton].godot_skeleton; + const Skeleton3D *skeleton = state.skeletons[node->skeleton].godot_skeleton; const int bone_idx = skeleton->find_bone(node->name); xform = skeleton->get_bone_rest(bone_idx).affine_inverse() * xform; @@ -2922,7 +2922,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye ap->add_animation(name, animation); } -void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial *scene_root) { +void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Node3D *scene_root) { for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) { const GLTFNode *node = state.nodes[node_i]; @@ -2930,12 +2930,12 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial const GLTFSkinIndex skin_i = node->skin; Map<GLTFNodeIndex, Node *>::Element *mi_element = state.scene_nodes.find(node_i); - MeshInstance *mi = Object::cast_to<MeshInstance>(mi_element->get()); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(mi_element->get()); ERR_FAIL_COND(mi == nullptr); const GLTFSkeletonIndex skel_i = state.skins[node->skin].skeleton; const GLTFSkeleton &gltf_skeleton = state.skeletons[skel_i]; - Skeleton *skeleton = gltf_skeleton.godot_skeleton; + Skeleton3D *skeleton = gltf_skeleton.godot_skeleton; ERR_FAIL_COND(skeleton == nullptr); mi->get_parent()->remove_child(mi); @@ -2949,9 +2949,9 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial } } -Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) { +Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) { - Spatial *root = memnew(Spatial); + Node3D *root = memnew(Node3D); // scene_name is already unique root->set_name(state.scene_name); @@ -3084,7 +3084,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla _assign_scene_names(state); /* STEP 17 MAKE SCENE! */ - Spatial *scene = _generate_scene(state, p_bake_fps); + Node3D *scene = _generate_scene(state, p_bake_fps); return scene; } diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index 9f354fde2d..79395cca93 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -32,12 +32,12 @@ #define EDITOR_SCENE_IMPORTER_GLTF_H #include "editor/import/resource_importer_scene.h" -#include "scene/3d/skeleton.h" -#include "scene/3d/spatial.h" +#include "scene/3d/node_3d.h" +#include "scene/3d/skeleton_3d.h" class AnimationPlayer; -class BoneAttachment; -class MeshInstance; +class BoneAttachment3D; +class MeshInstance3D; class EditorSceneImporterGLTF : public EditorSceneImporter { @@ -192,7 +192,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Vector<GLTFNodeIndex> roots; // The created Skeleton for the scene - Skeleton *godot_skeleton; + Skeleton3D *godot_skeleton; // Set of unique bone names for the skeleton Set<String> unique_names; @@ -395,15 +395,15 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Error _parse_animations(GLTFState &state); - BoneAttachment *_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index); - MeshInstance *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); - Camera *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); - Spatial *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + BoneAttachment3D *_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index); + MeshInstance3D *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + Camera3D *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + Node3D *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); - void _generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index); - Spatial *_generate_scene(GLTFState &state, const int p_bake_fps); + void _generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index); + Node3D *_generate_scene(GLTFState &state, const int p_bake_fps); - void _process_mesh_instances(GLTFState &state, Spatial *scene_root); + void _process_mesh_instances(GLTFState &state, Node3D *scene_root); void _assign_scene_names(GLTFState &state); diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index fb1782cb65..4be6f2ed80 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -32,8 +32,8 @@ #include "core/io/resource_saver.h" #include "core/os/file_access.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/spatial.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/node_3d.h" #include "scene/resources/mesh.h" #include "scene/resources/surface_tool.h" @@ -431,11 +431,11 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in return NULL; } - Spatial *scene = memnew(Spatial); + Node3D *scene = memnew(Node3D); for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) { - MeshInstance *mi = memnew(MeshInstance); + MeshInstance3D *mi = memnew(MeshInstance3D); mi->set_mesh(E->get()); mi->set_name(E->get()->get_name()); scene->add_child(mi); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 94a6fee6b7..fb57773b18 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -32,19 +32,19 @@ #include "core/io/resource_saver.h" #include "editor/editor_node.h" -#include "scene/3d/collision_shape.h" -#include "scene/3d/mesh_instance.h" -#include "scene/3d/navigation.h" -#include "scene/3d/physics_body.h" -#include "scene/3d/vehicle_body.h" +#include "scene/3d/collision_shape_3d.h" +#include "scene/3d/mesh_instance_3d.h" +#include "scene/3d/navigation_3d.h" +#include "scene/3d/physics_body_3d.h" +#include "scene/3d/vehicle_body_3d.h" #include "scene/animation/animation_player.h" #include "scene/resources/animation.h" -#include "scene/resources/box_shape.h" +#include "scene/resources/box_shape_3d.h" #include "scene/resources/packed_scene.h" -#include "scene/resources/ray_shape.h" +#include "scene/resources/ray_shape_3d.h" #include "scene/resources/resource_format_text.h" -#include "scene/resources/sphere_shape.h" -#include "scene/resources/world_margin_shape.h" +#include "scene/resources/sphere_shape_3d.h" +#include "scene/resources/world_margin_shape_3d.h" uint32_t EditorSceneImporter::get_import_flags() const { @@ -276,15 +276,15 @@ static String _fixstr(const String &p_what, const String &p_str) { return what; } -static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape>> &r_shape_list, bool p_convex) { +static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) { if (!p_convex) { - Ref<Shape> shape = mesh->create_trimesh_shape(); + Ref<Shape3D> shape = mesh->create_trimesh_shape(); r_shape_list.push_back(shape); } else { - Vector<Ref<Shape>> cd = mesh->convex_decompose(); + Vector<Ref<Shape3D>> cd = mesh->convex_decompose(); if (cd.size()) { for (int i = 0; i < cd.size(); i++) { r_shape_list.push_back(cd[i]); @@ -293,7 +293,7 @@ static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape>> &r_shape_lis } } -Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape>>> &collision_map, LightBakeMode p_light_bake_mode) { +Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode) { // children first for (int i = 0; i < p_node->get_child_count(); i++) { @@ -314,9 +314,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> return NULL; } - if (Object::cast_to<MeshInstance>(p_node)) { + if (Object::cast_to<MeshInstance3D>(p_node)) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> m = mi->get_mesh(); @@ -344,7 +344,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> if (p_light_bake_mode != LIGHT_BAKE_DISABLED) { - mi->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + mi->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true); } } @@ -377,12 +377,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> if (isroot) return p_node; - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); if (mi) { Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - List<Ref<Shape>> shapes; + List<Ref<Shape3D>> shapes; String fixed_name; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; @@ -404,7 +404,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> if (shapes.size()) { - StaticBody *col = memnew(StaticBody); + StaticBody3D *col = memnew(StaticBody3D); col->set_transform(mi->get_transform()); col->set_name(fixed_name); p_node->replace_by(col); @@ -412,9 +412,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> p_node = col; int idx = 0; - for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -427,55 +427,55 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } else if (p_node->has_meta("empty_draw_type")) { String empty_draw_type = String(p_node->get_meta("empty_draw_type")); - StaticBody *sb = memnew(StaticBody); + StaticBody3D *sb = memnew(StaticBody3D); sb->set_name(_fixstr(name, "colonly")); - Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform()); + Object::cast_to<Node3D>(sb)->set_transform(Object::cast_to<Node3D>(p_node)->get_transform()); p_node->replace_by(sb); memdelete(p_node); p_node = NULL; - CollisionShape *colshape = memnew(CollisionShape); + CollisionShape3D *colshape = memnew(CollisionShape3D); if (empty_draw_type == "CUBE") { - BoxShape *boxShape = memnew(BoxShape); + BoxShape3D *boxShape = memnew(BoxShape3D); boxShape->set_extents(Vector3(1, 1, 1)); colshape->set_shape(boxShape); - colshape->set_name("BoxShape"); + colshape->set_name("BoxShape3D"); } else if (empty_draw_type == "SINGLE_ARROW") { - RayShape *rayShape = memnew(RayShape); + RayShape3D *rayShape = memnew(RayShape3D); rayShape->set_length(1); colshape->set_shape(rayShape); - colshape->set_name("RayShape"); - Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2); + colshape->set_name("RayShape3D"); + Object::cast_to<Node3D>(sb)->rotate_x(Math_PI / 2); } else if (empty_draw_type == "IMAGE") { - WorldMarginShape *world_margin_shape = memnew(WorldMarginShape); + WorldMarginShape3D *world_margin_shape = memnew(WorldMarginShape3D); colshape->set_shape(world_margin_shape); colshape->set_name("WorldMarginShape"); } else { - SphereShape *sphereShape = memnew(SphereShape); + SphereShape3D *sphereShape = memnew(SphereShape3D); sphereShape->set_radius(1); colshape->set_shape(sphereShape); - colshape->set_name("SphereShape"); + colshape->set_name("SphereShape3D"); } sb->add_child(colshape); colshape->set_owner(sb->get_owner()); } - } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance>(p_node)) { + } else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance3D>(p_node)) { if (isroot) return p_node; - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - List<Ref<Shape>> shapes; + List<Ref<Shape3D>> shapes; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; } else { _gen_shape_list(mesh, shapes, true); } - RigidBody *rigid_body = memnew(RigidBody); + RigidBody3D *rigid_body = memnew(RigidBody3D); rigid_body->set_name(_fixstr(name, "rigid")); p_node->replace_by(rigid_body); rigid_body->set_transform(mi->get_transform()); @@ -486,9 +486,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> mi->set_owner(rigid_body->get_owner()); int idx = 0; - for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); rigid_body->add_child(cshape); @@ -498,14 +498,14 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } } - } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance>(p_node)) { + } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance3D>(p_node)) { - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - List<Ref<Shape>> shapes; + List<Ref<Shape3D>> shapes; String fixed_name; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; @@ -530,15 +530,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } if (shapes.size()) { - StaticBody *col = memnew(StaticBody); + StaticBody3D *col = memnew(StaticBody3D); col->set_name("static_collision"); mi->add_child(col); col->set_owner(mi->get_owner()); int idx = 0; - for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -550,22 +550,22 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } } - } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance>(p_node)) { + } else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance3D>(p_node)) { if (isroot) return p_node; - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); ERR_FAIL_COND_V(mesh.is_null(), NULL); - NavigationRegion *nmi = memnew(NavigationRegion); + NavigationRegion3D *nmi = memnew(NavigationRegion3D); nmi->set_name(_fixstr(name, "navmesh")); Ref<NavigationMesh> nmesh = memnew(NavigationMesh); nmesh->create_from_mesh(mesh); nmi->set_navigation_mesh(nmesh); - Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform()); + Object::cast_to<Node3D>(nmi)->set_transform(mi->get_transform()); p_node->replace_by(nmi); memdelete(p_node); p_node = nmi; @@ -575,8 +575,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> return p_node; Node *owner = p_node->get_owner(); - Spatial *s = Object::cast_to<Spatial>(p_node); - VehicleBody *bv = memnew(VehicleBody); + Node3D *s = Object::cast_to<Node3D>(p_node); + VehicleBody3D *bv = memnew(VehicleBody3D); String n = _fixstr(p_node->get_name(), "vehicle"); bv->set_name(n); p_node->replace_by(bv); @@ -595,8 +595,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> return p_node; Node *owner = p_node->get_owner(); - Spatial *s = Object::cast_to<Spatial>(p_node); - VehicleWheel *bv = memnew(VehicleWheel); + Node3D *s = Object::cast_to<Node3D>(p_node); + VehicleWheel3D *bv = memnew(VehicleWheel3D); String n = _fixstr(p_node->get_name(), "wheel"); bv->set_name(n); p_node->replace_by(bv); @@ -609,16 +609,16 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> p_node = bv; - } else if (Object::cast_to<MeshInstance>(p_node)) { + } else if (Object::cast_to<MeshInstance3D>(p_node)) { //last attempt, maybe collision inside the mesh data - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); if (!mesh.is_null()) { - List<Ref<Shape>> shapes; + List<Ref<Shape3D>> shapes; if (collision_map.has(mesh)) { shapes = collision_map[mesh]; } else if (_teststr(mesh->get_name(), "col")) { @@ -632,15 +632,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> } if (shapes.size()) { - StaticBody *col = memnew(StaticBody); + StaticBody3D *col = memnew(StaticBody3D); col->set_name("static_collision"); p_node->add_child(col); col->set_owner(p_node->get_owner()); int idx = 0; - for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) { + for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) { - CollisionShape *cshape = memnew(CollisionShape); + CollisionShape3D *cshape = memnew(CollisionShape3D); cshape->set_shape(E->get()); col->add_child(cshape); @@ -934,14 +934,14 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans List<PropertyInfo> pi; p_node->get_property_list(&pi); - MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node); if (mi) { Ref<ArrayMesh> mesh = mi->get_mesh(); if (mesh.is_valid() && !meshes.has(mesh)) { - Spatial *s = mi; + Node3D *s = mi; Transform transform; while (s) { transform = transform * s->get_transform(); @@ -1141,7 +1141,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, int p_preset) const { - r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Spatial")); + r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Node3D")); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root")); List<String> script_extentions; @@ -1333,7 +1333,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p root_type = ScriptServer::get_global_class_base(root_type); } - if (root_type != "Spatial") { + if (root_type != "Node3D") { Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type)); if (base_node) { @@ -1348,9 +1348,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p scene->set_script(Variant(root_script)); } - if (Object::cast_to<Spatial>(scene)) { + if (Object::cast_to<Node3D>(scene)) { float root_scale = p_options["nodes/root_scale"]; - Object::cast_to<Spatial>(scene)->scale(Vector3(root_scale, root_scale, root_scale)); + Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale)); } if (p_options["nodes/root_name"] != "Scene Root") @@ -1368,7 +1368,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p float anim_optimizer_maxang = p_options["animation/optimizer/max_angle"]; int light_bake_mode = p_options["meshes/light_baking"]; - Map<Ref<Mesh>, List<Ref<Shape>>> collision_map; + Map<Ref<Mesh>, List<Ref<Shape3D>>> collision_map; scene = _fix_node(scene, scene, collision_map, LightBakeMode(light_bake_mode)); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 6d1043eb28..bb01725854 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -34,7 +34,7 @@ #include "core/io/resource_importer.h" #include "scene/resources/animation.h" #include "scene/resources/mesh.h" -#include "scene/resources/shape.h" +#include "scene/resources/shape_3d.h" class Material; @@ -147,7 +147,7 @@ public: void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation>> &p_animations, Map<Ref<Material>, Ref<Material>> &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh>> &p_meshes); - Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape>>> &collision_map, LightBakeMode p_light_bake_mode); + Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode); void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all); void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep); |