From d7565f65ee8a7043664d12d971cb149e16095729 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Mon, 15 Nov 2021 13:44:57 +0100 Subject: [PATCH 1/9] Add script to download the expolanets dataset for the dataprep task * Python script to download all the columns needed * Update task file. Use strings instead of std::filesystem::path, so that relative paths and tokens can be used --- data/tasks/exoplanets/datapreparation.task | 8 ++-- data/tasks/exoplanets/downloadexodata.py | 39 +++++++++++++++++++ .../tasks/exoplanetsdatapreparationtask.cpp | 12 +++--- 3 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 data/tasks/exoplanets/downloadexodata.py diff --git a/data/tasks/exoplanets/datapreparation.task b/data/tasks/exoplanets/datapreparation.task index dd924210cd..76dec4e2ea 100644 --- a/data/tasks/exoplanets/datapreparation.task +++ b/data/tasks/exoplanets/datapreparation.task @@ -1,11 +1,11 @@ -local dataFolder = "D:/dev/exoplanets data config" +local dataFolder = "D:/data/prepared_exoplanets_data" return { { Type = "ExoplanetsDataPreparationTask", - InputDataFile = dataFolder .. "/exoplanets_data_composite.csv", - InputSPECK = "${SYNC}/http/digitaluniverse_exoplanets_speck/1/expl.speck", - TeffToBvFile = "${SYNC}/http/exoplanets_data/1/teff_bv.txt", + InputDataFile = "${DATA}/tasks/exoplanets/downloaded_exo_data.csv", + InputSPECK = "${SYNC}/http/digitaluniverse_exoplanets_speck/2/expl.speck", + TeffToBvFile = "${SYNC}/http/exoplanets_data/2/teff_bv.txt", OutputBIN = dataFolder .. "/exoplanets_data.bin", OutputLUT = dataFolder .. "/lookup.txt" } diff --git a/data/tasks/exoplanets/downloadexodata.py b/data/tasks/exoplanets/downloadexodata.py new file mode 100644 index 0000000000..9f4ea3c11c --- /dev/null +++ b/data/tasks/exoplanets/downloadexodata.py @@ -0,0 +1,39 @@ +## +# Download most recent exoplanet data from NASA Exoplanet Archive using the TAP service +# More info at: https://exoplanetarchive.ipac.caltech.edu/docs/TAP/usingTAP.html +# +# The data table is the Planetary Systems Composite dataset, where multiple sources have +# been combined into one row per planet. +# https://exoplanetarchive.ipac.caltech.edu/cgi-bin/TblView/nph-tblView?app=ExoTbls&config=PSCompPars +# +# The script downloads the columns needed for the visualization in OpenSpace and for the +# exoplanets datapreparation task, but more columns can be added if needed. +## + +import pandas as pd + +dataFileName = 'downloaded_exo_data.csv' + +# The columns we need for the visualization in OpenSpace +columns = 'pl_name,hostname,pl_letter,sy_snum,sy_pnum,pl_orbsmax,pl_orbsmaxerr1,pl_orbsmaxerr2,' \ + 'pl_orbeccen,pl_orbeccenerr1,pl_orbeccenerr2,pl_orbincl,pl_orbinclerr1,pl_orbinclerr2,' \ + 'pl_orblper,pl_orblpererr1,pl_orblpererr2,pl_orbper,pl_orbpererr1,pl_orbpererr2,' \ + 'pl_radj,pl_radjerr1,pl_radjerr2,pl_tranmid,pl_tranmiderr1,pl_tranmiderr2,ra,dec,' \ + 'sy_dist,st_rad,st_raderr1,st_raderr2,st_teff,st_tefferr1,st_tefferr2,' \ + 'st_lum,st_lumerr1,st_lumerr2,cb_flag,disc_year' + +# This may contain any extra conditions that one might want to fulfill. Start with a '+' sign +where = '' + +### +## Download and save csv file +print("Downloading all confirmed planets from NExSci's Exoplanets Archive... (Planetary Systems Composite Data table)") + +NEW_API = 'https://exoplanetarchive.ipac.caltech.edu/TAP/sync?query=' +url = NEW_API + 'select+' + columns + '+from+pscomppars' + where + '&format=csv' +print(url) +df = pd.read_csv(url) + +print("Writing data to file...") +df.to_csv(dataFileName) +print("Done!") diff --git a/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp b/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp index d817b86285..21d89a4c54 100644 --- a/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp +++ b/modules/exoplanets/tasks/exoplanetsdatapreparationtask.cpp @@ -42,10 +42,10 @@ namespace { struct [[codegen::Dictionary(ExoplanetsDataPreparationTask)]] Parameters { // The csv file to extract data from - std::filesystem::path inputDataFile; + std::string inputDataFile; // The speck file with star locations - std::filesystem::path inputSPECK; + std::string inputSPECK; // The bin file to export data into std::string outputBIN [[codegen::annotation("A valid filepath")]]; @@ -55,7 +55,7 @@ namespace { // The path to a teff to bv conversion file. Should be a txt file where each line // has the format 'teff,bv' - std::filesystem::path teffToBvFile; + std::string teffToBvFile; }; #include "exoplanetsdatapreparationtask_codegen.cpp" } // namespace @@ -71,11 +71,11 @@ ExoplanetsDataPreparationTask::ExoplanetsDataPreparationTask( { const Parameters p = codegen::bake(dictionary); - _inputDataPath = absPath(p.inputDataFile.string()); - _inputSpeckPath = absPath(p.inputSPECK.string()); + _inputDataPath = absPath(p.inputDataFile); + _inputSpeckPath = absPath(p.inputSPECK); _outputBinPath = absPath(p.outputBIN); _outputLutPath = absPath(p.outputLUT); - _teffToBvFilePath = absPath(p.teffToBvFile.string()); + _teffToBvFilePath = absPath(p.teffToBvFile); } std::string ExoplanetsDataPreparationTask::description() { From 73895e4c62c3a8d5f0076b48badebc024a999bba Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Wed, 17 Nov 2021 09:39:03 +0100 Subject: [PATCH 2/9] Fix problems in avoid collision path when start and end position are the same --- .../pathcurves/avoidcollisioncurve.cpp | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/navigation/pathcurves/avoidcollisioncurve.cpp b/src/navigation/pathcurves/avoidcollisioncurve.cpp index 2acd4f744d..5c1c1d2623 100644 --- a/src/navigation/pathcurves/avoidcollisioncurve.cpp +++ b/src/navigation/pathcurves/avoidcollisioncurve.cpp @@ -44,6 +44,8 @@ namespace { constexpr const double AvoidCollisionDistanceRadiusMultiplier = 3.0; constexpr const double CollisionBufferSizeRadiusMultiplier = 1.0; constexpr const int MaxAvoidCollisionSteps = 10; + + constexpr const double Epsilon = 1e-5; } // namespace namespace openspace::interaction { @@ -76,20 +78,23 @@ AvoidCollisionCurve::AvoidCollisionCurve(const Waypoint& start, const Waypoint& _points.push_back(newPos); } - // Add point for moving out if the end state is in opposite direction - glm::dvec3 startToEnd = end.position() - start.position(); - double cosAngleToTarget = glm::dot(normalize(-startViewDir), normalize(startToEnd)); - bool targetInOppositeDirection = cosAngleToTarget > 0.7; + const glm::dvec3 startToEnd = end.position() - start.position(); - if (targetInOppositeDirection) { - const glm::dquat midleRot = glm::slerp(start.rotation(), end.rotation(), 0.5); - const glm::dvec3 middleViewDir = ghoul::viewDirection(midleRot); - const double stepOutDistance = 0.4 * glm::length(startToEnd); + if (glm::length(startToEnd) > 0.0) { + // Add point for moving out if the end state is in opposite direction + double cosAngleToTarget = glm::dot(normalize(-startViewDir), normalize(startToEnd)); + bool targetInOppositeDirection = cosAngleToTarget > 0.7; - glm::dvec3 newPos = start.position() + 0.2 * startToEnd - - stepOutDistance * glm::normalize(middleViewDir); + if (targetInOppositeDirection) { + const glm::dquat midleRot = glm::slerp(start.rotation(), end.rotation(), 0.5); + const glm::dvec3 middleViewDir = ghoul::viewDirection(midleRot); + const double stepOutDistance = 0.4 * glm::length(startToEnd); - _points.push_back(newPos); + glm::dvec3 newPos = start.position() + 0.2 * startToEnd - + stepOutDistance * glm::normalize(middleViewDir); + + _points.push_back(newPos); + } } // Add an extra point to approach target @@ -119,11 +124,15 @@ void AvoidCollisionCurve::removeCollisions(int step) { return; } - const int nSegments = static_cast( _points.size() - 3); + const int nSegments = static_cast(_points.size() - 3); for (int i = 0; i < nSegments; ++i) { const glm::dvec3 lineStart = _points[i + 1]; const glm::dvec3 lineEnd = _points[i + 2]; + if (glm::distance(lineEnd, lineStart) - Epsilon < 0.0) { + continue; // Start and end position are the same. Go to next segment + } + for (SceneGraphNode* node : _relevantNodes) { // Do collision check in relative coordinates, to avoid huge numbers const glm::dmat4 modelTransform = node->modelTransform(); From 51fe17c32018da4ffb5e6d1f7ea82dc88c48b0e5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 21 Nov 2021 00:00:46 +0100 Subject: [PATCH 3/9] Fix an issue where the removal of a screenspacerenderable is published after the screenspace renderable has already been destroyed --- src/rendering/renderengine.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index cf019622db..1cfb61e17c 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -1119,12 +1119,11 @@ void RenderEngine::removeScreenSpaceRenderable(ScreenSpaceRenderable* s) { ); if (it != global::screenSpaceRenderables->end()) { + global::eventEngine->publishEvent(s); s->deinitialize(); global::screenSpaceRootPropertyOwner->removePropertySubOwner(s); global::screenSpaceRenderables->erase(it); } - - global::eventEngine->publishEvent(s); } void RenderEngine::removeScreenSpaceRenderable(const std::string& identifier) { From d1821ae0e412bc760f4cc8abc5f1aaa0757e3291 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Tue, 23 Nov 2021 10:00:51 +0100 Subject: [PATCH 4/9] Add lua functions to get the bounding and interaction sphere values for a SGN --- src/scene/scene.cpp | 14 ++++++++++++++ src/scene/scene_lua.inl | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index f13197155b..5cf74e1ccf 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -915,6 +915,20 @@ scripting::LuaLibrary Scene::luaLibrary() { "string, string", "The scene graph node identified by the first string is reparented to be " "a child of the scene graph node identified by the second string." + }, + { + "boundingSphere", + &luascriptfunctions::boundingSphere, + "string", + "Returns the bounding sphere of the scene graph node with the given " + "string as identifier" + }, + { + "interactionSphere", + &luascriptfunctions::interactionSphere, + "string", + "Returns the interaction sphere of the scene graph node with the given " + "string as identifier" } } }; diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index bd6650045b..384dd85da2 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -926,6 +926,40 @@ int setParent(lua_State* L) { return 0; } +int boundingSphere(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::boundingSphere"); + const std::string identifier = ghoul::lua::value(L); + + SceneGraphNode* node = sceneGraphNode(identifier); + if (!node) { + return ghoul::lua::luaError( + L, + fmt::format("Did not find a match for identifier: {} ", identifier) + ); + } + + double bs = node->boundingSphere(); + ghoul::lua::push(L, bs); + return 1; +} + +int interactionSphere(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::interactionSphere"); + const std::string identifier = ghoul::lua::value(L); + + SceneGraphNode* node = sceneGraphNode(identifier); + if (!node) { + return ghoul::lua::luaError( + L, + fmt::format("Did not find a match for identifier: {} ", identifier) + ); + } + + double is = node->interactionSphere(); + ghoul::lua::push(L, is); + return 1; +} + /** * \ingroup LuaScripts * isBoolValue(const std::string& s): From b41d5efd25c2f4ce3e15607a9ca2a403e9ec65f0 Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Tue, 23 Nov 2021 11:15:59 +0100 Subject: [PATCH 5/9] Extra check to prevent zero length segments in ZoomOutOverview camera path --- src/navigation/pathcurves/zoomoutoverviewcurve.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/navigation/pathcurves/zoomoutoverviewcurve.cpp b/src/navigation/pathcurves/zoomoutoverviewcurve.cpp index 4f96553a44..d0130c857f 100644 --- a/src/navigation/pathcurves/zoomoutoverviewcurve.cpp +++ b/src/navigation/pathcurves/zoomoutoverviewcurve.cpp @@ -64,10 +64,16 @@ ZoomOutOverviewCurve::ZoomOutOverviewCurve(const Waypoint& start, const Waypoint _points.push_back(start.position()); _points.push_back(start.position() + startTangentLength * startTangentDir); + const glm::dvec3 startPosToEndPos = end.position() - start.position(); + constexpr const double Epsilon = 1E-4; + // Zoom out - if (start.nodeIdentifier() != end.nodeIdentifier()) { + if (start.nodeIdentifier() != end.nodeIdentifier() && + glm::length(startPosToEndPos) > Epsilon) + { const glm::dvec3 n1 = startTangentDir; const glm::dvec3 n2 = endTangentDir; + const glm::dvec3 halfWayPos = start.position() + 0.5 * startPosToEndPos; // Decide the step direction for the "overview point" based on the directions // at the start and end of the path, to try to get a nice curve shape @@ -82,7 +88,6 @@ ZoomOutOverviewCurve::ZoomOutOverviewCurve(const Waypoint& start, const Waypoint // Find a direction that is orthogonal to the line between the start and end // position - const glm::dvec3 startPosToEndPos = end.position() - start.position(); const glm::dvec3 outwardStepVector = 0.5 * glm::length(startPosToEndPos) * goodStepDirection; @@ -91,8 +96,8 @@ ZoomOutOverviewCurve::ZoomOutOverviewCurve(const Waypoint& start, const Waypoint const glm::dvec3 stepDirection = glm::normalize(orthogonalComponent); // Step half-way along the line between the position and then orthogonally - const glm::dvec3 extraKnot = start.position() + 0.5 * startPosToEndPos - + 1.5 * glm::length(startPosToEndPos) * stepDirection; + const double stepDistance = 1.5 * glm::length(startPosToEndPos); + const glm::dvec3 extraKnot = halfWayPos + stepDistance * stepDirection; _points.push_back(extraKnot); } From 2c7bbc5deeefc5b6c3b3d46a401b233d4aef556a Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Tue, 23 Nov 2021 11:42:33 +0100 Subject: [PATCH 6/9] Update GUI hash Includes fix for broken touch gui --- data/assets/util/webgui.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/util/webgui.asset b/data/assets/util/webgui.asset index 324e301604..698f491ec7 100644 --- a/data/assets/util/webgui.asset +++ b/data/assets/util/webgui.asset @@ -3,7 +3,7 @@ asset.require('./static_server') local guiCustomization = asset.require('customization/gui') -- Select which commit hashes to use for the frontend and backend -local frontendHash = "913fe364fcd3baa314351dc4e332f9a1bdb340f0" +local frontendHash = "4fe18eea379c8493dbcb2cea6798d09a85819912" local dataProvider = "data.openspaceproject.com/files/webgui" local frontend = asset.syncedResource({ From b966b29c05ff8fc00eda45682e31c1a0080e468c Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 24 Nov 2021 15:31:20 +0100 Subject: [PATCH 7/9] Update SGCT repository to get rid of line ending issues --- apps/OpenSpace/ext/sgct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index d03bd10777..606a5ba8d6 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit d03bd1077704da032fe25ef70c97d19e5c431d11 +Subproject commit 606a5ba8d655e4e0e9a64451cd06a8ea1e10e859 From c1696453a5acb2a16a05563dd260b4aef92332ac Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 25 Nov 2021 09:46:25 +0100 Subject: [PATCH 8/9] Shader compilation fix for newer NVidia drivers --- modules/gaia/shaders/gaia_ssbo_vs.glsl | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/gaia/shaders/gaia_ssbo_vs.glsl b/modules/gaia/shaders/gaia_ssbo_vs.glsl index 67b09bdbdd..812cd8424e 100644 --- a/modules/gaia/shaders/gaia_ssbo_vs.glsl +++ b/modules/gaia/shaders/gaia_ssbo_vs.glsl @@ -41,8 +41,6 @@ layout (std430) buffer ssbo_comb_data { float allData[]; }; -in int gl_VertexID; - out vec2 vs_brightness; out vec4 vs_gPosition; out float vs_starDistFromSun; From 01a04a6faa0ca38552a60604556abe087c75b788 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 26 Nov 2021 14:50:19 +0100 Subject: [PATCH 9/9] Fix missing keybind for taking screenshots (closes #1786) --- data/assets/util/default_keybindings.asset | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/data/assets/util/default_keybindings.asset b/data/assets/util/default_keybindings.asset index b3fdc7ca40..e7e771417d 100644 --- a/data/assets/util/default_keybindings.asset +++ b/data/assets/util/default_keybindings.asset @@ -192,9 +192,14 @@ asset.onInitialize(function() openspace.action.registerAction(action) openspace.bindKey(action.Key, action.Identifier) end + + -- The take screenshot function is a bit special since we want to bind two keys to that action + openspace.bindKey("PRINT_SCREEN", take_screenshot.Identifier) end) asset.onDeinitialize(function () + openspace.clearKey("PRINT_SCREEN") + for _, action in ipairs(Actions) do openspace.action.removeAction(action.Identifier) openspace.clearKey(action.Key)