diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index fb0ad85061..7d7114da0a 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -106,6 +106,7 @@ private: void runGlobalCustomizationScripts(); void configureLogging(); + std::string generateFilePath(std::string openspaceRelativePath); std::unique_ptr _scene; std::unique_ptr _assetManager; diff --git a/scripts/convertProfileToScene.lua b/scripts/convertProfileToScene.lua index 1321dd52a5..bc1d34de86 100644 --- a/scripts/convertProfileToScene.lua +++ b/scripts/convertProfileToScene.lua @@ -464,10 +464,11 @@ parsingSections = { {section = "MarkNodes", func = parseMarkNodes} } -profileFilename = openspace.profile.getFilename() -profilePath = openspace.profile.getPath() +profilePathIn = openspace.profile.getProfileInputPath() +scenePathOut = openspace.profile.getSceneOutputPath() -assetOut = profilePath..".scene" +profileIn = profilePathIn..".profile" +assetOut = scenePathOut..".scene" -local resultTable = parseProfile(profilePath) +local resultTable = parseProfile(profileIn) generateAsset(resultTable, assetOut) diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 4e858562ed..43578a1f58 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -301,24 +301,8 @@ void OpenSpaceEngine::initialize() { global::configuration.profile)); ghoul::lua::LuaState lState; - // Generate path to temp dir where output .scene file will reside. - // Needs to handle either windows (which seems to require double back-slashes) - // or unix path slashes. - std::string outputScenePath = absPath("${TEMPORARY}"); - const std::string search = "\\"; - const std::string replace = "\\\\"; - if (outputScenePath.find(search) != std::string::npos) { - size_t start_pos = 0; - while((start_pos = outputScenePath.find(search, start_pos)) != std::string::npos) { - outputScenePath.replace(start_pos, search.length(), replace); - start_pos += replace.length(); - } - outputScenePath.append(replace); - } - else { - outputScenePath.append("/"); - } - outputScenePath.append(global::configuration.profile); + std::string inputProfilePath = generateFilePath("${BASE}/data/assets"); + std::string outputScenePath = generateFilePath("${TEMPORARY}"); std::string setProfileFilenameInLuaState = fmt::format(R"( openspace = {{}} @@ -326,11 +310,14 @@ void OpenSpaceEngine::initialize() { function openspace.profile.getFilename() return "{}.profile" end - function openspace.profile.getPath() + function openspace.profile.getProfileInputPath() + return "{}" + end + function openspace.profile.getSceneOutputPath() return "{}" end )", - global::configuration.profile, outputScenePath + global::configuration.profile, inputProfilePath, outputScenePath ); ghoul::lua::runScript(lState, setProfileFilenameInLuaState); @@ -385,6 +372,26 @@ void OpenSpaceEngine::initialize() { LTRACE("OpenSpaceEngine::initialize(end)"); } +std::string OpenSpaceEngine::generateFilePath(std::string openspaceRelativePath) { + std::string path = absPath(openspaceRelativePath); + // Needs to handle either windows (which seems to require double back-slashes) + // or unix path slashes. + const std::string search = "\\"; + const std::string replace = "\\\\"; + if (path.find(search) != std::string::npos) { + size_t start_pos = 0; + while ((start_pos = path.find(search, start_pos)) != std::string::npos) { + path.replace(start_pos, search.length(), replace); + start_pos += replace.length(); + } + path.append(replace); + } + else { + path.append("/"); + } + return path.append(global::configuration.profile); +} + void OpenSpaceEngine::initializeGL() { LTRACE("OpenSpaceEngine::initializeGL(begin)");