From e558e0f7008d868dea7e0205661b00ab6ce66710 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 28 Aug 2022 16:01:50 +0200 Subject: [PATCH] Fix build when the new skeleton 3d module is disabled. --- .../animation_blend_tree_editor_plugin.cpp | 5 +++-- editor/spatial_editor_gizmos.cpp | 6 ++++++ editor_modules/gltf/gltf_document.cpp | 16 ++++++++++++++-- editor_modules/gltf/gltf_document.h | 4 ++++ editor_modules/gltf/gltf_skeleton.h | 2 ++ scene/3d/importer_mesh_instance_3d.cpp | 4 ++++ scene/3d/importer_mesh_instance_3d.h | 4 ++++ scene/3d/mesh_instance.cpp | 4 ++++ scene/animation/animation_player.h | 2 ++ scene/animation/animation_tree.h | 2 ++ 10 files changed, 45 insertions(+), 4 deletions(-) diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 3b71b1ca2..4e8adb3ba 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -667,9 +667,9 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref &ano } if (path.get_subname_count()) { -#ifdef MODULE_SKELETON_3D_ENABLED String concat = path.get_concatenated_subnames(); +#ifdef MODULE_SKELETON_3D_ENABLED Skeleton *skeleton = Object::cast_to(node); if (skeleton && skeleton->find_bone(concat) != -1) { //path in skeleton @@ -707,8 +707,9 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref &ano ti->set_checked(0, anode->is_path_filtered(path)); ti->set_icon(0, get_theme_icon("BoneAttachment", "EditorIcons")); ti->set_metadata(0, path); + } else #endif - } else { + { //just a property ti = filters->create_item(ti); ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 7f975f07e..1fa9c2eef 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -927,7 +927,13 @@ void EditorSpatialGizmo::set_plugin(EditorSpatialGizmoPlugin *p_plugin) { void EditorSpatialGizmo::_bind_methods() { ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard", "modulate"), &EditorSpatialGizmo::add_lines, DEFVAL(false), DEFVAL(Color(1, 1, 1))); + +#ifdef MODULE_SKELETON_3D_ENABLED ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "material", "transform", "skeleton"), &EditorSpatialGizmo::add_mesh, DEFVAL(Variant()), DEFVAL(Transform()), DEFVAL(Ref())); +#else + ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "material", "transform"), &EditorSpatialGizmo::add_mesh, DEFVAL(Variant()), DEFVAL(Transform())); +#endif + ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorSpatialGizmo::add_collision_segments); ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorSpatialGizmo::add_collision_triangles); ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale", "modulate"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1), DEFVAL(Color(1, 1, 1))); diff --git a/editor_modules/gltf/gltf_document.cpp b/editor_modules/gltf/gltf_document.cpp index 4bb6885dd..7dfa42bef 100644 --- a/editor_modules/gltf/gltf_document.cpp +++ b/editor_modules/gltf/gltf_document.cpp @@ -4391,6 +4391,7 @@ Error GLTFDocument::_create_skeletons(Ref state) { #endif Error GLTFDocument::_map_skin_joints_indices_to_skeleton_bone_indices(Ref state) { +#ifdef MODULE_SKELETON_3D_ENABLED for (GLTFSkinIndex skin_i = 0; skin_i < state->skins.size(); ++skin_i) { Ref skin = state->skins.write[skin_i]; @@ -4406,6 +4407,7 @@ Error GLTFDocument::_map_skin_joints_indices_to_skeleton_bone_indices(Refjoint_i_to_bone_i.insert(joint_index, bone_index); } } +#endif return OK; } @@ -4430,6 +4432,7 @@ Error GLTFDocument::_serialize_skins(Ref state) { } Error GLTFDocument::_create_skins(Ref state) { +#ifdef MODULE_SKELETON_3D_ENABLED for (GLTFSkinIndex skin_i = 0; skin_i < state->skins.size(); ++skin_i) { Ref gltf_skin = state->skins.write[skin_i]; @@ -4470,10 +4473,12 @@ Error GLTFDocument::_create_skins(Ref state) { skin->set_name(_gen_unique_name(state, "Skin")); } } +#endif return OK; } +#ifdef MODULE_SKELETON_3D_ENABLED bool GLTFDocument::_skins_are_same(const Ref skin_a, const Ref skin_b) { if (skin_a->get_bind_count() != skin_b->get_bind_count()) { return false; @@ -4497,8 +4502,10 @@ bool GLTFDocument::_skins_are_same(const Ref skin_a, const Ref skin_ return true; } +#endif void GLTFDocument::_remove_duplicate_skins(Ref state) { +#ifdef MODULE_SKELETON_3D_ENABLED for (int i = 0; i < state->skins.size(); ++i) { for (int j = i + 1; j < state->skins.size(); ++j) { const Ref skin_i = state->skins[i]->pandemonium_skin; @@ -4510,6 +4517,7 @@ void GLTFDocument::_remove_duplicate_skins(Ref state) { } } } +#endif } Error GLTFDocument::_serialize_lights(Ref state) { @@ -5316,11 +5324,11 @@ void GLTFDocument::_convert_scene_node(Ref state, Node *p_current, co if (cast_to(p_current)) { MeshInstance *mi = cast_to(p_current); _convert_mesh_instance_to_gltf(mi, state, gltf_node); +#ifdef MODULE_SKELETON_3D_ENABLED } else if (cast_to(p_current)) { BoneAttachment *bone = cast_to(p_current); _convert_bone_attachment_to_gltf(bone, state, p_gltf_parent, p_gltf_root, gltf_node); return; -#ifdef MODULE_SKELETON_3D_ENABLED } else if (cast_to(p_current)) { Skeleton *skel = cast_to(p_current); _convert_skeleton_to_gltf(skel, state, p_gltf_parent, p_gltf_root, gltf_node); @@ -5546,7 +5554,9 @@ void GLTFDocument::_generate_scene_node(Ref state, Node *scene_parent Ref gltf_node = state->nodes[node_index]; if (gltf_node->skeleton >= 0) { +#ifdef MODULE_SKELETON_3D_ENABLED _generate_skeleton_bone_node(state, scene_parent, scene_root, node_index); +#endif return; } @@ -6140,8 +6150,8 @@ void GLTFDocument::_convert_mesh_instances(Ref state) { node->skin = skin_gltf_i; node->skeleton = skeleton_gltf_i; } - } #endif + } } float GLTFDocument::solve_metallic(float p_dielectric_specular, float diffuse, float specular, float p_one_minus_specular_strength) { @@ -6682,6 +6692,7 @@ Error GLTFDocument::parse(Ref state, String p_path, bool p_read_binar return Error::FAILED; } +#ifdef MODULE_SKELETON_3D_ENABLED /* CREATE SKELETONS */ err = _create_skeletons(state); if (err != OK) { @@ -6693,6 +6704,7 @@ Error GLTFDocument::parse(Ref state, String p_path, bool p_read_binar if (err != OK) { return Error::FAILED; } +#endif /* PARSE MESHES (we have enough info now) */ err = _parse_meshes(state); diff --git a/editor_modules/gltf/gltf_document.h b/editor_modules/gltf/gltf_document.h index 92451bbfe..5c882969f 100644 --- a/editor_modules/gltf/gltf_document.h +++ b/editor_modules/gltf/gltf_document.h @@ -42,8 +42,10 @@ #include "modules/modules_enabled.gen.h" // For csg, gridmap. +#ifdef MODULE_SKELETON_3D_ENABLED class Skeleton; class BoneAttachment; +#endif class GLTFState; class GLTFSkin; @@ -254,7 +256,9 @@ private: Error _map_skin_joints_indices_to_skeleton_bone_indices(Ref state); Error _serialize_skins(Ref state); Error _create_skins(Ref state); +#ifdef MODULE_SKELETON_3D_ENABLED bool _skins_are_same(const Ref skin_a, const Ref skin_b); +#endif void _remove_duplicate_skins(Ref state); Error _serialize_cameras(Ref state); Error _parse_cameras(Ref state); diff --git a/editor_modules/gltf/gltf_skeleton.h b/editor_modules/gltf/gltf_skeleton.h index 3b7aea0be..937936fe3 100644 --- a/editor_modules/gltf/gltf_skeleton.h +++ b/editor_modules/gltf/gltf_skeleton.h @@ -53,8 +53,10 @@ private: // same parent (ie roots are siblings) PoolVector roots; +#ifdef MODULE_SKELETON_3D_ENABLED // The created Skeleton for the scene Skeleton *pandemonium_skeleton = nullptr; +#endif // Set of unique bone names for the skeleton Set unique_names; diff --git a/scene/3d/importer_mesh_instance_3d.cpp b/scene/3d/importer_mesh_instance_3d.cpp index f37a5be98..31aef0834 100644 --- a/scene/3d/importer_mesh_instance_3d.cpp +++ b/scene/3d/importer_mesh_instance_3d.cpp @@ -64,12 +64,14 @@ Ref ImporterMeshInstance3D::get_surface_material(int p_idx) const { return surface_materials[p_idx]; } +#ifdef MODULE_SKELETON_3D_ENABLED void ImporterMeshInstance3D::set_skeleton_path(const NodePath &p_path) { skeleton_path = p_path; } NodePath ImporterMeshInstance3D::get_skeleton_path() const { return skeleton_path; } +#endif void ImporterMeshInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &ImporterMeshInstance3D::set_mesh); @@ -82,7 +84,9 @@ void ImporterMeshInstance3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skin", PROPERTY_HINT_RESOURCE_TYPE, "Skin"), "set_skin", "get_skin"); #endif +#ifdef MODULE_SKELETON_3D_ENABLED ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &ImporterMeshInstance3D::set_skeleton_path); ClassDB::bind_method(D_METHOD("get_skeleton_path"), &ImporterMeshInstance3D::get_skeleton_path); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton"), "set_skeleton_path", "get_skeleton_path"); +#endif } diff --git a/scene/3d/importer_mesh_instance_3d.h b/scene/3d/importer_mesh_instance_3d.h index 84934aeee..ce3e61f5c 100644 --- a/scene/3d/importer_mesh_instance_3d.h +++ b/scene/3d/importer_mesh_instance_3d.h @@ -45,8 +45,10 @@ class ImporterMeshInstance3D : public Spatial { GDCLASS(ImporterMeshInstance3D, Spatial) Ref mesh; +#ifdef MODULE_SKELETON_3D_ENABLED Ref skin; NodePath skeleton_path; +#endif Vector> surface_materials; protected: @@ -64,8 +66,10 @@ public: void set_surface_material(int p_idx, const Ref &p_material); Ref get_surface_material(int p_idx) const; +#ifdef MODULE_SKELETON_3D_ENABLED void set_skeleton_path(const NodePath &p_path); NodePath get_skeleton_path() const; +#endif }; #endif // IMPORTER_MESH_INSTANCE_3D_H diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 0b937f4d0..3dc14faa6 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -124,10 +124,12 @@ void MeshInstance::set_mesh(const Ref &p_mesh) { mesh->disconnect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_mesh_changed); } +#ifdef MODULE_SKELETON_3D_ENABLED if (skin_ref.is_valid() && mesh.is_valid() && _is_software_skinning_enabled() && is_visible_in_tree()) { ERR_FAIL_COND(!skin_ref->get_skeleton_node()); skin_ref->get_skeleton_node()->disconnect("pose_updated", this, "_update_skinning"); } +#endif #ifdef MODULE_SKELETON_3D_ENABLED if (software_skinning) { @@ -749,9 +751,11 @@ void MeshInstance::set_material_override(const Ref &p_material) { GeometryInstance::set_material_override(p_material); +#ifdef MODULE_SKELETON_3D_ENABLED if (software_skinning) { _initialize_skinning(true); } +#endif } void MeshInstance::set_material_overlay(const Ref &p_material) { diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index da675ff6e..7bf5a69a6 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -172,7 +172,9 @@ private: node(nullptr), spatial(nullptr), node_2d(nullptr), +#ifdef MODULE_SKELETON_3D_ENABLED skeleton(nullptr), +#endif bone_idx(-1), accum_pass(0), audio_playing(false), diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index ac2486a8f..88598c026 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -208,8 +208,10 @@ private: TrackCacheTransform() { type = Animation::TYPE_POSITION_3D; spatial = nullptr; +#ifdef MODULE_SKELETON_3D_ENABLED bone_idx = -1; skeleton = nullptr; +#endif loc_used = false; rot_used = false; scale_used = false;