From 797c674f127dadc195d445cb48c84b55c7911ade Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 20 Dec 2019 14:12:25 -0700 Subject: [PATCH] Moved profile-to-asset conversion to openspaceengine and using temp dir --- apps/OpenSpace/main.cpp | 39 ---------------------------------- src/engine/openspaceengine.cpp | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 80e24ffba6..0c2db5f9e4 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -84,9 +84,6 @@ constexpr const char* _loggerCat = "main"; constexpr const char* SpoutTag = "Spout"; constexpr const char* OpenVRTag = "OpenVR"; -constexpr const char* ProfileToSceneConverter - = "${BASE}/scripts/convertProfileToScene.lua"; - sgct::Engine* SgctEngine; sgct::SharedVector _synchronizationBuffer; @@ -1187,42 +1184,6 @@ int main(int argc, char** argv) { parseLuaState(global::configuration); } - // Convert profile to scene file (if was provided in configuration file) - if (!global::configuration.profile.empty()) { - LINFO(fmt::format("Run Lua script to convert {}.profile to scene", - global::configuration.profile)); - ghoul::lua::LuaState lState; - - // Get path where .scene files reside. Need to add extra escape slashes to - // accomodate lua parser. - std::string outputScenePath = absPath("${BASE}/data/assets"); - std::string search = "\\"; - std::string replace = "\\\\"; - for (std::string::size_type i = outputScenePath.find(search); - i != std::string::npos; - i = outputScenePath.find(search, i)) - { - outputScenePath.replace(i, search.length(), replace); - i += replace.length(); - } - - std::string setProfileFilenameInLuaState = fmt::format(R"( - openspace = {{}} - openspace.profile = {{}} - function openspace.profile.getFilename() - return "{}.profile" - end - function openspace.profile.getPath() - return "{}" - end - )", - global::configuration.profile, outputScenePath - ); - - ghoul::lua::runScript(lState, setProfileFilenameInLuaState); - ghoul::lua::runScriptFile(lState, absPath(ProfileToSceneConverter)); - } - // Determining SGCT configuration file LDEBUG("SGCT Configuration file: " + global::configuration.windowConfiguration); diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index d62d07937d..e393807bc2 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -98,6 +98,9 @@ namespace { constexpr const char* _loggerCat = "OpenSpaceEngine"; constexpr const int CacheVersion = 1; + constexpr const char* ProfileToSceneConverter + = "${BASE}/scripts/convertProfileToScene.lua"; + } // namespace namespace openspace { @@ -292,6 +295,42 @@ void OpenSpaceEngine::initialize() { LDEBUG("Registering Lua libraries"); registerCoreClasses(global::scriptEngine); + // Convert profile to scene file (if was provided in configuration file) + if (!global::configuration.profile.empty()) { + LINFO(fmt::format("Run Lua script to convert {}.profile to scene", + global::configuration.profile)); + ghoul::lua::LuaState lState; + + // Get path where .scene files reside. Need to add extra escape slashes to + // accomodate lua parser. + std::string outputScenePath = absPath("${TEMPORARY}"); + std::string search = "\\"; + std::string replace = "\\\\"; + for (std::string::size_type i = outputScenePath.find(search); + i != std::string::npos; + i = outputScenePath.find(search, i)) + { + outputScenePath.replace(i, search.length(), replace); + i += replace.length(); + } + + std::string setProfileFilenameInLuaState = fmt::format(R"( + openspace = {{}} + openspace.profile = {{}} + function openspace.profile.getFilename() + return "{}.profile" + end + function openspace.profile.getPath() + return "{}" + end + )", + global::configuration.profile, outputScenePath + ); + + ghoul::lua::runScript(lState, setProfileFilenameInLuaState); + ghoul::lua::runScriptFile(lState, absPath(ProfileToSceneConverter)); + } + // Set up asset loader std::unique_ptr w = std::make_unique();