From 1bc7531da736c78c3ba38ba00cc140939ae3cc46 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 7 Aug 2022 21:02:32 +0200 Subject: [PATCH] Remove Gridmap and CSG support from the gltf module. --- modules/gltf/gltf_defines.h | 3 -- modules/gltf/gltf_document.cpp | 83 ---------------------------------- modules/gltf/gltf_document.h | 11 ----- 3 files changed, 97 deletions(-) diff --git a/modules/gltf/gltf_defines.h b/modules/gltf/gltf_defines.h index 55976e9c6..abb86ef46 100644 --- a/modules/gltf/gltf_defines.h +++ b/modules/gltf/gltf_defines.h @@ -41,9 +41,6 @@ class MultiMeshInstance; class Skeleton; class Skin; -class CSGShape3D; -class GridMap; - // GLTF classes. struct GLTFAccessor; class GLTFAnimation; diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index f03d101b3..290577446 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -5307,18 +5307,6 @@ void GLTFDocument::_convert_scene_node(Ref state, Node *p_current, co } else if (cast_to(p_current)) { MultiMeshInstance *multi = cast_to(p_current); _convert_multi_mesh_instance_to_gltf(multi, p_gltf_parent, p_gltf_root, gltf_node, state); -#ifdef MODULE_CSG_ENABLED - } else if (cast_to(p_current)) { - CSGShape3D *shape = cast_to(p_current); - if (shape->get_parent() && shape->is_root_shape()) { - _convert_csg_shape_to_gltf(shape, p_gltf_parent, gltf_node, state); - } -#endif // MODULE_CSG_ENABLED -#ifdef MODULE_GRIDMAP_ENABLED - } else if (cast_to(p_current)) { - GridMap *gridmap = Object::cast_to(p_current); - _convert_grid_map_to_gltf(gridmap, p_gltf_parent, p_gltf_root, gltf_node, state); -#endif // MODULE_GRIDMAP_ENABLED } else if (cast_to(p_current)) { Camera3D *camera = Object::cast_to(p_current); _convert_camera_to_gltf(camera, state, gltf_node); @@ -5343,47 +5331,6 @@ void GLTFDocument::_convert_scene_node(Ref state, Node *p_current, co } } -#ifdef MODULE_CSG_ENABLED -void GLTFDocument::_convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref gltf_node, Ref state) { - CSGShape3D *csg = p_current; - csg->call("_update_shape"); - Array meshes = csg->get_meshes(); - if (meshes.size() != 2) { - return; - } - - Ref mesh; - mesh.instantiate(); - { - Ref csg_mesh = csg->get_meshes()[1]; - - for (int32_t surface_i = 0; surface_i < csg_mesh->get_surface_count(); surface_i++) { - Array array = csg_mesh->surface_get_arrays(surface_i); - Ref mat = csg_mesh->surface_get_material(surface_i); - String mat_name; - if (mat.is_valid()) { - mat_name = mat->get_name(); - } else { - // Assign default material when no material is assigned. - mat = Ref(memnew(StandardMaterial3D)); - } - mesh->add_surface(csg_mesh->surface_get_primitive_type(surface_i), - array, csg_mesh->surface_get_blend_shape_arrays(surface_i), csg_mesh->surface_get_lods(surface_i), mat, - mat_name, csg_mesh->surface_get_format(surface_i)); - } - } - - Ref gltf_mesh; - gltf_mesh.instantiate(); - gltf_mesh->set_mesh(mesh); - GLTFMeshIndex mesh_i = state->meshes.size(); - state->meshes.push_back(gltf_mesh); - gltf_node->mesh = mesh_i; - gltf_node->xform = csg->get_meshes()[0]; - gltf_node->set_name(_gen_unique_name(state, csg->get_name())); -} -#endif // MODULE_CSG_ENABLED - void GLTFDocument::_create_gltf_node(Ref state, Node *p_scene_parent, GLTFNodeIndex current_node_i, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_gltf_node, Ref gltf_node) { state->scene_nodes.insert(current_node_i, p_scene_parent); @@ -5431,36 +5378,6 @@ void GLTFDocument::_convert_light_to_gltf(Light *light, Ref state, Re } } -#ifdef MODULE_GRIDMAP_ENABLED -void GLTFDocument::_convert_grid_map_to_gltf(GridMap *p_grid_map, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_node_index, Ref gltf_node, Ref state) { - Array cells = p_grid_map->get_used_cells(); - for (int32_t k = 0; k < cells.size(); k++) { - GLTFNode *new_gltf_node = memnew(GLTFNode); - gltf_node->children.push_back(state->nodes.size()); - state->nodes.push_back(new_gltf_node); - Vector3 cell_location = cells[k]; - int32_t cell = p_grid_map->get_cell_item( - Vector3(cell_location.x, cell_location.y, cell_location.z)); - Transform3D cell_xform; - cell_xform.basis.set_orthogonal_index( - p_grid_map->get_cell_item_orientation( - Vector3(cell_location.x, cell_location.y, cell_location.z))); - cell_xform.basis.scale(Vector3(p_grid_map->get_cell_scale(), - p_grid_map->get_cell_scale(), - p_grid_map->get_cell_scale())); - cell_xform.set_origin(p_grid_map->map_to_world( - Vector3(cell_location.x, cell_location.y, cell_location.z))); - Ref gltf_mesh; - gltf_mesh.instantiate(); - gltf_mesh->set_mesh(_mesh_to_importer_mesh(p_grid_map->get_mesh_library()->get_item_mesh(cell))); - new_gltf_node->mesh = state->meshes.size(); - state->meshes.push_back(gltf_mesh); - new_gltf_node->xform = cell_xform * p_grid_map->get_transform(); - new_gltf_node->set_name(_gen_unique_name(state, p_grid_map->get_mesh_library()->get_item_name(cell))); - } -} -#endif // MODULE_GRIDMAP_ENABLED - void GLTFDocument::_convert_multi_mesh_instance_to_gltf( MultiMeshInstance *p_multi_mesh_instance, GLTFNodeIndex p_parent_node_index, diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 175080cbb..88f6984d0 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -312,10 +312,6 @@ public: const GLTFNodeIndex p_gltf_current, const GLTFNodeIndex p_gltf_root); -#ifdef MODULE_CSG_ENABLED - void _convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref gltf_node, Ref state); -#endif // MODULE_CSG_ENABLED - void _create_gltf_node(Ref state, Node *p_scene_parent, GLTFNodeIndex current_node_i, @@ -330,13 +326,6 @@ public: void _check_visibility(Node *p_node, bool &retflag); void _convert_camera_to_gltf(Camera3D *camera, Ref state, Ref gltf_node); -#ifdef MODULE_GRIDMAP_ENABLED - void _convert_grid_map_to_gltf( - GridMap *p_grid_map, - GLTFNodeIndex p_parent_node_index, - GLTFNodeIndex p_root_node_index, - Ref gltf_node, Ref state); -#endif // MODULE_GRIDMAP_ENABLED void _convert_multi_mesh_instance_to_gltf( MultiMeshInstance *p_multi_mesh_instance, GLTFNodeIndex p_parent_node_index,