diff options
Diffstat (limited to 'modules/fbx')
| -rw-r--r-- | modules/fbx/data/fbx_mesh_data.cpp | 11 | ||||
| -rw-r--r-- | modules/fbx/editor_scene_importer_fbx.cpp | 34 | ||||
| -rw-r--r-- | modules/fbx/editor_scene_importer_fbx.h | 3 |
3 files changed, 23 insertions, 25 deletions
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp index 643a74f83e..1d59851778 100644 --- a/modules/fbx/data/fbx_mesh_data.cpp +++ b/modules/fbx/data/fbx_mesh_data.cpp @@ -371,6 +371,17 @@ ImporterMeshInstance3D *FBXMeshData::create_fbx_mesh(const ImportState &state, c Array mesh_array = surface->surface_tool->commit_to_arrays(); Array blend_shapes = surface->morphs; + // Enforce blend shape mask array format + for (int i = 0; i < blend_shapes.size(); i++) { + Array bsdata = blend_shapes[i]; + + for (int j = 0; j < Mesh::ARRAY_MAX; j++) { + if (!(Mesh::ARRAY_FORMAT_BLEND_SHAPE_MASK & (1 << j))) { + bsdata[j] = Variant(); + } + } + } + if (surface->material.is_valid()) { mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, mesh_array, blend_shapes, Dictionary(), surface->material, surface->material->get_name()); } else { diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp index 758c47eecc..afaeb15708 100644 --- a/modules/fbx/editor_scene_importer_fbx.cpp +++ b/modules/fbx/editor_scene_importer_fbx.cpp @@ -58,24 +58,8 @@ void EditorSceneFormatImporterFBX::get_extensions(List<String> *r_extensions) const { // register FBX as the one and only format for FBX importing - const String import_setting_string = "filesystem/import/fbx/"; - const String fbx_str = "fbx"; - Vector<String> exts; - exts.push_back(fbx_str); - _register_project_setting_import(fbx_str, import_setting_string, exts, r_extensions, true); -} - -void EditorSceneFormatImporterFBX::_register_project_setting_import(const String generic, - const String import_setting_string, - const Vector<String> &exts, - List<String> *r_extensions, - const bool p_enabled) const { - const String use_generic = "use_" + generic; - _GLOBAL_DEF(import_setting_string + use_generic, p_enabled, true); - if (ProjectSettings::get_singleton()->get(import_setting_string + use_generic)) { - for (int32_t i = 0; i < exts.size(); i++) { - r_extensions->push_back(exts[i]); - } + if (GLOBAL_GET("filesystem/import/fbx/use_fbx")) { + r_extensions->push_back("fbx"); } } @@ -964,7 +948,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene( // extra const required by C++11 colon/Range operator // note: do not use C++17 syntax here for dicts. // this is banned in Godot. - for (std::pair<const std::string, const FBXDocParser::AnimationCurve *> &kvp : curves) { + for (const std::pair<const std::string, const FBXDocParser::AnimationCurve *> &kvp : curves) { const String curve_element = ImportUtils::FBXNodeToName(kvp.first); const FBXDocParser::AnimationCurve *curve = kvp.second; String curve_name = ImportUtils::FBXNodeToName(curve->Name()); @@ -980,7 +964,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene( const std::map<int64_t, float> &track_time = curve->GetValueTimeTrack(); if (track_time.size() > 0) { - for (std::pair<int64_t, float> keyframe : track_time) { + for (const std::pair<const int64_t, float> &keyframe : track_time) { if (curve_element == "d|X") { keyframe_map.keyframes[keyframe.first].x = keyframe.second; } else if (curve_element == "d|Y") { @@ -1089,7 +1073,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene( double max_duration = 0; double anim_length = animation->get_length(); - for (std::pair<int64_t, Vector3> position_key : translation_keys.keyframes) { + for (const std::pair<const int64_t, Vector3> &position_key : translation_keys.keyframes) { pos_values.push_back(position_key.second * state.scale); double animation_track_time = CONVERT_FBX_TIME(position_key.first); @@ -1101,7 +1085,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene( pos_times.push_back(animation_track_time); } - for (std::pair<int64_t, Vector3> scale_key : scale_keys.keyframes) { + for (const std::pair<const int64_t, Vector3> &scale_key : scale_keys.keyframes) { scale_values.push_back(scale_key.second); double animation_track_time = CONVERT_FBX_TIME(scale_key.first); @@ -1136,7 +1120,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene( Quaternion lastQuaternion = Quaternion(); - for (std::pair<int64_t, Vector3> rotation_key : rotation_keys.keyframes) { + for (const std::pair<const int64_t, Vector3> &rotation_key : rotation_keys.keyframes) { double animation_track_time = CONVERT_FBX_TIME(rotation_key.first); //print_verbose("euler rotation key: " + rotation_key.second); @@ -1473,3 +1457,7 @@ Ref<Animation> EditorSceneFormatImporterFBX::import_animation(const String &p_pa int p_bake_fps) { return Ref<Animation>(); } + +EditorSceneFormatImporterFBX::EditorSceneFormatImporterFBX() { + _GLOBAL_DEF("filesystem/import/fbx/use_fbx", true, true); +} diff --git a/modules/fbx/editor_scene_importer_fbx.h b/modules/fbx/editor_scene_importer_fbx.h index eebcb86409..fb72f93feb 100644 --- a/modules/fbx/editor_scene_importer_fbx.h +++ b/modules/fbx/editor_scene_importer_fbx.h @@ -119,10 +119,9 @@ private: template <class T> T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, AssetImportAnimation::Interpolation p_interp); - void _register_project_setting_import(const String generic, const String import_setting_string, const Vector<String> &exts, List<String> *r_extensions, const bool p_enabled) const; public: - EditorSceneFormatImporterFBX() {} + EditorSceneFormatImporterFBX(); ~EditorSceneFormatImporterFBX() {} virtual void get_extensions(List<String> *r_extensions) const override; |