MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _convert_scene_node

Method _convert_scene_node

modules/gltf/gltf_document.cpp:5951–6033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5949}
5950
5951void 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);

Callers

nothing calls this directly

Calls 15

merge_meta_fromMethod · 0.80
is_root_shapeMethod · 0.80
set_parentMethod · 0.80
append_gltf_nodeMethod · 0.80
sizeMethod · 0.65
is_editor_hintMethod · 0.45
get_ownerMethod · 0.45
get_nameMethod · 0.45
instantiateMethod · 0.45
has_methodMethod · 0.45
callMethod · 0.45
set_original_nameMethod · 0.45

Tested by

no test coverage detected