fix: generate json in non-binary glTF path
This commit is contained in:
@@ -248,18 +248,27 @@ bool write_gltf(const std::string& filepath, const mesh::HalfedgeMesh& mesh,
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// ── glTF JSON + separate .bin ──
|
// ── glTF JSON + separate .bin ──
|
||||||
std::ofstream file(filepath);
|
// Determine bin filename from output path
|
||||||
if (!file) return false;
|
|
||||||
file << json;
|
|
||||||
|
|
||||||
// Write separate bin
|
|
||||||
std::string dot = ".";
|
std::string dot = ".";
|
||||||
size_t dot_pos = filepath.rfind(dot);
|
size_t dot_pos = filepath.rfind(dot);
|
||||||
std::string binpath;
|
std::string binpath;
|
||||||
if (dot_pos != std::string::npos)
|
std::string bin_basename;
|
||||||
|
if (dot_pos != std::string::npos) {
|
||||||
binpath = filepath.substr(0, dot_pos) + ".bin";
|
binpath = filepath.substr(0, dot_pos) + ".bin";
|
||||||
else
|
// Extract just the filename
|
||||||
|
size_t slash_pos = binpath.rfind('/');
|
||||||
|
bin_basename = (slash_pos != std::string::npos)
|
||||||
|
? binpath.substr(slash_pos + 1) : binpath;
|
||||||
|
} else {
|
||||||
binpath = filepath + ".bin";
|
binpath = filepath + ".bin";
|
||||||
|
bin_basename = binpath;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string json = generate_json(mesh, options, layout, bin_basename);
|
||||||
|
|
||||||
|
std::ofstream file(filepath);
|
||||||
|
if (!file) return false;
|
||||||
|
file << json;
|
||||||
|
|
||||||
std::ofstream bin(binpath, std::ios::binary);
|
std::ofstream bin(binpath, std::ios::binary);
|
||||||
if (!bin) return false;
|
if (!bin) return false;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "vde/foundation/io_gltf.h"
|
#include "vde/foundation/io_gltf.h"
|
||||||
#include "vde/brep/modeling.h"
|
#include "vde/brep/modeling.h"
|
||||||
|
#include "vde/brep/modeling.h"
|
||||||
|
|
||||||
using namespace vde::foundation;
|
using namespace vde::foundation;
|
||||||
using namespace vde::mesh;
|
using namespace vde::mesh;
|
||||||
|
|||||||
Reference in New Issue
Block a user