Skip to content

Commit

Permalink
Merge pull request #59998 from akien-mga/fbx-blend-importers-path-han…
Browse files Browse the repository at this point in the history
…dling
  • Loading branch information
akien-mga authored Apr 7, 2022
2 parents 5a912b0 + d4b54e3 commit ae2d53c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions modules/gltf/editor/editor_scene_importer_blend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
List<String> *r_missing_deps, Error *r_err) {
// Get global paths for source and sink.

const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path);
// Escape paths to be valid Python strings to embed in the script.
const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape();
const String sink = ProjectSettings::get_singleton()->get_imported_files_path().plus_file(
vformat("%s-%s.gltf", p_path.get_file().get_basename(), p_path.md5_text()));
const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink);
const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink).c_escape();

// Handle configuration options.

Expand Down
11 changes: 7 additions & 4 deletions modules/gltf/editor/editor_scene_importer_fbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t
List<String> *r_missing_deps, Error *r_err) {
// Get global paths for source and sink.

const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path);
// Don't use `c_escape()` as it can generate broken paths. These paths will be
// enclosed in double quotes by OS::execute(), so we only need to escape those.
// `c_escape_multiline()` seems to do this (escapes `\` and `"` only).
const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape_multiline();
const String sink = ProjectSettings::get_singleton()->get_imported_files_path().plus_file(
vformat("%s-%s.glb", p_path.get_file().get_basename(), p_path.md5_text()));
const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink);
const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink).c_escape_multiline();

// Run fbx2gltf.

Expand All @@ -65,9 +68,9 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t
List<String> args;
args.push_back("--pbr-metallic-roughness");
args.push_back("--input");
args.push_back(vformat("\"%s\"", source_global));
args.push_back(source_global);
args.push_back("--output");
args.push_back(vformat("\"%s\"", sink_global));
args.push_back(sink_global);
args.push_back("--binary");

String standard_out;
Expand Down

0 comments on commit ae2d53c

Please sign in to comment.