|
@@ -57,8 +57,12 @@
|
|
#include "core/version_hash.gen.h"
|
|
#include "core/version_hash.gen.h"
|
|
#include "drivers/png/png_driver_common.h"
|
|
#include "drivers/png/png_driver_common.h"
|
|
#include "editor/import/resource_importer_scene.h"
|
|
#include "editor/import/resource_importer_scene.h"
|
|
|
|
+#ifdef MODULE_CSG_ENABLED
|
|
#include "modules/csg/csg_shape.h"
|
|
#include "modules/csg/csg_shape.h"
|
|
|
|
+#endif // MODULE_CSG_ENABLED
|
|
|
|
+#ifdef MODULE_GRIDMAP_ENABLED
|
|
#include "modules/gridmap/grid_map.h"
|
|
#include "modules/gridmap/grid_map.h"
|
|
|
|
+#endif // MODULE_GRIDMAP_ENABLED
|
|
#include "modules/regex/regex.h"
|
|
#include "modules/regex/regex.h"
|
|
#include "scene/2d/node_2d.h"
|
|
#include "scene/2d/node_2d.h"
|
|
#include "scene/3d/bone_attachment_3d.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;
|
|
return;
|
|
} else if (cast_to<MultiMeshInstance3D>(p_current)) {
|
|
} 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);
|
|
_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)) {
|
|
} else if (cast_to<CSGShape3D>(p_current)) {
|
|
if (p_current->get_parent() && cast_to<CSGShape3D>(p_current)->is_root_shape()) {
|
|
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);
|
|
_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)) {
|
|
} 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);
|
|
_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)) {
|
|
} else if (cast_to<Camera3D>(p_current)) {
|
|
Camera3D *camera = Object::cast_to<Camera3D>(p_current);
|
|
Camera3D *camera = Object::cast_to<Camera3D>(p_current);
|
|
_convert_camera_to_gltf(camera, state, spatial, gltf_node);
|
|
_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) {
|
|
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);
|
|
CSGShape3D *csg = Object::cast_to<CSGShape3D>(p_current);
|
|
csg->call("_update_shape");
|
|
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->xform = csg->get_meshes()[0];
|
|
gltf_node->set_name(_gen_unique_name(state, csg->get_name()));
|
|
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,
|
|
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) {
|
|
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) {
|
|
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);
|
|
GridMap *grid_map = Object::cast_to<GridMap>(p_scene_parent);
|
|
ERR_FAIL_COND(!grid_map);
|
|
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)));
|
|
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) {
|
|
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);
|
|
MultiMeshInstance3D *multi_mesh_instance = Object::cast_to<MultiMeshInstance3D>(p_scene_parent);
|