Merge pull request #45375 from aaronfranke/gltf-csg-gridmap
Make GLTF not depend on CSG or GridMap
This commit is contained in:
commit
78661d1a43
2 changed files with 17 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue