From 18d2dc5c00da84bdc5c14733c166ecf8298a813d Mon Sep 17 00:00:00 2001 From: "Herholz, Sebastian" Date: Wed, 18 Sep 2024 18:42:11 +0200 Subject: [PATCH] [viewer] The opglv files does not require to set a root directory anymore all file path can now be relative to the .opglv file that is loaded --- tools/openpgl-viewer/src/data/Data.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/openpgl-viewer/src/data/Data.cpp b/tools/openpgl-viewer/src/data/Data.cpp index 22d1542..c978bc6 100644 --- a/tools/openpgl-viewer/src/data/Data.cpp +++ b/tools/openpgl-viewer/src/data/Data.cpp @@ -7,6 +7,11 @@ #include using json = nlohmann::json; +std::string get_path(std::string filename) +{ + return filename.substr(0, filename.find_last_of("/\\")); +} + void Data::init() { m_device = new openpgl::cpp::Device(PGL_DEVICE_TYPE_CPU_4); @@ -16,7 +21,12 @@ void Data::load(std::string filename) { std::ifstream f(filename); json data = json::parse(f); - std::string rootDir = data["root"]; + std::string rootDir = ""; + if(data.contains("root")) + rootDir = data["root"]; + else { + rootDir = get_path(filename); + } std::string cameraFile = data["camera"]; std::string fieldFile = data["field"]; std::string samplesFile = data["samples"];