Revert "Merge branch 'master' into old"

This reverts commit 9763c4b1b3.
This commit is contained in:
K. S. Ernest (iFire) Lee 2021-11-28 16:54:44 -08:00
parent 9763c4b1b3
commit 988f4a90be
5 changed files with 26 additions and 45 deletions

View File

@ -11,7 +11,3 @@ You need to install the MVSC redistributable on Windows. https://support.microso
## Build Instructions ## Build Instructions
Reference the Github workflow. Reference the Github workflow.
```bash
conan install . -i build -s build_type=Release -s compiler.cppstd=17 -s compiler.runtime=static --build=missing
```

View File

@ -32,12 +32,11 @@ func _import_scene(path: String, flags: int, bake_fps: int):
ProjectSettings.add_property_info(property_info) ProjectSettings.add_property_info(property_info)
var user_path_base = OS.get_user_data_dir() var user_path_base = OS.get_user_data_dir()
var path_global : String = ProjectSettings.globalize_path(path) var path_global : String = ProjectSettings.globalize_path(path)
var output_path : String = "res://.godot/imported/" + path.get_file().get_basename() + "-" + path.md5_text() + ".gltf" var output_path : String = "res://.godot/imported/" + path.get_file().get_basename() + "-" + path.md5_text() + ".glb"
var output_path_global = ProjectSettings.globalize_path(output_path) var output_path_global = ProjectSettings.globalize_path(output_path)
var stdout = [].duplicate() var stdout = [].duplicate()
var temp_dir_global = ProjectSettings.globalize_path("res://.godot/imported/") var temp_dir_global = ProjectSettings.globalize_path("res://.godot/imported/")
var ret = OS.execute(fbx2gltf_path, [ var ret = OS.execute(fbx2gltf_path, [
"--keep-originals",
"--fbx-temp-dir", temp_dir_global, "--fbx-temp-dir", temp_dir_global,
"-i", path_global, "-i", path_global,
"-o", output_path_global], stdout, true) "-o", output_path_global], stdout, true)

View File

@ -40,8 +40,9 @@ int main(int argc, char* argv[]) {
exit(0); exit(0);
}); });
app.add_option("FBX Model", gltfOptions.inputPath, "The FBX model to convert.")->check(CLI::ExistingFile); std::string inputPath;
app.add_option("-i,--input", gltfOptions.inputPath, "The FBX model to convert.")->check(CLI::ExistingFile); app.add_option("FBX Model", inputPath, "The FBX model to convert.")->check(CLI::ExistingFile);
app.add_option("-i,--input", inputPath, "The FBX model to convert.")->check(CLI::ExistingFile);
std::string outputPath; std::string outputPath;
app.add_option("-o,--output", outputPath, "Where to generate the output, without suffix."); app.add_option("-o,--output", outputPath, "Where to generate the output, without suffix.");
@ -51,12 +52,6 @@ int main(int argc, char* argv[]) {
gltfOptions.embedResources, gltfOptions.embedResources,
"Inline buffers as data:// URIs within generated non-binary glTF."); "Inline buffers as data:// URIs within generated non-binary glTF.");
app.add_flag(
"--keep-originals",
gltfOptions.keepOriginals,
"Keep the originals paths in a non-binary glTF.");
app.add_flag( app.add_flag(
"-t,--separate-textures", gltfOptions.separateTextures, "Write texture files out separately"); "-t,--separate-textures", gltfOptions.separateTextures, "Write texture files out separately");
@ -296,7 +291,7 @@ int main(int argc, char* argv[]) {
} }
} }
if (gltfOptions.inputPath.empty()) { if (inputPath.empty()) {
fmt::printf("You must supply a FBX file to convert.\n"); fmt::printf("You must supply a FBX file to convert.\n");
exit(1); exit(1);
} }
@ -314,7 +309,7 @@ int main(int argc, char* argv[]) {
if (outputPath.empty()) { if (outputPath.empty()) {
// if -o is not given, default to the basename of the .fbx // if -o is not given, default to the basename of the .fbx
outputPath = "./" + FileUtils::GetFileBase(gltfOptions.inputPath); outputPath = "./" + FileUtils::GetFileBase(inputPath);
} }
// the output folder in .gltf mode, not used for .glb // the output folder in .gltf mode, not used for .glb
std::string outputFolder; std::string outputFolder;
@ -354,10 +349,10 @@ int main(int argc, char* argv[]) {
RawModel raw; RawModel raw;
if (verboseOutput) { if (verboseOutput) {
fmt::printf("Loading FBX File: %s\n", gltfOptions.inputPath); fmt::printf("Loading FBX File: %s\n", inputPath);
} }
if (!LoadFBXFile(raw, gltfOptions.inputPath, {"png", "jpg", "jpeg"}, gltfOptions)) { if (!LoadFBXFile(raw, inputPath, {"png", "jpg", "jpeg"}, gltfOptions)) {
fmt::fprintf(stderr, "ERROR:: Failed to parse FBX: %s\n", gltfOptions.inputPath); fmt::fprintf(stderr, "ERROR:: Failed to parse FBX: %s\n", inputPath);
return 1; return 1;
} }
@ -399,7 +394,7 @@ int main(int argc, char* argv[]) {
assert(!outputFolder.empty()); assert(!outputFolder.empty());
const std::string binaryPath = outputFolder + FileUtils::GetFileBase(gltfOptions.inputPath) + extBufferFilename; const std::string binaryPath = outputFolder + extBufferFilename;
FILE* fp = fopen(binaryPath.c_str(), "wb"); FILE* fp = fopen(binaryPath.c_str(), "wb");
if (fp == nullptr) { if (fp == nullptr) {
fmt::fprintf(stderr, "ERROR:: Couldn't open file '%s' for writing.\n", binaryPath); fmt::fprintf(stderr, "ERROR:: Couldn't open file '%s' for writing.\n", binaryPath);

View File

@ -78,7 +78,6 @@ enum class AnimationFramerateOptions {
* User-supplied options that dictate the nature of the glTF being generated. * User-supplied options that dictate the nature of the glTF being generated.
*/ */
struct GltfOptions { struct GltfOptions {
std::string inputPath;
/** /**
* If negative, disabled. Otherwise, a bitfield of RawVertexAttributes that * If negative, disabled. Otherwise, a bitfield of RawVertexAttributes that
* specify the largest set of attributes that'll ever be kept for a vertex. * specify the largest set of attributes that'll ever be kept for a vertex.
@ -91,8 +90,6 @@ struct GltfOptions {
/** If non-binary, whether to inline all resources, for a single (large) .glTF file. */ /** If non-binary, whether to inline all resources, for a single (large) .glTF file. */
bool embedResources{false}; bool embedResources{false};
bool keepOriginals{false};
bool separateTextures{true}; bool separateTextures{true};
/** Whether and how to use KHR_draco_mesh_compression to minimize static geometry size. */ /** Whether and how to use KHR_draco_mesh_compression to minimize static geometry size. */

View File

@ -185,18 +185,7 @@ std::shared_ptr<TextureData> TextureBuilder::simple(int rawTexIndex, const std::
const std::string textureName = FileUtils::GetFileBase(rawTexture.name); const std::string textureName = FileUtils::GetFileBase(rawTexture.name);
const std::string relativeFilename = FileUtils::GetFileName(rawTexture.fileLocation); const std::string relativeFilename = FileUtils::GetFileName(rawTexture.fileLocation);
ImageData* image = nullptr; ImageData* image = nullptr;
if (options.keepOriginals && !relativeFilename.empty()) { if (options.outputBinary) {
image = new ImageData(textureName, relativeFilename);
} else if (options.keepOriginals && relativeFilename.empty()) {
std::string inputPathBase = FileUtils::GetFileBase(options.inputPath);
std::string outputPath = inputPathBase + "/textures/" + textureName;
image = new ImageData(textureName, outputPath);
if (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) {
if (verboseOutput) {
fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath);
}
}
} else if (options.outputBinary) {
auto bufferView = gltf.AddBufferViewForFile(*gltf.defaultBuffer, rawTexture.fileLocation); auto bufferView = gltf.AddBufferViewForFile(*gltf.defaultBuffer, rawTexture.fileLocation);
if (bufferView) { if (bufferView) {
const auto& suffix = FileUtils::GetFileSuffix(rawTexture.fileLocation); const auto& suffix = FileUtils::GetFileSuffix(rawTexture.fileLocation);
@ -212,17 +201,22 @@ std::shared_ptr<TextureData> TextureBuilder::simple(int rawTexIndex, const std::
} }
image = new ImageData(relativeFilename, *bufferView, mimeType); image = new ImageData(relativeFilename, *bufferView, mimeType);
} }
} else if (!relativeFilename.empty()) { } else if (!relativeFilename.empty()) {
image = new ImageData(relativeFilename, relativeFilename);
std::string outputPath = outputFolder + "/" + relativeFilename; std::string outputPath = outputFolder + "/" + relativeFilename;
if (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) { auto dstAbs = FileUtils::GetAbsolutePath(outputPath);
if (verboseOutput) { image = new ImageData(relativeFilename, relativeFilename);
fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath); auto srcAbs = FileUtils::GetAbsolutePath(rawTexture.fileLocation);
if (!FileUtils::FileExists(outputPath) && srcAbs != dstAbs) {
if (FileUtils::CopyFile(rawTexture.fileLocation, outputPath, true)) {
if (verboseOutput) {
fmt::printf("Copied texture '%s' to output folder: %s\n", textureName, outputPath);
}
} else {
// no point commenting further on read/write error; CopyFile() does enough of that, and we
// certainly want to to add an image struct to the glTF JSON, with the correct relative
// path reference, even if the copy failed.
} }
} else {
// no point commenting further on read/write error; CopyFile() does enough of that, and we
// certainly want to to add an image struct to the glTF JSON, with the correct relative path
// reference, even if the copy failed.
} }
} }
if (!image) { if (!image) {