Fix build when the new skeleton 3d module is disabled.

This commit is contained in:
Relintai 2022-08-28 16:01:50 +02:00
parent dc28777321
commit e558e0f700
10 changed files with 45 additions and 4 deletions

View File

@ -667,9 +667,9 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &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<Skeleton>(node);
if (skeleton && skeleton->find_bone(concat) != -1) {
//path in skeleton
@ -707,8 +707,9 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &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);

View File

@ -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<SkinReference>()));
#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)));

View File

@ -4391,6 +4391,7 @@ Error GLTFDocument::_create_skeletons(Ref<GLTFState> state) {
#endif
Error GLTFDocument::_map_skin_joints_indices_to_skeleton_bone_indices(Ref<GLTFState> state) {
#ifdef MODULE_SKELETON_3D_ENABLED
for (GLTFSkinIndex skin_i = 0; skin_i < state->skins.size(); ++skin_i) {
Ref<GLTFSkin> skin = state->skins.write[skin_i];
@ -4406,6 +4407,7 @@ Error GLTFDocument::_map_skin_joints_indices_to_skeleton_bone_indices(Ref<GLTFSt
skin->joint_i_to_bone_i.insert(joint_index, bone_index);
}
}
#endif
return OK;
}
@ -4430,6 +4432,7 @@ Error GLTFDocument::_serialize_skins(Ref<GLTFState> state) {
}
Error GLTFDocument::_create_skins(Ref<GLTFState> state) {
#ifdef MODULE_SKELETON_3D_ENABLED
for (GLTFSkinIndex skin_i = 0; skin_i < state->skins.size(); ++skin_i) {
Ref<GLTFSkin> gltf_skin = state->skins.write[skin_i];
@ -4470,10 +4473,12 @@ Error GLTFDocument::_create_skins(Ref<GLTFState> 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> skin_a, const Ref<Skin> 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> skin_a, const Ref<Skin> skin_
return true;
}
#endif
void GLTFDocument::_remove_duplicate_skins(Ref<GLTFState> 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> skin_i = state->skins[i]->pandemonium_skin;
@ -4510,6 +4517,7 @@ void GLTFDocument::_remove_duplicate_skins(Ref<GLTFState> state) {
}
}
}
#endif
}
Error GLTFDocument::_serialize_lights(Ref<GLTFState> state) {
@ -5316,11 +5324,11 @@ void GLTFDocument::_convert_scene_node(Ref<GLTFState> state, Node *p_current, co
if (cast_to<MeshInstance>(p_current)) {
MeshInstance *mi = cast_to<MeshInstance>(p_current);
_convert_mesh_instance_to_gltf(mi, state, gltf_node);
#ifdef MODULE_SKELETON_3D_ENABLED
} else if (cast_to<BoneAttachment>(p_current)) {
BoneAttachment *bone = cast_to<BoneAttachment>(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<Skeleton>(p_current)) {
Skeleton *skel = cast_to<Skeleton>(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<GLTFState> state, Node *scene_parent
Ref<GLTFNode> 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<GLTFState> 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<GLTFState> 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<GLTFState> 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);

View File

@ -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<GLTFState> state);
Error _serialize_skins(Ref<GLTFState> state);
Error _create_skins(Ref<GLTFState> state);
#ifdef MODULE_SKELETON_3D_ENABLED
bool _skins_are_same(const Ref<Skin> skin_a, const Ref<Skin> skin_b);
#endif
void _remove_duplicate_skins(Ref<GLTFState> state);
Error _serialize_cameras(Ref<GLTFState> state);
Error _parse_cameras(Ref<GLTFState> state);

View File

@ -53,8 +53,10 @@ private:
// same parent (ie roots are siblings)
PoolVector<GLTFNodeIndex> 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<String> unique_names;

View File

@ -64,12 +64,14 @@ Ref<Material> 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
}

View File

@ -45,8 +45,10 @@ class ImporterMeshInstance3D : public Spatial {
GDCLASS(ImporterMeshInstance3D, Spatial)
Ref<ImporterMesh> mesh;
#ifdef MODULE_SKELETON_3D_ENABLED
Ref<Skin> skin;
NodePath skeleton_path;
#endif
Vector<Ref<Material>> surface_materials;
protected:
@ -64,8 +66,10 @@ public:
void set_surface_material(int p_idx, const Ref<Material> &p_material);
Ref<Material> 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

View File

@ -124,10 +124,12 @@ void MeshInstance::set_mesh(const Ref<Mesh> &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<Material> &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<Material> &p_material) {

View File

@ -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),

View File

@ -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;