feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
Import("env_modules")
|
||||
|
|
|
|||
|
|
@ -32,15 +32,11 @@
|
|||
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
#include "editor_scene_importer_ufbx.h"
|
||||
#include "modules/gltf/gltf_document.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor_scene_importer_ufbx.h"
|
||||
|
||||
uint32_t EditorSceneFormatImporterFBX2GLTF::get_import_flags() const {
|
||||
return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
|
||||
}
|
||||
#include "modules/gltf/gltf_document.h"
|
||||
|
||||
void EditorSceneFormatImporterFBX2GLTF::get_extensions(List<String> *r_extensions) const {
|
||||
r_extensions->push_back("fbx");
|
||||
|
|
@ -124,7 +120,7 @@ Node *EditorSceneFormatImporterFBX2GLTF::import_scene(const String &p_path, uint
|
|||
#endif
|
||||
}
|
||||
|
||||
Variant EditorSceneFormatImporterFBX2GLTF::get_option_visibility(const String &p_path, bool p_for_animation,
|
||||
Variant EditorSceneFormatImporterFBX2GLTF::get_option_visibility(const String &p_path, const String &p_scene_import_type,
|
||||
const String &p_option, const HashMap<StringName, Variant> &p_options) {
|
||||
// Remove all the FBX options except for 'fbx/importer' if the importer is fbx2gltf.
|
||||
// These options are available only for ufbx.
|
||||
|
|
|
|||
|
|
@ -42,14 +42,13 @@ class EditorSceneFormatImporterFBX2GLTF : public EditorSceneFormatImporter {
|
|||
GDCLASS(EditorSceneFormatImporterFBX2GLTF, EditorSceneFormatImporter);
|
||||
|
||||
public:
|
||||
virtual uint32_t get_import_flags() const override;
|
||||
virtual void get_extensions(List<String> *r_extensions) const override;
|
||||
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
|
||||
const HashMap<StringName, Variant> &p_options,
|
||||
List<String> *r_missing_deps, Error *r_err = nullptr) override;
|
||||
virtual void get_import_options(const String &p_path,
|
||||
List<ResourceImporter::ImportOption> *r_options) override;
|
||||
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option,
|
||||
virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option,
|
||||
const HashMap<StringName, Variant> &p_options) override;
|
||||
virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@
|
|||
|
||||
#include "core/config/project_settings.h"
|
||||
|
||||
uint32_t EditorSceneFormatImporterUFBX::get_import_flags() const {
|
||||
return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
|
||||
}
|
||||
|
||||
void EditorSceneFormatImporterUFBX::get_extensions(List<String> *r_extensions) const {
|
||||
r_extensions->push_back("fbx");
|
||||
}
|
||||
|
|
@ -88,7 +84,7 @@ Node *EditorSceneFormatImporterUFBX::import_scene(const String &p_path, uint32_t
|
|||
return fbx->generate_scene(state, state->get_bake_fps(), (bool)p_options["animation/trimming"], false);
|
||||
}
|
||||
|
||||
Variant EditorSceneFormatImporterUFBX::get_option_visibility(const String &p_path, bool p_for_animation,
|
||||
Variant EditorSceneFormatImporterUFBX::get_option_visibility(const String &p_path, const String &p_scene_import_type,
|
||||
const String &p_option, const HashMap<StringName, Variant> &p_options) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,14 +46,13 @@ public:
|
|||
FBX_IMPORTER_UFBX,
|
||||
FBX_IMPORTER_FBX2GLTF,
|
||||
};
|
||||
virtual uint32_t get_import_flags() const override;
|
||||
virtual void get_extensions(List<String> *r_extensions) const override;
|
||||
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
|
||||
const HashMap<StringName, Variant> &p_options,
|
||||
List<String> *r_missing_deps, Error *r_err = nullptr) override;
|
||||
virtual void get_import_options(const String &p_path,
|
||||
List<ResourceImporter::ImportOption> *r_options) override;
|
||||
virtual Variant get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option,
|
||||
virtual Variant get_option_visibility(const String &p_path, const String &p_scene_import_type, const String &p_option,
|
||||
const HashMap<StringName, Variant> &p_options) override;
|
||||
virtual void handle_compatibility_options(HashMap<StringName, Variant> &p_import_params) const override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -288,14 +288,8 @@ String FBXDocument::_gen_unique_name(HashSet<String> &unique_names, const String
|
|||
}
|
||||
|
||||
String FBXDocument::_sanitize_animation_name(const String &p_name) {
|
||||
// Animations disallow the normal node invalid characters as well as "," and "["
|
||||
// (See animation/animation_player.cpp::add_animation)
|
||||
|
||||
// TODO: Consider adding invalid_characters or a validate_animation_name to animation_player to mirror Node.
|
||||
String anim_name = p_name.validate_node_name();
|
||||
anim_name = anim_name.replace(",", "");
|
||||
anim_name = anim_name.replace("[", "");
|
||||
return anim_name;
|
||||
return AnimationLibrary::validate_library_name(anim_name);
|
||||
}
|
||||
|
||||
String FBXDocument::_gen_unique_animation_name(Ref<FBXState> p_state, const String &p_name) {
|
||||
|
|
@ -375,21 +369,25 @@ Error FBXDocument::_parse_nodes(Ref<FBXState> p_state) {
|
|||
// all skin clusters connected to the bone.
|
||||
for (const ufbx_connection &child_conn : fbx_node->element.connections_src) {
|
||||
ufbx_skin_cluster *child_cluster = ufbx_as_skin_cluster(child_conn.dst);
|
||||
if (!child_cluster)
|
||||
if (!child_cluster) {
|
||||
continue;
|
||||
}
|
||||
ufbx_skin_deformer *child_deformer = _find_skin_deformer(child_cluster);
|
||||
if (!child_deformer)
|
||||
if (!child_deformer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Found a skin cluster: Now iterate through all the skin clusters of the parent and
|
||||
// try to find one that used by the same deformer.
|
||||
for (const ufbx_connection &parent_conn : fbx_node->parent->element.connections_src) {
|
||||
ufbx_skin_cluster *parent_cluster = ufbx_as_skin_cluster(parent_conn.dst);
|
||||
if (!parent_cluster)
|
||||
if (!parent_cluster) {
|
||||
continue;
|
||||
}
|
||||
ufbx_skin_deformer *parent_deformer = _find_skin_deformer(parent_cluster);
|
||||
if (parent_deformer != child_deformer)
|
||||
if (parent_deformer != child_deformer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Success: Found two skin clusters from the same deformer, now we can resolve the
|
||||
// local bind pose from the difference between the two world-space bind poses.
|
||||
|
|
@ -875,7 +873,7 @@ Error FBXDocument::_parse_meshes(Ref<FBXState> p_state) {
|
|||
const int material = int(fbx_material->typed_id);
|
||||
ERR_FAIL_INDEX_V(material, p_state->materials.size(), ERR_FILE_CORRUPT);
|
||||
Ref<Material> mat3d = p_state->materials[material];
|
||||
ERR_FAIL_NULL_V(mat3d, ERR_FILE_CORRUPT);
|
||||
ERR_FAIL_COND_V(mat3d.is_null(), ERR_FILE_CORRUPT);
|
||||
|
||||
Ref<BaseMaterial3D> base_material = mat3d;
|
||||
if (has_vertex_color && base_material.is_valid()) {
|
||||
|
|
@ -891,7 +889,7 @@ Error FBXDocument::_parse_meshes(Ref<FBXState> p_state) {
|
|||
}
|
||||
mat = mat3d;
|
||||
}
|
||||
ERR_FAIL_NULL_V(mat, ERR_FILE_CORRUPT);
|
||||
ERR_FAIL_COND_V(mat.is_null(), ERR_FILE_CORRUPT);
|
||||
mat_name = mat->get_name();
|
||||
}
|
||||
import_mesh->add_surface(primitive, array, morphs,
|
||||
|
|
@ -1056,7 +1054,7 @@ GLTFImageIndex FBXDocument::_parse_image_save_image(Ref<FBXState> p_state, const
|
|||
}
|
||||
|
||||
Error FBXDocument::_parse_images(Ref<FBXState> p_state, const String &p_base_path) {
|
||||
ERR_FAIL_NULL_V(p_state, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_COND_V(p_state.is_null(), ERR_INVALID_PARAMETER);
|
||||
|
||||
const ufbx_scene *fbx_scene = p_state->scene.get();
|
||||
for (int texture_i = 0; texture_i < static_cast<int>(fbx_scene->texture_files.count); texture_i++) {
|
||||
|
|
@ -1395,7 +1393,7 @@ Error FBXDocument::_parse_animations(Ref<FBXState> p_state) {
|
|||
|
||||
for (const ufbx_baked_node &fbx_baked_node : fbx_baked_anim->nodes) {
|
||||
const GLTFNodeIndex node = fbx_baked_node.typed_id;
|
||||
GLTFAnimation::Track &track = animation->get_tracks()[node];
|
||||
GLTFAnimation::NodeTrack &track = animation->get_node_tracks()[node];
|
||||
|
||||
for (const ufbx_baked_vec3 &key : fbx_baked_node.translation_keys) {
|
||||
track.position_track.times.push_back(float(key.time));
|
||||
|
|
@ -1785,8 +1783,8 @@ void FBXDocument::_import_animation(Ref<FBXState> p_state, AnimationPlayer *p_an
|
|||
|
||||
double anim_start_offset = p_trimming ? double(additional_animation_data["time_begin"]) : 0.0;
|
||||
|
||||
for (const KeyValue<int, GLTFAnimation::Track> &track_i : anim->get_tracks()) {
|
||||
const GLTFAnimation::Track &track = track_i.value;
|
||||
for (const KeyValue<int, GLTFAnimation::NodeTrack> &track_i : anim->get_node_tracks()) {
|
||||
const GLTFAnimation::NodeTrack &track = track_i.value;
|
||||
//need to find the path: for skeletons, weight tracks will affect the mesh
|
||||
NodePath node_path;
|
||||
//for skeletons, transform tracks always affect bones
|
||||
|
|
@ -2017,6 +2015,7 @@ void FBXDocument::_process_mesh_instances(Ref<FBXState> p_state, Node *p_scene_r
|
|||
ERR_CONTINUE_MSG(skeleton == nullptr, vformat("Unable to find Skeleton for node %d skin %d", node_i, skin_i));
|
||||
|
||||
mi->get_parent()->remove_child(mi);
|
||||
mi->set_owner(nullptr);
|
||||
skeleton->add_child(mi, true);
|
||||
mi->set_owner(skeleton->get_owner());
|
||||
|
||||
|
|
@ -2114,13 +2113,9 @@ Error FBXDocument::_parse(Ref<FBXState> p_state, String p_path, Ref<FileAccess>
|
|||
return OK;
|
||||
}
|
||||
|
||||
void FBXDocument::_bind_methods() {
|
||||
}
|
||||
|
||||
Node *FBXDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, bool p_trimming, bool p_remove_immutable_tracks) {
|
||||
Ref<FBXState> state = p_state;
|
||||
ERR_FAIL_COND_V(state.is_null(), nullptr);
|
||||
ERR_FAIL_NULL_V(state, nullptr);
|
||||
ERR_FAIL_INDEX_V(0, state->root_nodes.size(), nullptr);
|
||||
p_state->set_bake_fps(p_bake_fps);
|
||||
GLTFNodeIndex fbx_root = state->root_nodes.write[0];
|
||||
|
|
@ -2248,7 +2243,7 @@ Error FBXDocument::append_from_file(String p_path, Ref<GLTFState> p_state, uint3
|
|||
Error err;
|
||||
Ref<FileAccess> file = FileAccess::open(p_path, FileAccess::READ, &err);
|
||||
ERR_FAIL_COND_V(err != OK, ERR_FILE_CANT_OPEN);
|
||||
ERR_FAIL_NULL_V(file, ERR_FILE_CANT_OPEN);
|
||||
ERR_FAIL_COND_V(file.is_null(), ERR_FILE_CANT_OPEN);
|
||||
String base_path = p_base_path;
|
||||
if (base_path.is_empty()) {
|
||||
base_path = p_path.get_base_dir();
|
||||
|
|
|
|||
|
|
@ -61,9 +61,6 @@ public:
|
|||
PackedByteArray generate_buffer(Ref<GLTFState> p_state) override;
|
||||
Error write_to_filesystem(Ref<GLTFState> p_state, const String &p_path) override;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
String _get_texture_path(const String &p_base_directory, const String &p_source_file_path) const;
|
||||
void _process_uv_set(PackedVector2Array &uv_array);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
||||
static void _editor_init() {
|
||||
Ref<EditorSceneFormatImporterUFBX> import_fbx;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue