| 5949 | } |
| 5950 | |
| 5951 | void GLTFDocument::_convert_scene_node(Ref<GLTFState> p_state, Node *p_current, const GLTFNodeIndex p_gltf_parent, const GLTFNodeIndex p_gltf_root) { |
| 5952 | #ifdef TOOLS_ENABLED |
| 5953 | if (Engine::get_singleton()->is_editor_hint() && p_gltf_root != -1 && p_current->get_owner() == nullptr) { |
| 5954 | WARN_VERBOSE("glTF export warning: Node '" + p_current->get_name() + "' has no owner. This is likely a temporary node generated by a @tool script. This would not be saved when saving the Redot scene, therefore it will not be exported to glTF."); |
| 5955 | return; |
| 5956 | } |
| 5957 | #endif // TOOLS_ENABLED |
| 5958 | Ref<GLTFNode> gltf_node; |
| 5959 | gltf_node.instantiate(); |
| 5960 | if (p_current->has_method("is_visible")) { |
| 5961 | bool visible = p_current->call("is_visible"); |
| 5962 | if (!visible && _visibility_mode == VISIBILITY_MODE_EXCLUDE) { |
| 5963 | return; |
| 5964 | } |
| 5965 | gltf_node->visible = visible; |
| 5966 | } |
| 5967 | gltf_node->set_original_name(p_current->get_name()); |
| 5968 | gltf_node->set_name(_gen_unique_name(p_state, p_current->get_name())); |
| 5969 | gltf_node->merge_meta_from(p_current); |
| 5970 | if (Object::cast_to<Node3D>(p_current)) { |
| 5971 | Node3D *spatial = Object::cast_to<Node3D>(p_current); |
| 5972 | _convert_spatial(p_state, spatial, gltf_node); |
| 5973 | } |
| 5974 | if (Object::cast_to<MeshInstance3D>(p_current)) { |
| 5975 | MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_current); |
| 5976 | _convert_mesh_instance_to_gltf(mi, p_state, gltf_node); |
| 5977 | } else if (Object::cast_to<BoneAttachment3D>(p_current)) { |
| 5978 | BoneAttachment3D *bone = Object::cast_to<BoneAttachment3D>(p_current); |
| 5979 | _convert_bone_attachment_to_gltf(bone, p_state, p_gltf_parent, p_gltf_root, gltf_node); |
| 5980 | return; |
| 5981 | } else if (Object::cast_to<Skeleton3D>(p_current)) { |
| 5982 | Skeleton3D *skel = Object::cast_to<Skeleton3D>(p_current); |
| 5983 | _convert_skeleton_to_gltf(skel, p_state, p_gltf_parent, p_gltf_root, gltf_node); |
| 5984 | // We ignore the Godot Engine node that is the skeleton. |
| 5985 | return; |
| 5986 | } else if (Object::cast_to<MultiMeshInstance3D>(p_current)) { |
| 5987 | MultiMeshInstance3D *multi = Object::cast_to<MultiMeshInstance3D>(p_current); |
| 5988 | _convert_multi_mesh_instance_to_gltf(multi, p_gltf_parent, p_gltf_root, gltf_node, p_state); |
| 5989 | #ifdef MODULE_CSG_ENABLED |
| 5990 | } else if (Object::cast_to<CSGShape3D>(p_current)) { |
| 5991 | CSGShape3D *shape = Object::cast_to<CSGShape3D>(p_current); |
| 5992 | if (shape->get_parent() && shape->is_root_shape()) { |
| 5993 | _convert_csg_shape_to_gltf(shape, p_gltf_parent, gltf_node, p_state); |
| 5994 | } |
| 5995 | #endif // MODULE_CSG_ENABLED |
| 5996 | #ifdef MODULE_GRIDMAP_ENABLED |
| 5997 | } else if (Object::cast_to<GridMap>(p_current)) { |
| 5998 | GridMap *gridmap = Object::cast_to<GridMap>(p_current); |
| 5999 | _convert_grid_map_to_gltf(gridmap, p_gltf_parent, p_gltf_root, gltf_node, p_state); |
| 6000 | #endif // MODULE_GRIDMAP_ENABLED |
| 6001 | } else if (Object::cast_to<Camera3D>(p_current)) { |
| 6002 | Camera3D *camera = Object::cast_to<Camera3D>(p_current); |
| 6003 | _convert_camera_to_gltf(camera, p_state, gltf_node); |
| 6004 | } else if (Object::cast_to<Light3D>(p_current)) { |
| 6005 | Light3D *light = Object::cast_to<Light3D>(p_current); |
| 6006 | _convert_light_to_gltf(light, p_state, gltf_node); |
| 6007 | } else if (Object::cast_to<AnimationPlayer>(p_current)) { |
| 6008 | AnimationPlayer *animation_player = Object::cast_to<AnimationPlayer>(p_current); |
nothing calls this directly
no test coverage detected