diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-26 00:08:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-26 00:08:45 +0100 |
commit | 78661d1a4395d209a9aa4e30b53a988aec140a30 (patch) | |
tree | 8330cc412cc7b10b00345e075ee156912228e13f | |
parent | 6cba65893485195a5520c91346cf0540f9e9a23b (diff) | |
parent | abd06567a7881f368a341f88c27ec538c41f21c8 (diff) |
Merge pull request #45375 from aaronfranke/gltf-csg-gridmap
Make GLTF not depend on CSG or GridMap
-rw-r--r-- | modules/gltf/gltf_document.cpp | 12 | ||||
-rw-r--r-- | modules/gltf/gltf_document.h | 5 |
2 files changed, 17 insertions, 0 deletions
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index ebf30b13f2..d07d4d603c 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -57,8 +57,12 @@ #include "core/version_hash.gen.h" #include "drivers/png/png_driver_common.h" #include "editor/import/resource_importer_scene.h" +#ifdef MODULE_CSG_ENABLED #include "modules/csg/csg_shape.h" +#endif // MODULE_CSG_ENABLED +#ifdef MODULE_GRIDMAP_ENABLED #include "modules/gridmap/grid_map.h" +#endif // MODULE_GRIDMAP_ENABLED #include "modules/regex/regex.h" #include "scene/2d/node_2d.h" #include "scene/3d/bone_attachment_3d.h" @@ -5124,12 +5128,16 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No return; } else if (cast_to<MultiMeshInstance3D>(p_current)) { _convert_mult_mesh_instance_to_gltf(p_current, p_gltf_parent, p_gltf_root, gltf_node, state, p_root); +#ifdef MODULE_CSG_ENABLED } else if (cast_to<CSGShape3D>(p_current)) { if (p_current->get_parent() && cast_to<CSGShape3D>(p_current)->is_root_shape()) { _convert_csg_shape_to_gltf(p_current, p_gltf_parent, gltf_node, state); } +#endif // MODULE_CSG_ENABLED +#ifdef MODULE_GRIDMAP_ENABLED } else if (cast_to<GridMap>(p_current)) { _convert_grid_map_to_gltf(p_current, p_gltf_parent, p_gltf_root, gltf_node, state, p_root); +#endif // MODULE_GRIDMAP_ENABLED } else if (cast_to<Camera3D>(p_current)) { Camera3D *camera = Object::cast_to<Camera3D>(p_current); _convert_camera_to_gltf(camera, state, spatial, gltf_node); @@ -5154,6 +5162,7 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, No } } +#ifdef MODULE_CSG_ENABLED void GLTFDocument::_convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state) { CSGShape3D *csg = Object::cast_to<CSGShape3D>(p_current); csg->call("_update_shape"); @@ -5180,6 +5189,7 @@ void GLTFDocument::_convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_g 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<GLTFState> state, Node *p_scene_parent, GLTFNodeIndex current_node_i, GLTFNodeIndex p_parent_node_index, GLTFNodeIndex p_root_gltf_node, Ref<GLTFNode> gltf_node) { @@ -5229,6 +5239,7 @@ void GLTFDocument::_convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, } } +#ifdef MODULE_GRIDMAP_ENABLED void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node) { GridMap *grid_map = Object::cast_to<GridMap>(p_scene_parent); ERR_FAIL_COND(!grid_map); @@ -5260,6 +5271,7 @@ void GLTFDocument::_convert_grid_map_to_gltf(Node *p_scene_parent, const GLTFNod new_gltf_node->set_name(_gen_unique_name(state, grid_map->get_mesh_library()->get_item_name(cell))); } } +#endif // MODULE_GRIDMAP_ENABLED void GLTFDocument::_convert_mult_mesh_instance_to_gltf(Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node) { MultiMeshInstance3D *multi_mesh_instance = Object::cast_to<MultiMeshInstance3D>(p_scene_parent); diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 111324d1e6..ddf307e6a7 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -34,6 +34,7 @@ #include "editor/import/resource_importer_scene.h" #include "editor/import/scene_importer_mesh_node_3d.h" #include "gltf_animation.h" +#include "modules/modules_enabled.gen.h" #include "scene/2d/node_2d.h" #include "scene/3d/bone_attachment_3d.h" #include "scene/3d/light_3d.h" @@ -377,7 +378,9 @@ public: const GLTFNodeIndex p_gltf_current, const GLTFNodeIndex p_gltf_root); +#ifdef MODULE_CSG_ENABLED void _convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state); +#endif // MODULE_CSG_ENABLED void _create_gltf_node(Ref<GLTFState> state, Node *p_scene_parent, @@ -395,12 +398,14 @@ public: void _convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> state, Node3D *spatial, Ref<GLTFNode> gltf_node); +#ifdef MODULE_GRIDMAP_ENABLED void _convert_grid_map_to_gltf( Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, const GLTFNodeIndex &p_root_node_index, Ref<GLTFNode> gltf_node, Ref<GLTFState> state, Node *p_root_node); +#endif // MODULE_GRIDMAP_ENABLED void _convert_mult_mesh_instance_to_gltf( Node *p_scene_parent, const GLTFNodeIndex &p_parent_node_index, |