From 79a3b42d065ffcaf235163f533df38558ef9ad11 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 19 Feb 2020 09:13:08 -0700 Subject: [PATCH 01/67] Added pre-2000 date tests to globebrowsing timequantizer --- modules/globebrowsing/src/timequantizer.h | 2 +- tests/test_timequantizer.cpp | 36 +++++++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/modules/globebrowsing/src/timequantizer.h b/modules/globebrowsing/src/timequantizer.h index 3f7df6c176..f8907e3359 100644 --- a/modules/globebrowsing/src/timequantizer.h +++ b/modules/globebrowsing/src/timequantizer.h @@ -371,13 +371,13 @@ private: void verifyResolutionRestrictions(const int value, const char unit); double diff(DateTime& from, DateTime& to); void doFirstApproximation(DateTime& q, DateTime& unQ, double value, char unit); - RangedTime _timerange; double computeSecondsFromResolution(const int valueIn, const char unit); double _resolution = 0.0; double _resolutionValue = 0.0; char _resolutionUnit = 'd'; DateTime _dt; DateTime _start; + RangedTime _timerange; }; } // namespace openspace::globebrowsing diff --git a/tests/test_timequantizer.cpp b/tests/test_timequantizer.cpp index 29ae664101..d97f845c98 100644 --- a/tests/test_timequantizer.cpp +++ b/tests/test_timequantizer.cpp @@ -65,7 +65,6 @@ namespace { std::string expectedType, bool expectFailure) { std::string res; - const std::string search = "Invalid resolution "; try { tq.setResolution(resolution); } @@ -74,11 +73,10 @@ namespace { } if (expectFailure) { - REQUIRE(res.find(search) != std::string::npos); REQUIRE(res.find(expectedType) != std::string::npos); } else { - REQUIRE(res.find(search) == std::string::npos); + REQUIRE(res.find(expectedType) == std::string::npos); } } @@ -274,6 +272,37 @@ TEST_CASE("TimeQuantizer: Test hours & minutes resolution", "[timequantizer]") { SpiceManager::deinitialize(); } +TEST_CASE("TimeQuantizer: Test pre-2000 dates", "[timequantizer]") { + SpiceManager::initialize(); + + loadLSKKernel(); + globebrowsing::TimeQuantizer t1; + Time testT; + + t1.setStartEndRange("1000-01-01T00:00:00", "2001-01-01T00:00:00"); + t1.setResolution("1d"); + + singleTimeTest(testT, t1, true, "1980-02-28T16:10:00", "1980-02-28T00:00:00.000"); + singleTimeTest(testT, t1, true, "1930-04-30T22:00:00", "1930-04-30T00:00:00.000"); + singleTimeTest(testT, t1, true, "1910-05-31T00:00:00", "1910-05-31T00:00:00.000"); + singleTimeTest(testT, t1, true, "1969-09-30T12:00:00", "1969-09-30T00:00:00.000"); + singleTimeTest(testT, t1, true, "1900-11-30T20:11:07", "1900-11-30T00:00:00.000"); + singleTimeTest(testT, t1, true, "1800-04-30T22:00:20", "1800-04-30T00:00:00.000"); + singleTimeTest(testT, t1, true, "1799-07-31T02:13:17", "1799-07-31T00:00:00.000"); + singleTimeTest(testT, t1, true, "1860-01-30T22:00:00", "1860-01-30T00:00:00.000"); + singleTimeTest(testT, t1, true, "1944-04-12T05:55:55", "1944-04-12T00:00:00.000"); + singleTimeTest(testT, t1, true, "1000-01-01T00:00:00", "1000-01-01T00:00:00.000"); + singleTimeTest(testT, t1, true, "1999-04-30T22:00:00", "1999-04-30T00:00:00.000"); + singleTimeTest(testT, t1, true, "1999-12-31T23:59:59", "1999-12-31T00:00:00.000"); + singleTimeTest(testT, t1, true, "2000-01-01T11:59:59", "2000-01-01T00:00:00.000"); + singleTimeTest(testT, t1, true, "2000-01-01T12:00:00", "2000-01-01T00:00:00.000"); + singleTimeTest(testT, t1, true, "2000-01-01T12:00:01", "2000-01-01T00:00:00.000"); + singleTimeTest(testT, t1, true, "2000-01-01T00:00:00", "2000-01-01T00:00:00.000"); + singleTimeTest(testT, t1, true, "2000-01-02T00:00:00", "2000-01-02T00:00:00.000"); + + SpiceManager::deinitialize(); +} + TEST_CASE("TimeQuantizer: Test valid resolutions", "[timequantizer]") { SpiceManager::initialize(); @@ -322,6 +351,7 @@ TEST_CASE("TimeQuantizer: Test start time using constructor", "[timequantizer]") singleStartTimeTest("2017-01-28T12:00:00", "Invalid start time value", true); singleStartTimeTest("2017-01-28T00:01:00", "Invalid start time value", true); singleStartTimeTest("2017-01-28T00:00:01", "Invalid start time value", true); + singleStartTimeTest("1980-01-20T00:00:00", "Invalid start", false); SpiceManager::deinitialize(); } From addfa65fa66cf33ff55ee32aa7f2d620dfe62798 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 19 Feb 2020 09:25:33 -0700 Subject: [PATCH 02/67] Merge with latest master --- CMakeLists.txt | 38 +- LICENSE.md | 2 +- apps/OpenSpace-MinVR/main.cpp | 2 +- apps/OpenSpace/CMakeLists.txt | 6 +- apps/Sync/main.cpp | 2 +- apps/TaskRunner/main.cpp | 2 +- apps/TimelineView/CMakeLists.txt | 63 --- apps/TimelineView/common.h | 37 -- apps/TimelineView/configurationwidget.cpp | 86 ---- apps/TimelineView/configurationwidget.h | 53 --- apps/TimelineView/controlwidget.cpp | 319 -------------- apps/TimelineView/controlwidget.h | 69 --- apps/TimelineView/informationwidget.cpp | 50 --- apps/TimelineView/informationwidget.h | 41 -- apps/TimelineView/main.cpp | 160 ------- apps/TimelineView/mainwindow.cpp | 398 ------------------ apps/TimelineView/mainwindow.h | 74 ---- apps/TimelineView/timelinewidget.cpp | 304 ------------- apps/TimelineView/timelinewidget.h | 72 ---- data/assets/base.asset | 7 +- .../messenger/mercurymagnetosphere.asset | 2 +- .../moon/map_service_configs/LiU/Kaguya.vrt | 28 ++ .../moon/map_service_configs/Utah/Kaguya.vrt | 28 ++ .../solarsystem/planets/earth/moon/moon.asset | 12 +- .../planets/earth/moon/trail.asset | 3 +- .../Utah/MagellanMosaic.vrt | 28 ++ .../solarsystem/planets/venus/venus.asset | 10 +- data/assets/util/webgui.asset | 2 +- ext/ghoul | 2 +- .../openspace/interaction/keybindingmanager.h | 1 - .../openspace/interaction/navigationhandler.h | 1 + .../interaction/sessionrecording.inl | 12 +- include/openspace/interaction/touchbar.h | 2 +- .../atmosphere/shaders/atmosphere_common.glsl | 6 +- .../shaders/atmosphere_deferred_fs.glsl | 27 +- .../atmosphere/shaders/deltaJ_calc_fs.glsl | 3 +- .../shaders/inScattering_calc_fs.glsl | 3 +- .../shaders/irradiance_sup_calc_fs.glsl | 3 +- .../shaders/transmittance_calc_fs.glsl | 3 +- .../rendering/renderableplaneimagelocal.cpp | 3 +- modules/base/rendering/renderablesphere.cpp | 6 +- modules/base/rotation/staticrotation.cpp | 6 +- .../shaders/renderabletrail_apple_fs.glsl | 2 +- .../shaders/renderabletrail_apple_vs.glsl | 2 +- modules/base/shaders/renderabletrail_fs.glsl | 3 +- modules/base/timeframe/timeframeinterval.cpp | 3 +- modules/cefwebgui/cefwebguimodule.cpp | 6 +- modules/cefwebgui/shaders/gui_fs.glsl | 2 +- modules/cefwebgui/shaders/gui_vs.glsl | 2 +- .../rendering/renderablebillboardscloud.cpp | 3 +- .../rendering/renderabledumeshes.cpp | 3 +- .../digitaluniverse/shaders/billboard_gs.glsl | 21 +- .../digitaluniverse/shaders/points_fs.glsl | 3 +- .../renderablefieldlinessequence.cpp | 9 +- .../shaders/fieldlinessequence_vs.glsl | 6 +- modules/fieldlinessequence/util/commons.cpp | 6 +- .../util/kameleonfieldlinehelper.cpp | 15 +- modules/gaia/shaders/gaia_billboard_ge.glsl | 6 +- modules/gaia/shaders/gaia_point_ge.glsl | 4 +- modules/gaia/shaders/gaia_ssbo_vs.glsl | 3 +- .../shaders/gaia_tonemapping_point_fs.glsl | 3 +- modules/gaia/shaders/gaia_vbo_vs.glsl | 3 +- modules/galaxy/shaders/galaxyraycast.glsl | 2 +- .../galaxy/shaders/raycasterbounds_fs.glsl | 4 +- modules/globebrowsing/shaders/blending.hglsl | 6 +- .../globebrowsing/shaders/smviewer_fs.glsl | 2 +- .../globebrowsing/shaders/smviewer_vs.glsl | 2 +- modules/globebrowsing/src/lrucache.inl | 3 +- modules/globebrowsing/src/renderableglobe.cpp | 2 +- modules/imgui/src/guiassetcomponent.cpp | 3 +- modules/imgui/src/guiiswacomponent.cpp | 16 +- modules/imgui/src/guiparallelcomponent.cpp | 3 +- modules/iswa/rendering/datacygnet.cpp | 9 +- modules/iswa/rendering/dataplane.cpp | 8 +- modules/iswa/rendering/datasphere.cpp | 6 +- modules/iswa/rendering/iswacygnet.cpp | 3 +- modules/iswa/rendering/iswadatagroup.cpp | 9 +- modules/iswa/rendering/iswakameleongroup.cpp | 3 +- modules/iswa/rendering/kameleonplane.cpp | 15 +- modules/iswa/rendering/texturecygnet.cpp | 6 +- modules/iswa/shaders/dataplane_fs.glsl | 3 +- modules/iswa/shaders/datasphere_fs.glsl | 2 +- modules/iswa/shaders/datasphere_vs.glsl | 2 +- modules/iswa/util/dataprocessor.cpp | 6 +- modules/iswa/util/iswamanager.cpp | 50 ++- modules/iswa/util/iswamanager_lua.inl | 12 +- modules/kameleon/src/kameleonhelper.cpp | 21 +- modules/kameleon/src/kameleonwrapper.cpp | 57 ++- .../kameleonvolume/kameleonvolumereader.cpp | 12 +- .../rendering/renderablekameleonvolume.cpp | 6 +- .../rendering/brickselection.cpp | 3 +- .../rendering/errorhistogrammanager.cpp | 6 +- .../rendering/histogrammanager.cpp | 6 +- .../rendering/localerrorhistogrammanager.cpp | 30 +- .../rendering/localtfbrickselector.cpp | 39 +- .../rendering/renderablemultiresvolume.cpp | 30 +- .../rendering/shenbrickselector.cpp | 21 +- .../rendering/simpletfbrickselector.cpp | 30 +- .../rendering/tfbrickselector.cpp | 36 +- modules/multiresvolume/rendering/tsp.cpp | 3 +- modules/multiresvolume/shaders/boundsFs.glsl | 2 +- modules/multiresvolume/shaders/boundsVs.glsl | 2 +- modules/multiresvolume/shaders/helper.glsl | 2 +- modules/multiresvolume/shaders/raycast.glsl | 2 +- modules/server/src/connection.cpp | 6 +- modules/server/src/serverinterface.cpp | 3 +- .../server/src/topics/authorizationtopic.cpp | 6 +- .../server/src/topics/documentationtopic.cpp | 6 +- .../server/src/topics/setpropertytopic.cpp | 15 +- modules/server/src/topics/shortcuttopic.cpp | 3 +- .../space/rendering/renderablesmallbody.cpp | 46 +- modules/space/rendering/renderablestars.cpp | 50 ++- modules/space/rendering/renderablestars.h | 16 +- modules/space/shaders/convolution_fs.glsl | 2 +- modules/space/shaders/convolution_vs.glsl | 2 +- modules/space/shaders/debrisViz_fs.glsl | 7 +- modules/space/shaders/debrisViz_vs.glsl | 2 +- modules/space/shaders/psfToTexture_fs.glsl | 2 +- modules/space/shaders/psfToTexture_vs.glsl | 2 +- modules/space/shaders/star_fs.glsl | 24 +- .../space/tasks/generatedebrisvolumetask.cpp | 2 +- .../space/tasks/generatedebrisvolumetask.h | 10 +- modules/space/translation/tletranslation.cpp | 6 +- .../rendering/renderableplanetprojection.cpp | 6 +- .../shaders/dilation_fs.glsl | 2 +- .../shaders/dilation_vs.glsl | 2 +- .../shaders/renderableModelDepth_fs.glsl | 2 +- .../shaders/renderableModelDepth_vs.glsl | 2 +- .../renderablePlanetProjection_fs.glsl | 4 +- .../shaders/terminatorshadow_vs.glsl | 3 +- .../util/instrumentdecoder.cpp | 3 +- modules/sync/syncmodule.cpp | 3 +- modules/sync/syncs/urlsynchronization.cpp | 15 +- modules/touch/ext/CMakeLists.txt | 8 +- modules/touch/src/win32_touch.cpp | 5 +- modules/toyvolume/shaders/boundsfs.glsl | 2 +- modules/toyvolume/shaders/boundsvs.glsl | 2 +- modules/toyvolume/shaders/raycast.glsl | 2 +- .../rendering/renderabletimevaryingvolume.cpp | 6 +- modules/volume/shaders/boundsfs.glsl | 2 +- modules/volume/shaders/boundsvs.glsl | 2 +- modules/volume/shaders/helper.glsl | 2 +- modules/volume/shaders/raycast.glsl | 2 +- modules/volume/volumesampler.inl | 9 +- modules/webbrowser/CMakeLists.txt | 11 +- .../cmake/patch/cmake/cef_variables.cmake | 2 +- .../webbrowser/shaders/screenspace_fs.glsl | 2 +- .../webbrowser/shaders/screenspace_vs.glsl | 2 +- modules/webbrowser/src/processhelpermac.cpp | 2 +- modules/webbrowser/src/webrenderhandler.cpp | 6 +- modules/webbrowser/webbrowsermodule.cpp | 6 +- modules/webgui/webguimodule.cpp | 3 +- shaders/PowerScaling/powerScalingMath.hglsl | 2 +- shaders/PowerScaling/powerScaling_fs.hglsl | 2 +- shaders/PowerScaling/powerScaling_vs.hglsl | 2 +- shaders/abuffer/abufferfragment.glsl | 2 +- shaders/abuffer/abufferresources.glsl | 2 +- shaders/abuffer/boundsabuffer.frag | 2 +- shaders/abuffer/raycasterdata.glsl | 2 +- shaders/abuffer/renderabuffer.frag | 2 +- shaders/abuffer/renderabuffer.vert | 2 +- shaders/abuffer/resolveabuffer.frag | 2 +- shaders/abuffer/resolveabuffer.vert | 2 +- shaders/abuffer/resolvehelpers.glsl | 2 +- shaders/blending.glsl | 2 +- shaders/floatoperations.glsl | 2 +- shaders/fragment.glsl | 2 +- shaders/framebuffer/exitframebuffer.frag | 2 +- shaders/framebuffer/fxaa.frag | 2 +- shaders/framebuffer/fxaa.vert | 2 +- shaders/framebuffer/hdrAndFiltering.frag | 2 +- shaders/framebuffer/hdrAndFiltering.vert | 2 +- shaders/framebuffer/inside.glsl | 2 +- .../framebuffer/mergeDownscaledVolume.frag | 2 +- .../framebuffer/mergeDownscaledVolume.vert | 2 +- shaders/framebuffer/nOneStripMSAA.frag | 4 +- shaders/framebuffer/nOneStripMSAA.vert | 2 +- shaders/framebuffer/outside.glsl | 2 +- shaders/framebuffer/raycastframebuffer.frag | 2 +- shaders/framebuffer/renderframebuffer.frag | 2 +- shaders/framebuffer/resolveframebuffer.vert | 2 +- shaders/hdr.glsl | 2 +- shaders/rand.glsl | 2 +- src/documentation/documentationengine.cpp | 3 +- src/engine/downloadmanager.cpp | 9 +- src/engine/openspaceengine.cpp | 9 +- src/interaction/navigationhandler.cpp | 28 +- src/interaction/sessionrecording.cpp | 15 +- src/interaction/touchbar.mm | 2 +- src/network/parallelpeer.cpp | 3 +- src/network/parallelserver.cpp | 3 +- src/openspace.cpp | 2 +- src/properties/matrix/dmat4x3property.cpp | 3 +- src/properties/matrix/mat2property.cpp | 3 +- src/properties/matrix/mat3property.cpp | 3 +- src/properties/matrix/mat3x2property.cpp | 5 +- src/properties/matrix/mat3x4property.cpp | 3 +- src/properties/matrix/mat4property.cpp | 3 +- src/properties/matrix/mat4x2property.cpp | 3 +- src/properties/matrix/mat4x3property.cpp | 3 +- src/properties/propertyowner.cpp | 12 +- src/rendering/abufferrenderer.cpp | 3 +- src/rendering/framebufferrenderer.cpp | 176 +++++++- src/rendering/luaconsole.cpp | 3 +- src/rendering/renderable.cpp | 3 +- src/rendering/screenspacerenderable.cpp | 3 +- src/rendering/transferfunction.cpp | 15 +- src/scene/assetloader.cpp | 6 +- src/scene/scene.cpp | 4 +- src/scene/scene_lua.inl | 1 - src/scene/scenegraphnode.cpp | 3 +- src/scene/scenelicensewriter.cpp | 3 +- src/scripting/scriptengine.cpp | 9 +- src/scripting/scriptengine_lua.inl | 9 +- src/util/camera.cpp | 16 +- src/util/histogram.cpp | 6 +- src/util/httprequest.cpp | 9 +- src/util/taskloader.cpp | 3 +- src/util/time_lua.inl | 18 +- src/util/timemanager.cpp | 9 +- src/util/touch.cpp | 2 +- src/util/transformationmanager.cpp | 6 +- src/util/versionchecker.cpp | 3 +- support/cmake/openspace_header.template | 2 +- .../set_openspace_compile_settings.cmake | 23 +- support/coding/check_style_guide.py | 4 +- support/coding/convert_tabs.py | 2 +- support/coding/count_includes.py | 2 +- support/coding/new_files.py | 6 +- support/coding/remove_byte_order_mark.py | 2 +- 230 files changed, 1151 insertions(+), 2270 deletions(-) delete mode 100644 apps/TimelineView/CMakeLists.txt delete mode 100644 apps/TimelineView/common.h delete mode 100644 apps/TimelineView/configurationwidget.cpp delete mode 100644 apps/TimelineView/configurationwidget.h delete mode 100644 apps/TimelineView/controlwidget.cpp delete mode 100644 apps/TimelineView/controlwidget.h delete mode 100644 apps/TimelineView/informationwidget.cpp delete mode 100644 apps/TimelineView/informationwidget.h delete mode 100644 apps/TimelineView/main.cpp delete mode 100644 apps/TimelineView/mainwindow.cpp delete mode 100644 apps/TimelineView/mainwindow.h delete mode 100644 apps/TimelineView/timelinewidget.cpp delete mode 100644 apps/TimelineView/timelinewidget.h create mode 100644 data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/LiU/Kaguya.vrt create mode 100644 data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.vrt create mode 100644 data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.vrt diff --git a/CMakeLists.txt b/CMakeLists.txt index 215dfa5b16..ee78a175b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ project(OpenSpace) set(OPENSPACE_VERSION_MAJOR 0) set(OPENSPACE_VERSION_MINOR 15) -set(OPENSPACE_VERSION_PATCH 0) +set(OPENSPACE_VERSION_PATCH 1) set(OPENSPACE_VERSION_STRING "Beta-5") @@ -50,7 +50,7 @@ message(STATUS "CMake version: ${CMAKE_VERSION}") # Bail out if the user tries to generate a 32 bit project. if (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8) message(FATAL_ERROR "OpenSpace can only be generated for 64 bit architectures.") -endif() +endif () ########################################################################################## # Cleanup project # @@ -63,7 +63,7 @@ if (NOT EXISTS ${OPENSPACE_EXT_DIR}/ghoul/CMakeLists.txt) "git submodule update --init --recursive \n" "to download the missing dependencies." ) -endif() +endif () set_property(GLOBAL PROPERTY USE_FOLDERS On) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER CMake) @@ -106,10 +106,34 @@ if (NOT OPENSPACE_GIT_STATUS_RETURN EQUAL 0) set(OPENSPACE_GIT_STATUS "uncommitted changes") else() set(OPENSPACE_GIT_STATUS "") -endif() +endif () option(OPENSPACE_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF) +if (MSVC) + option(OPENSPACE_OPTIMIZATION_ENABLE_AVX "Enable AVX instruction set for compilation" OFF) + option(OPENSPACE_OPTIMIZATION_ENABLE_AVX2 "Enable AVX2 instruction set for compilation" OFF) + option(OPENSPACE_OPTIMIZATION_ENABLE_AVX512 "Enable AVX2 instruction set for compilation" OFF) + option(OPENSPACE_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS "Enable other optimizations, like LTCG, intrinsics, etc") + + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX AND OPENSPACE_OPTIMIZATION_ENABLE_AVX2) + message(FATAL_ERROR "Cannot enable AVX and AVX2 instructions simultaneously") + endif () + + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX AND OPENSPACE_OPTIMIZATION_ENABLE_AVX512) + message(FATAL_ERROR "Cannot enable AVX and AVX512 instructions simultaneously") + endif () + + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX2 AND OPENSPACE_OPTIMIZATION_ENABLE_AVX512) + message(FATAL_ERROR "Cannot enable AVX2 and AVX512 instructions simultaneously") + endif () + + set(GHOUL_OPTIMIZATION_ENABLE_AVX ${OPENSPACE_OPTIMIZATION_ENABLE_AVX} CACHE BOOL "" FORCE) + set(GHOUL_OPTIMIZATION_ENABLE_AVX2 ${OPENSPACE_OPTIMIZATION_ENABLE_AVX2} CACHE BOOL "" FORCE) + set(GHOUL_OPTIMIZATION_ENABLE_AVX512 ${OPENSPACE_OPTIMIZATION_ENABLE_AVX512} CACHE BOOL "" FORCE) + set(GHOUL_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS ${OPENSPACE_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS} CACHE BOOL "" FORCE) +endif () + include(src/CMakeLists.txt) ########################################################################################## @@ -127,11 +151,12 @@ if (APPLE) target_link_libraries(openspace-core ${CARBON_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COCOA_LIBRARY} ${APP_SERVICES_LIBRARY}) end_dependency() -endif() +endif () # Ghoul add_subdirectory(${OPENSPACE_EXT_DIR}/ghoul) target_link_libraries(openspace-core Ghoul) +set_openspace_compile_settings(Ghoul) set_folder_location(Lua "External") set_folder_location(lz4 "External") set_folder_location(GhoulTest "Unit Tests") @@ -158,7 +183,7 @@ else () target_link_libraries(openspace-core ${CURL_LIBRARIES}) target_compile_definitions(openspace-core PUBLIC "OPENSPACE_CURL_ENABLED") endif () -endif() +endif () end_dependency() # Qt @@ -204,7 +229,6 @@ if (MSVC) target_include_directories(openspace-core PUBLIC "${OPENSPACE_NVTOOLS_PATH}/include") end_dependency() endif () - endif () begin_header("Configuring Modules") diff --git a/LICENSE.md b/LICENSE.md index 65a49a2e5b..4e0881c01c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2014-2019 +Copyright (c) 2014-2020 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software diff --git a/apps/OpenSpace-MinVR/main.cpp b/apps/OpenSpace-MinVR/main.cpp index c2d857cc7c..cd1191434b 100644 --- a/apps/OpenSpace-MinVR/main.cpp +++ b/apps/OpenSpace-MinVR/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index 9eb5283c01..267eb2c182 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -61,7 +61,7 @@ if (OPENSPACE_OPENVR_SUPPORT) ) endif () end_header("Dependency: OpenVR") -endif() +endif () ##### # Spout @@ -78,9 +78,9 @@ endif () ##### if (APPLE) set(MACOSX_BUNDLE_ICON_FILE openspace.icns) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version" FORCE) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version" FORCE) set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep" CACHE STRING "Other Code Signing Flags" FORCE) -endif() +endif () create_new_application(OpenSpace ${SGCT_OPENVR_FILES} diff --git a/apps/Sync/main.cpp b/apps/Sync/main.cpp index 8661f900af..7ea54a745a 100644 --- a/apps/Sync/main.cpp +++ b/apps/Sync/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/apps/TaskRunner/main.cpp b/apps/TaskRunner/main.cpp index c7b89253c5..f41d8105ab 100644 --- a/apps/TaskRunner/main.cpp +++ b/apps/TaskRunner/main.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/apps/TimelineView/CMakeLists.txt b/apps/TimelineView/CMakeLists.txt deleted file mode 100644 index 38edbf98f5..0000000000 --- a/apps/TimelineView/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -########################################################################################## -# # -# OpenSpace # -# # -# Copyright (c) 2014-2020 # -# # -# Permission is hereby granted, free of charge, to any person obtaining a copy of this # -# software and associated documentation files (the "Software"), to deal in the Software # -# without restriction, including without limitation the rights to use, copy, modify, # -# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # -# permit persons to whom the Software is furnished to do so, subject to the following # -# conditions: # -# # -# The above copyright notice and this permission notice shall be included in all copies # -# or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # -# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # -# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # -# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE # -# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -########################################################################################## - -include(${OPENSPACE_CMAKE_EXT_DIR}/application_definition.cmake) - -set(APPLICATION_NAME TimelineView) -set(APPLICATION_LINK_TO_OPENSPACE OFF) - -set(SOURCE_FILES - ${OPENSPACE_APPS_DIR}/TimelineView/main.cpp - ${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.cpp - ${OPENSPACE_APPS_DIR}/TimelineView/configurationwidget.cpp - ${OPENSPACE_APPS_DIR}/TimelineView/informationwidget.cpp - ${OPENSPACE_APPS_DIR}/TimelineView/controlwidget.cpp - ${OPENSPACE_APPS_DIR}/TimelineView/timelinewidget.cpp -) - -set(HEADER_FILES - ${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.h - ${OPENSPACE_APPS_DIR}/TimelineView/configurationwidget.h - ${OPENSPACE_APPS_DIR}/TimelineView/controlwidget.h - ${OPENSPACE_APPS_DIR}/TimelineView/informationwidget.h - ${OPENSPACE_APPS_DIR}/TimelineView/mainwindow.h - ${OPENSPACE_APPS_DIR}/TimelineView/timelinewidget.h -) - -find_package(Qt5Widgets) -find_package(Qt5Network) - -set(MOC_FILES "") -qt5_wrap_cpp(MOC_FILES ${HEADER_FILES}) - -create_new_application(${APPLICATION_NAME} MACOSX_BUNDLE ${SOURCE_FILES} ${HEADER_FILES} ${MOC_FILES}) - -target_link_libraries(${APPLICATION_NAME} Qt5::Widgets Qt5::Network) - -#if (APPLE) -# INSTALL(CODE " -# include(BundleUtilities) -# fixup_bundle(\"${application_path}/bin/openspace/Debug/Launcher.app/Contents/MacOS/Launcher\" \"${application_path}/bin/openspace/Debug/TimelineView.app/Contents/plugins/platforms/libqcocoa.dylib\" \"\") -# " COMPONENT Runtime) -#endif () diff --git a/apps/TimelineView/common.h b/apps/TimelineView/common.h deleted file mode 100644 index e10eb25822..0000000000 --- a/apps/TimelineView/common.h +++ /dev/null @@ -1,37 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__ - -struct Image { - double beginning; - double ending; - std::string beginningString; - std::string endingString; - std::string target; - std::vector instruments; -}; - -#endif // __OPENSPACE_APP_TIMELINEVIEW___COMMON___H__ diff --git a/apps/TimelineView/configurationwidget.cpp b/apps/TimelineView/configurationwidget.cpp deleted file mode 100644 index d7833c6125..0000000000 --- a/apps/TimelineView/configurationwidget.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include "configurationwidget.h" - -#include -#include -#include -#include - -ConfigurationWidget::ConfigurationWidget(QWidget* parent) - : QWidget(parent) - , _ipAddress(new QLineEdit("localhost")) - , _port(new QLineEdit("20500")) - , _connect(new QPushButton("Connect")) -{ - _connect->setObjectName("connection"); - QGroupBox* box = new QGroupBox("Connection", this); - - QGridLayout* layout = new QGridLayout; - layout->setVerticalSpacing(0); - { - QLabel* t = new QLabel("IP Address"); - t->setObjectName("label"); - layout->addWidget(t, 0, 0); - } - layout->addWidget(_ipAddress, 1, 0); - - { - QLabel* t = new QLabel("Port"); - t->setObjectName("label"); - layout->addWidget(t, 0, 1); - } - layout->addWidget(_port, 1, 1); - layout->addWidget(_connect, 1, 2, 1, 1); - - box->setLayout(layout); - - QHBoxLayout* l = new QHBoxLayout; - l->addWidget(box); - setLayout(l); - QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton())); - - QTimer::singleShot(100, this, SLOT(onConnectButton())); -} - -void ConfigurationWidget::onConnectButton() { - emit connect(_ipAddress->text(), _port->text()); -} - -void ConfigurationWidget::socketConnected() { - _ipAddress->setEnabled(false); - _port->setEnabled(false); - _connect->setText("Disconnect"); - QObject::disconnect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton())); - QObject::connect(_connect, SIGNAL(clicked()), this, SIGNAL(disconnect())); -} - -void ConfigurationWidget::socketDisconnected() { - _ipAddress->setEnabled(true); - _port->setEnabled(true); - _connect->setText("Connect"); - QObject::disconnect(_connect, SIGNAL(clicked()), this, SIGNAL(disconnect())); - QObject::connect(_connect, SIGNAL(clicked()), this, SLOT(onConnectButton())); -} diff --git a/apps/TimelineView/configurationwidget.h b/apps/TimelineView/configurationwidget.h deleted file mode 100644 index 23e3600daa..0000000000 --- a/apps/TimelineView/configurationwidget.h +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__ - -#include -#include -#include - -class ConfigurationWidget : public QWidget { -Q_OBJECT -public: - ConfigurationWidget(QWidget* parent); - - void socketConnected(); - void socketDisconnected(); - -signals: - void connect(QString host, QString port); - void disconnect(); - -private slots: - void onConnectButton(); - -private: - QLineEdit* _ipAddress; - QLineEdit* _port; - QPushButton* _connect; -}; - -#endif // __OPENSPACE_APP_TIMELINEVIEW___CONFIGURATIONWIDGET___H__ diff --git a/apps/TimelineView/controlwidget.cpp b/apps/TimelineView/controlwidget.cpp deleted file mode 100644 index 29125e8752..0000000000 --- a/apps/TimelineView/controlwidget.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include "controlwidget.h" - -#include "mainwindow.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace { - struct ImportantDate { - QString date; - QString focus; - QString coordinateSystem; - }; - - const ImportantDate ImportantDates[] = { - { "", "", "" }, - { "2007-02-27T16:40:00.00", "JupiterProjection", "Jupiter" }, - { "2015-07-14T10:10:00.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T10:50:00.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T11:22:00.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T11:36:40.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T11:48:43.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T12:04:35.00", "PlutoProjection", "Pluto" }, - { "2015-07-14T15:02:46.00", "PlutoProjection", "Pluto" } - }; - - struct FocusNode { - QString guiName; - QString name; - QString coordinateSystem; - }; - const FocusNode FocusNodes[] = { - { "Earth", "Earth", "Sun" }, - { "Sun", "Sun", "Sun" }, - { "Pluto", "PlutoProjection", "Pluto" }, - { "Charon", "Charon", "Pluto" }, - { "Jupiter", "JupiterProjection", "Jupiter" }, - { "Nix", "Nix", "Pluto" }, - { "Kerberos", "Kerberos", "Pluto" }, - { "Hydra", "Hydra", "Pluto" }, - }; -} - -ControlWidget::ControlWidget(QWidget* parent) - : QWidget(parent) - , _currentTime(new QLabel("")) - , _setTime(new QComboBox) - , _currentDelta(new QLabel("")) - , _setDelta(new QSlider(Qt::Horizontal)) - , _pause(new QPushButton("Pause")) - , _play(new QPushButton("Play")) - , _focusNode(new QComboBox) - , _setFocusToNextTarget(new QPushButton("Set Focus to the next Target")) - , _setFocusToNewHorizons(new QPushButton("Set Focus to New Horizons")) -{ - _pause->setObjectName("pause"); - _play->setObjectName("play"); - - _currentTime->setObjectName("value"); - _currentDelta->setObjectName("value"); - - for (const ImportantDate& d : ImportantDates) - _setTime->addItem(d.date); - QObject::connect( - _setTime, - SIGNAL(currentIndexChanged(int)), - this, - SLOT(onDateChange()) - ); - - for (const FocusNode& f : FocusNodes) - _focusNode->addItem(f.guiName); - QObject::connect( - _focusNode, - SIGNAL(currentIndexChanged(int)), - this, - SLOT(onFocusChange()) - ); - - _setDelta->setMinimum(-100); - _setDelta->setMaximum(100); - _setDelta->setValue(0); - QObject::connect( - _setDelta, - SIGNAL(valueChanged(int)), - this, - SLOT(onValueChange()) - ); - - QObject::connect( - _pause, - SIGNAL(clicked()), - this, - SLOT(onPauseButton()) - ); - - QObject::connect( - _play, - SIGNAL(clicked()), - this, - SLOT(onPlayButton()) - ); - - QObject::connect( - _setFocusToNextTarget, - SIGNAL(clicked()), - this, - SLOT(onFocusToTargetButton()) - ); - - QObject::connect( - _setFocusToNewHorizons, - SIGNAL(clicked()), - this, - SLOT(onFocusToNewHorizonsButton()) -); - - QVBoxLayout* mainLayout = new QVBoxLayout; - - { - QGroupBox* box = new QGroupBox("Time", this); - QGridLayout* layout = new QGridLayout; - - //layout->setRowStretch(1, 5); - box->setLayout(layout); - - { - QLabel* l = new QLabel("Current Time (UTC):"); - l->setObjectName("label"); - layout->addWidget(l, 0, 0, Qt::AlignLeft); - layout->addWidget(_currentTime, 0, 1, Qt::AlignRight); - } - { - QLabel* l = new QLabel("Bookmarked Times:"); - l->setObjectName("label"); - layout->addWidget(l, 1, 0, Qt::AlignLeft); - layout->addWidget(_setTime, 1, 1, Qt::AlignRight); - } - layout->addItem(new QSpacerItem(0, 7), 2, 0, 1, 2); - { - QLabel* l = new QLabel("Current Time Increment\n(seconds per second):"); - l->setObjectName("label"); - layout->addWidget(l, 3, 0, Qt::AlignLeft); - layout->addWidget(_currentDelta, 3, 1, Qt::AlignRight); - } - - _setDelta->setObjectName("background"); - layout->addWidget(_setDelta, 4, 0, 1, 2); - - QWidget* controlContainer = new QWidget; - controlContainer->setObjectName("background"); - QHBoxLayout* controlContainerLayout = new QHBoxLayout; - controlContainerLayout->addWidget(_pause); - controlContainerLayout->addWidget(_play); - controlContainer->setLayout(controlContainerLayout); - layout->addWidget(controlContainer, 5, 0, 1, 2); - - mainLayout->addWidget(box); - } - - { - QGroupBox* box = new QGroupBox("Focus"); - QGridLayout* layout = new QGridLayout; - box->setLayout(layout); - - { - QLabel* l = new QLabel("Set Focus:"); - l->setObjectName("label"); - layout->addWidget(l, 0, 0, Qt::AlignLeft); - _focusNode->setMinimumWidth(200); - layout->addWidget(_focusNode, 0, 1, Qt::AlignRight); - } - layout->addWidget(_setFocusToNextTarget, 1, 0, 1, 2); - layout->addWidget(_setFocusToNewHorizons, 2, 0, 1, 2); - - mainLayout->addWidget(box); - } - - setLayout(mainLayout); -} - -void ControlWidget::update(QString currentTime, QString currentDelta) { - currentTime.replace("T", " "); - _currentTime->setText(currentTime); - _currentDelta->setText(currentDelta); -} - -void ControlWidget::onValueChange() { - float value = static_cast(_setDelta->value()); - - float delta; - if (value < 0.f) { - value = -value; - float d = pow(3, value / 10) - 1.f; - delta = -d; - } - else { - float d = pow(3, value / 10) - 1.f; - delta = d; - } - - QString script = "openspace.time.setDeltaTime(" + QString::number(delta) + ");"; - emit scriptActivity(script); -} - -void ControlWidget::onPauseButton() { - QString script = "openspace.time.setPause(true);"; - emit scriptActivity(script); -} - -void ControlWidget::onPlayButton() { - QString script = "openspace.time.setPause(false);"; - emit scriptActivity(script); -} - -void ControlWidget::onDateChange() { - int index = _setTime->currentIndex(); - if (index != 0) { - QString date = ImportantDates[index].date; - QString focus = ImportantDates[index].focus; - QString coordinateSystem = ImportantDates[index].coordinateSystem; - QString script = - "openspace.time.setTime('" + date + "');\ - openspace.setPropertyValue('Interaction.origin', '" + focus + "');\ - openspace.setPropertyValue('Interaction.coordinateSystem', '" + - coordinateSystem + "')"; - emit scriptActivity(script); - } - _setTime->blockSignals(true); - _setTime->setCurrentIndex(0); - _setTime->blockSignals(false); -} - -void ControlWidget::onFocusChange() { - int index = _focusNode->currentIndex(); - QString name = FocusNodes[index].name; - QString coordinateSystem = FocusNodes[index].coordinateSystem; - QString script = "openspace.setPropertyValue('Interaction.origin', '" + name + - "');openspace.setPropertyValue('Interaction.coordinateSystem', '" + - coordinateSystem + "');"; - emit scriptActivity(script); -} - -void ControlWidget::onFocusToTargetButton() { - std::string target = reinterpret_cast(parent())->nextTarget(); - if (!target.empty()) { - auto it = std::find_if( - std::begin(FocusNodes), - std::end(FocusNodes), - [target](const FocusNode& n) { - return n.guiName.toLower() == QString::fromStdString(target).toLower(); - }); - if (it != std::end(FocusNodes)) { - QString name = it->name; - QString coordinateSystem = it->coordinateSystem; - QString script = - "openspace.setPropertyValue('Interaction.origin', '" + name + - "');openspace.setPropertyValue('Interaction.coordinateSystem', '" + - coordinateSystem + "');"; - emit scriptActivity(script); - } - } -} - -void ControlWidget::onFocusToNewHorizonsButton() { - QString coordinateSystem; - int date = _currentTime->text().left(4).toInt(); - if (date < 2008) - coordinateSystem = "Jupiter"; - else if (date < 2014) - coordinateSystem = "Sun"; - else - coordinateSystem = "Pluto"; - - QString script = "openspace.setPropertyValue('Interaction.origin', 'NewHorizons');\ - openspace.setPropertyValue('Interaction.coordinateSystem', '" + coordinateSystem + - "');"; - emit scriptActivity(script); -} - -void ControlWidget::socketConnected() { - setDisabled(false); -} - -void ControlWidget::socketDisconnected() { - setDisabled(true); -} - diff --git a/apps/TimelineView/controlwidget.h b/apps/TimelineView/controlwidget.h deleted file mode 100644 index 7d0017a28b..0000000000 --- a/apps/TimelineView/controlwidget.h +++ /dev/null @@ -1,69 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ - -#include - -class QComboBox; -class QLabel; -class QPushButton; -class QSlider; - -class ControlWidget : public QWidget { -Q_OBJECT -public: - ControlWidget(QWidget* parent); - - void update(QString currentTime, QString currentDelta); - - void socketConnected(); - void socketDisconnected(); - -signals: - void scriptActivity(QString script); - -private slots: - void onValueChange(); - void onDateChange(); - void onFocusChange(); - void onPauseButton(); - void onPlayButton(); - void onFocusToTargetButton(); - void onFocusToNewHorizonsButton(); - -private: - QLabel* _currentTime; - QComboBox* _setTime; - QLabel* _currentDelta; - QSlider* _setDelta; - QPushButton* _pause; - QPushButton* _play; - QComboBox* _focusNode; - QPushButton* _setFocusToNextTarget; - QPushButton* _setFocusToNewHorizons; -}; - -#endif // __OPENSPACE_APP_TIMELINEVIEW___CONTROLWIDGET___H__ diff --git a/apps/TimelineView/informationwidget.cpp b/apps/TimelineView/informationwidget.cpp deleted file mode 100644 index f866ad1b28..0000000000 --- a/apps/TimelineView/informationwidget.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include "informationwidget.h" - -#include -#include - -InformationWidget::InformationWidget(QWidget* parent) - : QTextEdit(parent) -{ - setReadOnly(true); -} - -void InformationWidget::socketConnected() { - setDisabled(false); -} - -void InformationWidget::socketDisconnected() { - setDisabled(true); -} - -void InformationWidget::logInformation(QString text) { - QString currentText = toPlainText(); - - currentText += text + "\n"; - - setPlainText(currentText); -} diff --git a/apps/TimelineView/informationwidget.h b/apps/TimelineView/informationwidget.h deleted file mode 100644 index a19ee41fb8..0000000000 --- a/apps/TimelineView/informationwidget.h +++ /dev/null @@ -1,41 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ - -#include - -class InformationWidget : public QTextEdit { -Q_OBJECT -public: - InformationWidget(QWidget* parent); - void socketConnected(); - void socketDisconnected(); - -public slots: - void logInformation(QString text); -}; - -#endif // __OPENSPACE_APP_TIMELINEVIEW___INFORMATIONWIDGET___H__ diff --git a/apps/TimelineView/main.cpp b/apps/TimelineView/main.cpp deleted file mode 100644 index 79bd875cec..0000000000 --- a/apps/TimelineView/main.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include - -#include "mainwindow.h" - -static const QString style = R"style( -QWidget { - background-color: rgb(80, 80, 80); - font-family: Helvetica; -} - -QGroupBox { - background-color: qlineargradient( - x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #858585, - stop: 1 #959595); - border: 2px solid gray; - border-radius: 5px; - margin-top: 4ex; - font-size: bold 12px; -} - -QGroupBox::title { - background-color: #E0E0E0; - border: 2px solid gray; - border-radius: 5px; - subcontrol-origin: margin; - subcontrol-position: top center; - padding: 0 10px; -} - -QLineEdit { - color: lightgray; -} - -QSlider::groove:horizontal { - border: 1px solid #999999; - /* the groove expands to the size of the slider by default. by giving it a height, - it has a fixed size */ - height: 8px; - background: qlineargradient( - x1:0, y1:0, x2:1, y2:0, - stop:0 #c4c4c4, - stop:0.5 #555555, - stop:1 #c4c4c4 - ); - margin: 2px 0; -} - -QSlider::handle:horizontal { - background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); - border: 1px solid #5c5c5c; - width: 18px; - /* handle is placed by default on the contents rect of the groove. - Expand outside the groove */ - margin: -2px 0; - border-radius: 3px; -} - -QPushButton { - background-color: lightgray; - border-style: outset; - border-width: 0.5px; - border-radius: 5px; - border-color: black; - font: bold 12px; - min-width: 10em; -} - -QPushButton#connection { - background-color: lightgreen; -} - -QPushButton#connection:pressed { - background-color: green; -} - - -QPushButton#pause, QPushButton#play { - padding: 5px; -} - -QPushButton#pause:pressed, QPushButton#play:pressed, QPushButton:pressed { - background-color: darkgray; - border-style: inset; -} - -QCombobox { - border: 1px solid gray; - border-radius: 3px; - padding: 1px 18px 1px 3px; - min-width: 6em; -} - -QComboBox:editable { - background: lightgrey; -} - -QComboBox QAbstractItemView { - border: 2px solid darkgray; - border-radius: 5px; - background-color: #a8a8a8; - selection-background-color: #a8a8a8; -} - -QLabel#label { - font-size: 13px; - background-color: transparent; - font-variant: small-caps; -} - -QLabel#value { - font-family: monospace; - font-weight: bold; - font-size: 14px; - background-color: transparent; -} - -QWidget#background { - background-color: transparent; -} - -QTextEdit { - font-family: monospace; -} -)style"; - -int main(int argc, char** argv) { - QApplication app(argc, argv); - - app.setStyleSheet(style); - - MainWindow window; - window.show(); - - return app.exec(); -} diff --git a/apps/TimelineView/mainwindow.cpp b/apps/TimelineView/mainwindow.cpp deleted file mode 100644 index e7241f80a2..0000000000 --- a/apps/TimelineView/mainwindow.cpp +++ /dev/null @@ -1,398 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include "mainwindow.h" - -#include "configurationwidget.h" -#include "controlwidget.h" -#include "informationwidget.h" -#include "timelinewidget.h" - -#include -#include -#include -#include - -#include -#include - -namespace { - QByteArray continuousData; -} - -template -T readFromBuffer(char* buffer, size_t& currentReadLocation) { - union { - T value; - std::array data; - } b; - std::memmove(b.data.data(), buffer + currentReadLocation, sizeof(T)); - currentReadLocation += sizeof(T); - return b.value; -} - -template <> -std::string readFromBuffer(char* buffer, size_t& currentReadLocation) { - uint8_t size = readFromBuffer(buffer, currentReadLocation); - - std::string result(buffer + currentReadLocation, buffer + currentReadLocation + size); - currentReadLocation += size; - return result; -} - -MainWindow::MainWindow() - : QWidget(nullptr) - , _configurationWidget(nullptr) - , _timeControlWidget(nullptr) - , _informationWidget(nullptr) - , _timelineWidget(nullptr) - , _socket(nullptr) -{ - setWindowTitle("OpenSpace Timeline"); - - _configurationWidget = new ConfigurationWidget(this); - _configurationWidget->setMinimumWidth(350); - _timeControlWidget = new ControlWidget(this); - _timeControlWidget->setMinimumWidth(350); - _informationWidget = new InformationWidget(this); - _informationWidget->setMinimumWidth(350); - _timelineWidget = new TimelineWidget(this); - - QGridLayout* layout = new QGridLayout; - layout->addWidget(_configurationWidget, 0, 0); - layout->addWidget(_timeControlWidget, 1, 0); - layout->addWidget(_informationWidget, 2, 0); - layout->addWidget(_timelineWidget, 0, 1, 3, 1); - - layout->setColumnStretch(1, 5); - - - QObject::connect( - _configurationWidget, SIGNAL(connect(QString, QString)), - this, SLOT(onConnect(QString, QString)) - ); - QObject::connect( - _configurationWidget, SIGNAL(disconnect()), - this, SLOT(onDisconnect()) - ); - - QObject::connect( - _timeControlWidget, SIGNAL(scriptActivity(QString)), - this, SLOT(sendScript(QString)) - ); - - setLayout(layout); - - _configurationWidget->socketDisconnected(); - _timeControlWidget->socketDisconnected(); - _informationWidget->socketDisconnected(); - _timelineWidget->socketDisconnected(); -} - -MainWindow::~MainWindow() { - delete _socket; -} - -void MainWindow::onConnect(QString host, QString port) { - delete _socket; - - _socket = new QTcpSocket(this); - QObject::connect(_socket, SIGNAL(readyRead()), SLOT(readTcpData())); - QObject::connect(_socket, SIGNAL(connected()), SLOT(onSocketConnected())); - QObject::connect(_socket, SIGNAL(disconnected()), SLOT(onSocketDisconnected())); - - _socket->connectToHost(host, port.toUInt()); -} - -void MainWindow::onDisconnect() { - delete _socket; - _socket = nullptr; -} - -void MainWindow::readTcpData() { - static const uint16_t MessageTypeStatus = 0; - static const uint16_t MessageTypeMappingIdentifier = 1; - static const uint16_t MessageTypeInitialMessageFinished = 2; - static const uint16_t MessageTypePlayBookLabel = 3; - static const uint16_t MessageTypePlayBookHongKang = 4; - - QByteArray data = continuousData.append(_socket->readAll()); -// int d = data.size(); - - if (QString(data) == "Connected to SGCT!\r\n") { - continuousData.clear(); - return; - } - if (QString(data) == "OK\r\n") { - continuousData.clear(); - return; - } - - if (data.size() != 42) - qDebug() << QString(data); - - QByteArray messageTypeData = data.left(2); - union { - uint16_t value; - std::array data; - } messageType; - std::memcpy(messageType.data.data(), messageTypeData.data(), sizeof(uint16_t)); - - switch (messageType.value) { - case MessageTypeStatus: - break; - case MessageTypeMappingIdentifier: - qDebug() << "Mapping Identifier received"; - printMapping(data.mid(2)); - continuousData.clear(); - break; - case MessageTypeInitialMessageFinished: - qDebug() << "InitialMessageFinished received"; - break; - case MessageTypePlayBookHongKang: - qDebug() << "Hong Kang Playbook received"; - break; - case MessageTypePlayBookLabel: - qDebug() << "Label Playbook received"; - break; - default: - qDebug() << "Unknown message of type '" << messageType.value << "'"; - } - - switch (messageType.value) { - case MessageTypeStatus: - { - if (_isConnected) - handleStatusMessage(data.mid(2)); - continuousData.clear(); - break; - } - case MessageTypePlayBookHongKang: - case MessageTypePlayBookLabel: - { -// const char* payloadDebug = data.mid(2).data(); - - size_t beginning = 0; - uint32_t size = readFromBuffer(data.mid(2).data(), beginning); - - //qDebug() << "Begin reading data"; - while (_socket->waitForReadyRead() && data.size() < int(size)) { - //qDebug() << "."; - //_socket->read - //data = data.append(_socket->re) - data = data.append(_socket->readAll()); - //data = data.append(_socket->read(int(size) - data.size())); - //QThread::msleep(50); - } - //qDebug() << "Finished reading data. Handling playbook"; - - continuousData = handlePlaybook(data.mid(2)); - - - //qDebug() << "Finished handling playbook"; - - //if (messageType.value == MessageTypePlayBookHongKang) - // _hasHongKangTimeline = true; - //if (messageType.value == MessageTypePlayBookLabel) - // _hasLabelTimeline = true; - - //if (_hasHongKangTimeline && _hasLabelTimeline) { - // fullyConnected(); - //} - - break; - } - case MessageTypeInitialMessageFinished: - _isConnected = true; - fullyConnected(); - continuousData.clear(); - break; - - default: - qDebug() << QString(data); - } - -} - -void MainWindow::handleStatusMessage(QByteArray data) { - const char* buffer = data.data(); - - union { - double value; - std::array buffer; - } et; - std::memmove(et.buffer.data(), buffer, sizeof(double)); - - std::vector timeString(24); - std::memmove(timeString.data(), buffer + sizeof(double), 24); - - union { - double value; - std::array buffer; - } delta; - std::memmove(delta.buffer.data(), buffer + sizeof(double) + 24, sizeof(double)); - - _timeControlWidget->update( - QString::fromStdString(std::string(timeString.begin(), timeString.end())), - QString::number(delta.value) - ); - _timelineWidget->setCurrentTime( - std::string(timeString.begin(), timeString.end()), - et.value - ); -} - -std::vector instrumentsFromId(uint16_t instrumentId, - std::map instrumentMap) -{ - std::vector results; - for (int i = 0; i < 16; ++i) { - uint16_t testValue = 1 << i; - if ((testValue & instrumentId) != 0) { - std::string t = instrumentMap.at(testValue); - if (t.empty()) { - qDebug() << "Empty instrument"; - } - results.push_back(t); - } - } - return results; -} - -QByteArray MainWindow::handlePlaybook(QByteArray data) { - char* buffer = data.data(); - size_t currentReadLocation = 0; - - uint32_t totalData = readFromBuffer(buffer, currentReadLocation); - - uint8_t nTargets = readFromBuffer(buffer, currentReadLocation); - qDebug() << "Targets: " << nTargets; - std::map targetMap; - for (uint8_t i = 0; i < nTargets; ++i) { - uint8_t id = readFromBuffer(buffer, currentReadLocation); - std::string value = readFromBuffer(buffer, currentReadLocation); - qDebug() << QString::fromStdString(value); - targetMap[id] = value; - } - - uint8_t nInstruments = readFromBuffer(buffer, currentReadLocation); - qDebug() << "Instruments: " << nInstruments; - std::map instrumentMap; - for (uint8_t i = 0; i < nInstruments; ++i) { - uint16_t id = readFromBuffer(buffer, currentReadLocation); - std::string value = readFromBuffer(buffer, currentReadLocation); - qDebug() << QString::fromStdString(value); - instrumentMap[id] = value; - } - - uint32_t nImages = readFromBuffer(buffer, currentReadLocation); - std::vector images; - for (uint32_t i = 0; i < nImages; ++i) { - Image image; - image.beginning = readFromBuffer(buffer, currentReadLocation); - image.ending = readFromBuffer(buffer, currentReadLocation); - - image.beginningString = readFromBuffer(buffer, currentReadLocation); - image.endingString = readFromBuffer(buffer, currentReadLocation); - - uint8_t targetId = readFromBuffer(buffer, currentReadLocation); - uint16_t instrumentId = readFromBuffer(buffer, currentReadLocation); - image.target = targetMap[targetId]; - image.instruments = instrumentsFromId(instrumentId, instrumentMap); - if (image.instruments.empty()) - qDebug() << "Instruments were empty"; - images.push_back(image); - } - _timelineWidget->setData( - std::move(images), - std::move(targetMap), - std::move(instrumentMap) - ); - - auto dataSize = data.size(); - auto readSize = currentReadLocation; - auto extraBytes = dataSize - readSize; - if (extraBytes > 0) { - return data.mid(currentReadLocation); - } - else { - return QByteArray(); - } -} - -void MainWindow::sendScript(QString script) { - if (_socket) { - _socket->write(("0" + script + "\r\n").toLatin1()); - //QByteArray data = (QString("0") + script).toLocal8Bit(); - //qDebug() << data; - //_socket->write(data); - //QThread::msleep(25); - } - //_socket->write(("0" + script + "\r\n").toLatin1()); - //_socket->write(("0" + script + "\0").toLatin1()); -} - -void MainWindow::onSocketConnected() { - _socket->write(QString("1\r\n").toLatin1()); - //_socket->write(QString("1").toLatin1()); - -} - -void MainWindow::onSocketDisconnected() { - _configurationWidget->socketDisconnected(); - _timeControlWidget->socketDisconnected(); - _informationWidget->socketDisconnected(); - _timelineWidget->socketDisconnected(); - - _informationWidget->logInformation("Disconnected."); -} - -std::string MainWindow::nextTarget() const { - return _timelineWidget->nextTarget(); -} - -void MainWindow::fullyConnected() { - _informationWidget->logInformation( - "Connected to " + _socket->peerName() + " on port " + - QString::number(_socket->peerPort()) + "." - ); - - _configurationWidget->socketConnected(); - _timeControlWidget->socketConnected(); - _informationWidget->socketConnected(); - _timelineWidget->socketConnected(); -} - -void MainWindow::printMapping(QByteArray data) { - char* buffer = data.data(); - size_t currentReadPosition = 0; - - uint16_t size = readFromBuffer(buffer, currentReadPosition); - for (uint16_t i = 0; i < size; ++i) { - uint16_t identifier = readFromBuffer(buffer, currentReadPosition); - std::string mapping = readFromBuffer(buffer, currentReadPosition); - - qDebug() << identifier << ": " << QString::fromStdString(mapping); - } -} diff --git a/apps/TimelineView/mainwindow.h b/apps/TimelineView/mainwindow.h deleted file mode 100644 index 550c075bee..0000000000 --- a/apps/TimelineView/mainwindow.h +++ /dev/null @@ -1,74 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ - -#include -#include - -#include "common.h" - -class ConfigurationWidget; -class ControlWidget; -class InformationWidget; -class TimelineWidget; - -class MainWindow : public QWidget { -Q_OBJECT -public: - MainWindow(); - ~MainWindow(); - - std::string nextTarget() const; - -public slots: - void sendScript(QString script); - -private slots: - void onConnect(QString host, QString port); - void onDisconnect(); - - void onSocketConnected(); - void onSocketDisconnected(); - - void readTcpData(); - void handleStatusMessage(QByteArray data); - QByteArray handlePlaybook(QByteArray data); - void printMapping(QByteArray data); - - void fullyConnected(); - -private: - ConfigurationWidget* _configurationWidget; - ControlWidget* _timeControlWidget; - InformationWidget* _informationWidget; - TimelineWidget* _timelineWidget; - - QTcpSocket* _socket; - - bool _isConnected = false; -}; - -#endif // __OPENSPACE_APP_TIMELINEVIEW___MAINWINDOW___H__ diff --git a/apps/TimelineView/timelinewidget.cpp b/apps/TimelineView/timelinewidget.cpp deleted file mode 100644 index f529663eb1..0000000000 --- a/apps/TimelineView/timelinewidget.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include "timelinewidget.h" - -#include -#include -#include -#include - -#include -#include - -namespace { - static const int LegendHeight = 105; - static const int TimeWidth = 200; - - static const int TextOffset = 5; - - QMap InstrumentColors = { - { "NH_ALICE_AIRGLOW", QColor(40, 130, 200) }, - { "NH_ALICE_SOC", QColor(49, 234, 219) }, - { "NH_RALPH_LEISA", QColor(139, 86, 152) }, - { "NH_RALPH_MVIC_NIR", QColor(100, 14, 14) }, - { "NH_RALPH_MVIC_METHANE", QColor(211, 154, 31) }, - { "NH_RALPH_MVIC_RED", QColor(175, 18, 18) }, - { "NH_RALPH_MVIC_BLUE", QColor(84, 79, 149) }, - { "NH_LORRI", QColor(149, 219, 32) }, - { "NH_REX", QColor(35, 185, 125) }, - - { "NH_RALPH_MVIC_PAN1", QColor(203, 153, 200) }, - { "NH_RALPH_MVIC_FT", QColor(242, 101, 74) }, - { "NH_RALPH_MVIC_PAN2", QColor(180, 180, 140) } - }; - - //{ "NH_ALICE_AIRGLOW", QColor(82, 145, 57) }, - //{ "NH_ALICE_SOC", QColor(241, 231, 48) }, - - - QMap InstrumentConversion = { - { "NH_ALICE_AIRGLOW", "ALICE Airglow" }, - { "NH_RALPH_LEISA", "RALPH LEISA" }, - { "NH_RALPH_MVIC_NIR", "RALPH MVIC NIR" }, - { "NH_ALICE_SOC", "ALICE SOC" }, - { "NH_RALPH_MVIC_BLUE", "RALPH MVIC Blue" }, - { "NH_RALPH_MVIC_PAN1" , "RALPH MVIC Pan1" }, - { "NH_LORRI", "LORRI" }, - { "NH_RALPH_MVIC_FT", "RALPH MVIC FT" }, - { "NH_RALPH_MVIC_PAN2", "RALPH MVIC Pan2" }, - { "NH_RALPH_MVIC_METHANE", "RALPH MVIC Methane" }, - { "NH_RALPH_MVIC_RED", "RALPH MVIC Red" }, - { "NH_REX", "REX" } - }; - - const double etSpread = 100.0; -} - -TimelineWidget::TimelineWidget(QWidget* parent) - : QWidget(parent) - , _currentTime{"", 0.0} -{ - setMinimumWidth(600); - setMinimumHeight(600); -} - -void TimelineWidget::paintEvent(QPaintEvent* event) { - QPainter painter(this); - - QRectF fullRect = contentsRect(); - QRectF contentRect(0, 0, fullRect.width() - 1, fullRect.height() - LegendHeight); - QRectF legendRect( - 0, - fullRect.bottom() - LegendHeight, - fullRect.right(), - fullRect.bottom() - ); - - painter.save(); - drawContent(painter, contentRect); - painter.restore(); - - painter.save(); - painter.translate(0, fullRect.height() - LegendHeight); - drawLegend(painter, QRectF(legendRect)); - painter.restore(); -} - -void TimelineWidget::setData(std::vector images, - std::map targetMap, - std::map instrumentMap) -{ - _images.insert(_images.end(), images.begin(), images.end()); - - std::sort( - _images.begin(), - _images.end(), - [](const Image& a, const Image& b) { return a.beginning < b.beginning; } - ); - - _targetMap.insert(targetMap.begin(), targetMap.end()); - _instrumentMap.insert(instrumentMap.begin(), instrumentMap.end()); - - _instruments.clear(); - std::set instruments; - for (auto p : _instrumentMap) - instruments.insert(p.second); - std::copy(instruments.begin(), instruments.end(), std::back_inserter(_instruments)); - - _targets.clear(); - std::set targets; - for (auto p : _targetMap) - targets.insert(p.second); - std::copy(targets.begin(), targets.end(), std::back_inserter(_targets)); - - repaint(); -} - -void TimelineWidget::drawContent(QPainter& painter, QRectF rect) { - QRectF timelineRect(0, 0, rect.width() - TimeWidth, rect.height()); - QRectF dateRect(rect.width() - TimeWidth, 0, TimeWidth, rect.height()); - - // Draw background - //painter.setBrush(QBrush(Qt::lightGray)); painter.drawRect(timelineRect); - painter.setBrush(QBrush(QColor(85, 85, 85))); painter.drawRect(timelineRect); - painter.setBrush(QBrush(QColor(165, 165, 165))); painter.drawRect(dateRect); - - const double lowerTime = _currentTime.et - etSpread; - const double upperTime = _currentTime.et + etSpread; - - std::vector images; - for (Image& i : _images) { - if (i.beginning <= upperTime && i.ending >= lowerTime) - images.push_back(&i); - } - - drawImages(painter, timelineRect, images, lowerTime, upperTime); - - - // Draw current time - painter.setBrush(QBrush(Qt::black)); - painter.setPen(QPen(Qt::black, 2)); - painter.drawLine( - QPointF(0, timelineRect.height() / 2), - QPointF(timelineRect.width(), timelineRect.height() / 2) - ); - painter.drawText( - timelineRect.width(), - timelineRect.height() / 2 + TextOffset, - QString::fromStdString(_currentTime.time) - ); -} - -void TimelineWidget::drawLegend(QPainter& painter, QRectF rect) { - static const int Padding = 5; - static const int BoxSize = 20; - - int currentHorizontalPosition = Padding; - int currentVerticalPosition = Padding + BoxSize + Padding; - - // Draw Targets - // Draw Instruments - for (int i = 0; i < _instruments.size(); ++i) { - if (i == _instruments.size() / 3 || i == _instruments.size() * 2 / 3) { - currentVerticalPosition += BoxSize + Padding; - currentHorizontalPosition = Padding; - } - - const std::string& instrument = _instruments[i]; - ; - painter.setBrush(QBrush(InstrumentColors[QString::fromStdString(instrument)])); - painter.setPen(QPen(InstrumentColors[QString::fromStdString(instrument)])); - painter.drawRect( - currentHorizontalPosition, - currentVerticalPosition, - BoxSize, - BoxSize - ); - currentHorizontalPosition += BoxSize + Padding; - - painter.setPen(QPen(QColor(200, 200, 200))); - //painter.setPen(QPen(Qt::black)); - painter.drawText( - currentHorizontalPosition, - currentVerticalPosition + BoxSize / 2 + TextOffset, - InstrumentConversion[QString::fromStdString(instrument)] - ); - currentHorizontalPosition += 125; - } -} - -void TimelineWidget::setCurrentTime(std::string currentTime, double et) { - _currentTime.time = std::move(currentTime); - _currentTime.et = std::move(et); - repaint(); - -} - -void TimelineWidget::drawImages( - QPainter& painter, - QRectF timelineRect, - std::vector images, - double minimumTime, double maximumTime) -{ - std::set instrumentSet; - for (Image* i : images) { - for (std::string instrument : i->instruments) { - instrumentSet.insert(instrument); - } - } - std::map instruments; - for (auto it = instrumentSet.begin(); it != instrumentSet.end(); ++it) - instruments[*it] = std::distance(instrumentSet.begin(), it); - - for (Image* i : images) { - double tBeg = (i->beginning - minimumTime) / (maximumTime - minimumTime); - tBeg = std::max(tBeg, 0.0); - double tEnd = (i->ending - minimumTime) / (maximumTime - minimumTime); - tEnd = std::min(tEnd, 1.0); - - int loc = timelineRect.top() + timelineRect.height() * tBeg; - int height = (timelineRect.top() + timelineRect.height() * tEnd) - loc; - height = std::max(height, 5); - - if (loc + height > timelineRect.height()) { - height = timelineRect.height() - loc; - } - - std::string target = i->target; - auto it = std::find(_targets.begin(), _targets.end(), target); -// int iTarget = std::distance(_targets.begin(), it); - - for (std::string instrument : i->instruments) { - auto it = std::find(_instruments.begin(), _instruments.end(), instrument); - if (it == _instruments.end()) { - qDebug() << "Instrument not found"; - } - - painter.setBrush( - QBrush(InstrumentColors[QString::fromStdString(instrument)]) - ); - - double width = timelineRect.width() / instruments.size(); - double pos = instruments[instrument] * width; - - painter.drawRect(pos, loc, width, height); - } - - if (height >= 5) { - painter.setBrush(QBrush(Qt::black)); - painter.setPen(QPen(Qt::black)); - QString line = QString::fromStdString(i->beginningString) + QString(" (") + - QString::fromStdString(i->target) + QString(")"); - - painter.drawText(timelineRect.width(), loc + height / 2 + TextOffset, line); - } - } -} - -void TimelineWidget::socketConnected() { - setDisabled(false); -} - -void TimelineWidget::socketDisconnected() { - setDisabled(true); - _images.clear(); - _instruments.clear(); - _targets.clear(); -} - -std::string TimelineWidget::nextTarget() const { - auto it = std::lower_bound( - _images.begin(), - _images.end(), - _currentTime.et, - [](const Image& i, double et) { return i.beginning < et; } - ); - if (it != _images.end()) { - return it->target; - } - else { - return ""; - } -} diff --git a/apps/TimelineView/timelinewidget.h b/apps/TimelineView/timelinewidget.h deleted file mode 100644 index e5fcc440c0..0000000000 --- a/apps/TimelineView/timelinewidget.h +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2019 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__ -#define __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__ - -#include - -#include "common.h" - -#include -#include -#include - -class QPaintEvent; - -class TimelineWidget : public QWidget { -Q_OBJECT -public: - TimelineWidget(QWidget* parent); - - void setData(std::vector images, std::map targetMap, - std::map instrumentMap); - void setCurrentTime(std::string currentTime, double et); - void socketConnected(); - void socketDisconnected(); - - std::string nextTarget() const; - -protected: - void paintEvent(QPaintEvent* event); - void drawContent(QPainter& painter, QRectF rect); - void drawLegend(QPainter& painter, QRectF rect); - void drawImages(QPainter& painter, QRectF timelineRect, std::vector images, - double minimumTime, double maximumTime); - -private: - std::vector _images; - std::map _targetMap; - std::map _instrumentMap; - - std::vector _targets; - std::vector _instruments; - - struct { - std::string time; - double et; - } _currentTime; -}; - -#endif // __OPENSPACE_APP_TIMELINEVIEW___TIMELINEWIDGET___H__ diff --git a/data/assets/base.asset b/data/assets/base.asset index 34a64b783b..3c6406cc80 100644 --- a/data/assets/base.asset +++ b/data/assets/base.asset @@ -57,9 +57,10 @@ local Keybindings = { }, { Key = "h", - Name="Toggle Planet Trails", - Command = "local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end", - Documentation = "Toggles the visibility of planet trails", + Name="Toggle Trails", + Command = "local list = openspace.getProperty('{planetTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(list) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end\n" .. + "local moonlist = openspace.getProperty('{moonTrail_solarSystem}.Renderable.Enabled'); for _,v in pairs(moonlist) do openspace.setPropertyValueSingle(v, not openspace.getPropertyValue(v)) end", + Documentation = "Toggles the visibility of planet and moon trails", GuiPath = "/Rendering", Local = false }, diff --git a/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset b/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset index 363af34171..35dfbe7110 100644 --- a/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset +++ b/data/assets/scene/solarsystem/missions/messenger/mercurymagnetosphere.asset @@ -6,7 +6,7 @@ local localFolder = asset.syncedResource({ Name = "Mercury Magnetosphere", Type = "HttpSynchronization", Identifier = "mercury_magnetosphere", - Version = 2 + Version = 3 }) diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/LiU/Kaguya.vrt b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/LiU/Kaguya.vrt new file mode 100644 index 0000000000..e7ad44a020 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/LiU/Kaguya.vrt @@ -0,0 +1,28 @@ + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 2.4414062500000000e-04, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -2.4414062500000000e-04 + + Gray + + Kaguya.wms + 1 + + + + + + + Alpha + 0 + + Kaguya.wms + 1 + + + + 255 + 0 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.vrt b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.vrt new file mode 100644 index 0000000000..e7ad44a020 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.vrt @@ -0,0 +1,28 @@ + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 2.4414062500000000e-04, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -2.4414062500000000e-04 + + Gray + + Kaguya.wms + 1 + + + + + + + Alpha + 0 + + Kaguya.wms + 1 + + + + 255 + 0 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset index e9f0f49b3a..851e8d135c 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset +++ b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset @@ -49,8 +49,8 @@ local Moon = { Name = "Clem Uvvis [Utah]", FilePath = mapServiceConfigs .. "/Utah/ClemUvvis.wms", Settings = { - Gamma = 0.81, - Multiplier = 1.1 + Gamma = 1.14, + Multiplier = 1.4 } }, { @@ -58,8 +58,8 @@ local Moon = { Name = "Clem Uvvis [Sweden]", FilePath = mapServiceConfigs .. "/LiU/Clem_Uvvis.wms", Settings = { - Gamma = 0.81, - Multiplier = 1.1 + Gamma = 1.14, + Multiplier = 1.4 } }, { @@ -83,7 +83,7 @@ local Moon = { { Identifier = "Kaguya_Utah", Name = "Kaguya [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Kaguya.wms", + FilePath = mapServiceConfigs .. "/Utah/Kaguya.vrt", Settings = { Gamma = 1.0, Multiplier = 1.23 @@ -92,7 +92,7 @@ local Moon = { { Identifier = "Kaguya_Sweden", Name = "Kaguya [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Kaguya.wms", + FilePath = mapServiceConfigs .. "/LiU/Kaguya.vrt", Settings = { Gamma = 1.0, Multiplier = 1.23 diff --git a/data/assets/scene/solarsystem/planets/earth/moon/trail.asset b/data/assets/scene/solarsystem/planets/earth/moon/trail.asset index fe707fff53..bd96ce84ac 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/trail.asset +++ b/data/assets/scene/solarsystem/planets/earth/moon/trail.asset @@ -16,7 +16,8 @@ local MoonTrail = { }, Color = { 0.5, 0.3, 0.3 }, Period = 27, - Resolution = 1000 + Resolution = 1000, + Tag = { "moonTrail_solarSystem", "moonTrail_terrestrial", "moonTrail_earth" } }, GUI = { Name = "Moon Trail", diff --git a/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.vrt b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.vrt new file mode 100644 index 0000000000..7eb41cc198 --- /dev/null +++ b/data/assets/scene/solarsystem/planets/venus/map_service_configs/Utah/MagellanMosaic.vrt @@ -0,0 +1,28 @@ + + GEOGCS["GCS_Venus",DATUM["D_Venus",SPHEROID["Venus_localRadius",6051000,0]],PRIMEM["Reference_Meridian",0],UNIT["Degree",0.0174532925199433]] + -1.8000000000000000e+02, 7.1016002272512077e-04, 0.0000000000000000e+00, 9.0000000000000000e+01, 0.0000000000000000e+00, -7.1011656303583486e-04 + + Gray + + MagellanMosaic.wms + 1 + + + + + + + Alpha + 0 + + MagellanMosaic.wms + 1 + + + + 255 + 0 + 0 + + + diff --git a/data/assets/scene/solarsystem/planets/venus/venus.asset b/data/assets/scene/solarsystem/planets/venus/venus.asset index 797ed5b949..486f2d2cab 100644 --- a/data/assets/scene/solarsystem/planets/venus/venus.asset +++ b/data/assets/scene/solarsystem/planets/venus/venus.asset @@ -26,12 +26,13 @@ local color_layers = { { Identifier = "Magellan_Mosaic_Utah", Name = "Magellan Mosaic [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MagellanMosaic.wms", + FilePath = mapServiceConfigs .. "/Utah/MagellanMosaic.vrt", BlendMode = "Color", Settings = { Gamma = 2.0 - } - } + }, + Enabled = true + }, } local height_layers = { @@ -43,7 +44,8 @@ local height_layers = { Settings = { Gamma = 1.72, Multiplier = 1.1 - } + }, + Enabled = true } } diff --git a/data/assets/util/webgui.asset b/data/assets/util/webgui.asset index 94f3998ed4..13baac61cb 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 = "be37b84637a88a6961504a8648a4f509bfb07475" +local frontendHash = "c2d8ff7419b82a614b6cdc02fbe391e0862279de" local dataProvider = "data.openspaceproject.com/files/webgui" local frontend = asset.syncedResource({ diff --git a/ext/ghoul b/ext/ghoul index 42c4d7e985..0461bf1f44 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 42c4d7e9855516510249fa6520e5d62beb679115 +Subproject commit 0461bf1f44b58e04fb21d929b0f385e1120da7b4 diff --git a/include/openspace/interaction/keybindingmanager.h b/include/openspace/interaction/keybindingmanager.h index 2c652c7d40..aca56d84e6 100644 --- a/include/openspace/interaction/keybindingmanager.h +++ b/include/openspace/interaction/keybindingmanager.h @@ -75,7 +75,6 @@ public: const std::multimap& keyBindings() const; private: - std::multimap _keyLua; }; diff --git a/include/openspace/interaction/navigationhandler.h b/include/openspace/interaction/navigationhandler.h index ea29dd98ea..66b1e3942b 100644 --- a/include/openspace/interaction/navigationhandler.h +++ b/include/openspace/interaction/navigationhandler.h @@ -166,6 +166,7 @@ private: std::optional _pendingNavigationState; + properties::BoolProperty _disableInputs; properties::BoolProperty _useKeyFrameInteraction; }; diff --git a/include/openspace/interaction/sessionrecording.inl b/include/openspace/interaction/sessionrecording.inl index 5c8ce2c9ac..386357c9c5 100644 --- a/include/openspace/interaction/sessionrecording.inl +++ b/include/openspace/interaction/sessionrecording.inl @@ -33,9 +33,11 @@ T nextKeyframeObj(unsigned int index, const std::vector& keyframeContainer, finishedCallback(); } return keyframeContainer.back(); - } else if (index < keyframeContainer.size()) { + } + else if (index < keyframeContainer.size()) { return keyframeContainer[index]; - } else { + } + else { return keyframeContainer.back(); } } @@ -44,9 +46,11 @@ template T prevKeyframeObj(unsigned int index, const std::vector& keyframeContainer) { if (index >= keyframeContainer.size()) { return keyframeContainer.back(); - } else if (index > 0) { + } + else if (index > 0) { return keyframeContainer[index - 1]; - } else { + } + else { return keyframeContainer.front(); } } diff --git a/include/openspace/interaction/touchbar.h b/include/openspace/interaction/touchbar.h index beae46641d..3b769a03f9 100644 --- a/include/openspace/interaction/touchbar.h +++ b/include/openspace/interaction/touchbar.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/atmosphere/shaders/atmosphere_common.glsl b/modules/atmosphere/shaders/atmosphere_common.glsl index 07887b12a9..c806dfab8e 100644 --- a/modules/atmosphere/shaders/atmosphere_common.glsl +++ b/modules/atmosphere/shaders/atmosphere_common.glsl @@ -125,7 +125,8 @@ vec3 analyticTransmittance(const float r, const float mu, const float d) { return exp(-betaRayleigh * opticalDepth(HR, r, mu, d) - betaOzoneExtinction * (0.0000006) * opticalDepth(HO, r, mu, d) - betaMieExtinction * opticalDepth(HM, r, mu, d)); - } else { + } + else { return exp(-betaRayleigh * opticalDepth(HR, r, mu, d) - betaMieExtinction * opticalDepth(HM, r, mu, d)); } @@ -315,7 +316,8 @@ vec3 transmittance(const float r, const float mu, const float d) { if (mu > 0.0f) { return min(transmittanceLUT(r, mu) / transmittanceLUT(ri, mui), 1.0f); - } else { + } + else { return min(transmittanceLUT(ri, -mui) / transmittanceLUT(r, -mu), 1.0f); } diff --git a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl index 54a356dcc4..e9c3fdb17a 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_fs.glsl @@ -128,14 +128,16 @@ vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[numberOfShadows], co if (ground) { if (hardShadows) { return vec4(0.2, 0.2, 0.2, 1.0); - } else { + } + else { return butterworthFunc(length_d, r_u_pi, 4.0); } } else { if (hardShadows) { return vec4(0.5, 0.5, 0.5, 1.0); - } else { + } + else { return vec4(vec3(length_d/r_p_pi), 1.0); } } @@ -143,7 +145,8 @@ vec4 calcShadow(const ShadowRenderingStruct shadowInfoArray[numberOfShadows], co else if ( length_d < r_p_pi ) {// penumbra if (hardShadows) { return vec4(0.5, 0.5, 0.5, 1.0); - } else { + } + else { return vec4(vec3(length_d/r_p_pi), 1.0); } } @@ -212,7 +215,8 @@ bool dAtmosphereIntersection(const dvec3 planetPosition, const dRay ray, const d inside = false; offset = s - q; maxLength = s + q; - } else { + } + else { inside = true; offset = 0.0; maxLength = s + q; @@ -332,7 +336,8 @@ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor // We set the irradianceFactor to 1.0 so the reflected irradiance will be considered // when calculating the reflected light on the ground. irradianceFactor = 1.0; - } else { + } + else { attenuation = analyticTransmittance(r, mu, t); //attenuation = transmittance(r, mu, t); groundHit = false; @@ -412,7 +417,8 @@ vec3 inscatterRadiance(inout vec3 x, inout float t, inout float irradianceFactor if (groundHit) { return finalScatteringRadiance; - } else { + } + else { //return ((r-Rg) * invRtMinusRg)*spaceColor.rgb + finalScatteringRadiance; return spaceColor.rgb + finalScatteringRadiance; // return attenuation * spaceColor.rgb + @@ -476,7 +482,8 @@ vec3 groundColor(const vec3 x, const float t, const vec3 v, const vec3 s, const vec3 RLStar = (muSun * transmittanceL0 + irradianceReflected) * sunIntensity / M_PI; if (dotNS < 0.05f) { groundRadiance = groundReflectance.rgb * mix(30.0f, 1.0f, smoothstep(-1.0f, 0.05f, dotNS)) * RLStar; - } else { + } + else { groundRadiance = groundReflectance.rgb * RLStar; } @@ -618,7 +625,8 @@ void main() { if (pixelDepth < offset) { // ATM Occluded - Something in fron of ATM. atmosphereFinalColor += color; - } else { + } + else { // Following paper nomenclature double t = offset; vec3 attenuation; @@ -658,7 +666,8 @@ void main() { groundColorV = groundColor(x, tF, v, s, r, mu, attenuation, color, normal.xyz, irradianceFactor, normal.a, sunIntensityGround); - } else { + } + else { // In order to get better performance, we are not tracing // multiple rays per pixel when the ray doesn't intersect // the ground. diff --git a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl index 088267c6f0..d39e6e2e15 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl @@ -173,7 +173,8 @@ void inscatter(float r, float mu, float muSun, float nu, inout vec3 radianceJ) { // Initial InScattering including the phase functions radianceJ1 += singleRay * phaseRaySW + singleMie * phaseMieSW; - } else { + } + else { // On line 9 of the algorithm, the texture table deltaSR is updated, so when we are not in the first // iteraction, we are getting the updated result of deltaSR (not the single inscattered light but the // accumulated (higher order) inscattered light. diff --git a/modules/atmosphere/shaders/inScattering_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_calc_fs.glsl index fc8adbda28..6201fc1acb 100644 --- a/modules/atmosphere/shaders/inScattering_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_fs.glsl @@ -68,7 +68,8 @@ void integrand(const float r, const float mu, const float muSun, const float nu, if (ozoneLayerEnabled) { S_R = (exp(-(ri - Rg) / HO) + exp( -(ri - Rg) / HR )) * transmittanceY; S_M = exp( -(ri - Rg) / HM ) * transmittanceY; - } else { + } + else { S_R = exp( -(ri - Rg) / HR ) * transmittanceY; S_M = exp( -(ri - Rg) / HM ) * transmittanceY; } diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl index 72e2f58a04..07ba931806 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl @@ -78,7 +78,8 @@ void main(void) { vec3 singleMie = texture4D(deltaSMTexture, r, w.z, muSun, nu).rgb; // w.z is the cosine(theta) = mu for vec(w) and also vec(w) dot vec(n(xo)) irradianceE += (singleRay * phaseRay + singleMie * phaseMie) * w.z * dw; - } else { + } + else { // On line 10 of the algorithm, the texture table deltaE is updated, so when we are not in the first // iteraction, we are getting the updated result of deltaE (not the single irradiance light but the // accumulated (higher order) irradiance light. diff --git a/modules/atmosphere/shaders/transmittance_calc_fs.glsl b/modules/atmosphere/shaders/transmittance_calc_fs.glsl index 479a729b00..3413b91e41 100644 --- a/modules/atmosphere/shaders/transmittance_calc_fs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_fs.glsl @@ -82,7 +82,8 @@ void main(void) { opDepth = betaOzoneExtinction * (0.0000006) * opticalDepth(r, muSun, HO) + betaMieExtinction * opticalDepth(r, muSun, HM) + betaRayleigh * opticalDepth(r, muSun, HR); - } else { + } + else { opDepth = betaMieExtinction * opticalDepth(r, muSun, HM) + betaRayleigh * opticalDepth(r, muSun, HR); } diff --git a/modules/base/rendering/renderableplaneimagelocal.cpp b/modules/base/rendering/renderableplaneimagelocal.cpp index a83340ca9f..5c106c21ed 100644 --- a/modules/base/rendering/renderableplaneimagelocal.cpp +++ b/modules/base/rendering/renderableplaneimagelocal.cpp @@ -102,7 +102,8 @@ RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& di ); if (renderType == "Background") { setRenderBin(Renderable::RenderBin::Background); - } else if (renderType == "Opaque") { + } + else if (renderType == "Opaque") { setRenderBin(Renderable::RenderBin::Opaque); } else if (renderType == "Transparent") { diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index f512eefe8e..37939db68a 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -424,7 +424,8 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { if (orientation == Orientation::Inside) { glCullFace(GL_FRONT); - } else if (orientation == Orientation::Both) { + } + else if (orientation == Orientation::Both) { glDisable(GL_CULL_FACE); } @@ -455,7 +456,8 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { if (orientation == Orientation::Inside) { glCullFace(GL_BACK); - } else if (orientation == Orientation::Both) { + } + else if (orientation == Orientation::Both) { glEnable(GL_CULL_FACE); } } diff --git a/modules/base/rotation/staticrotation.cpp b/modules/base/rotation/staticrotation.cpp index 26333b4902..c5ca228c74 100644 --- a/modules/base/rotation/staticrotation.cpp +++ b/modules/base/rotation/staticrotation.cpp @@ -109,13 +109,15 @@ StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary) : StaticRota dictionary.value(RotationInfo.identifier) ); _matrixIsDirty = true; - } else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { + } + else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { glm::dvec4 data = dictionary.value(RotationInfo.identifier); _eulerRotation = rotationMatrixToEulerAngles( glm::mat3_cast(glm::dquat(data.w, data.x, data.y, data.z)) ); _matrixIsDirty = true; - } else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { + } + else if (dictionary.hasKeyAndValue(RotationInfo.identifier)) { _eulerRotation = rotationMatrixToEulerAngles( dictionary.value(RotationInfo.identifier) ); diff --git a/modules/base/shaders/renderabletrail_apple_fs.glsl b/modules/base/shaders/renderabletrail_apple_fs.glsl index f0f83b0285..d89b3cc720 100644 --- a/modules/base/shaders/renderabletrail_apple_fs.glsl +++ b/modules/base/shaders/renderabletrail_apple_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/base/shaders/renderabletrail_apple_vs.glsl b/modules/base/shaders/renderabletrail_apple_vs.glsl index 4c4db42aac..aa6224c3af 100644 --- a/modules/base/shaders/renderabletrail_apple_vs.glsl +++ b/modules/base/shaders/renderabletrail_apple_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/base/shaders/renderabletrail_fs.glsl b/modules/base/shaders/renderabletrail_fs.glsl index a5d9ce25d1..86aae007f2 100644 --- a/modules/base/shaders/renderabletrail_fs.glsl +++ b/modules/base/shaders/renderabletrail_fs.glsl @@ -67,7 +67,8 @@ Fragment getFragment() { if (distanceCenter > dLW) { frag.color.a = 0.0; - } else { + } + else { frag.color.a *= pow(float((dLW - distanceCenter) / dLW), blendFactor); } diff --git a/modules/base/timeframe/timeframeinterval.cpp b/modules/base/timeframe/timeframeinterval.cpp index 84d6dc28bf..53d8ebc1b9 100644 --- a/modules/base/timeframe/timeframeinterval.cpp +++ b/modules/base/timeframe/timeframeinterval.cpp @@ -133,7 +133,8 @@ TimeFrameInterval::TimeFrameInterval(const ghoul::Dictionary& dictionary) dictionary.value(StartInfo.identifier) ); _hasStart = true; - } else if (dictionary.hasValue(StartInfo.identifier)) { + } + else if (dictionary.hasValue(StartInfo.identifier)) { _start = dictionary.value(StartInfo.identifier); _hasStart = true; } diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index 478b5847b5..2d5b7c520d 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -121,7 +121,8 @@ void CefWebGuiModule::startOrStopGui() { _instance->setZoom(_guiScale); webBrowserModule->addBrowser(_instance.get()); - } else if (_instance) { + } + else if (_instance) { _instance->close(true); webBrowserModule->removeBrowser(_instance.get()); webBrowserModule->detachEventHandler(); @@ -176,7 +177,8 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) if (_visible && _instance) { webBrowserModule->attachEventHandler(_instance.get()); - } else { + } + else { webBrowserModule->detachEventHandler(); } }); diff --git a/modules/cefwebgui/shaders/gui_fs.glsl b/modules/cefwebgui/shaders/gui_fs.glsl index 9dda0651ab..3b31cb9184 100644 --- a/modules/cefwebgui/shaders/gui_fs.glsl +++ b/modules/cefwebgui/shaders/gui_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/cefwebgui/shaders/gui_vs.glsl b/modules/cefwebgui/shaders/gui_vs.glsl index 2323d505d3..f8ee811e0a 100644 --- a/modules/cefwebgui/shaders/gui_vs.glsl +++ b/modules/cefwebgui/shaders/gui_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index e7df8224e0..688d518611 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -465,7 +465,8 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di if (o == "Camera View Direction") { _renderOption = RenderOptionViewDirection; - } else if (o == "Camera Position Normal") { + } + else if (o == "Camera Position Normal") { _renderOption = RenderOptionPositionNormal; } } diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index 8a1d259747..bdc7b80436 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -713,7 +713,8 @@ bool RenderableDUMeshes::readSpeckFile() { //file.seekg(position); //break; continue; - } else { + } + else { //if (line.substr(0, 4) == "mesh") { // mesh lines are structured as follows: diff --git a/modules/digitaluniverse/shaders/billboard_gs.glsl b/modules/digitaluniverse/shaders/billboard_gs.glsl index 23e4f88912..2ee4ea61cd 100644 --- a/modules/digitaluniverse/shaders/billboard_gs.glsl +++ b/modules/digitaluniverse/shaders/billboard_gs.glsl @@ -78,15 +78,20 @@ void main() { // Must be the same as the enum in RenderableBillboardsCloud.h if (pos.w == 1.f) { unit = 1E3; - } else if (pos.w == 2.f) { + } + else if (pos.w == 2.f) { unit = PARSEC; - } else if (pos.w == 3.f) { + } + else if (pos.w == 3.f) { unit = 1E3 * PARSEC; - } else if (pos.w == 4.f) { + } + else if (pos.w == 4.f) { unit = 1E6 * PARSEC; - } else if (pos.w == 5.f) { + } + else if (pos.w == 5.f) { unit = 1E9 * PARSEC; - } else if (pos.w == 6.f) { + } + else if (pos.w == 6.f) { // Convertion factor from Parsecs to GigalightYears unit = 306391534.73091 * PARSEC; } @@ -105,7 +110,8 @@ void main() { if (renderOption == 0) { scaledRight = scaleMultiply * right * 0.5f; scaledUp = scaleMultiply * up * 0.5f; - } else if (renderOption == 1) { + } + else if (renderOption == 1) { vec3 normal = vec3(normalize(cameraPosition - dpos.xyz)); vec3 newRight = normalize(cross(cameraLookUp, normal)); vec3 newUp = cross(normal, newRight); @@ -148,7 +154,8 @@ void main() { scaledRight *= correctionScale; scaledUp *= correctionScale; - } else { + } + else { // linear alpha decay if (sizes.x < 2.0f * minBillboardSize) { float maxVar = 2.0f * minBillboardSize; diff --git a/modules/digitaluniverse/shaders/points_fs.glsl b/modules/digitaluniverse/shaders/points_fs.glsl index 35bf38a6db..ff55cd58d8 100644 --- a/modules/digitaluniverse/shaders/points_fs.glsl +++ b/modules/digitaluniverse/shaders/points_fs.glsl @@ -41,7 +41,8 @@ Fragment getFragment() { if (hasColorMap) { frag.color = vec4(colorMap.xyz, alphaValue); - } else { + } + else { frag.color = vec4(color, alphaValue); } diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index c560fca43e..003ec69e3c 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -1157,12 +1157,14 @@ void RenderableFieldlinesSequence::update(const UpdateData& data) { if (_loadingStatesDynamically) { _mustLoadNewStateFromDisk = true; - } else { + } + else { _needsUpdate = true; _activeStateIndex = _activeTriggerTimeIndex; } } // else {we're still in same state as previous frame (no changes needed)} - } else { + } + else { // Not in interval => set everything to false _activeTriggerTimeIndex = -1; _mustLoadNewStateFromDisk = false; @@ -1221,7 +1223,8 @@ void RenderableFieldlinesSequence::updateActiveTriggerTimeIndex(double currentTi else { _activeTriggerTimeIndex = 0; } - } else { + } + else { _activeTriggerTimeIndex = static_cast(_nStates) - 1; } } diff --git a/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl b/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl index 6b0405fd9f..400b69a0c5 100644 --- a/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl +++ b/modules/fieldlinessequence/shaders/fieldlinessequence_vs.glsl @@ -107,7 +107,8 @@ void main() { if (isParticle) { vs_color = flowColor; - } else { + } + else { vs_color = lineColor; } @@ -115,7 +116,8 @@ void main() { vec4 quantityColor = getTransferFunctionColor(); vs_color = vec4(quantityColor.xyz, vs_color.a * quantityColor.a); } - } else { + } + else { vs_color = vec4(0); } diff --git a/modules/fieldlinessequence/util/commons.cpp b/modules/fieldlinessequence/util/commons.cpp index b3aef7b491..9602b52b9b 100644 --- a/modules/fieldlinessequence/util/commons.cpp +++ b/modules/fieldlinessequence/util/commons.cpp @@ -29,9 +29,11 @@ namespace openspace::fls { Model stringToModel(const std::string& s) { if (s == "batsrus") { return Model::Batsrus; - } else if (s == "enlil") { + } + else if (s == "enlil") { return Model::Enlil; - } else if (s == "pfss") { + } + else if (s == "pfss") { return Model::Pfss; } return Model::Invalid; diff --git a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp index 63b0f6f85d..76daab2b7a 100644 --- a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp +++ b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp @@ -236,7 +236,8 @@ void addExtraQuantities(ccmc::Kameleon* kameleon, val = interpolator->interpolate("p", p.x, p.y, p.z); val *= ToKelvin; val /= interpolator->interpolate("rho", p.x, p.y, p.z); - } else { + } + else { val = interpolator->interpolate(extraScalarVars[i], p.x, p.y, p.z); // When measuring density in ENLIL CCMC multiply by the radius^2 @@ -265,7 +266,8 @@ void addExtraQuantities(ccmc::Kameleon* kameleon, // the magnetic field vector! val = glm::dot(glm::vec3(x,y,z), normMagnetic); - } else { + } + else { val = std::sqrt(x*x + y*y + z*z); } state.appendToExtra(i + nXtraScalars, val); @@ -315,7 +317,8 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon, )); extraScalarVars.erase(extraScalarVars.begin() + i); --i; - } else { + } + else { extraQuantityNames.push_back(str); } } @@ -359,11 +362,13 @@ void prepareStateAndKameleonForExtras(ccmc::Kameleon* kameleon, extraMagVars.begin() + i + 3 ); i -= 3; - } else { + } + else { extraQuantityNames.push_back(std::move(name)); } } - } else { + } + else { // WRONG NUMBER OF MAGNITUDE VARIABLES.. REMOVE ALL! extraMagVars.clear(); LWARNING(fmt::format( diff --git a/modules/gaia/shaders/gaia_billboard_ge.glsl b/modules/gaia/shaders/gaia_billboard_ge.glsl index 6ff847259d..3296ae1fa2 100644 --- a/modules/gaia/shaders/gaia_billboard_ge.glsl +++ b/modules/gaia/shaders/gaia_billboard_ge.glsl @@ -100,15 +100,15 @@ void main() { // Discard geometry if star has no position (but wasn't a nullArray). // Or if observed distance is above threshold set by cutOffThreshold. // By discarding in gs instead of fs we save computations for when nothing is visible. - if( length(position) < EPS || distThreshold <= 0){ + if (length(position) < EPS || distThreshold <= 0) { return; } vec4 centerWorldPos = vs_gPosition[0]; - dvec3 cameraNormal = normalize(cameraPos - dvec3(centerWorldPos.xyz)); + dvec3 cameraNormal = normalize(cameraPos - dvec3(centerWorldPos.xyz)); dvec3 newRight = normalize(cross(cameraLookUp, cameraNormal)); - dvec3 newUp = cross(cameraNormal, newRight); + dvec3 newUp = cross(cameraNormal, newRight); vec4 wCameraRight = vec4(newRight, 0.0); vec4 wCameraUp = vec4(newUp, 0.0); diff --git a/modules/gaia/shaders/gaia_point_ge.glsl b/modules/gaia/shaders/gaia_point_ge.glsl index e8eeecb2aa..b36e18f5bb 100644 --- a/modules/gaia/shaders/gaia_point_ge.glsl +++ b/modules/gaia/shaders/gaia_point_ge.glsl @@ -61,14 +61,14 @@ void main() { // Discard geometry if star has no position (but wasn't a nullArray). // Or if observed distance is above threshold set by cutOffThreshold. // By discarding in gs instead of fs we save computations for when nothing is visible. - if( length(position) < EPS || distThreshold <= 0){ + if (length(position) < EPS || distThreshold <= 0) { return; } //gl_PointSize = 1.0; gl_Position = position; gl_Position.z = 0.0; - ge_gPosition = viewPosition; + ge_gPosition = viewPosition; EmitVertex(); diff --git a/modules/gaia/shaders/gaia_ssbo_vs.glsl b/modules/gaia/shaders/gaia_ssbo_vs.glsl index 08aee91a65..ecd6f1b064 100644 --- a/modules/gaia/shaders/gaia_ssbo_vs.glsl +++ b/modules/gaia/shaders/gaia_ssbo_vs.glsl @@ -179,7 +179,8 @@ void main() { if ( length(in_position) > EPS ){ vs_gPosition = vec4(model * objectPosition); gl_Position = vec4(projection * viewPosition); - } else { + } + else { vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); } diff --git a/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl b/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl index 6b91cc0ef0..f2da517b0b 100644 --- a/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl +++ b/modules/gaia/shaders/gaia_tonemapping_point_fs.glsl @@ -82,7 +82,8 @@ Fragment getFragment() { //vec2 screenOrigo = vec2(-left, -bottom) / vec2(right - left, top - bottom); //if (abs(screenOrigo.x - uv.x) > 0.0005 && abs(screenOrigo.y - uv.y) > 0.0005) { // origoFrag.color = vec4(0.0); - //} else { + //} + //else { // origoFrag.color = vec4(1.0); //} //return origoFrag; diff --git a/modules/gaia/shaders/gaia_vbo_vs.glsl b/modules/gaia/shaders/gaia_vbo_vs.glsl index a87aacf2d1..f5a635c3d2 100644 --- a/modules/gaia/shaders/gaia_vbo_vs.glsl +++ b/modules/gaia/shaders/gaia_vbo_vs.glsl @@ -112,7 +112,8 @@ void main() { if ( length(in_position) > EPS ){ vs_gPosition = vec4(model * objectPosition); gl_Position = vec4(projection * viewPosition); - } else { + } + else { vs_gPosition = vec4(0.0); gl_Position = vec4(0.0); } diff --git a/modules/galaxy/shaders/galaxyraycast.glsl b/modules/galaxy/shaders/galaxyraycast.glsl index dab687e3ca..5bc7bcb4c6 100644 --- a/modules/galaxy/shaders/galaxyraycast.glsl +++ b/modules/galaxy/shaders/galaxyraycast.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * -* Copyright (c) 2014-2019 * +* Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/galaxy/shaders/raycasterbounds_fs.glsl b/modules/galaxy/shaders/raycasterbounds_fs.glsl index 993bc884e1..2ff99f2c5a 100644 --- a/modules/galaxy/shaders/raycasterbounds_fs.glsl +++ b/modules/galaxy/shaders/raycasterbounds_fs.glsl @@ -32,10 +32,10 @@ Fragment getFragment() { Fragment frag; //Early ray termination on black parts of the data /*vec3 normalizedPos = (modelPosition*2.0)-1.0; - if(abs(modelPosition.x) > 0.9 || abs(modelPosition.y) > 0.9){ + if (abs(modelPosition.x) > 0.9 || abs(modelPosition.y) > 0.9) { frag.color = vec4(0.0, 0.0, 0.0, 1.0); } - else{*/ + else {*/ vec3 pos = modelPosition + 0.5; //vec3 posClamp = clamp(pos, vec3(0.0), vec3(1.0)); frag.color = vec4(pos, 1.0); diff --git a/modules/globebrowsing/shaders/blending.hglsl b/modules/globebrowsing/shaders/blending.hglsl index 2157a1314c..166ec948d1 100644 --- a/modules/globebrowsing/shaders/blending.hglsl +++ b/modules/globebrowsing/shaders/blending.hglsl @@ -78,9 +78,11 @@ vec3 rgb2hsl(in vec3 c) { float h = 0.0; if (r == cMax) { h = (g - b) / cDelta; - } else if (g == cMax) { + } + else if (g == cMax) { h = 2.0 + (b - r) / cDelta; - } else { + } + else { h = 4.0 + (r - g) / cDelta; } diff --git a/modules/globebrowsing/shaders/smviewer_fs.glsl b/modules/globebrowsing/shaders/smviewer_fs.glsl index 0d58b4e8aa..62719a89a5 100644 --- a/modules/globebrowsing/shaders/smviewer_fs.glsl +++ b/modules/globebrowsing/shaders/smviewer_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/globebrowsing/shaders/smviewer_vs.glsl b/modules/globebrowsing/shaders/smviewer_vs.glsl index 958527c339..c5bb033b36 100644 --- a/modules/globebrowsing/shaders/smviewer_vs.glsl +++ b/modules/globebrowsing/shaders/smviewer_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/globebrowsing/src/lrucache.inl b/modules/globebrowsing/src/lrucache.inl index 2d3dd0b140..2e67893a80 100644 --- a/modules/globebrowsing/src/lrucache.inl +++ b/modules/globebrowsing/src/lrucache.inl @@ -69,7 +69,8 @@ bool LRUCache::touch(const KeyType& key) { _itemMap.emplace(key, _itemList.begin()); return true; - } else { + } + else { return false; } } diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 257ebd550f..d205fc4a5a 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -330,7 +330,7 @@ BoundingHeights boundingHeightsForChunk(const Chunk& chunk, const LayerManager& } lastHadMissingData = tileMetaData.hasMissingData[HeightChannel]; } - else if(chunkTile.tile.status == Tile::Status::Unavailable) { + else if (chunkTile.tile.status == Tile::Status::Unavailable) { boundingHeights.tileOK = false; } diff --git a/modules/imgui/src/guiassetcomponent.cpp b/modules/imgui/src/guiassetcomponent.cpp index bff854cdd3..34fb9d629a 100644 --- a/modules/imgui/src/guiassetcomponent.cpp +++ b/modules/imgui/src/guiassetcomponent.cpp @@ -112,7 +112,8 @@ void GuiAssetComponent::renderTree(const Asset& asset, const std::string& relati if (requested.empty() && required.empty() && resourceSyncs.empty()) { ImGui::Text("%s", assetText.c_str()); - } else if (ImGui::TreeNode(assetPath.c_str(), "%s", assetText.c_str())) { + } + else if (ImGui::TreeNode(assetPath.c_str(), "%s", assetText.c_str())) { for (const std::shared_ptr& child : required) { renderTree(*child, assetDirectory); } diff --git a/modules/imgui/src/guiiswacomponent.cpp b/modules/imgui/src/guiiswacomponent.cpp index 0b0824ca11..468968de69 100644 --- a/modules/imgui/src/guiiswacomponent.cpp +++ b/modules/imgui/src/guiiswacomponent.cpp @@ -87,7 +87,8 @@ void GuiIswaComponent::render() { script, scripting::ScriptEngine::RemoteScripting::Yes ); - } else { + } + else { global::scriptEngine.queueScript( "openspace.iswa.removeGroup('GMData');", scripting::ScriptEngine::RemoteScripting::Yes @@ -106,7 +107,8 @@ void GuiIswaComponent::render() { script, scripting::ScriptEngine::RemoteScripting::Yes ); - } else { + } + else { global::scriptEngine.queueScript( "openspace.iswa.removeGroup('GMImage');", scripting::ScriptEngine::RemoteScripting::Yes @@ -114,13 +116,14 @@ void GuiIswaComponent::render() { } } - if(_ionData != oldIonDataValue) { - if(_ionData) { + if (_ionData != oldIonDataValue) { + if (_ionData) { global::scriptEngine.queueScript( "openspace.iswa.addCygnet(-10, 'Data', 'Ionosphere');", scripting::ScriptEngine::RemoteScripting::Yes ); - } else { + } + else { global::scriptEngine.queueScript( "openspace.iswa.removeGroup('Ionosphere');", scripting::ScriptEngine::RemoteScripting::Yes @@ -202,7 +205,8 @@ void GuiIswaComponent::render() { "openspace.iswa.addScreenSpaceCygnet({CygnetId=" + idStr + "});", scripting::ScriptEngine::RemoteScripting::Yes ); - } else { + } + else { global::scriptEngine.queueScript( "openspace.iswa.removeScreenSpaceCygnet(" + idStr + ");", scripting::ScriptEngine::RemoteScripting::Yes diff --git a/modules/imgui/src/guiparallelcomponent.cpp b/modules/imgui/src/guiparallelcomponent.cpp index b108911774..60527364bc 100644 --- a/modules/imgui/src/guiparallelcomponent.cpp +++ b/modules/imgui/src/guiparallelcomponent.cpp @@ -146,7 +146,8 @@ void GuiParallelComponent::renderHost() { const size_t nClients = nConnections - 1; if (nClients == 1) { connectionInfo = "Hosting session with 1 client"; - } else { + } + else { connectionInfo = "Hosting session with " + std::to_string(nClients) + " clients"; } diff --git a/modules/iswa/rendering/datacygnet.cpp b/modules/iswa/rendering/datacygnet.cpp index 6b556a073a..35e17aae52 100644 --- a/modules/iswa/rendering/datacygnet.cpp +++ b/modules/iswa/rendering/datacygnet.cpp @@ -140,7 +140,8 @@ bool DataCygnet::updateTexture() { texture->setFilter(Texture::FilterMode::LinearMipMap); _textures[option] = std::move(texture); } - } else { + } + else { _textures[option]->setPixelData(values); _textures[option]->uploadTexture(); } @@ -227,7 +228,8 @@ void DataCygnet::setTextureUniforms() { tfUnits[0].activate(); _transferFunctions[0].bind(); _shader->setUniform("transferFunctions[0]", tfUnits[0]); - } else { + } + else { for (int option : selectedOptions) { if (static_cast(_transferFunctions.size()) >= option) { tfUnits[j].activate(); @@ -284,7 +286,8 @@ void DataCygnet::fillOptions(const std::string& source) { g->registerOptions(_dataOptions.options()); _dataOptions.setValue(g->dataOptionsValue()); - } else { + } + else { _dataOptions.setValue(std::vector(1, 0)); } } diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index 4e51556b0d..a4dcc8ce83 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -49,7 +49,8 @@ void DataPlane::initializeGL() { if (_group) { _dataProcessor = _group->dataProcessor(); subscribeToGroup(); - } else { + } + else { _dataProcessor = std::make_shared(); //If autofiler is on, background values property should be hidden @@ -60,7 +61,8 @@ void DataPlane::initializeGL() { _backgroundValues = _dataProcessor->filterValues(); _backgroundValues.setVisibility(properties::Property::Visibility::Hidden); // else if autofilter is turned off, register backgroundValues - } else { + } + else { _backgroundValues.setVisibility(properties::Property::Visibility::All); } }); @@ -148,7 +150,7 @@ std::vector DataPlane::textureData(){ return std::vector(); } - if(!_dataOptions.options().size()) { // load options for value selection + if (!_dataOptions.options().size()) { // load options for value selection fillOptions(_dataBuffer); _dataProcessor->addDataValues(_dataBuffer, _dataOptions); diff --git a/modules/iswa/rendering/datasphere.cpp b/modules/iswa/rendering/datasphere.cpp index 868ee0de16..318b9d8a19 100644 --- a/modules/iswa/rendering/datasphere.cpp +++ b/modules/iswa/rendering/datasphere.cpp @@ -60,7 +60,8 @@ void DataSphere::initializeGL() { if (_group) { _dataProcessor = _group->dataProcessor(); subscribeToGroup(); - } else { + } + else { _dataProcessor = std::make_shared(); //If autofiler is on, background values property should be hidden _autoFilter.onChange([this]() { @@ -71,7 +72,8 @@ void DataSphere::initializeGL() { _backgroundValues.setVisibility(properties::Property::Visibility::Hidden); //_backgroundValues.setVisible(false); // else if autofilter is turned off, register backgroundValues - } else { + } + else { _backgroundValues.setVisibility(properties::Property::Visibility::All); //_backgroundValues.setVisible(true); } diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index e4d0b91906..2482037464 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -110,7 +110,8 @@ void IswaCygnet::initializeGL() { if (!_data.groupName.empty()) { initializeGroup(); - } else { + } + else { _delete.onChange([this]() { deinitialize(); global::scriptEngine.queueScript( diff --git a/modules/iswa/rendering/iswadatagroup.cpp b/modules/iswa/rendering/iswadatagroup.cpp index 89f563871a..33a6275dab 100644 --- a/modules/iswa/rendering/iswadatagroup.cpp +++ b/modules/iswa/rendering/iswadatagroup.cpp @@ -134,7 +134,8 @@ void IswaDataGroup::registerProperties() { _backgroundValues.setVisibility(properties::Property::Visibility::Hidden); //_backgroundValues.setVisible(false); // else if autofilter is turned off, register backgroundValues - } else { + } + else { _backgroundValues.setVisibility(properties::Property::Visibility::All); //_backgroundValues.setVisible(true); } @@ -194,9 +195,11 @@ void IswaDataGroup::registerOptions( void IswaDataGroup::createDataProcessor() { if (_type == typeid(DataPlane).name()) { _dataProcessor = std::make_shared(); - }else if (_type == typeid(DataSphere).name()) { + } + else if (_type == typeid(DataSphere).name()) { _dataProcessor = std::make_shared(); - }else if (_type == typeid(KameleonPlane).name()) { + } + else if (_type == typeid(KameleonPlane).name()) { _dataProcessor = std::make_shared(); } } diff --git a/modules/iswa/rendering/iswakameleongroup.cpp b/modules/iswa/rendering/iswakameleongroup.cpp index ffff28ada9..df227ff0b5 100644 --- a/modules/iswa/rendering/iswakameleongroup.cpp +++ b/modules/iswa/rendering/iswakameleongroup.cpp @@ -155,7 +155,8 @@ void IswaKameleonGroup::updateFieldlineSeeds() { ); std::get<2>(seedPath.second) = false; // if this option was turned on - } else if (it != options.end() && !std::get<2>(seedPath.second)) { + } + else if (it != options.end() && !std::get<2>(seedPath.second)) { LDEBUG("Created fieldlines: " + std::get<0>(seedPath.second)); IswaManager::ref().createFieldline( diff --git a/modules/iswa/rendering/kameleonplane.cpp b/modules/iswa/rendering/kameleonplane.cpp index 18ee019d18..bfc889e835 100644 --- a/modules/iswa/rendering/kameleonplane.cpp +++ b/modules/iswa/rendering/kameleonplane.cpp @@ -131,7 +131,8 @@ void KameleonPlane::initializeGL() { if (_group) { _dataProcessor = _group->dataProcessor(); subscribeToGroup(); - } else { + } + else { _dataProcessor = std::make_shared(); //If autofiler is on, background values property should be hidden @@ -143,7 +144,8 @@ void KameleonPlane::initializeGL() { _backgroundValues.setVisibility(properties::Property::Visibility::Hidden); //_backgroundValues.setVisible(false); // else if autofilter is turned off, register backgroundValues - } else { + } + else { _backgroundValues.setVisibility(properties::Property::Visibility::All); //_backgroundValues.setVisible(true); } @@ -286,7 +288,8 @@ void KameleonPlane::updateFieldlineSeeds() { ); std::get<2>(seedPath.second) = false; // if this option was turned on - } else if (it != selectedOptions.end() && !std::get<2>(seedPath.second)) { + } + else if (it != selectedOptions.end() && !std::get<2>(seedPath.second)) { SceneGraphNode* n = global::renderEngine.scene()->sceneGraphNode( std::get<0>(seedPath.second) ); @@ -377,9 +380,11 @@ void KameleonPlane::setDimensions() { if (_cut == Cut::X) { _textureDimensions = glm::size3_t(_dimensions.y, _dimensions.z, 1); - } else if (_cut == Cut::Y) { + } + else if (_cut == Cut::Y) { _textureDimensions = glm::size3_t(_dimensions.x, _dimensions.z, 1); - } else { + } + else { _textureDimensions = glm::size3_t(_dimensions.x, _dimensions.y, 1); } } diff --git a/modules/iswa/rendering/texturecygnet.cpp b/modules/iswa/rendering/texturecygnet.cpp index 7d9823bcd4..7f21ffb29d 100644 --- a/modules/iswa/rendering/texturecygnet.cpp +++ b/modules/iswa/rendering/texturecygnet.cpp @@ -94,10 +94,12 @@ bool TextureCygnet::updateTextureResource() { if (imageFile.corrupted) { delete[] imageFile.buffer; return false; - } else { + } + else { _imageFile = imageFile; } - } else { + } + else { return false; } diff --git a/modules/iswa/shaders/dataplane_fs.glsl b/modules/iswa/shaders/dataplane_fs.glsl index 893fb2e313..9e53abf9cb 100644 --- a/modules/iswa/shaders/dataplane_fs.glsl +++ b/modules/iswa/shaders/dataplane_fs.glsl @@ -62,7 +62,8 @@ Fragment getFragment() { else { diffuse = texture(transferFunctions[0], vec2(v, 0.0)); } - } else { + } + else { float v = 0.0; for (int i = 0; i < numTextures; i++) { v = texture(textures[i], vs_st).r; diff --git a/modules/iswa/shaders/datasphere_fs.glsl b/modules/iswa/shaders/datasphere_fs.glsl index 58435e4ba3..a374bd57c2 100644 --- a/modules/iswa/shaders/datasphere_fs.glsl +++ b/modules/iswa/shaders/datasphere_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/iswa/shaders/datasphere_vs.glsl b/modules/iswa/shaders/datasphere_vs.glsl index fb4befc750..af4b217a9b 100644 --- a/modules/iswa/shaders/datasphere_vs.glsl +++ b/modules/iswa/shaders/datasphere_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/iswa/util/dataprocessor.cpp b/modules/iswa/util/dataprocessor.cpp index 7c8e82603b..0bda04e042 100644 --- a/modules/iswa/util/dataprocessor.cpp +++ b/modules/iswa/util/dataprocessor.cpp @@ -72,7 +72,8 @@ float DataProcessor::processDataPoint(float value, int option) { return histogram.equalize( normalizeWithStandardScore(value, mean, sd, _histNormValues) ) / 512.f; - } else { + } + else { return normalizeWithStandardScore(value, mean, sd, _normValues); } } @@ -153,7 +154,8 @@ void DataProcessor::calculateFilterValues(const std::vector& selectedOption standardDeviation, _normValues) ); - } else { + } + else { Histogram hist = _histograms[option]->equalize(); filterMid = hist.highestBinValue(true); filterWidth = 1.f / 512.f; diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index 0be92828ef..5046bb85a9 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -147,7 +147,8 @@ IswaManager& IswaManager::ref() { void IswaManager::addIswaCygnet(int id, const std::string& type, std::string group) { if (id > 0) { createScreenSpace(id); - } else if (id < 0) { + } + else if (id < 0) { // create metadata object and assign group and id MetadataFuture metaFuture; metaFuture.id = id; @@ -156,9 +157,11 @@ void IswaManager::addIswaCygnet(int id, const std::string& type, std::string gro // Assign type of cygnet Texture/Data if (type == _type[CygnetType::Texture]) { metaFuture.type = CygnetType::Texture; - } else if (type == _type[CygnetType::Data]) { + } + else if (type == _type[CygnetType::Data]) { metaFuture.type = CygnetType::Data; - } else { + } + else { LERROR("\""+ type + "\" is not a valid type"); return; } @@ -178,7 +181,8 @@ void IswaManager::addIswaCygnet(int id, const std::string& type, std::string gro if (j["Coordinate Type"].is_null()) { metaFuture.geom = CygnetGeometry::Sphere; createSphere(metaFuture); - } else if (j["Coordinate Type"] == "Cartesian") { + } + else if (j["Coordinate Type"] == "Cartesian") { metaFuture.geom = CygnetGeometry::Plane; createPlane(metaFuture); } @@ -258,7 +262,8 @@ std::string IswaManager::iswaUrl(int id, double timestamp, const std::string& ty std::string url; if (id < 0) { url = _baseUrl + type + "/" + std::to_string(-id) + "/"; - } else { + } + else { url = "http://iswa3.ccmc.gsfc.nasa.gov/IswaSystemWebApp/iSWACygnetStreamer?" "window=-1&cygnetId="+ std::to_string(id) +"×tamp="; } @@ -292,18 +297,21 @@ void IswaManager::registerGroup(std::string groupName, std::string type) { std::move(groupName), std::move(type) ); - } else if (kameleonGroup) { + } + else if (kameleonGroup) { _groups[groupName] = std::make_shared( std::move(groupName), std::move(type) ); - } else { + } + else { _groups[groupName] = std::make_shared( std::move(groupName), std::move(type) ); } - } else if (!_groups[groupName]->isType(type)) { + } + else if (!_groups[groupName]->isType(type)) { LWARNING("Can't add cygnet to groups with diffent type"); } } @@ -425,7 +433,8 @@ std::string IswaManager::parseKWToLuaTable(const CdfInfo& info, const std::strin spatialScale.w = 6; coordinateType = "Cartesian"; - } else { + } + else { spatialScale = glm::vec4(1.f); spatialScale.w = 1; //-log10(1.0f/max.x); coordinateType = "Polar"; @@ -514,7 +523,8 @@ void IswaManager::createPlane(MetadataFuture& data) { std::string type; if (data.type == CygnetType::Data) { type = typeid(DataPlane).name(); - } else { + } + else { type = typeid(TexturePlane).name(); } @@ -523,7 +533,8 @@ void IswaManager::createPlane(MetadataFuture& data) { auto it = _groups.find(data.group); if (it == _groups.end() || (*it).second->isType(type)) { name = data.group + "_" + name; - } else { + } + else { data.group = ""; } } @@ -549,14 +560,15 @@ void IswaManager::createSphere(MetadataFuture& data) { // check if this sphere already exist std::string name = _type[data.type] + _geom[data.geom] + std::to_string(data.id); - if(!data.group.empty()){ + if (!data.group.empty()){ std::string type = typeid(DataSphere).name(); registerGroup(data.group, type); auto it = _groups.find(data.group); if (it == _groups.end() || (*it).second->isType(type)) { name = data.group + "_" + name; - } else { + } + else { data.group = ""; } } @@ -589,7 +601,8 @@ void IswaManager::createKameleonPlane(CdfInfo info, std::string cut) { auto it = _groups.find(info.group); if (it == _groups.end() || (*it).second->isType(type)) { info.name = info.group + "_" + info.name; - } else { + } + else { info.group = ""; } } @@ -609,7 +622,8 @@ void IswaManager::createKameleonPlane(CdfInfo info, std::string cut) { scripting::ScriptEngine::RemoteScripting::Yes ); } - } else { + } + else { LWARNING( absPath(info.path) + " is not a cdf file or can't be found."); } } @@ -648,7 +662,8 @@ void IswaManager::createFieldline(std::string name, std::string cdfPath, scripting::ScriptEngine::RemoteScripting::Yes ); } - } else { + } + else { LWARNING( cdfPath + " is not a cdf file or can't be found."); } } @@ -728,7 +743,8 @@ void IswaManager::addCdfFiles(std::string cdfpath) { jsonFile.close(); } - } else { + } + else { LWARNING(cdfpath + " is not a cdf file or can't be found."); } } diff --git a/modules/iswa/util/iswamanager_lua.inl b/modules/iswa/util/iswamanager_lua.inl index fc93fd30db..b2f609ad3c 100644 --- a/modules/iswa/util/iswamanager_lua.inl +++ b/modules/iswa/util/iswamanager_lua.inl @@ -88,7 +88,8 @@ int iswa_addScreenSpaceCygnet(lua_State* L) { if (global::renderEngine.screenSpaceRenderable(name)) { LERROR("A cygnet with the name \"" + name +"\" already exist"); return 0; - } else { + } + else { d.setValue("Name", name); d.setValue("Type", "ScreenSpaceCygnet"); d.setValue("UpdateInterval", static_cast(updateInterval)); @@ -108,14 +109,17 @@ int iswa_addScreenSpaceCygnet(lua_State* L) { // std::string type = "x"; // std::string group = ""; -// if(nArguments > 0) +// if (nArguments > 0) { // kwPath = luaL_checkstring(L, 1); +// } -// if(nArguments > 1) +// if (nArguments > 1) { // type = luaL_checkstring(L, 2); +// } -// if(nArguments > 2) +// if (nArguments > 2) { // group = luaL_checkstring(L, 3); +// } // IswaManager::ref().createKameleonPlane(kwPath, type, group); // return 0; diff --git a/modules/kameleon/src/kameleonhelper.cpp b/modules/kameleon/src/kameleonhelper.cpp index 67d7983af2..53bbf3f08a 100644 --- a/modules/kameleon/src/kameleonhelper.cpp +++ b/modules/kameleon/src/kameleonhelper.cpp @@ -81,7 +81,8 @@ double getTime(ccmc::Kameleon* kameleon) { if (kameleon->doesAttributeExist("start_time")){ seqStartStr = kameleon->getGlobalAttribute("start_time").getAttributeString(); - } else if (kameleon->doesAttributeExist("tim_rundate_cal")) { + } + else if (kameleon->doesAttributeExist("tim_rundate_cal")) { seqStartStr = kameleon->getGlobalAttribute("tim_rundate_cal").getAttributeString(); const size_t N_CHARS = seqStartStr.length(); @@ -111,13 +112,16 @@ double getTime(ccmc::Kameleon* kameleon) { break; } } - } else if (kameleon->doesAttributeExist("tim_obsdate_cal")) { + } + else if (kameleon->doesAttributeExist("tim_obsdate_cal")) { seqStartStr = kameleon->getGlobalAttribute("tim_obsdate_cal").getAttributeString(); - } else if (kameleon->doesAttributeExist("tim_crstart_cal")) { + } + else if (kameleon->doesAttributeExist("tim_crstart_cal")) { seqStartStr = kameleon->getGlobalAttribute("tim_crstart_cal").getAttributeString(); - } else { + } + else { LWARNING( "No starting time attribute could be found in the .cdf file. Starting " "time is set to 01.JAN.2000 12:00." @@ -133,7 +137,8 @@ double getTime(ccmc::Kameleon* kameleon) { seqStartDbl = Time::convertTime( seqStartStr.substr(0, seqStartStr.length() - 2) ); - } else { + } + else { LWARNING("No starting time attribute could be found in the .cdf file." "Starting time is set to 01.JAN.2000 12:00."); seqStartDbl = 0.0; @@ -144,10 +149,12 @@ double getTime(ccmc::Kameleon* kameleon) { if (kameleon->doesAttributeExist("elapsed_time_in_seconds")) { ccmc::Attribute att = kameleon->getGlobalAttribute("elapsed_time_in_seconds"); stateStartOffset = static_cast(att.getAttributeFloat()); - } else if (kameleon->doesAttributeExist("time_physical_time")) { + } + else if (kameleon->doesAttributeExist("time_physical_time")) { ccmc::Attribute att = kameleon->getGlobalAttribute("time_physical_time"); stateStartOffset = static_cast(att.getAttributeFloat()); - } else { + } + else { stateStartOffset = 0.0; LWARNING("No time offset attribute could be found in the .cdf file." "The current state starts the same time as the sequence!"); diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index c3fdbbdc05..6f725b1c2b 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -248,7 +248,8 @@ float* KameleonWrapper::uniformSampledValues(const std::string& var, LWARNING("Warning: There might be a gap in the data"); } // Leave values at zero if outside domain - } else { // if inside + } + else { // if inside // ENLIL CDF specific hacks! // Convert from meters to AU for interpolator const double localRPh = rPh / ccmc::constants::AU_in_meters; @@ -268,8 +269,8 @@ float* KameleonWrapper::uniformSampledValues(const std::string& var, doubleData[index] = value; histogram[mapToHistogram(value)]++; - - } else { + } + else { // Assume cartesian for fallback purpose const double stepX = (_max.x - _min.x) / (static_cast(outDimensions.x)); @@ -408,7 +409,9 @@ float* KameleonWrapper::uniformSliceValues(const std::string& var, LWARNING("Warning: There might be a gap in the data"); } // Leave values at zero if outside domain - } else { // if inside + } + else { + // if inside // ENLIL CDF specific hacks! // Convert from meters to AU for interpolator const double localRPh = rPh / ccmc::constants::AU_in_meters; @@ -426,7 +429,8 @@ float* KameleonWrapper::uniformSliceValues(const std::string& var, ); } - } else { + } + else { const double xPos = _min.x + stepX * xi; const double yPos = _min.y + stepY * yi; const double zPos = _min.z + stepZ * zi; @@ -443,7 +447,8 @@ float* KameleonWrapper::uniformSliceValues(const std::string& var, if (value != missingValue) { doubleData[index] = value; data[index] = static_cast(value); - } else { + } + else { doubleData[index] = 0; } } @@ -513,7 +518,8 @@ float* KameleonWrapper::uniformSampledVectorValues(const std::string& xVar, data[index + 2] = (zVal - varZMin) / (varZMax - varZMin); // B // GL_RGB refuses to work. Workaround doing a GL_RGBA hardcoded alpha data[index + 3] = 1.f; - } else { + } + else { LERROR( "Only cartesian grid supported for " "uniformSampledVectorValues (for now)" @@ -579,7 +585,8 @@ KameleonWrapper::Fieldlines KameleonWrapper::classifiedFieldLines(const std::str fieldLines.push_back(line); } - } else { + } + else { LERROR("Fieldlines are only supported for BATSRUS model"); } @@ -637,7 +644,8 @@ KameleonWrapper::Fieldlines KameleonWrapper::fieldLines(const std::string& xVar, fieldLines.push_back(line); } - } else { + } + else { LERROR("Fieldlines are only supported for BATSRUS model"); } @@ -989,17 +997,23 @@ KameleonWrapper::Model KameleonWrapper::modelType() const { _kameleon->getGlobalAttribute("model_name").getAttributeString(); if (modelName == "open_ggcm" || modelName == "ucla_ggcm") { return Model::OpenGGCM; - } else if (modelName == "batsrus") { + } + else if (modelName == "batsrus") { return Model::BATSRUS; - } else if (modelName == "enlil") { + } + else if (modelName == "enlil") { return Model::ENLIL; - } else if (modelName == "mas") { + } + else if (modelName == "mas") { return Model::MAS; - } else if (modelName == "ADAPT3D") { + } + else if (modelName == "ADAPT3D") { return Model::Adapt3D; - } else if (modelName == "swmf") { + } + else if (modelName == "swmf") { return Model::SWMF; - } else if (modelName == "LFM") { + } + else if (modelName == "LFM") { return Model::LFM; } } @@ -1012,17 +1026,20 @@ glm::vec4 KameleonWrapper::classifyFieldline(FieldlineEnd fEnd, FieldlineEnd bEn { // closed return glm::vec4(1.f, 0.f, 0.f, 1.f); - } else if ((fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::NORTH) || - (bEnd == FieldlineEnd::FAROUT && fEnd == FieldlineEnd::NORTH)) + } + else if ((fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::NORTH) || + (bEnd == FieldlineEnd::FAROUT && fEnd == FieldlineEnd::NORTH)) { // north return glm::vec4(1.f, 1.f, 0.f, 1.f); - } else if ((fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::SOUTH) || - (bEnd == FieldlineEnd::FAROUT && fEnd == FieldlineEnd::SOUTH)) + } + else if ((fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::SOUTH) || + (bEnd == FieldlineEnd::FAROUT && fEnd == FieldlineEnd::SOUTH)) { // south return glm::vec4(0.f, 1.f, 0.f, 1.f); - } else if (fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::FAROUT) { + } + else if (fEnd == FieldlineEnd::FAROUT && bEnd == FieldlineEnd::FAROUT) { // solar wind return glm::vec4(0.f, 0.f, 1.f, 1.f); } diff --git a/modules/kameleonvolume/kameleonvolumereader.cpp b/modules/kameleonvolume/kameleonvolumereader.cpp index bd692888ef..0df6caca5d 100644 --- a/modules/kameleonvolume/kameleonvolumereader.cpp +++ b/modules/kameleonvolume/kameleonvolumereader.cpp @@ -222,7 +222,8 @@ std::string KameleonVolumeReader::simulationStart() const { std::string startTime; if (_kameleon.model->doesAttributeExist("start_time")) { startTime = globalAttribute(*_kameleon.model, "start_time"); - } else if (_kameleon.model->doesAttributeExist("tim_rundate_cal")) { + } + else if (_kameleon.model->doesAttributeExist("tim_rundate_cal")) { startTime = globalAttribute(*_kameleon.model, "tim_rundate_cal"); size_t numChars = startTime.length(); if (numChars < 19) { @@ -247,9 +248,11 @@ std::string KameleonVolumeReader::simulationStart() const { break; } } - } else if (_kameleon.model->doesAttributeExist("tim_obsdate_cal")) { + } + else if (_kameleon.model->doesAttributeExist("tim_obsdate_cal")) { startTime = globalAttribute(*_kameleon.model, "tim_obsdate_cal"); - } else if (_kameleon.model->doesAttributeExist("tim_crstart_cal")) { + } + else if (_kameleon.model->doesAttributeExist("tim_crstart_cal")) { startTime = globalAttribute(*_kameleon.model, "tim_crstart_cal"); } @@ -263,7 +266,8 @@ std::string KameleonVolumeReader::simulationStart() const { float KameleonVolumeReader::elapsedTime() const { if (_kameleon.model->doesAttributeExist("elapsed_time_in_seconds")) { return globalAttribute(*_kameleon.model, "elapsed_time_in_seconds"); - } else if (_kameleon.model->doesAttributeExist("time_physical_time")) { + } + else if (_kameleon.model->doesAttributeExist("time_physical_time")) { return globalAttribute(*_kameleon.model, "time_physical_time"); } return 0.f; diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp index e221255fd1..7daeed8749 100644 --- a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -329,7 +329,8 @@ void RenderableKameleonVolume::load() { ); if (FileSys.fileExists(cachePath)) { loadRaw(cachePath); - } else { + } + else { loadFromPath(_sourcePath); storeRaw(cachePath); } @@ -351,7 +352,8 @@ void RenderableKameleonVolume::loadFromPath(const std::string& path) { ); if (extension == "cdf") { loadCdf(path); - } else { + } + else { loadRaw(path); } } diff --git a/modules/multiresvolume/rendering/brickselection.cpp b/modules/multiresvolume/rendering/brickselection.cpp index 3a6c844635..fa37a64ec7 100644 --- a/modules/multiresvolume/rendering/brickselection.cpp +++ b/modules/multiresvolume/rendering/brickselection.cpp @@ -70,7 +70,8 @@ BrickSelection BrickSelection::splitTemporally(bool t, unsigned int childBrickIn if (t) { child.lowT = centerT(); child.highT = highT; - } else { + } + else { child.lowT = lowT; child.highT = centerT(); } diff --git a/modules/multiresvolume/rendering/errorhistogrammanager.cpp b/modules/multiresvolume/rendering/errorhistogrammanager.cpp index 7fbef2d659..726ea4b21c 100644 --- a/modules/multiresvolume/rendering/errorhistogrammanager.cpp +++ b/modules/multiresvolume/rendering/errorhistogrammanager.cpp @@ -117,7 +117,8 @@ bool ErrorHistogramManager::buildFromLeaf(unsigned int bstOffset, _histograms[innerNodeIndex] = Histogram(_minBin, _maxBin, _numBins); ancestorVoxels = readValues(ancestorBrickIndex); _voxelCache[innerNodeIndex] = ancestorVoxels; - } else { + } + else { ancestorVoxels = it->second; } @@ -289,7 +290,8 @@ const Histogram* ErrorHistogramManager::histogram(unsigned int brickIndex) const const unsigned int innerNodeIndex = brickToInnerNodeIndex(brickIndex); if (innerNodeIndex < _numInnerNodes) { return &(_histograms[innerNodeIndex]); - } else { + } + else { return nullptr; } } diff --git a/modules/multiresvolume/rendering/histogrammanager.cpp b/modules/multiresvolume/rendering/histogrammanager.cpp index 83711cafd2..d0ad4a8ed7 100644 --- a/modules/multiresvolume/rendering/histogrammanager.cpp +++ b/modules/multiresvolume/rendering/histogrammanager.cpp @@ -64,7 +64,8 @@ bool HistogramManager::buildHistogram(TSP* tsp, unsigned int brickIndex) { for (size_t v = 0; v < numVoxels; ++v) { histogram.add(voxelValues[v], 1.0); } - } else { + } + else { // Has children std::vector children; @@ -89,7 +90,8 @@ bool HistogramManager::buildHistogram(TSP* tsp, unsigned int brickIndex) { // If node has both BST and Octree children, only add BST ones histogram.add(_histograms[childIndex]); } - } else { + } + else { return false; } } diff --git a/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp b/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp index 5a9f7ca421..39f53d52c1 100644 --- a/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp +++ b/modules/multiresvolume/rendering/localerrorhistogrammanager.cpp @@ -129,12 +129,14 @@ bool LocalErrorHistogramManager::buildFromOctreeChild(unsigned int bstOffset, if (isOctreeLeaf) { childValues = readValues(childIndex); - } else { + } + else { const unsigned int childInnerNodeIndex = brickToInnerNodeIndex(childIndex); auto it = _voxelCache.find(childInnerNodeIndex); if (it != _voxelCache.end()) { childValues = it->second; - } else { + } + else { LERROR(fmt::format( "Child {} visited without cache, {}, {}", childIndex, @@ -149,11 +151,13 @@ bool LocalErrorHistogramManager::buildFromOctreeChild(unsigned int bstOffset, if (octreeChildIndex == 0) { parentValues = readValues(parentIndex); _voxelCache[parentInnerNodeIndex] = parentValues; - } else { + } + else { auto it = _voxelCache.find(parentInnerNodeIndex); if (it != _voxelCache.end()) { parentValues = it->second; - } else { + } + else { LERROR(fmt::format("Parent {} visited without cache", parentIndex)); return false; } @@ -231,12 +235,14 @@ bool LocalErrorHistogramManager::buildFromBstChild(unsigned int bstOffset, if (isBstLeaf) { childValues = readValues(childIndex); - } else { + } + else { unsigned int childInnerNodeIndex = brickToInnerNodeIndex(childIndex); auto it = _voxelCache.find(childInnerNodeIndex); if (it != _voxelCache.end()) { childValues = it->second; - } else { + } + else { LERROR(fmt::format("Child {} visited without cache", childIndex)); return false; } @@ -246,11 +252,13 @@ bool LocalErrorHistogramManager::buildFromBstChild(unsigned int bstOffset, if (bstChildIndex == 1) { parentValues = readValues(parentIndex); _voxelCache[parentInnerNodeIndex] = parentValues; - } else { + } + else { auto it = _voxelCache.find(parentInnerNodeIndex); if (it != _voxelCache.end()) { parentValues = it->second; - } else { + } + else { LERROR(fmt::format("Parent {} visited without cache", parentIndex)); return false; } @@ -433,7 +441,8 @@ const Histogram* LocalErrorHistogramManager::spatialHistogram( const unsigned int innerNodeIndex = brickToInnerNodeIndex(brickIndex); if (innerNodeIndex < _numInnerNodes) { return &(_spatialHistograms[innerNodeIndex]); - } else { + } + else { return nullptr; } } @@ -444,7 +453,8 @@ const Histogram* LocalErrorHistogramManager::temporalHistogram( const unsigned int innerNodeIndex = brickToInnerNodeIndex(brickIndex); if (innerNodeIndex < _numInnerNodes) { return &(_temporalHistograms[innerNodeIndex]); - } else { + } + else { return nullptr; } } diff --git a/modules/multiresvolume/rendering/localtfbrickselector.cpp b/modules/multiresvolume/rendering/localtfbrickselector.cpp index 837ddf1928..37d2cd70e4 100644 --- a/modules/multiresvolume/rendering/localtfbrickselector.cpp +++ b/modules/multiresvolume/rendering/localtfbrickselector.cpp @@ -82,7 +82,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) if (splitType != BrickSelection::SplitType::None) { priorityQueue.push_back(brickSelection); - } else { + } + else { leafSelections.push_back(brickSelection); } @@ -135,10 +136,12 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) priorityQueue.end(), compareSplitPoints ); - } else { + } + else { leafSelections.push_back(childSelection); } - } else if (bs.splitType == BrickSelection::SplitType::Spatial) { + } + else if (bs.splitType == BrickSelection::SplitType::Spatial) { nBricksInMemory += 7; // Remove one and add eight. const unsigned int firstChild = _tsp->firstOctreeChild(brickIndex); @@ -156,7 +159,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) } if (bs.splitPoints > -1) { temporalSplitQueue.push_back(bs); - } else { + } + else { deadEnds.push_back(bs); } break; @@ -187,7 +191,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) priorityQueue.end(), compareSplitPoints ); - } else { + } + else { leafSelections.push_back(childSelection); } } @@ -210,7 +215,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) temporalSplitQueue.end(), compareSplitPoints ); - } else { + } + else { deadEnds.push_back(bs); } } @@ -241,7 +247,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) if (pickRightTimeChild) { childBrickIndex = _tsp->bstRight(brickIndex); - } else { + } + else { childBrickIndex = _tsp->bstLeft(brickIndex); } @@ -260,7 +267,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) temporalSplitQueue.end(), compareSplitPoints ); - } else { + } + else { BrickSelection childSelection = bs.splitTemporally( pickRightTimeChild, childBrickIndex, @@ -270,7 +278,8 @@ void LocalTfBrickSelector::selectBricks(int timestep, std::vector& bricks) deadEnds.push_back(childSelection); } } - } else { + } + else { // Write selected inner nodes to brickSelection vector for (const BrickSelection& bs : priorityQueue) { writeSelection(bs, bricks); @@ -316,10 +325,12 @@ float LocalTfBrickSelector::splitPoints(unsigned int brickIndex, if (spatialPoints > 0 && spatialPoints > temporalPoints) { splitPoints = spatialPoints; splitType = BrickSelection::SplitType::Spatial; - } else if (temporalPoints > 0) { + } + else if (temporalPoints > 0) { splitPoints = temporalPoints; splitType = BrickSelection::SplitType::Temporal; - } else { + } + else { splitPoints = -1; splitType = BrickSelection::SplitType::None; } @@ -354,7 +365,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() { for (unsigned int brickIndex = 0; brickIndex < nHistograms; brickIndex++) { if (_tsp->isOctreeLeaf(brickIndex)) { _brickErrors[brickIndex].spatial = 0.0; - } else { + } + else { const Histogram* histogram = _histogramManager->spatialHistogram( brickIndex ); @@ -371,7 +383,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() { if (_tsp->isBstLeaf(brickIndex)) { _brickErrors[brickIndex].temporal = 0.0; - } else { + } + else { const Histogram* histogram = _histogramManager->temporalHistogram( brickIndex ); diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index e07c447b6a..02cfcaaf74 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -221,7 +221,8 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict _startTime = SpiceManager::ref().ephemerisTimeFromDate(startTimeString); _endTime = SpiceManager::ref().ephemerisTimeFromDate(endTimeString); _loop = false; - } else { + } + else { _loop = true; LWARNING("Node does not provide time information. Viewing one image / frame"); } @@ -268,9 +269,11 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict std::string selectorName = _selectorName; if (selectorName == "simple") { _selector = Selector::SIMPLE; - } else if (selectorName == "local") { + } + else if (selectorName == "local") { _selector = Selector::LOCAL; - } else { + } + else { _selector = Selector::TF; } @@ -280,11 +283,14 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict std::string newSelectorName = _selectorName; if (newSelectorName == "simple") { s = Selector::SIMPLE; - } else if (newSelectorName == "local") { + } + else if (newSelectorName == "local") { s = Selector::LOCAL; - } else if (newSelectorName == "tf") { + } + else if (newSelectorName == "tf") { s = Selector::TF; - } else { + } + else { return; } setSelectorType(s); @@ -474,13 +480,15 @@ bool RenderableMultiresVolume::initializeSelector() { fmt::format("Loading histograms from cache: {}", cacheFilename) ); success &= _errorHistogramManager->loadFromFile(cacheFilename); - } else if (_errorHistogramsPath != "") { + } + else if (_errorHistogramsPath != "") { // Read histograms from scene data. LINFO(fmt::format( "Loading histograms from scene data: {}", _errorHistogramsPath )); success &= _errorHistogramManager->loadFromFile(_errorHistogramsPath); - } else { + } + else { // Build histograms from tsp file. LWARNING(fmt::format("Failed to open {}", cacheFilename)); success &= _errorHistogramManager->buildHistograms(nHistograms); @@ -510,7 +518,8 @@ bool RenderableMultiresVolume::initializeSelector() { cacheFile.close(); LINFO(fmt::format("Loading histograms from {}", cacheFilename)); success &= _histogramManager->loadFromFile(cacheFilename); - } else { + } + else { // Build histograms from tsp file. LWARNING(fmt::format("Failed to open '{}'", cacheFilename)); success &= _histogramManager->buildHistograms( @@ -541,7 +550,8 @@ bool RenderableMultiresVolume::initializeSelector() { cacheFile.close(); LINFO(fmt::format("Loading histograms from {}", cacheFilename)); success &= _localErrorHistogramManager->loadFromFile(cacheFilename); - } else { + } + else { // Build histograms from tsp file. LWARNING(fmt::format("Failed to open {}", cacheFilename)); success &= _localErrorHistogramManager->buildHistograms(nHistograms); diff --git a/modules/multiresvolume/rendering/shenbrickselector.cpp b/modules/multiresvolume/rendering/shenbrickselector.cpp index d10de2ef22..c05553a661 100644 --- a/modules/multiresvolume/rendering/shenbrickselector.cpp +++ b/modules/multiresvolume/rendering/shenbrickselector.cpp @@ -74,7 +74,8 @@ void ShenBrickSelector::traverseBST(int timestep, unsigned int brickIndex, if (timestep <= timeSpanCenter) { bstChild = _tsp->bstLeft(brickIndex); timeSpanEnd = timeSpanCenter; - } else { + } + else { bstChild = _tsp->bstRight(brickIndex); timeSpanStart = timeSpanCenter; } @@ -97,11 +98,14 @@ void ShenBrickSelector::selectBricks(int timestep, unsigned int brickIndex, if (_tsp->temporalError(brickIndex) <= _temporalTolerance) { if (_tsp->isOctreeLeaf(bstRootBrickIndex)) { selectCover(coveredBricks, brickIndex, bricks); - } else if (_tsp->spatialError(brickIndex) <= _spatialTolerance) { + } + else if (_tsp->spatialError(brickIndex) <= _spatialTolerance) { selectCover(coveredBricks, brickIndex, bricks); - } else if (_tsp->isBstLeaf(brickIndex)) { + } + else if (_tsp->isBstLeaf(brickIndex)) { traverseOT(timestep, bstRootBrickIndex, coveredBricks, bricks); - } else { + } + else { traverseBST( timestep, brickIndex, @@ -112,13 +116,16 @@ void ShenBrickSelector::selectBricks(int timestep, unsigned int brickIndex, bricks ); } - } else if (_tsp->isBstLeaf(brickIndex)) { + } + else if (_tsp->isBstLeaf(brickIndex)) { if (_tsp->isOctreeLeaf(bstRootBrickIndex)) { selectCover(coveredBricks, brickIndex, bricks); - } else { + } + else { traverseOT(timestep, bstRootBrickIndex, coveredBricks, bricks); } - } else { + } + else { traverseBST( timestep, brickIndex, diff --git a/modules/multiresvolume/rendering/simpletfbrickselector.cpp b/modules/multiresvolume/rendering/simpletfbrickselector.cpp index d69f557a36..78d99e7796 100644 --- a/modules/multiresvolume/rendering/simpletfbrickselector.cpp +++ b/modules/multiresvolume/rendering/simpletfbrickselector.cpp @@ -83,7 +83,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector& bricks) if (splitType != BrickSelection::SplitType::None) { priorityQueue.push_back(brickSelection); - } else { + } + else { leafSelections.push_back(brickSelection); } @@ -137,10 +138,12 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector& bricks) priorityQueue.end(), compareSplitPoints ); - } else { + } + else { leafSelections.push_back(childSelection); } - } else if (bs.splitType == BrickSelection::SplitType::Spatial) { + } + else if (bs.splitType == BrickSelection::SplitType::Spatial) { nBricksInMemory += 7; // Remove one and add eight. unsigned int firstChild = _tsp->firstOctreeChild(brickIndex); @@ -158,7 +161,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector& bricks) } if (bs.splitPoints > -1) { temporalSplitQueue.push_back(bs); - } else { + } + else { deadEnds.push_back(bs); } break; @@ -186,7 +190,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector& bricks) priorityQueue.end(), compareSplitPoints ); - } else { + } + else { leafSelections.push_back(childSelection); } } @@ -208,7 +213,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector& bricks) temporalSplitQueue.end(), compareSplitPoints ); - } else { + } + else { deadEnds.push_back(bs); } } @@ -256,7 +262,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector& bricks) temporalSplitQueue.end(), compareSplitPoints ); - } else { + } + else { BrickSelection childSelection = bs.splitTemporally( pickRightTimeChild, childBrickIndex, @@ -265,7 +272,8 @@ void SimpleTfBrickSelector::selectBricks(int timestep, std::vector& bricks) deadEnds.push_back(childSelection); } } - } else { + } + else { // Write selected inner nodes to brickSelection vector for (const BrickSelection& bs : priorityQueue) { writeSelection(bs, bricks); @@ -309,10 +317,12 @@ float SimpleTfBrickSelector::splitPoints(unsigned int brickIndex, if (spatialPoints > 0 && spatialPoints > temporalPoints) { splitPoints = spatialPoints; splitType = BrickSelection::SplitType::Spatial; - } else if (temporalPoints > 0) { + } + else if (temporalPoints > 0) { splitPoints = temporalPoints; splitType = BrickSelection::SplitType::Temporal; - } else { + } + else { splitPoints = -1; splitType = BrickSelection::SplitType::None; } diff --git a/modules/multiresvolume/rendering/tfbrickselector.cpp b/modules/multiresvolume/rendering/tfbrickselector.cpp index 810c792b92..75036f1a09 100644 --- a/modules/multiresvolume/rendering/tfbrickselector.cpp +++ b/modules/multiresvolume/rendering/tfbrickselector.cpp @@ -84,7 +84,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { if (splitType != BrickSelection::SplitType::None) { priorityQueue.push_back(brickSelection); - } else { + } + else { leafSelections.push_back(brickSelection); } @@ -126,7 +127,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { if (pickRightTimeChild) { childBrickIndex = _tsp->bstRight(brickIndex); - } else { + } + else { childBrickIndex = _tsp->bstLeft(brickIndex); } @@ -145,10 +147,12 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { priorityQueue.end(), compareSplitPoints ); - } else { + } + else { leafSelections.push_back(childSelection); } - } else if (bs.splitType == BrickSelection::SplitType::Spatial) { + } + else if (bs.splitType == BrickSelection::SplitType::Spatial) { nBricksInMemory += 7; // Remove one and add eight. unsigned int firstChild = _tsp->firstOctreeChild(brickIndex); @@ -167,7 +171,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { } if (bs.splitPoints > -1) { temporalSplitQueue.push_back(bs); - } else { + } + else { deadEnds.push_back(bs); } break; @@ -196,7 +201,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { priorityQueue.end(), compareSplitPoints ); - } else { + } + else { leafSelections.push_back(childSelection); } } @@ -224,7 +230,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { temporalSplitQueue.end(), compareSplitPoints ); - } else { + } + else { deadEnds.push_back(bs); } } @@ -273,7 +280,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { temporalSplitQueue.end(), compareSplitPoints ); - } else { + } + else { BrickSelection childSelection = bs.splitTemporally( pickRightTimeChild, childBrickIndex, @@ -283,7 +291,8 @@ void TfBrickSelector::selectBricks(int timestep, std::vector& bricks) { deadEnds.push_back(childSelection); } } - } else { + } + else { // Write selected inner nodes to brickSelection vector //std::cout << "priority queue: " << priorityQueue.size() << std::endl; for (const BrickSelection& bs : priorityQueue) { @@ -357,10 +366,12 @@ float TfBrickSelector::splitPoints(unsigned int brickIndex, if (spatialPoints > 0 && spatialPoints > temporalPoints) { splitPoints = spatialPoints; splitType = BrickSelection::SplitType::Spatial; - } else if (temporalPoints > 0) { + } + else if (temporalPoints > 0) { splitPoints = temporalPoints; splitType = BrickSelection::SplitType::Temporal; - } else { + } + else { splitPoints = -1; splitType = BrickSelection::SplitType::None; } @@ -396,7 +407,8 @@ bool TfBrickSelector::calculateBrickErrors() { for (unsigned int brickIndex = 0; brickIndex < nHistograms; brickIndex++) { if (_tsp->isBstLeaf(brickIndex) && _tsp->isOctreeLeaf(brickIndex)) { _brickErrors[brickIndex] = 0; - } else { + } + else { const Histogram* histogram = _histogramManager->histogram(brickIndex); float error = 0; for (size_t i = 0; i < gradients.size(); i++) { diff --git a/modules/multiresvolume/rendering/tsp.cpp b/modules/multiresvolume/rendering/tsp.cpp index e18c62adc6..bcb194fcea 100644 --- a/modules/multiresvolume/rendering/tsp.cpp +++ b/modules/multiresvolume/rendering/tsp.cpp @@ -436,7 +436,8 @@ bool TSP::calculateTemporalError() { // 0.0 higher up in the tree if (coveredBricks.size() == 1) { errors[brick] = -0.1f; - } else { + } + else { // Calculate standard deviation per voxel, average over brick float avgStdDev = 0.f; for (unsigned int voxel = 0; voxelisDone()) { _topics.emplace(topicId, std::move(topic)); } - } else { + } + else { if (!isAuthorized()) { LERROR("Connection isn't authorized."); return; diff --git a/modules/server/src/serverinterface.cpp b/modules/server/src/serverinterface.cpp index 639535edd2..d5f8ca6517 100644 --- a/modules/server/src/serverinterface.cpp +++ b/modules/server/src/serverinterface.cpp @@ -155,7 +155,8 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config) const std::string type = config.value(TypeInfo.identifier); if (type == TcpSocketType) { _type = static_cast(InterfaceType::TcpSocket); - } else if (type == WebSocketType) { + } + else if (type == WebSocketType) { _type = static_cast(InterfaceType::WebSocket); } diff --git a/modules/server/src/topics/authorizationtopic.cpp b/modules/server/src/topics/authorizationtopic.cpp index e3c7394ff8..b761fa7da5 100644 --- a/modules/server/src/topics/authorizationtopic.cpp +++ b/modules/server/src/topics/authorizationtopic.cpp @@ -51,14 +51,16 @@ bool AuthorizationTopic::isDone() const { void AuthorizationTopic::handleJson(const nlohmann::json& json) { if (isDone()) { _connection->sendJson(wrappedPayload({ KeyStatus, Authorized })); - } else { + } + else { try { auto providedKey = json.at("key").get(); if (authorize(providedKey)) { _connection->setAuthorized(true); _connection->sendJson(wrappedPayload({ KeyStatus, Authorized })); LINFO("Client successfully authorized."); - } else { + } + else { _connection->sendJson(wrappedPayload({ KeyStatus, IncorrectKey })); } } catch (const std::out_of_range&) { diff --git a/modules/server/src/topics/documentationtopic.cpp b/modules/server/src/topics/documentationtopic.cpp index b3f4e2573b..24cbf84cf2 100644 --- a/modules/server/src/topics/documentationtopic.cpp +++ b/modules/server/src/topics/documentationtopic.cpp @@ -55,9 +55,11 @@ void DocumentationTopic::handleJson(const nlohmann::json& json) { // ghoul::Dictionary objects from ScriptEngine, FactoryManager, and KeybindingManager. if (requestedType == TypeLua) { response = json::parse(global::scriptEngine.generateJson()); - } else if (requestedType == TypeFactories) { + } + else if (requestedType == TypeFactories) { response = json::parse(FactoryManager::ref().generateJson()); - } else if (requestedType == TypeKeyboard) { + } + else if (requestedType == TypeKeyboard) { response = json::parse(global::keybindingManager.generateJson()); } diff --git a/modules/server/src/topics/setpropertytopic.cpp b/modules/server/src/topics/setpropertytopic.cpp index dc25536b53..76b05f1c37 100644 --- a/modules/server/src/topics/setpropertytopic.cpp +++ b/modules/server/src/topics/setpropertytopic.cpp @@ -70,11 +70,14 @@ namespace { std::string luaLiteralFromJson(nlohmann::json value) { if (value.is_string()) { return "'" + escapedLuaString(value.get()) + "'"; - } else if (value.is_boolean()) { + } + else if (value.is_boolean()) { return value.get() ? "true" : "false"; - } else if (value.is_number()) { + } + else if (value.is_number()) { return std::to_string(value.get()); - } else if (value.is_array()) { + } + else if (value.is_array()) { std::string literal = "{"; for (nlohmann::json::iterator it = value.begin(); it != value.end(); ++it) { literal += luaLiteralFromJson(it.value()) += ","; @@ -82,7 +85,8 @@ namespace { literal.pop_back(); // remove last comma literal += "}"; return literal; - } else if (value.is_object()) { + } + else if (value.is_object()) { std::string literal = "{"; for (nlohmann::json::iterator it = value.begin(); it != value.end(); ++it) { literal += it.key() + "=" + luaLiteralFromJson(it.value()) += ","; @@ -90,7 +94,8 @@ namespace { literal.pop_back(); // remove last comma literal += "}"; return literal; - }{ + } + else { return "nil"; } } diff --git a/modules/server/src/topics/shortcuttopic.cpp b/modules/server/src/topics/shortcuttopic.cpp index 396ae2c283..34376e0c69 100644 --- a/modules/server/src/topics/shortcuttopic.cpp +++ b/modules/server/src/topics/shortcuttopic.cpp @@ -102,7 +102,8 @@ void ShortcutTopic::handleJson(const nlohmann::json& input) { if (event == StartSubscription) { // TODO: Subscribe to shortcuts and keybindings // shortcutManager.subscribe(); ... - } else if (event == StopSubscription) { + } + else if (event == StopSubscription) { // TODO: Unsubscribe to shortcuts and keybindings // shortcutManager.unsubscribe(); ... return; diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 38a0a94c86..eb486a5035 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -1,26 +1,26 @@ - /**************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ +/**************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ #include diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 6e3bf3d918..377f8c77bd 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -53,12 +53,12 @@ namespace { constexpr const char* KeyStaticFilterValue = "StaticFilter"; constexpr const char* KeyStaticFilterReplacement = "StaticFilterReplacement"; - constexpr const std::array UniformNames = { + constexpr const std::array UniformNames = { "modelMatrix", "cameraUp", "cameraViewProjectionMatrix", "colorOption", "magnitudeExponent", "eyePosition", "psfParamConf", "lumCent", "radiusCent", "brightnessCent", "colorTexture", "alphaValue", "psfTexture", "otherDataTexture", "otherDataRange", - "filterOutOfRange" + "filterOutOfRange", "fixedColor" }; constexpr int8_t CurrentCacheVersion = 3; @@ -126,6 +126,12 @@ namespace { "values so they can be used by the specified color map." }; + constexpr openspace::properties::Property::PropertyInfo FixedColorInfo = { + "FixedColorValue", + "Color used for fixed star colors", + "The color that should be used if the 'Fixed Color' value is used." + }; + constexpr openspace::properties::Property::PropertyInfo OtherDataColorMapInfo = { "OtherDataColorMap", "Other Data Color Map", @@ -328,7 +334,9 @@ documentation::Documentation RenderableStars::Documentation() { },*/ { ColorOptionInfo.identifier, - new StringInListVerifier({ "Color", "Velocity", "Speed", "Other Data" }), + new StringInListVerifier({ + "Color", "Velocity", "Speed", "Other Data", "Fixed Color" + }), Optional::Yes, ColorOptionInfo.description }, @@ -423,6 +431,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) glm::vec2(-10.f, -10.f), glm::vec2(10.f, 10.f) ) + , _fixedColor(FixedColorInfo, glm::vec4(1.f), glm::vec4(0.f), glm::vec4(1.f)) , _filterOutOfRange(FilterOutOfRangeInfo, false) , _pointSpreadFunctionTexturePath(PsfTextureInfo) , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) @@ -489,11 +498,15 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) ); } + _fixedColor.setViewOption(properties::Property::ViewOptions::Color, true); + addProperty(_fixedColor); + _colorOption.addOptions({ { ColorOption::Color, "Color" }, { ColorOption::Velocity, "Velocity" }, { ColorOption::Speed, "Speed" }, - { ColorOption::OtherData, "Other Data" } + { ColorOption::OtherData, "Other Data" }, + { ColorOption::FixedColor, "Fixed Color" } }); if (dictionary.hasKey(ColorOptionInfo.identifier)) { const std::string colorOption = dictionary.value( @@ -508,9 +521,12 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) else if (colorOption == "Speed") { _colorOption = ColorOption::Speed; } - else { + else if (colorOption == "OtherData") { _colorOption = ColorOption::OtherData; } + else { + _colorOption = ColorOption::FixedColor; + } } _colorOption.onChange([&] { _dataIsDirty = true; }); addProperty(_colorOption); @@ -615,7 +631,8 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) if (sizeCompositionOption == "App Brightness") { _psfMultiplyOption = 0; - } else if (sizeCompositionOption == "Lum and Size") { + } + else if (sizeCompositionOption == "Lum and Size") { _psfMultiplyOption = 1; } else if (sizeCompositionOption == "Lum, Size and App Brightness") { @@ -716,7 +733,7 @@ void RenderableStars::initializeGL() { glBindVertexArray(_psfVao); glBindBuffer(GL_ARRAY_BUFFER, _psfVbo); - const GLfloat vertex_data[] = { + const GLfloat vertexData[] = { //x y s t -1.f, -1.f, 0.f, 0.f, 1.f, 1.f, 1.f, 1.f, @@ -726,7 +743,7 @@ void RenderableStars::initializeGL() { 1.f, 1.f, 1.f, 1.f }; - glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(vertexData), vertexData, GL_STATIC_DRAW); glVertexAttribPointer( 0, 4, @@ -987,14 +1004,21 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) { _program->setUniform(_uniformCache.radiusCent, _radiusCent); _program->setUniform(_uniformCache.brightnessCent, _brightnessCent); + if (_colorOption == ColorOption::FixedColor) { + if (_uniformCache.fixedColor == -1) { + _uniformCache.fixedColor = _program->uniformLocation("fixedColor"); + } + _program->setUniform(_uniformCache.fixedColor, _fixedColor); + } + float fadeInVariable = 1.f; if (!_disableFadeInDistance) { float distCamera = static_cast(glm::length(data.camera.positionVec3())); const glm::vec2 fadeRange = _fadeInDistance; - const float a = 1.f / ((fadeRange.y - fadeRange.x) * PARSEC); - const float b = -(fadeRange.x / (fadeRange.y - fadeRange.x)); - const float funcValue = a * distCamera + b; - fadeInVariable *= funcValue > 1.f ? 1.f : funcValue; + const double a = 1.f / ((fadeRange.y - fadeRange.x) * PARSEC); + const double b = -(fadeRange.x / (fadeRange.y - fadeRange.x)); + const double funcValue = a * distCamera + b; + fadeInVariable *= static_cast(funcValue > 1.f ? 1.f : funcValue); _program->setUniform(_uniformCache.alphaValue, _alphaValue * fadeInVariable); } @@ -1107,6 +1131,7 @@ void RenderableStars::update(const UpdateData&) { const int colorOption = _colorOption; switch (colorOption) { case ColorOption::Color: + case ColorOption::FixedColor: glVertexAttribPointer( positionAttrib, 3, @@ -1586,6 +1611,7 @@ void RenderableStars::createDataSlice(ColorOption option) { switch (option) { case ColorOption::Color: + case ColorOption::FixedColor: { union { ColorVBOLayout value; diff --git a/modules/space/rendering/renderablestars.h b/modules/space/rendering/renderablestars.h index 2645900ad6..7e36d0aafb 100644 --- a/modules/space/rendering/renderablestars.h +++ b/modules/space/rendering/renderablestars.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -63,15 +64,13 @@ public: static documentation::Documentation Documentation(); -//private: -// void loadShapeTexture(); - private: enum ColorOption { - Color = 0, - Velocity = 1, - Speed = 2, - OtherData = 3 + Color = 0, + Velocity = 1, + Speed = 2, + OtherData = 3, + FixedColor = 4 }; static const int _psfTextureSize = 64; @@ -99,6 +98,7 @@ private: properties::StringProperty _otherDataColorMapPath; properties::Vec2Property _otherDataRange; std::unique_ptr _otherDataColorMapTexture; + properties::Vec4Property _fixedColor; properties::BoolProperty _filterOutOfRange; properties::StringProperty _pointSpreadFunctionTexturePath; std::unique_ptr _pointSpreadFunctionTexture; @@ -132,7 +132,7 @@ private: colorOption, magnitudeExponent, eyePosition, psfParamConf, lumCent, radiusCent, brightnessCent, colorTexture, alphaValue, psfTexture, otherDataTexture, otherDataRange, - filterOutOfRange + filterOutOfRange, fixedColor ) _uniformCache; bool _speckFileIsDirty = true; diff --git a/modules/space/shaders/convolution_fs.glsl b/modules/space/shaders/convolution_fs.glsl index f10b9e0c14..9cde38881e 100644 --- a/modules/space/shaders/convolution_fs.glsl +++ b/modules/space/shaders/convolution_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/space/shaders/convolution_vs.glsl b/modules/space/shaders/convolution_vs.glsl index a2e5f20da8..c87dcf9fe6 100644 --- a/modules/space/shaders/convolution_vs.glsl +++ b/modules/space/shaders/convolution_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/space/shaders/debrisViz_fs.glsl b/modules/space/shaders/debrisViz_fs.glsl index e54886d99a..2fd1b77264 100644 --- a/modules/space/shaders/debrisViz_fs.glsl +++ b/modules/space/shaders/debrisViz_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2018 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * @@ -86,8 +86,9 @@ Fragment getFragment() { // to debug using colors use this if-statment. // float ep = 0.01; - // if( fract(vertexID_f) < ep ){ //periodFraction < ep - // frag.color = vec4(1, 0, 0, 1); + // if (fract(vertexID_f) < ep) { + // periodFraction < ep + // frag.color = vec4(1, 0, 0, 1); // } return frag; diff --git a/modules/space/shaders/debrisViz_vs.glsl b/modules/space/shaders/debrisViz_vs.glsl index c81cd42431..57b89a2510 100644 --- a/modules/space/shaders/debrisViz_vs.glsl +++ b/modules/space/shaders/debrisViz_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2018 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/space/shaders/psfToTexture_fs.glsl b/modules/space/shaders/psfToTexture_fs.glsl index 3eee43d979..060b33e557 100644 --- a/modules/space/shaders/psfToTexture_fs.glsl +++ b/modules/space/shaders/psfToTexture_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/space/shaders/psfToTexture_vs.glsl b/modules/space/shaders/psfToTexture_vs.glsl index d24f8ac013..791adc6c4e 100644 --- a/modules/space/shaders/psfToTexture_vs.glsl +++ b/modules/space/shaders/psfToTexture_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/space/shaders/star_fs.glsl b/modules/space/shaders/star_fs.glsl index 8d6096e21d..329e7e513c 100644 --- a/modules/space/shaders/star_fs.glsl +++ b/modules/space/shaders/star_fs.glsl @@ -26,15 +26,18 @@ #include "floatoperations.glsl" // keep in sync with renderablestars.h:ColorOption enum -const int COLOROPTION_COLOR = 0; -const int COLOROPTION_VELOCITY = 1; -const int COLOROPTION_SPEED = 2; +const int COLOROPTION_COLOR = 0; +const int COLOROPTION_VELOCITY = 1; +const int COLOROPTION_SPEED = 2; const int COLOROPTION_OTHERDATA = 3; +const int COLOROPTION_FIXEDCOLOR = 4; uniform sampler1D colorTexture; uniform sampler2D psfTexture; uniform float alphaValue; +uniform vec4 fixedColor; + uniform int colorOption; uniform sampler1D otherDataTexture; @@ -89,21 +92,28 @@ Fragment getFragment() { color = otherDataValue(); } break; + case COLOROPTION_FIXEDCOLOR: + color = fixedColor; + break; } - vec4 textureColor = texture(psfTexture, 0.5*psfCoords + 0.5); + vec4 textureColor = texture(psfTexture, 0.5 * psfCoords + 0.5); vec4 fullColor = vec4(color.rgb, textureColor.a); fullColor.a *= alphaValue; + + if (colorOption == COLOROPTION_FIXEDCOLOR) { + fullColor.a *= fixedColor.a; + } if (fullColor.a == 0) { discard; } Fragment frag; - frag.color = fullColor; - frag.depth = gs_screenSpaceDepth; + frag.color = fullColor; + frag.depth = gs_screenSpaceDepth; frag.gPosition = vs_position; - frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); + frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); frag.disableLDR2HDR = true; return frag; diff --git a/modules/space/tasks/generatedebrisvolumetask.cpp b/modules/space/tasks/generatedebrisvolumetask.cpp index 2922de72b7..d7bf763a45 100644 --- a/modules/space/tasks/generatedebrisvolumetask.cpp +++ b/modules/space/tasks/generatedebrisvolumetask.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/space/tasks/generatedebrisvolumetask.h b/modules/space/tasks/generatedebrisvolumetask.h index 005936213d..887f75be60 100644 --- a/modules/space/tasks/generatedebrisvolumetask.h +++ b/modules/space/tasks/generatedebrisvolumetask.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * @@ -21,8 +21,9 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_SPACE___GENERATERDEBRISVOLUMETASK___H__ -#define __OPENSPACE_MODULE_SPACE___GENERATERDEBRISVOLUMETASK___H__ + +#ifndef __OPENSPACE_MODULE_SPACE___GENERATEDEBRISVOLUMETASK___H__ +#define __OPENSPACE_MODULE_SPACE___GENERATEDEBRISVOLUMETASK___H__ #include #include @@ -69,11 +70,8 @@ private: // not sure if it should be local function or hidden function. //std::vector readTLEFile(const std::string& filename); - }; - - } // namespace volume } // namespace openspace diff --git a/modules/space/translation/tletranslation.cpp b/modules/space/translation/tletranslation.cpp index 7d41878a33..ec5fb75137 100644 --- a/modules/space/translation/tletranslation.cpp +++ b/modules/space/translation/tletranslation.cpp @@ -319,7 +319,8 @@ void TLETranslation::readTLEFile(const std::string& filename, int lineNum) { // 13 65-68 Element set number.Incremented when a new TLE is generated // 14 69-69 Checksum (modulo 10) keplerElements.epoch = epochFromSubstring(line.substr(18, 14)); - } else { + } + else { throw ghoul::RuntimeError(fmt::format( "File {} @ line {} does not have '1' header", filename, lineNum + 1 )); @@ -371,7 +372,8 @@ void TLETranslation::readTLEFile(const std::string& filename, int lineNum) { // Get mean motion stream.str(line.substr(52, 11)); stream >> keplerElements.meanMotion; - } else { + } + else { throw ghoul::RuntimeError(fmt::format( "File {} @ line {} does not have '2' header", filename, lineNum + 2 )); diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 6abdfaaff1..238ad1cd11 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -487,7 +487,8 @@ void RenderablePlanetProjection::imageProjectGPU( if (glm::vec3* radius = std::any_cast(&r)){ _fboProgramObject->setUniform(_fboUniformCache.radius, radius); } - } else { + } + else { LERROR("Geometry object needs to provide radius"); } if (_geometry->hasProperty("Segments")) { @@ -495,7 +496,8 @@ void RenderablePlanetProjection::imageProjectGPU( if (int* segments = std::any_cast(&s)) { _fboProgramObject->setUniform(_fboUniformCache.segments, segments[0]); } - }else{ + } + else{ LERROR("Geometry object needs to provide segment count"); } diff --git a/modules/spacecraftinstruments/shaders/dilation_fs.glsl b/modules/spacecraftinstruments/shaders/dilation_fs.glsl index 827fa02491..0b4b01e684 100644 --- a/modules/spacecraftinstruments/shaders/dilation_fs.glsl +++ b/modules/spacecraftinstruments/shaders/dilation_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/spacecraftinstruments/shaders/dilation_vs.glsl b/modules/spacecraftinstruments/shaders/dilation_vs.glsl index d8cc4380db..9d2a0c22d9 100644 --- a/modules/spacecraftinstruments/shaders/dilation_vs.glsl +++ b/modules/spacecraftinstruments/shaders/dilation_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/spacecraftinstruments/shaders/renderableModelDepth_fs.glsl b/modules/spacecraftinstruments/shaders/renderableModelDepth_fs.glsl index f0e3acc04f..c4a2b2c5c3 100644 --- a/modules/spacecraftinstruments/shaders/renderableModelDepth_fs.glsl +++ b/modules/spacecraftinstruments/shaders/renderableModelDepth_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/spacecraftinstruments/shaders/renderableModelDepth_vs.glsl b/modules/spacecraftinstruments/shaders/renderableModelDepth_vs.glsl index 7bf11b3be2..eec94130a1 100644 --- a/modules/spacecraftinstruments/shaders/renderableModelDepth_vs.glsl +++ b/modules/spacecraftinstruments/shaders/renderableModelDepth_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl b/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl index a78f09d07e..3760905ab4 100644 --- a/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl +++ b/modules/spacecraftinstruments/shaders/renderablePlanetProjection_fs.glsl @@ -79,8 +79,8 @@ void main() { vec3 v_b = normalize(boresight); - if((inRange(projected.x, 0.0, 1.0) && inRange(projected.y, 0.0, 1.0)) && - dot(v_b, normal) < 0.0) + if ((inRange(projected.x, 0.0, 1.0) && inRange(projected.y, 0.0, 1.0)) && + dot(v_b, normal) < 0.0) { color = texture(projectionTexture, vec2(projected.x, projected.y)); stencil = vec4(1.0); diff --git a/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl b/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl index 3e5ab5cfbd..c837cac53b 100644 --- a/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl +++ b/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl @@ -41,7 +41,8 @@ uniform vec4 shadowColor; void main() { if (mod(gl_VertexID,2) == 0.0) { vs_color = shadowColor; - } else { + } + else { vs_color = vec4(0.0); } diff --git a/modules/spacecraftinstruments/util/instrumentdecoder.cpp b/modules/spacecraftinstruments/util/instrumentdecoder.cpp index 4ef3eeed44..a5b04f79ba 100644 --- a/modules/spacecraftinstruments/util/instrumentdecoder.cpp +++ b/modules/spacecraftinstruments/util/instrumentdecoder.cpp @@ -53,7 +53,8 @@ InstrumentDecoder::InstrumentDecoder(const ghoul::Dictionary& dictionary) { if (dictionary.hasKeyAndValue(KeyStopCommand) && _type == "SCANNER"){ dictionary.getValue(KeyStopCommand, _stopCommand); - } else { + } + else { LWARNING("Scanner must provide stop command, please check mod file."); } diff --git a/modules/sync/syncmodule.cpp b/modules/sync/syncmodule.cpp index 53a7151789..0bba0d59a0 100644 --- a/modules/sync/syncmodule.cpp +++ b/modules/sync/syncmodule.cpp @@ -62,7 +62,8 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) { if (configuration.hasKey(KeySynchronizationRoot)) { _synchronizationRoot = configuration.value(KeySynchronizationRoot); - } else { + } + else { LWARNINGC( "SyncModule", "No synchronization root specified. Disabling resource synchronization" diff --git a/modules/sync/syncs/urlsynchronization.cpp b/modules/sync/syncs/urlsynchronization.cpp index 374c6c93f9..d7b3e61348 100644 --- a/modules/sync/syncs/urlsynchronization.cpp +++ b/modules/sync/syncs/urlsynchronization.cpp @@ -46,7 +46,6 @@ namespace { constexpr const char* KeyFilename = "Filename"; constexpr const char* TempSuffix = ".tmp"; - constexpr const char* FileSuffix = ".txt"; } // namespace namespace openspace { @@ -128,10 +127,6 @@ UrlSynchronization::UrlSynchronization(const ghoul::Dictionary& dict, if (dict.hasValue(KeyFilename)) { _filename = dict.value(KeyFilename); - std::size_t foundExt = _filename.find(FileSuffix); - if (foundExt == std::string::npos) { - _filename += FileSuffix; - } } bool useHash = true; @@ -204,12 +199,10 @@ void UrlSynchronization::start() { std::string lastPartOfUrl = url.substr(lastSlash + 1); // We can not create filenames with questionmarks - lastPartOfUrl.erase(std::remove(lastPartOfUrl.begin(), lastPartOfUrl.end(), '?'), lastPartOfUrl.end()); - - std::size_t foundExt = lastPartOfUrl.find(FileSuffix); - if (foundExt == std::string::npos) { - lastPartOfUrl += FileSuffix; - } + lastPartOfUrl.erase( + std::remove(lastPartOfUrl.begin(), lastPartOfUrl.end(), '?'), + lastPartOfUrl.end() + ); _filename = lastPartOfUrl; } std::string fileDestination = directory() + diff --git a/modules/touch/ext/CMakeLists.txt b/modules/touch/ext/CMakeLists.txt index 19a1dca056..9ce2824de9 100644 --- a/modules/touch/ext/CMakeLists.txt +++ b/modules/touch/ext/CMakeLists.txt @@ -44,9 +44,9 @@ set(TUIO_SOURCE ${PROJECT_SOURCE_DIR}/libTUIO11/TUIO/OscReceiver.cpp ${PROJECT_SOURCE_DIR}/libTUIO11/TUIO/OneEuroFilter.cpp ${PROJECT_SOURCE_DIR}/libTUIO11/TUIO/FlashSender.cpp - + ${PROJECT_SOURCE_DIR}/libTUIO11/oscpack/ip/IpEndpointName.cpp - + ${PROJECT_SOURCE_DIR}/libTUIO11/oscpack/osc/OscTypes.cpp ${PROJECT_SOURCE_DIR}/libTUIO11/oscpack/osc/OscReceivedElements.cpp ${PROJECT_SOURCE_DIR}/libTUIO11/oscpack/osc/OscPrintReceivedElements.cpp @@ -58,7 +58,7 @@ if (WIN32) ${TUIO_SOURCE} ${PROJECT_SOURCE_DIR}/libTUIO11/oscpack/ip/win32/NetworkingUtils.cpp ${PROJECT_SOURCE_DIR}/libTUIO11/oscpack/ip/win32/UdpSocket.cpp - ) + ) endif () if (UNIX) @@ -80,4 +80,4 @@ target_include_directories(libTUIO11 PUBLIC if (WIN32) # Tuio dependencies target_link_libraries(libTUIO11 PRIVATE winmm.lib wininet.lib ws2_32.lib) -endif() +endif () diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 725c005c23..9507b5ef8a 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -237,13 +237,12 @@ Win32TouchHook::Win32TouchHook(void* nativeWindow) // GetModuleHandleW(NULL), // 0 //<- Global thread id (low-level mouse is global only) // ); - // if(!gMouseHook){ + // if (!gMouseHook) { // LINFO("Could not setup mousehook!"); // } // MSG msg; - // while (GetMessage(&msg, NULL, 0, 0)) - // { + // while (GetMessage(&msg, NULL, 0, 0)) { // DispatchMessage(&msg); // } // }); diff --git a/modules/toyvolume/shaders/boundsfs.glsl b/modules/toyvolume/shaders/boundsfs.glsl index 6f1123a51d..4c6fa0ed17 100644 --- a/modules/toyvolume/shaders/boundsfs.glsl +++ b/modules/toyvolume/shaders/boundsfs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/toyvolume/shaders/boundsvs.glsl b/modules/toyvolume/shaders/boundsvs.glsl index b5a22f127b..67c3aa488e 100644 --- a/modules/toyvolume/shaders/boundsvs.glsl +++ b/modules/toyvolume/shaders/boundsvs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/toyvolume/shaders/raycast.glsl b/modules/toyvolume/shaders/raycast.glsl index 7168af6ef6..b604dd050d 100644 --- a/modules/toyvolume/shaders/raycast.glsl +++ b/modules/toyvolume/shaders/raycast.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/volume/rendering/renderabletimevaryingvolume.cpp b/modules/volume/rendering/renderabletimevaryingvolume.cpp index d689713104..0cad00ee51 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.cpp +++ b/modules/volume/rendering/renderabletimevaryingvolume.cpp @@ -452,7 +452,8 @@ void RenderableTimeVaryingVolume::update(const UpdateData&) { glm::dmat4 scaleMatrix = glm::scale(glm::dmat4(1.0), scale); modelTransform = modelTransform * scaleMatrix; _raycaster->setModelTransform(glm::mat4(modelTransform)); - } else { + } + else { // The diameter is two times the maximum radius. // No translation: the sphere is always centered in (0, 0, 0) _raycaster->setModelTransform( @@ -463,7 +464,8 @@ void RenderableTimeVaryingVolume::update(const UpdateData&) { ); } _raycaster->setVolumeTexture(t->texture); - } else { + } + else { _raycaster->setVolumeTexture(nullptr); } _raycaster->setStepSize(_stepSize); diff --git a/modules/volume/shaders/boundsfs.glsl b/modules/volume/shaders/boundsfs.glsl index 8fa1123413..5e589ac90b 100644 --- a/modules/volume/shaders/boundsfs.glsl +++ b/modules/volume/shaders/boundsfs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/volume/shaders/boundsvs.glsl b/modules/volume/shaders/boundsvs.glsl index 04688e177a..32c2d80aeb 100644 --- a/modules/volume/shaders/boundsvs.glsl +++ b/modules/volume/shaders/boundsvs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/volume/shaders/helper.glsl b/modules/volume/shaders/helper.glsl index 970b6cf6fa..9c51d02d41 100644 --- a/modules/volume/shaders/helper.glsl +++ b/modules/volume/shaders/helper.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/volume/shaders/raycast.glsl b/modules/volume/shaders/raycast.glsl index e7e28ab456..0ecee6cf0d 100644 --- a/modules/volume/shaders/raycast.glsl +++ b/modules/volume/shaders/raycast.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/volume/volumesampler.inl b/modules/volume/volumesampler.inl index 8fba419183..4c6f344607 100644 --- a/modules/volume/volumesampler.inl +++ b/modules/volume/volumesampler.inl @@ -59,17 +59,20 @@ typename VolumeType::VoxelType VolumeSampler::sample( if (x == minCoords.x) { filterCoefficient *= (1.f - t.x); - } else if (x == maxCoords.x) { + } + else if (x == maxCoords.x) { filterCoefficient *= t.x; } if (y == minCoords.y) { filterCoefficient *= (1.f - t.y); - } else if (y == maxCoords.y) { + } + else if (y == maxCoords.y) { filterCoefficient *= t.y; } if (z == minCoords.z) { filterCoefficient *= (1.f - t.z); - } else if (z == maxCoords.z) { + } + else if (z == maxCoords.z) { filterCoefficient *= t.z; } diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index e838953772..c914689fda 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -152,7 +152,7 @@ set(CEF_HELPER_TARGET "OpenSpace Helper" CACHE INTERNAL "CEF_HELPER_TARGET") # CEF platform-specific config # -if(OS_MACOSX) +if (OS_MACOSX) # Helper executable target. add_executable(${CEF_HELPER_TARGET} MACOSX_BUNDLE ${WEBBROWSER_HELPER_SOURCES}) SET_EXECUTABLE_TARGET_PROPERTIES(${CEF_HELPER_TARGET}) @@ -163,12 +163,15 @@ if(OS_MACOSX) MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist ) - if(USE_SANDBOX) + target_compile_options(${CEF_HELPER_TARGET} PRIVATE -Wno-deprecated-declarations) + target_compile_options(libcef_dll_wrapper PRIVATE -Wno-deprecated-declarations) + + if (USE_SANDBOX) # Logical target used to link the cef_sandbox library. ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}") target_link_libraries(${CEF_HELPER_TARGET} cef_sandbox_lib) - endif() -endif() + endif () +endif () if (OS_WINDOWS) message(STATUS "Setting up WebBrowser CEF helper executable: ${CEF_HELPER_TARGET}") diff --git a/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake b/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake index 08acbeba7c..d534b80192 100644 --- a/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake +++ b/modules/webbrowser/cmake/patch/cmake/cef_variables.cmake @@ -305,7 +305,7 @@ if(OS_MACOSX) endforeach() # Target SDK. - set(CEF_TARGET_SDK "10.9") + set(CEF_TARGET_SDK "10.14") list(APPEND CEF_COMPILER_FLAGS -mmacosx-version-min=${CEF_TARGET_SDK} ) diff --git a/modules/webbrowser/shaders/screenspace_fs.glsl b/modules/webbrowser/shaders/screenspace_fs.glsl index bef4564a75..7b0491b004 100644 --- a/modules/webbrowser/shaders/screenspace_fs.glsl +++ b/modules/webbrowser/shaders/screenspace_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/webbrowser/shaders/screenspace_vs.glsl b/modules/webbrowser/shaders/screenspace_vs.glsl index 780ddfcef6..b7a3b4af15 100644 --- a/modules/webbrowser/shaders/screenspace_vs.glsl +++ b/modules/webbrowser/shaders/screenspace_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/webbrowser/src/processhelpermac.cpp b/modules/webbrowser/src/processhelpermac.cpp index b26788b629..f39f312b8f 100644 --- a/modules/webbrowser/src/processhelpermac.cpp +++ b/modules/webbrowser/src/processhelpermac.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/modules/webbrowser/src/webrenderhandler.cpp b/modules/webbrowser/src/webrenderhandler.cpp index 9c01a4e668..d0d081c7c1 100644 --- a/modules/webbrowser/src/webrenderhandler.cpp +++ b/modules/webbrowser/src/webrenderhandler.cpp @@ -71,7 +71,8 @@ void WebRenderHandler::OnPaint(CefRefPtr, CefRenderHandler::PaintEle const glm::ivec2 rectSize = upperUpdatingRectBound - lowerUpdatingRectBound; if (rectSize.x > 0 && rectSize.y > 0) { _textureIsDirty = true; - } else { + } + else { return; } @@ -117,7 +118,8 @@ void WebRenderHandler::updateTexture() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindTexture(GL_TEXTURE_2D, 0); - } else if (_textureIsDirty) { + } + else if (_textureIsDirty) { glBindTexture(GL_TEXTURE_2D, _texture); glPixelStorei(GL_UNPACK_ROW_LENGTH, _browserBufferSize.x); diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index 4417787c7d..32d042581e 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -129,7 +129,8 @@ void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) { if (dictionary.hasKeyAndValue("WebHelperLocation")) { _webHelperLocation = absPath(dictionary.value("WebHelperLocation")); - } else { + } + else { _webHelperLocation = findHelperExecutable(); } @@ -188,7 +189,8 @@ void WebBrowserModule::removeBrowser(BrowserInstance* browser) { const auto p = std::find(_browsers.begin(), _browsers.end(), browser); if (p != _browsers.end()) { _browsers.erase(p); - } else { + } + else { LWARNING("Could not find browser in list of browsers."); } diff --git a/modules/webgui/webguimodule.cpp b/modules/webgui/webguimodule.cpp index 8f3b83ddb0..ae0d3079fd 100644 --- a/modules/webgui/webguimodule.cpp +++ b/modules/webgui/webguimodule.cpp @@ -174,7 +174,8 @@ void WebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) { auto startOrStop = [this]() { if (_enabled && !_entryPoint.value().empty()) { startProcess(); - } else { + } + else { stopProcess(); } }; diff --git a/shaders/PowerScaling/powerScalingMath.hglsl b/shaders/PowerScaling/powerScalingMath.hglsl index 626a76fcc7..c07c248f4b 100644 --- a/shaders/PowerScaling/powerScalingMath.hglsl +++ b/shaders/PowerScaling/powerScalingMath.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/PowerScaling/powerScaling_fs.hglsl b/shaders/PowerScaling/powerScaling_fs.hglsl index f31ab0a052..d30d5370fa 100644 --- a/shaders/PowerScaling/powerScaling_fs.hglsl +++ b/shaders/PowerScaling/powerScaling_fs.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/PowerScaling/powerScaling_vs.hglsl b/shaders/PowerScaling/powerScaling_vs.hglsl index b1cbbb4c9f..85b94bd939 100644 --- a/shaders/PowerScaling/powerScaling_vs.hglsl +++ b/shaders/PowerScaling/powerScaling_vs.hglsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/abufferfragment.glsl b/shaders/abuffer/abufferfragment.glsl index 108bd1726c..519c76136f 100644 --- a/shaders/abuffer/abufferfragment.glsl +++ b/shaders/abuffer/abufferfragment.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/abufferresources.glsl b/shaders/abuffer/abufferresources.glsl index 562a761be9..2083160765 100644 --- a/shaders/abuffer/abufferresources.glsl +++ b/shaders/abuffer/abufferresources.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/boundsabuffer.frag b/shaders/abuffer/boundsabuffer.frag index 127f1dedd7..39b3c9de74 100644 --- a/shaders/abuffer/boundsabuffer.frag +++ b/shaders/abuffer/boundsabuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/raycasterdata.glsl b/shaders/abuffer/raycasterdata.glsl index 50d5ed6d76..6adc2b505d 100644 --- a/shaders/abuffer/raycasterdata.glsl +++ b/shaders/abuffer/raycasterdata.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/renderabuffer.frag b/shaders/abuffer/renderabuffer.frag index af323f7bec..316238681b 100644 --- a/shaders/abuffer/renderabuffer.frag +++ b/shaders/abuffer/renderabuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/renderabuffer.vert b/shaders/abuffer/renderabuffer.vert index a1bf057ce6..95ffd3ac7a 100644 --- a/shaders/abuffer/renderabuffer.vert +++ b/shaders/abuffer/renderabuffer.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/resolveabuffer.frag b/shaders/abuffer/resolveabuffer.frag index 8efebf2947..d3681578da 100644 --- a/shaders/abuffer/resolveabuffer.frag +++ b/shaders/abuffer/resolveabuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/resolveabuffer.vert b/shaders/abuffer/resolveabuffer.vert index 956aa538ce..c33c92d84d 100644 --- a/shaders/abuffer/resolveabuffer.vert +++ b/shaders/abuffer/resolveabuffer.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/abuffer/resolvehelpers.glsl b/shaders/abuffer/resolvehelpers.glsl index 411bcd9c9a..2a474879c9 100644 --- a/shaders/abuffer/resolvehelpers.glsl +++ b/shaders/abuffer/resolvehelpers.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/blending.glsl b/shaders/blending.glsl index 46091050cb..c5dce91519 100644 --- a/shaders/blending.glsl +++ b/shaders/blending.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/floatoperations.glsl b/shaders/floatoperations.glsl index 7b43a5f891..dad993dc47 100644 --- a/shaders/floatoperations.glsl +++ b/shaders/floatoperations.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/fragment.glsl b/shaders/fragment.glsl index 95efdb25ab..7607996e74 100644 --- a/shaders/fragment.glsl +++ b/shaders/fragment.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/exitframebuffer.frag b/shaders/framebuffer/exitframebuffer.frag index e561206773..0280f0a36c 100644 --- a/shaders/framebuffer/exitframebuffer.frag +++ b/shaders/framebuffer/exitframebuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/fxaa.frag b/shaders/framebuffer/fxaa.frag index a9d30c4279..c558b4cd04 100644 --- a/shaders/framebuffer/fxaa.frag +++ b/shaders/framebuffer/fxaa.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/fxaa.vert b/shaders/framebuffer/fxaa.vert index f737e51882..b0a412be03 100644 --- a/shaders/framebuffer/fxaa.vert +++ b/shaders/framebuffer/fxaa.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/hdrAndFiltering.frag b/shaders/framebuffer/hdrAndFiltering.frag index 0e2b3b2090..d4e43cbdf8 100644 --- a/shaders/framebuffer/hdrAndFiltering.frag +++ b/shaders/framebuffer/hdrAndFiltering.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/hdrAndFiltering.vert b/shaders/framebuffer/hdrAndFiltering.vert index f737e51882..b0a412be03 100644 --- a/shaders/framebuffer/hdrAndFiltering.vert +++ b/shaders/framebuffer/hdrAndFiltering.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/inside.glsl b/shaders/framebuffer/inside.glsl index 5801dfc587..012a221fd9 100644 --- a/shaders/framebuffer/inside.glsl +++ b/shaders/framebuffer/inside.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/mergeDownscaledVolume.frag b/shaders/framebuffer/mergeDownscaledVolume.frag index 14a6405735..b255d2a590 100644 --- a/shaders/framebuffer/mergeDownscaledVolume.frag +++ b/shaders/framebuffer/mergeDownscaledVolume.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/mergeDownscaledVolume.vert b/shaders/framebuffer/mergeDownscaledVolume.vert index f737e51882..b0a412be03 100644 --- a/shaders/framebuffer/mergeDownscaledVolume.vert +++ b/shaders/framebuffer/mergeDownscaledVolume.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/nOneStripMSAA.frag b/shaders/framebuffer/nOneStripMSAA.frag index c16d61aeba..4386ad4af5 100644 --- a/shaders/framebuffer/nOneStripMSAA.frag +++ b/shaders/framebuffer/nOneStripMSAA.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * @@ -32,7 +32,7 @@ in vec2 vTexCoord; uniform int currentSample; uniform sampler2DMS pixelSizeTexture; -void main() { +void main() { finalColor = vec4(texelFetch(pixelSizeTexture, ivec2(vTexCoord), currentSample).rgb, 1.0); //finalColor = vec4(0.5*vPosition.xy + 0.5, 1.0, 1.0); //finalColor = vec4(vPosition.xy, 0.0, 1.0); diff --git a/shaders/framebuffer/nOneStripMSAA.vert b/shaders/framebuffer/nOneStripMSAA.vert index 6c7f2e9163..ccce241d15 100644 --- a/shaders/framebuffer/nOneStripMSAA.vert +++ b/shaders/framebuffer/nOneStripMSAA.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/outside.glsl b/shaders/framebuffer/outside.glsl index e56198693b..847304b039 100644 --- a/shaders/framebuffer/outside.glsl +++ b/shaders/framebuffer/outside.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/raycastframebuffer.frag b/shaders/framebuffer/raycastframebuffer.frag index bff04b1dbe..1a9efc53c2 100644 --- a/shaders/framebuffer/raycastframebuffer.frag +++ b/shaders/framebuffer/raycastframebuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/renderframebuffer.frag b/shaders/framebuffer/renderframebuffer.frag index a20d685f4e..deb68cb122 100644 --- a/shaders/framebuffer/renderframebuffer.frag +++ b/shaders/framebuffer/renderframebuffer.frag @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/framebuffer/resolveframebuffer.vert b/shaders/framebuffer/resolveframebuffer.vert index 9167d4c640..320f8b7f15 100644 --- a/shaders/framebuffer/resolveframebuffer.vert +++ b/shaders/framebuffer/resolveframebuffer.vert @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/hdr.glsl b/shaders/hdr.glsl index 2fca4496c5..63dc9b5d2d 100644 --- a/shaders/hdr.glsl +++ b/shaders/hdr.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/shaders/rand.glsl b/shaders/rand.glsl index 3e38e95058..f2ac746245 100644 --- a/shaders/rand.glsl +++ b/shaders/rand.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/src/documentation/documentationengine.cpp b/src/documentation/documentationengine.cpp index dd65a56231..06456dca21 100644 --- a/src/documentation/documentationengine.cpp +++ b/src/documentation/documentationengine.cpp @@ -113,7 +113,8 @@ std::string generateJsonDocumentation(const Documentation& d) { if (it == documentations.end()) { result << R"("reference": { "found": false })"; - } else { + } + else { result << R"("reference": {)" << R"("found": true,)" << R"("name": ")" << it->name << "\"," diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index f8e256f768..936b7c4672 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -271,17 +271,20 @@ std::future DownloadManager::fetchFile( getline(ss, extension ,'/'); getline(ss, extension); file.format = extension; - } else { + } + else { LWARNING("Could not get extension from file downloaded from: " + url); } successCb(file); curl_easy_cleanup(curl); return file; - } else { + } + else { std::string err = curl_easy_strerror(res); if (errorCb) { errorCb(err); - } else { + } + else { LWARNING(fmt::format("Error downloading '{}': {}", url, err)); } curl_easy_cleanup(curl); diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 3390914c42..2ed17ecb9a 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -723,7 +723,8 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { unsigned int nAvailableThreads = std::thread::hardware_concurrency(); unsigned int nThreads = nAvailableThreads == 0 ? 2 : nAvailableThreads - 1; sceneInitializer = std::make_unique(nThreads); - } else { + } + else { sceneInitializer = std::make_unique(); } @@ -740,7 +741,8 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { const SceneGraphNode* parent = camera->parent(); if (parent) { global::navigationHandler.orbitalNavigator().setFocusNode(parent->identifier()); - } else { + } + else { global::navigationHandler.orbitalNavigator().setFocusNode( _scene->root()->identifier() ); @@ -817,7 +819,8 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { progressInfo ); ++it; - } else { + } + else { LoadingScreen::ProgressInfo progressInfo; progressInfo.progress = 1.f; diff --git a/src/interaction/navigationhandler.cpp b/src/interaction/navigationhandler.cpp index ed57ecea91..e8d6094b0d 100644 --- a/src/interaction/navigationhandler.cpp +++ b/src/interaction/navigationhandler.cpp @@ -53,6 +53,12 @@ namespace { constexpr const char* KeyReferenceFrame = "ReferenceFrame"; const double Epsilon = 1E-7; + constexpr const openspace::properties::Property::PropertyInfo KeyDisableInputInfo = { + "DisableInputs", + "Disable all mouse inputs", + "Disables all mouse inputs and prevents them from affecting the camera" + }; + constexpr const openspace::properties::Property::PropertyInfo KeyFrameInfo = { "UseKeyFrameInteraction", "Use keyframe interaction", @@ -142,11 +148,13 @@ NavigationHandler::NavigationState::NavigationState(std::string anchor, std::str NavigationHandler::NavigationHandler() : properties::PropertyOwner({ "NavigationHandler" }) + , _disableInputs(KeyDisableInputInfo, false) , _useKeyFrameInteraction(KeyFrameInfo, false) { - // Add the properties - addProperty(_useKeyFrameInteraction); addPropertySubOwner(_orbitalNavigator); + + addProperty(_disableInputs); + addProperty(_useKeyFrameInteraction); } NavigationHandler::~NavigationHandler() {} // NOLINT @@ -326,20 +334,28 @@ const InputState& NavigationHandler::inputState() const { } void NavigationHandler::mouseButtonCallback(MouseButton button, MouseAction action) { - _inputState.mouseButtonCallback(button, action); + if (!_disableInputs) { + _inputState.mouseButtonCallback(button, action); + } } void NavigationHandler::mousePositionCallback(double x, double y) { - _inputState.mousePositionCallback(x, y); + if (!_disableInputs) { + _inputState.mousePositionCallback(x, y); + } } void NavigationHandler::mouseScrollWheelCallback(double pos) { - _inputState.mouseScrollWheelCallback(pos); + if (!_disableInputs) { + _inputState.mouseScrollWheelCallback(pos); + } } void NavigationHandler::keyboardCallback(Key key, KeyModifier modifier, KeyAction action) { - _inputState.keyboardCallback(key, modifier, action); + if (!_disableInputs) { + _inputState.keyboardCallback(key, modifier, action); + } } NavigationHandler::NavigationState NavigationHandler::navigationState() const { diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index db8496e106..110eca4b43 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -523,7 +523,8 @@ void SessionRecording::saveTimeKeyframe() { writeToFileBuffer(kf._requiresTimeJump); saveKeyframeToFileBinary(_keyframeBuffer, _bufferIndex); - } else { + } + else { std::stringstream keyframeLine = std::stringstream(); //Add simulation timestamp, timestamp relative, simulation time to recording start keyframeLine << "time "; @@ -880,7 +881,8 @@ void SessionRecording::playbackTimeChange() { )); return; } - } else { + } + else { std::istringstream iss(_playbackLineParsing); std::string entryType; //double timeRef; @@ -943,7 +945,8 @@ void SessionRecording::playbackScript() { )); return; } - } else { + } + else { std::istringstream iss(_playbackLineParsing); std::string entryType; std::string tmpReadbackScript; @@ -958,7 +961,8 @@ void SessionRecording::playbackScript() { "Error parsing script line {} of playback file", _playbackLineNum )); return; - } else if (!iss.eof()) { + } + else if (!iss.eof()) { LERROR(fmt::format( "Did not find an EOL at line {} of playback file", _playbackLineNum )); @@ -1108,7 +1112,8 @@ bool SessionRecording::findNextFutureCameraIndex(double currTime) { _idxTimeline_cameraPtrNext = seekAheadIndex; } break; - } else { + } + else { // Force interpolation between consecutive keyframes _idxTimeline_cameraPtrPrev = seekAheadIndex; } diff --git a/src/interaction/touchbar.mm b/src/interaction/touchbar.mm index f1762ced24..644e199e29 100644 --- a/src/interaction/touchbar.mm +++ b/src/interaction/touchbar.mm @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/src/network/parallelpeer.cpp b/src/network/parallelpeer.cpp index ec68ee23cb..7a6de5c9de 100644 --- a/src/network/parallelpeer.cpp +++ b/src/network/parallelpeer.cpp @@ -547,7 +547,8 @@ void ParallelPeer::setStatus(ParallelConnection::Status status) { global::timeManager.addTimelineChangeCallback([this]() { _timeTimelineChanged = true; }); - } else { + } + else { if (_timeJumpCallback != -1) { global::timeManager.removeTimeJumpCallback(_timeJumpCallback); } diff --git a/src/network/parallelserver.cpp b/src/network/parallelserver.cpp index b4f775cf48..499aa642f8 100644 --- a/src/network/parallelserver.cpp +++ b/src/network/parallelserver.cpp @@ -382,7 +382,8 @@ void ParallelServer::setToClient(Peer& peer) { it.second->status = ParallelConnection::Status::ClientWithoutHost; sendConnectionStatus(*it.second); } - } else { + } + else { peer.status = (_hostPeerId > 0) ? ParallelConnection::Status::ClientWithHost : ParallelConnection::Status::ClientWithoutHost; diff --git a/src/openspace.cpp b/src/openspace.cpp index 48c80e5071..eda8a807f2 100644 --- a/src/openspace.cpp +++ b/src/openspace.cpp @@ -29,7 +29,7 @@ namespace openspace { std::string licenseText() { return "OpenSpace\n\ \n\ -Copyright (c) 2014-2019\n\ +Copyright (c) 2014-2020\n\ \n\ Permission is hereby granted, free of charge, to any person obtaining a copy of this\n\ software and associated documentation files (the \"Software\"), to deal in the Software\n\ diff --git a/src/properties/matrix/dmat4x3property.cpp b/src/properties/matrix/dmat4x3property.cpp index 29153cfedc..95fa2beaaf 100644 --- a/src/properties/matrix/dmat4x3property.cpp +++ b/src/properties/matrix/dmat4x3property.cpp @@ -46,7 +46,8 @@ glm::dmat4x3 fromLuaConversion(lua_State* state, bool& success) { if (lua_isnumber(state, -1) != 1) { success = false; return glm::dmat4x3(0.0); - } else { + } + else { result[i][j] = lua_tonumber(state, -1); lua_pop(state, 1); ++number; diff --git a/src/properties/matrix/mat2property.cpp b/src/properties/matrix/mat2property.cpp index e9bde9a9a9..aaa69c6cbc 100644 --- a/src/properties/matrix/mat2property.cpp +++ b/src/properties/matrix/mat2property.cpp @@ -46,7 +46,8 @@ glm::mat2x2 fromLuaConversion(lua_State* state, bool& success) { if (lua_isnumber(state, -1) != 1) { success = false; return glm::mat2x2(1.f); - } else { + } + else { result[i][j] = static_cast( lua_tonumber(state, -1) ); diff --git a/src/properties/matrix/mat3property.cpp b/src/properties/matrix/mat3property.cpp index edd2cc0438..8cb87a6418 100644 --- a/src/properties/matrix/mat3property.cpp +++ b/src/properties/matrix/mat3property.cpp @@ -46,7 +46,8 @@ glm::mat3x3 fromLuaConversion(lua_State* state, bool& success) { if (lua_isnumber(state, -1) != 1) { success = false; return glm::mat3x3(1.f); - } else { + } + else { result[i][j] = static_cast(lua_tonumber(state, -1)); lua_pop(state, 1); diff --git a/src/properties/matrix/mat3x2property.cpp b/src/properties/matrix/mat3x2property.cpp index 7177f076b2..8e9b1b2ea9 100644 --- a/src/properties/matrix/mat3x2property.cpp +++ b/src/properties/matrix/mat3x2property.cpp @@ -43,10 +43,11 @@ glm::mat3x2 fromLuaConversion(lua_State* state, bool& success) { success = false; return glm::mat3x2(0.f); } - if (lua_isnumber(state, -1) != 1) { + if (lua_isnumber(state, -1) != 1) { success = false; return glm::mat3x2(0.f); - } else { + } + else { result[i][j] = static_cast(lua_tonumber(state, -1)); lua_pop(state, 1); diff --git a/src/properties/matrix/mat3x4property.cpp b/src/properties/matrix/mat3x4property.cpp index 82b81626ec..be54c8239e 100644 --- a/src/properties/matrix/mat3x4property.cpp +++ b/src/properties/matrix/mat3x4property.cpp @@ -46,7 +46,8 @@ glm::mat3x4 fromLuaConversion(lua_State* state, bool& success) { if (lua_isnumber(state, -1) != 1) { success = false; return glm::mat3x4(1.f); - } else { + } + else { result[i][j] = static_cast(lua_tonumber(state, -1)); lua_pop(state, 1); diff --git a/src/properties/matrix/mat4property.cpp b/src/properties/matrix/mat4property.cpp index 6141c71918..b224668489 100644 --- a/src/properties/matrix/mat4property.cpp +++ b/src/properties/matrix/mat4property.cpp @@ -48,7 +48,8 @@ glm::mat4x4 fromLuaConversion(lua_State* state, bool& success) { if (lua_isnumber(state, -1) != 1) { success = false; return glm::mat4x4(1.f); - } else { + } + else { result[i][j] = static_cast(lua_tonumber(state, -1)); lua_pop(state, 1); diff --git a/src/properties/matrix/mat4x2property.cpp b/src/properties/matrix/mat4x2property.cpp index a25b68c9be..c528dd49cc 100644 --- a/src/properties/matrix/mat4x2property.cpp +++ b/src/properties/matrix/mat4x2property.cpp @@ -46,7 +46,8 @@ glm::mat4x2 fromLuaConversion(lua_State* state, bool& success) { if (lua_isnumber(state, -1) != 1) { success = false; return glm::mat4x2(1.f); - } else { + } + else { result[i][j] = static_cast(lua_tonumber(state, -1)); lua_pop(state, 1); diff --git a/src/properties/matrix/mat4x3property.cpp b/src/properties/matrix/mat4x3property.cpp index 33ac21d96d..74bd66237e 100644 --- a/src/properties/matrix/mat4x3property.cpp +++ b/src/properties/matrix/mat4x3property.cpp @@ -46,7 +46,8 @@ glm::mat4x3 fromLuaConversion(lua_State* state, bool& success) { if (lua_isnumber(state, -1) != 1) { success = false; return glm::mat4x3(1.f); - } else { + } + else { result[i][j] = static_cast(lua_tonumber(state, -1)); lua_pop(state, 1); diff --git a/src/properties/propertyowner.cpp b/src/properties/propertyowner.cpp index 0bd235c565..b1c00328c8 100644 --- a/src/properties/propertyowner.cpp +++ b/src/properties/propertyowner.cpp @@ -190,7 +190,8 @@ void PropertyOwner::addProperty(Property* prop) { identifier() )); return; - } else { + } + else { // Otherwise we still have to look if there is a PropertyOwner with the same name const bool hasOwner = hasPropertySubOwner(prop->identifier()); if (hasOwner) { @@ -235,7 +236,8 @@ void PropertyOwner::addPropertySubOwner(openspace::properties::PropertyOwner* ow identifier() )); return; - } else { + } + else { // We still need to check if the PropertyOwners name is used in a Property const bool hasProp = hasProperty(owner->identifier()); if (hasProp) { @@ -269,7 +271,8 @@ void PropertyOwner::removeProperty(Property* prop) { if (it != _properties.end() && (*it)->identifier() == prop->identifier()) { (*it)->setPropertyOwner(nullptr); _properties.erase(it); - } else { + } + else { LERROR(fmt::format( "Property with identifier '{}' not found for removal", prop->identifier() )); @@ -295,7 +298,8 @@ void PropertyOwner::removePropertySubOwner(openspace::properties::PropertyOwner* // If we found the propertyowner, we can delete it if (it != _subOwners.end() && (*it)->identifier() == owner->identifier()) { _subOwners.erase(it); - } else { + } + else { LERROR(fmt::format( "PropertyOwner with name '{}' not found for removal", owner->identifier() )); diff --git a/src/rendering/abufferrenderer.cpp b/src/rendering/abufferrenderer.cpp index fb9be4e8a7..5bc54db990 100644 --- a/src/rendering/abufferrenderer.cpp +++ b/src/rendering/abufferrenderer.cpp @@ -975,7 +975,8 @@ void ABufferRenderer::updateRaycastData() { if (helperPath.empty()) { data.namespaceName = "NAMESPACE_" + std::to_string(nextNamespaceIndex++); - } else { + } + else { auto iter = namespaceIndices.find(helperPath); if (iter == namespaceIndices.end()) { int namespaceIndex = nextNamespaceIndex++; diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index d260facb32..5a3ff016cd 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -51,6 +51,30 @@ namespace { constexpr const char* _loggerCat = "FramebufferRenderer"; + // If this is true (detected automatically), the OpenGL debug information functions + // are available and will be used to mark object names and debug groups + bool HasGLDebugInfo = false; + + struct GLDebugGroup { + explicit GLDebugGroup(std::string_view name) { + if (HasGLDebugInfo) { + glPushDebugGroup( + GL_DEBUG_SOURCE_APPLICATION, + 0, + name.length(), + name.data() + ); + } + } + + ~GLDebugGroup() { + if (HasGLDebugInfo) { + glPopDebugGroup(); + } + } + }; + + constexpr const std::array HDRUniformNames = { "hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma", "Hue", "Saturation", "Value" @@ -141,6 +165,10 @@ namespace openspace { void FramebufferRenderer::initialize() { LDEBUG("Initializing FramebufferRenderer"); + HasGLDebugInfo = glbinding::Binding::ObjectLabel.isResolved() && + glbinding::Binding::PushDebugGroup.isResolved() && + glbinding::Binding::PopDebugGroup.isResolved(); + const GLfloat vertexData[] = { // x y -1.f, -1.f, @@ -165,35 +193,112 @@ void FramebufferRenderer::initialize() { // GBuffers glGenTextures(1, &_gBuffers.colorTexture); + if (HasGLDebugInfo) { + glObjectLabel(GL_TEXTURE, _gBuffers.colorTexture, -1, "G-Buffer Color"); + } glGenTextures(1, &_gBuffers.depthTexture); + if (HasGLDebugInfo) { + glObjectLabel(GL_TEXTURE, _gBuffers.depthTexture, -1, "G-Buffer Depth"); + } glGenTextures(1, &_gBuffers.positionTexture); + if (HasGLDebugInfo) { + glObjectLabel(GL_TEXTURE, _gBuffers.positionTexture, -1, "G-Buffer Position"); + } glGenTextures(1, &_gBuffers.normalTexture); + if (HasGLDebugInfo) { + glObjectLabel(GL_TEXTURE, _gBuffers.normalTexture, -1, "G-Buffer Normal"); + } glGenFramebuffers(1, &_gBuffers.framebuffer); + if (HasGLDebugInfo) { + glObjectLabel(GL_FRAMEBUFFER, _gBuffers.framebuffer, -1, "G-Buffer Main"); + } // PingPong Buffers // The first pingpong buffer shares the color texture with the renderbuffer: _pingPongBuffers.colorTexture[0] = _gBuffers.colorTexture; glGenTextures(1, &_pingPongBuffers.colorTexture[1]); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel( + GL_TEXTURE, + _pingPongBuffers.colorTexture[1], + -1, + "G-Buffer Color Ping-Pong" + ); + } glGenFramebuffers(1, &_pingPongBuffers.framebuffer); - + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel( + GL_FRAMEBUFFER, + _pingPongBuffers.framebuffer, + -1, + "G-Buffer Ping-Pong" + ); + } + // Exit framebuffer glGenTextures(1, &_exitColorTexture); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel(GL_TEXTURE, _exitColorTexture, -1, "Exit color"); + } glGenTextures(1, &_exitDepthTexture); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel(GL_TEXTURE, _exitColorTexture, -1, "Exit depth"); + } glGenFramebuffers(1, &_exitFramebuffer); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel(GL_FRAMEBUFFER, _exitFramebuffer, -1, "Exit"); + } // HDR / Filtering Buffers glGenFramebuffers(1, &_hdrBuffers.hdrFilteringFramebuffer); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel(GL_FRAMEBUFFER, _exitFramebuffer, -1, "HDR filtering"); + } glGenTextures(1, &_hdrBuffers.hdrFilteringTexture); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel(GL_TEXTURE, _hdrBuffers.hdrFilteringTexture, -1, "HDR filtering"); + } + // FXAA Buffers glGenFramebuffers(1, &_fxaaBuffers.fxaaFramebuffer); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel(GL_FRAMEBUFFER, _fxaaBuffers.fxaaFramebuffer, -1, "FXAA"); + } glGenTextures(1, &_fxaaBuffers.fxaaTexture); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel(GL_TEXTURE, _fxaaBuffers.fxaaTexture, -1, "FXAA"); + } // DownscaleVolumeRendering glGenFramebuffers(1, &_downscaleVolumeRendering.framebuffer); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel( + GL_FRAMEBUFFER, + _downscaleVolumeRendering.framebuffer, + -1, + "Downscaled Volume" + ); + } glGenTextures(1, &_downscaleVolumeRendering.colorTexture); + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel( + GL_TEXTURE, + _downscaleVolumeRendering.colorTexture, + -1, + "Downscaled Volume Color" + ); + } glGenTextures(1, &_downscaleVolumeRendering.depthbuffer); - + if (glbinding::Binding::ObjectLabel.isResolved()) { + glObjectLabel( + GL_TEXTURE, + _downscaleVolumeRendering.depthbuffer, + -1, + "Downscaled Volume Depth" + ); + } + // Allocate Textures/Buffers Memory updateResolution(); @@ -424,23 +529,19 @@ void FramebufferRenderer::applyTMO(float blackoutFactor) { if (doPerformanceMeasurements) { perfInternal = std::make_unique( "FramebufferRenderer::render::TMO" - ); + ); } _hdrFilteringProgram->activate(); ghoul::opengl::TextureUnit hdrFeedingTextureUnit; hdrFeedingTextureUnit.activate(); - glBindTexture( - GL_TEXTURE_2D, - _pingPongBuffers.colorTexture[_pingPongIndex] - ); + glBindTexture(GL_TEXTURE_2D, _pingPongBuffers.colorTexture[_pingPongIndex]); _hdrFilteringProgram->setUniform( _hdrUniformCache.hdrFeedingTexture, hdrFeedingTextureUnit ); - _hdrFilteringProgram->setUniform(_hdrUniformCache.blackoutFactor, blackoutFactor); _hdrFilteringProgram->setUniform(_hdrUniformCache.hdrExposure, _hdrExposure); _hdrFilteringProgram->setUniform(_hdrUniformCache.gamma, _gamma); @@ -468,7 +569,7 @@ void FramebufferRenderer::applyFXAA() { if (doPerformanceMeasurements) { perfInternal = std::make_unique( "FramebufferRenderer::render::FXAA" - ); + ); } _fxaaProgram->activate(); @@ -1042,6 +1143,9 @@ void FramebufferRenderer::updateDownscaledVolume() { void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFactor) { ZoneScoped + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + { // Set OpenGL default rendering state ZoneScopedN("Setting OpenGL state") @@ -1076,6 +1180,8 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac ZoneScopedN("Deferred G-Buffer") TracyGpuZone("Deferred G-Buffer") + glViewport(0, 0, _resolution.x, _resolution.y); + glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); glDrawBuffers(3, ColorAttachment012Array); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -1091,15 +1197,28 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac }; RendererTasks tasks; - data.renderBinMask = static_cast(Renderable::RenderBin::Background); - scene->render(data, tasks); - data.renderBinMask = static_cast(Renderable::RenderBin::Opaque); - scene->render(data, tasks); - data.renderBinMask = static_cast(Renderable::RenderBin::Transparent); - scene->render(data, tasks); + { + GLDebugGroup group("Background"); + data.renderBinMask = static_cast(Renderable::RenderBin::Background); + scene->render(data, tasks); + } + + { + GLDebugGroup group("Opaque"); + data.renderBinMask = static_cast(Renderable::RenderBin::Opaque); + scene->render(data, tasks); + } + + { + GLDebugGroup group("Transparent"); + data.renderBinMask = static_cast(Renderable::RenderBin::Transparent); + scene->render(data, tasks); + } // Run Volume Tasks { + GLDebugGroup group("Raycaster Tasks"); + std::unique_ptr perfInternal; if (doPerformanceMeasurements) { perfInternal = std::make_unique( @@ -1107,9 +1226,15 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac ); } performRaycasterTasks(tasks.raycasterTasks); + + if (HasGLDebugInfo) { + glPopDebugGroup(); + } } if (!tasks.deferredcasterTasks.empty()) { + GLDebugGroup group("Deferred Caster Tasks"); + // We use ping pong rendering in order to be able to // render to the same final buffer, multiple // deferred tasks at same time (e.g. more than 1 ATM being seen at once) @@ -1124,22 +1249,28 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac } performDeferredTasks(tasks.deferredcasterTasks); } - + glDrawBuffers(1, &ColorAttachment01Array[_pingPongIndex]); glEnablei(GL_BLEND, 0); - data.renderBinMask = static_cast(Renderable::RenderBin::Overlay); - scene->render(data, tasks); + { + GLDebugGroup group("Overlay"); + data.renderBinMask = static_cast(Renderable::RenderBin::Overlay); + scene->render(data, tasks); + } glDrawBuffer(GL_COLOR_ATTACHMENT0); // Disabling depth test for filtering and hdr glDisable(GL_DEPTH_TEST); + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + if (_enableFXAA) { glBindFramebuffer(GL_FRAMEBUFFER, _fxaaBuffers.fxaaFramebuffer); glDrawBuffers(1, ColorAttachment0Array); glDisable(GL_BLEND); + } else { // When applying the TMO, the result is saved to the default FBO to be displayed @@ -1147,10 +1278,15 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); } - // Apply the selected TMO on the results and resolve the result for the default FBO - applyTMO(blackoutFactor); + { + // Apply the selected TMO on the results and resolve the result to the default FBO + GLDebugGroup group("Apply TMO"); + + applyTMO(blackoutFactor); + } if (_enableFXAA) { + GLDebugGroup group("Apply FXAA"); glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); applyFXAA(); } diff --git a/src/rendering/luaconsole.cpp b/src/rendering/luaconsole.cpp index 022c144dbb..84a4f3ba79 100644 --- a/src/rendering/luaconsole.cpp +++ b/src/rendering/luaconsole.cpp @@ -817,7 +817,8 @@ void LuaConsole::render() { const glm::vec2 loc = locationForRightJustifiedText(nClientsText); RenderFont(*_font, loc, nClientsText, Red); - } else if (global::parallelPeer.isHost()) { + } + else if (global::parallelPeer.isHost()) { const glm::vec4 LightBlue(0.4f, 0.4f, 1.f, 1.f); const std::string localExecutionText = "Local script execution"; diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 908cd3d200..cc3bbbfb51 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -128,7 +128,8 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) if (!tagName.empty()) { addTag(std::move(tagName)); } - } else if (dictionary.hasKeyAndValue(KeyTag)) { + } + else if (dictionary.hasKeyAndValue(KeyTag)) { const ghoul::Dictionary& tagNames = dictionary.value(KeyTag); const std::vector& keys = tagNames.keys(); for (const std::string& key : keys) { diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index a153149ed1..ed9b3fbbeb 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -442,7 +442,8 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary if (!tagName.empty()) { addTag(std::move(tagName)); } - } else if (dictionary.hasKeyAndValue(KeyTag)) { + } + else if (dictionary.hasKeyAndValue(KeyTag)) { const ghoul::Dictionary& tagNames = dictionary.value(KeyTag); const std::vector& keys = tagNames.keys(); for (const std::string& key : keys) { diff --git a/src/rendering/transferfunction.cpp b/src/rendering/transferfunction.cpp index f2abf5fc9e..f702b1d347 100644 --- a/src/rendering/transferfunction.cpp +++ b/src/rendering/transferfunction.cpp @@ -45,7 +45,8 @@ namespace { return (0 == filepath.compare( filepath.length() - ending.length(), ending.length(), ending)); - } else { + } + else { return false; } } @@ -95,7 +96,8 @@ void TransferFunction::update() { if (_needsUpdate) { if (hasExtension(_filepath, "txt")) { setTextureFromTxt(); - } else { + } + else { setTextureFromImage(); } _texture->uploadTexture(); @@ -133,13 +135,16 @@ void TransferFunction::setTextureFromTxt(std::shared_ptr if (key == "width") { iss >> width; - } else if (key == "lower") { + } + else if (key == "lower") { iss >> lower; lower = glm::clamp(lower, 0.f, 1.f); - } else if (key == "upper") { + } + else if (key == "upper") { iss >> upper; upper = glm::clamp(upper, lower, 1.f); - } else if (key == "mappingkey") { + } + else if (key == "mappingkey") { float intensity; glm::vec4 rgba = glm::vec4(0.f); iss >> intensity; diff --git a/src/scene/assetloader.cpp b/src/scene/assetloader.cpp index 15ce77bb86..6d4b7c95c0 100644 --- a/src/scene/assetloader.cpp +++ b/src/scene/assetloader.cpp @@ -323,7 +323,8 @@ std::string AssetLoader::generateAssetPath(const std::string& baseDirectory, std::string prefix; if (pathType == PathType::RelativeToAsset) { prefix = baseDirectory + ghoul::filesystem::FileSystem::PathSeparator; - } else if (pathType == PathType::RelativeToAssetRoot) { + } + else if (pathType == PathType::RelativeToAssetRoot) { prefix = _assetRootDirectory + ghoul::filesystem::FileSystem::PathSeparator; } @@ -464,7 +465,8 @@ void AssetLoader::unrequest(const std::string& identifier) { ghoul::filesystem::Directory AssetLoader::currentDirectory() const { if (_currentAsset->hasAssetFile()) { return _currentAsset->assetDirectory(); - } else { + } + else { return _assetRootDirectory; } } diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index f8c9ef6e8a..1f5574816f 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -468,7 +469,8 @@ SceneGraphNode* Scene::loadNode(const ghoul::Dictionary& nodeDictionary) { if (parent) { parent->attachChild(std::move(node)); - } else { + } + else { attachNode(std::move(node)); } diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index ee8b2d6258..1e00beee8c 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -29,7 +29,6 @@ #include #include -#pragma optimize ("", off) namespace openspace { namespace { diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 4fdabb91e7..5177ea9c69 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -252,7 +252,8 @@ std::unique_ptr SceneGraphNode::createFromDictionary( if (!tagName.empty()) { result->addTag(std::move(tagName)); } - } else if (dictionary.hasKeyAndValue(KeyTag)) { + } + else if (dictionary.hasKeyAndValue(KeyTag)) { ghoul::Dictionary tagNames = dictionary.value(KeyTag); std::vector keys = tagNames.keys(); std::string tagName; diff --git a/src/scene/scenelicensewriter.cpp b/src/scene/scenelicensewriter.cpp index 84832573ba..9dc82ea163 100644 --- a/src/scene/scenelicensewriter.cpp +++ b/src/scene/scenelicensewriter.cpp @@ -66,7 +66,8 @@ std::string SceneLicenseWriter::generateJson() const { for (const char& c : json.str()) { if (c == '\'') { jsonString += "\\'"; - } else { + } + else { jsonString += c; } } diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index 3beb182fc4..8ff0a2e935 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -182,7 +182,8 @@ bool ScriptEngine::runScript(const std::string& script, ScriptCallback callback) ghoul::Dictionary returnValue = ghoul::lua::loadArrayDictionaryFromString(script, _state); callback(returnValue); - } else { + } + else { ghoul::lua::runScript(_state, script); } } @@ -651,7 +652,8 @@ bool ScriptEngine::writeLog(const std::string& script) { return false; } - } else { + } + else { _logScripts = false; return false; } @@ -738,7 +740,8 @@ void ScriptEngine::postSync(bool isMaster) { continue; } } - } else { + } + else { std::lock_guard guard(_slaveScriptsMutex); while (!_slaveScriptQueue.empty()) { try { diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 0b9a076ece..4ffce5c454 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -412,18 +412,18 @@ int saveLastChangeToProfile(lua_State* L) { std::string strNew = fmt::format("{}\n{}",actualLastLine, strReplace); std::ifstream filein(assetPath); std::ofstream fileout(tempAssetPath); - if(!filein) { + if (!filein) { ghoul::lua::push(L, fmt::format("Could not open profile '{}'", assetPath)); printInternal(ghoul::logging::LogLevel::Error, L); } - if(!fileout) { + if (!fileout) { ghoul::lua::push(L, fmt::format("Could not open tmp profile '{}'", tempAssetPath)); printInternal(ghoul::logging::LogLevel::Error, L); } bool found = false; while(std::getline (filein, line)) { - if(line == strReplace){ + if (line == strReplace) { line = strNew; found = true; } @@ -444,7 +444,8 @@ int saveLastChangeToProfile(lua_State* L) { } FileSys.deleteFile(tempAssetPath); return 0; - } else { + } + else { ghoul::lua::push(L, "can not save to built in profiles"); printInternal(ghoul::logging::LogLevel::Error, L); return -1; diff --git a/src/util/camera.cpp b/src/util/camera.cpp index 82d912c52c..02cd915e04 100644 --- a/src/util/camera.cpp +++ b/src/util/camera.cpp @@ -156,20 +156,20 @@ float Camera::scaling() const { } const glm::dmat4& Camera::viewRotationMatrix() const { - if (_cachedViewRotationMatrix.isDirty) { + //if (_cachedViewRotationMatrix.isDirty) { _cachedViewRotationMatrix.datum = glm::mat4_cast( glm::inverse(static_cast(_rotation)) ); _cachedViewRotationMatrix.isDirty = false; - } + //} return _cachedViewRotationMatrix.datum; } const glm::dmat4& Camera::viewScaleMatrix() const { - if (_cachedViewScaleMatrix.isDirty) { + //if (_cachedViewScaleMatrix.isDirty) { _cachedViewScaleMatrix.datum = glm::scale(glm::mat4(1.f), glm::vec3(_scaling)); _cachedViewScaleMatrix.isDirty = false; - } + //} return _cachedViewScaleMatrix.datum; } @@ -178,7 +178,7 @@ const glm::dquat& Camera::rotationQuaternion() const { } const glm::dmat4& Camera::combinedViewMatrix() const { - if (_cachedCombinedViewMatrix.isDirty) { + //if (_cachedCombinedViewMatrix.isDirty) { const glm::dmat4 cameraTranslation = glm::inverse( glm::translate(glm::dmat4(1.0), static_cast(_position)) ); @@ -188,7 +188,7 @@ const glm::dmat4& Camera::combinedViewMatrix() const { glm::dmat4(viewRotationMatrix()) * cameraTranslation; _cachedCombinedViewMatrix.isDirty = false; - } + //} return _cachedCombinedViewMatrix.datum; } @@ -256,11 +256,11 @@ const glm::mat4& Camera::SgctInternal::projectionMatrix() const { } const glm::mat4& Camera::SgctInternal::viewProjectionMatrix() const { - if (_cachedViewProjectionMatrix.isDirty) { + //if (_cachedViewProjectionMatrix.isDirty) { std::lock_guard _lock(_mutex); _cachedViewProjectionMatrix.datum = _projectionMatrix * _viewMatrix; _cachedViewProjectionMatrix.isDirty = false; - } + //} return _cachedViewProjectionMatrix.datum; } diff --git a/src/util/histogram.cpp b/src/util/histogram.cpp index 15345b873b..148b3d2a19 100644 --- a/src/util/histogram.cpp +++ b/src/util/histogram.cpp @@ -127,7 +127,8 @@ bool Histogram::add(const Histogram& histogram) { } _numValues += histogram._numValues; return true; - } else { + } + else { LERROR("Dimension mismatch"); return false; } @@ -329,7 +330,8 @@ float Histogram::highestBinValue(bool equalized, int overBins){ _numBins * (_maxValue - _minValue); float high = low + (_maxValue - _minValue) / static_cast(_numBins); return (high+low) / 2.f; - } else { + } + else { return highestBin / static_cast(_numBins); // return equalize((high+low)/2.0); } diff --git a/src/util/httprequest.cpp b/src/util/httprequest.cpp index 4d9262a505..74e1749d1d 100644 --- a/src/util/httprequest.cpp +++ b/src/util/httprequest.cpp @@ -142,10 +142,12 @@ void HttpRequest::perform(RequestOptions opt) { curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &responseCode); // NOLINT if (responseCode == StatusCodeOk) { setReadyState(ReadyState::Success); - } else { + } + else { setReadyState(ReadyState::Fail); } - } else { + } + else { setReadyState(ReadyState::Fail); } curl_easy_cleanup(curl); @@ -218,7 +220,8 @@ void SyncHttpDownload::download(HttpRequest::RequestOptions opt) { LTRACE(fmt::format("Finished sync download '{}'", _httpRequest.url())); deinitDownload(); markAsSuccessful(); - } else if (rs == HttpRequest::ReadyState::Fail) { + } + else if (rs == HttpRequest::ReadyState::Fail) { LERROR(fmt::format("Failed sync download '{}'", _httpRequest.url())); deinitDownload(); markAsFailed(); diff --git a/src/util/taskloader.cpp b/src/util/taskloader.cpp index 2ef22f1b3a..75778d07d3 100644 --- a/src/util/taskloader.cpp +++ b/src/util/taskloader.cpp @@ -52,7 +52,8 @@ std::vector> TaskLoader::tasksFromDictionary( const std::string path = taskName + ".task"; std::vector> subTasks = tasksFromFile(path); std::move(subTasks.begin(), subTasks.end(), std::back_inserter(tasks)); - } else if (tasksDictionary.getValue(key, subTask)) { + } + else if (tasksDictionary.getValue(key, subTask)) { const std::string& taskType = subTask.value("Type"); std::unique_ptr task = Task::createFromDictionary(subTask); if (!task) { diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index 613b942839..008f129b91 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -56,7 +56,8 @@ int time_setDeltaTime(lua_State* L) { } const double newDeltaTime = lua_tonumber(L, 1); global::timeManager.setDeltaTime(newDeltaTime); - } else { + } + else { lua_settop(L, 0); const char* msg = lua_pushfstring(L, "Bad number of arguments. Expected 1 or 2."); @@ -159,7 +160,8 @@ int time_togglePause(lua_State* L) { if (nArguments == 0) { global::timeManager.setPause(!global::timeManager.isPaused()); - } else { + } + else { lua_settop(L, 0); return luaL_error( L, @@ -210,7 +212,8 @@ int time_interpolateTogglePause(lua_State* L) { global::timeManager.defaultPauseInterpolationDuration() : global::timeManager.defaultUnpauseInterpolationDuration() ); - } else { + } + else { lua_settop(L, 0); return luaL_error( L, @@ -236,7 +239,8 @@ int time_setPause(lua_State* L) { if (nArguments == 1) { const bool pause = lua_toboolean(L, 1) == 1; global::timeManager.setPause(pause); - } else { + } + else { lua_settop(L, 0); return luaL_error( L, @@ -284,7 +288,8 @@ int time_interpolatePause(lua_State* L) { global::timeManager.defaultPauseInterpolationDuration() : global::timeManager.defaultUnpauseInterpolationDuration() ); - } else { + } + else { lua_settop(L, 0); return luaL_error( L, @@ -342,7 +347,8 @@ int time_setTime(lua_State* L) { return 0; } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); - } else { + } + else { return luaL_error( L, "bad number of arguments, expected 1 or 2, got %i", diff --git a/src/util/timemanager.cpp b/src/util/timemanager.cpp index cc17806280..e1ecf58d74 100644 --- a/src/util/timemanager.cpp +++ b/src/util/timemanager.cpp @@ -193,7 +193,8 @@ TimeKeyframeData TimeManager::interpolate(double applicationTime) { *firstFutureKeyframe, applicationTime ); - } else if (hasPastKeyframes) { + } + else if (hasPastKeyframes) { // Extrapolate based on last past keyframe const double deltaApplicationTime = applicationTime - lastPastKeyframe->timestamp; Time predictedTime( @@ -271,9 +272,11 @@ void TimeManager::progressTime(double dt) { _currentTime.data().setTime(interpolated.time.j2000Seconds()); _deltaTime = interpolated.delta; - } else if (!hasConsumedLastPastKeyframe) { + } + else if (!hasConsumedLastPastKeyframe) { applyKeyframeData(lastPastKeyframe->data); - } else if (!isPaused()) { + } + else if (!isPaused()) { // If there are no keyframes to consider // and time is not paused, just advance time. _deltaTime = _targetDeltaTime; diff --git a/src/util/touch.cpp b/src/util/touch.cpp index 995e871850..aa0ef75ddd 100644 --- a/src/util/touch.cpp +++ b/src/util/touch.cpp @@ -128,7 +128,7 @@ float TouchInputHolder::speedX() const { } float TouchInputHolder::speedY() const { - if(_inputs.size() <= 1) { + if (_inputs.size() <= 1) { return 0.f; } const TouchInput& currentInput = _inputs[0]; diff --git a/src/util/transformationmanager.cpp b/src/util/transformationmanager.cpp index 663f06b605..08e14675ae 100644 --- a/src/util/transformationmanager.cpp +++ b/src/util/transformationmanager.cpp @@ -134,7 +134,8 @@ glm::dmat3 TransformationManager::frameTransformationMatrix( if (fromKameleon && toKameleon) { return kameleonTransformationMatrix(from, to, ephemerisTime); - } else if (fromKameleon && !toKameleon) { + } + else if (fromKameleon && !toKameleon) { glm::dmat3 kameleonTransformation = kameleonTransformationMatrix( from, "J2000", @@ -146,7 +147,8 @@ glm::dmat3 TransformationManager::frameTransformationMatrix( ephemerisTime ); return spiceTransformation*kameleonTransformation; - } else if (!fromKameleon && toKameleon) { + } + else if (!fromKameleon && toKameleon) { glm::dmat3 spiceTransformation = SpiceManager::ref().frameTransformationMatrix( from, "J2000", diff --git a/src/util/versionchecker.cpp b/src/util/versionchecker.cpp index 7f4b077bc0..aabec2be59 100644 --- a/src/util/versionchecker.cpp +++ b/src/util/versionchecker.cpp @@ -105,7 +105,8 @@ void VersionChecker::cancel() { currentVersion.minor, currentVersion.patch )); - } else { + } + else { LINFO(fmt::format( "OpenSpace version {}.{}.{} is up to date.", currentVersion.major, diff --git a/support/cmake/openspace_header.template b/support/cmake/openspace_header.template index 5cae439242..ca8ede21eb 100644 --- a/support/cmake/openspace_header.template +++ b/support/cmake/openspace_header.template @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2019 * + * Copyright (c) 2014-2020 * * * * Permission is hereby granted, free of charge, to any person obtaining a copy of this * * software and associated documentation files (the "Software"), to deal in the Software * diff --git a/support/cmake/set_openspace_compile_settings.cmake b/support/cmake/set_openspace_compile_settings.cmake index 70abc0f055..61efb29938 100644 --- a/support/cmake/set_openspace_compile_settings.cmake +++ b/support/cmake/set_openspace_compile_settings.cmake @@ -30,7 +30,6 @@ function (set_openspace_compile_settings project) target_compile_options( ${project} PRIVATE - "/ZI" # Edit and continue support "/MP" # Multi-threading support "/W4" # Highest warning level "/w44062" # enumerator 'identifier' in a switch of enum 'enumeration' is not handled @@ -81,8 +80,28 @@ function (set_openspace_compile_settings project) # Boost as of 1.64 still uses unary_function unless we define this target_compile_definitions(${project} PRIVATE "_HAS_AUTO_PTR_ETC") - target_compile_definitions(${project} PRIVATE "NOMINMAX") + + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX) + target_compile_options(${project} PRIVATE "/arch:AVX") + endif () + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX2) + target_compile_options(${project} PRIVATE "/arch:AVX2") + endif () + if (OPENSPACE_OPTIMIZATION_ENABLE_AVX512) + target_compile_options(${project} PRIVATE "/arch:AVX512") + endif () + + if (OPENSPACE_OPTIMIZATION_ENABLE_OTHER_OPTIMIZATIONS) + target_compile_options(${project} PRIVATE + "/Oi" # usage of intrinsic functions + "/GL" # Whole program optimization + ) + else () + target_compile_options(${project} PRIVATE + "/ZI" # Edit and continue support + ) + endif () elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (OPENSPACE_WARNINGS_AS_ERRORS) target_compile_options(${project} PRIVATE "-Werror") diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py index 34d03f6122..8b23b4027f 100644 --- a/support/coding/check_style_guide.py +++ b/support/coding/check_style_guide.py @@ -3,7 +3,7 @@ """ OpenSpace -Copyright (c) 2014-2018 +Copyright (c) 2014-2020 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software @@ -59,7 +59,7 @@ import os import re import sys -current_year = '2019' +current_year = '2020' is_strict_mode = False is_silent_mode = False diff --git a/support/coding/convert_tabs.py b/support/coding/convert_tabs.py index a7ae4d0b49..21425ae092 100644 --- a/support/coding/convert_tabs.py +++ b/support/coding/convert_tabs.py @@ -1,7 +1,7 @@ """ OpenSpace -Copyright (c) 2014-2018 +Copyright (c) 2014-2020 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software diff --git a/support/coding/count_includes.py b/support/coding/count_includes.py index 96cd39d9da..12088368cd 100644 --- a/support/coding/count_includes.py +++ b/support/coding/count_includes.py @@ -1,7 +1,7 @@ """ OpenSpace -Copyright (c) 2014-2018 +Copyright (c) 2014-2020 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software diff --git a/support/coding/new_files.py b/support/coding/new_files.py index ca3a3753ba..60ee3c29e2 100644 --- a/support/coding/new_files.py +++ b/support/coding/new_files.py @@ -1,7 +1,7 @@ """ OpenSpace -Copyright (c) 2014-2018 +Copyright (c) 2014-2020 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software @@ -33,8 +33,8 @@ Project = { } License = { - 'OpenSpace': '/*****************************************************************************************\n * *\n * OpenSpace *\n * *\n * Copyright (c) 2014-2018 *\n * *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this *\n * software and associated documentation files (the "Software"), to deal in the Software *\n * without restriction, including without limitation the rights to use, copy, modify, *\n * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *\n * permit persons to whom the Software is furnished to do so, subject to the following *\n * conditions: *\n * *\n * The above copyright notice and this permission notice shall be included in all copies *\n * or substantial portions of the Software. *\n * *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *\n * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *\n * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *\n ****************************************************************************************/', - 'Ghoul': '/*****************************************************************************************\n * *\n * GHOUL *\n * General Helpful Open Utility Library *\n * *\n * Copyright (c) 2012-2018 *\n * *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this *\n * software and associated documentation files (the "Software"), to deal in the Software *\n * without restriction, including without limitation the rights to use, copy, modify, *\n * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *\n * permit persons to whom the Software is furnished to do so, subject to the following *\n * conditions: *\n * *\n * The above copyright notice and this permission notice shall be included in all copies *\n * or substantial portions of the Software. *\n * *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *\n * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *\n * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *\n ****************************************************************************************/' + 'OpenSpace': '/*****************************************************************************************\n * *\n * OpenSpace *\n * *\n * Copyright (c) 2014-2020 *\n * *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this *\n * software and associated documentation files (the "Software"), to deal in the Software *\n * without restriction, including without limitation the rights to use, copy, modify, *\n * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *\n * permit persons to whom the Software is furnished to do so, subject to the following *\n * conditions: *\n * *\n * The above copyright notice and this permission notice shall be included in all copies *\n * or substantial portions of the Software. *\n * *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *\n * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *\n * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *\n ****************************************************************************************/', + 'Ghoul': '/*****************************************************************************************\n * *\n * GHOUL *\n * General Helpful Open Utility Library *\n * *\n * Copyright (c) 2012-2020 *\n * *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this *\n * software and associated documentation files (the "Software"), to deal in the Software *\n * without restriction, including without limitation the rights to use, copy, modify, *\n * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *\n * permit persons to whom the Software is furnished to do so, subject to the following *\n * conditions: *\n * *\n * The above copyright notice and this permission notice shall be included in all copies *\n * or substantial portions of the Software. *\n * *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *\n * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *\n * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *\n ****************************************************************************************/' } Namespace = { diff --git a/support/coding/remove_byte_order_mark.py b/support/coding/remove_byte_order_mark.py index b663e379d6..8095c6d835 100644 --- a/support/coding/remove_byte_order_mark.py +++ b/support/coding/remove_byte_order_mark.py @@ -1,7 +1,7 @@ """ OpenSpace -Copyright (c) 2014-2018 +Copyright (c) 2014-2020 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software From 048665e35e15e5204a5078675f2972926eccb310 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 26 Feb 2020 13:34:33 -0700 Subject: [PATCH 03/67] Added checks to enforce 0.0 - 360.0 range on angles in JPL Horizons data --- .../space/rendering/renderablesmallbody.cpp | 23 +++++++++++++------ modules/space/rendering/renderablesmallbody.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index eb486a5035..be5dbf2ba3 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -105,8 +105,8 @@ enum Months { December }; -int daysIntoGivenYear(int year, int month, int dayOfMonth) { - //month and dayCount are zero-based +int daysIntoGivenYear(int month, int dayOfMonth) { + //month and dayCount are zero-based. Does NOT account for leap year. month -= 1; int dayCount = dayOfMonth - 1; @@ -140,7 +140,7 @@ double epochFromYMDdSubstring(const std::string& epochString) { // 2.a int monthNum = std::atoi(epochString.substr(4, 2).c_str()); int dayOfMonthNum = std::atoi(epochString.substr(6, 2).c_str()); - int wholeDaysInto = daysIntoGivenYear(year, monthNum, dayOfMonthNum); + int wholeDaysInto = daysIntoGivenYear(monthNum, dayOfMonthNum); double fractionOfDay = std::atof(epochString.substr(9, 7).c_str()); double daysInYear = static_cast(wholeDaysInto) + fractionOfDay; @@ -344,7 +344,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read inclination from line" + std::to_string(csvLine + 1)); } - keplerElements.inclination = std::stod(field); + keplerElements.inclination = importAngleValue(field); fieldCount++; // Longitude of ascending node (degrees) @@ -352,7 +352,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read ascending node from line" + std::to_string(csvLine + 1)); } - keplerElements.ascendingNode = std::stod(field); + keplerElements.ascendingNode = importAngleValue(field); fieldCount++; // Argument of Periapsis (degrees) @@ -360,7 +360,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read arg of periapsis from line" + std::to_string(csvLine + 1)); } - keplerElements.argumentOfPeriapsis = std::stod(field); + keplerElements.argumentOfPeriapsis = importAngleValue(field); fieldCount++; // Mean Anomaly (degrees) @@ -368,7 +368,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { throw std::invalid_argument("Unable to read mean anomaly from line" + std::to_string(csvLine + 1)); } - keplerElements.meanAnomaly = std::stod(field); + keplerElements.meanAnomaly = importAngleValue(field); fieldCount++; // Period (days) @@ -412,6 +412,15 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { file.close(); } +static double importAngleValue(const std::string& angle) { + double output = std::stod(angle); + output = std::fmod(output, 360.0); + if (output < 0.0) { + output += 360.0; + } + return output; +} + void RenderableSmallBody::initializeGL() { glGenVertexArrays(1, &_vertexArray); glGenBuffers(1, &_vertexBuffer); diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index a61b56cb74..4e1b87219a 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -126,6 +126,8 @@ private: const double convertDaysToSecs = 86400.; }; +static double importAngleValue(const std::string& angle); + } // namespace openspace #endif // __OPENSPACE_MODULE_SPACE___RENDERABLESMALLBODY___H__ From ce79a7031e7641d69b1b322a7f34d8050272cabb Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 28 Feb 2020 16:16:06 -0700 Subject: [PATCH 04/67] Implemented upper limit on objects to render from data file --- .../space/rendering/renderablesmallbody.cpp | 215 +++++++++++------- modules/space/rendering/renderablesmallbody.h | 4 + 2 files changed, 137 insertions(+), 82 deletions(-) diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index be5dbf2ba3..c39cda7475 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -60,6 +60,12 @@ namespace { "Segments", "The number of segments to use for each orbit ellipse" }; + static const openspace::properties::Property::PropertyInfo UpperLimitInfo = { + "UpperLimit", + "Upper Limit", + "Upper limit on the number of objects for this renderable, regardless of " + "how many objects are contained in the data file" + }; constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { "LineWidth", "Line Width", @@ -192,6 +198,12 @@ documentation::Documentation RenderableSmallBody::Documentation() { Optional::No, SegmentsInfo.description }, + { + UpperLimitInfo.identifier, + new IntVerifier, + Optional::Yes, + UpperLimitInfo.description + }, { PathInfo.identifier, new StringVerifier, @@ -223,8 +235,8 @@ documentation::Documentation RenderableSmallBody::Documentation() { RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _path(PathInfo) - , _nSegments(SegmentsInfo) - + , _nSegments(SegmentsInfo, 100, 10, 4000) + , _upperLimit(UpperLimitInfo, 1000, 1, 1000000) { documentation::testSpecificationAndThrow( Documentation(), @@ -233,7 +245,9 @@ RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) ); _path = dictionary.value(PathInfo.identifier); - _nSegments = static_cast(dictionary.value(SegmentsInfo.identifier)); + _nSegments = static_cast( + dictionary.value(SegmentsInfo.identifier) + ); if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { _appearance.lineColor = dictionary.value(LineColorInfo.identifier); @@ -247,6 +261,15 @@ RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) _appearance.lineFade = 20; } + if (dictionary.hasKeyAndValue(UpperLimitInfo.identifier)) { + _upperLimit = static_cast( + dictionary.value(UpperLimitInfo.identifier) + ); + } + else { + _upperLimit = 0; + } + if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { _appearance.lineWidth = static_cast( dictionary.value(LineWidthInfo.identifier) @@ -262,11 +285,13 @@ RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) _path.onChange(reinitializeTrailBuffers); _nSegments.onChange(reinitializeTrailBuffers); + _upperLimit.onChange(reinitializeTrailBuffers); addPropertySubOwner(_appearance); addProperty(_path); addProperty(_nSegments); addProperty(_opacity); + addProperty(_upperLimit); setRenderBin(Renderable::RenderBin::Overlay); } @@ -288,16 +313,27 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { file.seekg(std::ios_base::beg); // reset iterator to beginning of file std::string line; - std::string name; - std::string field; std::streamoff csvLine = -1; int fieldCount = 0; + float lineSkipFraction = 1.0; + float lineSkipTotal = 0.0; + float currLineFraction; + int currLineCount; + int lastLineCount = -1; const std::string expectedHeaderLine = "full_name,epoch_cal,e,a,i,om,w,ma,per"; try { std::getline(file, line); // get rid of first line (header) numberOfLines -= 1; + if (_upperLimit == 0 || _upperLimit > numberOfLines) { + //If limit wasn't specified in dictionary, set to lines in file (-header) + _upperLimit = numberOfLines; + } + else { + lineSkipFraction = static_cast(_upperLimit) / + static_cast(numberOfLines); + } if (line.compare(expectedHeaderLine) != 0) { LERROR(fmt::format( "File {} does not have the appropriate JPL SBDB header at line 1.", @@ -307,81 +343,13 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { return; } - for (csvLine = 0; csvLine < numberOfLines; csvLine++) { - fieldCount = 0; - KeplerParameters keplerElements; - // Object designator string - std::getline(file, name, ','); - fieldCount++; - - // Epoch - if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read epoch from line" - + std::to_string(csvLine + 1)); + for (csvLine = 1; csvLine <= numberOfLines; csvLine++) { + currLineFraction = static_cast(csvLine - 1) * lineSkipFraction; + currLineCount = static_cast(currLineFraction); + if (currLineCount > lastLineCount) { + readOrbitalParamsFromThisLine(fieldCount, csvLine, file); } - keplerElements.epoch = epochFromYMDdSubstring(field); - fieldCount++; - - // Eccentricity (unit-less) - if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read eccentricity from line" - + std::to_string(csvLine + 1)); - } - keplerElements.eccentricity = std::stod(field); - fieldCount++; - - // Semi-major axis (astronomical units - au) - if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read semi-major axis from line" - + std::to_string(csvLine + 1)); - } - keplerElements.semiMajorAxis = std::stod(field); - keplerElements.semiMajorAxis *= convertAuToKm; - fieldCount++; - - // Inclination (degrees) - if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read inclination from line" - + std::to_string(csvLine + 1)); - } - keplerElements.inclination = importAngleValue(field); - fieldCount++; - - // Longitude of ascending node (degrees) - if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read ascending node from line" - + std::to_string(csvLine + 1)); - } - keplerElements.ascendingNode = importAngleValue(field); - fieldCount++; - - // Argument of Periapsis (degrees) - if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read arg of periapsis from line" - + std::to_string(csvLine + 1)); - } - keplerElements.argumentOfPeriapsis = importAngleValue(field); - fieldCount++; - - // Mean Anomaly (degrees) - if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read mean anomaly from line" - + std::to_string(csvLine + 1)); - } - keplerElements.meanAnomaly = importAngleValue(field); - fieldCount++; - - // Period (days) - if (!std::getline(file, field)) { - throw std::invalid_argument("Unable to read period from line" - + std::to_string(csvLine + 1)); - } - keplerElements.period = std::stod(field); - keplerElements.period *= convertDaysToSecs; - fieldCount++; - - _sbData.push_back(keplerElements); - _sbNames.push_back(name); + lastLineCount = currLineCount; } } catch (std::invalid_argument&) { @@ -389,7 +357,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { "(invalid_argument exception) at line {}/{} of {}"; LERROR(fmt::format( errMsg, - fieldCount, csvLine + 1, numberOfLines, filename + fieldCount, csvLine, numberOfLines, filename )); } catch (std::out_of_range&) { @@ -397,7 +365,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { "(out_of_range exception) at line {}/{} of {}"; LERROR(fmt::format( errMsg, - fieldCount, csvLine + 1, numberOfLines, filename + fieldCount, csvLine, numberOfLines, filename )); } catch (std::ios_base::failure&) { @@ -405,13 +373,96 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { "to read field {} at line {}/{} of {}"; LERROR(fmt::format( errMsg, - fieldCount, csvLine + 1, numberOfLines, filename + fieldCount, csvLine, numberOfLines, filename )); } file.close(); } +void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, + std::streamoff& csvLine, + std::ifstream& file) +{ + std::string name; + std::string field; + fieldCount = 0; + KeplerParameters keplerElements; + + // Object designator string + std::getline(file, name, ','); + fieldCount++; + + // Epoch + if (!std::getline(file, field, ',')) { + throw std::invalid_argument("Unable to read epoch from line" + + std::to_string(csvLine)); + } + keplerElements.epoch = epochFromYMDdSubstring(field); + fieldCount++; + + // Eccentricity (unit-less) + if (!std::getline(file, field, ',')) { + throw std::invalid_argument("Unable to read eccentricity from line" + + std::to_string(csvLine)); + } + keplerElements.eccentricity = std::stod(field); + fieldCount++; + + // Semi-major axis (astronomical units - au) + if (!std::getline(file, field, ',')) { + throw std::invalid_argument("Unable to read semi-major axis from line" + + std::to_string(csvLine)); + } + keplerElements.semiMajorAxis = std::stod(field); + keplerElements.semiMajorAxis *= convertAuToKm; + fieldCount++; + + // Inclination (degrees) + if (!std::getline(file, field, ',')) { + throw std::invalid_argument("Unable to read inclination from line" + + std::to_string(csvLine)); + } + keplerElements.inclination = importAngleValue(field); + fieldCount++; + + // Longitude of ascending node (degrees) + if (!std::getline(file, field, ',')) { + throw std::invalid_argument("Unable to read ascending node from line" + + std::to_string(csvLine)); + } + keplerElements.ascendingNode = importAngleValue(field); + fieldCount++; + + // Argument of Periapsis (degrees) + if (!std::getline(file, field, ',')) { + throw std::invalid_argument("Unable to read arg of periapsis from line" + + std::to_string(csvLine)); + } + keplerElements.argumentOfPeriapsis = importAngleValue(field); + fieldCount++; + + // Mean Anomaly (degrees) + if (!std::getline(file, field, ',')) { + throw std::invalid_argument("Unable to read mean anomaly from line" + + std::to_string(csvLine)); + } + keplerElements.meanAnomaly = importAngleValue(field); + fieldCount++; + + // Period (days) + if (!std::getline(file, field)) { + throw std::invalid_argument("Unable to read period from line" + + std::to_string(csvLine)); + } + keplerElements.period = std::stod(field); + keplerElements.period *= convertDaysToSecs; + fieldCount++; + + _sbData.push_back(keplerElements); + _sbNames.push_back(name); +} + static double importAngleValue(const std::string& angle) { double output = std::stod(angle); output = std::fmod(output, 360.0); diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index 4e1b87219a..531270ce09 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -88,6 +88,9 @@ private: double epoch, period; }; + void readOrbitalParamsFromThisLine(int& fieldCount, std::streamoff& csvLine, + std::ifstream& file); + KeplerTranslation _keplerTranslator; std::vector _sbData; std::vector _sbNames; @@ -114,6 +117,7 @@ private: properties::StringProperty _path; properties::UIntProperty _nSegments; + properties::UIntProperty _upperLimit; RenderableTrail::Appearance _appearance; From b222bb26dbba94ab887320986da55a46ec5deb89 Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 2 Mar 2020 15:45:52 -0700 Subject: [PATCH 05/67] Fixed upper limit bug and added new asset details to main asteroid belt --- data/assets/default.scene | 1 + .../scene/solarsystem/sssb/main_asteroid_belt.asset | 11 +++++++++++ modules/space/rendering/renderablesmallbody.cpp | 6 ++++-- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset diff --git a/data/assets/default.scene b/data/assets/default.scene index 606d5852d5..d3736bd8b9 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -3,6 +3,7 @@ asset.require('./base') local earthAsset = asset.require('scene/solarsystem/planets/earth/earth') asset.require('scene/solarsystem/planets/earth/satellites/satellites.asset') asset.require('scene/solarsystem/sssb/pha') +asset.require('scene/solarsystem/sssb/main_asteroid_belt') asset.onInitialize(function () local now = openspace.time.currentWallTime() diff --git a/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset b/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset new file mode 100644 index 0000000000..001f06578c --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main asteroid belt', 'sssb_data_main_asteroid_belt') +local object = sharedSssb.createSssbGroupObject("sssb_data_main_asteroid_belt.csv", filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 40 +object.Renderable.Fade = 3 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index c39cda7475..c793b7f820 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -252,9 +252,9 @@ RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { _appearance.lineColor = dictionary.value(LineColorInfo.identifier); } - if (dictionary.hasKeyAndValue("FadeInfo")) { + if (dictionary.hasKeyAndValue(FadeInfo.identifier)) { _appearance.lineFade = static_cast( - dictionary.value("FadeInfo") + dictionary.value(FadeInfo.identifier) ); } else { @@ -311,6 +311,8 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { std::streamoff numberOfLines = std::count(std::istreambuf_iterator(file), std::istreambuf_iterator(), '\n' ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file + _sbData.clear(); + _sbNames.clear(); std::string line; std::streamoff csvLine = -1; From dbf78b1862e5055202851ad48249d63330050132 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 4 Mar 2020 12:17:06 -0700 Subject: [PATCH 06/67] Fix for printing out correct line number if read error occurs --- .../space/rendering/renderablesmallbody.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index c793b7f820..9757bac9d6 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -359,7 +359,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { "(invalid_argument exception) at line {}/{} of {}"; LERROR(fmt::format( errMsg, - fieldCount, csvLine, numberOfLines, filename + fieldCount, csvLine + 1, numberOfLines, filename )); } catch (std::out_of_range&) { @@ -367,7 +367,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { "(out_of_range exception) at line {}/{} of {}"; LERROR(fmt::format( errMsg, - fieldCount, csvLine, numberOfLines, filename + fieldCount, csvLine + 1, numberOfLines, filename )); } catch (std::ios_base::failure&) { @@ -375,7 +375,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { "to read field {} at line {}/{} of {}"; LERROR(fmt::format( errMsg, - fieldCount, csvLine, numberOfLines, filename + fieldCount, csvLine + 1, numberOfLines, filename )); } @@ -398,7 +398,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Epoch if (!std::getline(file, field, ',')) { throw std::invalid_argument("Unable to read epoch from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.epoch = epochFromYMDdSubstring(field); fieldCount++; @@ -406,7 +406,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Eccentricity (unit-less) if (!std::getline(file, field, ',')) { throw std::invalid_argument("Unable to read eccentricity from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.eccentricity = std::stod(field); fieldCount++; @@ -414,7 +414,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Semi-major axis (astronomical units - au) if (!std::getline(file, field, ',')) { throw std::invalid_argument("Unable to read semi-major axis from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.semiMajorAxis = std::stod(field); keplerElements.semiMajorAxis *= convertAuToKm; @@ -423,7 +423,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Inclination (degrees) if (!std::getline(file, field, ',')) { throw std::invalid_argument("Unable to read inclination from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.inclination = importAngleValue(field); fieldCount++; @@ -431,7 +431,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Longitude of ascending node (degrees) if (!std::getline(file, field, ',')) { throw std::invalid_argument("Unable to read ascending node from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.ascendingNode = importAngleValue(field); fieldCount++; @@ -439,7 +439,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Argument of Periapsis (degrees) if (!std::getline(file, field, ',')) { throw std::invalid_argument("Unable to read arg of periapsis from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.argumentOfPeriapsis = importAngleValue(field); fieldCount++; @@ -447,7 +447,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Mean Anomaly (degrees) if (!std::getline(file, field, ',')) { throw std::invalid_argument("Unable to read mean anomaly from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.meanAnomaly = importAngleValue(field); fieldCount++; @@ -455,7 +455,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, // Period (days) if (!std::getline(file, field)) { throw std::invalid_argument("Unable to read period from line" - + std::to_string(csvLine)); + + std::to_string(csvLine + 1)); } keplerElements.period = std::stod(field); keplerElements.period *= convertDaysToSecs; From 0c70ee7a2d4acf0a278d46b46356300617121c4f Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 9 Mar 2020 15:08:51 -0600 Subject: [PATCH 07/67] Combining satellite & sbdb renderables under a common base class --- modules/space/CMakeLists.txt | 2 + .../rendering/renderableorbitalkepler.cpp | 525 ++++++++++++++++++ .../space/rendering/renderableorbitalkepler.h | 138 +++++ .../space/rendering/renderablesatellites.cpp | 411 +------------- .../space/rendering/renderablesatellites.h | 88 +-- .../space/rendering/renderablesmallbody.cpp | 345 +----------- modules/space/rendering/renderablesmallbody.h | 81 +-- 7 files changed, 679 insertions(+), 911 deletions(-) create mode 100644 modules/space/rendering/renderableorbitalkepler.cpp create mode 100644 modules/space/rendering/renderableorbitalkepler.h diff --git a/modules/space/CMakeLists.txt b/modules/space/CMakeLists.txt index 612c2686e4..e191a4eff1 100644 --- a/modules/space/CMakeLists.txt +++ b/modules/space/CMakeLists.txt @@ -28,6 +28,7 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablerings.h + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableorbitalkepler.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesatellites.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesmallbody.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.h @@ -44,6 +45,7 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/planetgeometry.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableconstellationbounds.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablerings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableorbitalkepler.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesatellites.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablesmallbody.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablestars.cpp diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp new file mode 100644 index 0000000000..7705c466ff --- /dev/null +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -0,0 +1,525 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + constexpr const char* ProgramName = "OrbitalKepler"; + constexpr const char* _loggerCat = "OrbitalKepler"; + + static const openspace::properties::Property::PropertyInfo PathInfo = { + "Path", + "Path", + "The file path to the data file to read" + }; + static const openspace::properties::Property::PropertyInfo SegmentsInfo = { + "Segments", + "Segments", + "The number of segments to use for each orbit ellipse" + }; + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { + "LineWidth", + "Line Width", + "This value specifies the line width of the trail if the selected rendering " + "method includes lines. If the rendering mode is set to Points, this value is " + "ignored." + }; + constexpr openspace::properties::Property::PropertyInfo LineColorInfo = { + "Color", + "Color", + "This value determines the RGB main color for the lines and points of the trail." + }; + constexpr openspace::properties::Property::PropertyInfo TrailFadeInfo = { + "TrailFade", + "Trail Fade", + "This value determines how fast the trail fades and is an appearance property. " + }; + static const openspace::properties::Property::PropertyInfo UpperLimitInfo = { + "UpperLimit", + "Upper Limit", + "Upper limit on the number of objects for this renderable, regardless of " + "how many objects are contained in the data file" + }; + + constexpr const char* KeyFile = "Path"; + constexpr const char* KeyLineNum = "LineNumber"; +} + +namespace openspace { + + // Count the number of full days since the beginning of 2000 to the beginning of + // the parameter 'year' + int countDays(int year) { + // Find the position of the current year in the vector, the difference + // between its position and the position of 2000 (for J2000) gives the + // number of leap years + constexpr const int Epoch = 2000; + constexpr const int DaysRegularYear = 365; + constexpr const int DaysLeapYear = 366; + + if (year == Epoch) { + return 0; + } + + // Get the position of the most recent leap year + const auto lb = std::lower_bound(LeapYears.begin(), LeapYears.end(), year); + + // Get the position of the epoch + const auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); + + // The distance between the two iterators gives us the number of leap years + const int nLeapYears = static_cast(std::abs(std::distance(y2000, lb))); + + const int nYears = std::abs(year - Epoch); + const int nRegularYears = nYears - nLeapYears; + + // Get the total number of days as the sum of leap years + non leap years + const int result = nRegularYears * DaysRegularYear + nLeapYears * DaysLeapYear; + return result; + } + + // Returns the number of leap seconds that lie between the {year, dayOfYear} + // time point and { 2000, 1 } + int countLeapSeconds(int year, int dayOfYear) { + // Find the position of the current year in the vector; its position in + // the vector gives the number of leap seconds + struct LeapSecond { + int year; + int dayOfYear; + bool operator<(const LeapSecond& rhs) const { + return std::tie(year, dayOfYear) < std::tie(rhs.year, rhs.dayOfYear); + } + }; + + const LeapSecond Epoch = { 2000, 1 }; + + // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list + static const std::vector LeapSeconds = { + { 1972, 1 }, + { 1972, 183 }, + { 1973, 1 }, + { 1974, 1 }, + { 1975, 1 }, + { 1976, 1 }, + { 1977, 1 }, + { 1978, 1 }, + { 1979, 1 }, + { 1980, 1 }, + { 1981, 182 }, + { 1982, 182 }, + { 1983, 182 }, + { 1985, 182 }, + { 1988, 1 }, + { 1990, 1 }, + { 1991, 1 }, + { 1992, 183 }, + { 1993, 182 }, + { 1994, 182 }, + { 1996, 1 }, + { 1997, 182 }, + { 1999, 1 }, + { 2006, 1 }, + { 2009, 1 }, + { 2012, 183 }, + { 2015, 182 }, + { 2017, 1 } + }; + + // Get the position of the last leap second before the desired date + LeapSecond date { year, dayOfYear }; + const auto it = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), date); + + // Get the position of the Epoch + const auto y2000 = std::lower_bound( + LeapSeconds.begin(), + LeapSeconds.end(), + Epoch + ); + + // The distance between the two iterators gives us the number of leap years + const int nLeapSeconds = static_cast(std::abs(std::distance(y2000, it))); + return nLeapSeconds; + } + + double calculateSemiMajorAxis(double meanMotion) { + constexpr const double GravitationalConstant = 6.6740831e-11; + constexpr const double MassEarth = 5.9721986e24; + constexpr const double muEarth = GravitationalConstant * MassEarth; + + // Use Kepler's 3rd law to calculate semimajor axis + // a^3 / P^2 = mu / (2pi)^2 + // <=> a = ((mu * P^2) / (2pi^2))^(1/3) + // with a = semimajor axis + // P = period in seconds + // mu = G*M_earth + double period = std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion; + + const double pisq = glm::pi() * glm::pi(); + double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); + + // We need the semi major axis in km instead of m + return semiMajorAxis / 1000.0; + } + +double epochFromSubstring(const std::string& epochString) { + // The epochString is in the form: + // YYDDD.DDDDDDDD + // With YY being the last two years of the launch epoch, the first DDD the day + // of the year and the remaning a fractional part of the day + + // The main overview of this function: + // 1. Reconstruct the full year from the YY part + // 2. Calculate the number of seconds since the beginning of the year + // 2.a Get the number of full days since the beginning of the year + // 2.b If the year is a leap year, modify the number of days + // 3. Convert the number of days to a number of seconds + // 4. Get the number of leap seconds since January 1st, 2000 and remove them + // 5. Adjust for the fact the epoch starts on 1st Januaray at 12:00:00, not + // midnight + + // According to https://celestrak.com/columns/v04n03/ + // Apparently, US Space Command sees no need to change the two-line element + // set format yet since no artificial earth satellites existed prior to 1957. + // By their reasoning, two-digit years from 57-99 correspond to 1957-1999 and + // those from 00-56 correspond to 2000-2056. We'll see each other again in 2057! + + // 1. Get the full year + std::string yearPrefix = [y = epochString.substr(0, 2)](){ + int year = std::atoi(y.c_str()); + return year >= 57 ? "19" : "20"; + }(); + const int year = std::atoi((yearPrefix + epochString.substr(0, 2)).c_str()); + const int daysSince2000 = countDays(year); + + // 2. + // 2.a + double daysInYear = std::atof(epochString.substr(2).c_str()); + + // 2.b + const bool isInLeapYear = std::find( + LeapYears.begin(), + LeapYears.end(), + year + ) != LeapYears.end(); + if (isInLeapYear && daysInYear >= 60) { + // We are in a leap year, so we have an effective day more if we are + // beyond the end of february (= 31+29 days) + --daysInYear; + } + + // 3 + using namespace std::chrono; + const int SecondsPerDay = static_cast(seconds(hours(24)).count()); + //Need to subtract 1 from daysInYear since it is not a zero-based count + const double nSecondsSince2000 = (daysSince2000 + daysInYear - 1) * SecondsPerDay; + + // 4 + // We need to remove additional leap seconds past 2000 and add them prior to + // 2000 to sync up the time zones + const double nLeapSecondsOffset = -countLeapSeconds( + year, + static_cast(std::floor(daysInYear)) + ); + + // 5 + const double nSecondsEpochOffset = static_cast( + seconds(hours(12)).count() + ); + + // Combine all of the values + const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; + return epoch; + } + +documentation::Documentation RenderableOrbitalKepler::Documentation() { + using namespace documentation; + return { + "RenderableOrbitalKepler", + "space_renderable_keplerian_orbitals", + { + { + SegmentsInfo.identifier, + new DoubleVerifier, + Optional::No, + SegmentsInfo.description + }, + { + PathInfo.identifier, + new StringVerifier, + Optional::No, + PathInfo.description + }, + { + LineWidthInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LineWidthInfo.description + }, + { + LineColorInfo.identifier, + new DoubleVector3Verifier, + Optional::No, + LineColorInfo.description + } + } + }; +} + +RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictionary) + : Renderable(dictionary) + , _path(PathInfo) + , _nSegments(SegmentsInfo, 120, 4, 1024) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "RenderableOrbitalKepler" + ); + + _path = dictionary.value(PathInfo.identifier); + _nSegments = static_cast(dictionary.value(SegmentsInfo.identifier)); + + if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { + _appearance.lineColor = dictionary.value(LineColorInfo.identifier); + } + if (dictionary.hasKeyAndValue(TrailFadeInfo.identifier)) { + _appearance.lineFade = static_cast( + dictionary.value(TrailFadeInfo.identifier) + ); + } + else { + _appearance.lineFade = 20; + } + + if (dictionary.hasKeyAndValue(UpperLimitInfo.identifier)) { + _upperLimit = static_cast( + dictionary.value(UpperLimitInfo.identifier) + ); + } + else { + _upperLimit = 0; + } + + if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { + _appearance.lineWidth = static_cast( + dictionary.value(LineWidthInfo.identifier) + ); + } + else { + _appearance.lineWidth = 2.0; + } + + auto reinitializeTrailBuffers = [this]() { + initializeGL(); + }; + + _path.onChange(reinitializeTrailBuffers); + _nSegments.onChange(reinitializeTrailBuffers); + _upperLimit.onChange(reinitializeTrailBuffers); + + addPropertySubOwner(_appearance); + addProperty(_path); + addProperty(_nSegments); + addProperty(_opacity); + addProperty(_upperLimit); + + setRenderBin(Renderable::RenderBin::Overlay); +} + +void RenderableOrbitalKepler::initializeGL() { + glGenVertexArrays(1, &_vertexArray); + glGenBuffers(1, &_vertexBuffer); + + _programObject = SpaceModule::ProgramObjectManager.request( + ProgramName, + []() -> std::unique_ptr { + return global::renderEngine.buildRenderProgram( + ProgramName, + absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl") + ); + } + ); + + _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform"); + _uniformCache.projection = _programObject->uniformLocation("projectionTransform"); + _uniformCache.lineFade = _programObject->uniformLocation("lineFade"); + _uniformCache.inGameTime = _programObject->uniformLocation("inGameTime"); + _uniformCache.color = _programObject->uniformLocation("color"); + _uniformCache.opacity = _programObject->uniformLocation("opacity"); + + updateBuffers(); +} + +void RenderableOrbitalKepler::deinitializeGL() { + glDeleteBuffers(1, &_vertexBuffer); + glDeleteVertexArrays(1, &_vertexArray); + + SpaceModule::ProgramObjectManager.release( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + global::renderEngine.removeRenderProgram(p); + } + ); + _programObject = nullptr; +} + +bool RenderableOrbitalKepler::isReady() const { + return _programObject != nullptr; +} + +void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { + if (_data.empty()) + return; + + _programObject->activate(); + _programObject->setUniform(_uniformCache.opacity, _opacity); + _programObject->setUniform(_uniformCache.inGameTime, data.time.j2000Seconds()); + + + glm::dmat4 modelTransform = + glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * + glm::dmat4(data.modelTransform.rotation) * + glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); + + _programObject->setUniform( + _uniformCache.modelView, + data.camera.combinedViewMatrix() * modelTransform + ); + + // Because we want the property to work similar to the planet trails + float fade = static_cast(pow(_appearance.lineFade.maxValue() - _appearance.lineFade, 2.0)); + + _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix()); + _programObject->setUniform(_uniformCache.color, _appearance.lineColor); + _programObject->setUniform(_uniformCache.lineFade, fade); + + glLineWidth(_appearance.lineWidth); + + const size_t nrOrbits = _data.size(); + gl::GLint vertices = 0; + + //glDepthMask(false); + //glBlendFunc(GL_SRC_ALPHA, GL_ONE) + + glBindVertexArray(_vertexArray); + for (size_t i = 0; i < nrOrbits; ++i) { + glDrawArrays(GL_LINE_STRIP, vertices, _nSegments + 1); + vertices = vertices + _nSegments + 1; + } + glBindVertexArray(0); + + _programObject->deactivate(); + +} + +void RenderableOrbitalKepler::updateBuffers() { + readDataFile(_path); + + const size_t nVerticesPerOrbit = _nSegments + 1; + _vertexBufferData.resize(_data.size() * nVerticesPerOrbit); + size_t orbitindex = 0; + + for (const auto& orbit : _data) { + _keplerTranslator.setKeplerElements( + orbit.eccentricity, + orbit.semiMajorAxis, + orbit.inclination, + orbit.ascendingNode, + orbit.argumentOfPeriapsis, + orbit.meanAnomaly, + orbit.period, + orbit.epoch + ); + + for (size_t i=0 ; i < nVerticesPerOrbit; ++i) { + size_t index = orbitindex * nVerticesPerOrbit + i; + + double timeOffset = orbit.period * + static_cast(i)/ static_cast(_nSegments); + + glm::dvec3 position = _keplerTranslator.position({ + {}, + Time(timeOffset + orbit.epoch), + Time(0.0), + false + }); + + double positionX = position.x; + double positionY = position.y; + double positionZ = position.z; + + _vertexBufferData[index].x = static_cast(positionX); + _vertexBufferData[index].y = static_cast(positionY); + _vertexBufferData[index].z = static_cast(positionZ); + _vertexBufferData[index].time = static_cast(timeOffset); + _vertexBufferData[index].epoch = orbit.epoch; + _vertexBufferData[index].period = orbit.period; + } + + ++orbitindex; + } + + glBindVertexArray(_vertexArray); + + glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); + glBufferData( + GL_ARRAY_BUFFER, + _vertexBufferData.size() * sizeof(TrailVBOLayout), + _vertexBufferData.data(), + GL_STATIC_DRAW + ); + + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr); + + glEnableVertexAttribArray(1); + glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4 * sizeof(GL_FLOAT))); + + + glBindVertexArray(0); + +} + +} diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h new file mode 100644 index 0000000000..b1c36ea7fd --- /dev/null +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -0,0 +1,138 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_SPACE___RENDERABLEORBITALKEPLER___H__ +#define __OPENSPACE_MODULE_SPACE___RENDERABLEORBITALKEPLER___H__ + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace openspace { + +const std::vector LeapYears = { + 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, + 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, + 2044, 2048, 2052, 2056 +}; +int countDays(int year); +int countLeapSeconds(int year, int dayOfYear); +double calculateSemiMajorAxis(double meanMotion); +double epochFromSubstring(const std::string& epochString); + +class RenderableOrbitalKepler : public Renderable { +public: + RenderableOrbitalKepler(const ghoul::Dictionary& dictionary); + + void initializeGL() override; + void deinitializeGL() override; + + bool isReady() const override; + void render(const RenderData& data, RendererTasks& rendererTask) override; + + static documentation::Documentation Documentation(); + /** + * Reads the provided data file and calls the KeplerTranslation::setKeplerElments + * method with the correct values. If \p filename is a valid data file but contains + * disallowed values (see KeplerTranslation::setKeplerElements), a + * KeplerTranslation::RangeError is thrown. + * + * \param filename The path to the file that contains the data file. + * + * \throw ghoul::RuntimeError if the data file does not exist or there is a + * problem with its format. + * \pre The \p filename must exist + */ + virtual void readDataFile(const std::string& filename) = 0; + +private: + struct Vertex { + glm::vec3 position = glm::vec3(0.f); + glm::vec3 color = glm::vec3(0.f); + glm::vec2 texcoord = glm::vec2(0.f); + }; + + struct KeplerParameters { + double inclination = 0.0; + double semiMajorAxis = 0.0; + double ascendingNode = 0.0; + double eccentricity = 0.0; + double argumentOfPeriapsis = 0.0; + double meanAnomaly = 0.0; + double meanMotion = 0.0; + double epoch = 0.0; + double period = 0.0; + }; + + /// The layout of the VBOs + struct TrailVBOLayout { + float x = 0.f; + float y = 0.f; + float z = 0.f; + float time = 0.f; + double epoch = 0.0; + double period = 0.0; + }; + + KeplerTranslation _keplerTranslator; + std::vector _data; + + /// The backend storage for the vertex buffer object containing all points for this + /// trail. + std::vector _vertexBufferData; + + GLuint _vertexArray; + GLuint _vertexBuffer; + GLuint _indexBuffer; + + //GLuint _vaoTest; // vertexArrayObject + //GLuint _vboTest; // vertextBufferObject + //GLuint _eboTest; // elementBufferObject/ indexBufferObject + + void updateBuffers(); + + ghoul::opengl::ProgramObject* _programObject; + + properties::StringProperty _path; + properties::UIntProperty _nSegments; + properties::UIntProperty _upperLimit; + + RenderableTrail::Appearance _appearance; + + glm::vec3 _position = glm::vec3(0.f); + + UniformCache(modelView, projection, lineFade, inGameTime, color, opacity, + numberOfSegments) _uniformCache; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_SPACE___RENDERABLEORBITALKEPLER___H__ + diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index a2e34ac2ba..62f80ed4bd 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -53,220 +53,10 @@ namespace { "Path", "The file path to the TLE file to read" }; - - static const openspace::properties::Property::PropertyInfo SegmentsInfo = { - "Segments", - "Segments", - "The number of segments to use for each orbit ellipse" - }; - constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { - "LineWidth", - "Line Width", - "This value specifies the line width of the trail if the selected rendering " - "method includes lines. If the rendering mode is set to Points, this value is " - "ignored." - }; - constexpr openspace::properties::Property::PropertyInfo LineColorInfo = { - "Color", - "Color", - "This value determines the RGB main color for the lines and points of the trail." - }; - constexpr openspace::properties::Property::PropertyInfo TrailFadeInfo = { - "TrailFade", - "Trail Fade", - "This value determines how fast the trail fades and is an appearance property. " - }; - - constexpr const char* KeyFile = "Path"; - constexpr const char* KeyLineNum = "LineNumber"; } namespace openspace { - // Count the number of full days since the beginning of 2000 to the beginning of - // the parameter 'year' - int countDays(int year) { - // Find the position of the current year in the vector, the difference - // between its position and the position of 2000 (for J2000) gives the - // number of leap years - constexpr const int Epoch = 2000; - constexpr const int DaysRegularYear = 365; - constexpr const int DaysLeapYear = 366; - - if (year == Epoch) { - return 0; - } - - // Get the position of the most recent leap year - const auto lb = std::lower_bound(LeapYears.begin(), LeapYears.end(), year); - - // Get the position of the epoch - const auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); - - // The distance between the two iterators gives us the number of leap years - const int nLeapYears = static_cast(std::abs(std::distance(y2000, lb))); - - const int nYears = std::abs(year - Epoch); - const int nRegularYears = nYears - nLeapYears; - - // Get the total number of days as the sum of leap years + non leap years - const int result = nRegularYears * DaysRegularYear + nLeapYears * DaysLeapYear; - return result; - } - - // Returns the number of leap seconds that lie between the {year, dayOfYear} - // time point and { 2000, 1 } - int countLeapSeconds(int year, int dayOfYear) { - // Find the position of the current year in the vector; its position in - // the vector gives the number of leap seconds - struct LeapSecond { - int year; - int dayOfYear; - bool operator<(const LeapSecond& rhs) const { - return std::tie(year, dayOfYear) < std::tie(rhs.year, rhs.dayOfYear); - } - }; - - const LeapSecond Epoch = { 2000, 1 }; - - // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list - static const std::vector LeapSeconds = { - { 1972, 1 }, - { 1972, 183 }, - { 1973, 1 }, - { 1974, 1 }, - { 1975, 1 }, - { 1976, 1 }, - { 1977, 1 }, - { 1978, 1 }, - { 1979, 1 }, - { 1980, 1 }, - { 1981, 182 }, - { 1982, 182 }, - { 1983, 182 }, - { 1985, 182 }, - { 1988, 1 }, - { 1990, 1 }, - { 1991, 1 }, - { 1992, 183 }, - { 1993, 182 }, - { 1994, 182 }, - { 1996, 1 }, - { 1997, 182 }, - { 1999, 1 }, - { 2006, 1 }, - { 2009, 1 }, - { 2012, 183 }, - { 2015, 182 }, - { 2017, 1 } - }; - - // Get the position of the last leap second before the desired date - LeapSecond date { year, dayOfYear }; - const auto it = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), date); - - // Get the position of the Epoch - const auto y2000 = std::lower_bound( - LeapSeconds.begin(), - LeapSeconds.end(), - Epoch - ); - - // The distance between the two iterators gives us the number of leap years - const int nLeapSeconds = static_cast(std::abs(std::distance(y2000, it))); - return nLeapSeconds; - } - - double calculateSemiMajorAxis(double meanMotion) { - constexpr const double GravitationalConstant = 6.6740831e-11; - constexpr const double MassEarth = 5.9721986e24; - constexpr const double muEarth = GravitationalConstant * MassEarth; - - // Use Kepler's 3rd law to calculate semimajor axis - // a^3 / P^2 = mu / (2pi)^2 - // <=> a = ((mu * P^2) / (2pi^2))^(1/3) - // with a = semimajor axis - // P = period in seconds - // mu = G*M_earth - double period = std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion; - - const double pisq = glm::pi() * glm::pi(); - double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); - - // We need the semi major axis in km instead of m - return semiMajorAxis / 1000.0; - } - -double epochFromSubstring(const std::string& epochString) { - // The epochString is in the form: - // YYDDD.DDDDDDDD - // With YY being the last two years of the launch epoch, the first DDD the day - // of the year and the remaning a fractional part of the day - - // The main overview of this function: - // 1. Reconstruct the full year from the YY part - // 2. Calculate the number of seconds since the beginning of the year - // 2.a Get the number of full days since the beginning of the year - // 2.b If the year is a leap year, modify the number of days - // 3. Convert the number of days to a number of seconds - // 4. Get the number of leap seconds since January 1st, 2000 and remove them - // 5. Adjust for the fact the epoch starts on 1st Januaray at 12:00:00, not - // midnight - - // According to https://celestrak.com/columns/v04n03/ - // Apparently, US Space Command sees no need to change the two-line element - // set format yet since no artificial earth satellites existed prior to 1957. - // By their reasoning, two-digit years from 57-99 correspond to 1957-1999 and - // those from 00-56 correspond to 2000-2056. We'll see each other again in 2057! - - // 1. Get the full year - std::string yearPrefix = [y = epochString.substr(0, 2)](){ - int year = std::atoi(y.c_str()); - return year >= 57 ? "19" : "20"; - }(); - const int year = std::atoi((yearPrefix + epochString.substr(0, 2)).c_str()); - const int daysSince2000 = countDays(year); - - // 2. - // 2.a - double daysInYear = std::atof(epochString.substr(2).c_str()); - - // 2.b - const bool isInLeapYear = std::find( - LeapYears.begin(), - LeapYears.end(), - year - ) != LeapYears.end(); - if (isInLeapYear && daysInYear >= 60) { - // We are in a leap year, so we have an effective day more if we are - // beyond the end of february (= 31+29 days) - --daysInYear; - } - - // 3 - using namespace std::chrono; - const int SecondsPerDay = static_cast(seconds(hours(24)).count()); - //Need to subtract 1 from daysInYear since it is not a zero-based count - const double nSecondsSince2000 = (daysSince2000 + daysInYear - 1) * SecondsPerDay; - - // 4 - // We need to remove additional leap seconds past 2000 and add them prior to - // 2000 to sync up the time zones - const double nLeapSecondsOffset = -countLeapSeconds( - year, - static_cast(std::floor(daysInYear)) - ); - - // 5 - const double nSecondsEpochOffset = static_cast( - seconds(hours(12)).count() - ); - - // Combine all of the values - const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; - return epoch; - } - documentation::Documentation RenderableSatellites::Documentation() { using namespace documentation; return { @@ -302,57 +92,17 @@ documentation::Documentation RenderableSatellites::Documentation() { } RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) - : Renderable(dictionary) - , _path(PathInfo) - , _nSegments(SegmentsInfo, 120, 4, 1024) + : RenderableOrbitalKepler(dictionary) { documentation::testSpecificationAndThrow( Documentation(), dictionary, "RenderableSatellites" ); - - _path = dictionary.value(PathInfo.identifier); - _nSegments = static_cast(dictionary.value(SegmentsInfo.identifier)); - - if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { - _appearance.lineColor = dictionary.value(LineColorInfo.identifier); - } - if (dictionary.hasKeyAndValue(TrailFadeInfo.identifier)) { - _appearance.lineFade = static_cast( - dictionary.value(TrailFadeInfo.identifier) - ); - } - else { - _appearance.lineFade = 20; - } - - if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { - _appearance.lineWidth = static_cast( - dictionary.value(LineWidthInfo.identifier) - ); - } - else { - _appearance.lineWidth = 2.0; - } - - auto reinitializeTrailBuffers = [this]() { - initializeGL(); - }; - - _path.onChange(reinitializeTrailBuffers); - _nSegments.onChange(reinitializeTrailBuffers); - - addPropertySubOwner(_appearance); - addProperty(_path); - addProperty(_nSegments); - addProperty(_opacity); - - setRenderBin(Renderable::RenderBin::Overlay); } -void RenderableSatellites::readTLEFile(const std::string& filename) { +void RenderableSatellites::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { throw ghoul::RuntimeError(fmt::format( "Satellite TLE file {} does not exist.", filename @@ -462,165 +212,10 @@ void RenderableSatellites::readTLEFile(const std::string& filename) { double period = seconds(hours(24)).count() / keplerElements.meanMotion; keplerElements.period = period; - _TLEData.push_back(keplerElements); + _data.push_back(keplerElements); } file.close(); } - -void RenderableSatellites::initializeGL() { - glGenVertexArrays(1, &_vertexArray); - glGenBuffers(1, &_vertexBuffer); - - _programObject = SpaceModule::ProgramObjectManager.request( - ProgramName, - []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( - ProgramName, - absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"), - absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl") - ); - } - ); - - _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform"); - _uniformCache.projection = _programObject->uniformLocation("projectionTransform"); - _uniformCache.lineFade = _programObject->uniformLocation("lineFade"); - _uniformCache.inGameTime = _programObject->uniformLocation("inGameTime"); - _uniformCache.color = _programObject->uniformLocation("color"); - _uniformCache.opacity = _programObject->uniformLocation("opacity"); - - updateBuffers(); -} - -void RenderableSatellites::deinitializeGL() { - glDeleteBuffers(1, &_vertexBuffer); - glDeleteVertexArrays(1, &_vertexArray); - - SpaceModule::ProgramObjectManager.release( - ProgramName, - [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); - } - ); - _programObject = nullptr; -} - -bool RenderableSatellites::isReady() const { - return _programObject != nullptr; -} - -void RenderableSatellites::render(const RenderData& data, RendererTasks&) { - if (_TLEData.empty()) - return; - - _programObject->activate(); - _programObject->setUniform(_uniformCache.opacity, _opacity); - _programObject->setUniform(_uniformCache.inGameTime, data.time.j2000Seconds()); - - - glm::dmat4 modelTransform = - glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * - glm::dmat4(data.modelTransform.rotation) * - glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - - _programObject->setUniform( - _uniformCache.modelView, - data.camera.combinedViewMatrix() * modelTransform - ); - - // Because we want the property to work similar to the planet trails - float fade = static_cast(pow(_appearance.lineFade.maxValue() - _appearance.lineFade, 2.0)); - - _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix()); - _programObject->setUniform(_uniformCache.color, _appearance.lineColor); - _programObject->setUniform(_uniformCache.lineFade, fade); - - glLineWidth(_appearance.lineWidth); - - const size_t nrOrbits = _TLEData.size(); - gl::GLint vertices = 0; - - //glDepthMask(false); - //glBlendFunc(GL_SRC_ALPHA, GL_ONE) - - glBindVertexArray(_vertexArray); - for (size_t i = 0; i < nrOrbits; ++i) { - glDrawArrays(GL_LINE_STRIP, vertices, _nSegments + 1); - vertices = vertices + _nSegments + 1; - } - glBindVertexArray(0); - - _programObject->deactivate(); - -} - -void RenderableSatellites::updateBuffers() { - readTLEFile(_path); - - const size_t nVerticesPerOrbit = _nSegments + 1; - _vertexBufferData.resize(_TLEData.size() * nVerticesPerOrbit); - size_t orbitindex = 0; - - for (const auto& orbit : _TLEData) { - _keplerTranslator.setKeplerElements( - orbit.eccentricity, - orbit.semiMajorAxis, - orbit.inclination, - orbit.ascendingNode, - orbit.argumentOfPeriapsis, - orbit.meanAnomaly, - orbit.period, - orbit.epoch - ); - - for (size_t i=0 ; i < nVerticesPerOrbit; ++i) { - size_t index = orbitindex * nVerticesPerOrbit + i; - - double timeOffset = orbit.period * - static_cast(i)/ static_cast(_nSegments); - - glm::dvec3 position = _keplerTranslator.position({ - {}, - Time(timeOffset + orbit.epoch), - Time(0.0), - false - }); - - double positionX = position.x; - double positionY = position.y; - double positionZ = position.z; - - _vertexBufferData[index].x = static_cast(positionX); - _vertexBufferData[index].y = static_cast(positionY); - _vertexBufferData[index].z = static_cast(positionZ); - _vertexBufferData[index].time = static_cast(timeOffset); - _vertexBufferData[index].epoch = orbit.epoch; - _vertexBufferData[index].period = orbit.period; - } - - ++orbitindex; - } - - glBindVertexArray(_vertexArray); - - glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); - glBufferData( - GL_ARRAY_BUFFER, - _vertexBufferData.size() * sizeof(TrailVBOLayout), - _vertexBufferData.data(), - GL_STATIC_DRAW - ); - - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr); - - glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4 * sizeof(GL_FLOAT))); - - - glBindVertexArray(0); - -} } diff --git a/modules/space/rendering/renderablesatellites.h b/modules/space/rendering/renderablesatellites.h index 9043c4ab46..05cf7b7498 100644 --- a/modules/space/rendering/renderablesatellites.h +++ b/modules/space/rendering/renderablesatellites.h @@ -25,6 +25,7 @@ #ifndef __OPENSPACE_MODULE_SPACE___RENDERABLESATELLITES___H__ #define __OPENSPACE_MODULE_SPACE___RENDERABLESATELLITES___H__ +#include #include #include @@ -37,98 +38,13 @@ namespace openspace { -const std::vector LeapYears = { - 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, - 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, - 2044, 2048, 2052, 2056 -}; -int countDays(int year); -int countLeapSeconds(int year, int dayOfYear); -double calculateSemiMajorAxis(double meanMotion); -double epochFromSubstring(const std::string& epochString); - -class RenderableSatellites : public Renderable { +class RenderableSatellites : private RenderableOrbitalKepler { public: RenderableSatellites(const ghoul::Dictionary& dictionary); - - void initializeGL() override; - void deinitializeGL() override; - - bool isReady() const override; - void render(const RenderData& data, RendererTasks& rendererTask) override; - static documentation::Documentation Documentation(); - /** - * Reads the provided TLE file and calls the KeplerTranslation::setKeplerElments - * method with the correct values. If \p filename is a valid TLE file but contains - * disallowed values (see KeplerTranslation::setKeplerElements), a - * KeplerTranslation::RangeError is thrown. - * - * \param filename The path to the file that contains the TLE file. - * - * \throw ghoul::RuntimeError if the TLE file does not exist or there is a - * problem with its format. - * \pre The \p filename must exist - */ - void readTLEFile(const std::string& filename); private: - struct Vertex { - glm::vec3 position = glm::vec3(0.f); - glm::vec3 color = glm::vec3(0.f); - glm::vec2 texcoord = glm::vec2(0.f); - }; - struct KeplerParameters { - double inclination = 0.0; - double semiMajorAxis = 0.0; - double ascendingNode = 0.0; - double eccentricity = 0.0; - double argumentOfPeriapsis = 0.0; - double meanAnomaly = 0.0; - double meanMotion = 0.0; - double epoch = 0.0; - double period = 0.0; - }; - - /// The layout of the VBOs - struct TrailVBOLayout { - float x = 0.f; - float y = 0.f; - float z = 0.f; - float time = 0.f; - double epoch = 0.0; - double period = 0.0; - }; - - KeplerTranslation _keplerTranslator; - std::vector _TLEData; - - /// The backend storage for the vertex buffer object containing all points for this - /// trail. - std::vector _vertexBufferData; - - GLuint _vertexArray; - GLuint _vertexBuffer; - GLuint _indexBuffer; - - //GLuint _vaoTest; // vertexArrayObject - //GLuint _vboTest; // vertextBufferObject - //GLuint _eboTest; // elementBufferObject/ indexBufferObject - - void updateBuffers(); - - ghoul::opengl::ProgramObject* _programObject; - - properties::StringProperty _path; - properties::UIntProperty _nSegments; - - RenderableTrail::Appearance _appearance; - - glm::vec3 _position = glm::vec3(0.f); - - UniformCache(modelView, projection, lineFade, inGameTime, color, opacity, - numberOfSegments) _uniformCache; }; } // namespace openspace diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 9757bac9d6..abfef75e47 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -54,138 +54,10 @@ namespace { "Path", "The file path to the SBDB file to read" }; - - static const openspace::properties::Property::PropertyInfo SegmentsInfo = { - "Segments", - "Segments", - "The number of segments to use for each orbit ellipse" - }; - static const openspace::properties::Property::PropertyInfo UpperLimitInfo = { - "UpperLimit", - "Upper Limit", - "Upper limit on the number of objects for this renderable, regardless of " - "how many objects are contained in the data file" - }; - constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { - "LineWidth", - "Line Width", - "This value specifies the line width of the trail if the selected rendering " - "method includes lines. If the rendering mode is set to Points, this value is " - "ignored." - }; - constexpr openspace::properties::Property::PropertyInfo FadeInfo = { - "Fade", - "Line fade", - "The fading factor that is applied to the trail if the 'EnableFade' value is " - "'true'. If it is 'false', this setting has no effect. The higher the number, " - "the less fading is applied." - }; - constexpr openspace::properties::Property::PropertyInfo LineColorInfo = { - "Color", - "Color", - "This value determines the RGB main color for the lines and points of the trail." - }; - - constexpr const char* KeyFile = "Path"; - constexpr const char* KeyLineNum = "LineNumber"; } namespace openspace { -const std::vector DaysOfMonths = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 -}; - -enum Months { - January = 0, - February, - March, - April, - May, - June, - July, - August, - September, - October, - November, - December -}; - -int daysIntoGivenYear(int month, int dayOfMonth) { - //month and dayCount are zero-based. Does NOT account for leap year. - month -= 1; - int dayCount = dayOfMonth - 1; - - for (int m = Months::January; m < month; ++m) { - dayCount += DaysOfMonths[m]; - } - return dayCount; -} - -double epochFromYMDdSubstring(const std::string& epochString) { - // The epochString is in the form: - // YYYYMMDD.ddddddd - // With YYYY as the year, MM the month (1 - 12), DD the day of month (1-31), - // and dddd the fraction of that day. - - // The main overview of this function: - // 1. Read the year value - // 2. Calculate the number of seconds since the beginning of the year - // 2.a Get the number of full days since the beginning of the year - // 2.b If the year is a leap year, modify the number of days - // 3. Convert the number of days to a number of seconds - // 4. Get the number of leap seconds since January 1st, 2000 and remove them - // 5. Adjust for the fact the epoch starts on 1st January at 12:00:00, not - // midnight - - // 1 - int year = std::atoi(epochString.substr(0, 4).c_str()); - const int daysSince2000 = countDays(year); - - // 2. - // 2.a - int monthNum = std::atoi(epochString.substr(4, 2).c_str()); - int dayOfMonthNum = std::atoi(epochString.substr(6, 2).c_str()); - int wholeDaysInto = daysIntoGivenYear(monthNum, dayOfMonthNum); - double fractionOfDay = std::atof(epochString.substr(9, 7).c_str()); - double daysInYear = static_cast(wholeDaysInto) + fractionOfDay; - - // 2.b - const bool isInLeapYear = std::find( - LeapYears.begin(), - LeapYears.end(), - year - ) != LeapYears.end(); - if (isInLeapYear && daysInYear >= 60) { - // We are in a leap year, so we have an effective day more if we are - // beyond the end of february (= 31+29 days) - --daysInYear; - } - - // 3 - using namespace std::chrono; - const int SecondsPerDay = static_cast(seconds(hours(24)).count()); - //Need to subtract 1 from daysInYear since it is not a zero-based count - const double nSecondsSince2000 = (daysSince2000 + daysInYear - 1) * SecondsPerDay; - - // 4 - // We need to remove additional leap seconds past 2000 and add them prior to - // 2000 to sync up the time zones - const double nLeapSecondsOffset = -countLeapSeconds( - year, - static_cast(std::floor(daysInYear)) - ); - - // 5 - const double nSecondsEpochOffset = static_cast( - seconds(hours(12)).count() - ); - - // Combine all of the values - const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; - return epoch; -} - documentation::Documentation RenderableSmallBody::Documentation() { using namespace documentation; return { @@ -233,71 +105,17 @@ documentation::Documentation RenderableSmallBody::Documentation() { } RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) - : Renderable(dictionary) - , _path(PathInfo) - , _nSegments(SegmentsInfo, 100, 10, 4000) - , _upperLimit(UpperLimitInfo, 1000, 1, 1000000) + : RenderableOrbitalKepler(dictionary) { documentation::testSpecificationAndThrow( Documentation(), dictionary, "RenderableSmallBody" ); - - _path = dictionary.value(PathInfo.identifier); - _nSegments = static_cast( - dictionary.value(SegmentsInfo.identifier) - ); - - if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { - _appearance.lineColor = dictionary.value(LineColorInfo.identifier); - } - if (dictionary.hasKeyAndValue(FadeInfo.identifier)) { - _appearance.lineFade = static_cast( - dictionary.value(FadeInfo.identifier) - ); - } - else { - _appearance.lineFade = 20; - } - - if (dictionary.hasKeyAndValue(UpperLimitInfo.identifier)) { - _upperLimit = static_cast( - dictionary.value(UpperLimitInfo.identifier) - ); - } - else { - _upperLimit = 0; - } - - if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { - _appearance.lineWidth = static_cast( - dictionary.value(LineWidthInfo.identifier) - ); - } - else { - _appearance.lineWidth = 2.0; - } - - auto reinitializeTrailBuffers = [this]() { - initializeGL(); - }; - - _path.onChange(reinitializeTrailBuffers); - _nSegments.onChange(reinitializeTrailBuffers); - _upperLimit.onChange(reinitializeTrailBuffers); - - addPropertySubOwner(_appearance); - addProperty(_path); - addProperty(_nSegments); - addProperty(_opacity); - addProperty(_upperLimit); - - setRenderBin(Renderable::RenderBin::Overlay); } -void RenderableSmallBody::readJplSbDb(const std::string& filename) { +void RenderableSmallBody::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { throw ghoul::RuntimeError(fmt::format( "JPL SBDB file {} does not exist.", filename @@ -311,7 +129,7 @@ void RenderableSmallBody::readJplSbDb(const std::string& filename) { std::streamoff numberOfLines = std::count(std::istreambuf_iterator(file), std::istreambuf_iterator(), '\n' ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file - _sbData.clear(); + _data.clear(); _sbNames.clear(); std::string line; @@ -461,7 +279,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, keplerElements.period *= convertDaysToSecs; fieldCount++; - _sbData.push_back(keplerElements); + _data.push_back(keplerElements); _sbNames.push_back(name); } @@ -473,158 +291,5 @@ static double importAngleValue(const std::string& angle) { } return output; } - -void RenderableSmallBody::initializeGL() { - glGenVertexArrays(1, &_vertexArray); - glGenBuffers(1, &_vertexBuffer); - - _programObject = SpaceModule::ProgramObjectManager.request( - ProgramName, - []() -> std::unique_ptr { - return global::renderEngine.buildRenderProgram( - ProgramName, - absPath("${MODULE_SPACE}/shaders/debrisViz_vs.glsl"), - absPath("${MODULE_SPACE}/shaders/debrisViz_fs.glsl") - ); - } - ); - - _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform"); - _uniformCache.projection = _programObject->uniformLocation("projectionTransform"); - _uniformCache.lineFade = _programObject->uniformLocation("lineFade"); - _uniformCache.inGameTime = _programObject->uniformLocation("inGameTime"); - _uniformCache.color = _programObject->uniformLocation("color"); - _uniformCache.opacity = _programObject->uniformLocation("opacity"); - - updateBuffers(); - setRenderBin(Renderable::RenderBin::Overlay); -} - -void RenderableSmallBody::deinitializeGL() { - glDeleteBuffers(1, &_vertexBuffer); - glDeleteVertexArrays(1, &_vertexArray); - - SpaceModule::ProgramObjectManager.release( - ProgramName, - [](ghoul::opengl::ProgramObject* p) { - global::renderEngine.removeRenderProgram(p); - } - ); - _programObject = nullptr; -} - -bool RenderableSmallBody::isReady() const { - return _programObject != nullptr; -} - -void RenderableSmallBody::render(const RenderData& data, RendererTasks&) { - if (_sbData.empty()) - return; - - _programObject->activate(); - _programObject->setUniform(_uniformCache.opacity, _opacity); - _programObject->setUniform(_uniformCache.inGameTime, data.time.j2000Seconds()); - - - glm::dmat4 modelTransform = - glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * - glm::dmat4(data.modelTransform.rotation) * - glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - - _programObject->setUniform( - _uniformCache.modelView, - data.camera.combinedViewMatrix() * modelTransform - ); - // Because we want the property to work similar to the planet trails - float fade = static_cast(pow(_appearance.lineFade.maxValue() - _appearance.lineFade, 2.0)); - - _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix()); - _programObject->setUniform(_uniformCache.color, _appearance.lineColor); - _programObject->setUniform(_uniformCache.lineFade, fade); - - glLineWidth(_appearance.lineWidth); - - const size_t nrOrbits = _sbData.size(); - gl::GLint vertices = 0; - - //glDepthMask(false); - //glBlendFunc(GL_SRC_ALPHA, GL_ONE) - - glBindVertexArray(_vertexArray); - for (size_t i = 0; i < nrOrbits; ++i) { - glDrawArrays(GL_LINE_STRIP, vertices, _nSegments + 1); - vertices = vertices + _nSegments + 1; - } - glBindVertexArray(0); - - _programObject->deactivate(); - -} - -void RenderableSmallBody::updateBuffers() { - readJplSbDb(_path); - - const size_t nVerticesPerOrbit = _nSegments + 1; - _vertexBufferData.resize(_sbData.size() * nVerticesPerOrbit); - size_t orbitindex = 0; - - for (const auto& orbit : _sbData) { - _keplerTranslator.setKeplerElements( - orbit.eccentricity, - orbit.semiMajorAxis, - orbit.inclination, - orbit.ascendingNode, - orbit.argumentOfPeriapsis, - orbit.meanAnomaly, - orbit.period, - orbit.epoch - ); - - for (size_t i=0 ; i < nVerticesPerOrbit; ++i) { - size_t index = orbitindex * nVerticesPerOrbit + i; - - double timeOffset = orbit.period * - static_cast(i)/ static_cast(_nSegments); - - glm::dvec3 position = _keplerTranslator.position({ - {}, - Time(timeOffset + orbit.epoch), - Time(0.0), - false - }); - - double positionX = position.x; - double positionY = position.y; - double positionZ = position.z; - - _vertexBufferData[index].x = static_cast(positionX); - _vertexBufferData[index].y = static_cast(positionY); - _vertexBufferData[index].z = static_cast(positionZ); - _vertexBufferData[index].time = static_cast(timeOffset); - _vertexBufferData[index].epoch = orbit.epoch; - _vertexBufferData[index].period = orbit.period; - } - - ++orbitindex; - } - - glBindVertexArray(_vertexArray); - - glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer); - glBufferData( - GL_ARRAY_BUFFER, - _vertexBufferData.size() * sizeof(TrailVBOLayout), - _vertexBufferData.data(), - GL_STATIC_DRAW - ); - - glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr); - - glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4*sizeof(GL_FLOAT)) ); - - glBindVertexArray(0); -} - + } diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index 531270ce09..5c9fa5b9f8 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -25,6 +25,7 @@ #ifndef __OPENSPACE_MODULE_SPACE___RENDERABLESMALLBODY___H__ #define __OPENSPACE_MODULE_SPACE___RENDERABLESMALLBODY___H__ +#include #include #include @@ -37,101 +38,27 @@ namespace openspace { -class RenderableSmallBody : public Renderable { +static double importAngleValue(const std::string& angle); + +class RenderableSmallBody : public RenderableOrbitalKepler { public: RenderableSmallBody(const ghoul::Dictionary& dictionary); - - void initializeGL() override; - void deinitializeGL() override; - - bool isReady() const override; - void render(const RenderData& data, RendererTasks& rendererTask) override; - static documentation::Documentation Documentation(); - /** - * Reads the provided file downloaded from the JPL Small Body Database and calls - * the KeplerTranslation::setKeplerElments method with the correct values. - * If \p filename is a valid JPL SBDB file but contains - * disallowed values (see KeplerTranslation::setKeplerElements), a - * KeplerTranslation::RangeError is thrown. - * - * \param filename The path to the file that contains the file. - * - * \throw ghoul::RuntimeError if the file does not exist or there is a - * problem with its format. - * \pre The \p filename must exist - */ - void readJplSbDb(const std::string& filename); private: - struct Vertex { - glm::vec3 position; - glm::vec3 color; - glm::vec2 texcoord; - }; - - struct KeplerParameters { - double inclination = 0.0; - double semiMajorAxis = 0.0; - double ascendingNode = 0.0; - double eccentricity = 0.0; - double argumentOfPeriapsis = 0.0; - double meanAnomaly = 0.0; - double meanMotion = 0.0; - double epoch = 0.0; - double period = 0.0; - }; - - /// The layout of the VBOs - struct TrailVBOLayout { - float x, y, z, time; - double epoch, period; - }; - void readOrbitalParamsFromThisLine(int& fieldCount, std::streamoff& csvLine, std::ifstream& file); - KeplerTranslation _keplerTranslator; - std::vector _sbData; std::vector _sbNames; - /// The backend storage for the vertex buffer object containing all points for this - /// trail. - std::vector _vertexBufferData; - /// The index array that is potentially used in the draw call. If this is empty, no /// element draw call is used. std::vector _indexBufferData; - GLuint _vertexArray; - GLuint _vertexBuffer; - GLuint _indexBuffer; - - //GLuint _vaoTest; // vertexArrayObject - //GLuint _vboTest; // vertextBufferObject - //GLuint _eboTest; // elementBufferObject/ indexBufferObject - - void updateBuffers(); - - ghoul::opengl::ProgramObject* _programObject; - - properties::StringProperty _path; - properties::UIntProperty _nSegments; - properties::UIntProperty _upperLimit; - - RenderableTrail::Appearance _appearance; - - glm::vec3 _position; - - UniformCache(modelView, projection, lineFade, inGameTime, color, opacity, - numberOfSegments) _uniformCache; - const double convertAuToKm = 1.496e8; const double convertDaysToSecs = 86400.; }; -static double importAngleValue(const std::string& angle); - } // namespace openspace #endif // __OPENSPACE_MODULE_SPACE___RENDERABLESMALLBODY___H__ From 4e9aae3f78292985e227109c3c25649ffb121238 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Tue, 10 Mar 2020 09:09:58 +0100 Subject: [PATCH 08/67] Read out timestamps from actual touchevent rather than doing it from the message pumping. This produces less scattered timestamps as we now get the timestamp from the touch monitor driver. --- modules/touch/src/win32_touch.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 9507b5ef8a..9796247790 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -46,6 +46,11 @@ namespace { HHOOK gMouseHook = nullptr; bool gStarted = false; std::chrono::microseconds gStartTime = std::chrono::microseconds(0); + const long long gFrequency = []() -> long long { + LARGE_INTEGER frequency; + QueryPerformanceFrequency(&frequency); + return frequency.QuadPart; + }(); std::unordered_map< UINT32, std::unique_ptr @@ -80,9 +85,9 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { } using namespace std::chrono; - const microseconds timestamp = duration_cast( - high_resolution_clock::now().time_since_epoch() - ) - gStartTime; + const microseconds timestamp = duration( + info.PerformanceCount * std::micro::den / gFrequency) - gStartTime; + RECT rect; GetClientRect(pStruct->hwnd, reinterpret_cast(&rect)); @@ -100,7 +105,7 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { static_cast(info.pointerId), xPos, yPos, - static_cast(timestamp.count())/1'000'000.0 + static_cast(timestamp.count()) / 1'000'000.0 ); if (info.pointerFlags & POINTER_FLAG_DOWN) { @@ -213,8 +218,10 @@ Win32TouchHook::Win32TouchHook(void* nativeWindow) if (!gStarted) { gStarted = true; - gStartTime = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now().time_since_epoch() + LARGE_INTEGER count; + QueryPerformanceCounter(&count); + gStartTime = std::chrono::duration( + count.QuadPart * std::micro::den / gFrequency ); #ifdef ENABLE_TUIOMESSAGES gTuioServer = new TUIO::TuioServer("localhost", 3333); From b9210a65fdf335abe16cc0415f0d30c7d2c04006 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Tue, 10 Mar 2020 09:52:30 +0100 Subject: [PATCH 09/67] Changed (and simplified) some internal logic of the touch class --- include/openspace/util/touch.h | 4 +++- src/util/touch.cpp | 29 ++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/openspace/util/touch.h b/include/openspace/util/touch.h index cb9a6e71da..a7f8500a93 100644 --- a/include/openspace/util/touch.h +++ b/include/openspace/util/touch.h @@ -46,7 +46,7 @@ struct TouchInput { float y; float dx = 0.f; // movement in x direction since last touch input float dy = 0.f; // movement in y direction since last touch input - double timestamp; // timestamp in seconds from global touch initialization + double timestamp; // timestamp in seconds from global touch initialization }; class TouchInputHolder { @@ -56,6 +56,7 @@ public: // tryAddInput: // Succeeds upon a different input than last. // Fails upon a too similar input as last. + // Updates time for the last input if same position. bool tryAddInput(TouchInput input); void clearInputs(); @@ -72,6 +73,7 @@ public: double gestureTime() const; size_t numInputs() const; + const TouchInput& firstInput() const; const TouchInput& latestInput() const; const std::deque& peekInputs() const; diff --git a/src/util/touch.cpp b/src/util/touch.cpp index aa0ef75ddd..d5381daa01 100644 --- a/src/util/touch.cpp +++ b/src/util/touch.cpp @@ -78,27 +78,35 @@ TouchInputHolder::TouchInputHolder(TouchInput input) {} bool TouchInputHolder::tryAddInput(TouchInput input) { + if(_inputs.empty()) { + _inputs.emplace_front(input); + return true; + } constexpr const double ONE_MS = 0.001; const TouchInput& lastInput = latestInput(); input.dx = input.x - lastInput.x; input.dy = input.y - lastInput.y; - const bool sameTimeAsLastInput = (input.timestamp - lastInput.timestamp) > ONE_MS; - bool wasInserted = false; - if (isMoving()) { + const bool sameTimeAsLastInput = (input.timestamp - lastInput.timestamp) < ONE_MS; + bool successful = false; + if (!sameTimeAsLastInput && isMoving()) { _inputs.emplace_front(input); - wasInserted = true; + successful = true; } - else if (sameTimeAsLastInput && input.isMoving()) { + else if (!sameTimeAsLastInput && input.isMoving()) { _inputs.emplace_front(input); - wasInserted = true; + successful = true; + } + else if (!sameTimeAsLastInput){ + _inputs.front().timestamp = input.timestamp; + successful = true; } constexpr const int MaxInputs = 128; if (_inputs.size() > MaxInputs) { _inputs.pop_back(); } - return wasInserted; + return successful; } void TouchInputHolder::clearInputs() { @@ -142,8 +150,7 @@ bool TouchInputHolder::isMoving() const { if (_inputs.size() <= 1) { return false; } - const TouchInput& currentInput = _inputs[0]; - return currentInput.dx != 0.f || currentInput.dy != 0.f; + return latestInput().isMoving(); } float TouchInputHolder::gestureDistance() const { @@ -174,6 +181,10 @@ size_t TouchInputHolder::numInputs() const { return _inputs.size(); } +const TouchInput& TouchInputHolder::firstInput() const { + return _inputs.back(); +} + const TouchInput& TouchInputHolder::latestInput() const { return _inputs.front(); } From a991a8052544b10f1810441465f9a1a47f665942 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Tue, 10 Mar 2020 09:57:07 +0100 Subject: [PATCH 10/67] Made pinch input default to continuous zoom - Added a directTouch bool field to touch step function - Some logic of how to gather accumulated zoom value --- modules/touch/include/touchinteraction.h | 6 +- modules/touch/src/touchinteraction.cpp | 106 +++++++++++++---------- modules/touch/touchmodule.cpp | 2 +- 3 files changed, 65 insertions(+), 49 deletions(-) diff --git a/modules/touch/include/touchinteraction.h b/modules/touch/include/touchinteraction.h index 8faed8bbfb..b4e89ffeb7 100644 --- a/modules/touch/include/touchinteraction.h +++ b/modules/touch/include/touchinteraction.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -96,7 +97,7 @@ public: std::vector& lastProcessed); // Calculates the new camera state with velocities and time since last frame - void step(double dt); + void step(double dt, bool directTouch = false); // Called each frame we have no new input, used to reset data void resetAfterInput(); @@ -202,7 +203,7 @@ private: double pinchConsecZoomFactor = 0; //int stepVelUpdate = 0; #endif - + std::array _pinchInputs; // Class variables VelocityStates _vel; VelocityStates _lastVel; @@ -242,4 +243,3 @@ private: } // openspace namespace #endif // __OPENSPACE_MODULE_TOUCH___TOUCH_INTERACTION___H__ - diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index b12795b9e6..31c6c44be5 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -307,6 +307,8 @@ TouchInteraction::TouchInteraction() { "Ignore GUI", "Disable GUI touch interaction", "" }, false ) + , _pinchInputs({ TouchInput(0x0, 0x0, 0.0, 0.0, 0.0), + TouchInput(0x0, 0x0, 0.0, 0.0, 0.0) }) , _vel{ glm::dvec2(0.0), 0.0, 0.0, glm::dvec2(0.0) } , _sensitivity{ glm::dvec2(0.08, 0.045), 12.0 /*4.0*/, 2.75, glm::dvec2(0.08, 0.045) } , _constTimeDecay_secs(ConstantTimeDecaySecsInfo, 1.75f, 0.1f, 4.0f) @@ -494,7 +496,7 @@ void TouchInteraction::directControl(const std::vector& list) _vel.pan = glm::dvec2(par.at(4), par.at(5)); } } - step(1.0); + step(1.0, true); // Reset velocities after setting new camera state _lastVel = _vel; @@ -777,6 +779,16 @@ int TouchInteraction::interpretInteraction(const std::vector& return ROLL; } else { + const bool sameInput0 = _pinchInputs[0].holdsInput(list[0].latestInput()); + const bool sameInput1 = _pinchInputs[1].holdsInput(list[1].latestInput()); + if(sameInput0 && sameInput1) + { + _pinchInputs[0].tryAddInput(list[0].latestInput()); + _pinchInputs[1].tryAddInput(list[1].latestInput()); + }else{ + _pinchInputs[0] = TouchInputHolder(list[0].latestInput()); + _pinchInputs[1] = TouchInputHolder(list[1].latestInput()); + } return PINCH; } } @@ -818,6 +830,10 @@ void TouchInteraction::computeVelocities(const std::vector& li const TouchInputHolder& inputHolder = list.at(0); switch (action) { case ROT: { // add rotation velocity + const auto inputs = inputHolder.peekInputs(); + if(inputs.size() > 1 ){ + const float dt = inputs[0].timestamp - inputs[1].timestamp; + } _vel.orbit += glm::dvec2(inputHolder.speedX() * _sensitivity.orbit.x, inputHolder.speedY() * _sensitivity.orbit.y); @@ -830,51 +846,25 @@ void TouchInteraction::computeVelocities(const std::vector& li case PINCH: { // add zooming velocity - dependant on distance difference between contact // points this/last frame - double distance = std::accumulate( - list.begin(), - list.end(), - 0.0, - [&](double d, const TouchInputHolder& c) { - const glm::vec2 currPos = { c.latestInput().x, c.latestInput().y }; - return d + glm::distance(currPos, _centroid); - } - ) / list.size(); - double lastDistance = std::accumulate( - lastProcessed.begin(), - lastProcessed.end(), - 0.f, - [&](float d, const TouchInput& p) { - const glm::vec2 lastPos = { p.x, p.y }; - return d + glm::distance(lastPos, _centroid); - } - ) / lastProcessed.size(); + const TouchInput& startFinger0 = _pinchInputs[0].firstInput(); + const TouchInput& startFinger1 = _pinchInputs[1].firstInput(); + double distToCentroidStart = + glm::length(glm::dvec2(startFinger0.x, startFinger0.y) - + glm::dvec2(startFinger1.x, startFinger1.y)) / 2.0; - glm::dvec3 camPos = _camera->positionVec3(); - glm::dvec3 centerPos = anchor->worldPosition(); - glm::dvec3 currDistanceToFocusNode = camPos - centerPos; + const TouchInput& endFinger0 = _pinchInputs[0].latestInput(); + const TouchInput& endFinger1 = _pinchInputs[1].latestInput(); + double distToCentroidEnd = + glm::length(glm::dvec2(endFinger0.x, endFinger0.y) - + glm::dvec2(endFinger1.x, endFinger1.y)) / 2.0; - const double distanceFromFocusSurface = - length(currDistanceToFocusNode) - anchor->boundingSphere(); - double zoomFactor = (distance - lastDistance); + double zoomFactor = 0.01*(distToCentroidEnd - distToCentroidStart); #ifdef TOUCH_DEBUG_PROPERTIES pinchConsecCt++; pinchConsecZoomFactor += zoomFactor; #endif - _constTimeDecayCoeff.zoom = computeConstTimeDecayCoefficient(_vel.zoom); - if (distanceFromFocusSurface > 0.1) { - const double ratioOfDistanceToNodeVsSurface = - length(currDistanceToFocusNode) / distanceFromFocusSurface; - if (ratioOfDistanceToNodeVsSurface > _zoomSensitivityDistanceThreshold) { - zoomFactor *= pow( - std::abs(distanceFromFocusSurface), - static_cast(_zoomSensitivityExponential) - ); - } - } - else { - zoomFactor = 1.0; - } + _constTimeDecayCoeff.zoom = 1.0; _vel.zoom = zoomFactor * _zoomSensitivityProportionalDist * std::max(_touchScreenSize.value() * 0.1, 1.0); break; @@ -917,7 +907,7 @@ void TouchInteraction::computeVelocities(const std::vector& li break; } case PAN: { - // add local rotation velocity + // add local rotation velocity _vel.pan += glm::dvec2(inputHolder.speedX() * _sensitivity.pan.x, inputHolder.speedY() * _sensitivity.pan.y); double panVelocityAvg = glm::distance(_vel.pan.x, _vel.pan.y); @@ -925,7 +915,7 @@ void TouchInteraction::computeVelocities(const std::vector& li break; } case PICK: { - // pick something in the scene as focus node + // pick something in the scene as focus node if (_pickingSelected) { setFocusNode(_pickingSelected); @@ -992,7 +982,7 @@ double TouchInteraction::computeTapZoomDistance(double zoomGain) { // Main update call, calculates the new orientation and position for the camera depending // on _vel and dt. Called every frame -void TouchInteraction::step(double dt) { +void TouchInteraction::step(double dt, bool directTouch) { using namespace glm; const SceneGraphNode* anchor = @@ -1103,11 +1093,30 @@ void TouchInteraction::step(double dt) { _loggerCat, _zoomOutLimit.value() )); } + const double currentPosDistance = length(centerToCamera); //Apply the velocity to update camera position - glm::dvec3 zoomDistanceIncrement = directionToCenter * _vel.zoom * dt; + double zoomVelocity = _vel.zoom; + if(!directTouch) { + const double distanceFromSurface = + length(currentPosDistance) - anchor->boundingSphere(); + if (distanceFromSurface > 0.1) { + const double ratioOfDistanceToNodeVsSurface = + length(currentPosDistance) / distanceFromSurface; + if (ratioOfDistanceToNodeVsSurface > _zoomSensitivityDistanceThreshold) { + zoomVelocity *= pow( + std::abs(distanceFromSurface), + static_cast(_zoomSensitivityExponential) + ); + } + } + else { + zoomVelocity = 1.0; + } + } + + const glm::dvec3 zoomDistanceIncrement = directionToCenter * zoomVelocity * dt; const double newPosDistance = length(centerToCamera + zoomDistanceIncrement); - const double currentPosDistance = length(centerToCamera); // Possible with other navigations performed outside touch interaction const bool currentPosViolatingZoomOutLimit = @@ -1116,8 +1125,11 @@ void TouchInteraction::step(double dt) { (newPosDistance >= _zoomOutLimit.value()); bool willNewPositionViolateZoomInLimit = (newPosDistance < zoomInBounds); + bool willNewPositionViolateDirection = + (currentPosDistance <= length(zoomDistanceIncrement)); if (!willNewPositionViolateZoomInLimit + && !willNewPositionViolateDirection && !willNewPositionViolateZoomOutLimit) { camPos += zoomDistanceIncrement; } @@ -1218,7 +1230,6 @@ void TouchInteraction::resetAfterInput() { module.touchInput.active = false; module.touchInput.action = 0; } - _lmSuccess = true; // Ensure that _guiON is consistent with properties in OnScreenGUI and _guiON = module.gui.isEnabled(); @@ -1228,6 +1239,11 @@ void TouchInteraction::resetAfterInput() { _lastVel.zoom = 0.0; _lastVel.roll = 0.0; _lastVel.pan = glm::dvec2(0.0); + + _constTimeDecayCoeff.zoom = computeConstTimeDecayCoefficient(_vel.zoom); + _pinchInputs[0].clearInputs(); + _pinchInputs[1].clearInputs(); + _selected.clear(); _pickingSelected = nullptr; } diff --git a/modules/touch/touchmodule.cpp b/modules/touch/touchmodule.cpp index 73a12cbbfc..1672b2cf42 100644 --- a/modules/touch/touchmodule.cpp +++ b/modules/touch/touchmodule.cpp @@ -221,7 +221,7 @@ void TouchModule::internalInitialize(const ghoul::Dictionary& /*dictionary*/){ global::callback::touchUpdated.push_back( [this](TouchInput i) { updateOrAddTouchInput(i); - return true; + return true; } ); From fd0a9743a2e81348ebfdb8a3156ff0da5f9c096e Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Tue, 10 Mar 2020 10:25:31 +0100 Subject: [PATCH 11/67] Touch: Added a firstInput so that if we ever get more than max amount of inputs in our Deque, we will still have our first point stored (for pinching around a start-centroid mainly) --- include/openspace/util/touch.h | 1 + src/util/touch.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/openspace/util/touch.h b/include/openspace/util/touch.h index a7f8500a93..a7e8bc0735 100644 --- a/include/openspace/util/touch.h +++ b/include/openspace/util/touch.h @@ -80,6 +80,7 @@ public: private: //A deque of recorded inputs. Adding newer points to the front of the queue std::deque _inputs; + TouchInput _firstInput; size_t _touchDeviceId; size_t _fingerId; diff --git a/src/util/touch.cpp b/src/util/touch.cpp index d5381daa01..f08c5cab03 100644 --- a/src/util/touch.cpp +++ b/src/util/touch.cpp @@ -73,6 +73,7 @@ float TouchInput::angleToPos(float otherX, float otherY) const { TouchInputHolder::TouchInputHolder(TouchInput input) : _inputs{ input } + , _firstInput(input) , _touchDeviceId(input.touchDeviceId) , _fingerId(input.fingerId) {} @@ -182,7 +183,7 @@ size_t TouchInputHolder::numInputs() const { } const TouchInput& TouchInputHolder::firstInput() const { - return _inputs.back(); + return _firstInput; } const TouchInput& TouchInputHolder::latestInput() const { From 7b282ae77c2a8ca53674f8dfa729c0b1135ff84b Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Tue, 10 Mar 2020 17:58:14 +0100 Subject: [PATCH 12/67] Replaced magic value with a property and added a quick and dirty aspect ratio to the pinch-zoom handling --- modules/touch/include/touchinteraction.h | 1 + modules/touch/src/touchinteraction.cpp | 33 +++++++++++++++--------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/modules/touch/include/touchinteraction.h b/modules/touch/include/touchinteraction.h index b4e89ffeb7..f1713c2f20 100644 --- a/modules/touch/include/touchinteraction.h +++ b/modules/touch/include/touchinteraction.h @@ -167,6 +167,7 @@ private: properties::IntProperty _deceleratesPerSecond; properties::FloatProperty _touchScreenSize; properties::FloatProperty _tapZoomFactor; + properties::FloatProperty _pinchZoomFactor; properties::FloatProperty _nodeRadiusThreshold; properties::FloatProperty _rollAngleThreshold; properties::FloatProperty _orbitSpeedThreshold; diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 31c6c44be5..0f0c575870 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -117,6 +117,11 @@ namespace { "" // @TODO Missing documentation }; + constexpr openspace::properties::Property::PropertyInfo PinchZoomFactorInfo = { + "PinchZoomFactor", "Scaling distance travelled on pinch", + "" // @TODO Missing documentation + }; + constexpr openspace::properties::Property::PropertyInfo DirectManipulationInfo = { "DirectManipulationRadius", "Radius a planet has to have to activate direct-manipulation", @@ -264,6 +269,7 @@ TouchInteraction::TouchInteraction() , _deceleratesPerSecond(DecelatesPerSecondInfo, 240, 60, 300) , _touchScreenSize(TouchScreenSizeInfo, 55.0f, 5.5f, 150.0f) , _tapZoomFactor(TapZoomFactorInfo, 0.2f, 0.f, 0.5f) + , _pinchZoomFactor(PinchZoomFactorInfo, 0.01f, 0.f, 0.2f) , _nodeRadiusThreshold(DirectManipulationInfo, 0.2f, 0.0f, 1.0f) , _rollAngleThreshold(RollThresholdInfo, 0.025f, 0.f, 0.05f) , _orbitSpeedThreshold(OrbitSpinningThreshold, 0.005f, 0.f, 0.01f) @@ -322,6 +328,7 @@ TouchInteraction::TouchInteraction() addProperty(_deceleratesPerSecond); addProperty(_touchScreenSize); addProperty(_tapZoomFactor); + addProperty(_pinchZoomFactor); addProperty(_nodeRadiusThreshold); addProperty(_rollAngleThreshold); addProperty(_orbitSpeedThreshold); @@ -828,12 +835,11 @@ void TouchInteraction::computeVelocities(const std::vector& li #endif const TouchInputHolder& inputHolder = list.at(0); + const glm::ivec2 windowSize = global::windowDelegate.currentWindowSize(); + const float aspectRatio = + static_cast(windowSize.x) / static_cast(windowSize.y); switch (action) { case ROT: { // add rotation velocity - const auto inputs = inputHolder.peekInputs(); - if(inputs.size() > 1 ){ - const float dt = inputs[0].timestamp - inputs[1].timestamp; - } _vel.orbit += glm::dvec2(inputHolder.speedX() * _sensitivity.orbit.x, inputHolder.speedY() * _sensitivity.orbit.y); @@ -845,28 +851,30 @@ void TouchInteraction::computeVelocities(const std::vector& li } case PINCH: { // add zooming velocity - dependant on distance difference between contact - // points this/last frame + // points this/first frame const TouchInput& startFinger0 = _pinchInputs[0].firstInput(); const TouchInput& startFinger1 = _pinchInputs[1].firstInput(); double distToCentroidStart = - glm::length(glm::dvec2(startFinger0.x, startFinger0.y) - - glm::dvec2(startFinger1.x, startFinger1.y)) / 2.0; + glm::length(glm::dvec2(startFinger0.x * aspectRatio, startFinger0.y) - + glm::dvec2(startFinger1.x * aspectRatio, startFinger1.y)) / 2.0; const TouchInput& endFinger0 = _pinchInputs[0].latestInput(); const TouchInput& endFinger1 = _pinchInputs[1].latestInput(); double distToCentroidEnd = - glm::length(glm::dvec2(endFinger0.x, endFinger0.y) - - glm::dvec2(endFinger1.x, endFinger1.y)) / 2.0; + glm::length(glm::dvec2(endFinger0.x * aspectRatio, endFinger0.y) - + glm::dvec2(endFinger1.x * aspectRatio, endFinger1.y)) / 2.0; - double zoomFactor = 0.01*(distToCentroidEnd - distToCentroidStart); + double zoomFactor = distToCentroidEnd - distToCentroidStart; #ifdef TOUCH_DEBUG_PROPERTIES pinchConsecCt++; pinchConsecZoomFactor += zoomFactor; #endif _constTimeDecayCoeff.zoom = 1.0; - _vel.zoom = zoomFactor * _zoomSensitivityProportionalDist * - std::max(_touchScreenSize.value() * 0.1, 1.0); + _vel.zoom = zoomFactor * + _pinchZoomFactor * + _zoomSensitivityProportionalDist * + std::max(_touchScreenSize.value() * 0.1, 1.0); break; } case ROLL: { @@ -1256,6 +1264,7 @@ void TouchInteraction::resetToDefault() { _deceleratesPerSecond.set(240); _touchScreenSize.set(55.0f); _tapZoomFactor.set(0.2f); + _pinchZoomFactor.set(0.01f); _nodeRadiusThreshold.set(0.2f); _rollAngleThreshold.set(0.025f); _orbitSpeedThreshold.set(0.005f); From 42462ccfab57bce7b0d6ab602092adde1eb39219 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Tue, 10 Mar 2020 18:22:50 +0100 Subject: [PATCH 13/67] Minor cleanup for code clarity --- modules/touch/src/touchinteraction.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 0f0c575870..01634ea46a 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -852,17 +852,18 @@ void TouchInteraction::computeVelocities(const std::vector& li case PINCH: { // add zooming velocity - dependant on distance difference between contact // points this/first frame + using namespace glm; const TouchInput& startFinger0 = _pinchInputs[0].firstInput(); const TouchInput& startFinger1 = _pinchInputs[1].firstInput(); - double distToCentroidStart = - glm::length(glm::dvec2(startFinger0.x * aspectRatio, startFinger0.y) - - glm::dvec2(startFinger1.x * aspectRatio, startFinger1.y)) / 2.0; + const dvec2 startVec0 = dvec2(startFinger0.x * aspectRatio, startFinger0.y); + const dvec2 startVec1 = dvec2(startFinger1.x * aspectRatio, startFinger1.y); + double distToCentroidStart = length(startVec0 - startVec1) / 2.0; const TouchInput& endFinger0 = _pinchInputs[0].latestInput(); const TouchInput& endFinger1 = _pinchInputs[1].latestInput(); - double distToCentroidEnd = - glm::length(glm::dvec2(endFinger0.x * aspectRatio, endFinger0.y) - - glm::dvec2(endFinger1.x * aspectRatio, endFinger1.y)) / 2.0; + const dvec2 endVec0 = dvec2(endFinger0.x * aspectRatio, endFinger0.y); + const dvec2 endVec1 = dvec2(endFinger1.x * aspectRatio, endFinger1.y); + double distToCentroidEnd = length(endVec0 - endVec1) / 2.0; double zoomFactor = distToCentroidEnd - distToCentroidStart; #ifdef TOUCH_DEBUG_PROPERTIES From 0808ebb1b4b7fc8d6658084d9dc3e4c86ee5f081 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Tue, 10 Mar 2020 18:34:11 +0100 Subject: [PATCH 14/67] Added documentation for the pinchzoomfactor property --- modules/touch/src/touchinteraction.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 01634ea46a..cf36a632e5 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -118,8 +118,10 @@ namespace { }; constexpr openspace::properties::Property::PropertyInfo PinchZoomFactorInfo = { - "PinchZoomFactor", "Scaling distance travelled on pinch", - "" // @TODO Missing documentation + "PinchZoomFactor", + "Scaling distance travelled on pinch", + "This value is used to reduce the amount of pinching needed. A linear" + "kind of sensitivity that will alter the pinch-zoom speed." }; constexpr openspace::properties::Property::PropertyInfo DirectManipulationInfo = { @@ -1106,7 +1108,7 @@ void TouchInteraction::step(double dt, bool directTouch) { //Apply the velocity to update camera position double zoomVelocity = _vel.zoom; - if(!directTouch) { + if (!directTouch) { const double distanceFromSurface = length(currentPosDistance) - anchor->boundingSphere(); if (distanceFromSurface > 0.1) { From 88a5dfe6b2de77709f2109df19d70388d09f5d73 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 10 Mar 2020 14:13:17 -0600 Subject: [PATCH 15/67] Resolved build errors from combining satellites & SBDB renderables --- .../rendering/renderableorbitalkepler.cpp | 422 +++++++++++------- .../space/rendering/renderableorbitalkepler.h | 60 ++- .../space/rendering/renderablesatellites.cpp | 40 -- .../space/rendering/renderablesatellites.h | 8 +- .../space/rendering/renderablesmallbody.cpp | 58 +-- modules/space/rendering/renderablesmallbody.h | 6 +- 6 files changed, 302 insertions(+), 292 deletions(-) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 7705c466ff..ab277b8ff5 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -88,189 +88,264 @@ namespace { namespace openspace { - // Count the number of full days since the beginning of 2000 to the beginning of - // the parameter 'year' - int countDays(int year) { - // Find the position of the current year in the vector, the difference - // between its position and the position of 2000 (for J2000) gives the - // number of leap years - constexpr const int Epoch = 2000; - constexpr const int DaysRegularYear = 365; - constexpr const int DaysLeapYear = 366; +// Count the number of full days since the beginning of 2000 to the beginning of +// the parameter 'year' +int RenderableOrbitalKepler::countDays(int year) { + // Find the position of the current year in the vector, the difference + // between its position and the position of 2000 (for J2000) gives the + // number of leap years + constexpr const int Epoch = 2000; + constexpr const int DaysRegularYear = 365; + constexpr const int DaysLeapYear = 366; - if (year == Epoch) { - return 0; + if (year == Epoch) { + return 0; + } + + // Get the position of the most recent leap year + const auto lb = std::lower_bound(LeapYears.begin(), LeapYears.end(), year); + + // Get the position of the epoch + const auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); + + // The distance between the two iterators gives us the number of leap years + const int nLeapYears = static_cast(std::abs(std::distance(y2000, lb))); + + const int nYears = std::abs(year - Epoch); + const int nRegularYears = nYears - nLeapYears; + + // Get the total number of days as the sum of leap years + non leap years + const int result = nRegularYears * DaysRegularYear + nLeapYears * DaysLeapYear; + return result; +} + +// Returns the number of leap seconds that lie between the {year, dayOfYear} +// time point and { 2000, 1 } +int RenderableOrbitalKepler::countLeapSeconds(int year, int dayOfYear) { + // Find the position of the current year in the vector; its position in + // the vector gives the number of leap seconds + struct LeapSecond { + int year; + int dayOfYear; + bool operator<(const LeapSecond& rhs) const { + return std::tie(year, dayOfYear) < std::tie(rhs.year, rhs.dayOfYear); } + }; - // Get the position of the most recent leap year - const auto lb = std::lower_bound(LeapYears.begin(), LeapYears.end(), year); + const LeapSecond Epoch = { 2000, 1 }; - // Get the position of the epoch - const auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); + // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list + static const std::vector LeapSeconds = { + { 1972, 1 }, + { 1972, 183 }, + { 1973, 1 }, + { 1974, 1 }, + { 1975, 1 }, + { 1976, 1 }, + { 1977, 1 }, + { 1978, 1 }, + { 1979, 1 }, + { 1980, 1 }, + { 1981, 182 }, + { 1982, 182 }, + { 1983, 182 }, + { 1985, 182 }, + { 1988, 1 }, + { 1990, 1 }, + { 1991, 1 }, + { 1992, 183 }, + { 1993, 182 }, + { 1994, 182 }, + { 1996, 1 }, + { 1997, 182 }, + { 1999, 1 }, + { 2006, 1 }, + { 2009, 1 }, + { 2012, 183 }, + { 2015, 182 }, + { 2017, 1 } + }; - // The distance between the two iterators gives us the number of leap years - const int nLeapYears = static_cast(std::abs(std::distance(y2000, lb))); + // Get the position of the last leap second before the desired date + LeapSecond date { year, dayOfYear }; + const auto it = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), date); - const int nYears = std::abs(year - Epoch); - const int nRegularYears = nYears - nLeapYears; + // Get the position of the Epoch + const auto y2000 = std::lower_bound( + LeapSeconds.begin(), + LeapSeconds.end(), + Epoch + ); - // Get the total number of days as the sum of leap years + non leap years - const int result = nRegularYears * DaysRegularYear + nLeapYears * DaysLeapYear; - return result; + // The distance between the two iterators gives us the number of leap years + const int nLeapSeconds = static_cast(std::abs(std::distance(y2000, it))); + return nLeapSeconds; +} + +double RenderableOrbitalKepler::calculateSemiMajorAxis(double meanMotion) { + constexpr const double GravitationalConstant = 6.6740831e-11; + constexpr const double MassEarth = 5.9721986e24; + constexpr const double muEarth = GravitationalConstant * MassEarth; + + // Use Kepler's 3rd law to calculate semimajor axis + // a^3 / P^2 = mu / (2pi)^2 + // <=> a = ((mu * P^2) / (2pi^2))^(1/3) + // with a = semimajor axis + // P = period in seconds + // mu = G*M_earth + double period = std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion; + + const double pisq = glm::pi() * glm::pi(); + double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); + + // We need the semi major axis in km instead of m + return semiMajorAxis / 1000.0; +} + +double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochString) { + // The epochString is in the form: + // YYDDD.DDDDDDDD + // With YY being the last two years of the launch epoch, the first DDD the day + // of the year and the remaning a fractional part of the day + + // The main overview of this function: + // 1. Reconstruct the full year from the YY part + // 2. Calculate the number of seconds since the beginning of the year + // 2.a Get the number of full days since the beginning of the year + // 2.b If the year is a leap year, modify the number of days + // 3. Convert the number of days to a number of seconds + // 4. Get the number of leap seconds since January 1st, 2000 and remove them + // 5. Adjust for the fact the epoch starts on 1st Januaray at 12:00:00, not + // midnight + + // According to https://celestrak.com/columns/v04n03/ + // Apparently, US Space Command sees no need to change the two-line element + // set format yet since no artificial earth satellites existed prior to 1957. + // By their reasoning, two-digit years from 57-99 correspond to 1957-1999 and + // those from 00-56 correspond to 2000-2056. We'll see each other again in 057! + + // 1. Get the full year + std::string yearPrefix = [y = epochString.substr(0, 2)](){ + int year = std::atoi(y.c_str()); + return year >= 57 ? "19" : "20"; + }(); + const int year = std::atoi((yearPrefix + epochString.substr(0, 2)).c_str()); + const int daysSince2000 = countDays(year); + + // 2. + // 2.a + double daysInYear = std::atof(epochString.substr(2).c_str()); + + // 2.b + const bool isInLeapYear = std::find( + LeapYears.begin(), + LeapYears.end(), + year + ) != LeapYears.end(); + if (isInLeapYear && daysInYear >= 60) { + // We are in a leap year, so we have an effective day more if we are + // beyond the end of february (= 31+29 days) + --daysInYear; } - // Returns the number of leap seconds that lie between the {year, dayOfYear} - // time point and { 2000, 1 } - int countLeapSeconds(int year, int dayOfYear) { - // Find the position of the current year in the vector; its position in - // the vector gives the number of leap seconds - struct LeapSecond { - int year; - int dayOfYear; - bool operator<(const LeapSecond& rhs) const { - return std::tie(year, dayOfYear) < std::tie(rhs.year, rhs.dayOfYear); - } - }; + // 3 + using namespace std::chrono; + const int SecondsPerDay = static_cast(seconds(hours(24)).count()); + //Need to subtract 1 from daysInYear since it is not a zero-based count + const double nSecondsSince2000 = (daysSince2000 + daysInYear - 1) * SecondsPerDay; - const LeapSecond Epoch = { 2000, 1 }; + // 4 + // We need to remove additional leap seconds past 2000 and add them prior to + // 2000 to sync up the time zones + const double nLeapSecondsOffset = -countLeapSeconds( + year, + static_cast(std::floor(daysInYear)) + ); - // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list - static const std::vector LeapSeconds = { - { 1972, 1 }, - { 1972, 183 }, - { 1973, 1 }, - { 1974, 1 }, - { 1975, 1 }, - { 1976, 1 }, - { 1977, 1 }, - { 1978, 1 }, - { 1979, 1 }, - { 1980, 1 }, - { 1981, 182 }, - { 1982, 182 }, - { 1983, 182 }, - { 1985, 182 }, - { 1988, 1 }, - { 1990, 1 }, - { 1991, 1 }, - { 1992, 183 }, - { 1993, 182 }, - { 1994, 182 }, - { 1996, 1 }, - { 1997, 182 }, - { 1999, 1 }, - { 2006, 1 }, - { 2009, 1 }, - { 2012, 183 }, - { 2015, 182 }, - { 2017, 1 } - }; + // 5 + const double nSecondsEpochOffset = static_cast( + seconds(hours(12)).count() + ); - // Get the position of the last leap second before the desired date - LeapSecond date { year, dayOfYear }; - const auto it = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), date); + // Combine all of the values + const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; + return epoch; +} - // Get the position of the Epoch - const auto y2000 = std::lower_bound( - LeapSeconds.begin(), - LeapSeconds.end(), - Epoch +double RenderableOrbitalKepler::epochFromYMDdSubstring(const std::string& epochString) { + // The epochString is in the form: + // YYYYMMDD.ddddddd + // With YYYY as the year, MM the month (1 - 12), DD the day of month (1-31), + // and dddd the fraction of that day. + + // The main overview of this function: + // 1. Read the year value + // 2. Calculate the number of seconds since the beginning of the year + // 2.a Get the number of full days since the beginning of the year + // 2.b If the year is a leap year, modify the number of days + // 3. Convert the number of days to a number of seconds + // 4. Get the number of leap seconds since January 1st, 2000 and remove them + // 5. Adjust for the fact the epoch starts on 1st January at 12:00:00, not + // midnight + + // 1 + int year = std::atoi(epochString.substr(0, 4).c_str()); + const int daysSince2000 = countDays(year); + + // 2. + // 2.a + int monthNum = std::atoi(epochString.substr(4, 2).c_str()); + int dayOfMonthNum = std::atoi(epochString.substr(6, 2).c_str()); + int wholeDaysInto = daysIntoGivenYear(monthNum, dayOfMonthNum); + double fractionOfDay = std::atof(epochString.substr(9, 7).c_str()); + double daysInYear = static_cast(wholeDaysInto) + fractionOfDay; + + // 2.b + const bool isInLeapYear = std::find( + LeapYears.begin(), + LeapYears.end(), + year + ) != LeapYears.end(); + if (isInLeapYear && daysInYear >= 60) { + // We are in a leap year, so we have an effective day more if we are + // beyond the end of february (= 31+29 days) + --daysInYear; + } + + // 3 + using namespace std::chrono; + const int SecondsPerDay = static_cast(seconds(hours(24)).count()); + //Need to subtract 1 from daysInYear since it is not a zero-based count + const double nSecondsSince2000 = (daysSince2000 + daysInYear - 1) * SecondsPerDay; + + // 4 + // We need to remove additional leap seconds past 2000 and add them prior to + // 2000 to sync up the time zones + const double nLeapSecondsOffset = -countLeapSeconds( + year, + static_cast(std::floor(daysInYear)) + ); + + // 5 + const double nSecondsEpochOffset = static_cast( + seconds(hours(12)).count() ); - // The distance between the two iterators gives us the number of leap years - const int nLeapSeconds = static_cast(std::abs(std::distance(y2000, it))); - return nLeapSeconds; - } - - double calculateSemiMajorAxis(double meanMotion) { - constexpr const double GravitationalConstant = 6.6740831e-11; - constexpr const double MassEarth = 5.9721986e24; - constexpr const double muEarth = GravitationalConstant * MassEarth; - - // Use Kepler's 3rd law to calculate semimajor axis - // a^3 / P^2 = mu / (2pi)^2 - // <=> a = ((mu * P^2) / (2pi^2))^(1/3) - // with a = semimajor axis - // P = period in seconds - // mu = G*M_earth - double period = std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion; - - const double pisq = glm::pi() * glm::pi(); - double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); - - // We need the semi major axis in km instead of m - return semiMajorAxis / 1000.0; - } - -double epochFromSubstring(const std::string& epochString) { - // The epochString is in the form: - // YYDDD.DDDDDDDD - // With YY being the last two years of the launch epoch, the first DDD the day - // of the year and the remaning a fractional part of the day - - // The main overview of this function: - // 1. Reconstruct the full year from the YY part - // 2. Calculate the number of seconds since the beginning of the year - // 2.a Get the number of full days since the beginning of the year - // 2.b If the year is a leap year, modify the number of days - // 3. Convert the number of days to a number of seconds - // 4. Get the number of leap seconds since January 1st, 2000 and remove them - // 5. Adjust for the fact the epoch starts on 1st Januaray at 12:00:00, not - // midnight - - // According to https://celestrak.com/columns/v04n03/ - // Apparently, US Space Command sees no need to change the two-line element - // set format yet since no artificial earth satellites existed prior to 1957. - // By their reasoning, two-digit years from 57-99 correspond to 1957-1999 and - // those from 00-56 correspond to 2000-2056. We'll see each other again in 2057! - - // 1. Get the full year - std::string yearPrefix = [y = epochString.substr(0, 2)](){ - int year = std::atoi(y.c_str()); - return year >= 57 ? "19" : "20"; - }(); - const int year = std::atoi((yearPrefix + epochString.substr(0, 2)).c_str()); - const int daysSince2000 = countDays(year); - - // 2. - // 2.a - double daysInYear = std::atof(epochString.substr(2).c_str()); - - // 2.b - const bool isInLeapYear = std::find( - LeapYears.begin(), - LeapYears.end(), - year - ) != LeapYears.end(); - if (isInLeapYear && daysInYear >= 60) { - // We are in a leap year, so we have an effective day more if we are - // beyond the end of february (= 31+29 days) - --daysInYear; - } - - // 3 - using namespace std::chrono; - const int SecondsPerDay = static_cast(seconds(hours(24)).count()); - //Need to subtract 1 from daysInYear since it is not a zero-based count - const double nSecondsSince2000 = (daysSince2000 + daysInYear - 1) * SecondsPerDay; - - // 4 - // We need to remove additional leap seconds past 2000 and add them prior to - // 2000 to sync up the time zones - const double nLeapSecondsOffset = -countLeapSeconds( - year, - static_cast(std::floor(daysInYear)) - ); - - // 5 - const double nSecondsEpochOffset = static_cast( - seconds(hours(12)).count() - ); - - // Combine all of the values - const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; - return epoch; + // Combine all of the values + const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; + return epoch; +} + +int RenderableOrbitalKepler::daysIntoGivenYear(int month, int dayOfMonth) { + //month and dayCount are zero-based. Does NOT account for leap year. + month -= 1; + int dayCount = dayOfMonth - 1; + + for (int m = Months::January; m < month; ++m) { + dayCount += DaysOfMonths[m]; } + return dayCount; +} documentation::Documentation RenderableOrbitalKepler::Documentation() { using namespace documentation; @@ -284,6 +359,12 @@ documentation::Documentation RenderableOrbitalKepler::Documentation() { Optional::No, SegmentsInfo.description }, + { + UpperLimitInfo.identifier, + new IntVerifier, + Optional::Yes, + UpperLimitInfo.description + }, { PathInfo.identifier, new StringVerifier, @@ -301,6 +382,12 @@ documentation::Documentation RenderableOrbitalKepler::Documentation() { new DoubleVector3Verifier, Optional::No, LineColorInfo.description + }, + { + TrailFadeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + TrailFadeInfo.description } } }; @@ -310,6 +397,7 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio : Renderable(dictionary) , _path(PathInfo) , _nSegments(SegmentsInfo, 120, 4, 1024) + , _upperLimit(UpperLimitInfo, 1000, 1, 1000000) { documentation::testSpecificationAndThrow( Documentation(), diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h index b1c36ea7fd..f9ed0fbf9e 100644 --- a/modules/space/rendering/renderableorbitalkepler.h +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -37,16 +37,6 @@ namespace openspace { -const std::vector LeapYears = { - 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, - 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, - 2044, 2048, 2052, 2056 -}; -int countDays(int year); -int countLeapSeconds(int year, int dayOfYear); -double calculateSemiMajorAxis(double meanMotion); -double epochFromSubstring(const std::string& epochString); - class RenderableOrbitalKepler : public Renderable { public: RenderableOrbitalKepler(const ghoul::Dictionary& dictionary); @@ -72,13 +62,35 @@ public: */ virtual void readDataFile(const std::string& filename) = 0; -private: - struct Vertex { - glm::vec3 position = glm::vec3(0.f); - glm::vec3 color = glm::vec3(0.f); - glm::vec2 texcoord = glm::vec2(0.f); +protected: + int countDays(int year); + int countLeapSeconds(int year, int dayOfYear); + double calculateSemiMajorAxis(double meanMotion); + double epochFromSubstring(const std::string& epochString); + double epochFromYMDdSubstring(const std::string& epochString); + int daysIntoGivenYear(int month, int dayOfMonth); + const std::vector LeapYears = { + 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, + 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, + 2044, 2048, 2052, 2056 + }; + const std::vector DaysOfMonths = { + 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + enum Months { + January = 0, + February, + March, + April, + May, + June, + July, + August, + September, + October, + November, + December }; - struct KeplerParameters { double inclination = 0.0; double semiMajorAxis = 0.0; @@ -90,6 +102,17 @@ private: double epoch = 0.0; double period = 0.0; }; + const double convertAuToKm = 1.496e8; + const double convertDaysToSecs = 86400.; + std::vector _data; + properties::UIntProperty _upperLimit; + +private: + struct Vertex { + glm::vec3 position = glm::vec3(0.f); + glm::vec3 color = glm::vec3(0.f); + glm::vec2 texcoord = glm::vec2(0.f); + }; /// The layout of the VBOs struct TrailVBOLayout { @@ -102,7 +125,6 @@ private: }; KeplerTranslation _keplerTranslator; - std::vector _data; /// The backend storage for the vertex buffer object containing all points for this /// trail. @@ -119,13 +141,9 @@ private: void updateBuffers(); ghoul::opengl::ProgramObject* _programObject; - properties::StringProperty _path; properties::UIntProperty _nSegments; - properties::UIntProperty _upperLimit; - RenderableTrail::Appearance _appearance; - glm::vec3 _position = glm::vec3(0.f); UniformCache(modelView, projection, lineFade, inGameTime, color, opacity, diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 62f80ed4bd..3904308407 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -56,51 +56,11 @@ namespace { } namespace openspace { - -documentation::Documentation RenderableSatellites::Documentation() { - using namespace documentation; - return { - "RenderableSatellites", - "space_renderable_satellites", - { - { - SegmentsInfo.identifier, - new DoubleVerifier, - Optional::No, - SegmentsInfo.description - }, - { - PathInfo.identifier, - new StringVerifier, - Optional::No, - PathInfo.description - }, - { - LineWidthInfo.identifier, - new DoubleVerifier, - Optional::Yes, - LineWidthInfo.description - }, - { - LineColorInfo.identifier, - new DoubleVector3Verifier, - Optional::No, - LineColorInfo.description - } - } - }; -} RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) { - documentation::testSpecificationAndThrow( - Documentation(), - dictionary, - "RenderableSatellites" - ); } - void RenderableSatellites::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { diff --git a/modules/space/rendering/renderablesatellites.h b/modules/space/rendering/renderablesatellites.h index 05cf7b7498..230aca2e2b 100644 --- a/modules/space/rendering/renderablesatellites.h +++ b/modules/space/rendering/renderablesatellites.h @@ -38,13 +38,11 @@ namespace openspace { -class RenderableSatellites : private RenderableOrbitalKepler { +class RenderableSatellites : public RenderableOrbitalKepler { public: RenderableSatellites(const ghoul::Dictionary& dictionary); - static documentation::Documentation Documentation(); - -private: - + void readDataFile(const std::string& filename); + //static documentation::Documentation Documentation(); }; } // namespace openspace diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index abfef75e47..ad70e7afd8 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -58,62 +58,11 @@ namespace { namespace openspace { -documentation::Documentation RenderableSmallBody::Documentation() { - using namespace documentation; - return { - "RenderableSmallBody", - "small solar system bodies", - { - { - SegmentsInfo.identifier, - new DoubleVerifier, - Optional::No, - SegmentsInfo.description - }, - { - UpperLimitInfo.identifier, - new IntVerifier, - Optional::Yes, - UpperLimitInfo.description - }, - { - PathInfo.identifier, - new StringVerifier, - Optional::No, - PathInfo.description - }, - { - LineWidthInfo.identifier, - new DoubleVerifier, - Optional::Yes, - LineWidthInfo.description - }, - { - FadeInfo.identifier, - new DoubleVerifier, - Optional::Yes, - FadeInfo.description - }, - { - LineColorInfo.identifier, - new DoubleVector3Verifier, - Optional::No, - LineColorInfo.description - } - } - }; -} - + RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) { - documentation::testSpecificationAndThrow( - Documentation(), - dictionary, - "RenderableSmallBody" - ); -} - +} void RenderableSmallBody::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { @@ -136,7 +85,6 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { std::streamoff csvLine = -1; int fieldCount = 0; float lineSkipFraction = 1.0; - float lineSkipTotal = 0.0; float currLineFraction; int currLineCount; int lastLineCount = -1; @@ -148,7 +96,7 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { numberOfLines -= 1; if (_upperLimit == 0 || _upperLimit > numberOfLines) { //If limit wasn't specified in dictionary, set to lines in file (-header) - _upperLimit = numberOfLines; + _upperLimit = static_cast(numberOfLines); } else { lineSkipFraction = static_cast(_upperLimit) / diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index 5c9fa5b9f8..5c385d32f6 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -43,20 +43,18 @@ static double importAngleValue(const std::string& angle); class RenderableSmallBody : public RenderableOrbitalKepler { public: RenderableSmallBody(const ghoul::Dictionary& dictionary); - static documentation::Documentation Documentation(); + //static documentation::Documentation Documentation(); private: void readOrbitalParamsFromThisLine(int& fieldCount, std::streamoff& csvLine, std::ifstream& file); + void readDataFile(const std::string& filename); std::vector _sbNames; /// The index array that is potentially used in the draw call. If this is empty, no /// element draw call is used. std::vector _indexBufferData; - - const double convertAuToKm = 1.496e8; - const double convertDaysToSecs = 86400.; }; } // namespace openspace From e7185ebcb630878663d51b17bedead77408954bb Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 10 Mar 2020 14:40:45 -0600 Subject: [PATCH 16/67] Asteroid asset name change to be consistent with other data sets --- data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset b/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset index 001f06578c..93f11b035a 100644 --- a/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset +++ b/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset @@ -1,8 +1,8 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') -local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main asteroid belt', 'sssb_data_main_asteroid_belt') -local object = sharedSssb.createSssbGroupObject("sssb_data_main_asteroid_belt.csv", filepath, { 0.9, 0.3, 0.1 }) +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main asteroid belt', 'sssb_data_main_belt_asteroid') +local object = sharedSssb.createSssbGroupObject("sssb_data_main_belt_asteroid.csv", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 40 object.Renderable.Fade = 3 From fb7036c4970f92877619d4321a864e30787249b4 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Wed, 11 Mar 2020 13:23:46 +0100 Subject: [PATCH 17/67] Made imgui handle touch input as the webgui does Also removed imgui-handling code in touchinteraction --- modules/imgui/imguimodule.cpp | 22 ++++- modules/imgui/imguimodule.h | 8 -- modules/imgui/include/gui.h | 7 ++ modules/imgui/src/gui.cpp | 71 ++++++++++++++ modules/touch/include/touchinteraction.h | 21 +--- modules/touch/src/touchinteraction.cpp | 118 +++++------------------ 6 files changed, 123 insertions(+), 124 deletions(-) diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index 1b8d63ace9..9066fe9859 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -171,10 +171,6 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { uint32_t mouseButtons = delegate.mouseButtons(2); const double dt = std::max(delegate.averageDeltaTime(), 0.0); - if (touchInput.active && mouseButtons == 0) { - mouseButtons = touchInput.action; - mousePosition = touchInput.pos; - } // We don't do any collection of immediate mode user interface, so it // is fine to open and close a frame immediately gui.startFrame( @@ -252,6 +248,24 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } } ); + + global::callback::touchDetected.emplace_back( + [&](TouchInput input) -> bool { + return gui.touchDetectedCallback(input); + } + ); + + global::callback::touchUpdated.emplace_back( + [&](TouchInput input) -> bool { + return gui.touchUpdatedCallback(input); + } + ); + + global::callback::touchExit.emplace_back( + [&](TouchInput input) { + gui.touchExitCallback(input); + } + ); } } // namespace openspace diff --git a/modules/imgui/imguimodule.h b/modules/imgui/imguimodule.h index 73f037b5f2..d106967c65 100644 --- a/modules/imgui/imguimodule.h +++ b/modules/imgui/imguimodule.h @@ -31,13 +31,6 @@ namespace openspace { -// This should be moved into the touch module ---abock -struct Touch { - bool active; - glm::vec2 pos = glm::vec2(0.f); - uint32_t action = 0; -}; - class ImGUIModule : public OpenSpaceModule { public: constexpr static const char* Name = "ImGUI"; @@ -45,7 +38,6 @@ public: ImGUIModule(); gui::GUI gui; - Touch touchInput = { false, glm::vec2(0), 0 }; }; } // namespace openspace diff --git a/modules/imgui/include/gui.h b/modules/imgui/include/gui.h index 17378491d0..e428631d89 100644 --- a/modules/imgui/include/gui.h +++ b/modules/imgui/include/gui.h @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +90,10 @@ public: bool keyCallback(Key key, KeyModifier modifier, KeyAction action); bool charCallback(unsigned int character, KeyModifier modifier); + bool touchDetectedCallback(TouchInput input); + bool touchUpdatedCallback(TouchInput input); + void touchExitCallback(TouchInput input); + void startFrame(float deltaTime, const glm::vec2& windowSize, const glm::vec2& dpiScaling, const glm::vec2& mousePos, uint32_t mouseButtonsPressed); @@ -169,6 +174,8 @@ private: properties::Property::Visibility::Developer; std::vector _contexts; + + std::vector _validTouchStates; }; void CaptionText(const char* text); diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index f9389ce043..38c4e32f26 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -637,6 +637,77 @@ bool GUI::charCallback(unsigned int character, KeyModifier) { return consumeEvent; } +bool GUI::touchDetectedCallback(TouchInput input) { + ImGuiIO& io = ImGui::GetIO(); + glm::vec2 windowPos = input.currentWindowCoordinates(); + bool consumeEvent = ImGui::IsPosHoveringAnyWindow({windowPos.x, windowPos.y}); + + if(!consumeEvent) { + return false; + } + if(_validTouchStates.empty()) { + io.MousePos = {windowPos.x, windowPos.y}; + io.MouseClicked[0] = true; + } + _validTouchStates.push_back(input); + return true; +} + +bool GUI::touchUpdatedCallback(TouchInput input) { + if(_validTouchStates.empty()) { + return false; + } + ImGuiIO& io = ImGui::GetIO(); + + auto it = std::find_if( + _validTouchStates.cbegin(), + _validTouchStates.cend(), + [&](const TouchInput& state){ + return state.fingerId == input.fingerId && + state.touchDeviceId == input.touchDeviceId; + } + ); + + if (it == _validTouchStates.cbegin()) { + glm::vec2 windowPos = input.currentWindowCoordinates(); + io.MousePos = {windowPos.x, windowPos.y}; + io.MouseClicked[0] = true; + return true; + } + else if (it != _validTouchStates.cend()){ + return true; + } + return false; +} + +void GUI::touchExitCallback(TouchInput input) { + if (_validTouchStates.empty()) { + return; + } + + const auto found = std::find_if( + _validTouchStates.cbegin(), + _validTouchStates.cend(), + [&](const TouchInput& state){ + return state.fingerId == input.fingerId && + state.touchDeviceId == input.touchDeviceId; + } + ); + + if (found == _validTouchStates.cend()) { + return; + } + + ImGuiIO& io = ImGui::GetIO(); + _validTouchStates.erase(found); + if (_validTouchStates.empty()) { + glm::vec2 windowPos = input.currentWindowCoordinates(); + io.MousePos = {windowPos.x, windowPos.y}; + io.MouseClicked[0] = false; + } +} + + void GUI::render() { ImGui::SetNextWindowCollapsed(_isCollapsed); diff --git a/modules/touch/include/touchinteraction.h b/modules/touch/include/touchinteraction.h index 8faed8bbfb..1516d7a843 100644 --- a/modules/touch/include/touchinteraction.h +++ b/modules/touch/include/touchinteraction.h @@ -79,16 +79,14 @@ public: /* Main function call * 1 Checks if doubleTap occured - * 2 Goes through the guiMode() function - * 3 Continues if GUI isn't on - * 4 If the node in focus is large enough and all contact points have selected it, + * 2 If the node in focus is large enough and all contact points have selected it, * calls directControl() function for direct-manipulation - * 5 Updates std::vector _selected (only if LMA successfully + * 3 Updates std::vector _selected (only if LMA successfully * converged, avoids interaction to snap on LMA fails) - * 6 If directControl() wasn't called this frame, interpret the incoming + * 4 If directControl() wasn't called this frame, interpret the incoming * list and decide what type of interaction this frame should do - * 7 Compute the new total velocities after interaction - * 8 Evaluate if directControl should be called next frame- true if all contact points + * 5 Compute the new total velocities after interaction + * 6 Evaluate if directControl should be called next frame- true if all contact points * select the same node and said node is larger than _nodeRadiusThreshold */ @@ -114,11 +112,6 @@ public: void setCamera(Camera* camera); private: - /* Returns true if we have the GUI window open. If so, emulates the incoming touch - * input to a mouse such that we can interact with the GUI - */ - bool isGuiMode(glm::dvec2 screenPosition, size_t numFingers); - /* Function that calculates the new camera state such that it minimizes the L2 error * in screenspace * between contact points and surface coordinates projected to clip space using LMA @@ -181,10 +174,8 @@ private: properties::BoolProperty _panEnabled; properties::FloatProperty _interpretPan; properties::FloatProperty _slerpTime; - properties::IVec2Property _guiButton; properties::Vec4Property _friction; properties::FloatProperty _pickingRadiusMinimum; - properties::BoolProperty _ignoreGui; properties::FloatProperty _constTimeDecay_secs; #ifdef TOUCH_DEBUG_PROPERTIES @@ -220,7 +211,6 @@ private: bool _doubleTap = false; bool _zoomOutTap = false; bool _lmSuccess = true; - bool _guiON = false; std::vector _selected; SceneGraphNode* _pickingSelected = nullptr; DirectInputSolver _solver; @@ -242,4 +232,3 @@ private: } // openspace namespace #endif // __OPENSPACE_MODULE_TOUCH___TOUCH_INTERACTION___H__ - diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index b12795b9e6..ed5210f854 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -29,7 +29,6 @@ #include #endif -#include #include #include #include @@ -205,12 +204,6 @@ namespace { "" // @TODO Missing documentation }; - constexpr openspace::properties::Property::PropertyInfo GuiButtonSizeInfo = { - "GuiButtonSize", - "GUI button size in pixels", - "" // @TODO Missing documentation - }; - constexpr openspace::properties::Property::PropertyInfo FrictionInfo = { "Friction", "Friction for different interactions (orbit, zoom, roll, pan)", @@ -285,12 +278,6 @@ TouchInteraction::TouchInteraction() , _panEnabled(PanModeInfo, false) , _interpretPan(PanDeltaDistanceInfo, 0.015f, 0.f, 0.1f) , _slerpTime(SlerpTimeInfo, 3.f, 0.1f, 5.f) - , _guiButton( - GuiButtonSizeInfo, - glm::ivec2(32, 64), - glm::ivec2(8, 16), - glm::ivec2(128, 256) - ) , _friction( FrictionInfo, glm::vec4(0.025f, 0.025f, 0.02f, 0.02f), @@ -303,10 +290,6 @@ TouchInteraction::TouchInteraction() 0.f, 1.f ) - , _ignoreGui( // @TODO Missing documentation - { "Ignore GUI", "Disable GUI touch interaction", "" }, - false - ) , _vel{ glm::dvec2(0.0), 0.0, 0.0, glm::dvec2(0.0) } , _sensitivity{ glm::dvec2(0.08, 0.045), 12.0 /*4.0*/, 2.75, glm::dvec2(0.08, 0.045) } , _constTimeDecay_secs(ConstantTimeDecaySecsInfo, 1.75f, 0.1f, 4.0f) @@ -336,10 +319,8 @@ TouchInteraction::TouchInteraction() addProperty(_panEnabled); addProperty(_interpretPan); addProperty(_slerpTime); - addProperty(_guiButton); addProperty(_friction); addProperty(_pickingRadiusMinimum); - addProperty(_ignoreGui); #ifdef TOUCH_DEBUG_PROPERTIES addPropertySubOwner(_debugProperties); @@ -401,69 +382,36 @@ void TouchInteraction::updateStateFromInput(const std::vector& } size_t numFingers = list.size(); - if (!isGuiMode(pos, numFingers)) { - bool isTransitionBetweenModes = (_wasPrevModeDirectTouch != _directTouchMode); - if (isTransitionBetweenModes) { - _vel.orbit = glm::dvec2(0.0); - _vel.zoom = 0.0; - _vel.roll = 0.0; - _vel.pan = glm::dvec2(0.0); - resetAfterInput(); - } + bool isTransitionBetweenModes = (_wasPrevModeDirectTouch != _directTouchMode); + if (isTransitionBetweenModes) { + _vel.orbit = glm::dvec2(0.0); + _vel.zoom = 0.0; + _vel.roll = 0.0; + _vel.pan = glm::dvec2(0.0); + resetAfterInput(); + } - if (_directTouchMode && _selected.size() > 0 && numFingers == _selected.size()) { + if (_directTouchMode && _selected.size() > 0 && numFingers == _selected.size()) { #ifdef TOUCH_DEBUG_PROPERTIES - _debugProperties.interactionMode = "Direct"; + _debugProperties.interactionMode = "Direct"; #endif - directControl(list); - } - if (_lmSuccess) { - findSelectedNode(list); - } + directControl(list); + } + if (_lmSuccess) { + findSelectedNode(list); + } - if (!_directTouchMode) { + if (!_directTouchMode) { #ifdef TOUCH_DEBUG_PROPERTIES - _debugProperties.interactionMode = "Velocities"; + _debugProperties.interactionMode = "Velocities"; #endif - computeVelocities(list, lastProcessed); - } - - _wasPrevModeDirectTouch = _directTouchMode; - // evaluates if current frame is in directTouchMode (will be used next frame) - _directTouchMode = - (_currentRadius > _nodeRadiusThreshold && _selected.size() == numFingers); - } -} - -bool TouchInteraction::isGuiMode(glm::dvec2 screenPosition, size_t numFingers) { - if (_ignoreGui) { - return false; + computeVelocities(list, lastProcessed); } - ImGUIModule& module = *(global::moduleEngine.module()); - _guiON = module.gui.isEnabled(); - - if (_tap && numFingers == 1 && - std::abs(screenPosition.x) < _guiButton.value().x && - std::abs(screenPosition.y) < _guiButton.value().y) - { - // pressed invisible button - _guiON = !_guiON; - module.gui.setEnabled(_guiON); - - LINFO(fmt::format( - "GUI mode is {}. Inside box by: ({}%, {}%)", - _guiON ? "activated" : "deactivated", - static_cast(100 * (screenPosition.x / _guiButton.value().x)), - static_cast(100 * (screenPosition.y / _guiButton.value().y)) - )); - } - else if (_guiON) { - // emulate touch input as a mouse - module.touchInput = { _guiON, screenPosition, 1 }; - } - - return _guiON; + _wasPrevModeDirectTouch = _directTouchMode; + // evaluates if current frame is in directTouchMode (will be used next frame) + _directTouchMode = + (_currentRadius > _nodeRadiusThreshold && _selected.size() == numFingers); } void TouchInteraction::directControl(const std::vector& list) { @@ -506,11 +454,6 @@ void TouchInteraction::directControl(const std::vector& list) else { // prevents touch to infinitely be active (due to windows bridge case where event // doesnt get consumed sometimes when LMA fails to converge) - Touch touch; - touch.active = true; - touch.pos = glm::dvec2(0.0); - touch.action = 1; - global::moduleEngine.module()->touchInput = touch; resetAfterInput(); } } @@ -1204,24 +1147,8 @@ void TouchInteraction::resetAfterInput() { _vel.orbit = _lastVel.orbit * spinDelta; } } - // Reset emulated mouse values - ImGUIModule& module = *(global::moduleEngine.module()); - if (_guiON) { - bool activeLastFrame = module.touchInput.action; - module.touchInput.active = false; - if (activeLastFrame) { - module.touchInput.active = true; - module.touchInput.action = 0; - } - } - else { - module.touchInput.active = false; - module.touchInput.action = 0; - } _lmSuccess = true; - // Ensure that _guiON is consistent with properties in OnScreenGUI and - _guiON = module.gui.isEnabled(); // Reset variables _lastVel.orbit = glm::dvec2(0.0); @@ -1249,7 +1176,6 @@ void TouchInteraction::resetToDefault() { _centroidStillThreshold.set(0.0018f); _interpretPan.set(0.015f); _slerpTime.set(3.0f); - _guiButton.set(glm::ivec2(32, 64)); _friction.set(glm::vec4(0.025, 0.025, 0.02, 0.02)); } From d347733234786a2976b7e0542f07b4c1b8dca501 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 11 Mar 2020 10:09:23 -0600 Subject: [PATCH 18/67] Fixed documentation errors to finish consolidating satellite/sbdb code --- .../rendering/renderableorbitalkepler.cpp | 50 +----------- .../space/rendering/renderableorbitalkepler.h | 1 - .../space/rendering/renderablesatellites.cpp | 76 +++++++++++++++++- .../space/rendering/renderablesatellites.h | 2 +- .../space/rendering/renderablesmallbody.cpp | 77 ++++++++++++++++++- modules/space/rendering/renderablesmallbody.h | 2 +- 6 files changed, 154 insertions(+), 54 deletions(-) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index ab277b8ff5..d530f3f4c0 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -81,7 +81,7 @@ namespace { "Upper limit on the number of objects for this renderable, regardless of " "how many objects are contained in the data file" }; - + constexpr const char* KeyFile = "Path"; constexpr const char* KeyLineNum = "LineNumber"; } @@ -346,53 +346,7 @@ int RenderableOrbitalKepler::daysIntoGivenYear(int month, int dayOfMonth) { } return dayCount; } - -documentation::Documentation RenderableOrbitalKepler::Documentation() { - using namespace documentation; - return { - "RenderableOrbitalKepler", - "space_renderable_keplerian_orbitals", - { - { - SegmentsInfo.identifier, - new DoubleVerifier, - Optional::No, - SegmentsInfo.description - }, - { - UpperLimitInfo.identifier, - new IntVerifier, - Optional::Yes, - UpperLimitInfo.description - }, - { - PathInfo.identifier, - new StringVerifier, - Optional::No, - PathInfo.description - }, - { - LineWidthInfo.identifier, - new DoubleVerifier, - Optional::Yes, - LineWidthInfo.description - }, - { - LineColorInfo.identifier, - new DoubleVector3Verifier, - Optional::No, - LineColorInfo.description - }, - { - TrailFadeInfo.identifier, - new DoubleVerifier, - Optional::Yes, - TrailFadeInfo.description - } - } - }; -} - + RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _path(PathInfo) diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h index f9ed0fbf9e..e99b2c47a9 100644 --- a/modules/space/rendering/renderableorbitalkepler.h +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -47,7 +47,6 @@ public: bool isReady() const override; void render(const RenderData& data, RendererTasks& rendererTask) override; - static documentation::Documentation Documentation(); /** * Reads the provided data file and calls the KeplerTranslation::setKeplerElments * method with the correct values. If \p filename is a valid data file but contains diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 3904308407..83f8215fd0 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -53,10 +53,84 @@ namespace { "Path", "The file path to the TLE file to read" }; + static const openspace::properties::Property::PropertyInfo SegmentsInfo = { + "Segments", + "Segments", + "The number of segments to use for each orbit ellipse" + }; + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { + "LineWidth", + "Line Width", + "This value specifies the line width of the trail if the selected rendering " + "method includes lines. If the rendering mode is set to Points, this value is " + "ignored." + }; + constexpr openspace::properties::Property::PropertyInfo LineColorInfo = { + "Color", + "Color", + "This value determines the RGB main color for the lines and points of the trail." + }; + constexpr openspace::properties::Property::PropertyInfo TrailFadeInfo = { + "TrailFade", + "Trail Fade", + "This value determines how fast the trail fades and is an appearance property. " + }; + static const openspace::properties::Property::PropertyInfo UpperLimitInfo = { + "UpperLimit", + "Upper Limit", + "Upper limit on the number of objects for this renderable, regardless of " + "how many objects are contained in the data file" + }; } namespace openspace { - + +documentation::Documentation RenderableSatellites::Documentation() { + using namespace documentation; + return { + "RenderableSatellites", + "space_renderable_satellites", + { + { + SegmentsInfo.identifier, + new DoubleVerifier, + Optional::No, + SegmentsInfo.description + }, + { + UpperLimitInfo.identifier, + new IntVerifier, + Optional::Yes, + UpperLimitInfo.description + }, + { + PathInfo.identifier, + new StringVerifier, + Optional::No, + PathInfo.description + }, + { + LineWidthInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LineWidthInfo.description + }, + { + LineColorInfo.identifier, + new DoubleVector3Verifier, + Optional::No, + LineColorInfo.description + }, + { + TrailFadeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + TrailFadeInfo.description + } + } + }; +} + RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) { diff --git a/modules/space/rendering/renderablesatellites.h b/modules/space/rendering/renderablesatellites.h index 230aca2e2b..1bf2804216 100644 --- a/modules/space/rendering/renderablesatellites.h +++ b/modules/space/rendering/renderablesatellites.h @@ -42,7 +42,7 @@ class RenderableSatellites : public RenderableOrbitalKepler { public: RenderableSatellites(const ghoul::Dictionary& dictionary); void readDataFile(const std::string& filename); - //static documentation::Documentation Documentation(); + static documentation::Documentation Documentation(); }; } // namespace openspace diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index ad70e7afd8..97d6ed12ec 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -52,13 +52,86 @@ namespace { static const openspace::properties::Property::PropertyInfo PathInfo = { "Path", "Path", - "The file path to the SBDB file to read" + "The file path to the SBDB .csv file to read" + }; + static const openspace::properties::Property::PropertyInfo SegmentsInfo = { + "Segments", + "Segments", + "The number of segments to use for each orbit ellipse" + }; + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { + "LineWidth", + "Line Width", + "This value specifies the line width of the trail if the selected rendering " + "method includes lines. If the rendering mode is set to Points, this value is " + "ignored." + }; + constexpr openspace::properties::Property::PropertyInfo LineColorInfo = { + "Color", + "Color", + "This value determines the RGB main color for the lines and points of the trail." + }; + constexpr openspace::properties::Property::PropertyInfo TrailFadeInfo = { + "TrailFade", + "Trail Fade", + "This value determines how fast the trail fades and is an appearance property. " + }; + static const openspace::properties::Property::PropertyInfo UpperLimitInfo = { + "UpperLimit", + "Upper Limit", + "Upper limit on the number of objects for this renderable, regardless of " + "how many objects are contained in the data file" }; } namespace openspace { - +documentation::Documentation RenderableSmallBody::Documentation() { + using namespace documentation; + return { + "RenderableSmallBody", + "space_renderable_small_body", + { + { + SegmentsInfo.identifier, + new DoubleVerifier, + Optional::No, + SegmentsInfo.description + }, + { + UpperLimitInfo.identifier, + new IntVerifier, + Optional::Yes, + UpperLimitInfo.description + }, + { + PathInfo.identifier, + new StringVerifier, + Optional::No, + PathInfo.description + }, + { + LineWidthInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LineWidthInfo.description + }, + { + LineColorInfo.identifier, + new DoubleVector3Verifier, + Optional::No, + LineColorInfo.description + }, + { + TrailFadeInfo.identifier, + new DoubleVerifier, + Optional::Yes, + TrailFadeInfo.description + } + } + }; +} + RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) { diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index 5c385d32f6..818b1c172a 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -43,7 +43,7 @@ static double importAngleValue(const std::string& angle); class RenderableSmallBody : public RenderableOrbitalKepler { public: RenderableSmallBody(const ghoul::Dictionary& dictionary); - //static documentation::Documentation Documentation(); + static documentation::Documentation Documentation(); private: void readOrbitalParamsFromThisLine(int& fieldCount, std::streamoff& csvLine, From 6583520023919a696483a52490968cbef4f114d6 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 11 Mar 2020 10:13:26 -0600 Subject: [PATCH 19/67] Renamed main asteroid belt asset to be consistent with other data sets --- .../sssb/{main_asteroid_belt.asset => main_belt_asteroid.asset} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename data/assets/scene/solarsystem/sssb/{main_asteroid_belt.asset => main_belt_asteroid.asset} (100%) diff --git a/data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset similarity index 100% rename from data/assets/scene/solarsystem/sssb/main_asteroid_belt.asset rename to data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset From 865a247ee9ff92fbfa48f9a494b9f58e78e23380 Mon Sep 17 00:00:00 2001 From: GPayne Date: Wed, 11 Mar 2020 10:57:11 -0600 Subject: [PATCH 20/67] Added new assets for asteroids and comets --- data/assets/asteroids.scene | 37 +++++++++++++++++++ .../solarsystem/sssb/amor_asteroid.asset | 11 ++++++ .../solarsystem/sssb/apollo_asteroid.asset | 11 ++++++ .../solarsystem/sssb/aten_asteroid.asset | 11 ++++++ .../solarsystem/sssb/atira_asteroid.asset | 11 ++++++ .../solarsystem/sssb/centaur_asteroid.asset | 11 ++++++ .../solarsystem/sssb/chiron-type_comet.asset | 11 ++++++ .../solarsystem/sssb/encke-type_comet.asset | 11 ++++++ .../solarsystem/sssb/halley-type_comet.asset | 11 ++++++ .../sssb/hyperbolic_asteroid.asset | 11 ++++++ .../solarsystem/sssb/hyperbolic_comet.asset | 11 ++++++ .../sssb/inner_main_belt_asteroid.asset | 11 ++++++ .../sssb/jupiter-family_comet.asset | 11 ++++++ .../sssb/jupiter_trojan_asteroid.asset | 11 ++++++ .../solarsystem/sssb/main_belt_asteroid.asset | 8 ++-- .../sssb/mars-crossing_asteroid.asset | 11 ++++++ .../sssb/outer_main_belt_asteroid.asset | 11 ++++++ .../solarsystem/sssb/parabolic_asteroid.asset | 11 ++++++ .../sssb/transneptunian_object_asteroid.asset | 11 ++++++ 19 files changed, 228 insertions(+), 4 deletions(-) create mode 100644 data/assets/asteroids.scene create mode 100644 data/assets/scene/solarsystem/sssb/amor_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/apollo_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/aten_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/atira_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/centaur_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/chiron-type_comet.asset create mode 100644 data/assets/scene/solarsystem/sssb/encke-type_comet.asset create mode 100644 data/assets/scene/solarsystem/sssb/halley-type_comet.asset create mode 100644 data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset create mode 100644 data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset create mode 100644 data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset create mode 100644 data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset diff --git a/data/assets/asteroids.scene b/data/assets/asteroids.scene new file mode 100644 index 0000000000..8ac40d71fa --- /dev/null +++ b/data/assets/asteroids.scene @@ -0,0 +1,37 @@ +asset.require('./base') + +local earthAsset = asset.require('scene/solarsystem/planets/earth/earth') + +asset.require('scene/solarsystem/sssb/amor_asteroid') +asset.require('scene/solarsystem/sssb/apollo_asteroid') +asset.require('scene/solarsystem/sssb/aten_asteroid') +asset.require('scene/solarsystem/sssb/atira_asteroid') +asset.require('scene/solarsystem/sssb/centaur_asteroid') +asset.require('scene/solarsystem/sssb/chrion-type_comet') +asset.require('scene/solarsystem/sssb/encke-type_comet') +asset.require('scene/solarsystem/sssb/halley-type_comet') +asset.require('scene/solarsystem/sssb/hyperbolic_asteroid') +asset.require('scene/solarsystem/sssb/hyperbolic_comet') +asset.require('scene/solarsystem/sssb/inner_main_belt_asteroid') +asset.require('scene/solarsystem/sssb/jupiter_trojan_asteroid') +asset.require('scene/solarsystem/sssb/jupiter-family_comet') +-- asset.require('scene/solarsystem/sssb/main_belt_asteroid') +asset.require('scene/solarsystem/sssb/mars-crossing_asteroid') +asset.require('scene/solarsystem/sssb/outer_main_belt_asteroid') +asset.require('scene/solarsystem/sssb/parabolic_asteroid') +-- asset.require('scene/solarsystem/sssb/pha') +asset.require('scene/solarsystem/sssb/transneptunian_object_asteroid') + +asset.onInitialize(function () + local now = openspace.time.currentWallTime() + -- Jump back one day to be able to show complete weather data on Earth. + openspace.time.setTime(openspace.time.advancedTime(now, "-1d")) + + openspace.globebrowsing.goToGeo("Earth", 58.5877, 16.1924, 20000000) + + openspace.markInterestingNodes({ "Earth", "Mars", "Moon", "Sun" }) +end) + +asset.onDeinitialize(function () + openspace.removeInterestingNodes({ "Earth", "Mars", "Moon", "Sun" }) +end) diff --git a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset new file mode 100644 index 0000000000..546d3f3d96 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'amor_asteroid', 'sssb_data_amor_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset new file mode 100644 index 0000000000..5c47ed6222 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'apollo_asteroid', 'sssb_data_apollo_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset new file mode 100644 index 0000000000..a015070eb6 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'aten_asteroid', 'sssb_data_aten_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset new file mode 100644 index 0000000000..0e55e6d628 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'atira_asteroid', 'sssb_data_atira_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset new file mode 100644 index 0000000000..d60f5a93dd --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'centaur_asteroid', 'sssb_data_centaur_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset new file mode 100644 index 0000000000..ca9365f680 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'chiron-type_comet', 'sssb_data_chiron-type_comet') +local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset new file mode 100644 index 0000000000..6f60be8d2c --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'encke-type_comet', 'sssb_data_encke-type_comet') +local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset new file mode 100644 index 0000000000..b8f3d80671 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'halley-type_comet', 'sssb_data_halley-type_comet') +local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset b/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset new file mode 100644 index 0000000000..9b052b26e6 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'hyperbolic_asteroid', 'sssb_data_hyperbolic_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset b/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset new file mode 100644 index 0000000000..34787fee34 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'hyperbolic_comet', 'sssb_data_hyperbolic_comet') +local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset new file mode 100644 index 0000000000..b769e620ef --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'inner_main_belt_asteroid', 'sssb_data_inner_main_belt_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset new file mode 100644 index 0000000000..29e05584a7 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter-family_comet', 'sssb_data_jupiter-family_comet') +local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset new file mode 100644 index 0000000000..ec6298b978 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter_trojan_asteroid', 'sssb_data_jupiter_trojan_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset index 93f11b035a..318591bbfb 100644 --- a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset @@ -1,11 +1,11 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') -local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main asteroid belt', 'sssb_data_main_belt_asteroid') -local object = sharedSssb.createSssbGroupObject("sssb_data_main_belt_asteroid.csv", filepath, { 0.9, 0.3, 0.1 }) +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main_belt_asteroid', 'sssb_data_main_belt_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 40 -object.Renderable.Fade = 3 +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 object.Renderable.UpperLimit = 50000 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset new file mode 100644 index 0000000000..8810ad535b --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'mars-crossing_asteroid', 'sssb_data_mars-crossing_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset new file mode 100644 index 0000000000..a71c798ce4 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'outer_main_belt_asteroid', 'sssb_data_outer_main_belt_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset b/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset new file mode 100644 index 0000000000..0bcd8381c9 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'parabolic_asteroid', 'sssb_data_parabolic_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_parabolic_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset new file mode 100644 index 0000000000..ff43a1b296 --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset @@ -0,0 +1,11 @@ +local assetHelper = asset.require('util/asset_helper') +local sharedSssb = asset.require('./sssb_shared') + +local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'transneptunian_object_asteroid', 'sssb_data_transneptunian_object_asteroid') +local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +object.Renderable.Enabled = false +object.Renderable.Segments = 50 +object.Renderable.Fade = 5 +object.Renderable.UpperLimit = 50000 + +assetHelper.registerSceneGraphNodesAndExport(asset, { object }) From c9e35cbee4c13907c32225df6c7f921d6bc6a5e9 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Thu, 12 Mar 2020 15:12:29 +0100 Subject: [PATCH 21/67] Changed back from windows API calls to stl calls for timings Should be the same under-the-hood but produces more consistent code --- modules/touch/src/win32_touch.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 9796247790..948a242941 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -40,12 +40,13 @@ #define ENABLE_DIRECTMSG namespace { + using namespace std::chrono; constexpr const char* _loggerCat = "win32_touch"; HHOOK gTouchHook = nullptr; std::thread* gMouseHookThread; HHOOK gMouseHook = nullptr; bool gStarted = false; - std::chrono::microseconds gStartTime = std::chrono::microseconds(0); + microseconds gStartTime = microseconds(0); const long long gFrequency = []() -> long long { LARGE_INTEGER frequency; QueryPerformanceFrequency(&frequency); @@ -84,9 +85,13 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { break; } - using namespace std::chrono; - const microseconds timestamp = duration( - info.PerformanceCount * std::micro::den / gFrequency) - gStartTime; + //Implementation from microsoft STL of high_resolution_clock(steady_clock): + const long long freq = gFrequency; + const long long whole = (info.PerformanceCount / freq) * std::micro::den; + const long long part = (info.PerformanceCount % freq) * + std::micro::den / freq; + const microseconds timestamp = + duration(whole + part) - gStartTime; RECT rect; GetClientRect(pStruct->hwnd, reinterpret_cast(&rect)); @@ -218,11 +223,8 @@ Win32TouchHook::Win32TouchHook(void* nativeWindow) if (!gStarted) { gStarted = true; - LARGE_INTEGER count; - QueryPerformanceCounter(&count); - gStartTime = std::chrono::duration( - count.QuadPart * std::micro::den / gFrequency - ); + gStartTime = + duration_cast(high_resolution_clock::now().time_since_epoch()); #ifdef ENABLE_TUIOMESSAGES gTuioServer = new TUIO::TuioServer("localhost", 3333); TUIO::TuioTime::initSession(); From bfdfd44910ff6b4453a398193633fd502bcfae7d Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 12 Mar 2020 13:40:28 -0600 Subject: [PATCH 22/67] Added GUI name title for sssb objects --- data/assets/asteroids.scene | 2 +- data/assets/default.scene | 2 -- data/assets/scene/solarsystem/sssb/amor_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/apollo_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/aten_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/atira_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/centaur_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/chiron-type_comet.asset | 2 +- data/assets/scene/solarsystem/sssb/encke-type_comet.asset | 2 +- data/assets/scene/solarsystem/sssb/halley-type_comet.asset | 2 +- data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset | 2 +- .../scene/solarsystem/sssb/inner_main_belt_asteroid.asset | 2 +- .../assets/scene/solarsystem/sssb/jupiter-family_comet.asset | 2 +- .../scene/solarsystem/sssb/jupiter_trojan_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset | 2 +- .../scene/solarsystem/sssb/mars-crossing_asteroid.asset | 2 +- .../scene/solarsystem/sssb/outer_main_belt_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/sssb_shared.asset | 5 +++-- .../solarsystem/sssb/transneptunian_object_asteroid.asset | 2 +- openspace.cfg | 3 ++- 22 files changed, 24 insertions(+), 24 deletions(-) diff --git a/data/assets/asteroids.scene b/data/assets/asteroids.scene index 8ac40d71fa..b53256a032 100644 --- a/data/assets/asteroids.scene +++ b/data/assets/asteroids.scene @@ -15,7 +15,7 @@ asset.require('scene/solarsystem/sssb/hyperbolic_comet') asset.require('scene/solarsystem/sssb/inner_main_belt_asteroid') asset.require('scene/solarsystem/sssb/jupiter_trojan_asteroid') asset.require('scene/solarsystem/sssb/jupiter-family_comet') --- asset.require('scene/solarsystem/sssb/main_belt_asteroid') +asset.require('scene/solarsystem/sssb/main_belt_asteroid') asset.require('scene/solarsystem/sssb/mars-crossing_asteroid') asset.require('scene/solarsystem/sssb/outer_main_belt_asteroid') asset.require('scene/solarsystem/sssb/parabolic_asteroid') diff --git a/data/assets/default.scene b/data/assets/default.scene index d3736bd8b9..31a2e83d4f 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -2,8 +2,6 @@ asset.require('./base') local earthAsset = asset.require('scene/solarsystem/planets/earth/earth') asset.require('scene/solarsystem/planets/earth/satellites/satellites.asset') -asset.require('scene/solarsystem/sssb/pha') -asset.require('scene/solarsystem/sssb/main_asteroid_belt') asset.onInitialize(function () local now = openspace.time.currentWallTime() diff --git a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset index 546d3f3d96..9c3eda19cd 100644 --- a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'amor_asteroid', 'sssb_data_amor_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', "Amor Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset index 5c47ed6222..d5b1bcb556 100644 --- a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'apollo_asteroid', 'sssb_data_apollo_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', "Apollo Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset index a015070eb6..aca1505878 100644 --- a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'aten_asteroid', 'sssb_data_aten_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', "Aten Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset index 0e55e6d628..e7787b1a0b 100644 --- a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'atira_asteroid', 'sssb_data_atira_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', "Atira Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset index d60f5a93dd..df9d72c557 100644 --- a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'centaur_asteroid', 'sssb_data_centaur_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', "Centaur Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset index ca9365f680..6d5a81b69b 100644 --- a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'chiron-type_comet', 'sssb_data_chiron-type_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', "Chiron-type Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset index 6f60be8d2c..1f97ac9624 100644 --- a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'encke-type_comet', 'sssb_data_encke-type_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', "Encke-type Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset index b8f3d80671..20a6542e42 100644 --- a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'halley-type_comet', 'sssb_data_halley-type_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', "Halley-type Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset b/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset index 9b052b26e6..4ed8b01d22 100644 --- a/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'hyperbolic_asteroid', 'sssb_data_hyperbolic_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_asteroid.csv', "Hyperbolic Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset b/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset index 34787fee34..b0395c3fa5 100644 --- a/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset +++ b/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'hyperbolic_comet', 'sssb_data_hyperbolic_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_comet.csv', "Hyperbolic Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset index b769e620ef..96077eb6b3 100644 --- a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'inner_main_belt_asteroid', 'sssb_data_inner_main_belt_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', "Inner Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset index 29e05584a7..6a67ad6052 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter-family_comet', 'sssb_data_jupiter-family_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', "Jupiter-family Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset index ec6298b978..e52e4d863e 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter_trojan_asteroid', 'sssb_data_jupiter_trojan_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', "Jupiter Trojan Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset index 318591bbfb..4bd90cd824 100644 --- a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main_belt_asteroid', 'sssb_data_main_belt_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', "Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset index 8810ad535b..afd4e39721 100644 --- a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'mars-crossing_asteroid', 'sssb_data_mars-crossing_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', "Mars-crossing Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset index a71c798ce4..ebe3185947 100644 --- a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'outer_main_belt_asteroid', 'sssb_data_outer_main_belt_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', "Outer Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset b/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset index 0bcd8381c9..e80ca51568 100644 --- a/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'parabolic_asteroid', 'sssb_data_parabolic_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_parabolic_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_parabolic_asteroid.csv', "Parabolic Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/data/assets/scene/solarsystem/sssb/sssb_shared.asset b/data/assets/scene/solarsystem/sssb/sssb_shared.asset index d67679baff..6a5325acbe 100644 --- a/data/assets/scene/solarsystem/sssb/sssb_shared.asset +++ b/data/assets/scene/solarsystem/sssb/sssb_shared.asset @@ -13,7 +13,7 @@ function downloadSssbDatabaseFile(sceneAsset, name, identifier) }) end -local createSssbGroupObject = function(filename, sssbFolder, trailColor) +local createSssbGroupObject = function(filename, guiName, sssbFolder, trailColor) assert(filename, "'filename' needs to be provided") assert(sssbFolder, "'sssbFolder' needs to be provided") trailColor = trailColor or { 0.75, 0.1, 0.1 } @@ -30,7 +30,8 @@ local createSssbGroupObject = function(filename, sssbFolder, trailColor) Fade = 0.5, }, GUI = { - Path = "/Solar System/Small Solar System Body" + Path = "/Solar System/Small Solar System Body", + Name = guiName } } end diff --git a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset index ff43a1b296..a05340cd38 100644 --- a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'transneptunian_object_asteroid', 'sssb_data_transneptunian_object_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', "Transneptunian Object Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.Fade = 5 diff --git a/openspace.cfg b/openspace.cfg index c73d8154f3..cd8c6a8742 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -45,7 +45,8 @@ SGCTConfig = sgct.config.single{} -- Sets the scene that is to be loaded by OpenSpace. A scene file is a description -- of all entities that will be visible during an instance of OpenSpace -Asset = "default" +Asset = "asteroids" +-- Asset = "default" -- Asset = "default_full" -- Asset = "newhorizons" -- Asset = "rosetta" From 9017656f9b0e5ffc1a1f82c7132c66dbb4be9ef5 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 12 Mar 2020 13:49:12 -0600 Subject: [PATCH 23/67] Fixed typo in asset name --- data/assets/asteroids.scene | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/asteroids.scene b/data/assets/asteroids.scene index b53256a032..0aae35a733 100644 --- a/data/assets/asteroids.scene +++ b/data/assets/asteroids.scene @@ -7,7 +7,7 @@ asset.require('scene/solarsystem/sssb/apollo_asteroid') asset.require('scene/solarsystem/sssb/aten_asteroid') asset.require('scene/solarsystem/sssb/atira_asteroid') asset.require('scene/solarsystem/sssb/centaur_asteroid') -asset.require('scene/solarsystem/sssb/chrion-type_comet') +asset.require('scene/solarsystem/sssb/chiron-type_comet') asset.require('scene/solarsystem/sssb/encke-type_comet') asset.require('scene/solarsystem/sssb/halley-type_comet') asset.require('scene/solarsystem/sssb/hyperbolic_asteroid') From 1ac7d20708dbc99bb66c473d835e691a54fecaae Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Thu, 12 Mar 2020 15:03:23 -0600 Subject: [PATCH 24/67] Updated pha asset with Gui name --- data/assets/scene/solarsystem/sssb/pha.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/scene/solarsystem/sssb/pha.asset b/data/assets/scene/solarsystem/sssb/pha.asset index 5ba2b2e4eb..7ec1d16ae4 100644 --- a/data/assets/scene/solarsystem/sssb/pha.asset +++ b/data/assets/scene/solarsystem/sssb/pha.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'pha', 'sssb_data_pha') -local object = sharedSssb.createSssbGroupObject("sssb_data_pha.csv", filepath, { 0.75, 0.2, 0.2 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_pha.csv', "Potentially Hazardous Asteroids", filepath, { 0.75, 0.2, 0.2 }) object.Renderable.Enabled = false assetHelper.registerSceneGraphNodesAndExport(asset, { object }) From ab42e97b2d9b9c31562bffdbcc301615197774d4 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 19 Mar 2020 09:17:51 -0600 Subject: [PATCH 25/67] Deleted 3 asteroid/comet data sets that are invalid for periodic orbits --- data/assets/asteroids.scene | 5 +---- .../scene/solarsystem/sssb/hyperbolic_asteroid.asset | 11 ----------- .../scene/solarsystem/sssb/hyperbolic_comet.asset | 11 ----------- .../scene/solarsystem/sssb/parabolic_asteroid.asset | 11 ----------- 4 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset delete mode 100644 data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset delete mode 100644 data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset diff --git a/data/assets/asteroids.scene b/data/assets/asteroids.scene index 0aae35a733..e68e5a87af 100644 --- a/data/assets/asteroids.scene +++ b/data/assets/asteroids.scene @@ -10,17 +10,14 @@ asset.require('scene/solarsystem/sssb/centaur_asteroid') asset.require('scene/solarsystem/sssb/chiron-type_comet') asset.require('scene/solarsystem/sssb/encke-type_comet') asset.require('scene/solarsystem/sssb/halley-type_comet') -asset.require('scene/solarsystem/sssb/hyperbolic_asteroid') -asset.require('scene/solarsystem/sssb/hyperbolic_comet') asset.require('scene/solarsystem/sssb/inner_main_belt_asteroid') asset.require('scene/solarsystem/sssb/jupiter_trojan_asteroid') asset.require('scene/solarsystem/sssb/jupiter-family_comet') asset.require('scene/solarsystem/sssb/main_belt_asteroid') asset.require('scene/solarsystem/sssb/mars-crossing_asteroid') asset.require('scene/solarsystem/sssb/outer_main_belt_asteroid') -asset.require('scene/solarsystem/sssb/parabolic_asteroid') --- asset.require('scene/solarsystem/sssb/pha') asset.require('scene/solarsystem/sssb/transneptunian_object_asteroid') +asset.require('scene/solarsystem/sssb/pha') asset.onInitialize(function () local now = openspace.time.currentWallTime() diff --git a/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset b/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset deleted file mode 100644 index 4ed8b01d22..0000000000 --- a/data/assets/scene/solarsystem/sssb/hyperbolic_asteroid.asset +++ /dev/null @@ -1,11 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local sharedSssb = asset.require('./sssb_shared') - -local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'hyperbolic_asteroid', 'sssb_data_hyperbolic_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_asteroid.csv', "Hyperbolic Asteroid", filepath, { 0.9, 0.3, 0.1 }) -object.Renderable.Enabled = false -object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 - -assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset b/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset deleted file mode 100644 index b0395c3fa5..0000000000 --- a/data/assets/scene/solarsystem/sssb/hyperbolic_comet.asset +++ /dev/null @@ -1,11 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local sharedSssb = asset.require('./sssb_shared') - -local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'hyperbolic_comet', 'sssb_data_hyperbolic_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_hyperbolic_comet.csv', "Hyperbolic Comet", filepath, { 0.9, 0.3, 0.1 }) -object.Renderable.Enabled = false -object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 - -assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset b/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset deleted file mode 100644 index e80ca51568..0000000000 --- a/data/assets/scene/solarsystem/sssb/parabolic_asteroid.asset +++ /dev/null @@ -1,11 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local sharedSssb = asset.require('./sssb_shared') - -local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'parabolic_asteroid', 'sssb_data_parabolic_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_parabolic_asteroid.csv', "Parabolic Asteroid", filepath, { 0.9, 0.3, 0.1 }) -object.Renderable.Enabled = false -object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 - -assetHelper.registerSceneGraphNodesAndExport(asset, { object }) From f2aea512c1df35c898e92a5853489196a5930b48 Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 20 Mar 2020 13:59:35 -0600 Subject: [PATCH 26/67] Updated assets with renderable trail params specific to content of each --- data/assets/scene/solarsystem/sssb/amor_asteroid.asset | 3 +-- data/assets/scene/solarsystem/sssb/apollo_asteroid.asset | 3 +-- data/assets/scene/solarsystem/sssb/aten_asteroid.asset | 3 +-- data/assets/scene/solarsystem/sssb/atira_asteroid.asset | 3 +-- data/assets/scene/solarsystem/sssb/centaur_asteroid.asset | 3 +-- data/assets/scene/solarsystem/sssb/chiron-type_comet.asset | 3 +-- data/assets/scene/solarsystem/sssb/encke-type_comet.asset | 3 +-- data/assets/scene/solarsystem/sssb/halley-type_comet.asset | 3 +-- .../scene/solarsystem/sssb/inner_main_belt_asteroid.asset | 3 +-- .../assets/scene/solarsystem/sssb/jupiter-family_comet.asset | 5 ++--- .../scene/solarsystem/sssb/jupiter_trojan_asteroid.asset | 3 +-- data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset | 2 +- .../scene/solarsystem/sssb/mars-crossing_asteroid.asset | 3 +-- .../scene/solarsystem/sssb/outer_main_belt_asteroid.asset | 3 +-- data/assets/scene/solarsystem/sssb/pha.asset | 2 ++ data/assets/scene/solarsystem/sssb/sssb_shared.asset | 2 +- .../solarsystem/sssb/transneptunian_object_asteroid.asset | 5 ++--- 17 files changed, 20 insertions(+), 32 deletions(-) diff --git a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset index 9c3eda19cd..be94836b0d 100644 --- a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'amor_asteroid', 'ss local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', "Amor Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 11 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset index d5b1bcb556..43a2c217fc 100644 --- a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'apollo_asteroid', ' local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', "Apollo Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 10 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset index aca1505878..f313e9f665 100644 --- a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'aten_asteroid', 'ss local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', "Aten Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset index e7787b1a0b..4af2856b5b 100644 --- a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'atira_asteroid', 's local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', "Atira Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 25 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset index df9d72c557..9aae1b46c4 100644 --- a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'centaur_asteroid', local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', "Centaur Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset index 6d5a81b69b..ef4f4ef2c3 100644 --- a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'chiron-type_comet', local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', "Chiron-type Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 25 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset index 1f97ac9624..3a006f8b52 100644 --- a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'encke-type_comet', local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', "Encke-type Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 23 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset index 20a6542e42..58e57ef93b 100644 --- a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'halley-type_comet', local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', "Halley-type Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset index 96077eb6b3..92914e37d1 100644 --- a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'inner_main_belt_ast local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', "Inner Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 0.5 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset index 6a67ad6052..b7ac48e699 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset @@ -4,8 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter-family_comet', 'sssb_data_jupiter-family_comet') local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', "Jupiter-family Comet", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.Segments = 500 +object.Renderable.TrailFade = 28 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset index e52e4d863e..0bc7fae4fb 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter_trojan_aste local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', "Jupiter Trojan Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 5 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset index 4bd90cd824..5b871d5b20 100644 --- a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset @@ -5,7 +5,7 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main_belt_asteroid' local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', "Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 +object.Renderable.TrailFade = 0.1 object.Renderable.UpperLimit = 50000 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset index afd4e39721..c6a12efe99 100644 --- a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'mars-crossing_aster local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', "Mars-crossing Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 13 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset index ebe3185947..5d9816c6bc 100644 --- a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset @@ -5,7 +5,6 @@ local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'outer_main_belt_ast local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', "Outer Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.TrailFade = 2 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/pha.asset b/data/assets/scene/solarsystem/sssb/pha.asset index 7ec1d16ae4..b8d116fae3 100644 --- a/data/assets/scene/solarsystem/sssb/pha.asset +++ b/data/assets/scene/solarsystem/sssb/pha.asset @@ -4,5 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'pha', 'sssb_data_pha') local object = sharedSssb.createSssbGroupObject('sssb_data_pha.csv', "Potentially Hazardous Asteroids", filepath, { 0.75, 0.2, 0.2 }) object.Renderable.Enabled = false +object.Renderable.Segments = 100 +object.Renderable.TrailFade = 17 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/sssb_shared.asset b/data/assets/scene/solarsystem/sssb/sssb_shared.asset index 6a5325acbe..ae05a97c6e 100644 --- a/data/assets/scene/solarsystem/sssb/sssb_shared.asset +++ b/data/assets/scene/solarsystem/sssb/sssb_shared.asset @@ -27,7 +27,7 @@ local createSssbGroupObject = function(filename, guiName, sssbFolder, trailColor Path = sssbFolder.."/"..filename, Segments = 200, Color = trailColor, - Fade = 0.5, + TrailFade = 0.5, }, GUI = { Path = "/Solar System/Small Solar System Body", diff --git a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset index a05340cd38..4a01875b7b 100644 --- a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset @@ -4,8 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'transneptunian_object_asteroid', 'sssb_data_transneptunian_object_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', "Transneptunian Object Asteroid", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 -object.Renderable.Fade = 5 -object.Renderable.UpperLimit = 50000 +object.Renderable.Segments = 150 +object.Renderable.TrailFade = 10 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) From bdf859cd3c6b914dce2772e5936f5cd942fe84eb Mon Sep 17 00:00:00 2001 From: GPayne Date: Fri, 20 Mar 2020 17:27:39 -0600 Subject: [PATCH 27/67] Modified sbdb file read to handle line errors while keeping other data lines --- .../rendering/renderableorbitalkepler.cpp | 8 +-- .../space/rendering/renderableorbitalkepler.h | 3 + .../space/rendering/renderablesmallbody.cpp | 70 +++++++++++++------ 3 files changed, 54 insertions(+), 27 deletions(-) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index d530f3f4c0..6efa17e4a4 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -391,20 +391,14 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio else { _appearance.lineWidth = 2.0; } - - auto reinitializeTrailBuffers = [this]() { - initializeGL(); - }; - + reinitializeTrailBuffers = std::function([this] { initializeGL(); }); _path.onChange(reinitializeTrailBuffers); _nSegments.onChange(reinitializeTrailBuffers); - _upperLimit.onChange(reinitializeTrailBuffers); addPropertySubOwner(_appearance); addProperty(_path); addProperty(_nSegments); addProperty(_opacity); - addProperty(_upperLimit); setRenderBin(Renderable::RenderBin::Overlay); } diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h index e99b2c47a9..65fad29b56 100644 --- a/modules/space/rendering/renderableorbitalkepler.h +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -68,6 +68,8 @@ protected: double epochFromSubstring(const std::string& epochString); double epochFromYMDdSubstring(const std::string& epochString); int daysIntoGivenYear(int month, int dayOfMonth); + std::function reinitializeTrailBuffers; + const std::vector LeapYears = { 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, @@ -105,6 +107,7 @@ protected: const double convertDaysToSecs = 86400.; std::vector _data; properties::UIntProperty _upperLimit; + properties::Property::OnChangeHandle _upperLimitCallbackHandle; private: struct Vertex { diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 97d6ed12ec..7a1b018f0c 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -135,6 +135,8 @@ documentation::Documentation RenderableSmallBody::Documentation() { RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) { + _upperLimitCallbackHandle = _upperLimit.onChange(reinitializeTrailBuffers); + addProperty(_upperLimit); } void RenderableSmallBody::readDataFile(const std::string& filename) { @@ -168,8 +170,12 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { std::getline(file, line); // get rid of first line (header) numberOfLines -= 1; if (_upperLimit == 0 || _upperLimit > numberOfLines) { - //If limit wasn't specified in dictionary, set to lines in file (-header) + //If a limit wasn't specified in dictionary, set it to # lines in file + // minus the header line (but temporarily disable callback to avoid 2nd call) + _upperLimit.removeOnChange(_upperLimitCallbackHandle); + _upperLimit.setMaxValue(numberOfLines); _upperLimit = static_cast(numberOfLines); + _upperLimitCallbackHandle = _upperLimit.onChange(reinitializeTrailBuffers); } else { lineSkipFraction = static_cast(_upperLimit) / @@ -184,31 +190,48 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { return; } - for (csvLine = 1; csvLine <= numberOfLines; csvLine++) { + unsigned int sequentialLineErrors = 0; + for (csvLine = 1; csvLine <= numberOfLines; csvLine++, sequentialLineErrors++) { currLineFraction = static_cast(csvLine - 1) * lineSkipFraction; currLineCount = static_cast(currLineFraction); if (currLineCount > lastLineCount) { - readOrbitalParamsFromThisLine(fieldCount, csvLine, file); + try { + readOrbitalParamsFromThisLine(fieldCount, csvLine, file); + sequentialLineErrors = 0; + } + catch (std::invalid_argument&) { + const char* errMsg = "Unable to convert field {} to double value "\ + "(invalid_argument exception) at line {}/{} of {}"; + LERROR(fmt::format( + errMsg, + fieldCount, csvLine + 1, numberOfLines, filename + )); + } + catch (std::out_of_range&) { + const char* errMsg = "Unable to convert field {} to double value "\ + "(out_of_range exception) at line {}/{} of {}"; + LERROR(fmt::format( + errMsg, + fieldCount, csvLine + 1, numberOfLines, filename + )); + } + catch (std::ios_base::failure& f) { + throw f; + } + + if (sequentialLineErrors == 4) { + _data.clear(); + _sbNames.clear(); + LERROR(fmt::format( + "Abandoning data file {} (too many sequential line errors).", + filename + )); + break; + } } lastLineCount = currLineCount; } } - catch (std::invalid_argument&) { - const char* errMsg = "Unable to convert field {} to double value "\ - "(invalid_argument exception) at line {}/{} of {}"; - LERROR(fmt::format( - errMsg, - fieldCount, csvLine + 1, numberOfLines, filename - )); - } - catch (std::out_of_range&) { - const char* errMsg = "Unable to convert field {} to double value "\ - "(out_of_range exception) at line {}/{} of {}"; - LERROR(fmt::format( - errMsg, - fieldCount, csvLine + 1, numberOfLines, filename - )); - } catch (std::ios_base::failure&) { const char* errMsg = "File read exception (ios_base::failure) while trying "\ "to read field {} at line {}/{} of {}"; @@ -225,11 +248,18 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, std::streamoff& csvLine, std::ifstream& file) { + const int numDataFields = 8; std::string name; std::string field; - fieldCount = 0; KeplerParameters keplerElements; + //If there was a read/conversion error in the previous line, then read the remainder + // of that line and throw it out first before proceeding with the next line. + if (fieldCount != (numDataFields + 1) && csvLine != 1) { + std::getline(file, field); + } + fieldCount = 0; + // Object designator string std::getline(file, name, ','); fieldCount++; From 07c8efc8f6620a6f82f17b239457f8e9bcc16168 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Tue, 24 Mar 2020 14:00:47 -0600 Subject: [PATCH 28/67] Update data/assets/scene/solarsystem/sssb/sssb_shared.asset Eliminated tab Co-Authored-By: Micah Acinapura --- data/assets/scene/solarsystem/sssb/sssb_shared.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/scene/solarsystem/sssb/sssb_shared.asset b/data/assets/scene/solarsystem/sssb/sssb_shared.asset index ae05a97c6e..39e60ee3c3 100644 --- a/data/assets/scene/solarsystem/sssb/sssb_shared.asset +++ b/data/assets/scene/solarsystem/sssb/sssb_shared.asset @@ -31,7 +31,7 @@ local createSssbGroupObject = function(filename, guiName, sssbFolder, trailColor }, GUI = { Path = "/Solar System/Small Solar System Body", - Name = guiName + Name = guiName } } end From 0a2263cbb4cf133e5fc436d8bcdd058ec0cf63c3 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Tue, 24 Mar 2020 14:01:15 -0600 Subject: [PATCH 29/67] Update data/assets/scene/solarsystem/sssb/sssb_shared.asset Improved GUI name Co-Authored-By: Micah Acinapura --- data/assets/scene/solarsystem/sssb/sssb_shared.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/scene/solarsystem/sssb/sssb_shared.asset b/data/assets/scene/solarsystem/sssb/sssb_shared.asset index 39e60ee3c3..ea494d0fff 100644 --- a/data/assets/scene/solarsystem/sssb/sssb_shared.asset +++ b/data/assets/scene/solarsystem/sssb/sssb_shared.asset @@ -30,7 +30,7 @@ local createSssbGroupObject = function(filename, guiName, sssbFolder, trailColor TrailFade = 0.5, }, GUI = { - Path = "/Solar System/Small Solar System Body", + Path = "/Solar System/Small Bodies", Name = guiName } } From 4f6d9836d8720be518a89db88396192d9e650a39 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 24 Mar 2020 14:17:23 -0600 Subject: [PATCH 30/67] Corrected plurality of GUI names --- data/assets/scene/solarsystem/sssb/amor_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/apollo_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/aten_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/atira_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/centaur_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/chiron-type_comet.asset | 2 +- data/assets/scene/solarsystem/sssb/encke-type_comet.asset | 2 +- data/assets/scene/solarsystem/sssb/halley-type_comet.asset | 2 +- .../scene/solarsystem/sssb/inner_main_belt_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset | 2 +- .../assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset | 2 +- .../scene/solarsystem/sssb/outer_main_belt_asteroid.asset | 2 +- .../scene/solarsystem/sssb/transneptunian_object_asteroid.asset | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset index be94836b0d..7ab07f28a9 100644 --- a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'amor_asteroid', 'sssb_data_amor_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', "Amor Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', "Amor Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 11 diff --git a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset index 43a2c217fc..9b36a44658 100644 --- a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'apollo_asteroid', 'sssb_data_apollo_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', "Apollo Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', "Apollo Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 10 diff --git a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset index f313e9f665..591320400f 100644 --- a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'aten_asteroid', 'sssb_data_aten_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', "Aten Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', "Aten Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 18 diff --git a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset index 4af2856b5b..2ff617023b 100644 --- a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'atira_asteroid', 'sssb_data_atira_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', "Atira Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', "Atira Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 25 diff --git a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset index 9aae1b46c4..52ea702f0d 100644 --- a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'centaur_asteroid', 'sssb_data_centaur_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', "Centaur Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', "Centaur Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 18 diff --git a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset index ef4f4ef2c3..64ae626256 100644 --- a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'chiron-type_comet', 'sssb_data_chiron-type_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', "Chiron-type Comet", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', "Chiron-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 25 diff --git a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset index 3a006f8b52..c1d00da397 100644 --- a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'encke-type_comet', 'sssb_data_encke-type_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', "Encke-type Comet", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', "Encke-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 23 diff --git a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset index 58e57ef93b..3b13a9e9d4 100644 --- a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'halley-type_comet', 'sssb_data_halley-type_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', "Halley-type Comet", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', "Halley-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 18 diff --git a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset index 92914e37d1..f941126a6e 100644 --- a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'inner_main_belt_asteroid', 'sssb_data_inner_main_belt_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', "Inner Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', "Inner Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 0.5 diff --git a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset index b7ac48e699..1b4b54aa37 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter-family_comet', 'sssb_data_jupiter-family_comet') -local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', "Jupiter-family Comet", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', "Jupiter-family Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 500 object.Renderable.TrailFade = 28 diff --git a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset index 0bc7fae4fb..f08423484c 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter_trojan_asteroid', 'sssb_data_jupiter_trojan_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', "Jupiter Trojan Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', "Jupiter Trojan Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 5 diff --git a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset index 5b871d5b20..1e9ae65ee0 100644 --- a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main_belt_asteroid', 'sssb_data_main_belt_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', "Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', "Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 0.1 diff --git a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset index c6a12efe99..53b8837108 100644 --- a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'mars-crossing_asteroid', 'sssb_data_mars-crossing_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', "Mars-crossing Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', "Mars-crossing Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 13 diff --git a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset index 5d9816c6bc..e70e7966f9 100644 --- a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'outer_main_belt_asteroid', 'sssb_data_outer_main_belt_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', "Outer Main Belt Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', "Outer Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 50 object.Renderable.TrailFade = 2 diff --git a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset index 4a01875b7b..2fdfa47768 100644 --- a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset @@ -2,7 +2,7 @@ local assetHelper = asset.require('util/asset_helper') local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'transneptunian_object_asteroid', 'sssb_data_transneptunian_object_asteroid') -local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', "Transneptunian Object Asteroid", filepath, { 0.9, 0.3, 0.1 }) +local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', "Transneptunian Object Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false object.Renderable.Segments = 150 object.Renderable.TrailFade = 10 From 050029f16b54b598890a2cc24730261d4d82bbd0 Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 24 Mar 2020 14:21:15 -0600 Subject: [PATCH 31/67] Switched back to default scene in preparation for merge with master --- openspace.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openspace.cfg b/openspace.cfg index cd8c6a8742..a557e5468d 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -45,8 +45,8 @@ SGCTConfig = sgct.config.single{} -- Sets the scene that is to be loaded by OpenSpace. A scene file is a description -- of all entities that will be visible during an instance of OpenSpace -Asset = "asteroids" --- Asset = "default" +Asset = "default" +-- Asset = "asteroids" -- Asset = "default_full" -- Asset = "newhorizons" -- Asset = "rosetta" From cf7fcd9f035da1526736cfe5132d247cc22530da Mon Sep 17 00:00:00 2001 From: GPayne Date: Tue, 24 Mar 2020 17:20:49 -0600 Subject: [PATCH 32/67] Deleted UpperLimitInfo from satellites because only smallbody uses it --- modules/space/rendering/renderablesatellites.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 83f8215fd0..79e968b792 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -75,12 +75,6 @@ namespace { "Trail Fade", "This value determines how fast the trail fades and is an appearance property. " }; - static const openspace::properties::Property::PropertyInfo UpperLimitInfo = { - "UpperLimit", - "Upper Limit", - "Upper limit on the number of objects for this renderable, regardless of " - "how many objects are contained in the data file" - }; } namespace openspace { @@ -97,12 +91,6 @@ documentation::Documentation RenderableSatellites::Documentation() { Optional::No, SegmentsInfo.description }, - { - UpperLimitInfo.identifier, - new IntVerifier, - Optional::Yes, - UpperLimitInfo.description - }, { PathInfo.identifier, new StringVerifier, From c9b5ffd0213fda6a0492f19d54877b55b2e430d0 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Thu, 13 Feb 2020 09:58:56 +0100 Subject: [PATCH 33/67] Changed webbrowser to use cef touch events rather than injected mouse events. --- modules/webbrowser/include/browserinstance.h | 5 +- modules/webbrowser/include/eventhandler.h | 2 + modules/webbrowser/src/browserinstance.cpp | 14 +---- modules/webbrowser/src/eventhandler.cpp | 57 ++++++++++---------- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/modules/webbrowser/include/browserinstance.h b/modules/webbrowser/include/browserinstance.h index b96e701da8..071accc2aa 100644 --- a/modules/webbrowser/include/browserinstance.h +++ b/modules/webbrowser/include/browserinstance.h @@ -84,10 +84,7 @@ public: void draw(); void close(bool force = false); - void sendTouchPressEvent(const CefMouseEvent & event, - CefBrowserHost::MouseButtonType button, const int clickCount); - void sendResleasePressEvent(const CefMouseEvent & event, - CefBrowserHost::MouseButtonType button, const int clickCount); + void sendTouchEvent(const CefTouchEvent& event) const; bool sendKeyEvent(const CefKeyEvent& event); bool sendMouseClickEvent(const CefMouseEvent& event, diff --git a/modules/webbrowser/include/eventhandler.h b/modules/webbrowser/include/eventhandler.h index 406b27813d..918667b420 100644 --- a/modules/webbrowser/include/eventhandler.h +++ b/modules/webbrowser/include/eventhandler.h @@ -84,6 +84,8 @@ private: */ CefMouseEvent mouseEvent(KeyModifier mods = KeyModifier::NoModifier); + CefTouchEvent touchEvent(const TouchInput& input, + const cef_touch_event_type_t eventType) const; /** * Find the CEF key event to use for a given action. * diff --git a/modules/webbrowser/src/browserinstance.cpp b/modules/webbrowser/src/browserinstance.cpp index 52016fe15f..0f7ec357b7 100644 --- a/modules/webbrowser/src/browserinstance.cpp +++ b/modules/webbrowser/src/browserinstance.cpp @@ -149,18 +149,8 @@ bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent& event, return hasContent(event.x, event.y); } -void BrowserInstance::sendTouchPressEvent(const CefMouseEvent& event, - CefBrowserHost::MouseButtonType button, - const int clickCount) -{ - _browser->GetHost()->SendMouseClickEvent(event, button, false, clickCount); -} - -void BrowserInstance::sendResleasePressEvent(const CefMouseEvent& event, - CefBrowserHost::MouseButtonType button, - const int clickCount) -{ - _browser->GetHost()->SendMouseClickEvent(event, button, true, clickCount); +void BrowserInstance::sendTouchEvent(const CefTouchEvent& event) const{ + _browser->GetHost()->SendTouchEvent(event); } bool BrowserInstance::sendMouseMoveEvent(const CefMouseEvent& event) { diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index 0ee3e8f7a3..d9dc17424f 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -208,15 +208,11 @@ void EventHandler::initialize() { } if (_validTouchStates.empty()) { - _mousePosition.x = windowPos.x; - _mousePosition.y = windowPos.y; - _leftButton.down = true; - _browserInstance->sendMouseClickEvent( - mouseEvent(), - MBT_LEFT, - false, - BrowserInstance::SingleClick + CefTouchEvent event = touchEvent( + input, + cef_touch_event_type_t::CEF_TET_PRESSED ); + _browserInstance->sendTouchEvent(event); _validTouchStates.emplace_back(input); } else { @@ -245,11 +241,11 @@ void EventHandler::initialize() { ); if (it == _validTouchStates.cbegin()) { - glm::vec2 windowPos = input.currentWindowCoordinates(); - _mousePosition.x = windowPos.x; - _mousePosition.y = windowPos.y; - _leftButton.down = true; - _browserInstance->sendMouseMoveEvent(mouseEvent()); + CefTouchEvent event = touchEvent( + input, + cef_touch_event_type_t::CEF_TET_MOVED + ); + _browserInstance->sendTouchEvent(event); return true; } else if (it != _validTouchStates.cend()){ @@ -280,20 +276,12 @@ void EventHandler::initialize() { if (found == _validTouchStates.cend()) { return; } - + CefTouchEvent event = touchEvent( + input, + cef_touch_event_type_t::CEF_TET_RELEASED + ); + _browserInstance->sendTouchEvent(event); _validTouchStates.erase(found); - if (_validTouchStates.empty()) { - glm::vec2 windowPos = input.currentWindowCoordinates(); - _mousePosition.x = windowPos.x; - _mousePosition.y = windowPos.y; - _leftButton.down = false; - _browserInstance->sendMouseClickEvent( - mouseEvent(), - MBT_LEFT, - true, - BrowserInstance::SingleClick - ); - } } ); } @@ -337,7 +325,7 @@ bool EventHandler::mouseButtonCallback(MouseButton button, MouseAction action, bool EventHandler::isDoubleClick(const MouseButtonState& button) const { // check time using namespace std::chrono; - + auto now = high_resolution_clock::now(); milliseconds maxTimeDifference(doubleClickTime()); auto requiredTime = button.lastClickTime + maxTimeDifference; @@ -438,6 +426,21 @@ CefMouseEvent EventHandler::mouseEvent(KeyModifier mods) { return event; } +CefTouchEvent EventHandler::touchEvent(const TouchInput& input, + const cef_touch_event_type_t eventType) const +{ + const glm::vec2 windowPos = input.currentWindowCoordinates(); + CefTouchEvent event = {}; + event.id = static_cast(input.fingerId); + event.x = windowPos.x; + event.y = windowPos.y; + event.type = eventType; + //TODO: We should probably use key mods for touch as well: + // event.modifiers = mods; + event.pointer_type = cef_pointer_type_t::CEF_POINTER_TYPE_TOUCH; + return event; +} + void EventHandler::setBrowserInstance(BrowserInstance* browserInstance) { LDEBUG("Setting browser instance."); _browserInstance = browserInstance; From 3210dfd31582326f60c6e78caa3885db445c937d Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Fri, 21 Feb 2020 13:32:54 +0100 Subject: [PATCH 34/67] Made these changes only apply on Win32 builds --- modules/webbrowser/include/browserinstance.h | 2 + modules/webbrowser/include/eventhandler.h | 11 ++++++ modules/webbrowser/src/browserinstance.cpp | 2 + modules/webbrowser/src/eventhandler.cpp | 39 ++++++++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/modules/webbrowser/include/browserinstance.h b/modules/webbrowser/include/browserinstance.h index 071accc2aa..5e74c6806c 100644 --- a/modules/webbrowser/include/browserinstance.h +++ b/modules/webbrowser/include/browserinstance.h @@ -84,7 +84,9 @@ public: void draw(); void close(bool force = false); +#ifdef WIN32 void sendTouchEvent(const CefTouchEvent& event) const; +#endif bool sendKeyEvent(const CefKeyEvent& event); bool sendMouseClickEvent(const CefMouseEvent& event, diff --git a/modules/webbrowser/include/eventhandler.h b/modules/webbrowser/include/eventhandler.h index 918667b420..e08f2fbfc7 100644 --- a/modules/webbrowser/include/eventhandler.h +++ b/modules/webbrowser/include/eventhandler.h @@ -84,8 +84,19 @@ private: */ CefMouseEvent mouseEvent(KeyModifier mods = KeyModifier::NoModifier); +#ifdef WIN32 + /** + * Build a CEF touch event based on our internal structure + * + * Note: as of 02/21/2020 we are using an older version of CEF on OSX + * than WIN32. + * This version does not handle the CefTouchEvent type and does + * not have any internal touch handling. + */ CefTouchEvent touchEvent(const TouchInput& input, const cef_touch_event_type_t eventType) const; +#endif + /** * Find the CEF key event to use for a given action. * diff --git a/modules/webbrowser/src/browserinstance.cpp b/modules/webbrowser/src/browserinstance.cpp index 0f7ec357b7..14eaaef9b0 100644 --- a/modules/webbrowser/src/browserinstance.cpp +++ b/modules/webbrowser/src/browserinstance.cpp @@ -149,9 +149,11 @@ bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent& event, return hasContent(event.x, event.y); } +#ifdef WIN32 void BrowserInstance::sendTouchEvent(const CefTouchEvent& event) const{ _browser->GetHost()->SendTouchEvent(event); } +#endif bool BrowserInstance::sendMouseMoveEvent(const CefMouseEvent& event) { constexpr const bool DidNotLeaveWindow = false; diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index d9dc17424f..33c6db3a98 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -208,11 +208,23 @@ void EventHandler::initialize() { } if (_validTouchStates.empty()) { +#ifdef WIN32 CefTouchEvent event = touchEvent( input, cef_touch_event_type_t::CEF_TET_PRESSED ); _browserInstance->sendTouchEvent(event); +#else + _mousePosition.x = windowPos.x; + _mousePosition.y = windowPos.y; + _leftButton.down = true; + _browserInstance->sendMouseClickEvent( + mouseEvent(), + MBT_LEFT, + false, + BrowserInstance::SingleClick + ); +#endif _validTouchStates.emplace_back(input); } else { @@ -241,11 +253,20 @@ void EventHandler::initialize() { ); if (it == _validTouchStates.cbegin()) { +#ifdef WIN32 + CefTouchEvent event = touchEvent( input, cef_touch_event_type_t::CEF_TET_MOVED ); _browserInstance->sendTouchEvent(event); +#else + glm::vec2 windowPos = input.currentWindowCoordinates(); + _mousePosition.x = windowPos.x; + _mousePosition.y = windowPos.y; + _leftButton.down = true; + _browserInstance->sendMouseMoveEvent(mouseEvent()); +#endif return true; } else if (it != _validTouchStates.cend()){ @@ -276,12 +297,28 @@ void EventHandler::initialize() { if (found == _validTouchStates.cend()) { return; } +#ifdef WIN32 CefTouchEvent event = touchEvent( input, cef_touch_event_type_t::CEF_TET_RELEASED ); _browserInstance->sendTouchEvent(event); +#endif _validTouchStates.erase(found); +#ifndef WIN32 + if (_validTouchStates.empty()) { + glm::vec2 windowPos = input.currentWindowCoordinates(); + _mousePosition.x = windowPos.x; + _mousePosition.y = windowPos.y; + _leftButton.down = false; + _browserInstance->sendMouseClickEvent( + mouseEvent(), + MBT_LEFT, + true, + BrowserInstance::SingleClick + ); + } +#endif } ); } @@ -426,6 +463,7 @@ CefMouseEvent EventHandler::mouseEvent(KeyModifier mods) { return event; } +#ifdef WIN32 CefTouchEvent EventHandler::touchEvent(const TouchInput& input, const cef_touch_event_type_t eventType) const { @@ -440,6 +478,7 @@ CefTouchEvent EventHandler::touchEvent(const TouchInput& input, event.pointer_type = cef_pointer_type_t::CEF_POINTER_TYPE_TOUCH; return event; } +#endif void EventHandler::setBrowserInstance(BrowserInstance* browserInstance) { LDEBUG("Setting browser instance."); From fa5bbc5a44b3c55474a6594d8be31ce8f25150c7 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Wed, 11 Mar 2020 14:06:23 +0100 Subject: [PATCH 35/67] Added keymodifiers to touch event handling --- modules/webbrowser/src/eventhandler.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index 33c6db3a98..b7f4d55c96 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include #include @@ -473,8 +475,12 @@ CefTouchEvent EventHandler::touchEvent(const TouchInput& input, event.x = windowPos.x; event.y = windowPos.y; event.type = eventType; - //TODO: We should probably use key mods for touch as well: - // event.modifiers = mods; + const std::vector> &keyModVec = + global::navigationHandler.inputState().pressedKeys(); + for (auto keyModPair : keyModVec) { + const KeyModifier mods = keyModVec[0].second; + event.modifiers |= static_cast(mapToCefModifiers(mods)); + } event.pointer_type = cef_pointer_type_t::CEF_POINTER_TYPE_TOUCH; return event; } From 1c57f8ad21815f41236744fd1ef935b1b3b5d383 Mon Sep 17 00:00:00 2001 From: Mikael Date: Wed, 25 Mar 2020 10:01:56 +0100 Subject: [PATCH 36/67] Added more explanatory comments of the Touch-implementation --- include/openspace/util/touch.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/openspace/util/touch.h b/include/openspace/util/touch.h index a7e8bc0735..3d1e1bf8a4 100644 --- a/include/openspace/util/touch.h +++ b/include/openspace/util/touch.h @@ -32,6 +32,9 @@ namespace openspace { +// The TouchInput represents a single finger/device-input at a specific point in time. +// the fingerId and touchDeviceId coupled with the timestamp allows this to be compared +// with other TouchInputs in order to calculate gesture-like behaviour. struct TouchInput { TouchInput(size_t touchDeviceId, size_t fingerId, float x, float y, double timestamp); glm::vec2 screenCoordinates(glm::vec2 resolution) const; @@ -49,17 +52,22 @@ struct TouchInput { double timestamp; // timestamp in seconds from global touch initialization }; +// The TouchInputHolder holds one or many TouchInputs, in order to track the history of +// the finger/input device class TouchInputHolder { public: TouchInputHolder(TouchInput input); - // tryAddInput: // Succeeds upon a different input than last. // Fails upon a too similar input as last. // Updates time for the last input if same position. bool tryAddInput(TouchInput input); + void clearInputs(); + // Checks whether or not this Holder actually holds a specific input (based on IDs) + // Succeeds when `input` is held by this Holder + // Fails if `input` is not held by this Holder bool holdsInput(const TouchInput &input) const; size_t touchDeviceId() const; From 5209de548421076709aef2c79a40c40a9e2a4fce Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 28 Mar 2020 20:32:53 +0100 Subject: [PATCH 37/67] Some coding style fixes --- modules/touch/src/touchinteraction.cpp | 36 ++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index cf36a632e5..099296c3c2 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -118,10 +118,10 @@ namespace { }; constexpr openspace::properties::Property::PropertyInfo PinchZoomFactorInfo = { - "PinchZoomFactor", - "Scaling distance travelled on pinch", - "This value is used to reduce the amount of pinching needed. A linear" - "kind of sensitivity that will alter the pinch-zoom speed." + "PinchZoomFactor", + "Scaling distance travelled on pinch", + "This value is used to reduce the amount of pinching needed. A linear kind of " + "sensitivity that will alter the pinch-zoom speed." }; constexpr openspace::properties::Property::PropertyInfo DirectManipulationInfo = { @@ -285,7 +285,12 @@ TouchInteraction::TouchInteraction() 0.25f ) , _zoomBoundarySphereMultiplier(ZoomBoundarySphereMultiplierInfo, 1.001f, 1.f, 1.01f) - , _zoomOutLimit(ZoomOutLimitInfo, std::numeric_limits::max(), 1000.0, std::numeric_limits::max()) + , _zoomOutLimit( + ZoomOutLimitInfo, + std::numeric_limits::max(), + 1000.0, + std::numeric_limits::max() + ) , _zoomInLimit(ZoomInLimitInfo, -1.0, 0.0, std::numeric_limits::max()) , _inputStillThreshold(InputSensitivityInfo, 0.0005f, 0.f, 0.001f) // used to void wrongly interpreted roll interactions @@ -315,10 +320,9 @@ TouchInteraction::TouchInteraction() { "Ignore GUI", "Disable GUI touch interaction", "" }, false ) - , _pinchInputs({ TouchInput(0x0, 0x0, 0.0, 0.0, 0.0), - TouchInput(0x0, 0x0, 0.0, 0.0, 0.0) }) + , _pinchInputs({ TouchInput(0, 0, 0.0, 0.0, 0.0), TouchInput(0, 0, 0.0, 0.0, 0.0) }) , _vel{ glm::dvec2(0.0), 0.0, 0.0, glm::dvec2(0.0) } - , _sensitivity{ glm::dvec2(0.08, 0.045), 12.0 /*4.0*/, 2.75, glm::dvec2(0.08, 0.045) } + , _sensitivity{ glm::dvec2(0.08, 0.045), 12.0, 2.75, glm::dvec2(0.08, 0.045) } , _constTimeDecay_secs(ConstantTimeDecaySecsInfo, 1.75f, 0.1f, 4.0f) // calculated with two vectors with known diff in length, then // projDiffLength/diffLength. @@ -790,11 +794,10 @@ int TouchInteraction::interpretInteraction(const std::vector& else { const bool sameInput0 = _pinchInputs[0].holdsInput(list[0].latestInput()); const bool sameInput1 = _pinchInputs[1].holdsInput(list[1].latestInput()); - if(sameInput0 && sameInput1) - { + if (sameInput0 && sameInput1) { _pinchInputs[0].tryAddInput(list[0].latestInput()); _pinchInputs[1].tryAddInput(list[1].latestInput()); - }else{ + } else { _pinchInputs[0] = TouchInputHolder(list[0].latestInput()); _pinchInputs[1] = TouchInputHolder(list[1].latestInput()); } @@ -1131,17 +1134,18 @@ void TouchInteraction::step(double dt, bool directTouch) { // Possible with other navigations performed outside touch interaction const bool currentPosViolatingZoomOutLimit = - (currentPosDistance >= _zoomOutLimit.value()); + (currentPosDistance >= _zoomOutLimit); const bool willNewPositionViolateZoomOutLimit = - (newPosDistance >= _zoomOutLimit.value()); + (newPosDistance >= _zoomOutLimit); bool willNewPositionViolateZoomInLimit = (newPosDistance < zoomInBounds); bool willNewPositionViolateDirection = (currentPosDistance <= length(zoomDistanceIncrement)); - if (!willNewPositionViolateZoomInLimit - && !willNewPositionViolateDirection - && !willNewPositionViolateZoomOutLimit) { + if (!willNewPositionViolateZoomInLimit && + !willNewPositionViolateDirection && + !willNewPositionViolateZoomOutLimit) + { camPos += zoomDistanceIncrement; } else if (currentPosViolatingZoomOutLimit) { From b2c7529ddf4f4e48f5d48d9f708e85764d0512d3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 28 Mar 2020 20:42:19 +0100 Subject: [PATCH 38/67] Amend previous commit --- modules/touch/src/touchinteraction.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 3f640069d7..71deff0318 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -1175,20 +1175,6 @@ void TouchInteraction::resetAfterInput() { } } - // Reset emulated mouse values - ImGUIModule& module = *(global::moduleEngine.module()); - if (_guiON) { - bool activeLastFrame = module.touchInput.action; - module.touchInput.active = false; - if (activeLastFrame) { - module.touchInput.active = true; - module.touchInput.action = 0; - } - } - else { - module.touchInput.active = false; - module.touchInput.action = 0; - } _lmSuccess = true; // Reset variables From 5e37cb5ac38435d3f37fca32912765f11bf804d1 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 28 Mar 2020 20:45:14 +0100 Subject: [PATCH 39/67] Some coding style cleanup --- modules/imgui/src/gui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index 38c4e32f26..f1d2d3ffcd 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -639,13 +639,13 @@ bool GUI::charCallback(unsigned int character, KeyModifier) { bool GUI::touchDetectedCallback(TouchInput input) { ImGuiIO& io = ImGui::GetIO(); - glm::vec2 windowPos = input.currentWindowCoordinates(); - bool consumeEvent = ImGui::IsPosHoveringAnyWindow({windowPos.x, windowPos.y}); + const glm::vec2 windowPos = input.currentWindowCoordinates(); + const bool consumeEvent = ImGui::IsPosHoveringAnyWindow({ windowPos.x, windowPos.y }); - if(!consumeEvent) { + if (!consumeEvent) { return false; } - if(_validTouchStates.empty()) { + if (_validTouchStates.empty()) { io.MousePos = {windowPos.x, windowPos.y}; io.MouseClicked[0] = true; } @@ -654,7 +654,7 @@ bool GUI::touchDetectedCallback(TouchInput input) { } bool GUI::touchUpdatedCallback(TouchInput input) { - if(_validTouchStates.empty()) { + if (_validTouchStates.empty()) { return false; } ImGuiIO& io = ImGui::GetIO(); From 545a1314a567f23bbb28d70d874451370519a167 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 29 Mar 2020 17:23:25 -0600 Subject: [PATCH 40/67] Fix for issue #1122 forcing satellite files to download at each startup --- data/assets/util/tle_helper.asset | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data/assets/util/tle_helper.asset b/data/assets/util/tle_helper.asset index 92293479c3..5f5755b186 100644 --- a/data/assets/util/tle_helper.asset +++ b/data/assets/util/tle_helper.asset @@ -11,7 +11,8 @@ function downloadTLEFile(sceneAsset, url, name, filename) Name = "Satellite TLE Data (" .. name .. ")", Type = "UrlSynchronization", Identifier = "satellite_tle_data_" .. identifier, - Url = url + Url = url, + Override = true } if (filename ~= '') then From 9884d7e25d57a2ffa0e6cfdfb177b4256cb15226 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Sun, 29 Mar 2020 17:25:54 -0600 Subject: [PATCH 41/67] Fix tabs vs spaces --- data/assets/util/tle_helper.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/util/tle_helper.asset b/data/assets/util/tle_helper.asset index 5f5755b186..a7179795c7 100644 --- a/data/assets/util/tle_helper.asset +++ b/data/assets/util/tle_helper.asset @@ -12,7 +12,7 @@ function downloadTLEFile(sceneAsset, url, name, filename) Type = "UrlSynchronization", Identifier = "satellite_tle_data_" .. identifier, Url = url, - Override = true + Override = true } if (filename ~= '') then From 56467863317d09ec53b7e5cbbbf9e042cfb51fd7 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 6 Apr 2020 20:11:19 +0200 Subject: [PATCH 42/67] Add the C 2019 Y4 asset from Dan Tell --- .../scene/solarsystem/sssb/c2019y4atlas.asset | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 data/assets/scene/solarsystem/sssb/c2019y4atlas.asset diff --git a/data/assets/scene/solarsystem/sssb/c2019y4atlas.asset b/data/assets/scene/solarsystem/sssb/c2019y4atlas.asset new file mode 100644 index 0000000000..27acaa4adf --- /dev/null +++ b/data/assets/scene/solarsystem/sssb/c2019y4atlas.asset @@ -0,0 +1,48 @@ +local assetHelper = asset.require('util/asset_helper') +local sunTransforms = asset.require('scene/solarsystem/sun/transforms') + +local orbit = asset.syncedResource({ + Name = "Comet C/2019 Y4 ATLAS", + Type = "HttpSynchronization", + Identifier = "horizons_c2019y4atlas", + Version = 1 +}) .. "/c2019y4atlas.txt" + +local C2019Y4AtlasTrail = { + Identifier = "C2019Y4AtlasTrail", + Parent = sunTransforms.SolarSystemBarycenter.Identifier, + Renderable = { + Type = "RenderableTrailTrajectory", + Translation = { + Type = "HorizonsTranslation", + HorizonsTextFile = orbit + }, + Color = { 0.533333, 0.850980, 0.996078 }, + EnableFade = false, + StartTime = "1950 JAN 1 0:00:00", + EndTime = "2100 JAN 1 00:00:00", + SampleInterval = 35000, + TimeStampSubsampleFactor = 1 + }, + GUI = { + Name = "C2019 Y4 Atlas Trail", + Path = "/Solar System/Comets" + } +} + +local C2019Y4AtlasPosition = { + Identifier = "C2019Y4AtlasPosition", + Parent = sunTransforms.SolarSystemBarycenter.Identifier, + Transform = { + Translation = { + Type = "HorizonsTranslation", + HorizonsTextFile = orbit + }, + }, + GUI = { + Name = "C 2019 Y4 Atlas", + Path = "/Solar System/Comets" + } +} + +assetHelper.registerSceneGraphNodesAndExport(asset, {C2019Y4AtlasPosition, C2019Y4AtlasTrail }) From a95d01d7811c552f84ae6860510dd699c57c1709 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 9 Apr 2020 13:33:30 -0600 Subject: [PATCH 43/67] Implemented num orbital trail segments proportional to eccentricity --- .../solarsystem/sssb/amor_asteroid.asset | 2 +- .../solarsystem/sssb/apollo_asteroid.asset | 2 +- .../solarsystem/sssb/aten_asteroid.asset | 2 +- .../solarsystem/sssb/atira_asteroid.asset | 2 +- .../solarsystem/sssb/centaur_asteroid.asset | 2 +- .../solarsystem/sssb/chiron-type_comet.asset | 2 +- .../solarsystem/sssb/encke-type_comet.asset | 2 +- .../solarsystem/sssb/halley-type_comet.asset | 2 +- .../sssb/inner_main_belt_asteroid.asset | 2 +- .../sssb/jupiter-family_comet.asset | 2 +- .../sssb/jupiter_trojan_asteroid.asset | 2 +- .../solarsystem/sssb/main_belt_asteroid.asset | 2 +- .../sssb/mars-crossing_asteroid.asset | 2 +- .../sssb/outer_main_belt_asteroid.asset | 2 +- data/assets/scene/solarsystem/sssb/pha.asset | 2 +- .../sssb/transneptunian_object_asteroid.asset | 2 +- .../rendering/renderableorbitalkepler.cpp | 68 +++++++++++-------- .../space/rendering/renderableorbitalkepler.h | 3 +- .../space/rendering/renderablesatellites.cpp | 4 +- .../space/rendering/renderablesmallbody.cpp | 17 +++-- 20 files changed, 70 insertions(+), 54 deletions(-) diff --git a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset index 7ab07f28a9..72b9cd4f31 100644 --- a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'amor_asteroid', 'sssb_data_amor_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', "Amor Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 11 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset index 9b36a44658..02b592a7da 100644 --- a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'apollo_asteroid', 'sssb_data_apollo_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', "Apollo Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 10 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset index 591320400f..4604283150 100644 --- a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'aten_asteroid', 'sssb_data_aten_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', "Aten Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset index 2ff617023b..65801fede5 100644 --- a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'atira_asteroid', 'sssb_data_atira_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', "Atira Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 25 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset index 52ea702f0d..46bba5a0a8 100644 --- a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'centaur_asteroid', 'sssb_data_centaur_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', "Centaur Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset index 64ae626256..3365b253bc 100644 --- a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'chiron-type_comet', 'sssb_data_chiron-type_comet') local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', "Chiron-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 50 object.Renderable.TrailFade = 25 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset index c1d00da397..451433e6f1 100644 --- a/data/assets/scene/solarsystem/sssb/encke-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/encke-type_comet.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'encke-type_comet', 'sssb_data_encke-type_comet') local object = sharedSssb.createSssbGroupObject('sssb_data_encke-type_comet.csv', "Encke-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 2 object.Renderable.TrailFade = 23 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset index 3b13a9e9d4..6fb74b8061 100644 --- a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'halley-type_comet', 'sssb_data_halley-type_comet') local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', "Halley-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 2 object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset index f941126a6e..02426fdbeb 100644 --- a/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/inner_main_belt_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'inner_main_belt_asteroid', 'sssb_data_inner_main_belt_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_inner_main_belt_asteroid.csv', "Inner Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 0.5 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset index 1b4b54aa37..b42e8ac0be 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter-family_comet.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter-family_comet', 'sssb_data_jupiter-family_comet') local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter-family_comet.csv', "Jupiter-family Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 500 +object.Renderable.SegmentQuality = 10 object.Renderable.TrailFade = 28 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset index f08423484c..6be40249c7 100644 --- a/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/jupiter_trojan_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'jupiter_trojan_asteroid', 'sssb_data_jupiter_trojan_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_jupiter_trojan_asteroid.csv', "Jupiter Trojan Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 5 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset index 1e9ae65ee0..503a00dc04 100644 --- a/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/main_belt_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'main_belt_asteroid', 'sssb_data_main_belt_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_main_belt_asteroid.csv', "Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 0.1 object.Renderable.UpperLimit = 50000 diff --git a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset index 53b8837108..98cdda1f80 100644 --- a/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/mars-crossing_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'mars-crossing_asteroid', 'sssb_data_mars-crossing_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_mars-crossing_asteroid.csv', "Mars-crossing Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 13 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset index e70e7966f9..995b7623ea 100644 --- a/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/outer_main_belt_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'outer_main_belt_asteroid', 'sssb_data_outer_main_belt_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_outer_main_belt_asteroid.csv', "Outer Main Asteroid Belt", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 50 +object.Renderable.SegmentQuality = 1 object.Renderable.TrailFade = 2 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/pha.asset b/data/assets/scene/solarsystem/sssb/pha.asset index b8d116fae3..4a66174fdf 100644 --- a/data/assets/scene/solarsystem/sssb/pha.asset +++ b/data/assets/scene/solarsystem/sssb/pha.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'pha', 'sssb_data_pha') local object = sharedSssb.createSssbGroupObject('sssb_data_pha.csv', "Potentially Hazardous Asteroids", filepath, { 0.75, 0.2, 0.2 }) object.Renderable.Enabled = false -object.Renderable.Segments = 100 +object.Renderable.SegmentQuality = 3 object.Renderable.TrailFade = 17 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset index 2fdfa47768..a868bf7aec 100644 --- a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'transneptunian_object_asteroid', 'sssb_data_transneptunian_object_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', "Transneptunian Object Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.Segments = 150 +object.Renderable.SegmentQuality = 3 object.Renderable.TrailFade = 10 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 6efa17e4a4..e048e4fe15 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -53,10 +53,13 @@ namespace { "Path", "The file path to the data file to read" }; - static const openspace::properties::Property::PropertyInfo SegmentsInfo = { - "Segments", - "Segments", - "The number of segments to use for each orbit ellipse" + static const openspace::properties::Property::PropertyInfo SegmentQualityInfo = { + "SegmentQuality", + "Segment Quality", + "A segment quality value for the orbital trail. A value from 1 (lowest) to " + "100 (highest) that controls the number of line segments in the rendering of the " + "orbital trail. This does not control the direct number of segments because " + "these automatically increase according to the eccentricity of the orbit." }; constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { "LineWidth", @@ -350,7 +353,7 @@ int RenderableOrbitalKepler::daysIntoGivenYear(int month, int dayOfMonth) { RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _path(PathInfo) - , _nSegments(SegmentsInfo, 120, 4, 1024) + , _segmentQuality(SegmentQualityInfo, 10, 1, 100) , _upperLimit(UpperLimitInfo, 1000, 1, 1000000) { documentation::testSpecificationAndThrow( @@ -360,7 +363,8 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio ); _path = dictionary.value(PathInfo.identifier); - _nSegments = static_cast(dictionary.value(SegmentsInfo.identifier)); + _segmentQuality = static_cast( + dictionary.value(SegmentQualityInfo.identifier)); if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { _appearance.lineColor = dictionary.value(LineColorInfo.identifier); @@ -393,11 +397,11 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio } reinitializeTrailBuffers = std::function([this] { initializeGL(); }); _path.onChange(reinitializeTrailBuffers); - _nSegments.onChange(reinitializeTrailBuffers); + _segmentQuality.onChange(reinitializeTrailBuffers); addPropertySubOwner(_appearance); addProperty(_path); - addProperty(_nSegments); + addProperty(_segmentQuality); addProperty(_opacity); setRenderBin(Renderable::RenderBin::Overlay); @@ -481,11 +485,11 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { glBindVertexArray(_vertexArray); for (size_t i = 0; i < nrOrbits; ++i) { - glDrawArrays(GL_LINE_STRIP, vertices, _nSegments + 1); - vertices = vertices + _nSegments + 1; + glDrawArrays(GL_LINE_STRIP, vertices, _segmentSize[i] + 1); + vertices = vertices + _segmentSize[i] + 1; } glBindVertexArray(0); - + _programObject->deactivate(); } @@ -493,11 +497,18 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { void RenderableOrbitalKepler::updateBuffers() { readDataFile(_path); - const size_t nVerticesPerOrbit = _nSegments + 1; - _vertexBufferData.resize(_data.size() * nVerticesPerOrbit); - size_t orbitindex = 0; + size_t nVerticesPerOrbit = 0; + + int numOrbits = _data.size(); + for (size_t i = 0; i < numOrbits; ++i) { + nVerticesPerOrbit += _segmentSize[i] + 1; + } + _vertexBufferData.resize(nVerticesPerOrbit); + + size_t vertexBufIdx = 0; + for (size_t orbitIdx = 0; orbitIdx < numOrbits; ++orbitIdx) { + openspace::RenderableOrbitalKepler::KeplerParameters orbit = _data[orbitIdx]; - for (const auto& orbit : _data) { _keplerTranslator.setKeplerElements( orbit.eccentricity, orbit.semiMajorAxis, @@ -509,32 +520,30 @@ void RenderableOrbitalKepler::updateBuffers() { orbit.epoch ); - for (size_t i=0 ; i < nVerticesPerOrbit; ++i) { - size_t index = orbitindex * nVerticesPerOrbit + i; - + for (size_t j = 0 ; j < _segmentSize[orbitIdx]; ++j) { double timeOffset = orbit.period * - static_cast(i)/ static_cast(_nSegments); - + static_cast(j)/ static_cast(_segmentSize[orbitIdx]); + glm::dvec3 position = _keplerTranslator.position({ {}, Time(timeOffset + orbit.epoch), Time(0.0), false }); - + double positionX = position.x; double positionY = position.y; double positionZ = position.z; - _vertexBufferData[index].x = static_cast(positionX); - _vertexBufferData[index].y = static_cast(positionY); - _vertexBufferData[index].z = static_cast(positionZ); - _vertexBufferData[index].time = static_cast(timeOffset); - _vertexBufferData[index].epoch = orbit.epoch; - _vertexBufferData[index].period = orbit.period; + _vertexBufferData[vertexBufIdx].x = static_cast(positionX); + _vertexBufferData[vertexBufIdx].y = static_cast(positionY); + _vertexBufferData[vertexBufIdx].z = static_cast(positionZ); + _vertexBufferData[vertexBufIdx].time = static_cast(timeOffset); + _vertexBufferData[vertexBufIdx].epoch = orbit.epoch; + _vertexBufferData[vertexBufIdx].period = orbit.period; + + vertexBufIdx++; } - - ++orbitindex; } glBindVertexArray(_vertexArray); @@ -553,7 +562,6 @@ void RenderableOrbitalKepler::updateBuffers() { glEnableVertexAttribArray(1); glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4 * sizeof(GL_FLOAT))); - glBindVertexArray(0); } diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h index 65fad29b56..54183e818f 100644 --- a/modules/space/rendering/renderableorbitalkepler.h +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -106,7 +106,9 @@ protected: const double convertAuToKm = 1.496e8; const double convertDaysToSecs = 86400.; std::vector _data; + std::vector _segmentSize; properties::UIntProperty _upperLimit; + properties::UIntProperty _segmentQuality; properties::Property::OnChangeHandle _upperLimitCallbackHandle; private: @@ -144,7 +146,6 @@ private: ghoul::opengl::ProgramObject* _programObject; properties::StringProperty _path; - properties::UIntProperty _nSegments; RenderableTrail::Appearance _appearance; glm::vec3 _position = glm::vec3(0.f); diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 79e968b792..f935b4643d 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -130,6 +130,8 @@ void RenderableSatellites::readDataFile(const std::string& filename) { "Satellite TLE file {} does not exist.", filename )); } + _data.clear(); + _segmentSize.clear(); std::ifstream file; file.exceptions(std::ifstream::failbit | std::ifstream::badbit); @@ -235,7 +237,7 @@ void RenderableSatellites::readDataFile(const std::string& filename) { keplerElements.period = period; _data.push_back(keplerElements); - + _segmentSize.push_back(_segmentQuality * 10); } file.close(); } diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 7a1b018f0c..4d5f289c2e 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -54,10 +54,13 @@ namespace { "Path", "The file path to the SBDB .csv file to read" }; - static const openspace::properties::Property::PropertyInfo SegmentsInfo = { - "Segments", - "Segments", - "The number of segments to use for each orbit ellipse" + static const openspace::properties::Property::PropertyInfo SegmentQualityInfo = { + "SegmentQuality", + "Segment Quality", + "A segment quality value for the orbital trail. A value from 1 (lowest) to " + "100 (highest) that controls the number of line segments in the rendering of the " + "orbital trail. This does not control the direct number of segments because " + "these automatically increase according to the eccentricity of the orbit." }; constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { "LineWidth", @@ -93,10 +96,10 @@ documentation::Documentation RenderableSmallBody::Documentation() { "space_renderable_small_body", { { - SegmentsInfo.identifier, + SegmentQualityInfo.identifier, new DoubleVerifier, Optional::No, - SegmentsInfo.description + SegmentQualityInfo.description }, { UpperLimitInfo.identifier, @@ -155,6 +158,7 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { file.seekg(std::ios_base::beg); // reset iterator to beginning of file _data.clear(); _sbNames.clear(); + _segmentSize.clear(); std::string line; std::streamoff csvLine = -1; @@ -332,6 +336,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, _data.push_back(keplerElements); _sbNames.push_back(name); + _segmentSize.push_back(_segmentQuality * 10 * (keplerElements.eccentricity / 0.05)); } static double importAngleValue(const std::string& angle) { From 0dc2fc943027533439984947731cff8ae198edf0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 10 Apr 2020 17:38:18 +0200 Subject: [PATCH 44/67] Make OpenSpace work with the new SGCT version --- apps/OpenSpace/CMakeLists.txt | 29 +- apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 647 ++++++++++----------- include/openspace/engine/openspaceengine.h | 4 +- include/openspace/engine/syncengine.h | 4 +- include/openspace/engine/windowdelegate.h | 5 - include/openspace/util/syncbuffer.h | 6 +- src/engine/openspaceengine.cpp | 8 +- src/engine/syncengine.cpp | 6 +- src/util/syncbuffer.cpp | 4 +- 10 files changed, 316 insertions(+), 399 deletions(-) diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index 267eb2c182..12d4c5bd98 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -111,42 +111,19 @@ target_compile_definitions(OpenSpace PRIVATE begin_header("Dependency: SGCT") set(SGCT_TEXT OFF CACHE BOOL "" FORCE) -set(SGCT_BUILD_CSHARP_PROJECTS OFF CACHE BOOL "" FORCE) -set(SGCT_LIGHT_ONLY ON CACHE BOOL "" FORCE) -set(SGCT_CUSTOMOUTPUTDIRS OFF CACHE BOOL "" FORCE) -set(JPEG_TURBO_WITH_SIMD OFF CACHE BOOL "" FORCE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/sgct) target_include_directories(OpenSpace SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ext/sgct/include) -target_link_libraries( - OpenSpace - sgct_light glew glfw png16_static quat tinyxml2static turbojpeg-static - vrpn ${GLFW_LIBRARIES} -) +target_link_libraries(OpenSpace sgct) -mark_as_advanced(EXECUTABLE_OUTPUT_PATH GLFW_BUILD_DOCS GLFW_BUILD_EXAMPLES - GLFW_BUILD_TESTS GLFW_INSTALL GLFW_USE_HYBRID_HPG GLFW_USE_OSMESA GLFW_VULKAN_STATIC - INSTALL_BIN_DIR INSTALL_INC_DIR INSTALL_LIB_DIR INSTALL_MAN_DIR INSTALL_PKGCONFIG_DIR - IOKIT_LIBRARY JPEG_TURBO_FORCE32bit JPEG_TURBO_WITH_12BIT JPEG_TURBO_WITH_ARITH_DEC - JPEG_TURBO_WITH_ARITH_ENC JPEG_TURBO_WITH_JPEG7 JPEG_TURBO_WITH_JPEG8 - JPEG_TURBO_WITH_MEM_SRCDST JPEG_TURBO_WITH_SIMD JPEG_TURBO_WITH_TURBOJPEG LIB_SUFFIX - LIBRARY_OUTPUT_PATH M_LIBRARY SGCT_BUILD_ALUT SGCT_BUILD_CSHARP_PROJECTS - SGCT_CUSTOMOUTPUTDIRS SGCT_DOXYGEN SGCT_DOXYGEN_QUIET SGCT_EXAMPLES SGCT_INSTALL - SGCT_LIGHT_ONLY SGCT_NO_EXTERNAL_LIBRARIES SGCT_SPOUT_SUPPORT SGCT_TEXT - SGCT_USE_MSVC_RUNTIMES USE_MSVC_RUNTIME_LIBRARY_DLL -) - -set_folder_location(sgct_light "External") -set_folder_location(glew "External/SGCT") +set_folder_location(sgct "External") set_folder_location(glfw "External/SGCT") +set_folder_location(miniziplibstatic "External/SGCT") set_folder_location(png16_static "External/SGCT") set_folder_location(quat "External/SGCT") -set_folder_location(simd "External/SGCT") set_folder_location(tinyxml2static "External/SGCT") -set_folder_location(turbojpeg-static "External/SGCT") set_folder_location(vrpn "External/SGCT") set_folder_location(zlibstatic "External/SGCT") -set_folder_location(miniziplibstatic "External/SGCT") if (UNIX AND (NOT APPLE)) target_link_libraries(OpenSpace Xcursor Xinerama X11) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 3622605062..19799abace 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 3622605062ae61736426e3d8d26e98524ec1fc97 +Subproject commit 19799abace7513623902fa5e43158b6f6a565434 diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index ec47265306..87cb5d9b5c 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -41,21 +41,34 @@ #include #include #include -#include -#include -#include +//#include +#include +#define GLFW_EXPOSE_NATIVE_WIN32 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include +#include #ifdef WIN32 #include #include #include +#include #include #include #include -#include #endif // WIN32 #ifdef OPENVR_SUPPORT @@ -79,6 +92,7 @@ constexpr const bool EnableDetailedVtune = false; #endif // OPENSPACE_HAS_NVTOOLS using namespace openspace; +using namespace sgct; namespace { @@ -86,11 +100,15 @@ constexpr const char* _loggerCat = "main"; constexpr const char* SpoutTag = "Spout"; constexpr const char* OpenVRTag = "OpenVR"; -sgct::Engine* SgctEngine; -sgct::SharedVector _synchronizationBuffer; +// @TODO (abock, 2020-04-09): These state variables should disappear +const Window* currentWindow = nullptr; +const BaseViewport* currentViewport = nullptr; +Frustum::Mode currentFrustumMode; +glm::mat4 currentModelViewProjectionMatrix; +glm::mat4 currentModelMatrix; #ifdef OPENVR_SUPPORT -sgct::SGCTWindow* FirstOpenVRWindow = nullptr; +Window* FirstOpenVRWindow = nullptr; #endif #ifdef OPENSPACE_HAS_VTUNE @@ -214,55 +232,10 @@ LONG WINAPI generateMiniDump(EXCEPTION_POINTERS* exceptionPointers) { } #endif // WIN32 -// -// Detect OpenGL version -// -std::pair supportedOpenGLVersion() { - // Just create a window in order to retrieve the available OpenGL version before we - // create the real window - glfwInit(); - - // On OS X we need to explicitly set the version and specify that we are using CORE - // profile to be able to use glGetIntegerv(GL_MAJOR_VERSION, &major) and - // glGetIntegerv(GL_MINOR_VERSION, &minor) explicitly setting to OGL 3.3 CORE works - // since all Mac's now support at least 3.3 -#ifdef __APPLE__ - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); -#endif - - glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - - // By creating an offscreen window, the user will not know that we created this window - GLFWwindow* offscreen = glfwCreateWindow(128, 128, "", nullptr, nullptr); - glfwMakeContextCurrent(offscreen); - - // Get the OpenGL version - int major, minor; - glGetIntegerv(GL_MAJOR_VERSION, &major); - glGetIntegerv(GL_MINOR_VERSION, &minor); - - // And get rid of the window again - glfwDestroyWindow(offscreen); - glfwWindowHint(GLFW_VISIBLE, GL_TRUE); - - return { major, minor }; -} - -// -// Context creation function -// -void mainContextCreationFunc(GLFWwindow* win) { - // @TODO (abock, 2020-02-10) Remove this after updating SGCT to 3.0 - TracyGpuContext -} - // // Init function // -void mainInitFunc() { +void mainInitFunc(GLFWwindow*) { ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -288,32 +261,33 @@ void mainInitFunc() { icons[0].width = x; icons[0].height = y; - const size_t nWindows = SgctEngine->getNumberOfWindows(); - for (size_t i = 0; i < nWindows; ++i) { - const sgct::SGCTWindow* windowPtr = SgctEngine->getWindowPtr(i); - glfwSetWindowIcon(windowPtr->getWindowHandle(), 1, icons); + for (const std::unique_ptr& window : Engine::instance().windows()) { + glfwSetWindowIcon(window->windowHandle(), 1, icons); } stbi_image_free(icons[0].pixels); } - + currentWindow = Engine::instance().windows().front().get(); + currentViewport = currentWindow->viewports().front().get(); LDEBUG("Initializing OpenGL in OpenSpace Engine started"); global::openSpaceEngine.initializeGL(); LDEBUG("Initializing OpenGL in OpenSpace Engine finished"); + // Find if we have at least one OpenVR window // Save reference to first OpenVR window, which is the one we will copy to the HMD. - for (size_t i = 0; i < SgctEngine->getNumberOfWindows(); ++i) { - if (SgctEngine->getWindowPtr(i)->checkIfTagExists(OpenVRTag)) { + for (const std::unique_ptr& window : Engine::instance().windows()) { + if (window->hasTag(OpenVRTag)) { #ifdef OPENVR_SUPPORT - FirstOpenVRWindow = SgctEngine->getWindowPtr(i); + FirstOpenVRWindow = window.get(); // If we have an OpenVRWindow, initialize OpenVR. - sgct::SGCTOpenVR::initialize( - SgctEngine->getNearClippingPlane(), SgctEngine->getFarClippingPlane() + sgct::OpenVR::initialize( + Engine::instance().nearClippingPlane(), + Engine::instance().farClippingPlane() ); #else LWARNING("OpenVR was requested, but program was compiled without VR support"); @@ -323,11 +297,9 @@ void mainInitFunc() { } } - const size_t nWindows = SgctEngine->getNumberOfWindows(); - for (size_t i = 0; i < nWindows; ++i) { - const sgct::SGCTWindow* windowPtr = SgctEngine->getWindowPtr(i); - - if (!windowPtr->checkIfTagExists(SpoutTag)) { + for (size_t i = 0; i < Engine::instance().windows().size(); ++i) { + Window& window = *Engine::instance().windows()[i]; + if (!window.hasTag(SpoutTag)) { continue; } @@ -336,34 +308,34 @@ void mainInitFunc() { w.windowId = i; - const sgct::SGCTWindow::StereoMode sm = windowPtr->getStereoMode(); - const bool hasStereo = (sm != sgct::SGCTWindow::No_Stereo) && - (sm < sgct::SGCTWindow::Side_By_Side_Stereo); + const Window::StereoMode sm = window.stereoMode(); + const bool hasStereo = (sm != Window::StereoMode::NoStereo) && + (sm < Window::StereoMode::SideBySide); if (hasStereo) { SpoutWindow::SpoutData& left = w.leftOrMain; left.handle = GetSpout(); left.initialized = left.handle->CreateSender( - (windowPtr->getName() + "_left").c_str(), - windowPtr->getXFramebufferResolution(), - windowPtr->getYFramebufferResolution() + (window.name() + "_left").c_str(), + window.framebufferResolution().x, + window.framebufferResolution().y ); SpoutWindow::SpoutData& right = w.right; right.handle = GetSpout(); right.initialized = right.handle->CreateSender( - (windowPtr->getName() + "_right").c_str(), - windowPtr->getXFramebufferResolution(), - windowPtr->getYFramebufferResolution() + (window.name() + "_right").c_str(), + window.framebufferResolution().x, + window.framebufferResolution().y ); } else { SpoutWindow::SpoutData& main = w.leftOrMain; main.handle = GetSpout(); main.initialized = main.handle->CreateSender( - windowPtr->getName().c_str(), - windowPtr->getXFramebufferResolution(), - windowPtr->getYFramebufferResolution() + window.name().c_str(), + window.framebufferResolution().x, + window.framebufferResolution().y ); } @@ -392,23 +364,8 @@ void mainInitFunc() { ); } - for (size_t i = 0; i < nWindows; ++i) { - sgct::SGCTWindow* w = SgctEngine->getWindowPtr(i); - const std::string screenshotNames = nWindows > 1 ? - fmt::format("OpenSpace_{}", i) : - "OpenSpace"; + Settings::instance().setCapturePath(absPath(screenshotPath)); - sgct_core::ScreenCapture* cpt0 = w->getScreenCapturePointer(0); - sgct_core::ScreenCapture* cpt1 = w->getScreenCapturePointer(1); - - if (cpt0) { - cpt0->setPathAndFileName(absPath(screenshotPath), screenshotNames); - } - - if (cpt1) { - cpt1->setPathAndFileName(absPath(screenshotPath), screenshotNames); - } - } LTRACE("main::mainInitFunc(end)"); #ifdef OPENSPACE_HAS_VTUNE @@ -421,10 +378,6 @@ void mainInitFunc() { void mainPreSyncFunc() { - // @TODO (abock, 2020-02-10) Remove this after merging SGCT version 3.0 - FrameMark - - ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -439,7 +392,7 @@ void mainPreSyncFunc() { } catch (const ghoul::RuntimeError& e) { LFATALC(e.component, e.message); - sgct::Engine::instance()->terminate(); + Engine::instance().terminate(); } // Query joystick status @@ -459,13 +412,13 @@ void mainPreSyncFunc() { if (!state.isConnected) { // Joystick was added state.isConnected = true; - state.name = sgct::Engine::getJoystickName(i); + state.name = glfwGetJoystickName(i); std::fill(state.axes.begin(), state.axes.end(), 0.f); std::fill(state.buttons.begin(), state.buttons.end(), JoystickAction::Idle); } - const float* axes = sgct::Engine::getJoystickAxes(i, &state.nAxes); + const float* axes = glfwGetJoystickAxes(i, &state.nAxes); if (state.nAxes > JoystickInputState::MaxAxes) { LWARNING(fmt::format( "Joystick/Gamepad {} has {} axes, but only {} axes are supported. " @@ -476,10 +429,7 @@ void mainPreSyncFunc() { } std::memcpy(state.axes.data(), axes, state.nAxes * sizeof(float)); - const unsigned char* buttons = sgct::Engine::getJoystickButtons( - i, - &state.nButtons - ); + const unsigned char* buttons = glfwGetJoystickButtons(i, &state.nButtons); if (state.nButtons > JoystickInputState::MaxButtons) { LWARNING(fmt::format( @@ -566,7 +516,7 @@ void mainPostSyncPreDrawFunc() { -void mainRenderFunc() { +void mainRenderFunc(const RenderData& data) { ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -579,10 +529,31 @@ void mainRenderFunc() { #endif // OPENSPACE_HAS_NVTOOLS LTRACE("main::mainRenderFunc(begin)"); - glm::mat4 viewMatrix = SgctEngine->getCurrentViewMatrix() * - glm::translate(glm::mat4(1.f), sgct::Engine::getDefaultUserPtr()->getPos()); + currentWindow = &data.window; + currentViewport = &data.viewport; + currentFrustumMode = data.frustumMode; - glm::mat4 projectionMatrix = SgctEngine->getCurrentProjectionMatrix(); + glm::vec3 pos; + std::memcpy( + glm::value_ptr(pos), + &Engine::instance().defaultUser().posMono().x, + sizeof(vec3) + ); + + glm::mat4 viewMatrix; + std::memcpy( + glm::value_ptr(viewMatrix), + data.viewMatrix.values, + sizeof(mat4) + ); + viewMatrix = viewMatrix * glm::translate(glm::mat4(1.f), pos); + + glm::mat4 projectionMatrix; + std::memcpy( + glm::value_ptr(projectionMatrix), + data.projectionMatrix.values, + sizeof(mat4) + ); #ifdef OPENVR_SUPPORT bool currentWindowIsHMD = FirstOpenVRWindow == SgctEngine->getCurrentWindowPtr(); if (sgct::SGCTOpenVR::isHMDActive() && currentWindowIsHMD) { @@ -593,11 +564,15 @@ void mainRenderFunc() { #endif try { - global::openSpaceEngine.render( - SgctEngine->getModelMatrix(), - viewMatrix, - projectionMatrix + glm::mat4 modelMatrix; + std::memcpy( + glm::value_ptr(modelMatrix), + data.modelMatrix.values, + sizeof(mat4) ); + currentModelMatrix = modelMatrix; + currentModelViewProjectionMatrix = modelMatrix * viewMatrix * projectionMatrix; + global::openSpaceEngine.render(modelMatrix, viewMatrix, projectionMatrix); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.message); @@ -616,7 +591,7 @@ void mainRenderFunc() { -void mainDraw2DFunc() { +void mainDraw2DFunc(const RenderData& data) { ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -626,6 +601,10 @@ void mainDraw2DFunc() { #endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainDraw2DFunc(begin)"); + currentWindow = &data.window; + currentViewport = &data.viewport; + currentFrustumMode = data.frustumMode; + try { global::openSpaceEngine.drawOverlays(); } @@ -661,7 +640,7 @@ void mainPostDrawFunc() { #ifdef OPENVR_SUPPORT if (FirstOpenVRWindow) { // Copy the first OpenVR window to the HMD - sgct::SGCTOpenVR::copyWindowToHMD(FirstOpenVRWindow); + sgct::OpenVR::copyWindowToHMD(FirstOpenVRWindow); } #endif // OPENVR_SUPPORT @@ -669,26 +648,26 @@ void mainPostDrawFunc() { #ifdef OPENSPACE_HAS_SPOUT for (const SpoutWindow& w : SpoutWindows) { - sgct::SGCTWindow* window = SgctEngine->getWindowPtr(w.windowId); + sgct::Window& window = *Engine::instance().windows()[w.windowId]; if (w.leftOrMain.initialized) { - const GLuint texId = window->getFrameBufferTexture(sgct::Engine::LeftEye); + const GLuint texId = window.frameBufferTexture(Window::TextureIndex::LeftEye); glBindTexture(GL_TEXTURE_2D, texId); w.leftOrMain.handle->SendTexture( texId, GL_TEXTURE_2D, - window->getXFramebufferResolution(), - window->getYFramebufferResolution() + window.framebufferResolution().x, + window.framebufferResolution().y ); } if (w.right.initialized) { - const GLuint texId = window->getFrameBufferTexture(sgct::Engine::RightEye); + const GLuint texId = window.frameBufferTexture(Window::TextureIndex::RightEye); glBindTexture(GL_TEXTURE_2D, texId); w.right.handle->SendTexture( texId, GL_TEXTURE_2D, - window->getXFramebufferResolution(), - window->getYFramebufferResolution() + window.framebufferResolution().x, + window.framebufferResolution().y ); } } @@ -705,7 +684,9 @@ void mainPostDrawFunc() { -void mainKeyboardCallback(int key, int, int action, int modifiers) { +void mainKeyboardCallback(sgct::Key key, sgct::Modifier modifiers, sgct::Action action, + int) +{ ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -715,7 +696,7 @@ void mainKeyboardCallback(int key, int, int action, int modifiers) { #endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainKeyboardCallback(begin)"); - const Key k = Key(key); + const openspace::Key k = openspace::Key(key); const KeyModifier m = KeyModifier(modifiers); const KeyAction a = KeyAction(action); global::openSpaceEngine.keyboardCallback(k, m, a); @@ -730,7 +711,9 @@ void mainKeyboardCallback(int key, int, int action, int modifiers) { -void mainMouseButtonCallback(int key, int action, int modifiers) { +void mainMouseButtonCallback(sgct::MouseButton key, sgct::Modifier modifiers, + sgct::Action action) +{ ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -740,9 +723,9 @@ void mainMouseButtonCallback(int key, int action, int modifiers) { #endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainMouseButtonCallback(begin)"); - const MouseButton k = MouseButton(key); - const MouseAction a = MouseAction(action); - const KeyModifier m = KeyModifier(modifiers); + const openspace::MouseButton k = openspace::MouseButton(key); + const openspace::MouseAction a = openspace::MouseAction(action); + const openspace::KeyModifier m = openspace::KeyModifier(modifiers); global::openSpaceEngine.mouseButtonCallback(k, a, m); LTRACE("main::mainMouseButtonCallback(end)"); @@ -818,7 +801,7 @@ void mainCharCallback(unsigned int codepoint, int modifiers) { -void mainEncodeFun() { +std::vector mainEncodeFun() { ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -828,9 +811,7 @@ void mainEncodeFun() { #endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainEncodeFun(begin)"); - std::vector data = global::openSpaceEngine.encode(); - _synchronizationBuffer.setVal(std::move(data)); - sgct::SharedData::instance()->writeVector(&_synchronizationBuffer); + std::vector data = global::openSpaceEngine.encode(); LTRACE("main::mainEncodeFun(end)"); #ifdef OPENSPACE_HAS_VTUNE @@ -838,11 +819,13 @@ void mainEncodeFun() { __itt_frame_end_v3(_vTune.encode, nullptr); } #endif // OPENSPACE_HAS_VTUNE + + return data; } -void mainDecodeFun() { +void mainDecodeFun(const std::vector& data, unsigned int) { ZoneScoped #ifdef OPENSPACE_HAS_VTUNE @@ -852,9 +835,7 @@ void mainDecodeFun() { #endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainDecodeFun(begin)"); - sgct::SharedData::instance()->readVector(&_synchronizationBuffer); - std::vector data = _synchronizationBuffer.getVal(); - global::openSpaceEngine.decode(std::move(data)); + global::openSpaceEngine.decode(data); LTRACE("main::mainDecodeFun(end)"); #ifdef OPENSPACE_HAS_VTUNE @@ -866,17 +847,24 @@ void mainDecodeFun() { -void mainLogCallback(const char* msg) { +void mainLogCallback(Log::Level level, const char* message) { ZoneScoped - std::string message = msg; - if (message.empty() || message == ".") { - // We don't want the empty '.' message that SGCT sends while it is waiting for - // connections from other network nodes - return; - } + std::string msg = message; // Remove the trailing \n that is passed along - LINFOC("SGCT", message.substr(0, message.size() - 1)); + switch (level) { + case Log::Level::Debug: + LDEBUGC("SGCT", msg.substr(0, msg.size() - 1)); + break; + case Log::Level::Info: + LINFOC("SGCT", msg.substr(0, msg.size() - 1)); + break; + case Log::Level::Warning: + LWARNINGC("SGCT", msg.substr(0, msg.size() - 1)); + break; + case Log::Level::Error: + LERRORC("SGCT", msg.substr(0, msg.size() - 1)); + break; } } // namespace @@ -884,57 +872,52 @@ void mainLogCallback(const char* msg) { void setSgctDelegateFunctions() { WindowDelegate& sgctDelegate = global::windowDelegate; - sgctDelegate.terminate = []() { sgct::Engine::instance()->terminate(); }; + sgctDelegate.terminate = []() { Engine::instance().terminate(); }; sgctDelegate.setBarrier = [](bool enabled) { ZoneScoped - sgct::SGCTWindow::setBarrier(enabled); + sgct::Window::setBarrier(enabled); }; sgctDelegate.setSynchronization = [](bool enabled) { ZoneScoped - sgct_core::ClusterManager::instance()->setUseIgnoreSync(enabled); + sgct::ClusterManager::instance().setUseIgnoreSync(enabled); }; sgctDelegate.clearAllWindows = [](const glm::vec4& clearColor) { ZoneScoped - size_t n = sgct::Engine::instance()->getNumberOfWindows(); - for (size_t i = 0; i < n; ++i) { + for (const std::unique_ptr& window : Engine::instance().windows()) { glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - GLFWwindow* w = sgct::Engine::instance()->getWindowPtr(i)->getWindowHandle(); - glfwSwapBuffers(w); + glfwSwapBuffers(window->windowHandle()); } }; sgctDelegate.windowHasResized = []() { ZoneScoped - return sgct::Engine::instance()->getCurrentWindowPtr()->isWindowResized(); + return currentWindow->isWindowResized(); }; sgctDelegate.averageDeltaTime = []() { ZoneScoped - return sgct::Engine::instance()->getAvgDt(); - }; - sgctDelegate.deltaTimeStandardDeviation = []() { - ZoneScoped - - return sgct::Engine::instance()->getDtStandardDeviation(); + return Engine::instance().statistics().avgDt( + Engine::instance().currentFrameNumber() + ); }; sgctDelegate.minDeltaTime = []() { ZoneScoped - return sgct::Engine::instance()->getMinDt(); + return Engine::instance().statistics().minDt(); }; sgctDelegate.maxDeltaTime = []() { ZoneScoped - return sgct::Engine::instance()->getMaxDt(); + return Engine::instance().statistics().maxDt(); }; sgctDelegate.deltaTime = []() { ZoneScoped - return sgct::Engine::instance()->getDt(); + return Engine::instance().statistics().dt(); }; sgctDelegate.applicationTime = []() { ZoneScoped @@ -944,18 +927,17 @@ void setSgctDelegateFunctions() { sgctDelegate.mousePosition = []() { ZoneScoped - int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId(); - double posX, posY; - sgct::Engine::getMousePos(id, &posX, &posY); - return glm::vec2(posX, posY); + double xPos; + double yPos; + glfwGetCursorPos(currentWindow->windowHandle(), &xPos, &yPos); + return glm::vec2(xPos, yPos); }; sgctDelegate.mouseButtons = [](int maxNumber) { ZoneScoped - int id = sgct::Engine::instance()->getCurrentWindowPtr()->getId(); uint32_t result = 0; for (int i = 0; i < maxNumber; ++i) { - bool button = (sgct::Engine::getMouseButton(id, i) != 0); + bool button = (glfwGetMouseButton(currentWindow->windowHandle(), i) != 0); if (button) { result |= (1 << i); } @@ -965,59 +947,62 @@ void setSgctDelegateFunctions() { sgctDelegate.currentWindowSize = []() { ZoneScoped - return glm::ivec2( - sgct::Engine::instance()->getCurrentWindowPtr()->getXResolution(), - sgct::Engine::instance()->getCurrentWindowPtr()->getYResolution()); + return glm::ivec2(currentWindow->resolution().x, currentWindow->resolution().y); }; sgctDelegate.currentSubwindowSize = []() { ZoneScoped - auto window = sgct::Engine::instance()->getCurrentWindowPtr(); - if (sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfViewports() > 1) { - sgct_core::Viewport* viewport = - sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0); - return glm::ivec2(window->getXResolution()*viewport->getXSize(), window->getYResolution()*viewport->getYSize()); + if (currentWindow->viewports().size() > 1) { + const Viewport& viewport = *currentWindow->viewports().front(); + return glm::ivec2( + currentWindow->resolution().x * viewport.size().x, + currentWindow->resolution().y * viewport.size().y + ); } - switch (window->getStereoMode()) { - case sgct::SGCTWindow::Side_By_Side_Stereo: - case sgct::SGCTWindow::Side_By_Side_Inverted_Stereo: - return glm::ivec2(window->getXResolution() / 2, window->getYResolution()); - case sgct::SGCTWindow::Top_Bottom_Stereo: - case sgct::SGCTWindow::Top_Bottom_Inverted_Stereo: - return glm::ivec2(window->getXResolution(), window->getYResolution() / 2); + switch (currentWindow->stereoMode()) { + case Window::StereoMode::SideBySide: + case Window::StereoMode::SideBySideInverted: + return glm::ivec2( + currentWindow->resolution().x / 2, + currentWindow->resolution().y + ); + case Window::StereoMode::TopBottom: + case Window::StereoMode::TopBottomInverted: + return glm::ivec2( + currentWindow->resolution().x, + currentWindow->resolution().y / 2 + ); default: - return glm::ivec2(window->getXResolution(), window->getYResolution()); + return glm::ivec2( + currentWindow->resolution().x, + currentWindow->resolution().y + ); } }; sgctDelegate.currentWindowResolution = []() { ZoneScoped - int x, y; - auto window = sgct::Engine::instance()->getCurrentWindowPtr(); - window->getFinalFBODimensions(x, y); - return glm::ivec2(x, y); + ivec2 dim = currentWindow->finalFBODimensions(); + return glm::ivec2(dim.x, dim.y); }; sgctDelegate.currentDrawBufferResolution = []() { ZoneScoped - sgct_core::Viewport* viewport = - sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0); + Viewport* viewport = currentWindow->viewports().front().get(); if (viewport != nullptr) { - if (viewport->hasSubViewports() && viewport->getNonLinearProjectionPtr()) { - int res = viewport->getNonLinearProjectionPtr()->getCubemapResolution(); + if (viewport->hasSubViewports() && viewport->nonLinearProjection()) { + int res = viewport->nonLinearProjection()->cubemapResolution(); return glm::ivec2(res, res); } - else if (sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfViewports() > 1) { - int x, y; - auto window = sgct::Engine::instance()->getCurrentWindowPtr(); - window->getFinalFBODimensions(x, y); - return glm::ivec2(x*viewport->getXSize(), y*viewport->getYSize()); + else if (currentWindow->viewports().size() > 1) { + // @TODO (abock, 2020-04-09) This should probably be based on the current + // viewport? + ivec2 dim = currentWindow->finalFBODimensions(); + return glm::ivec2(dim.x * viewport->size().x, dim.y * viewport->size().y); } else { - int x, y; - auto window = sgct::Engine::instance()->getCurrentWindowPtr(); - window->getFinalFBODimensions(x, y); - return glm::ivec2(x, y); + ivec2 dim = currentWindow->finalFBODimensions(); + return glm::ivec2(dim.x, dim.y); } } return glm::ivec2(-1, -1); @@ -1025,35 +1010,28 @@ void setSgctDelegateFunctions() { sgctDelegate.currentViewportSize = []() { ZoneScoped - sgct_core::Viewport* viewport = - sgct::Engine::instance()->getCurrentWindowPtr()->getViewport(0); - if (viewport != nullptr) { - int x = 0; - int y = 0; - sgct::Engine::instance()->getCurrentViewportSize(x, y); - return glm::ivec2(x, y); + if (currentViewport != nullptr) { + vec2 size = currentViewport->size(); + return glm::ivec2(size.x, size.y); } return glm::ivec2(-1, -1); }; sgctDelegate.dpiScaling = []() { ZoneScoped - return glm::vec2( - sgct::Engine::instance()->getCurrentWindowPtr()->getXScale(), - sgct::Engine::instance()->getCurrentWindowPtr()->getYScale() - ); + vec2 scale = currentWindow->scale(); + return glm::vec2(scale.x, scale.y); }; sgctDelegate.currentNumberOfAaSamples = []() { ZoneScoped - return sgct::Engine::instance()->getCurrentWindowPtr()->getNumberOfAASamples(); + return currentWindow->numberOfAASamples(); }; sgctDelegate.hasGuiWindow = []() { ZoneScoped - auto engine = sgct::Engine::instance(); - for (size_t i = 0; i < engine->getNumberOfWindows(); ++i) { - if (engine->getWindowPtr(i)->checkIfTagExists("GUI")) { + for (const std::unique_ptr& window : Engine::instance().windows()) { + if (window->hasTag("GUI")) { return true; } } @@ -1062,77 +1040,76 @@ void setSgctDelegateFunctions() { sgctDelegate.isGuiWindow = []() { ZoneScoped - return sgct::Engine::instance()->getCurrentWindowPtr()->checkIfTagExists("GUI"); + return currentWindow->hasTag("GUI"); }; sgctDelegate.isMaster = []() { ZoneScoped - return sgct::Engine::instance()->isMaster(); + return Engine::instance().isMaster(); }; sgctDelegate.isUsingSwapGroups = []() { ZoneScoped - return sgct::SGCTWindow::isUsingSwapGroups(); + return Window::isUsingSwapGroups(); }; sgctDelegate.isSwapGroupMaster = []() { ZoneScoped - return sgct::SGCTWindow::isSwapGroupMaster(); + return Window::isSwapGroupMaster(); }; sgctDelegate.viewProjectionMatrix = []() { ZoneScoped - return sgct::Engine::instance()->getCurrentModelViewProjectionMatrix(); + return currentModelViewProjectionMatrix; }; sgctDelegate.modelMatrix = []() { ZoneScoped - return sgct::Engine::instance()->getModelMatrix(); + return currentModelMatrix; }; sgctDelegate.setNearFarClippingPlane = [](float nearPlane, float farPlane) { ZoneScoped - sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane); + Engine::instance().setNearAndFarClippingPlanes(nearPlane, farPlane); }; sgctDelegate.setEyeSeparationDistance = [](float distance) { ZoneScoped - sgct::Engine::instance()->setEyeSeparation(distance); + Engine::instance().setEyeSeparation(distance); }; - sgctDelegate.viewportPixelCoordinates = []() { - ZoneScoped + //sgctDelegate.viewportPixelCoordinates = []() { + // ZoneScoped - sgct::SGCTWindow* window = sgct::Engine::instance()->getCurrentWindowPtr(); - if (!window || !window->getCurrentViewport()) { - return glm::ivec4(0); - } - else { - const int* data = sgct::Engine::instance()->getCurrentViewportPixelCoords(); - return glm::ivec4(data[0], data[2], data[1], data[3]); - } - }; - sgctDelegate.sendMessageToExternalControl = [](const std::vector& message) { - ZoneScoped + // if (!currentWindow|| !currentViewport) { + // return glm::ivec4(0); + // } + // else { + // const int* data = cur sgct::Engine::instance()->getCurrentViewportPixelCoords(); + // return glm::ivec4(data[0], data[2], data[1], data[3]); + // } + //}; + //sgctDelegate.sendMessageToExternalControl = [](const std::vector& message) { + // ZoneScoped - sgct::Engine::instance()->sendMessageToExternalControl( - message.data(), - static_cast(message.size()) - ); - }; + // + // sgct::Engine::instance()->sendMessageToExternalControl( + // message.data(), + // static_cast(message.size()) + // ); + //}; sgctDelegate.isFisheyeRendering = []() { ZoneScoped - sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr(); - return dynamic_cast( - w->getViewport(0)->getNonLinearProjectionPtr() + return dynamic_cast( + currentWindow->viewports().front()->nonLinearProjection() ) != nullptr; }; sgctDelegate.takeScreenshot = [](bool applyWarping) { ZoneScoped - sgct::SGCTSettings::instance()->setCaptureFromBackBuffer(applyWarping); - sgct::Engine::instance()->takeScreenshot(); - return sgct::Engine::instance()->getScreenShotNumber(); + Settings::instance().setCaptureFromBackBuffer(applyWarping); + Engine::instance().takeScreenshot(); + return Engine::instance().screenShotNumber(); }; sgctDelegate.swapBuffer = []() { ZoneScoped @@ -1144,12 +1121,12 @@ void setSgctDelegateFunctions() { sgctDelegate.nWindows = []() { ZoneScoped - return static_cast(sgct::Engine::instance()->getNumberOfWindows()); + return static_cast(Engine::instance().windows().size()); }; sgctDelegate.currentWindowId = []() { ZoneScoped - return sgct::Engine::instance()->getCurrentWindowPtr()->getId(); + return currentWindow->id(); }; sgctDelegate.openGLProcedureAddress = [](const char* func) { ZoneScoped @@ -1160,23 +1137,22 @@ void setSgctDelegateFunctions() { ZoneScoped return static_cast( - sgct::Engine::instance()->getWindowPtr(0)->getHorizFieldOfViewDegrees() + Engine::instance().windows().front()->horizFieldOfViewDegrees() ); }; sgctDelegate.setHorizFieldOfView = [](float hFovDeg) { ZoneScoped - sgct::SGCTWindow* w = sgct::Engine::instance()->getWindowPtr(0); - w->setHorizFieldOfView(hFovDeg); + Engine::instance().windows().front()->setHorizFieldOfView(hFovDeg); }; #ifdef WIN32 sgctDelegate.getNativeWindowHandle = [](size_t windowIndex) -> void* { ZoneScoped - sgct::SGCTWindow* w = sgct::Engine::instance()->getWindowPtr(windowIndex); + Window* w = Engine::instance().windows()[windowIndex].get(); if (w) { - HWND hWnd = glfwGetWin32Window(w->getWindowHandle()); - return reinterpret_cast(hWnd); + HWND hWnd = glfwGetWin32Window(w->windowHandle()); + return reinterpret_cast(hWnd); } return nullptr; }; @@ -1184,19 +1160,17 @@ void setSgctDelegateFunctions() { sgctDelegate.frustumMode = []() { ZoneScoped - using FM = sgct_core::Frustum::FrustumMode; - switch (sgct::Engine::instance()->getCurrentFrustumMode()) { - case FM::MonoEye: return WindowDelegate::Frustum::Mono; - case FM::StereoLeftEye: return WindowDelegate::Frustum::LeftEye; - case FM::StereoRightEye: return WindowDelegate::Frustum::RightEye; + switch (currentFrustumMode) { + default: + case Frustum::Mode::MonoEye: return WindowDelegate::Frustum::Mono; + case Frustum::Mode::StereoLeftEye: return WindowDelegate::Frustum::LeftEye; + case Frustum::Mode::StereoRightEye: return WindowDelegate::Frustum::RightEye; } }; - sgctDelegate.swapGroupFrameNumber = []() { + sgctDelegate.swapGroupFrameNumber = []() -> uint64_t { ZoneScoped - unsigned int fn = 0; - sgct::Engine::instance()->getCurrentWindowPtr()->getSwapGroupFrameNumber(fn); - return static_cast(fn); + return currentWindow->swapGroupFrameNumber(); }; } @@ -1366,59 +1340,45 @@ int main(int argc, char** argv) { arguments.insert(arguments.begin() + 2, absPath(windowConfiguration)); // Need to set this before the creation of the sgct::Engine - sgct::MessageHandler::instance()->setLogToConsole(false); - sgct::MessageHandler::instance()->setShowTime(false); - sgct::MessageHandler::instance()->setLogToCallback(true); - sgct::MessageHandler::instance()->setLogCallback(mainLogCallback); + + Log::instance().setLogToConsole(false); + Log::instance().setShowTime(false); + Log::instance().setLogCallback(mainLogCallback); #ifdef __APPLE__ glfwWindowHint(GLFW_STENCIL_BITS, 8); #endif LDEBUG("Creating SGCT Engine"); - SgctEngine = new sgct::Engine(arguments); + std::vector arg(argv + 1, argv + argc); + Configuration config = parseArguments(arg); + config::Cluster cluster = loadCluster(windowConfiguration); - // Bind functions - SgctEngine->setContextCreationCallback(mainContextCreationFunc); - SgctEngine->setInitOGLFunction(mainInitFunc); - SgctEngine->setPreSyncFunction(mainPreSyncFunc); - SgctEngine->setPostSyncPreDrawFunction(mainPostSyncPreDrawFunc); - SgctEngine->setDrawFunction(mainRenderFunc); - SgctEngine->setDraw2DFunction(mainDraw2DFunc); - SgctEngine->setPostDrawFunction(mainPostDrawFunc); - SgctEngine->setKeyboardCallbackFunction(mainKeyboardCallback); - SgctEngine->setMouseButtonCallbackFunction(mainMouseButtonCallback); - SgctEngine->setMousePosCallbackFunction(mainMousePosCallback); - SgctEngine->setMouseScrollCallbackFunction(mainMouseScrollCallback); - SgctEngine->setCharCallbackFunction(mainCharCallback); + Engine::Callbacks callbacks; + callbacks.initOpenGL = mainInitFunc; + callbacks.preSync = mainPreSyncFunc; + callbacks.postSyncPreDraw = mainPostSyncPreDrawFunc; + callbacks.draw = mainRenderFunc; + callbacks.draw2D = mainDraw2DFunc; + callbacks.postDraw = mainPostDrawFunc; + callbacks.keyboard = mainKeyboardCallback; + callbacks.mouseButton = mainMouseButtonCallback; + callbacks.mousePos = mainMousePosCallback; + callbacks.mouseScroll = mainMouseScrollCallback; + callbacks.character = mainCharCallback; + callbacks.encode = mainEncodeFun; + callbacks.decode = mainDecodeFun; + Log::instance().setNotifyLevel(Log::Level::Debug); - // Disable the immediate exit of the application when the ESC key is pressed - SgctEngine->setExitKey(SGCT_KEY_UNKNOWN); - - sgct::MessageHandler::instance()->setNotifyLevel(sgct::MessageHandler::NOTIFY_ALL); - - // Set encode and decode functions - // NOTE: starts synchronizing before init functions - sgct::SharedData::instance()->setEncodeFunction(mainEncodeFun); - sgct::SharedData::instance()->setDecodeFunction(mainDecodeFun); - - // Try to open a window - LDEBUG("Initialize SGCT Engine"); - std::map, sgct::Engine::RunMode> versionMapping = { - { { 3, 3 }, sgct::Engine::RunMode::OpenGL_3_3_Core_Profile }, - { { 4, 0 }, sgct::Engine::RunMode::OpenGL_4_0_Core_Profile }, - { { 4, 1 }, sgct::Engine::RunMode::OpenGL_4_1_Core_Profile }, - { { 4, 2 }, sgct::Engine::RunMode::OpenGL_4_2_Core_Profile }, - { { 4, 3 }, sgct::Engine::RunMode::OpenGL_4_3_Core_Profile }, - { { 4, 4 }, sgct::Engine::RunMode::OpenGL_4_4_Core_Profile }, - { { 4, 5 }, sgct::Engine::RunMode::OpenGL_4_5_Core_Profile }, - { { 4, 6 }, sgct::Engine::RunMode::OpenGL_4_6_Core_Profile } - }; - - - std::pair version = supportedOpenGLVersion(); - LINFO(fmt::format("Detected OpenGL version: {}.{}", version.first, version.second)); - bool initSuccess = SgctEngine->init(versionMapping[version]); + try { + Engine::create(cluster, callbacks, config); + } + catch (...) { + Engine::destroy(); + global::openSpaceEngine.deinitialize(); + ghoul::deinitialize(); + throw; + } #ifdef __APPLE__ // Workaround for OpenGL bug that Apple introduced in 10.14 Mojave that prevents an @@ -1431,9 +1391,8 @@ int main(int argc, char** argv) { // machine. If the loading screen shows up without doing anything to the window, it // is fixed. With the bug, the rendering stays gray even well after the main render // loop has started -- 2018-10-28 abock - size_t n = sgct::Engine::instance()->getNumberOfWindows(); - for (size_t i = 0; i < n; ++i) { - GLFWwindow* w = sgct::Engine::instance()->getWindowPtr(i)->getWindowHandle(); + for (const std::unique_ptr& window : Engine::instance().windows()) { + GLFWwindow* w = window->windowHandle(); int x, y; glfwGetWindowPos(w, &x, &y); glfwSetWindowPos(w, x + 1, y + 1); @@ -1448,53 +1407,39 @@ int main(int argc, char** argv) { // Do not print message if slaves are waiting for the master // Only timeout after 15 minutes - SgctEngine->setSyncParameters(false, 15.f * 60.f); + Engine::instance().setSyncParameters(false, 15.f * 60.f); - auto cleanup = [&](bool isInitialized) { - if (isInitialized) { - global::openSpaceEngine.deinitializeGL(); - global::openSpaceEngine.deinitialize(); - } + LINFO("Starting rendering loop"); + Engine::instance().render(); + LINFO("Ending rendering loop"); - // Clear function bindings to avoid crash after destroying the OpenSpace Engine - sgct::MessageHandler::instance()->setLogToCallback(false); - sgct::MessageHandler::instance()->setLogCallback(nullptr); + global::openSpaceEngine.deinitializeGL(); + global::openSpaceEngine.deinitialize(); - LDEBUG("Destroying SGCT Engine"); - delete SgctEngine; + // Clear function bindings to avoid crash after destroying the OpenSpace Engine + Log::instance().setLogCallback(nullptr); + + LDEBUG("Destroying SGCT Engine"); + Engine::destroy(); #ifdef OPENVR_SUPPORT - // Clean up OpenVR - sgct::SGCTOpenVR::shutdown(); + // Clean up OpenVR + sgct::SGCTOpenVR::shutdown(); #endif #ifdef OPENSPACE_HAS_SPOUT - for (SpoutWindow& w : SpoutWindows) { - if (w.leftOrMain.handle) { - w.leftOrMain.handle->ReleaseReceiver(); - w.leftOrMain.handle->Release(); - } - if (w.right.handle) { - w.right.handle->ReleaseReceiver(); - w.right.handle->Release(); - } + for (SpoutWindow& w : SpoutWindows) { + if (w.leftOrMain.handle) { + w.leftOrMain.handle->ReleaseReceiver(); + w.leftOrMain.handle->Release(); } + if (w.right.handle) { + w.right.handle->ReleaseReceiver(); + w.right.handle->Release(); + } + } #endif // OPENSPACE_HAS_SPOUT - ghoul::deinitialize(); - }; - - if (!initSuccess) { - LFATAL("Initializing failed"); - cleanup(false); - return EXIT_FAILURE; - } - - LINFO("Starting rendering loop"); - SgctEngine->render(); - LINFO("Ending rendering loop"); - - cleanup(true); - + ghoul::deinitialize(); exit(EXIT_SUCCESS); } diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 539530cad0..2e076e82c4 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -84,8 +84,8 @@ public: void touchDetectionCallback(TouchInput input); void touchUpdateCallback(TouchInput input); void touchExitCallback(TouchInput input); - std::vector encode(); - void decode(std::vector data); + std::vector encode(); + void decode(std::vector data); void scheduleLoadSingleAsset(std::string assetPath); void toggleShutdownMode(); diff --git a/include/openspace/engine/syncengine.h b/include/openspace/engine/syncengine.h index 5b5b4f2d89..67902b34ee 100644 --- a/include/openspace/engine/syncengine.h +++ b/include/openspace/engine/syncengine.h @@ -53,13 +53,13 @@ public: * Encodes all added Syncables in the injected SyncBuffer. * This method is only called on the SGCT master node */ - std::vector encodeSyncables(); + std::vector encodeSyncables(); /** * Decodes the SyncBuffer into the added Syncables. * This method is only called on the SGCT slave nodes */ - void decodeSyncables(std::vector data); + void decodeSyncables(std::vector data); /** * Invokes the presync method of all added Syncables diff --git a/include/openspace/engine/windowdelegate.h b/include/openspace/engine/windowdelegate.h index 1bef12d181..c2a776dd4b 100644 --- a/include/openspace/engine/windowdelegate.h +++ b/include/openspace/engine/windowdelegate.h @@ -94,11 +94,6 @@ struct WindowDelegate { void (*setEyeSeparationDistance)(float distance) = [](float) {}; - glm::ivec4 (*viewportPixelCoordinates)() = []() { return glm::ivec4(0, 0, 0, 0); }; - - void (*sendMessageToExternalControl)(const std::vector& message) = - [](const std::vector&) {}; - bool (*isFisheyeRendering)() = []() { return false; }; unsigned int(*takeScreenshot)(bool applyWarping) = [](bool) { return 0u; }; diff --git a/include/openspace/util/syncbuffer.h b/include/openspace/util/syncbuffer.h index 4f2a7ed370..c73d05270c 100644 --- a/include/openspace/util/syncbuffer.h +++ b/include/openspace/util/syncbuffer.h @@ -57,14 +57,14 @@ public: //void write(); //void read(); - void setData(std::vector data); - std::vector data(); + void setData(std::vector data); + std::vector data(); private: size_t _n; size_t _encodeOffset = 0; size_t _decodeOffset = 0; - std::vector _dataStream; + std::vector _dataStream; }; } // namespace openspace diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 2ed17ecb9a..e782b56c8d 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -673,9 +673,9 @@ void OpenSpaceEngine::initializeGL() { global::moduleEngine.initializeGL(); + for (const std::function& func : global::callback::initializeGL) { ZoneScopedN("[Module] initializeGL") - func(); } @@ -1452,14 +1452,14 @@ void OpenSpaceEngine::touchExitCallback(TouchInput input) { } -std::vector OpenSpaceEngine::encode() { +std::vector OpenSpaceEngine::encode() { ZoneScoped - std::vector buffer = global::syncEngine.encodeSyncables(); + std::vector buffer = global::syncEngine.encodeSyncables(); return buffer; } -void OpenSpaceEngine::decode(std::vector data) { +void OpenSpaceEngine::decode(std::vector data) { ZoneScoped global::syncEngine.decodeSyncables(std::move(data)); diff --git a/src/engine/syncengine.cpp b/src/engine/syncengine.cpp index f3f341ce74..c2dca81352 100644 --- a/src/engine/syncengine.cpp +++ b/src/engine/syncengine.cpp @@ -38,18 +38,18 @@ SyncEngine::SyncEngine(unsigned int syncBufferSize) } // Should be called on sgct master -std::vector SyncEngine::encodeSyncables() { +std::vector SyncEngine::encodeSyncables() { for (Syncable* syncable : _syncables) { syncable->encode(&_syncBuffer); } - std::vector data = _syncBuffer.data(); + std::vector data = _syncBuffer.data(); _syncBuffer.reset(); return data; } // Should be called on sgct slaves -void SyncEngine::decodeSyncables(std::vector data) { +void SyncEngine::decodeSyncables(std::vector data) { _syncBuffer.setData(std::move(data)); for (Syncable* syncable : _syncables) { syncable->decode(&_syncBuffer); diff --git a/src/util/syncbuffer.cpp b/src/util/syncbuffer.cpp index f52cfa42dc..3869532a4e 100644 --- a/src/util/syncbuffer.cpp +++ b/src/util/syncbuffer.cpp @@ -78,11 +78,11 @@ void SyncBuffer::decode(std::string& s) { s = decode(); } -void SyncBuffer::setData(std::vector data) { +void SyncBuffer::setData(std::vector data) { _dataStream = std::move(data); } -std::vector SyncBuffer::data() { +std::vector SyncBuffer::data() { _dataStream.resize(_encodeOffset); return _dataStream; From 1df557d2eb67b0acd517130afa483107d9296e76 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 10 Apr 2020 17:46:59 +0200 Subject: [PATCH 45/67] Small code cleanup --- modules/touch/src/win32_touch.cpp | 43 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 948a242941..1118094768 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -40,29 +40,32 @@ #define ENABLE_DIRECTMSG namespace { - using namespace std::chrono; constexpr const char* _loggerCat = "win32_touch"; HHOOK gTouchHook = nullptr; - std::thread* gMouseHookThread; + std::thread* gMouseHookThread = nullptr; HHOOK gMouseHook = nullptr; bool gStarted = false; - microseconds gStartTime = microseconds(0); - const long long gFrequency = []() -> long long { - LARGE_INTEGER frequency; - QueryPerformanceFrequency(&frequency); - return frequency.QuadPart; - }(); + std::chrono::microseconds gStartTime = std::chrono::microseconds(0); std::unordered_map< UINT32, std::unique_ptr > gTouchInputsMap; + #ifdef ENABLE_TUIOMESSAGES TUIO::TuioServer* gTuioServer = nullptr; std::unordered_map gCursorMap; #endif + + const long long gFrequency = []() -> long long { + LARGE_INTEGER frequency; + QueryPerformanceFrequency(&frequency); + return frequency.QuadPart; + }(); + } // namespace namespace openspace { + LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam); // This hook will only work for Win8+ Digitizers. @@ -90,8 +93,8 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { const long long whole = (info.PerformanceCount / freq) * std::micro::den; const long long part = (info.PerformanceCount % freq) * std::micro::den / freq; - const microseconds timestamp = - duration(whole + part) - gStartTime; + const std::chrono::microseconds timestamp = + std::chrono::duration(whole + part) - gStartTime; RECT rect; GetClientRect(pStruct->hwnd, reinterpret_cast(&rect)); @@ -100,17 +103,17 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { // native touch to screen conversion ScreenToClient(pStruct->hwnd, reinterpret_cast(&p)); - float xPos = static_cast(p.x) / - static_cast(rect.right - rect.left); - float yPos = static_cast(p.y) / - static_cast(rect.bottom - rect.top); + const float xPos = static_cast(p.x) / + static_cast(rect.right - rect.left); + const float yPos = static_cast(p.y) / + static_cast(rect.bottom - rect.top); TouchInput touchInput( reinterpret_cast(info.sourceDevice), static_cast(info.pointerId), xPos, yPos, - static_cast(timestamp.count()) / 1'000'000.0 + static_cast(timestamp.count()) / 1000000.0 ); if (info.pointerFlags & POINTER_FLAG_DOWN) { @@ -170,8 +173,7 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { return CallNextHookEx(0, nCode, wParam, lParam); } -Win32TouchHook::Win32TouchHook(void* nativeWindow) -{ +Win32TouchHook::Win32TouchHook(void* nativeWindow) { HWND hWnd = reinterpret_cast(nativeWindow); if (hWnd == nullptr) { LINFO("No windowhandle available for touch input."); @@ -223,8 +225,9 @@ Win32TouchHook::Win32TouchHook(void* nativeWindow) if (!gStarted) { gStarted = true; - gStartTime = - duration_cast(high_resolution_clock::now().time_since_epoch()); + gStartTime = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now().time_since_epoch() + ); #ifdef ENABLE_TUIOMESSAGES gTuioServer = new TUIO::TuioServer("localhost", 3333); TUIO::TuioTime::initSession(); @@ -232,7 +235,7 @@ Win32TouchHook::Win32TouchHook(void* nativeWindow) gTouchHook = SetWindowsHookExW( WH_GETMESSAGE, HookCallback, - GetModuleHandleW(NULL), + GetModuleHandleW(nullptr), GetCurrentThreadId() ); From ba9012f5a9e9c7bdad5fed7bdafe86024e54ffa3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 10 Apr 2020 18:18:54 +0200 Subject: [PATCH 46/67] Some cleanup of the code --- modules/space/rendering/renderableorbitalkepler.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index e048e4fe15..278509ed67 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -360,11 +360,12 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio Documentation(), dictionary, "RenderableOrbitalKepler" - ); + ); _path = dictionary.value(PathInfo.identifier); _segmentQuality = static_cast( - dictionary.value(SegmentQualityInfo.identifier)); + dictionary.value(SegmentQualityInfo.identifier) + ); if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { _appearance.lineColor = dictionary.value(LineColorInfo.identifier); @@ -381,7 +382,7 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio if (dictionary.hasKeyAndValue(UpperLimitInfo.identifier)) { _upperLimit = static_cast( dictionary.value(UpperLimitInfo.identifier) - ); + ); } else { _upperLimit = 0; @@ -507,7 +508,7 @@ void RenderableOrbitalKepler::updateBuffers() { size_t vertexBufIdx = 0; for (size_t orbitIdx = 0; orbitIdx < numOrbits; ++orbitIdx) { - openspace::RenderableOrbitalKepler::KeplerParameters orbit = _data[orbitIdx]; + KeplerParameters orbit = _data[orbitIdx]; _keplerTranslator.setKeplerElements( orbit.eccentricity, @@ -522,7 +523,7 @@ void RenderableOrbitalKepler::updateBuffers() { for (size_t j = 0 ; j < _segmentSize[orbitIdx]; ++j) { double timeOffset = orbit.period * - static_cast(j)/ static_cast(_segmentSize[orbitIdx]); + static_cast(j)/ static_cast(_segmentSize[orbitIdx]); glm::dvec3 position = _keplerTranslator.position({ {}, From ed9a397549b4ca4f724c6756278d364218fc1a2e Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 12 Apr 2020 22:43:54 -0600 Subject: [PATCH 47/67] Improved segments algorithm and fix for rendering errors --- shaders/.fragment.glsl.swp | Bin 0 -> 12288 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 shaders/.fragment.glsl.swp diff --git a/shaders/.fragment.glsl.swp b/shaders/.fragment.glsl.swp new file mode 100644 index 0000000000000000000000000000000000000000..3b43364a9e19754f5810de11c43c1f3ca3a294fa GIT binary patch literal 12288 zcmeI2J&fE$7=|ZEgg^)&QqWL*T$<$M++L1I2vQ*5+Iws8+AG_8$2B>5?eVU`>si^} zoFW7i(9l!SfkZ`1fdUmsbTrUILr+DOhIeLv?h>I>qU4H*8Qm+}^Yi^Y->g@wo8jiJ z)1x;wt~0ck82j#K@86BwPBfnYy!>n4EqErJhe#U%Hn$FzU$&qUo-(tKoigeGyzRO z6VL=S0Zl*?&;&FAP2dS65T}gYeVVZ!&LVjH|9|=W|C<*Xdk6aa1;)OB-h}?Rz}TnI zW$4%E8LOaIpdZgO7DH#DZ=YkV5B>8jV_!mVLw}uP>~m-X`u!QkeuM5nUqfF(pFtc- zp#a*3HlSCb^Uz(y_9yfU^fUAmB;&mU>81&20-As(@V_H)iI-`fG4|07MrcDJ3QF@j z9v0lSf~~F<92>|)mGI6`1X#qYyd2HPW_j5V7L@7yIV(imP|Byxc;0b~C)a7@iE0uT z$9wvs&YN76$NCaci0THbn`)Lc)LEQkqYrV|CgoXPa@uxn&pPP&mVIDamJ>OdvtuIa#_W%kS+J6t(c z(;U}{_6^$W+A2-BGVwR}1n+axeKUxh_P{j*>JNgx4=|=@k>`7k*9j1^EsM4x1ND5e zckw`B*K}PKr#XnaJ_18DZNI-CI6K`)5>rt-UfUg5GV5*R>-iC)>N$~Z0gze^$bsoa zjtsm*Jv(T3@n~)@0`EAHXNTcD*Hs;qX<5T%naByLANaeD1aX67E!MpJ=Pl)wWz3`4eKT@n>;RPDk}LItVv|lj5&oO zYYyXzKlr{=AfOO0&KDnp*RO7EZf#0nkI>W(d4%;RELEmgN6t@}`0zug8g=WGzR=g#*}so5 BYhVBX literal 0 HcmV?d00001 From b5114bd4fd7925d17cc6026dc2213dbddd1a7ebb Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 13 Apr 2020 00:56:12 -0600 Subject: [PATCH 48/67] Finalized segments algorithm and added object selection --- .../solarsystem/sssb/amor_asteroid.asset | 2 +- .../solarsystem/sssb/apollo_asteroid.asset | 2 +- .../solarsystem/sssb/aten_asteroid.asset | 2 +- .../solarsystem/sssb/atira_asteroid.asset | 2 +- .../solarsystem/sssb/centaur_asteroid.asset | 2 +- .../solarsystem/sssb/chiron-type_comet.asset | 2 +- .../solarsystem/sssb/halley-type_comet.asset | 2 +- .../sssb/transneptunian_object_asteroid.asset | 2 +- .../rendering/renderableorbitalkepler.cpp | 53 +++++++++++-- .../space/rendering/renderableorbitalkepler.h | 7 ++ .../space/rendering/renderablesatellites.cpp | 6 +- .../space/rendering/renderablesmallbody.cpp | 72 ++++++++++++++---- modules/space/rendering/renderablesmallbody.h | 7 +- shaders/.fragment.glsl.swp | Bin 12288 -> 0 bytes 14 files changed, 127 insertions(+), 34 deletions(-) delete mode 100644 shaders/.fragment.glsl.swp diff --git a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset index 72b9cd4f31..b091b688fc 100644 --- a/data/assets/scene/solarsystem/sssb/amor_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/amor_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'amor_asteroid', 'sssb_data_amor_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_amor_asteroid.csv', "Amor Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 1 +object.Renderable.SegmentQuality = 4 object.Renderable.TrailFade = 11 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset index 02b592a7da..8c86d4e990 100644 --- a/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/apollo_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'apollo_asteroid', 'sssb_data_apollo_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_apollo_asteroid.csv', "Apollo Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 1 +object.Renderable.SegmentQuality = 6 object.Renderable.TrailFade = 10 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset index 4604283150..1dd7af7f10 100644 --- a/data/assets/scene/solarsystem/sssb/aten_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/aten_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'aten_asteroid', 'sssb_data_aten_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_aten_asteroid.csv', "Aten Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 1 +object.Renderable.SegmentQuality = 2 object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset index 65801fede5..1029f31430 100644 --- a/data/assets/scene/solarsystem/sssb/atira_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/atira_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'atira_asteroid', 'sssb_data_atira_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_atira_asteroid.csv', "Atira Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 1 +object.Renderable.SegmentQuality = 2 object.Renderable.TrailFade = 25 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset index 46bba5a0a8..68d97d2d9c 100644 --- a/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/centaur_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'centaur_asteroid', 'sssb_data_centaur_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_centaur_asteroid.csv', "Centaur Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 1 +object.Renderable.SegmentQuality = 6 object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset index 3365b253bc..e19c58b335 100644 --- a/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/chiron-type_comet.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'chiron-type_comet', 'sssb_data_chiron-type_comet') local object = sharedSssb.createSssbGroupObject('sssb_data_chiron-type_comet.csv', "Chiron-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 50 +object.Renderable.SegmentQuality = 10 object.Renderable.TrailFade = 25 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset index 6fb74b8061..c92a0e1c83 100644 --- a/data/assets/scene/solarsystem/sssb/halley-type_comet.asset +++ b/data/assets/scene/solarsystem/sssb/halley-type_comet.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'halley-type_comet', 'sssb_data_halley-type_comet') local object = sharedSssb.createSssbGroupObject('sssb_data_halley-type_comet.csv', "Halley-type Comets", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 2 +object.Renderable.SegmentQuality = 9 object.Renderable.TrailFade = 18 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset index a868bf7aec..5ef5e3b1e9 100644 --- a/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset +++ b/data/assets/scene/solarsystem/sssb/transneptunian_object_asteroid.asset @@ -4,7 +4,7 @@ local sharedSssb = asset.require('./sssb_shared') local filepath = sharedSssb.downloadSssbDatabaseFile(asset, 'transneptunian_object_asteroid', 'sssb_data_transneptunian_object_asteroid') local object = sharedSssb.createSssbGroupObject('sssb_data_transneptunian_object_asteroid.csv', "Transneptunian Object Asteroids", filepath, { 0.9, 0.3, 0.1 }) object.Renderable.Enabled = false -object.Renderable.SegmentQuality = 3 +object.Renderable.SegmentQuality = 8 object.Renderable.TrailFade = 10 assetHelper.registerSceneGraphNodesAndExport(asset, { object }) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 278509ed67..0d1c5de28f 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -57,7 +57,7 @@ namespace { "SegmentQuality", "Segment Quality", "A segment quality value for the orbital trail. A value from 1 (lowest) to " - "100 (highest) that controls the number of line segments in the rendering of the " + "10 (highest) that controls the number of line segments in the rendering of the " "orbital trail. This does not control the direct number of segments because " "these automatically increase according to the eccentricity of the orbit." }; @@ -84,7 +84,17 @@ namespace { "Upper limit on the number of objects for this renderable, regardless of " "how many objects are contained in the data file" }; - + static const openspace::properties::Property::PropertyInfo StartRenderIdxInfo = { + "StartRenderIdx", + "Starting Index of Render", + "Index of object in renderable group to start rendering (all prior objects will " + "be ignored)." + }; + static const openspace::properties::Property::PropertyInfo RenderSizeInfo = { + "RenderSizeInfo", + "Size of Render Block", + "Number of objects to render from StartRenderIdx" + }; constexpr const char* KeyFile = "Path"; constexpr const char* KeyLineNum = "LineNumber"; } @@ -349,12 +359,14 @@ int RenderableOrbitalKepler::daysIntoGivenYear(int month, int dayOfMonth) { } return dayCount; } - + RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _path(PathInfo) - , _segmentQuality(SegmentQualityInfo, 10, 1, 100) + , _segmentQuality(SegmentQualityInfo, 2, 1, 10) , _upperLimit(UpperLimitInfo, 1000, 1, 1000000) + , _startRenderIdx(StartRenderIdxInfo, 0, 0, 1) + , _sizeRender(RenderSizeInfo, 1, 1, 2) { documentation::testSpecificationAndThrow( Documentation(), @@ -388,6 +400,24 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio _upperLimit = 0; } + if (dictionary.hasKeyAndValue(StartRenderIdxInfo.identifier)) { + _startRenderIdx = static_cast( + dictionary.value(StartRenderIdxInfo.identifier) + ); + } + else { + _startRenderIdx = 0; + } + + if (dictionary.hasKeyAndValue(RenderSizeInfo.identifier)) { + _sizeRender = static_cast( + dictionary.value(RenderSizeInfo.identifier) + ); + } + else { + _sizeRender = 0; + } + if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { _appearance.lineWidth = static_cast( dictionary.value(LineWidthInfo.identifier) @@ -404,6 +434,13 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio addProperty(_path); addProperty(_segmentQuality); addProperty(_opacity); + addProperty(_startRenderIdx); + addProperty(_sizeRender); + + updateStartRenderIdxSelect = std::function([this] { initializeGL(); }); + updateRenderSizeSelect = std::function([this] { initializeGL(); }); + _startRenderIdxCallbackHandle = _startRenderIdx.onChange(updateStartRenderIdxSelect); + _sizeRenderCallbackHandle = _sizeRender.onChange(updateRenderSizeSelect); setRenderBin(Renderable::RenderBin::Overlay); } @@ -498,13 +535,13 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { void RenderableOrbitalKepler::updateBuffers() { readDataFile(_path); - size_t nVerticesPerOrbit = 0; + size_t nVerticesTotal = 0; int numOrbits = _data.size(); for (size_t i = 0; i < numOrbits; ++i) { - nVerticesPerOrbit += _segmentSize[i] + 1; + nVerticesTotal += _segmentSize[i] + 1; } - _vertexBufferData.resize(nVerticesPerOrbit); + _vertexBufferData.resize(nVerticesTotal); size_t vertexBufIdx = 0; for (size_t orbitIdx = 0; orbitIdx < numOrbits; ++orbitIdx) { @@ -521,7 +558,7 @@ void RenderableOrbitalKepler::updateBuffers() { orbit.epoch ); - for (size_t j = 0 ; j < _segmentSize[orbitIdx]; ++j) { + for (size_t j = 0 ; j < (_segmentSize[orbitIdx] + 1); ++j) { double timeOffset = orbit.period * static_cast(j)/ static_cast(_segmentSize[orbitIdx]); diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h index 54183e818f..40ea763f25 100644 --- a/modules/space/rendering/renderableorbitalkepler.h +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -69,6 +69,8 @@ protected: double epochFromYMDdSubstring(const std::string& epochString); int daysIntoGivenYear(int month, int dayOfMonth); std::function reinitializeTrailBuffers; + std::function updateStartRenderIdxSelect; + std::function updateRenderSizeSelect; const std::vector LeapYears = { 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, @@ -103,6 +105,7 @@ protected: double epoch = 0.0; double period = 0.0; }; + std::streamoff _numObjects; const double convertAuToKm = 1.496e8; const double convertDaysToSecs = 86400.; std::vector _data; @@ -110,6 +113,10 @@ protected: properties::UIntProperty _upperLimit; properties::UIntProperty _segmentQuality; properties::Property::OnChangeHandle _upperLimitCallbackHandle; + properties::UIntProperty _startRenderIdx; + properties::UIntProperty _sizeRender; + properties::Property::OnChangeHandle _startRenderIdxCallbackHandle; + properties::Property::OnChangeHandle _sizeRenderCallbackHandle; private: struct Vertex { diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index f935b4643d..0bf563bade 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -142,10 +142,10 @@ void RenderableSatellites::readDataFile(const std::string& filename) { file.seekg(std::ios_base::beg); // reset iterator to beginning of file // 3 because a TLE has 3 lines per element/ object. - std::streamoff numberOfObjects = numberOfLines / 3; + _numObjects = numberOfLines / 3; std::string line = "-"; - for (std::streamoff i = 0; i < numberOfObjects; i++) { + for (std::streamoff i = 0; i < _numObjects; i++) { std::getline(file, line); // get rid of title KeplerParameters keplerElements; @@ -237,7 +237,7 @@ void RenderableSatellites::readDataFile(const std::string& filename) { keplerElements.period = period; _data.push_back(keplerElements); - _segmentSize.push_back(_segmentQuality * 10); + _segmentSize.push_back(_segmentQuality * 100); } file.close(); } diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 4d5f289c2e..3472550b76 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -154,14 +154,14 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { file.open(filename); std::streamoff numberOfLines = std::count(std::istreambuf_iterator(file), - std::istreambuf_iterator(), '\n' ); + std::istreambuf_iterator(), '\n' ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file _data.clear(); _sbNames.clear(); _segmentSize.clear(); std::string line; - std::streamoff csvLine = -1; + unsigned int csvLine = 0; int fieldCount = 0; float lineSkipFraction = 1.0; float currLineFraction; @@ -173,18 +173,42 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { try { std::getline(file, line); // get rid of first line (header) numberOfLines -= 1; - if (_upperLimit == 0 || _upperLimit > numberOfLines) { + if (_numObjects != numberOfLines) { + _initialized = false; + } + _numObjects = numberOfLines; + + if (!_initialized) { + _initialized = true; + + _startRenderIdx.removeOnChange(_startRenderIdxCallbackHandle); + _sizeRender.removeOnChange(_sizeRenderCallbackHandle); + _startRenderIdx.setMaxValue(_numObjects - 1); + _sizeRender.setMaxValue(_numObjects); + _startRenderIdx = static_cast(0); + _sizeRender = static_cast(_numObjects); + _startRenderIdxCallbackHandle = _startRenderIdx.onChange( + updateStartRenderIdxSelect); + _sizeRenderCallbackHandle = _sizeRender.onChange( + updateRenderSizeSelect); + //If a limit wasn't specified in dictionary, set it to # lines in file // minus the header line (but temporarily disable callback to avoid 2nd call) _upperLimit.removeOnChange(_upperLimitCallbackHandle); - _upperLimit.setMaxValue(numberOfLines); - _upperLimit = static_cast(numberOfLines); + _upperLimit.setMaxValue(_numObjects); + _upperLimit = static_cast(_numObjects); _upperLimitCallbackHandle = _upperLimit.onChange(reinitializeTrailBuffers); } else { - lineSkipFraction = static_cast(_upperLimit) / - static_cast(numberOfLines); + if (_sizeRender < _numObjects || _startRenderIdx > 0) { + lineSkipFraction = 1.0; + } + else { + lineSkipFraction = static_cast(_upperLimit) + / static_cast(_numObjects); + } } + if (line.compare(expectedHeaderLine) != 0) { LERROR(fmt::format( "File {} does not have the appropriate JPL SBDB header at line 1.", @@ -195,12 +219,23 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { } unsigned int sequentialLineErrors = 0; - for (csvLine = 1; csvLine <= numberOfLines; csvLine++, sequentialLineErrors++) { + unsigned int endElement = _startRenderIdx + _sizeRender - 1; + endElement = (endElement >= _numObjects) ? _numObjects - 1 : endElement; + //Burn lines if not starting at first element + for (unsigned int k = 0; k < _startRenderIdx; ++k) { + skipSingleLineInFile(file); + } + bool firstDataLine = true; + for (csvLine = _startRenderIdx + 1; + csvLine <= endElement + 1; + csvLine++, sequentialLineErrors++) + { currLineFraction = static_cast(csvLine - 1) * lineSkipFraction; currLineCount = static_cast(currLineFraction); if (currLineCount > lastLineCount) { try { - readOrbitalParamsFromThisLine(fieldCount, csvLine, file); + readOrbitalParamsFromThisLine(firstDataLine, fieldCount, csvLine, + file); sequentialLineErrors = 0; } catch (std::invalid_argument&) { @@ -233,7 +268,11 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { break; } } + else { + skipSingleLineInFile(file); + } lastLineCount = currLineCount; + firstDataLine = false; } } catch (std::ios_base::failure&) { @@ -248,8 +287,14 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { file.close(); } -void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, - std::streamoff& csvLine, +void RenderableSmallBody::skipSingleLineInFile(std::ifstream& file) { + std::string line; + std::getline(file, line); +} + +void RenderableSmallBody::readOrbitalParamsFromThisLine(bool firstDataLine, + int& fieldCount, + unsigned int& csvLine, std::ifstream& file) { const int numDataFields = 8; @@ -259,7 +304,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, //If there was a read/conversion error in the previous line, then read the remainder // of that line and throw it out first before proceeding with the next line. - if (fieldCount != (numDataFields + 1) && csvLine != 1) { + if (fieldCount != (numDataFields + 1) && !firstDataLine) { std::getline(file, field); } fieldCount = 0; @@ -336,7 +381,8 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(int& fieldCount, _data.push_back(keplerElements); _sbNames.push_back(name); - _segmentSize.push_back(_segmentQuality * 10 * (keplerElements.eccentricity / 0.05)); + double scale = static_cast(_segmentQuality) * 10.0; + _segmentSize.push_back(scale + (scale / pow(1 - keplerElements.eccentricity, 1.2))); } static double importAngleValue(const std::string& angle) { diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index a26a0049cf..b5575117d2 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -46,12 +46,15 @@ public: static documentation::Documentation Documentation(); private: - void readOrbitalParamsFromThisLine(int& fieldCount, std::streamoff& csvLine, - std::ifstream& file); + void readOrbitalParamsFromThisLine(bool firstDataLine, int& fieldCount, + unsigned int& csvLine, std::ifstream& file); void readDataFile(const std::string& filename); + void skipSingleLineInFile(std::ifstream& file); std::vector _sbNames; + bool _initialized = false; + /// The index array that is potentially used in the draw call. If this is empty, no /// element draw call is used. std::vector _indexBufferData; diff --git a/shaders/.fragment.glsl.swp b/shaders/.fragment.glsl.swp deleted file mode 100644 index 3b43364a9e19754f5810de11c43c1f3ca3a294fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2J&fE$7=|ZEgg^)&QqWL*T$<$M++L1I2vQ*5+Iws8+AG_8$2B>5?eVU`>si^} zoFW7i(9l!SfkZ`1fdUmsbTrUILr+DOhIeLv?h>I>qU4H*8Qm+}^Yi^Y->g@wo8jiJ z)1x;wt~0ck82j#K@86BwPBfnYy!>n4EqErJhe#U%Hn$FzU$&qUo-(tKoigeGyzRO z6VL=S0Zl*?&;&FAP2dS65T}gYeVVZ!&LVjH|9|=W|C<*Xdk6aa1;)OB-h}?Rz}TnI zW$4%E8LOaIpdZgO7DH#DZ=YkV5B>8jV_!mVLw}uP>~m-X`u!QkeuM5nUqfF(pFtc- zp#a*3HlSCb^Uz(y_9yfU^fUAmB;&mU>81&20-As(@V_H)iI-`fG4|07MrcDJ3QF@j z9v0lSf~~F<92>|)mGI6`1X#qYyd2HPW_j5V7L@7yIV(imP|Byxc;0b~C)a7@iE0uT z$9wvs&YN76$NCaci0THbn`)Lc)LEQkqYrV|CgoXPa@uxn&pPP&mVIDamJ>OdvtuIa#_W%kS+J6t(c z(;U}{_6^$W+A2-BGVwR}1n+axeKUxh_P{j*>JNgx4=|=@k>`7k*9j1^EsM4x1ND5e zckw`B*K}PKr#XnaJ_18DZNI-CI6K`)5>rt-UfUg5GV5*R>-iC)>N$~Z0gze^$bsoa zjtsm*Jv(T3@n~)@0`EAHXNTcD*Hs;qX<5T%naByLANaeD1aX67E!MpJ=Pl)wWz3`4eKT@n>;RPDk}LItVv|lj5&oO zYYyXzKlr{=AfOO0&KDnp*RO7EZf#0nkI>W(d4%;RELEmgN6t@}`0zug8g=WGzR=g#*}so5 BYhVBX From eedd0f75e0f1b1d8a89a95c582b2f5c73b3377c0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 13 Apr 2020 10:40:31 +0200 Subject: [PATCH 49/67] Compile fix --- apps/OpenSpace/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 87cb5d9b5c..de0052caf4 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -162,6 +162,7 @@ std::vector SpoutWindows; #endif // OPENSPACE_HAS_SPOUT +} // // MiniDump generation From 29d68897d688fe06f72f66a1974e1187d86376e9 Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 13 Apr 2020 16:43:27 -0600 Subject: [PATCH 50/67] Added to satellites: group selection feature, segments fix --- data/assets/util/tle_helper.asset | 2 +- .../rendering/renderableorbitalkepler.cpp | 5 +- .../space/rendering/renderableorbitalkepler.h | 1 + .../space/rendering/renderablesatellites.cpp | 52 +++++++++++++--- .../space/rendering/renderablesatellites.h | 5 ++ .../space/rendering/renderablesmallbody.cpp | 60 ++++++++++++------- modules/space/rendering/renderablesmallbody.h | 4 +- 7 files changed, 95 insertions(+), 34 deletions(-) diff --git a/data/assets/util/tle_helper.asset b/data/assets/util/tle_helper.asset index a7179795c7..9aa08a3c71 100644 --- a/data/assets/util/tle_helper.asset +++ b/data/assets/util/tle_helper.asset @@ -82,7 +82,7 @@ function satellites(title, file, color, group) Renderable = { Type = "RenderableSatellites", Path = file, - Segments = 120, + SegmentQuality = 3, Color = color, Fade = 1.5 }, diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 0d1c5de28f..d53f4cbaee 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -82,7 +82,8 @@ namespace { "UpperLimit", "Upper Limit", "Upper limit on the number of objects for this renderable, regardless of " - "how many objects are contained in the data file" + "how many objects are contained in the data file. Produces an evenly-distributed" + "sample from the data file." }; static const openspace::properties::Property::PropertyInfo StartRenderIdxInfo = { "StartRenderIdx", @@ -93,7 +94,7 @@ namespace { static const openspace::properties::Property::PropertyInfo RenderSizeInfo = { "RenderSizeInfo", "Size of Render Block", - "Number of objects to render from StartRenderIdx" + "Number of objects to render sequentially from StartRenderIdx" }; constexpr const char* KeyFile = "Path"; constexpr const char* KeyLineNum = "LineNumber"; diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h index 40ea763f25..fc27a3c30e 100644 --- a/modules/space/rendering/renderableorbitalkepler.h +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -106,6 +106,7 @@ protected: double period = 0.0; }; std::streamoff _numObjects; + bool _isFileReadinitialized = false; const double convertAuToKm = 1.496e8; const double convertDaysToSecs = 86400.; std::vector _data; diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 0bf563bade..56780c7eaa 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -141,13 +141,24 @@ void RenderableSatellites::readDataFile(const std::string& filename) { std::istreambuf_iterator(), '\n' ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file - // 3 because a TLE has 3 lines per element/ object. - _numObjects = numberOfLines / 3; + _numObjects = numberOfLines / nLineEntriesPerSatellite; + + if (!_isFileReadinitialized) { + _isFileReadinitialized = true; + initializeFileReading(); + } std::string line = "-"; - for (std::streamoff i = 0; i < _numObjects; i++) { - std::getline(file, line); // get rid of title - + std::string name; + unsigned int endElement = _startRenderIdx + _sizeRender - 1; + endElement = (endElement >= _numObjects) ? _numObjects - 1 : endElement; + //Burn lines if not starting at first element + for (unsigned int k = 0; k < _startRenderIdx; ++k) { + skipSingleEntryInFile(file); + } + for (std::streamoff i = _startRenderIdx; i <= endElement; i++) { + //Read title line + std::getline(file, name); KeplerParameters keplerElements; std::getline(file, line); @@ -160,6 +171,13 @@ void RenderableSatellites::readDataFile(const std::string& filename) { // 4 10-11 International Designator (Last two digits of launch year) // 5 12-14 International Designator (Launch number of the year) // 6 15-17 International Designator(piece of the launch) A + name += " " + line.substr(2, 15); + if (_startRenderIdx > 0 && _startRenderIdx == i) { + LINFO(fmt::format( + "Set render block to start at object {}", + name + )); + } // 7 19-20 Epoch Year(last two digits of year) // 8 21-32 Epoch(day of the year and fractional portion of the day) // 9 34-43 First Time Derivative of the Mean Motion divided by two @@ -237,9 +255,29 @@ void RenderableSatellites::readDataFile(const std::string& filename) { keplerElements.period = period; _data.push_back(keplerElements); - _segmentSize.push_back(_segmentQuality * 100); + _segmentSize.push_back(_segmentQuality * 16); } file.close(); } - + +void RenderableSatellites::initializeFileReading() { + _startRenderIdx.removeOnChange(_startRenderIdxCallbackHandle); + _sizeRender.removeOnChange(_sizeRenderCallbackHandle); + _startRenderIdx.setMaxValue(_numObjects - 1); + _sizeRender.setMaxValue(_numObjects); + _startRenderIdx = static_cast(0); + _sizeRender = static_cast(_numObjects); + _startRenderIdxCallbackHandle = _startRenderIdx.onChange( + updateStartRenderIdxSelect); + _sizeRenderCallbackHandle = _sizeRender.onChange( + updateRenderSizeSelect); +} + +void RenderableSatellites::skipSingleEntryInFile(std::ifstream& file) { + std::string line; + for (unsigned int i = 0; i < nLineEntriesPerSatellite; i++) { + std::getline(file, line); + } +} + } diff --git a/modules/space/rendering/renderablesatellites.h b/modules/space/rendering/renderablesatellites.h index 1bf2804216..d6e9112ecb 100644 --- a/modules/space/rendering/renderablesatellites.h +++ b/modules/space/rendering/renderablesatellites.h @@ -43,6 +43,11 @@ public: RenderableSatellites(const ghoul::Dictionary& dictionary); void readDataFile(const std::string& filename); static documentation::Documentation Documentation(); + void initializeFileReading(); + +private: + void skipSingleEntryInFile(std::ifstream& file); + const unsigned int nLineEntriesPerSatellite = 3; }; } // namespace openspace diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 3472550b76..0eb013d30c 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -174,30 +174,13 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { std::getline(file, line); // get rid of first line (header) numberOfLines -= 1; if (_numObjects != numberOfLines) { - _initialized = false; + _isFileReadinitialized = false; } _numObjects = numberOfLines; - if (!_initialized) { - _initialized = true; - - _startRenderIdx.removeOnChange(_startRenderIdxCallbackHandle); - _sizeRender.removeOnChange(_sizeRenderCallbackHandle); - _startRenderIdx.setMaxValue(_numObjects - 1); - _sizeRender.setMaxValue(_numObjects); - _startRenderIdx = static_cast(0); - _sizeRender = static_cast(_numObjects); - _startRenderIdxCallbackHandle = _startRenderIdx.onChange( - updateStartRenderIdxSelect); - _sizeRenderCallbackHandle = _sizeRender.onChange( - updateRenderSizeSelect); - - //If a limit wasn't specified in dictionary, set it to # lines in file - // minus the header line (but temporarily disable callback to avoid 2nd call) - _upperLimit.removeOnChange(_upperLimitCallbackHandle); - _upperLimit.setMaxValue(_numObjects); - _upperLimit = static_cast(_numObjects); - _upperLimitCallbackHandle = _upperLimit.onChange(reinitializeTrailBuffers); + if (!_isFileReadinitialized) { + _isFileReadinitialized = true; + initializeFileReading(); } else { if (_sizeRender < _numObjects || _startRenderIdx > 0) { @@ -287,6 +270,25 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { file.close(); } +void RenderableSmallBody::initializeFileReading() { + _startRenderIdx.removeOnChange(_startRenderIdxCallbackHandle); + _sizeRender.removeOnChange(_sizeRenderCallbackHandle); + _startRenderIdx.setMaxValue(_numObjects - 1); + _sizeRender.setMaxValue(_numObjects); + _startRenderIdx = static_cast(0); + _sizeRender = static_cast(_numObjects); + _startRenderIdxCallbackHandle = _startRenderIdx.onChange( + updateStartRenderIdxSelect); + _sizeRenderCallbackHandle = _sizeRender.onChange( + updateRenderSizeSelect); + //If a limit wasn't specified in dictionary, set it to # lines in file + // minus the header line (but temporarily disable callback to avoid 2nd call) + _upperLimit.removeOnChange(_upperLimitCallbackHandle); + _upperLimit.setMaxValue(_numObjects); + _upperLimit = static_cast(_numObjects); + _upperLimitCallbackHandle = _upperLimit.onChange(reinitializeTrailBuffers); +} + void RenderableSmallBody::skipSingleLineInFile(std::ifstream& file) { std::string line; std::getline(file, line); @@ -311,6 +313,13 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(bool firstDataLine, // Object designator string std::getline(file, name, ','); + if (_startRenderIdx > 0 && _startRenderIdx == (csvLine - 1)) { + formatObjectName(name); + LINFO(fmt::format( + "Set render block to start at object {}", + name + )); + } fieldCount++; // Epoch @@ -393,5 +402,12 @@ static double importAngleValue(const std::string& angle) { } return output; } - + +static std::string& formatObjectName(std::string& name) { + const std::string trimChars = "\t\n\v\f\r\" "; + name.erase(0, name.find_first_not_of(trimChars)); + name.erase(name.find_last_not_of(trimChars) + 1); + return name; +} + } diff --git a/modules/space/rendering/renderablesmallbody.h b/modules/space/rendering/renderablesmallbody.h index b5575117d2..6a68bb7e3e 100644 --- a/modules/space/rendering/renderablesmallbody.h +++ b/modules/space/rendering/renderablesmallbody.h @@ -49,18 +49,18 @@ private: void readOrbitalParamsFromThisLine(bool firstDataLine, int& fieldCount, unsigned int& csvLine, std::ifstream& file); void readDataFile(const std::string& filename); + void initializeFileReading(); void skipSingleLineInFile(std::ifstream& file); std::vector _sbNames; - bool _initialized = false; - /// The index array that is potentially used in the draw call. If this is empty, no /// element draw call is used. std::vector _indexBufferData; }; static double importAngleValue(const std::string& angle); +static std::string& formatObjectName(std::string& name); } // namespace openspace From 606fa74817f382e6926e74dcf2868452ad25b8db Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 14 Apr 2020 10:47:59 +0200 Subject: [PATCH 51/67] Adapt configuration files and fix old SGCT style in them --- apps/OpenSpace/ext/sgct | 2 +- config/fullscreen1080.xml | 42 +++++++-------- config/gui_projector.xml | 60 ++++++++++----------- config/openvr_htcVive.xml | 40 +++++++------- config/openvr_oculusRiftCv1.xml | 40 +++++++------- config/single.xml | 42 +++++++-------- config/single_fisheye.xml | 66 +++++++++++------------ config/single_fisheye_gui.xml | 94 ++++++++++++++++----------------- config/single_gui.xml | 60 ++++++++++----------- config/single_sbs_stereo.xml | 56 ++++++++++---------- config/single_two_win.xml | 58 ++++++++++---------- config/spherical_mirror.xml | 64 +++++++++++----------- config/spherical_mirror_gui.xml | 4 +- config/spout_output.xml | 42 ++++++--------- config/two_nodes.xml | 71 ++++++++++++------------- ext/ghoul | 2 +- 16 files changed, 364 insertions(+), 379 deletions(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 19799abace..addec5d680 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 19799abace7513623902fa5e43158b6f6a565434 +Subproject commit addec5d6804ab8df8940f5dc3b3bf81b35216ee5 diff --git a/config/fullscreen1080.xml b/config/fullscreen1080.xml index 35506aeb09..3b7f94c4cc 100644 --- a/config/fullscreen1080.xml +++ b/config/fullscreen1080.xml @@ -1,24 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/config/gui_projector.xml b/config/gui_projector.xml index 42c3971235..9f50aa7037 100644 --- a/config/gui_projector.xml +++ b/config/gui_projector.xml @@ -1,33 +1,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/openvr_htcVive.xml b/config/openvr_htcVive.xml index ee6ea4df20..c5ab46597a 100644 --- a/config/openvr_htcVive.xml +++ b/config/openvr_htcVive.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/config/openvr_oculusRiftCv1.xml b/config/openvr_oculusRiftCv1.xml index 9db0689cbc..665715fb53 100644 --- a/config/openvr_oculusRiftCv1.xml +++ b/config/openvr_oculusRiftCv1.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + diff --git a/config/single.xml b/config/single.xml index a434c31d0b..6ec2d5a125 100644 --- a/config/single.xml +++ b/config/single.xml @@ -1,24 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/config/single_fisheye.xml b/config/single_fisheye.xml index 8a03730f5e..e27230e520 100644 --- a/config/single_fisheye.xml +++ b/config/single_fisheye.xml @@ -1,37 +1,37 @@ - - - - - - - - - - - - - - - - - - - + + + + --> + + + + + + + + + + + + + + + + + + + diff --git a/config/single_fisheye_gui.xml b/config/single_fisheye_gui.xml index b4a201f4c6..6eb46bbabb 100644 --- a/config/single_fisheye_gui.xml +++ b/config/single_fisheye_gui.xml @@ -1,53 +1,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + --> + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + diff --git a/config/single_gui.xml b/config/single_gui.xml index 6c200087d5..3404e572e3 100644 --- a/config/single_gui.xml +++ b/config/single_gui.xml @@ -1,33 +1,33 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/single_sbs_stereo.xml b/config/single_sbs_stereo.xml index 87ee3a33ec..595d92cafb 100644 --- a/config/single_sbs_stereo.xml +++ b/config/single_sbs_stereo.xml @@ -1,30 +1,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/single_two_win.xml b/config/single_two_win.xml index ae110d2148..ed1b09fc04 100644 --- a/config/single_two_win.xml +++ b/config/single_two_win.xml @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/spherical_mirror.xml b/config/spherical_mirror.xml index 2243582544..fc98729758 100644 --- a/config/spherical_mirror.xml +++ b/config/spherical_mirror.xml @@ -1,34 +1,34 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/spherical_mirror_gui.xml b/config/spherical_mirror_gui.xml index 14a48ad2e2..c946cbecd2 100644 --- a/config/spherical_mirror_gui.xml +++ b/config/spherical_mirror_gui.xml @@ -1,6 +1,6 @@ - + @@ -27,7 +27,7 @@ - + diff --git a/config/spout_output.xml b/config/spout_output.xml index f40a169c32..bac296112f 100644 --- a/config/spout_output.xml +++ b/config/spout_output.xml @@ -1,29 +1,19 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/config/two_nodes.xml b/config/two_nodes.xml index 5feb265138..e47946d5ef 100644 --- a/config/two_nodes.xml +++ b/config/two_nodes.xml @@ -1,41 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/ext/ghoul b/ext/ghoul index 0461bf1f44..11878e0dc0 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 0461bf1f44b58e04fb21d929b0f385e1120da7b4 +Subproject commit 11878e0dc08e43ecf4bcf158a6ccc00c6160d3a5 From d4218ad2fd1bc630e9486c8c38c1148ca7e04f95 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 14 Apr 2020 11:20:02 +0200 Subject: [PATCH 52/67] Provide a default value of 60 for the export of the screenshot playback (closes #1134) --- src/interaction/sessionrecording.cpp | 6 ++++-- src/interaction/sessionrecording_lua.inl | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/interaction/sessionrecording.cpp b/src/interaction/sessionrecording.cpp index 110eca4b43..849dc8d9e9 100644 --- a/src/interaction/sessionrecording.cpp +++ b/src/interaction/sessionrecording.cpp @@ -1441,8 +1441,10 @@ scripting::LuaLibrary SessionRecording::luaLibrary() { "enableTakeScreenShotDuringPlayback", &luascriptfunctions::enableTakeScreenShotDuringPlayback, {}, - "int", - "Enables that rendered frames should be saved during playback." + "[int]", + "Enables that rendered frames should be saved during playback. The " + "parameter determines the number of frames that are exported per second " + "if this value is not provided, 60 frames per second will be exported." }, { "disableTakeScreenShotDuringPlayback", diff --git a/src/interaction/sessionrecording_lua.inl b/src/interaction/sessionrecording_lua.inl index 5d138b84d6..8a1c2409b4 100644 --- a/src/interaction/sessionrecording_lua.inl +++ b/src/interaction/sessionrecording_lua.inl @@ -143,9 +143,13 @@ int stopPlayback(lua_State* L) { } int enableTakeScreenShotDuringPlayback(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::enableTakeScreenShotDuringPlayback"); + const int nArguments = ghoul::lua::checkArgumentsAndThrow( + L, + { 0, 1 }, + "lua::enableTakeScreenShotDuringPlayback" + ); - const int fps = ghoul::lua::value(L, 1); + const int fps = nArguments == 0 ? 60 : ghoul::lua::value(L, 1); global::sessionRecording.enableTakeScreenShotDuringPlayback(fps); From 84d3878be31d06ea87922299b4c6d6c81d648b45 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 14 Apr 2020 13:19:19 +0200 Subject: [PATCH 53/67] Ignore uniform warnings for cases when disabling the night layers on Earth (closes #1136) --- .../shaders/texturetilemapping.hglsl | 8 +++---- modules/globebrowsing/src/renderableglobe.cpp | 23 ++++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/modules/globebrowsing/shaders/texturetilemapping.hglsl b/modules/globebrowsing/shaders/texturetilemapping.hglsl index ff4b09eb42..a866211b85 100644 --- a/modules/globebrowsing/shaders/texturetilemapping.hglsl +++ b/modules/globebrowsing/shaders/texturetilemapping.hglsl @@ -377,16 +377,16 @@ vec4 calculateShadedColor(vec4 currentColor, vec3 ellipsoidNormalCameraSpace, vec3 shadedColor = currentColor.rgb * 0.05; vec3 n = normalize(ellipsoidNormalCameraSpace); - vec3 l = lightDirectionCameraSpace; - + float power = orenNayarDiffuse( -lightDirectionCameraSpace, - viewDirectionCameraSpace, + viewDirectionCameraSpace, ellipsoidNormalCameraSpace, roughness); + vec3 l = lightDirectionCameraSpace; power = max(smoothstep(0.0f, 0.1f, max(dot(-l, n), 0.0f)) * power, 0.0f); - + vec4 color = vec4(shadedColor + currentColor.rgb * power, currentColor.a); return color; } diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index d205fc4a5a..ce70591800 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -1135,13 +1135,22 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const glm::vec3 directionToSunCameraSpace = glm::vec3(viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); - _globalRenderer.program->setUniform( + // @TODO (abock, 2020-04-14); This is just a bandaid for issue #1136. The better + // way is to figure out with the uniform is optimized away. I assume that it is + // because the shader doesn't get recompiled when the last layer of the night + // or water is disabled; so the shader thinks it has to do the calculation, but + // there are actually no layers left + using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError; + _localRenderer.program->setIgnoreUniformLocationError(IgnoreError::Yes); + _localRenderer.program->setUniform( "lightDirectionCameraSpace", -glm::normalize(directionToSunCameraSpace) ); + _localRenderer.program->setIgnoreUniformLocationError(IgnoreError::Yes); } + // Local shader _localRenderer.program->setUniform( "projectionTransform", @@ -1156,10 +1165,18 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const glm::vec3 directionToSunCameraSpace = glm::vec3(viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); - _localRenderer.program->setUniform( + // @TODO (abock, 2020-04-14); This is just a bandaid for issue #1136. The better + // way is to figure out with the uniform is optimized away. I assume that it is + // because the shader doesn't get recompiled when the last layer of the night + // or water is disabled; so the shader thinks it has to do the calculation, but + // there are actually no layers left + using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError; + _globalRenderer.program->setIgnoreUniformLocationError(IgnoreError::Yes); + _globalRenderer.program->setUniform( "lightDirectionCameraSpace", -glm::normalize(directionToSunCameraSpace) ); + _globalRenderer.program->setIgnoreUniformLocationError(IgnoreError::Yes); } constexpr const int ChunkBufferSize = 2048; @@ -1616,7 +1633,7 @@ void RenderableGlobe::recompileShaders() { //); layeredTextureInfo.lastLayerIdx = static_cast( layerGroup.activeLayers().size() - 1 - ); + ); layeredTextureInfo.layerBlendingEnabled = layerGroup.layerBlendingEnabled(); for (Layer* layer : layers) { From 4f14e8476b90f5f6f7d6b0aa944791c31cada837 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 14 Apr 2020 15:00:37 +0200 Subject: [PATCH 54/67] Some code cleanup --- .../rendering/renderableorbitalkepler.cpp | 391 +++++++++--------- .../space/rendering/renderableorbitalkepler.h | 44 +- .../space/rendering/renderablesatellites.cpp | 4 +- .../space/rendering/renderablesmallbody.cpp | 95 +++-- 4 files changed, 241 insertions(+), 293 deletions(-) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index d53f4cbaee..c2225d1f8d 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -40,13 +40,68 @@ #include #include #include -#include #include +#include #include namespace { constexpr const char* ProgramName = "OrbitalKepler"; constexpr const char* _loggerCat = "OrbitalKepler"; + constexpr const char* KeyFile = "Path"; + constexpr const char* KeyLineNum = "LineNumber"; + + constexpr const std::array LeapYears = { + 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, + 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, + 2044, 2048, 2052, 2056 + }; + constexpr const std::array DaysOfMonths = { + 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 + }; + + // Find the position of the current year in the vector; its position in +// the vector gives the number of leap seconds + struct LeapSecond { + int year; + int dayOfYear; + bool operator<(const LeapSecond& rhs) const { + return std::tie(year, dayOfYear) < std::tie(rhs.year, rhs.dayOfYear); + } + }; + + constexpr const LeapSecond Epoch = { 2000, 1 }; + + // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list + constexpr const std::array LeapSeconds = { + LeapSecond{ 1972, 1 }, + LeapSecond{ 1972, 183 }, + LeapSecond{ 1973, 1 }, + LeapSecond{ 1974, 1 }, + LeapSecond{ 1975, 1 }, + LeapSecond{ 1976, 1 }, + LeapSecond{ 1977, 1 }, + LeapSecond{ 1978, 1 }, + LeapSecond{ 1979, 1 }, + LeapSecond{ 1980, 1 }, + LeapSecond{ 1981, 182 }, + LeapSecond{ 1982, 182 }, + LeapSecond{ 1983, 182 }, + LeapSecond{ 1985, 182 }, + LeapSecond{ 1988, 1 }, + LeapSecond{ 1990, 1 }, + LeapSecond{ 1991, 1 }, + LeapSecond{ 1992, 183 }, + LeapSecond{ 1993, 182 }, + LeapSecond{ 1994, 182 }, + LeapSecond{ 1996, 1 }, + LeapSecond{ 1997, 182 }, + LeapSecond{ 1999, 1 }, + LeapSecond{ 2006, 1 }, + LeapSecond{ 2009, 1 }, + LeapSecond{ 2012, 183 }, + LeapSecond{ 2015, 182 }, + LeapSecond{ 2017, 1 } + }; static const openspace::properties::Property::PropertyInfo PathInfo = { "Path", @@ -96,107 +151,73 @@ namespace { "Size of Render Block", "Number of objects to render sequentially from StartRenderIdx" }; - constexpr const char* KeyFile = "Path"; - constexpr const char* KeyLineNum = "LineNumber"; -} + + // Count the number of full days since the beginning of 2000 to the beginning of + // the parameter 'year' + int countDays(int year) { + // Find the position of the current year in the vector, the difference + // between its position and the position of 2000 (for J2000) gives the + // number of leap years + constexpr const int Epoch = 2000; + constexpr const int DaysRegularYear = 365; + constexpr const int DaysLeapYear = 366; + + if (year == Epoch) { + return 0; + } + + // Get the position of the most recent leap year + const auto lb = std::lower_bound(LeapYears.begin(), LeapYears.end(), year); + + // Get the position of the epoch + const auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); + + // The distance between the two iterators gives us the number of leap years + const int nLeapYears = static_cast(std::abs(std::distance(y2000, lb))); + + const int nYears = std::abs(year - Epoch); + const int nRegularYears = nYears - nLeapYears; + + // Get the total number of days as the sum of leap years + non leap years + const int result = nRegularYears * DaysRegularYear + nLeapYears * DaysLeapYear; + return result; + } + + // Returns the number of leap seconds that lie between the {year, dayOfYear} + // time point and { 2000, 1 } + int countLeapSeconds(int year, int dayOfYear) { + // Get the position of the last leap second before the desired date + LeapSecond date{ year, dayOfYear }; + const auto it = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), date); + + // Get the position of the Epoch + const auto y2000 = std::lower_bound( + LeapSeconds.begin(), + LeapSeconds.end(), + Epoch + ); + + // The distance between the two iterators gives us the number of leap years + const int nLeapSeconds = static_cast(std::abs(std::distance(y2000, it))); + return nLeapSeconds; + } + + int daysIntoGivenYear(int month, int dayOfMonth) { + //month and dayCount are zero-based. Does NOT account for leap year. + month -= 1; + int dayCount = dayOfMonth - 1; + + for (int m = 0; m < month; ++m) { + dayCount += DaysOfMonths[m]; + } + return dayCount; + } + +} // namespace namespace openspace { -// Count the number of full days since the beginning of 2000 to the beginning of -// the parameter 'year' -int RenderableOrbitalKepler::countDays(int year) { - // Find the position of the current year in the vector, the difference - // between its position and the position of 2000 (for J2000) gives the - // number of leap years - constexpr const int Epoch = 2000; - constexpr const int DaysRegularYear = 365; - constexpr const int DaysLeapYear = 366; - - if (year == Epoch) { - return 0; - } - - // Get the position of the most recent leap year - const auto lb = std::lower_bound(LeapYears.begin(), LeapYears.end(), year); - - // Get the position of the epoch - const auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); - - // The distance between the two iterators gives us the number of leap years - const int nLeapYears = static_cast(std::abs(std::distance(y2000, lb))); - - const int nYears = std::abs(year - Epoch); - const int nRegularYears = nYears - nLeapYears; - - // Get the total number of days as the sum of leap years + non leap years - const int result = nRegularYears * DaysRegularYear + nLeapYears * DaysLeapYear; - return result; -} - -// Returns the number of leap seconds that lie between the {year, dayOfYear} -// time point and { 2000, 1 } -int RenderableOrbitalKepler::countLeapSeconds(int year, int dayOfYear) { - // Find the position of the current year in the vector; its position in - // the vector gives the number of leap seconds - struct LeapSecond { - int year; - int dayOfYear; - bool operator<(const LeapSecond& rhs) const { - return std::tie(year, dayOfYear) < std::tie(rhs.year, rhs.dayOfYear); - } - }; - - const LeapSecond Epoch = { 2000, 1 }; - - // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list - static const std::vector LeapSeconds = { - { 1972, 1 }, - { 1972, 183 }, - { 1973, 1 }, - { 1974, 1 }, - { 1975, 1 }, - { 1976, 1 }, - { 1977, 1 }, - { 1978, 1 }, - { 1979, 1 }, - { 1980, 1 }, - { 1981, 182 }, - { 1982, 182 }, - { 1983, 182 }, - { 1985, 182 }, - { 1988, 1 }, - { 1990, 1 }, - { 1991, 1 }, - { 1992, 183 }, - { 1993, 182 }, - { 1994, 182 }, - { 1996, 1 }, - { 1997, 182 }, - { 1999, 1 }, - { 2006, 1 }, - { 2009, 1 }, - { 2012, 183 }, - { 2015, 182 }, - { 2017, 1 } - }; - - // Get the position of the last leap second before the desired date - LeapSecond date { year, dayOfYear }; - const auto it = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), date); - - // Get the position of the Epoch - const auto y2000 = std::lower_bound( - LeapSeconds.begin(), - LeapSeconds.end(), - Epoch - ); - - // The distance between the two iterators gives us the number of leap years - const int nLeapSeconds = static_cast(std::abs(std::distance(y2000, it))); - return nLeapSeconds; -} - -double RenderableOrbitalKepler::calculateSemiMajorAxis(double meanMotion) { +double RenderableOrbitalKepler::calculateSemiMajorAxis(double meanMotion) const { constexpr const double GravitationalConstant = 6.6740831e-11; constexpr const double MassEarth = 5.9721986e24; constexpr const double muEarth = GravitationalConstant * MassEarth; @@ -207,16 +228,17 @@ double RenderableOrbitalKepler::calculateSemiMajorAxis(double meanMotion) { // with a = semimajor axis // P = period in seconds // mu = G*M_earth - double period = std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion; + const double period = + std::chrono::seconds(std::chrono::hours(24)).count() / meanMotion; - const double pisq = glm::pi() * glm::pi(); - double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); + constexpr const double pisq = glm::pi() * glm::pi(); + const double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); // We need the semi major axis in km instead of m return semiMajorAxis / 1000.0; } -double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochString) { +double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochString) const { // The epochString is in the form: // YYDDD.DDDDDDDD // With YY being the last two years of the launch epoch, the first DDD the day @@ -239,10 +261,8 @@ double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochStrin // those from 00-56 correspond to 2000-2056. We'll see each other again in 057! // 1. Get the full year - std::string yearPrefix = [y = epochString.substr(0, 2)](){ - int year = std::atoi(y.c_str()); - return year >= 57 ? "19" : "20"; - }(); + std::string yearPrefix = + std::atoi(epochString.substr(0, 2).c_str()) > 57 ? "19" : "20"; const int year = std::atoi((yearPrefix + epochString.substr(0, 2)).c_str()); const int daysSince2000 = countDays(year); @@ -251,11 +271,8 @@ double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochStrin double daysInYear = std::atof(epochString.substr(2).c_str()); // 2.b - const bool isInLeapYear = std::find( - LeapYears.begin(), - LeapYears.end(), - year - ) != LeapYears.end(); + const bool isInLeapYear = + std::find(LeapYears.begin(), LeapYears.end(), year) != LeapYears.end(); if (isInLeapYear && daysInYear >= 60) { // We are in a leap year, so we have an effective day more if we are // beyond the end of february (= 31+29 days) @@ -277,9 +294,7 @@ double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochStrin ); // 5 - const double nSecondsEpochOffset = static_cast( - seconds(hours(12)).count() - ); + const double nSecondsEpochOffset = static_cast(seconds(hours(12)).count()); // Combine all of the values const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; @@ -315,11 +330,8 @@ double RenderableOrbitalKepler::epochFromYMDdSubstring(const std::string& epochS double daysInYear = static_cast(wholeDaysInto) + fractionOfDay; // 2.b - const bool isInLeapYear = std::find( - LeapYears.begin(), - LeapYears.end(), - year - ) != LeapYears.end(); + const bool isInLeapYear = + std::find(LeapYears.begin(), LeapYears.end(), year) != LeapYears.end(); if (isInLeapYear && daysInYear >= 60) { // We are in a leap year, so we have an effective day more if we are // beyond the end of february (= 31+29 days) @@ -341,28 +353,15 @@ double RenderableOrbitalKepler::epochFromYMDdSubstring(const std::string& epochS ); // 5 - const double nSecondsEpochOffset = static_cast( - seconds(hours(12)).count() - ); + const double nSecondsEpochOffset = static_cast(seconds(hours(12)).count()); // Combine all of the values const double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; return epoch; } -int RenderableOrbitalKepler::daysIntoGivenYear(int month, int dayOfMonth) { - //month and dayCount are zero-based. Does NOT account for leap year. - month -= 1; - int dayCount = dayOfMonth - 1; - - for (int m = Months::January; m < month; ++m) { - dayCount += DaysOfMonths[m]; - } - return dayCount; -} - -RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictionary) - : Renderable(dictionary) +RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dict) + : Renderable(dict) , _path(PathInfo) , _segmentQuality(SegmentQualityInfo, 2, 1, 10) , _upperLimit(UpperLimitInfo, 1000, 1, 1000000) @@ -370,66 +369,41 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio , _sizeRender(RenderSizeInfo, 1, 1, 2) { documentation::testSpecificationAndThrow( - Documentation(), - dictionary, - "RenderableOrbitalKepler" + Documentation(), + dict, + "RenderableOrbitalKepler" ); - _path = dictionary.value(PathInfo.identifier); - _segmentQuality = static_cast( - dictionary.value(SegmentQualityInfo.identifier) - ); + _path = dict.value(PathInfo.identifier); + _segmentQuality = static_cast(dict.value(SegmentQualityInfo.identifier)); - if (dictionary.hasKeyAndValue(LineColorInfo.identifier)) { - _appearance.lineColor = dictionary.value(LineColorInfo.identifier); - } - if (dictionary.hasKeyAndValue(TrailFadeInfo.identifier)) { - _appearance.lineFade = static_cast( - dictionary.value(TrailFadeInfo.identifier) - ); - } - else { - _appearance.lineFade = 20; + if (dict.hasKeyAndValue(LineColorInfo.identifier)) { + _appearance.lineColor = dict.value(LineColorInfo.identifier); } - if (dictionary.hasKeyAndValue(UpperLimitInfo.identifier)) { - _upperLimit = static_cast( - dictionary.value(UpperLimitInfo.identifier) - ); - } - else { - _upperLimit = 0; - } + _appearance.lineFade = dict.hasKeyAndValue(TrailFadeInfo.identifier) ? + static_cast(dict.value(TrailFadeInfo.identifier)) : + 20.f; - if (dictionary.hasKeyAndValue(StartRenderIdxInfo.identifier)) { - _startRenderIdx = static_cast( - dictionary.value(StartRenderIdxInfo.identifier) - ); - } - else { - _startRenderIdx = 0; - } + _upperLimit = dict.hasKeyAndValue(UpperLimitInfo.identifier) ? + static_cast(dict.value(UpperLimitInfo.identifier)) : + 0.f; - if (dictionary.hasKeyAndValue(RenderSizeInfo.identifier)) { - _sizeRender = static_cast( - dictionary.value(RenderSizeInfo.identifier) - ); - } - else { - _sizeRender = 0; - } + _startRenderIdx = dict.hasKeyAndValue(StartRenderIdxInfo.identifier) ? + static_cast(dict.value(StartRenderIdxInfo.identifier)) : + 0; - if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { - _appearance.lineWidth = static_cast( - dictionary.value(LineWidthInfo.identifier) - ); - } - else { - _appearance.lineWidth = 2.0; - } - reinitializeTrailBuffers = std::function([this] { initializeGL(); }); - _path.onChange(reinitializeTrailBuffers); - _segmentQuality.onChange(reinitializeTrailBuffers); + _sizeRender = dict.hasKeyAndValue(RenderSizeInfo.identifier) ? + static_cast(dict.value(RenderSizeInfo.identifier)) : + 0; + + _appearance.lineWidth = dict.hasKeyAndValue(LineWidthInfo.identifier) ? + static_cast(dict.value(LineWidthInfo.identifier)) : + 2.f; + + _reinitializeTrailBuffers = std::function([this] { initializeGL(); }); + _path.onChange(_reinitializeTrailBuffers); + _segmentQuality.onChange(_reinitializeTrailBuffers); addPropertySubOwner(_appearance); addProperty(_path); @@ -438,10 +412,10 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dictio addProperty(_startRenderIdx); addProperty(_sizeRender); - updateStartRenderIdxSelect = std::function([this] { initializeGL(); }); - updateRenderSizeSelect = std::function([this] { initializeGL(); }); - _startRenderIdxCallbackHandle = _startRenderIdx.onChange(updateStartRenderIdxSelect); - _sizeRenderCallbackHandle = _sizeRender.onChange(updateRenderSizeSelect); + _updateStartRenderIdxSelect = std::function([this] { initializeGL(); }); + _updateRenderSizeSelect = std::function([this] { initializeGL(); }); + _startRenderIdxCallbackHandle = _startRenderIdx.onChange(_updateStartRenderIdxSelect); + _sizeRenderCallbackHandle = _sizeRender.onChange(_updateRenderSizeSelect); setRenderBin(Renderable::RenderBin::Overlay); } @@ -489,14 +463,14 @@ bool RenderableOrbitalKepler::isReady() const { } void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { - if (_data.empty()) + if (_data.empty()) { return; + } _programObject->activate(); _programObject->setUniform(_uniformCache.opacity, _opacity); _programObject->setUniform(_uniformCache.inGameTime, data.time.j2000Seconds()); - glm::dmat4 modelTransform = glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * glm::dmat4(data.modelTransform.rotation) * @@ -508,7 +482,9 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { ); // Because we want the property to work similar to the planet trails - float fade = static_cast(pow(_appearance.lineFade.maxValue() - _appearance.lineFade, 2.0)); + const float fade = static_cast( + pow(_appearance.lineFade.maxValue() - _appearance.lineFade, 2.0) + ); _programObject->setUniform(_uniformCache.projection, data.camera.projectionMatrix()); _programObject->setUniform(_uniformCache.color, _appearance.lineColor); @@ -530,7 +506,6 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { glBindVertexArray(0); _programObject->deactivate(); - } void RenderableOrbitalKepler::updateBuffers() { @@ -546,7 +521,7 @@ void RenderableOrbitalKepler::updateBuffers() { size_t vertexBufIdx = 0; for (size_t orbitIdx = 0; orbitIdx < numOrbits; ++orbitIdx) { - KeplerParameters orbit = _data[orbitIdx]; + const KeplerParameters& orbit = _data[orbitIdx]; _keplerTranslator.setKeplerElements( orbit.eccentricity, @@ -570,13 +545,9 @@ void RenderableOrbitalKepler::updateBuffers() { false }); - double positionX = position.x; - double positionY = position.y; - double positionZ = position.z; - - _vertexBufferData[vertexBufIdx].x = static_cast(positionX); - _vertexBufferData[vertexBufIdx].y = static_cast(positionY); - _vertexBufferData[vertexBufIdx].z = static_cast(positionZ); + _vertexBufferData[vertexBufIdx].x = static_cast(position.x); + _vertexBufferData[vertexBufIdx].y = static_cast(position.y); + _vertexBufferData[vertexBufIdx].z = static_cast(position.z); _vertexBufferData[vertexBufIdx].time = static_cast(timeOffset); _vertexBufferData[vertexBufIdx].epoch = orbit.epoch; _vertexBufferData[vertexBufIdx].period = orbit.period; @@ -599,10 +570,16 @@ void RenderableOrbitalKepler::updateBuffers() { glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(TrailVBOLayout), nullptr); glEnableVertexAttribArray(1); - glVertexAttribPointer(1, 2, GL_DOUBLE, GL_FALSE, sizeof(TrailVBOLayout), (GLvoid*)(4 * sizeof(GL_FLOAT))); + glVertexAttribPointer( + 1, + 2, + GL_DOUBLE, + GL_FALSE, + sizeof(TrailVBOLayout), + reinterpret_cast(4 * sizeof(GL_FLOAT)) + ); glBindVertexArray(0); - } -} +} // namespace opensapce diff --git a/modules/space/rendering/renderableorbitalkepler.h b/modules/space/rendering/renderableorbitalkepler.h index fc27a3c30e..42c6a45848 100644 --- a/modules/space/rendering/renderableorbitalkepler.h +++ b/modules/space/rendering/renderableorbitalkepler.h @@ -62,38 +62,14 @@ public: virtual void readDataFile(const std::string& filename) = 0; protected: - int countDays(int year); - int countLeapSeconds(int year, int dayOfYear); - double calculateSemiMajorAxis(double meanMotion); - double epochFromSubstring(const std::string& epochString); + double calculateSemiMajorAxis(double meanMotion) const; + double epochFromSubstring(const std::string& epochString) const; double epochFromYMDdSubstring(const std::string& epochString); - int daysIntoGivenYear(int month, int dayOfMonth); - std::function reinitializeTrailBuffers; - std::function updateStartRenderIdxSelect; - std::function updateRenderSizeSelect; - const std::vector LeapYears = { - 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, - 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, - 2044, 2048, 2052, 2056 - }; - const std::vector DaysOfMonths = { - 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - enum Months { - January = 0, - February, - March, - April, - May, - June, - July, - August, - September, - October, - November, - December - }; + std::function _reinitializeTrailBuffers; + std::function _updateStartRenderIdxSelect; + std::function _updateRenderSizeSelect; + struct KeplerParameters { double inclination = 0.0; double semiMajorAxis = 0.0; @@ -107,8 +83,8 @@ protected: }; std::streamoff _numObjects; bool _isFileReadinitialized = false; - const double convertAuToKm = 1.496e8; - const double convertDaysToSecs = 86400.; + inline static constexpr double convertAuToKm = 1.496e8; + inline static constexpr double convertDaysToSecs = 86400.0; std::vector _data; std::vector _segmentSize; properties::UIntProperty _upperLimit; @@ -146,10 +122,6 @@ private: GLuint _vertexBuffer; GLuint _indexBuffer; - //GLuint _vaoTest; // vertexArrayObject - //GLuint _vboTest; // vertextBufferObject - //GLuint _eboTest; // elementBufferObject/ indexBufferObject - void updateBuffers(); ghoul::opengl::ProgramObject* _programObject; diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 56780c7eaa..ab0279a99e 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -268,9 +268,9 @@ void RenderableSatellites::initializeFileReading() { _startRenderIdx = static_cast(0); _sizeRender = static_cast(_numObjects); _startRenderIdxCallbackHandle = _startRenderIdx.onChange( - updateStartRenderIdxSelect); + _updateStartRenderIdxSelect); _sizeRenderCallbackHandle = _sizeRender.onChange( - updateRenderSizeSelect); + _updateRenderSizeSelect); } void RenderableSatellites::skipSingleEntryInFile(std::ifstream& file) { diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 0eb013d30c..07666e32c2 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -41,8 +41,8 @@ #include #include #include -#include #include +#include #include namespace { @@ -85,7 +85,7 @@ namespace { "Upper limit on the number of objects for this renderable, regardless of " "how many objects are contained in the data file" }; -} +} // namespace namespace openspace { @@ -138,7 +138,7 @@ documentation::Documentation RenderableSmallBody::Documentation() { RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) { - _upperLimitCallbackHandle = _upperLimit.onChange(reinitializeTrailBuffers); + _upperLimitCallbackHandle = _upperLimit.onChange(_reinitializeTrailBuffers); addProperty(_upperLimit); } @@ -153,8 +153,11 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { file.exceptions(std::ifstream::failbit | std::ifstream::badbit); file.open(filename); - std::streamoff numberOfLines = std::count(std::istreambuf_iterator(file), - std::istreambuf_iterator(), '\n' ); + std::streamoff numberOfLines = std::count( + std::istreambuf_iterator(file), + std::istreambuf_iterator(), + '\n' + ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file _data.clear(); _sbNames.clear(); @@ -164,11 +167,8 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { unsigned int csvLine = 0; int fieldCount = 0; float lineSkipFraction = 1.0; - float currLineFraction; - int currLineCount; int lastLineCount = -1; - const std::string expectedHeaderLine = - "full_name,epoch_cal,e,a,i,om,w,ma,per"; + const std::string expectedHeaderLine = "full_name,epoch_cal,e,a,i,om,w,ma,per"; try { std::getline(file, line); // get rid of first line (header) @@ -194,17 +194,16 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { if (line.compare(expectedHeaderLine) != 0) { LERROR(fmt::format( - "File {} does not have the appropriate JPL SBDB header at line 1.", + "File {} does not have the appropriate JPL SBDB header at line 1", filename )); - file.close(); return; } unsigned int sequentialLineErrors = 0; unsigned int endElement = _startRenderIdx + _sizeRender - 1; endElement = (endElement >= _numObjects) ? _numObjects - 1 : endElement; - //Burn lines if not starting at first element + // Burn lines if not starting at first element for (unsigned int k = 0; k < _startRenderIdx; ++k) { skipSingleLineInFile(file); } @@ -213,8 +212,8 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { csvLine <= endElement + 1; csvLine++, sequentialLineErrors++) { - currLineFraction = static_cast(csvLine - 1) * lineSkipFraction; - currLineCount = static_cast(currLineFraction); + float currLineFraction = static_cast(csvLine - 1) * lineSkipFraction; + int currLineCount = static_cast(currLineFraction); if (currLineCount > lastLineCount) { try { readOrbitalParamsFromThisLine(firstDataLine, fieldCount, csvLine, @@ -258,16 +257,13 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { firstDataLine = false; } } - catch (std::ios_base::failure&) { - const char* errMsg = "File read exception (ios_base::failure) while trying "\ - "to read field {} at line {}/{} of {}"; + catch (const std::ios_base::failure&) { LERROR(fmt::format( - errMsg, + "File read exception (ios_base::failure) while trying to read field {} at " + "line {}/{} of {}", fieldCount, csvLine + 1, numberOfLines, filename )); } - - file.close(); } void RenderableSmallBody::initializeFileReading() { @@ -277,16 +273,14 @@ void RenderableSmallBody::initializeFileReading() { _sizeRender.setMaxValue(_numObjects); _startRenderIdx = static_cast(0); _sizeRender = static_cast(_numObjects); - _startRenderIdxCallbackHandle = _startRenderIdx.onChange( - updateStartRenderIdxSelect); - _sizeRenderCallbackHandle = _sizeRender.onChange( - updateRenderSizeSelect); - //If a limit wasn't specified in dictionary, set it to # lines in file + _startRenderIdxCallbackHandle = _startRenderIdx.onChange(_updateStartRenderIdxSelect); + _sizeRenderCallbackHandle = _sizeRender.onChange(_updateRenderSizeSelect); + // If a limit wasn't specified in dictionary, set it to # lines in file // minus the header line (but temporarily disable callback to avoid 2nd call) _upperLimit.removeOnChange(_upperLimitCallbackHandle); _upperLimit.setMaxValue(_numObjects); _upperLimit = static_cast(_numObjects); - _upperLimitCallbackHandle = _upperLimit.onChange(reinitializeTrailBuffers); + _upperLimitCallbackHandle = _upperLimit.onChange(_reinitializeTrailBuffers); } void RenderableSmallBody::skipSingleLineInFile(std::ifstream& file) { @@ -315,33 +309,33 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(bool firstDataLine, std::getline(file, name, ','); if (_startRenderIdx > 0 && _startRenderIdx == (csvLine - 1)) { formatObjectName(name); - LINFO(fmt::format( - "Set render block to start at object {}", - name - )); + LINFO(fmt::format("Set render block to start at object {}", name)); } fieldCount++; // Epoch if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read epoch from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read epoch from line" + std::to_string(csvLine + 1) + ); } keplerElements.epoch = epochFromYMDdSubstring(field); fieldCount++; // Eccentricity (unit-less) if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read eccentricity from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read eccentricity from line" + std::to_string(csvLine + 1) + ); } keplerElements.eccentricity = std::stod(field); fieldCount++; // Semi-major axis (astronomical units - au) if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read semi-major axis from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read semi-major axis from line" + std::to_string(csvLine + 1) + ); } keplerElements.semiMajorAxis = std::stod(field); keplerElements.semiMajorAxis *= convertAuToKm; @@ -349,40 +343,45 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(bool firstDataLine, // Inclination (degrees) if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read inclination from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read inclination from line" + std::to_string(csvLine + 1) + ); } keplerElements.inclination = importAngleValue(field); fieldCount++; // Longitude of ascending node (degrees) if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read ascending node from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read ascending node from line" + std::to_string(csvLine + 1) + ); } keplerElements.ascendingNode = importAngleValue(field); fieldCount++; // Argument of Periapsis (degrees) if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read arg of periapsis from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read arg of periapsis from line" + std::to_string(csvLine + 1) + ); } keplerElements.argumentOfPeriapsis = importAngleValue(field); fieldCount++; // Mean Anomaly (degrees) if (!std::getline(file, field, ',')) { - throw std::invalid_argument("Unable to read mean anomaly from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read mean anomaly from line" + std::to_string(csvLine + 1) + ); } keplerElements.meanAnomaly = importAngleValue(field); fieldCount++; // Period (days) if (!std::getline(file, field)) { - throw std::invalid_argument("Unable to read period from line" - + std::to_string(csvLine + 1)); + throw std::invalid_argument( + "Unable to read period from line" + std::to_string(csvLine + 1) + ); } keplerElements.period = std::stod(field); keplerElements.period *= convertDaysToSecs; @@ -390,7 +389,7 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(bool firstDataLine, _data.push_back(keplerElements); _sbNames.push_back(name); - double scale = static_cast(_segmentQuality) * 10.0; + const double scale = static_cast(_segmentQuality) * 10.0; _segmentSize.push_back(scale + (scale / pow(1 - keplerElements.eccentricity, 1.2))); } @@ -410,4 +409,4 @@ static std::string& formatObjectName(std::string& name) { return name; } -} +} // namespace openspace From f1fe2f197b1925492ccffea2db919651139ea7d4 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 14 Apr 2020 15:48:58 +0200 Subject: [PATCH 55/67] General code cleanup --- ext/ghoul | 2 +- include/openspace/engine/globals.h | 3 +- include/openspace/engine/windowdelegate.h | 6 +- .../openspace/interaction/navigationhandler.h | 2 +- .../openspace/interaction/orbitalnavigator.h | 35 ++++---- .../interaction/websocketcamerastates.h | 3 +- .../interaction/websocketinputstate.h | 6 +- include/openspace/rendering/abufferrenderer.h | 1 - .../openspace/rendering/framebufferrenderer.h | 18 ++--- include/openspace/rendering/renderengine.h | 6 +- include/openspace/rendering/volumeraycaster.h | 2 +- include/openspace/scene/scenegraphnode.h | 2 +- include/openspace/util/touch.h | 4 +- modules/base/rendering/renderablelabels.cpp | 29 ++++--- modules/base/rendering/renderablelabels.h | 2 +- modules/base/rendering/renderablenodeline.cpp | 8 +- modules/base/rendering/renderabletrail.cpp | 7 +- modules/cefwebgui/cefwebguimodule.cpp | 4 +- .../rendering/renderablebillboardscloud.cpp | 28 ++++--- .../rendering/renderablebillboardscloud.h | 2 +- modules/galaxy/rendering/renderablegalaxy.cpp | 13 +-- modules/globebrowsing/src/renderableglobe.cpp | 34 ++++---- modules/globebrowsing/src/renderableglobe.h | 2 +- modules/globebrowsing/src/ringscomponent.cpp | 26 +++--- modules/globebrowsing/src/ringscomponent.h | 14 ++-- modules/globebrowsing/src/shadowcomponent.cpp | 73 +++++++++-------- modules/globebrowsing/src/shadowcomponent.h | 8 +- modules/globebrowsing/src/timequantizer.h | 6 +- modules/server/servermodule.cpp | 2 +- .../src/topics/flightcontrollertopic.cpp | 21 +++-- .../rendering/renderableorbitalkepler.cpp | 12 +-- .../space/rendering/renderablesatellites.cpp | 14 ++-- .../space/rendering/renderablesmallbody.cpp | 8 +- modules/space/rendering/renderablestars.cpp | 4 +- .../space/tasks/generatedebrisvolumetask.cpp | 79 +++++++++---------- .../space/tasks/generatedebrisvolumetask.h | 2 +- modules/space/translation/keplertranslation.h | 4 +- .../util/projectioncomponent.cpp | 7 +- modules/touch/src/touchinteraction.cpp | 19 +++-- modules/touch/src/win32_touch.cpp | 4 +- .../rendering/renderabletoyvolume.cpp | 3 +- .../rendering/renderabledistancelabel.cpp | 11 ++- modules/webbrowser/include/eventhandler.h | 2 +- modules/webbrowser/src/eventhandler.cpp | 4 +- src/engine/downloadmanager.cpp | 4 +- src/interaction/orbitalnavigator.cpp | 25 +++--- src/interaction/websocketcamerastates.cpp | 10 ++- src/interaction/websocketinputstate.cpp | 9 ++- src/rendering/framebufferrenderer.cpp | 38 ++++----- src/rendering/renderengine.cpp | 7 +- src/scene/scene.cpp | 2 +- src/scene/scene_lua.inl | 4 +- src/scene/scenegraphnode.cpp | 2 +- src/scripting/scriptengine_lua.inl | 5 +- 54 files changed, 339 insertions(+), 309 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 0461bf1f44..9e6f9abe90 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 0461bf1f44b58e04fb21d929b0f385e1120da7b4 +Subproject commit 9e6f9abe90b90157c52c6182b390a619062835b9 diff --git a/include/openspace/engine/globals.h b/include/openspace/engine/globals.h index c7133339bf..523936c496 100644 --- a/include/openspace/engine/globals.h +++ b/include/openspace/engine/globals.h @@ -122,7 +122,8 @@ static VersionChecker& versionChecker = detail::gVersionChecker(); static VirtualPropertyManager& virtualPropertyManager = detail::gVirtualPropertyManager(); static WindowDelegate& windowDelegate = detail::gWindowDelegate(); static configuration::Configuration& configuration = detail::gConfiguration(); -static interaction::InteractionMonitor& interactionMonitor = detail::gInteractionMonitor(); +static interaction::InteractionMonitor& interactionMonitor = + detail::gInteractionMonitor(); static interaction::JoystickInputStates& joystickInputStates = detail::gJoystickInputStates(); static interaction::WebsocketInputStates& websocketInputStates = diff --git a/include/openspace/engine/windowdelegate.h b/include/openspace/engine/windowdelegate.h index 1bef12d181..3d79719021 100644 --- a/include/openspace/engine/windowdelegate.h +++ b/include/openspace/engine/windowdelegate.h @@ -112,9 +112,9 @@ struct WindowDelegate { double (*getHorizFieldOfView)() = []() { return 0.0; }; void (*setHorizFieldOfView)(float hFovDeg) = [](float) { }; - - void* (*getNativeWindowHandle)(size_t windowIndex) = [](size_t) -> void* { - return nullptr; + + void* (*getNativeWindowHandle)(size_t windowIndex) = [](size_t) -> void* { + return nullptr; }; using GLProcAddress = void(*)(void); diff --git a/include/openspace/interaction/navigationhandler.h b/include/openspace/interaction/navigationhandler.h index 66b1e3942b..24d3ef495b 100644 --- a/include/openspace/interaction/navigationhandler.h +++ b/include/openspace/interaction/navigationhandler.h @@ -135,7 +135,7 @@ public: WebsocketCameraStates::AxisInvert::No, WebsocketCameraStates::AxisNormalize shouldNormalize = WebsocketCameraStates::AxisNormalize::No); - + NavigationState navigationState() const; NavigationState navigationState(const SceneGraphNode& referenceFrame) const; diff --git a/include/openspace/interaction/orbitalnavigator.h b/include/openspace/interaction/orbitalnavigator.h index 623cc5fd3f..f2ad409223 100644 --- a/include/openspace/interaction/orbitalnavigator.h +++ b/include/openspace/interaction/orbitalnavigator.h @@ -79,10 +79,10 @@ public: JoystickCameraStates& joystickStates(); const JoystickCameraStates& joystickStates() const; - + WebsocketCameraStates& websocketStates(); const WebsocketCameraStates& websocketStates() const; - + ScriptCameraStates& scriptStates(); const ScriptCameraStates& scriptStates() const; @@ -246,19 +246,22 @@ private: * Translates the horizontal direction. If far from the anchor object, this will * result in an orbital rotation around the object. This function does not affect the * rotation but only the position. - * \returns a position vector adjusted in the horizontal direction. + * + * \return a position vector adjusted in the horizontal direction. */ glm::dvec3 translateHorizontally(double deltaTime, const glm::dvec3& cameraPosition, const glm::dvec3& objectPosition, const glm::dquat& globalCameraRotation, const SurfacePositionHandle& positionHandle) const; /** - * Moves the camera along a vector, camPosToCenterPosDiff, until it reaches the focusLimit. - * The velocity of the zooming depend on distFromCameraToFocus and the final frame - * where the camera stops moving depends on the distance set in the variable focusLimit. - * The bool determines whether to move/fly towards the focus node or away from it. - * \returns a new position of the camera, closer to the focusLimit than the previous - * position. + * Moves the camera along a vector, camPosToCenterPosDiff, until it reaches the + * focusLimit. The velocity of the zooming depend on distFromCameraToFocus and the + * final frame where the camera stops moving depends on the distance set in the + * variable focusLimit. The bool determines whether to move/fly towards the focus node + * or away from it. + * + * \return a new position of the camera, closer to the focusLimit than the previous + * position */ glm::dvec3 moveCameraAlongVector(const glm::dvec3& camPos, double distFromCameraToFocus, const glm::dvec3& camPosToCenterPosDiff, @@ -267,14 +270,16 @@ private: /* * Adds rotation to the camera position so that it follows the rotation of the anchor * node defined by the differential anchorNodeRotationDiff. - * \returns a position updated with the rotation defined by anchorNodeRotationDiff + * + * \return a position updated with the rotation defined by anchorNodeRotationDiff */ glm::dvec3 followAnchorNodeRotation(const glm::dvec3& cameraPosition, const glm::dvec3& objectPosition, const glm::dquat& anchorNodeRotationDiff) const; /** * Updates the global rotation so that it points towards the anchor node. - * \returns a global rotation quaternion defining a rotation towards the anchor node. + * + * \return a global rotation quaternion defining a rotation towards the anchor node */ glm::dquat rotateGlobally(const glm::dquat& globalCameraRotation, const glm::dquat& aimNodeRotationDiff, @@ -290,7 +295,8 @@ private: /** * Rotates the camera around the out vector of the surface. - * \returns a quaternion adjusted to rotate around the out vector of the surface. + * + * \return a quaternion adjusted to rotate around the out vector of the surface */ glm::dquat rotateHorizontally(double deltaTime, const glm::dquat& globalCameraRotation, @@ -298,8 +304,9 @@ private: /** * Push the camera out to the surface of the object. - * \returns a position vector adjusted to be at least minHeightAboveGround meters - * above the actual surface of the object + * + * \return a position vector adjusted to be at least minHeightAboveGround meters + * above the actual surface of the object */ glm::dvec3 pushToSurface(double minHeightAboveGround, const glm::dvec3& cameraPosition, const glm::dvec3& objectPosition, diff --git a/include/openspace/interaction/websocketcamerastates.h b/include/openspace/interaction/websocketcamerastates.h index 0b0bc5c4a9..d7bbd66613 100644 --- a/include/openspace/interaction/websocketcamerastates.h +++ b/include/openspace/interaction/websocketcamerastates.h @@ -106,7 +106,8 @@ private: namespace ghoul { template <> -std::string to_string(const openspace::interaction::WebsocketCameraStates::AxisType& type); +std::string to_string( + const openspace::interaction::WebsocketCameraStates::AxisType& type); template <> openspace::interaction::WebsocketCameraStates::AxisType diff --git a/include/openspace/interaction/websocketinputstate.h b/include/openspace/interaction/websocketinputstate.h index 576e0c4c24..3068e22294 100644 --- a/include/openspace/interaction/websocketinputstate.h +++ b/include/openspace/interaction/websocketinputstate.h @@ -84,9 +84,9 @@ constexpr const int MaxWebsockets = 16; struct WebsocketInputStates : public std::unordered_map { /** * This function adds the contributions of all connected websockets for the provided - * \p axis. After adding each websockets contribution, the result is clamped to [-1,1]. - * If a websocket does not possess a particular axis, it's does not contribute to the - * sum. + * \p axis. After adding each websockets contribution, the result is clamped to + * [-1,1]. If a websocket does not possess a particular axis, it's does not contribute + * to the sum. * * \param axis The numerical axis for which the values are added * \return The summed axis values of all connected websockets diff --git a/include/openspace/rendering/abufferrenderer.h b/include/openspace/rendering/abufferrenderer.h index 275d41c897..3505c13292 100644 --- a/include/openspace/rendering/abufferrenderer.h +++ b/include/openspace/rendering/abufferrenderer.h @@ -80,7 +80,6 @@ public: void setLightness(float lightness) override; void setColorSpace(unsigned int colorspace) override; - void enableBloom(bool enable) override; void enableHistogram(bool enable) override; diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index 70330f2243..52df76befd 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -71,17 +71,17 @@ public: void updateHDRAndFiltering(); void updateFXAA(); void updateDownscaledVolume(); - + void setResolution(glm::ivec2 res) override; void setHDRExposure(float hdrExposure) override; void setGamma(float gamma) override; void setHue(float hue) override; void setValue(float value) override; void setSaturation(float sat) override; - + void enableFXAA(bool enable) override; void setDisableHDR(bool disable) override; - + void update() override; void performRaycasterTasks(const std::vector& tasks); void performDeferredTasks(const std::vector& tasks); @@ -114,7 +114,7 @@ private: void updateDownscaleTextures(); void updateExitVolumeTextures(); void writeDownscaledVolume(); - + std::map _raycastData; RaycasterProgObjMap _exitPrograms; RaycasterProgObjMap _raycastPrograms; @@ -131,7 +131,7 @@ private: UniformCache(hdrFeedingTexture, blackoutFactor, hdrExposure, gamma, Hue, Saturation, Value) _hdrUniformCache; UniformCache(renderedTexture, inverseScreenSize) _fxaaUniformCache; - UniformCache(downscaledRenderedVolume, downscaledRenderedVolumeDepth) + UniformCache(downscaledRenderedVolume, downscaledRenderedVolumeDepth) _writeDownscaledVolumeUniformCache; GLint _defaultFBO; @@ -158,7 +158,7 @@ private: GLuint hdrFilteringFramebuffer; GLuint hdrFilteringTexture; } _hdrBuffers; - + struct { GLuint fxaaFramebuffer; GLuint fxaaTexture; @@ -176,18 +176,18 @@ private: bool _dirtyDeferredcastData; bool _dirtyRaycastData; bool _dirtyResolution; - + glm::ivec2 _resolution = glm::ivec2(0); int _nAaSamples; bool _enableFXAA = true; bool _disableHDR = false; - + float _hdrExposure = 3.7f; float _gamma = 0.95f; float _hue = 1.f; float _saturation = 1.f; float _value = 1.f; - + ghoul::Dictionary _rendererData; }; diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 5216060d6d..29f12f2c4a 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -211,7 +211,7 @@ private: properties::BoolProperty _disableMasterRendering; properties::FloatProperty _globalBlackOutFactor; - + properties::BoolProperty _enableFXAA; properties::BoolProperty _disableHDRPipeline; @@ -221,13 +221,13 @@ private: properties::FloatProperty _hue; properties::FloatProperty _saturation; properties::FloatProperty _value; - + properties::FloatProperty _horizFieldOfView; properties::Vec3Property _globalRotation; properties::Vec3Property _screenSpaceRotation; properties::Vec3Property _masterRotation; - + uint64_t _frameNumber = 0; unsigned int _latestScreenshotNumber = 0; diff --git a/include/openspace/rendering/volumeraycaster.h b/include/openspace/rendering/volumeraycaster.h index 29c159f442..1534c51ff8 100644 --- a/include/openspace/rendering/volumeraycaster.h +++ b/include/openspace/rendering/volumeraycaster.h @@ -139,7 +139,7 @@ public: private: /** - * Maximum number of integration steps to be executed by the volume integrator. + * Maximum number of integration steps to be executed by the volume integrator. */ int _rayCastMaxSteps = 1000; diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 86bffe0658..ecc42bb9ff 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -198,7 +198,7 @@ private: properties::DoubleProperty _distFromCamToNode; properties::DoubleProperty _screenSizeRadius; properties::FloatProperty _visibilityDistance; - + // This variable is used for the rate-limiting of the screenspace positions (if they // are calculated when _computeScreenSpaceValues is true) std::chrono::high_resolution_clock::time_point _lastScreenSpaceUpdateTime; diff --git a/include/openspace/util/touch.h b/include/openspace/util/touch.h index 3d1e1bf8a4..2f5f1d6deb 100644 --- a/include/openspace/util/touch.h +++ b/include/openspace/util/touch.h @@ -52,7 +52,7 @@ struct TouchInput { double timestamp; // timestamp in seconds from global touch initialization }; -// The TouchInputHolder holds one or many TouchInputs, in order to track the history of +// The TouchInputHolder holds one or many TouchInputs, in order to track the history of // the finger/input device class TouchInputHolder { public: @@ -62,7 +62,7 @@ public: // Fails upon a too similar input as last. // Updates time for the last input if same position. bool tryAddInput(TouchInput input); - + void clearInputs(); // Checks whether or not this Holder actually holds a specific input (based on IDs) diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp index 2fa6c17ba4..f83752a8c1 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabels.cpp @@ -48,7 +48,7 @@ namespace { constexpr const char* _loggerCat = "base::RenderableLabels"; - + constexpr const char* MeterUnit = "m"; constexpr const char* KilometerUnit = "Km"; constexpr const char* MegameterUnit = "Mm"; @@ -203,7 +203,7 @@ documentation::Documentation RenderableLabels::Documentation() { LabelColorInfo.identifier, new DoubleVector4Verifier, Optional::Yes, - LabelColorInfo.description, + LabelColorInfo.description, }, { LabelColorInfo.identifier, @@ -392,7 +392,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) addProperty(_labelText); addProperty(_labelOrientationOption); - + _labelColor.setViewOption(properties::Property::ViewOptions::Color); if (dictionary.hasKey(LabelColorInfo.identifier)) { _labelColor = dictionary.value(LabelColorInfo.identifier); @@ -634,7 +634,7 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { //} float fadeInVariable = 1.f; - + if (_enableFadingEffect) { float distanceNodeToCamera = glm::distance( data.camera.positionVec3(), @@ -644,7 +644,6 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { float eUnit = unit(_fadeEndUnitOption); float startX = _fadeStartDistance * sUnit; float endX = _fadeEndDistance * eUnit; - //fadeInVariable = changedPerlinSmoothStepFunc(distanceNodeToCamera, startX, endX); fadeInVariable = linearSmoothStepFunc( distanceNodeToCamera, startX, @@ -676,7 +675,7 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { glm::dvec3 orthoUp = glm::normalize(glm::cross(cameraViewDirectionWorld, orthoRight)); renderLabels(data, modelViewProjectionMatrix, orthoRight, orthoUp, fadeInVariable); - + //if (additiveBlending) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(true); @@ -688,18 +687,18 @@ void RenderableLabels::setLabelText(const std::string & newText) { _labelText = newText; } -void RenderableLabels::renderLabels(const RenderData& data, +void RenderableLabels::renderLabels(const RenderData& data, const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable) { glm::vec4 textColor = _labelColor; - + textColor.a *= fadeInVariable; textColor.a *= _opacity; ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; - + labelInfo.orthoRight = orthoRight; labelInfo.orthoUp = orthoUp; labelInfo.minSize = static_cast(_labelMinSize); @@ -716,7 +715,7 @@ void RenderableLabels::renderLabels(const RenderData& data, glm::vec3 transformedPos( _transformationMatrix * glm::dvec4(data.modelTransform.translation, 1.0) ); - + ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( *_font, transformedPos, @@ -727,11 +726,11 @@ void RenderableLabels::renderLabels(const RenderData& data, } float RenderableLabels::changedPerlinSmoothStepFunc(float x, float startX, - float endX) const + float endX) const { - float f1 = 6.f * powf((x - startX), 5.f) - 15.f * powf((x - startX), 4.f) + + float f1 = 6.f * powf((x - startX), 5.f) - 15.f * powf((x - startX), 4.f) + 10.f * powf((x - startX), 3.f); - float f2 = -6.f * powf((x - endX), 5.f) + 15.f * powf((x - endX), 4.f) - + float f2 = -6.f * powf((x - endX), 5.f) + 15.f * powf((x - endX), 4.f) - 10.f * powf((x - endX), 3.f) + 1.f; float f3 = 1.f; @@ -743,7 +742,7 @@ float RenderableLabels::changedPerlinSmoothStepFunc(float x, float startX, } else if (x >= endX) { return std::clamp(f2, 0.f, 1.f); - } + } } float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX, @@ -754,7 +753,7 @@ float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX, float f1 = sdiv * (x - startX) + 1.f; float f2 = ediv * (x - endX) + 1.f; float f3 = 1.f; - + if (x <= startX) { return std::clamp(f1, 0.f, 1.f); } diff --git a/modules/base/rendering/renderablelabels.h b/modules/base/rendering/renderablelabels.h index c35d52d451..7d0466b9d0 100644 --- a/modules/base/rendering/renderablelabels.h +++ b/modules/base/rendering/renderablelabels.h @@ -100,7 +100,7 @@ private: const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable); float changedPerlinSmoothStepFunc(float x, float startX, float endX) const; - + float linearSmoothStepFunc(float x, float startX, float endX, float sUnit, float eUnit) const; diff --git a/modules/base/rendering/renderablenodeline.cpp b/modules/base/rendering/renderablenodeline.cpp index 4dc4291a55..fdf2acf398 100644 --- a/modules/base/rendering/renderablenodeline.cpp +++ b/modules/base/rendering/renderablenodeline.cpp @@ -146,7 +146,9 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary) _lineColor = dictionary.value(LineColorInfo.identifier); } if (dictionary.hasKey(LineWidthInfo.identifier)) { - _lineWidth = static_cast(dictionary.value(LineWidthInfo.identifier)); + _lineWidth = static_cast( + dictionary.value(LineWidthInfo.identifier) + ); } _start.onChange([&]() { validateNodes(); }); @@ -264,7 +266,7 @@ void RenderableNodeLine::updateVertexData() { void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { updateVertexData(); - + _program->activate(); glm::dmat4 anchorTranslation(1.0); @@ -316,7 +318,7 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { // Bind and draw bindGL(); glDrawArrays(GL_LINES, 0, 2); - + // Restore GL State unbindGL(); _program->deactivate(); diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index b6fa66ff23..8ad12a9d93 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -344,7 +344,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { } auto render = [renderLines, renderPoints, p = _programObject, &data, - &modelTransform, pointSize = _appearance.pointSize.value(), + &modelTransform, pointSize = _appearance.pointSize.value(), c = _uniformCache, lw = _appearance.lineWidth] (RenderInformation& info, int nVertices, int offset) { @@ -366,14 +366,13 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { p->setUniform(c.nVertices, nVertices); - #ifndef __APPLE__ glm::ivec2 resolution = global::renderEngine.renderingResolution(); p->setUniform(c.resolution, resolution); p->setUniform(c.lineWidth, ceil((2.f * 1.f + lw) * std::sqrt(2.f))); #endif - + if (renderPoints) { // The stride parameter determines the distance between larger points and // smaller ones @@ -444,7 +443,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { ); glm::dvec3 trailPosWorld = glm::dvec3( - modelTransform * _primaryRenderInformation._localTransform * + modelTransform * _primaryRenderInformation._localTransform * glm::dvec4(0.0, 0.0, 0.0, 1.0) ); const double distance = glm::distance( diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index 2d5b7c520d..839e5182c5 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -225,9 +225,9 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) if (isGuiWindow && isMaster && _instance) { if (global::windowDelegate.windowHasResized() || _instance->_shouldReshape) { + glm::ivec2 csws = global::windowDelegate.currentSubwindowSize(); _instance->reshape(static_cast( - static_cast(global::windowDelegate.currentSubwindowSize()) * - global::windowDelegate.dpiScaling() + static_cast(csws) * global::windowDelegate.dpiScaling() )); _instance->_shouldReshape = false; } diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 688d518611..2e5612e913 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -424,7 +424,10 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di , _drawLabels(DrawLabelInfo, false) , _pixelSizeControl(PixelSizeControlInfo, false) , _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown) - , _datavarSizeOption(SizeOptionInfo, properties::OptionProperty::DisplayType::Dropdown) + , _datavarSizeOption( + SizeOptionInfo, + properties::OptionProperty::DisplayType::Dropdown + ) , _fadeInDistance( FadeInDistancesInfo, glm::vec2(0.f), @@ -548,7 +551,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di ); } } - + if (dictionary.hasKey(ExactColorMapInfo.identifier)) { _isColorMapExact = dictionary.value(ExactColorMapInfo.identifier); } @@ -583,12 +586,12 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di _datavarSizeOption.onChange([&]() { _dataIsDirty = true; - _datavarSizeOptionString = _optionConversionSizeMap[_datavarSizeOption.value()]; - }); + _datavarSizeOptionString = _optionConversionSizeMap[_datavarSizeOption]; + }); addProperty(_datavarSizeOption); _hasDatavarSize = true; - } + } if (dictionary.hasKey(PolygonSidesInfo.identifier)) { _polygonSides = static_cast( @@ -673,13 +676,11 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di addProperty(_correctionSizeFactor); } - if (dictionary.hasKey(PixelSizeControlInfo.identifier)) { _pixelSizeControl = dictionary.value(PixelSizeControlInfo.identifier); addProperty(_pixelSizeControl); } - } bool RenderableBillboardsCloud::isReady() const { @@ -1086,7 +1087,7 @@ void RenderableBillboardsCloud::update(const UpdateData&) { sizeof(float) * 9, reinterpret_cast(sizeof(float) * 8) ); - } + } else if (_hasColorMapFile) { glEnableVertexAttribArray(positionAttrib); glVertexAttribPointer( @@ -1607,10 +1608,11 @@ void RenderableBillboardsCloud::createDataSlice() { } // what datavar in use for the index color - int colorMapInUse = _hasColorMapFile ? _variableDataPositionMap[_colorOptionString] : 0; - + int colorMapInUse = + _hasColorMapFile ? _variableDataPositionMap[_colorOptionString] : 0; + // what datavar in use for the size scaling (if present) - int sizeScalingInUse = _hasDatavarSize ? + int sizeScalingInUse = _hasDatavarSize ? _variableDataPositionMap[_datavarSizeOptionString] : -1; auto addDatavarSizeScalling = [&](size_t i, int datavarInUse) { @@ -1625,7 +1627,7 @@ void RenderableBillboardsCloud::createDataSlice() { float minColorIdx = std::numeric_limits::max(); float maxColorIdx = std::numeric_limits::min(); - + for (size_t i = 0; i < _fullData.size(); i += _nValuesPerAstronomicalObject) { float colorIdx = _fullData[i + 3 + colorMapInUse]; maxColorIdx = colorIdx >= maxColorIdx ? colorIdx : maxColorIdx; @@ -1671,7 +1673,7 @@ void RenderableBillboardsCloud::createDataSlice() { } else { float ncmap = static_cast(_colorMapData.size()); - float normalization = ((cmax != cmin) && (ncmap > 2)) ? + float normalization = ((cmax != cmin) && (ncmap > 2)) ? (ncmap - 2) / (cmax - cmin) : 0; colorIndex = (variableColor - cmin) * normalization + 1; colorIndex = colorIndex < 0 ? 0 : colorIndex; diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.h b/modules/digitaluniverse/rendering/renderablebillboardscloud.h index 15d4d241e6..7953806824 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.h +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.h @@ -144,7 +144,7 @@ private: correctionSizeFactor, color, alphaValue, scaleFactor, up, right, fadeInValue, screenSize, spriteTexture, hasColormap, enabledRectSizeControl, hasDvarScaling ) _uniformCache; - + std::shared_ptr _font; std::string _speckFile; diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 9023fe154d..c71403dc76 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -149,7 +149,10 @@ namespace { return; } - fileStream.write(reinterpret_cast(&CurrentCacheVersion), sizeof(int8_t)); + fileStream.write( + reinterpret_cast(&CurrentCacheVersion), + sizeof(int8_t) + ); fileStream.write(reinterpret_cast(&nPoints), sizeof(int64_t)); fileStream.write(reinterpret_cast(&pointsRatio), sizeof(float)); uint64_t nPositions = static_cast(positions.size()); @@ -291,7 +294,7 @@ RenderableGalaxy::RenderableGalaxy(const ghoul::Dictionary& dictionary) _downScaleVolumeRendering.setVisibility(properties::Property::Visibility::Developer); if (volumeDictionary.hasKey(DownscaleVolumeRenderingInfo.identifier)) { - _downScaleVolumeRendering = + _downScaleVolumeRendering = volumeDictionary.value(DownscaleVolumeRenderingInfo.identifier); } @@ -331,7 +334,7 @@ void RenderableGalaxy::initializeGL() { _aspect = static_cast(_volumeDimensions); _aspect /= std::max(std::max(_aspect.x, _aspect.y), _aspect.z); - // The volume + // The volume volume::RawVolumeReader> reader( _volumeFilename, _volumeDimensions @@ -657,7 +660,7 @@ void RenderableGalaxy::renderPoints(const RenderData& data) { glm::dmat4(1.0), glm::pi(), glm::dvec3(1.0, 0.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) ); @@ -737,7 +740,7 @@ void RenderableGalaxy::renderBillboards(const RenderData& data) { glm::dmat4(1.0), glm::pi(), glm::dvec3(1.0, 0.0, 0.0)) * - glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * + glm::rotate(glm::dmat4(1.0), 3.1248, glm::dvec3(0.0, 1.0, 0.0)) * glm::rotate(glm::dmat4(1.0), 4.45741, glm::dvec3(0.0, 0.0, 1.0) ); diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index ce70591800..b3bfcd144d 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -697,7 +697,7 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) _ringsComponent.initialize(); addPropertySubOwner(_ringsComponent); _hasRings = true; - + ghoul::Dictionary ringsDic; dictionary.getValue("Rings", ringsDic); } @@ -799,7 +799,7 @@ void RenderableGlobe::render(const RenderData& data, RendererTasks& rendererTask if (_hasRings && _ringsComponent.isEnabled()) { _ringsComponent.draw(lightRenderData, RingsComponent::GeometryOnly); } - + glEnable(GL_BLEND); _shadowComponent.setViewDepthMap(false); @@ -968,7 +968,7 @@ const glm::dmat4& RenderableGlobe::modelTransform() const { // Rendering code ////////////////////////////////////////////////////////////////////////////////////////// -void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, +void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const ShadowComponent::ShadowMapData& shadowData, bool renderGeomOnly) { @@ -986,7 +986,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const float dsf = static_cast( _generalProperties.currentLodScaleFactor * _ellipsoid.minimumRadius() ); - + // We are setting the setIgnoreUniformLocationError as it is not super trivial // and brittle to figure out apriori whether the uniform was optimized away // or not. It should be something long the lines of: @@ -1108,9 +1108,9 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const bool hasWaterLayer = !_layerManager.layerGroup( layergroupid::GroupID::WaterMasks ).activeLayers().empty(); - + _globalRenderer.program->setUniform("modelViewTransform", modelViewTransform); - + const bool hasHeightLayer = !_layerManager.layerGroup( layergroupid::HeightLayers ).activeLayers().empty(); @@ -1136,7 +1136,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const glm::vec3 directionToSunCameraSpace = glm::vec3(viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); // @TODO (abock, 2020-04-14); This is just a bandaid for issue #1136. The better - // way is to figure out with the uniform is optimized away. I assume that it is + // way is to figure out with the uniform is optimized away. I assume that it is // because the shader doesn't get recompiled when the last layer of the night // or water is disabled; so the shader thinks it has to do the calculation, but // there are actually no layers left @@ -1166,7 +1166,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, const glm::vec3 directionToSunCameraSpace = glm::vec3(viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); // @TODO (abock, 2020-04-14); This is just a bandaid for issue #1136. The better - // way is to figure out with the uniform is optimized away. I assume that it is + // way is to figure out with the uniform is optimized away. I assume that it is // because the shader doesn't get recompiled when the last layer of the night // or water is disabled; so the shader thinks it has to do the calculation, but // there are actually no layers left @@ -1346,9 +1346,9 @@ void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& // Shadow Mapping ghoul::opengl::TextureUnit shadowMapUnit; if (_generalProperties.shadowMapping && shadowData.shadowDepthTexture != 0) { - // Adding the model transformation to the final shadow matrix so we have a - // complete transformation from the model coordinates to the clip space of - // the light position. + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of the + // light position. program.setUniform( "shadowMatrix", shadowData.shadowMatrix * modelTransform() @@ -1362,14 +1362,14 @@ void RenderableGlobe::renderChunkGlobally(const Chunk& chunk, const RenderData& } glEnable(GL_DEPTH_TEST); - + if (!renderGeomOnly) { glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } _grid.drawUsingActiveProgram(); - + for (GPULayerGroup& l : _globalRenderer.gpuLayerGroups) { l.deactivate(); } @@ -1476,9 +1476,9 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d // Shadow Mapping ghoul::opengl::TextureUnit shadowMapUnit; if (_generalProperties.shadowMapping && shadowData.shadowDepthTexture != 0) { - // Adding the model transformation to the final shadow matrix so we have a - // complete transformation from the model coordinates to the clip space of - // the light position. + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of the + // light position. program.setUniform( "shadowMatrix", shadowData.shadowMatrix * modelTransform() @@ -1496,7 +1496,7 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } - + _grid.drawUsingActiveProgram(); for (GPULayerGroup& l : _localRenderer.gpuLayerGroups) { diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index 48f77d3042..ab4045d893 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -188,7 +188,7 @@ private: */ float getHeight(const glm::dvec3& position) const; - void renderChunks(const RenderData& data, RendererTasks& rendererTask, + void renderChunks(const RenderData& data, RendererTasks& rendererTask, const ShadowComponent::ShadowMapData& shadowData = {}, bool renderGeomOnly = false ); diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 45559754ab..4a45be2517 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -52,7 +52,7 @@ namespace { constexpr const char* _loggerCat = "RingsComponent"; constexpr const std::array UniformNames = { - "modelViewProjectionMatrix", "textureOffset", "transparency", "_nightFactor", + "modelViewProjectionMatrix", "textureOffset", "transparency", "_nightFactor", "sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture", "zFightingPercentage" }; @@ -180,7 +180,7 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) , _ringsDictionary(dictionary) { using ghoul::filesystem::File; - + if (dictionary.hasKey("Rings")) { // @TODO (abock, 2019-12-16) It would be better to not store the dictionary long // term and rather extract the values directly here. This would require a bit of @@ -188,7 +188,7 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) // class-initializer list though dictionary.getValue("Rings", _ringsDictionary); } - + documentation::testSpecificationAndThrow( Documentation(), _ringsDictionary, @@ -310,20 +310,20 @@ void RingsComponent::draw(const RenderData& data, else if (renderPass == GeometryOnly) { _geometryOnlyShader->activate(); } - + const glm::dmat4 modelTransform = glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * glm::dmat4(data.modelTransform.rotation) * glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); - const glm::dmat4 modelViewProjectionTransform = - glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix() + const glm::dmat4 modelViewProjectionTransform = + glm::dmat4(data.camera.projectionMatrix()) * data.camera.combinedViewMatrix() * modelTransform; ghoul::opengl::TextureUnit ringTextureUnit; if (renderPass == GeometryAndShading) { _shader->setUniform( - _uniformCache.modelViewProjectionMatrix, + _uniformCache.modelViewProjectionMatrix, modelViewProjectionTransform ); _shader->setUniform(_uniformCache.textureOffset, _offset); @@ -336,18 +336,18 @@ void RingsComponent::draw(const RenderData& data, _texture->bind(); _shader->setUniform(_uniformCache.ringTexture, ringTextureUnit); - // Adding the model transformation to the final shadow matrix so we have a - // complete transformation from the model coordinates to the clip space of + // Adding the model transformation to the final shadow matrix so we have a + // complete transformation from the model coordinates to the clip space of // the light position. _shader->setUniform( - _uniformCache.shadowMatrix, + _uniformCache.shadowMatrix, shadowData.shadowMatrix * modelTransform ); ghoul::opengl::TextureUnit shadowMapUnit; shadowMapUnit.activate(); glBindTexture(GL_TEXTURE_2D, shadowData.shadowDepthTexture); - + _shader->setUniform(_uniformCache.shadowMapTexture, shadowMapUnit); } else if (renderPass == GeometryOnly) { @@ -386,8 +386,8 @@ void RingsComponent::update(const UpdateData& data) { if (_geometryOnlyShader->isDirty()) { _geometryOnlyShader->rebuildFromFile(); ghoul::opengl::updateUniformLocations( - *_geometryOnlyShader, - _geomUniformCache, + *_geometryOnlyShader, + _geomUniformCache, GeomUniformNames ); } diff --git a/modules/globebrowsing/src/ringscomponent.h b/modules/globebrowsing/src/ringscomponent.h index c501c4a9de..62980e1bf6 100644 --- a/modules/globebrowsing/src/ringscomponent.h +++ b/modules/globebrowsing/src/ringscomponent.h @@ -54,18 +54,16 @@ public: GeometryOnly, GeometryAndShading }; - + RingsComponent(const ghoul::Dictionary& dictionary); void initialize(); void initializeGL(); void deinitializeGL(); - + bool isReady() const; - void draw( - const RenderData& data, - const RingsComponent::RenderPass renderPass, + void draw(const RenderData& data, const RingsComponent::RenderPass renderPass, const ShadowComponent::ShadowMapData& shadowData = {} ); void update(const UpdateData& data); @@ -90,11 +88,11 @@ private: std::unique_ptr _shader; std::unique_ptr _geometryOnlyShader; - UniformCache(modelViewProjectionMatrix, textureOffset, transparency, nightFactor, + UniformCache(modelViewProjectionMatrix, textureOffset, transparency, nightFactor, sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage ) _uniformCache; - UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture) - _geomUniformCache; + UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture + ) _geomUniformCache; std::unique_ptr _texture; std::unique_ptr _textureFile; diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index 3d59598e7b..2ab97a86fc 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -55,7 +55,7 @@ namespace { constexpr const char* _loggerCat = "ShadowComponent"; - + constexpr openspace::properties::Property::PropertyInfo SaveDepthTextureInfo = { "SaveDepthTextureInfo", "Save Depth Texture", @@ -197,7 +197,7 @@ ShadowComponent::ShadowComponent(const ghoul::Dictionary& dictionary) if (_shadowMapDictionary.hasKey(DepthMapSizeInfo.identifier)) { - glm::vec2 depthMapSize = + glm::vec2 depthMapSize = _shadowMapDictionary.value(DepthMapSizeInfo.identifier); _shadowDepthTextureWidth = depthMapSize.x; _shadowDepthTextureHeight = depthMapSize.y; @@ -240,42 +240,42 @@ RenderData ShadowComponent::begin(const RenderData& data) { // =========================================== // Builds light's ModelViewProjectionMatrix: // =========================================== - + glm::dvec3 diffVector = glm::dvec3(_sunPosition) - data.modelTransform.translation; double originalLightDistance = glm::length(diffVector); glm::dvec3 lightDirection = glm::normalize(diffVector); - + // Percentage of the original light source distance (to avoid artifacts) - //double multiplier = originalLightDistance * + //double multiplier = originalLightDistance * // (static_cast(_distanceFraction)/1.0E5); double multiplier = originalLightDistance * (static_cast(_distanceFraction) / 1E17); - + // New light source position - //glm::dvec3 lightPosition = data.modelTransform.translation + + //glm::dvec3 lightPosition = data.modelTransform.translation + // (lightDirection * multiplier); glm::dvec3 lightPosition = data.modelTransform.translation + (diffVector * multiplier); //// Light Position //glm::dvec3 lightPosition = glm::dvec3(_sunPosition); - + //=============== Manually Created Camera Matrix =================== //================================================================== // camera Z glm::dvec3 cameraZ = lightDirection; - + // camera X glm::dvec3 upVector = glm::dvec3(0.0, 1.0, 0.0); - glm::dvec3 cameraX = glm::normalize(glm::cross(upVector, cameraZ)); - + glm::dvec3 cameraX = glm::normalize(glm::cross(upVector, cameraZ)); + // camera Y glm::dvec3 cameraY = glm::cross(cameraZ, cameraX); // init 4x4 matrix glm::dmat4 cameraRotationMatrix(1.0); - + double* matrix = glm::value_ptr(cameraRotationMatrix); matrix[0] = cameraX.x; matrix[4] = cameraX.y; @@ -288,31 +288,31 @@ RenderData ShadowComponent::begin(const RenderData& data) { matrix[10] = cameraZ.z; // set translation part - // We aren't setting the position here because it is set in + // We aren't setting the position here because it is set in // the camera->setPosition() //matrix[12] = -glm::dot(cameraX, lightPosition); //matrix[13] = -glm::dot(cameraY, lightPosition); //matrix[14] = -glm::dot(cameraZ, lightPosition); - + _lightCamera = std::move(std::unique_ptr(new Camera(data.camera))); _lightCamera->setPositionVec3(lightPosition); _lightCamera->setRotation(glm::dquat(glm::inverse(cameraRotationMatrix))); //======================================================================= //======================================================================= - + //============= Light Matrix by Camera Matrices Composition ============= //======================================================================= glm::dmat4 lightProjectionMatrix = glm::dmat4(_lightCamera->projectionMatrix()); - - // The model transformation missing in the final shadow matrix is add when rendering each - // object (using its transformations provided by the RenderData structure) - _shadowData.shadowMatrix = - _toTextureCoordsMatrix * lightProjectionMatrix * + + // The model transformation missing in the final shadow matrix is add when rendering + // each object (using its transformations provided by the RenderData structure) + _shadowData.shadowMatrix = + _toTextureCoordsMatrix * lightProjectionMatrix * _lightCamera->combinedViewMatrix(); - + // Saves current state glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); glGetIntegerv(GL_VIEWPORT, _mViewport); @@ -337,8 +337,7 @@ RenderData ShadowComponent::begin(const RenderData& data) { glEnable(GL_DEPTH_TEST); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - + //glEnable(GL_CULL_FACE); //checkGLError("begin() -- enabled cull face"); //glCullFace(GL_FRONT); @@ -372,7 +371,7 @@ void ShadowComponent::end() { }; glDrawBuffers(3, drawBuffers); glViewport(_mViewport[0], _mViewport[1], _mViewport[2], _mViewport[3]); - + if (_faceCulling) { glEnable(GL_CULL_FACE); glCullFace(_faceToCull); @@ -399,9 +398,9 @@ void ShadowComponent::end() { } glClearColor( - _colorClearValue[0], - _colorClearValue[1], - _colorClearValue[2], + _colorClearValue[0], + _colorClearValue[1], + _colorClearValue[2], _colorClearValue[3] ); glClearDepth(_depthClearValue); @@ -433,14 +432,14 @@ void ShadowComponent::end() { glBindVertexArray(_quadVAO); glDrawArrays(GL_TRIANGLES, 0, 6); - + _renderDMProgram->deactivate(); } } void ShadowComponent::update(const UpdateData&) { _sunPosition = global::renderEngine.scene()->sceneGraphNode("Sun")->worldPosition(); - + glm::ivec2 renderingResolution = global::renderEngine.renderingResolution(); if (_dynamicDepthTextureRes && ((_shadowDepthTextureWidth != renderingResolution.x) || (_shadowDepthTextureHeight != renderingResolution.y))) @@ -454,7 +453,7 @@ void ShadowComponent::update(const UpdateData&) { void ShadowComponent::createDepthTexture() { glGenTextures(1, &_shadowDepthTexture); updateDepthTexture(); - + _shadowData.shadowDepthTexture = _shadowDepthTexture; //_shadowData.positionInLightSpaceTexture = _positionInLightSpaceTexture; } @@ -462,13 +461,13 @@ void ShadowComponent::createDepthTexture() { void ShadowComponent::createShadowFBO() { // Saves current FBO first glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); - + glGenFramebuffers(1, &_shadowFBO); glBindFramebuffer(GL_FRAMEBUFFER, _shadowFBO); glFramebufferTexture( - GL_FRAMEBUFFER, - GL_DEPTH_ATTACHMENT, - _shadowDepthTexture, + GL_FRAMEBUFFER, + GL_DEPTH_ATTACHMENT, + _shadowDepthTexture, 0 ); @@ -478,7 +477,7 @@ void ShadowComponent::createShadowFBO() { // _positionInLightSpaceTexture, // 0 //); - + //GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_NONE, GL_NONE }; GLenum drawBuffers[] = { GL_NONE, GL_NONE, GL_NONE }; glDrawBuffers(3, drawBuffers); @@ -561,7 +560,7 @@ void ShadowComponent::saveDepthBuffer() { if (ppmFile.is_open()) { ppmFile << "P3" << std::endl; - ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight + ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight << std::endl; ppmFile << "255" << std::endl; @@ -601,7 +600,7 @@ void ShadowComponent::saveDepthBuffer() { if (ppmFile.is_open()) { ppmFile << "P3" << std::endl; - ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight + ppmFile << _shadowDepthTextureWidth << " " << _shadowDepthTextureHeight << std::endl; ppmFile << "255" << std::endl; diff --git a/modules/globebrowsing/src/shadowcomponent.h b/modules/globebrowsing/src/shadowcomponent.h index 180b9aeccd..3c39293697 100644 --- a/modules/globebrowsing/src/shadowcomponent.h +++ b/modules/globebrowsing/src/shadowcomponent.h @@ -70,7 +70,7 @@ public: RenderData begin(const RenderData& data); void end(); void update(const UpdateData& data); - + static documentation::Documentation Documentation(); bool isEnabled() const; @@ -101,13 +101,13 @@ private: properties::TriggerProperty _saveDepthTexture; properties::IntProperty _distanceFraction; properties::BoolProperty _enabled; - + ghoul::Dictionary _shadowMapDictionary; - + int _shadowDepthTextureHeight = 4096; int _shadowDepthTextureWidth = 4096; bool _dynamicDepthTextureRes = true; - + GLuint _shadowDepthTexture = 0; GLuint _positionInLightSpaceTexture = 0; GLuint _shadowFBO = 0; diff --git a/modules/globebrowsing/src/timequantizer.h b/modules/globebrowsing/src/timequantizer.h index f8907e3359..19decc6fa9 100644 --- a/modules/globebrowsing/src/timequantizer.h +++ b/modules/globebrowsing/src/timequantizer.h @@ -65,7 +65,7 @@ public: * * \param checkTime An ISO8601 date/time string to clamp if falls outside of range * - * \returns clamped value of input parameter, will be equal to the start value if + * \returns clamped value of input parameter, will be equal to the start value if * less than start, equal to end if greater than end, or equal to input * parameter if falls in-between */ @@ -227,7 +227,7 @@ public: /* * Increment operation for the date/time - * + * * \param value integer value for number of units in an operation * \param unit single char that specifies the unit of increment. Allowable units are: * (y)ear, (M)onth, (d)ay, (h)our, (m)inute, (s)econd @@ -254,7 +254,7 @@ public: * \returns The number of decrements that were performed in order to get as close as * possible to the target, where each decrement is defined by the value & * unit (and approximated but not fixed by the resolution param) - */ + */ int decrement(int value, char unit, double error, double resolution); /* diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 95abd7c4ab..47974dfe50 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -87,7 +87,7 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { for (const std::string& key : interfaces.keys()) { ghoul::Dictionary interfaceDictionary = interfaces.value(key); - // @TODO (abock, 2019-09-17); This is a hack to make the parsing of the + // @TODO (abock, 2019-09-17); This is a hack to make the parsing of the // openspace.cfg file not corrupt the heap and cause a potential crash at shutdown // (see ticket https://github.com/OpenSpace/OpenSpace/issues/982) // The AllowAddresses are specified externally and are injected here diff --git a/modules/server/src/topics/flightcontrollertopic.cpp b/modules/server/src/topics/flightcontrollertopic.cpp index aedb5f3367..963a2b95bc 100644 --- a/modules/server/src/topics/flightcontrollertopic.cpp +++ b/modules/server/src/topics/flightcontrollertopic.cpp @@ -89,7 +89,8 @@ namespace { // Friction JSON Keys constexpr const char* FrictionEngagedKey = "engaged"; - constexpr const char* FrictionPropertyUri = "NavigationHandler.OrbitalNavigator.Friction"; + constexpr const char* FrictionPropertyUri = + "NavigationHandler.OrbitalNavigator.Friction"; constexpr const char* FrictionRotationKey = "rotation"; constexpr const char* FrictionZoomKey = "zoom"; constexpr const char* FrictionRollKey = "roll"; @@ -179,7 +180,9 @@ bool FlightControllerTopic::isDone() const { void FlightControllerTopic::handleJson(const nlohmann::json& json) { auto it = CommandMap.find(json[TypeKey]); if (it == CommandMap.end()) { - LWARNING(fmt::format("Poorly formatted JSON command: no '{}' in payload", TypeKey)); + LWARNING( + fmt::format("Poorly formatted JSON command: no '{}' in payload", TypeKey) + ); return; } @@ -290,10 +293,12 @@ void FlightControllerTopic::updateView(const nlohmann::json& json) const { void FlightControllerTopic::changeFocus(const nlohmann::json& json) const { if (json[FocusKey].find(SceneNodeName) == json[FocusKey].end()) { const std::string j = json; - LWARNING(fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j)); + LWARNING( + fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j) + ); return; } - + const std::string focus = json[FocusKey][SceneNodeName]; const SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(focus); if (node) { @@ -308,7 +313,9 @@ void FlightControllerTopic::changeFocus(const nlohmann::json& json) const { void FlightControllerTopic::setRenderableEnabled(const nlohmann::json& json) const { if (json[RenderableKey].find(SceneNodeName) == json[RenderableKey].end()) { const std::string j = json; - LWARNING(fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j)); + LWARNING( + fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j) + ); return; } @@ -426,7 +433,7 @@ void FlightControllerTopic::processInputState(const nlohmann::json& json) { _inputState.axes[std::distance(AxisIndexMap.begin(), mapIt)] = float(it.value()); } } - + void FlightControllerTopic::processLua(const nlohmann::json &json) { const std::string script = json[LuaScript]; global::scriptEngine.queueScript( @@ -434,5 +441,5 @@ void FlightControllerTopic::processLua(const nlohmann::json &json) { openspace::scripting::ScriptEngine::RemoteScripting::Yes ); } - + } // namespace openspace diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index c2225d1f8d..9d45571345 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include namespace { constexpr const char* ProgramName = "OrbitalKepler"; @@ -434,7 +434,7 @@ void RenderableOrbitalKepler::initializeGL() { ); } ); - + _uniformCache.modelView = _programObject->uniformLocation("modelViewTransform"); _uniformCache.projection = _programObject->uniformLocation("projectionTransform"); _uniformCache.lineFade = _programObject->uniformLocation("lineFade"); @@ -444,7 +444,7 @@ void RenderableOrbitalKepler::initializeGL() { updateBuffers(); } - + void RenderableOrbitalKepler::deinitializeGL() { glDeleteBuffers(1, &_vertexBuffer); glDeleteVertexArrays(1, &_vertexArray); @@ -535,7 +535,7 @@ void RenderableOrbitalKepler::updateBuffers() { ); for (size_t j = 0 ; j < (_segmentSize[orbitIdx] + 1); ++j) { - double timeOffset = orbit.period * + double timeOffset = orbit.period * static_cast(j)/ static_cast(_segmentSize[orbitIdx]); glm::dvec3 position = _keplerTranslator.position({ @@ -563,7 +563,7 @@ void RenderableOrbitalKepler::updateBuffers() { GL_ARRAY_BUFFER, _vertexBufferData.size() * sizeof(TrailVBOLayout), _vertexBufferData.data(), - GL_STATIC_DRAW + GL_STATIC_DRAW ); glEnableVertexAttribArray(0); @@ -581,5 +581,5 @@ void RenderableOrbitalKepler::updateBuffers() { glBindVertexArray(0); } - + } // namespace opensapce diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index ab0279a99e..420b93b5b6 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -42,7 +42,7 @@ #include #include #include -#include +#include namespace { constexpr const char* ProgramName = "RenderableSatellites"; @@ -121,9 +121,8 @@ documentation::Documentation RenderableSatellites::Documentation() { RenderableSatellites::RenderableSatellites(const ghoul::Dictionary& dictionary) : RenderableOrbitalKepler(dictionary) -{ -} - +{} + void RenderableSatellites::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { throw ghoul::RuntimeError(fmt::format( @@ -137,8 +136,11 @@ void RenderableSatellites::readDataFile(const std::string& filename) { file.exceptions(std::ifstream::failbit | std::ifstream::badbit); file.open(filename); - std::streamoff numberOfLines = std::count(std::istreambuf_iterator(file), - std::istreambuf_iterator(), '\n' ); + std::streamoff numberOfLines = std::count( + std::istreambuf_iterator(file), + std::istreambuf_iterator(), + '\n' + ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file _numObjects = numberOfLines / nLineEntriesPerSatellite; diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 07666e32c2..8ba63ed855 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include namespace { constexpr const char* ProgramName = "RenderableSmallBody"; @@ -140,8 +140,8 @@ RenderableSmallBody::RenderableSmallBody(const ghoul::Dictionary& dictionary) { _upperLimitCallbackHandle = _upperLimit.onChange(_reinitializeTrailBuffers); addProperty(_upperLimit); -} - +} + void RenderableSmallBody::readDataFile(const std::string& filename) { if (!FileSys.fileExists(filename)) { throw ghoul::RuntimeError(fmt::format( @@ -154,7 +154,7 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { file.open(filename); std::streamoff numberOfLines = std::count( - std::istreambuf_iterator(file), + std::istreambuf_iterator(file), std::istreambuf_iterator(), '\n' ); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 377f8c77bd..2778673233 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -1026,8 +1026,6 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) { _program->setUniform(_uniformCache.alphaValue, _alphaValue); } - - ghoul::opengl::TextureUnit psfUnit; psfUnit.activate(); @@ -1479,7 +1477,7 @@ void RenderableStars::readSpeckFile() { for (int i = 0; i < _nValuesPerStar; ++i) { str >> values[i]; } - + bool nullArray = true; for (float v : values) { if (v != 0.0) { diff --git a/modules/space/tasks/generatedebrisvolumetask.cpp b/modules/space/tasks/generatedebrisvolumetask.cpp index d7bf763a45..3946f9ccc2 100644 --- a/modules/space/tasks/generatedebrisvolumetask.cpp +++ b/modules/space/tasks/generatedebrisvolumetask.cpp @@ -44,7 +44,6 @@ namespace { - constexpr const char* ProgramName = "RenderableSatellites"; constexpr const char* _loggerCat = "SpaceDebris"; @@ -62,13 +61,11 @@ namespace { // constexpr const char* KeyInputPath3 = "InputPath3"; // constexpr const char* KeyInputPath4 = "InputPath4"; - constexpr const char* KeyLowerDomainBound = "LowerDomainBound"; - constexpr const char* KeyUpperDomainBound = "UpperDomainBound"; + constexpr const char* KeyUpperDomainBound = "UpperDomainBound"; +} // namespace -} - -namespace openspace{ +namespace openspace { namespace volume { // The list of leap years only goes until 2056 as we need to touch this file then // again anyway ;) @@ -263,14 +260,14 @@ double epochFromSubstring(const std::string& epochString) { std::vector readTLEFile(const std::string& filename){ ghoul_assert(FileSys.fileExists(filename), "The filename must exist"); - + std::vector data; std::ifstream file; file.exceptions(std::ifstream::failbit | std::ifstream::badbit); file.open(filename); - int numberOfLines = std::count(std::istreambuf_iterator(file), + int numberOfLines = std::count(std::istreambuf_iterator(file), std::istreambuf_iterator(), '\n' ); file.seekg(std::ios_base::beg); // reset iterator to beginning of file @@ -281,7 +278,7 @@ std::vector readTLEFile(const std::string& filename){ for (int i = 0; i < numberOfObjects; i++) { std::getline(file, line); // get rid of title - + KeplerParameters keplerElements; std::getline(file, line); @@ -379,21 +376,19 @@ std::vector readTLEFile(const std::string& filename){ glm::dvec3 cartesianToSphericalCoord(glm::dvec3 position){ glm::dvec3 sphericalPosition; - //sphericalPosition.x = pow(pow(position.x,2)+pow(position.y,2)+pow(position.z,2) , 0.5); //abs(position.x + position.y + position.z); // r - //sphericalPosition.y = atan(position.y/position.x); // theta - //sphericalPosition.z = atan(pow(pow(position.x,2)+pow(position.y,2),0.5)/position.z); // abs(position.x + position.y) // p - - sphericalPosition.x = sqrt(pow(position.x,2)+pow(position.y,2)+pow(position.z,2)); // r [0, MaxApogee] - sphericalPosition.y = acos(position.z/sphericalPosition.x); // theta [0, pi] - sphericalPosition.z = atan2(position.y,position.x); // phi [-pi, pi] -> [0, 2*pi] - // if(sphericalPosition.y < 0) - sphericalPosition.z += 3.14159265358979323846264338327950288; + // r [0, MaxApogee] + sphericalPosition.x = sqrt(pow(position.x,2)+pow(position.y,2)+pow(position.z,2)); + // theta [0, pi] + sphericalPosition.y = acos(position.z/sphericalPosition.x); + // phi [-pi, pi] -> [0, 2*pi] + sphericalPosition.z = atan2(position.y,position.x); + sphericalPosition.z += glm::pi(); return sphericalPosition; } - -std::vector getPositionBuffer(std::vector tleData, double timeInSeconds, std::string gridType) { - +std::vector getPositionBuffer(std::vector tleData, + double timeInSeconds, std::string gridType) +{ float minTheta = 0.0; float minPhi = 0.0; float maxTheta = 0.0; @@ -437,14 +432,14 @@ std::vector getPositionBuffer(std::vector tleData, } // LINFO(fmt::format("pos: {} ", sphPos)); positionBuffer.push_back(sphPos); - + } else { positionBuffer.push_back(position); } - - + + } LINFO(fmt::format("max theta: {} ", maxTheta)); LINFO(fmt::format("max phi: {} ", maxPhi)); @@ -456,7 +451,7 @@ std::vector getPositionBuffer(std::vector tleData, // std::vector generatePositions(int numberOfPositions) { // std::vector positions; - + // float radius = 700000; // meter // float degreeStep = 360 / numberOfPositions; @@ -483,7 +478,7 @@ float getMaxApogee(std::vector inData){ double ah = dataElement.semiMajorAxis * (1 + dataElement.eccentricity); if (ah > maxApogee) maxApogee = ah; - } + } return static_cast(maxApogee*1000); // * 1000 for meters } @@ -501,7 +496,7 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s ,static_cast(newPosition.y * dim.y / (2 * (maxApogee + epsilon))) ,static_cast(newPosition.z * dim.z / (2 * (maxApogee + epsilon)))); - + return coordinateIndex.z * (dim.x * dim.y) + coordinateIndex.y * dim.x + coordinateIndex.x; } else if(gridType == "Spherical"){ @@ -517,7 +512,7 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s ,static_cast(position.y * dim.y / (3.14159265358979323846264338327950288)) ,static_cast(position.z * dim.z / (2*3.14159265358979323846264338327950288))); - + // LINFO(fmt::format("index coords: {} ", coordinateIndex)); // LINFO(fmt::format("index dim: {} ", dim)); // LINFO(fmt::format("index va: {} ", coordinateIndex.y * (dim.x * dim.y) + coordinateIndex.z * dim.x + coordinateIndex.x)); @@ -529,7 +524,7 @@ int getIndexFromPosition(glm::dvec3 position, glm::uvec3 dim, float maxApogee, s } double getVoxelVolume(int index, RawVolume& raw, glm::uvec3 dim, float maxApogee){ - // get coords from index + // get coords from index glm::uvec3 coords = raw.indexToCoords(index); double rMax = maxApogee / dim.x; @@ -585,10 +580,9 @@ GenerateDebrisVolumeTask::GenerateDebrisVolumeTask(const ghoul::Dictionary& dict _gridType = dictionary.value(KeyGridType); _lowerDomainBound = dictionary.value(KeyLowerDomainBound); _upperDomainBound = dictionary.value(KeyUpperDomainBound); - + _TLEDataVector = readTLEFile(_inputPath); _maxApogee = getMaxApogee(_TLEDataVector); - } std::string GenerateDebrisVolumeTask::description() { @@ -603,7 +597,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal SpiceManager::ref().unloadKernel(kernel); }; - ////////// + ////////// //1. read TLE-data and position of debris elements. // std::vectorTLEDataVector = readTLEFile(_inputPath); // std::vectorTLEDataVector1 = readTLEFile(_inputPath1); @@ -620,7 +614,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal // ----- or ----- if only one // _TLEDataVector = readTLEFile(_inputPath); - + ////////// VolumeGridType GridType = VolumeGridType::Cartesian; if(_gridType == "Spherical"){ @@ -637,7 +631,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal /** SEQUENCE * 1. handle timeStep * 1.1 either ignore last timeperiod from the latest whole timestep to _endTime - * 1.2 or extend endTime to be equal to next full timestep + * 1.2 or extend endTime to be equal to next full timestep * 2. loop to create a rawVolume for each timestep. */ @@ -659,7 +653,7 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal // 2. for(int i=0 ; i<=numberOfIterations ; ++i) { - std::vector startPositionBuffer = getPositionBuffer(_TLEDataVector, startTimeInSeconds+(i*timeStep), _gridType); //+(i*timeStep) + std::vector startPositionBuffer = getPositionBuffer(_TLEDataVector, startTimeInSeconds+(i*timeStep), _gridType); //+(i*timeStep) //LINFO(fmt::format("pos: {} ", startPositionBuffer[4])); double *densityArrayp = new double[size](); @@ -678,16 +672,16 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal densityArrayp = mapDensityToVoxels(densityArrayp, testBuffer, _dimensions, _maxApogee, _gridType); */ // create object rawVolume - + //glm::vec3 domainSize = _upperDomainBound - _lowerDomainBound; - + // TODO: Create a forEachSatallite and set(cell, value) to combine mapDensityToVoxel // and forEachVoxel for less time complexity. rawVolume.forEachVoxel([&](glm::uvec3 cell, float) { // glm::vec3 coord = _lowerDomainBound + // glm::vec3(cell) / glm::vec3(_dimensions) * domainSize; float value = getDensityAt(cell, densityArrayp, rawVolume); // (coord) - + rawVolume.set(cell, value); minVal = std::min(minVal, value); @@ -705,22 +699,22 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal size_t lastIndex = _rawVolumeOutputPath.find_last_of("."); std::string rawOutputName = _rawVolumeOutputPath.substr(0, lastIndex); - rawOutputName += std::to_string(i) + ".rawvolume"; + rawOutputName += std::to_string(i) + ".rawvolume"; lastIndex = _dictionaryOutputPath.find_last_of("."); std::string dictionaryOutputName = _dictionaryOutputPath.substr(0, lastIndex); - dictionaryOutputName += std::to_string(i) + ".dictionary"; + dictionaryOutputName += std::to_string(i) + ".dictionary"; ghoul::filesystem::File file(rawOutputName); const std::string directory = file.directoryName(); if (!FileSys.directoryExists(directory)) { FileSys.createDirectory(directory, ghoul::filesystem::FileSystem::Recursive::Yes); } - + volume::RawVolumeWriter writer(rawOutputName); writer.write(rawVolumeQueue.front()); rawVolumeQueue.pop(); - + RawVolumeMetadata metadata; // alternatively metadata.hasTime = false; metadata.time = Time::convertTime(_startTime)+(i*timeStep); @@ -745,7 +739,6 @@ void GenerateDebrisVolumeTask::perform(const Task::ProgressCallback& progressCal std::fstream f(dictionaryOutputName, std::ios::out); f << "return " << metadataString; f.close(); - } } diff --git a/modules/space/tasks/generatedebrisvolumetask.h b/modules/space/tasks/generatedebrisvolumetask.h index 887f75be60..1a0225b4f2 100644 --- a/modules/space/tasks/generatedebrisvolumetask.h +++ b/modules/space/tasks/generatedebrisvolumetask.h @@ -59,7 +59,7 @@ private: std::string _timeStep; std::string _endTime; std::string _inputPath; - + glm::uvec3 _dimensions; glm::vec3 _lowerDomainBound; glm::vec3 _upperDomainBound; diff --git a/modules/space/translation/keplertranslation.h b/modules/space/translation/keplertranslation.h index 83c8fd6233..0370822e9e 100644 --- a/modules/space/translation/keplertranslation.h +++ b/modules/space/translation/keplertranslation.h @@ -78,7 +78,7 @@ public: * be passed to the constructor */ static documentation::Documentation Documentation(); - + /** * Sets the internal values for the Keplerian elements and the epoch as a string of * the form YYYY MM DD HH:mm:ss. @@ -120,7 +120,7 @@ public: void setKeplerElements(double eccentricity, double semiMajorAxis, double inclination, double ascendingNode, double argumentOfPeriapsis, double meanAnomalyAtEpoch, double orbitalPeriod, double epoch); - + /// Default construct that initializes all the properties and member variables KeplerTranslation(); diff --git a/modules/spacecraftinstruments/util/projectioncomponent.cpp b/modules/spacecraftinstruments/util/projectioncomponent.cpp index 704b361b6b..847a45523c 100644 --- a/modules/spacecraftinstruments/util/projectioncomponent.cpp +++ b/modules/spacecraftinstruments/util/projectioncomponent.cpp @@ -69,7 +69,8 @@ namespace { constexpr const char* sequenceTypePlaybook = "playbook"; constexpr const char* sequenceTypeHybrid = "hybrid"; constexpr const char* sequenceTypeInstrumentTimes = "instrument-times"; - constexpr const char* sequenceTypeImageAndInstrumentTimes = "image-and-instrument-times"; + constexpr const char* sequenceTypeImageAndInstrumentTimes = + "image-and-instrument-times"; constexpr const char* placeholderFile = "${DATA}/placeholder.png"; @@ -381,7 +382,9 @@ void ProjectionComponent::initialize(const std::string& identifier, ) ); - std::string timesSequenceSource = absPath(dictionary.value(keyTimesSequenceDir)); + std::string timesSequenceSource = absPath( + dictionary.value(keyTimesSequenceDir) + ); ghoul::Dictionary timesTranslationDictionary; dictionary.getValue(keyTimesTranslation, timesTranslationDictionary); diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 71deff0318..2c7ba9a106 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -680,7 +680,8 @@ int TouchInteraction::interpretInteraction(const std::vector& double res = 0.0; float lastAngle = lastPoint.angleToPos(_centroid.x, _centroid.y); - float currentAngle = inputHolder.latestInput().angleToPos(_centroid.x, _centroid.y); + float currentAngle = + inputHolder.latestInput().angleToPos(_centroid.x, _centroid.y); if (lastAngle > currentAngle + 1.5 * glm::pi()) { res = currentAngle + (2.0 * glm::pi() - lastAngle); } @@ -820,9 +821,7 @@ void TouchInteraction::computeVelocities(const std::vector& li #endif _constTimeDecayCoeff.zoom = 1.0; - _vel.zoom = zoomFactor * - _pinchZoomFactor * - _zoomSensitivityProportionalDist * + _vel.zoom = zoomFactor * _pinchZoomFactor * _zoomSensitivityProportionalDist * std::max(_touchScreenSize.value() * 0.1, 1.0); break; } @@ -1033,7 +1032,7 @@ void TouchInteraction::step(double dt, bool directTouch) { centerToActualSurfaceModelSpace; const double nodeRadius = length(centerToActualSurface); - // Because of heightmaps we should make sure we do not go through the surface + // Because of heightmaps we need to ensure we don't go through the surface if (_zoomInLimit.value() < nodeRadius) { #ifdef TOUCH_DEBUG_PROPERTIES LINFO(fmt::format("{}: Zoom In limit should be larger than anchor " @@ -1058,9 +1057,9 @@ void TouchInteraction::step(double dt, bool directTouch) { const double distanceFromSurface = length(currentPosDistance) - anchor->boundingSphere(); if (distanceFromSurface > 0.1) { - const double ratioOfDistanceToNodeVsSurface = + const double ratioOfDistanceToNodeVsSurf = length(currentPosDistance) / distanceFromSurface; - if (ratioOfDistanceToNodeVsSurface > _zoomSensitivityDistanceThreshold) { + if (ratioOfDistanceToNodeVsSurf > _zoomSensitivityDistanceThreshold) { zoomVelocity *= pow( std::abs(distanceFromSurface), static_cast(_zoomSensitivityExponential) @@ -1072,8 +1071,8 @@ void TouchInteraction::step(double dt, bool directTouch) { } } - const glm::dvec3 zoomDistanceIncrement = directionToCenter * zoomVelocity * dt; - const double newPosDistance = length(centerToCamera + zoomDistanceIncrement); + const glm::dvec3 zoomDistanceInc = directionToCenter * zoomVelocity * dt; + const double newPosDistance = length(centerToCamera + zoomDistanceInc); // Possible with other navigations performed outside touch interaction const bool currentPosViolatingZoomOutLimit = @@ -1182,7 +1181,7 @@ void TouchInteraction::resetAfterInput() { _lastVel.zoom = 0.0; _lastVel.roll = 0.0; _lastVel.pan = glm::dvec2(0.0); - + _constTimeDecayCoeff.zoom = computeConstTimeDecayCoefficient(_vel.zoom); _pinchInputs[0].clearInputs(); _pinchInputs[1].clearInputs(); diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 1118094768..b10b50ca32 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -91,9 +91,9 @@ LRESULT CALLBACK HookCallback(int nCode, WPARAM wParam, LPARAM lParam) { //Implementation from microsoft STL of high_resolution_clock(steady_clock): const long long freq = gFrequency; const long long whole = (info.PerformanceCount / freq) * std::micro::den; - const long long part = (info.PerformanceCount % freq) * + const long long part = (info.PerformanceCount % freq) * std::micro::den / freq; - const std::chrono::microseconds timestamp = + const std::chrono::microseconds timestamp = std::chrono::duration(whole + part) - gStartTime; RECT rect; diff --git a/modules/toyvolume/rendering/renderabletoyvolume.cpp b/modules/toyvolume/rendering/renderabletoyvolume.cpp index ab642b0a13..46dc7ffca8 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.cpp +++ b/modules/toyvolume/rendering/renderabletoyvolume.cpp @@ -69,7 +69,8 @@ namespace { "" // @TODO Missing documentation }; - constexpr openspace::properties::Property::PropertyInfo DownscaleVolumeRenderingInfo = { + constexpr openspace::properties::Property::PropertyInfo DownscaleVolumeRenderingInfo = + { "Downscale", "Downscale Factor Volume Rendering", "This value set the downscaling factor" diff --git a/modules/vislab/rendering/renderabledistancelabel.cpp b/modules/vislab/rendering/renderabledistancelabel.cpp index eac120946d..db6d3c0cef 100644 --- a/modules/vislab/rendering/renderabledistancelabel.cpp +++ b/modules/vislab/rendering/renderabledistancelabel.cpp @@ -53,8 +53,8 @@ namespace { constexpr openspace::properties::Property::PropertyInfo CustomUnitDescriptorInfo = { "CustomUnitDescriptor", "Custom Unit Descriptor", - "Property to define a custom unit descriptor to use to describe the distance value." - "Defaults to the units SI descriptor if not specified." + "Property to define a custom unit descriptor to use to describe the distance " + "value. Defaults to the units SI descriptor if not specified." }; } @@ -111,7 +111,8 @@ RenderableDistanceLabel::RenderableDistanceLabel(const ghoul::Dictionary& dictio addProperty(_distanceUnit); } if (dictionary.hasKey(CustomUnitDescriptorInfo.identifier)) { - _customUnitDescriptor = dictionary.value(CustomUnitDescriptorInfo.identifier); + _customUnitDescriptor = + dictionary.value(CustomUnitDescriptorInfo.identifier); addProperty(_customUnitDescriptor); } } @@ -144,7 +145,9 @@ void RenderableDistanceLabel::update(const UpdateData&) { } // Get distance as string and remove fractional part - std::string distanceText = std::to_string(std::round(nodeline->distance() / scale)); + std::string distanceText = std::to_string( + std::round(nodeline->distance() / scale) + ); int pos = static_cast(distanceText.find(".")); std::string subStr = distanceText.substr(pos); distanceText.erase(pos, subStr.size()); diff --git a/modules/webbrowser/include/eventhandler.h b/modules/webbrowser/include/eventhandler.h index e08f2fbfc7..870eb49a47 100644 --- a/modules/webbrowser/include/eventhandler.h +++ b/modules/webbrowser/include/eventhandler.h @@ -87,7 +87,7 @@ private: #ifdef WIN32 /** * Build a CEF touch event based on our internal structure - * + * * Note: as of 02/21/2020 we are using an older version of CEF on OSX * than WIN32. * This version does not handle the CefTouchEvent type and does diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index b7f4d55c96..6d9645b9a0 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -475,9 +475,9 @@ CefTouchEvent EventHandler::touchEvent(const TouchInput& input, event.x = windowPos.x; event.y = windowPos.y; event.type = eventType; - const std::vector> &keyModVec = + const std::vector>& keyModVec = global::navigationHandler.inputState().pressedKeys(); - for (auto keyModPair : keyModVec) { + for (const std::pair& keyModPair : keyModVec) { const KeyModifier mods = keyModVec[0].second; event.modifiers |= static_cast(mapToCefModifiers(mods)); } diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index 936b7c4672..6f75683ccb 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -188,8 +188,8 @@ std::shared_ptr DownloadManager::downloadFile( &progressCb }; #if LIBCURL_VERSION_NUM >= 0x072000 - // xferinfo was introduced in 7.32.0, if a lower curl version is used the progress - // will not be shown for downloads on the splash screen + // xferinfo was introduced in 7.32.0, if a lower curl version is used the + // progress will not be shown for downloads on the splash screen curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, xferinfo); // NOLINT curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &p); // NOLINT #endif diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index efcd4bace1..9f5e005b6e 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -145,16 +145,18 @@ namespace { constexpr openspace::properties::Property::PropertyInfo ApplyLinearFlightInfo = { "ApplyLinearFlight", "Apply Linear Flight", - "This property makes the camera move to the specified distance 'FlightDestinationDistance' while facing the anchor" + "This property makes the camera move to the specified distance " + "'FlightDestinationDistance' while facing the anchor" }; - constexpr openspace::properties::Property::PropertyInfo FlightDestinationDistanceInfo = { + constexpr openspace::properties::Property::PropertyInfo FlightDestinationDistInfo = { "FlightDestinationDistance", "Flight Destination Distance", "The final distance we want to fly to, with regards to the anchor node." }; - constexpr openspace::properties::Property::PropertyInfo FlightDestinationFactorInfo = { + constexpr openspace::properties::Property::PropertyInfo FlightDestinationFactorInfo = + { "FlightDestinationFactor", "Flight Destination Factor", "The minimal distance factor that we need to reach to end linear flight." @@ -236,7 +238,7 @@ OrbitalNavigator::OrbitalNavigator() , _minimumAllowedDistance(MinimumDistanceInfo, 10.0f, 0.0f, 10000.f) , _velocitySensitivity(VelocityZoomControlInfo, 0.02f, 0.01f, 0.15f) , _applyLinearFlight(ApplyLinearFlightInfo, false) - , _flightDestinationDistance(FlightDestinationDistanceInfo, 2e8f, 0.0f, 1e10f) + , _flightDestinationDistance(FlightDestinationDistInfo, 2e8f, 0.0f, 1e10f) , _flightDestinationFactor(FlightDestinationFactorInfo, 1E-4, 1E-6, 0.5) , _mouseSensitivity(MouseSensitivityInfo, 15.0f, 1.0f, 50.f) , _joystickSensitivity(JoystickSensitivityInfo, 10.0f, 1.0f, 50.f) @@ -442,16 +444,17 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) { if (_applyLinearFlight) { // Calculate a position handle based on the camera position in world space glm::dvec3 camPosToAnchorPosDiff = prevCameraPosition - anchorPos; - // Use the boundingsphere to get an approximate distance to the surface of the node + // Use the boundingsphere to get an approximate distance to the node surface double nodeRadius = static_cast(_anchorNode->boundingSphere()); - double distFromCameraToFocus = glm::distance(prevCameraPosition, anchorPos) - nodeRadius; + double distFromCameraToFocus = + glm::distance(prevCameraPosition, anchorPos) - nodeRadius; // Make the approximation delta size depending on the flight distance - double arrivalThreshold = _flightDestinationDistance.value() * _flightDestinationFactor; - - // Fly towards the flight destination distance. When getting closer than arrivalThreshold terminate the flight - if (abs(distFromCameraToFocus - _flightDestinationDistance.value()) > arrivalThreshold) { + double arrivalThreshold = _flightDestinationDistance * _flightDestinationFactor; + // Fly towards the flight destination distance. When getting closer than + // arrivalThreshold terminate the flight + if (abs(distFromCameraToFocus - _flightDestinationDistance) > arrivalThreshold) { pose.position = moveCameraAlongVector( pose.position, distFromCameraToFocus, @@ -460,7 +463,7 @@ void OrbitalNavigator::updateCameraStateFromStates(double deltaTime) { ); } else { - _applyLinearFlight.setValue(false); + _applyLinearFlight = false; } } diff --git a/src/interaction/websocketcamerastates.cpp b/src/interaction/websocketcamerastates.cpp index d3769213bc..9fefc15d02 100644 --- a/src/interaction/websocketcamerastates.cpp +++ b/src/interaction/websocketcamerastates.cpp @@ -32,12 +32,13 @@ namespace openspace::interaction { -WebsocketCameraStates::WebsocketCameraStates(double sensitivity, double velocityScaleFactor) +WebsocketCameraStates::WebsocketCameraStates(double sensitivity, + double velocityScaleFactor) : CameraInteractionStates(sensitivity, velocityScaleFactor) {} void WebsocketCameraStates::updateStateFromInput(const InputState& inputState, - double deltaTime) + double deltaTime) { std::pair globalRotation = { false, glm::dvec2(0.0) }; std::pair zoom = { false, 0.0 }; @@ -115,7 +116,7 @@ void WebsocketCameraStates::updateStateFromInput(const InputState& inputState, } } } - + if (globalRotation.first) { _globalRotationState.velocity.set(globalRotation.second, deltaTime); } @@ -164,7 +165,8 @@ void WebsocketCameraStates::setAxisMapping(int axis, AxisType mapping, _axisMapping[axis].normalize = shouldNormalize; } -WebsocketCameraStates::AxisInformation WebsocketCameraStates::axisMapping(int axis) const { +WebsocketCameraStates::AxisInformation WebsocketCameraStates::axisMapping(int axis) const +{ return _axisMapping[axis]; } diff --git a/src/interaction/websocketinputstate.cpp b/src/interaction/websocketinputstate.cpp index 3f6851d33a..9ccccf12cb 100644 --- a/src/interaction/websocketinputstate.cpp +++ b/src/interaction/websocketinputstate.cpp @@ -39,7 +39,9 @@ float WebsocketInputStates::axis(int axis) const { begin(), end(), 0.f, - [axis](float value, const std::pair state) { + [axis](float value, + const std::pair state) + { if (state.second->isConnected) { value += state.second->axes[axis]; } @@ -58,9 +60,10 @@ bool WebsocketInputStates::button(int button, WebsocketAction action) const { bool res = std::any_of( begin(), end(), - [button, action](const std::pair state) { + [button, action](const std::pair state) + { return state.second->isConnected ? - ( state.second->buttons[button] == action ) + (state.second->buttons[button] == action) : false; } ); diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 5a3ff016cd..c5280097ad 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -76,7 +76,7 @@ namespace { constexpr const std::array HDRUniformNames = { - "hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma", + "hdrFeedingTexture", "blackoutFactor", "hdrExposure", "gamma", "Hue", "Saturation", "Value" }; @@ -456,8 +456,8 @@ void FramebufferRenderer::initialize() { glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); ghoul::opengl::updateUniformLocations( - *_hdrFilteringProgram, - _hdrUniformCache, + *_hdrFilteringProgram, + _hdrUniformCache, HDRUniformNames ); ghoul::opengl::updateUniformLocations( @@ -525,7 +525,7 @@ void FramebufferRenderer::deferredcastersChanged(Deferredcaster&, void FramebufferRenderer::applyTMO(float blackoutFactor) { const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); std::unique_ptr perfInternal; - + if (doPerformanceMeasurements) { perfInternal = std::make_unique( "FramebufferRenderer::render::TMO" @@ -536,7 +536,7 @@ void FramebufferRenderer::applyTMO(float blackoutFactor) { ghoul::opengl::TextureUnit hdrFeedingTextureUnit; hdrFeedingTextureUnit.activate(); glBindTexture(GL_TEXTURE_2D, _pingPongBuffers.colorTexture[_pingPongIndex]); - + _hdrFilteringProgram->setUniform( _hdrUniformCache.hdrFeedingTexture, hdrFeedingTextureUnit @@ -683,7 +683,7 @@ void FramebufferRenderer::writeDownscaledVolume() { _writeDownscaledVolumeUniformCache.downscaledRenderedVolume, downscaledTextureUnit ); - + ghoul::opengl::TextureUnit downscaledDepthUnit; downscaledDepthUnit.activate(); glBindTexture( @@ -1160,7 +1160,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glEnable(GL_DEPTH_TEST); } _pingPongIndex = 0; - + // Measurements cache variable const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); @@ -1173,7 +1173,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac if (!scene || !camera) { return; - } + } { // deferred g-buffer @@ -1236,7 +1236,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac GLDebugGroup group("Deferred Caster Tasks"); // We use ping pong rendering in order to be able to - // render to the same final buffer, multiple + // render to the same final buffer, multiple // deferred tasks at same time (e.g. more than 1 ATM being seen at once) glBindFramebuffer(GL_FRAMEBUFFER, _pingPongBuffers.framebuffer); glDrawBuffers(1, &ColorAttachment01Array[_pingPongIndex]); @@ -1263,7 +1263,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac // Disabling depth test for filtering and hdr glDisable(GL_DEPTH_TEST); - + glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); if (_enableFXAA) { @@ -1277,7 +1277,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac // by the Operating System. Also, the resolve procedure is executed in this step. glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); } - + { // Apply the selected TMO on the results and resolve the result to the default FBO GLDebugGroup group("Apply TMO"); @@ -1290,7 +1290,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glBindFramebuffer(GL_FRAMEBUFFER, _defaultFBO); applyFXAA(); } - } void FramebufferRenderer::performRaycasterTasks(const std::vector& tasks) { @@ -1312,11 +1311,11 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector } if (raycaster->downscaleRender() < 1.f) { - float scaleDown = raycaster->downscaleRender(); glBindFramebuffer(GL_FRAMEBUFFER, _downscaleVolumeRendering.framebuffer); - glViewport(viewport[0], viewport[1], viewport[2] * scaleDown, viewport[3] * scaleDown); - if (_downscaleVolumeRendering.currentDownscaleFactor != scaleDown) { - _downscaleVolumeRendering.currentDownscaleFactor = scaleDown; + const float s = raycaster->downscaleRender(); + glViewport(viewport[0], viewport[1], viewport[2] * s, viewport[3] * s); + if (_downscaleVolumeRendering.currentDownscaleFactor != s) { + _downscaleVolumeRendering.currentDownscaleFactor = s; updateDownscaleTextures(); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -1357,7 +1356,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector if (raycastProgram) { raycastProgram->setUniform("rayCastSteps", raycaster->maxSteps()); - + raycaster->preRaycast(_raycastData[raycaster], *raycastProgram); ghoul::opengl::TextureUnit exitColorTextureUnit; @@ -1383,7 +1382,10 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector ); } else { - raycastProgram->setUniform("windowSize", static_cast(_resolution)); + raycastProgram->setUniform( + "windowSize", + static_cast(_resolution) + ); } glDisable(GL_DEPTH_TEST); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 99d6637790..c6b06dfde5 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -319,14 +319,13 @@ RenderEngine::RenderEngine() }); addProperty(_disableHDRPipeline); - _hdrExposure.onChange([this]() { if (_renderer) { _renderer->setHDRExposure(_hdrExposure); } }); addProperty(_hdrExposure); - + _gamma.onChange([this]() { if (_renderer) { _renderer->setGamma(_gamma); @@ -342,7 +341,7 @@ RenderEngine::RenderEngine() }); addProperty(_hue); - + _saturation.onChange([this]() { if (_renderer) { _renderer->setSaturation(_saturation); @@ -350,7 +349,7 @@ RenderEngine::RenderEngine() }); addProperty(_saturation); - + _value.onChange([this]() { if (_renderer) { _renderer->setValue(_value); diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index 1f5574816f..59334604ef 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -346,7 +346,7 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) { if (global::callback::webBrowserPerformanceHotfix) { (*global::callback::webBrowserPerformanceHotfix)(); } - + { ZoneScopedN("Get Error Hack") diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 1e00beee8c..37aa928996 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -643,7 +643,9 @@ int addInterestingTime(lua_State* L) { std::string time = ghoul::lua::value(L, 2, ghoul::lua::PopValue::No); lua_pop(L, 2); - global::renderEngine.scene()->addInterestingTime({ std::move(name), std::move(time) }); + global::renderEngine.scene()->addInterestingTime( + { std::move(name), std::move(time) } + ); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 5177ea9c69..aa1239cefd 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -707,7 +707,7 @@ void SceneGraphNode::computeScreenSpaceData(RenderData& newData) { } glm::ivec2 res = global::windowDelegate.currentSubwindowSize(); - + // Get the radius of node double nodeRadius = static_cast(this->boundingSphere()); diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 4ffce5c454..562d8c9600 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -417,7 +417,10 @@ int saveLastChangeToProfile(lua_State* L) { printInternal(ghoul::logging::LogLevel::Error, L); } if (!fileout) { - ghoul::lua::push(L, fmt::format("Could not open tmp profile '{}'", tempAssetPath)); + ghoul::lua::push( + L, + fmt::format("Could not open tmp profile '{}'", tempAssetPath) + ); printInternal(ghoul::logging::LogLevel::Error, L); } From 5a94c486f05a95048c352e558c7efcb4aefdebe3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 14 Apr 2020 22:32:26 +0200 Subject: [PATCH 56/67] Removing warnings --- ext/ghoul | 2 +- modules/base/rendering/renderablelabels.cpp | 17 ++++---- modules/base/rendering/renderablenodeline.cpp | 12 +++--- .../base/rendering/renderabletrailorbit.cpp | 2 +- .../rendering/renderabletrailtrajectory.cpp | 2 +- modules/galaxy/rendering/renderablegalaxy.cpp | 10 ++--- modules/globebrowsing/globebrowsingmodule.cpp | 3 +- .../globebrowsing/src/rawtiledatareader.cpp | 3 +- modules/globebrowsing/src/shadowcomponent.cpp | 4 +- modules/globebrowsing/src/timequantizer.cpp | 2 +- .../src/topics/flightcontrollertopic.cpp | 6 +-- .../rendering/renderableorbitalkepler.cpp | 16 ++++---- .../space/rendering/renderablesatellites.cpp | 6 +-- .../space/rendering/renderablesmallbody.cpp | 15 ++++--- modules/touch/src/touchinteraction.cpp | 6 +-- modules/touch/src/win32_touch.cpp | 2 +- modules/webbrowser/src/eventhandler.cpp | 2 +- src/interaction/scriptcamerastates.cpp | 5 +-- src/rendering/framebufferrenderer.cpp | 41 ++++++++++++++----- src/util/syncbuffer.cpp | 5 ++- 20 files changed, 93 insertions(+), 68 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 9e6f9abe90..df1522a1fe 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 9e6f9abe90b90157c52c6182b390a619062835b9 +Subproject commit df1522a1fe6f02b4d03cd36478d9d36f4384e93e diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp index f83752a8c1..e44e49fb17 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabels.cpp @@ -636,9 +636,8 @@ void RenderableLabels::render(const RenderData& data, RendererTasks&) { float fadeInVariable = 1.f; if (_enableFadingEffect) { - float distanceNodeToCamera = glm::distance( - data.camera.positionVec3(), - data.modelTransform.translation + float distanceNodeToCamera = static_cast( + glm::distance(data.camera.positionVec3(), data.modelTransform.translation) ); float sUnit = unit(_fadeStartUnitOption); float eUnit = unit(_fadeEndUnitOption); @@ -743,6 +742,7 @@ float RenderableLabels::changedPerlinSmoothStepFunc(float x, float startX, else if (x >= endX) { return std::clamp(f2, 0.f, 1.f); } + return x; } float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX, @@ -763,17 +763,18 @@ float RenderableLabels::linearSmoothStepFunc(float x, float startX, float endX, else if (x >= endX) { return std::clamp(f2, 0.f, 1.f); } + return x; } float RenderableLabels::unit(int unit) const { switch (static_cast(unit)) { case Meter: return 1.f; - case Kilometer: return 1e3; - case Megameter: return 1e6; - case Gigameter: return 1e9; + case Kilometer: return 1e3f; + case Megameter: return 1e6f; + case Gigameter: return 1e9f; case AU: return 149597870700.f; - case Terameter: return 1e12; - case Petameter: return 1e15; + case Terameter: return 1e12f; + case Petameter: return 1e15f; case Parsec: return static_cast(PARSEC); case Kiloparsec: return static_cast(1e3 * PARSEC); case Megaparsec: return static_cast(1e6 * PARSEC); diff --git a/modules/base/rendering/renderablenodeline.cpp b/modules/base/rendering/renderablenodeline.cpp index fdf2acf398..7fc1f26068 100644 --- a/modules/base/rendering/renderablenodeline.cpp +++ b/modules/base/rendering/renderablenodeline.cpp @@ -240,13 +240,13 @@ void RenderableNodeLine::updateVertexData() { global::renderEngine.scene()->sceneGraphNode(_end)->worldPosition() ); - _vertexArray.push_back(_startPos.x); - _vertexArray.push_back(_startPos.y); - _vertexArray.push_back(_startPos.z); + _vertexArray.push_back(static_cast(_startPos.x)); + _vertexArray.push_back(static_cast(_startPos.y)); + _vertexArray.push_back(static_cast(_startPos.z)); - _vertexArray.push_back(_endPos.x); - _vertexArray.push_back(_endPos.y); - _vertexArray.push_back(_endPos.z); + _vertexArray.push_back(static_cast(_endPos.x)); + _vertexArray.push_back(static_cast(_endPos.y)); + _vertexArray.push_back(static_cast(_endPos.z)); _vertexArray; diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index db57d56381..9d58c6dc72 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -373,7 +373,7 @@ void RenderableTrailOrbit::update(const UpdateData& data) { std::for_each(_vertexArray.begin(), _vertexArray.end(), setMax); - setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.0); + setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.f); } RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index e8dae4adc8..966ffd51af 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -350,7 +350,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) { std::for_each(_vertexArray.begin(), _vertexArray.end(), setMax); - setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.0); + setBoundingSphere(glm::distance(maxVertex, minVertex) / 2.f); } diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index c71403dc76..ba5a801649 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -463,9 +463,9 @@ void RenderableGalaxy::initializeGL() { } else { FileSys.cacheManager()->removeCacheFile(_pointsFilename); - Result res = loadPointFile(_pointsFilename); - pointPositions = std::move(res.positions); - pointColors = std::move(res.color); + Result resPoint = loadPointFile(_pointsFilename); + pointPositions = std::move(resPoint.positions); + pointColors = std::move(resPoint.color); saveCachedFile( cachedPointsFile, pointPositions, @@ -561,7 +561,7 @@ void RenderableGalaxy::update(const UpdateData& data) { _pointTransform[3] += translation; _raycaster->setDownscaleRender(_downScaleVolumeRendering); - _raycaster->setMaxSteps(_numberOfRayCastingSteps); + _raycaster->setMaxSteps(static_cast(_numberOfRayCastingSteps)); _raycaster->setStepSize(_stepSize); _raycaster->setAspect(_aspect); _raycaster->setModelTransform(volumeTransform); @@ -798,7 +798,7 @@ float RenderableGalaxy::safeLength(const glm::vec3& vector) const { return glm::length(vector / maxComponent) * maxComponent; } -RenderableGalaxy::Result RenderableGalaxy::loadPointFile(const std::string& file) { +RenderableGalaxy::Result RenderableGalaxy::loadPointFile(const std::string&) { std::vector pointPositions; std::vector pointColors; int64_t nPoints; diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 4eb99dd7da..b7cea3cb2d 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -626,8 +626,7 @@ void GlobeBrowsingModule::goToGeodetic2(const globebrowsing::RenderableGlobe& gl } void GlobeBrowsingModule::goToGeodetic3(const globebrowsing::RenderableGlobe& globe, - globebrowsing::Geodetic3 geo3, - bool doResetCameraDirection) + globebrowsing::Geodetic3 geo3, bool) { using namespace globebrowsing; const glm::dvec3 positionModelSpace = globe.ellipsoid().cartesianPosition(geo3); diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index 6cc980e36d..a602008e1a 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -394,7 +394,8 @@ PixelRegion highestResPixelRegion(const GeodeticPatch& geodeticPatch, return region; } -RawTile::ReadError postProcessErrorCheck(const RawTile& rawTile, size_t nRasters, +RawTile::ReadError postProcessErrorCheck(const RawTile& rawTile, + [[ maybe_unused ]] size_t nRasters, float noDataValue) { // This check was implicit before and just made explicit here diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index 2ab97a86fc..0662c50566 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -199,8 +199,8 @@ ShadowComponent::ShadowComponent(const ghoul::Dictionary& dictionary) if (_shadowMapDictionary.hasKey(DepthMapSizeInfo.identifier)) { glm::vec2 depthMapSize = _shadowMapDictionary.value(DepthMapSizeInfo.identifier); - _shadowDepthTextureWidth = depthMapSize.x; - _shadowDepthTextureHeight = depthMapSize.y; + _shadowDepthTextureWidth = static_cast(depthMapSize.x); + _shadowDepthTextureHeight = static_cast(depthMapSize.y); _dynamicDepthTextureRes = false; } else { diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 68de65ac1f..67f7288d62 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -540,7 +540,7 @@ void TimeQuantizer::doFirstApproximation(DateTime& quantized, DateTime& unQ, static_cast(_start.year()); minIncrementsAdjust = minYearsToAdjust / value; quantized.setYear( - _start.year() + static_cast(minIncrementsAdjust) * value + _start.year() + static_cast(minIncrementsAdjust * value) ); break; case 'M': diff --git a/modules/server/src/topics/flightcontrollertopic.cpp b/modules/server/src/topics/flightcontrollertopic.cpp index 963a2b95bc..6d8dc96573 100644 --- a/modules/server/src/topics/flightcontrollertopic.cpp +++ b/modules/server/src/topics/flightcontrollertopic.cpp @@ -216,7 +216,7 @@ void FlightControllerTopic::handleJson(const nlohmann::json& json) { void FlightControllerTopic::connect() { _isDone = false; - std::fill(_inputState.axes.begin(), _inputState.axes.end(), 0); + std::fill(_inputState.axes.begin(), _inputState.axes.end(), 0.f); _payload[TypeKey] = Connect; setFocusNodes(); setInterestingTimes(); @@ -376,7 +376,7 @@ void FlightControllerTopic::engageAutopilot(const nlohmann::json &json) { setFriction(false); auto input = json[AutopilotInputKey][ValuesKey]; - std::fill(_inputState.axes.begin(), _inputState.axes.end(), 0); + std::fill(_inputState.axes.begin(), _inputState.axes.end(), 0.f); _inputState.isConnected = true; for (auto it = input.begin(); it != input.end(); ++it) { @@ -413,7 +413,7 @@ void FlightControllerTopic::handleAutopilot(const nlohmann::json &json) { } void FlightControllerTopic::processInputState(const nlohmann::json& json) { - std::fill(_inputState.axes.begin(), _inputState.axes.end(), 0); + std::fill(_inputState.axes.begin(), _inputState.axes.end(), 0.f); _inputState.isConnected = true; // Get "inputState" object from "payload" diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 9d45571345..06e3cebcb7 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -69,7 +69,7 @@ namespace { } }; - constexpr const LeapSecond Epoch = { 2000, 1 }; + constexpr const LeapSecond LeapEpoch = { 2000, 1 }; // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list constexpr const std::array LeapSeconds = { @@ -194,7 +194,7 @@ namespace { const auto y2000 = std::lower_bound( LeapSeconds.begin(), LeapSeconds.end(), - Epoch + LeapEpoch ); // The distance between the two iterators gives us the number of leap years @@ -387,15 +387,15 @@ RenderableOrbitalKepler::RenderableOrbitalKepler(const ghoul::Dictionary& dict) _upperLimit = dict.hasKeyAndValue(UpperLimitInfo.identifier) ? static_cast(dict.value(UpperLimitInfo.identifier)) : - 0.f; + 0u; _startRenderIdx = dict.hasKeyAndValue(StartRenderIdxInfo.identifier) ? static_cast(dict.value(StartRenderIdxInfo.identifier)) : - 0; + 0u; _sizeRender = dict.hasKeyAndValue(RenderSizeInfo.identifier) ? static_cast(dict.value(RenderSizeInfo.identifier)) : - 0; + 0u; _appearance.lineWidth = dict.hasKeyAndValue(LineWidthInfo.identifier) ? static_cast(dict.value(LineWidthInfo.identifier)) : @@ -500,8 +500,8 @@ void RenderableOrbitalKepler::render(const RenderData& data, RendererTasks&) { glBindVertexArray(_vertexArray); for (size_t i = 0; i < nrOrbits; ++i) { - glDrawArrays(GL_LINE_STRIP, vertices, _segmentSize[i] + 1); - vertices = vertices + _segmentSize[i] + 1; + glDrawArrays(GL_LINE_STRIP, vertices, static_cast(_segmentSize[i] + 1)); + vertices = vertices + static_cast(_segmentSize[i]) + 1; } glBindVertexArray(0); @@ -513,7 +513,7 @@ void RenderableOrbitalKepler::updateBuffers() { size_t nVerticesTotal = 0; - int numOrbits = _data.size(); + int numOrbits = static_cast(_data.size()); for (size_t i = 0; i < numOrbits; ++i) { nVerticesTotal += _segmentSize[i] + 1; } diff --git a/modules/space/rendering/renderablesatellites.cpp b/modules/space/rendering/renderablesatellites.cpp index 420b93b5b6..f3c667a197 100644 --- a/modules/space/rendering/renderablesatellites.cpp +++ b/modules/space/rendering/renderablesatellites.cpp @@ -152,7 +152,7 @@ void RenderableSatellites::readDataFile(const std::string& filename) { std::string line = "-"; std::string name; - unsigned int endElement = _startRenderIdx + _sizeRender - 1; + long long endElement = _startRenderIdx + _sizeRender - 1; endElement = (endElement >= _numObjects) ? _numObjects - 1 : endElement; //Burn lines if not starting at first element for (unsigned int k = 0; k < _startRenderIdx; ++k) { @@ -265,8 +265,8 @@ void RenderableSatellites::readDataFile(const std::string& filename) { void RenderableSatellites::initializeFileReading() { _startRenderIdx.removeOnChange(_startRenderIdxCallbackHandle); _sizeRender.removeOnChange(_sizeRenderCallbackHandle); - _startRenderIdx.setMaxValue(_numObjects - 1); - _sizeRender.setMaxValue(_numObjects); + _startRenderIdx.setMaxValue(static_cast(_numObjects - 1)); + _sizeRender.setMaxValue(static_cast(_numObjects)); _startRenderIdx = static_cast(0); _sizeRender = static_cast(_numObjects); _startRenderIdxCallbackHandle = _startRenderIdx.onChange( diff --git a/modules/space/rendering/renderablesmallbody.cpp b/modules/space/rendering/renderablesmallbody.cpp index 8ba63ed855..39dd624e98 100644 --- a/modules/space/rendering/renderablesmallbody.cpp +++ b/modules/space/rendering/renderablesmallbody.cpp @@ -202,7 +202,10 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { unsigned int sequentialLineErrors = 0; unsigned int endElement = _startRenderIdx + _sizeRender - 1; - endElement = (endElement >= _numObjects) ? _numObjects - 1 : endElement; + endElement = + (endElement >= _numObjects) ? + static_cast(_numObjects - 1) : + endElement; // Burn lines if not starting at first element for (unsigned int k = 0; k < _startRenderIdx; ++k) { skipSingleLineInFile(file); @@ -269,8 +272,8 @@ void RenderableSmallBody::readDataFile(const std::string& filename) { void RenderableSmallBody::initializeFileReading() { _startRenderIdx.removeOnChange(_startRenderIdxCallbackHandle); _sizeRender.removeOnChange(_sizeRenderCallbackHandle); - _startRenderIdx.setMaxValue(_numObjects - 1); - _sizeRender.setMaxValue(_numObjects); + _startRenderIdx.setMaxValue(static_cast(_numObjects - 1)); + _sizeRender.setMaxValue(static_cast(_numObjects)); _startRenderIdx = static_cast(0); _sizeRender = static_cast(_numObjects); _startRenderIdxCallbackHandle = _startRenderIdx.onChange(_updateStartRenderIdxSelect); @@ -278,7 +281,7 @@ void RenderableSmallBody::initializeFileReading() { // If a limit wasn't specified in dictionary, set it to # lines in file // minus the header line (but temporarily disable callback to avoid 2nd call) _upperLimit.removeOnChange(_upperLimitCallbackHandle); - _upperLimit.setMaxValue(_numObjects); + _upperLimit.setMaxValue(static_cast(_numObjects)); _upperLimit = static_cast(_numObjects); _upperLimitCallbackHandle = _upperLimit.onChange(_reinitializeTrailBuffers); } @@ -390,7 +393,9 @@ void RenderableSmallBody::readOrbitalParamsFromThisLine(bool firstDataLine, _data.push_back(keplerElements); _sbNames.push_back(name); const double scale = static_cast(_segmentQuality) * 10.0; - _segmentSize.push_back(scale + (scale / pow(1 - keplerElements.eccentricity, 1.2))); + _segmentSize.push_back( + static_cast(scale + (scale / pow(1 - keplerElements.eccentricity, 1.2))) + ); } static double importAngleValue(const std::string& angle) { diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 2c7ba9a106..c31ac046ea 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -1082,13 +1082,13 @@ void TouchInteraction::step(double dt, bool directTouch) { bool willNewPositionViolateZoomInLimit = (newPosDistance < zoomInBounds); bool willNewPositionViolateDirection = - (currentPosDistance <= length(zoomDistanceIncrement)); + (currentPosDistance <= length(zoomDistanceInc)); if (!willNewPositionViolateZoomInLimit && !willNewPositionViolateDirection && !willNewPositionViolateZoomOutLimit) { - camPos += zoomDistanceIncrement; + camPos += zoomDistanceInc; } else if (currentPosViolatingZoomOutLimit) { #ifdef TOUCH_DEBUG_PROPERTIES @@ -1098,7 +1098,7 @@ void TouchInteraction::step(double dt, bool directTouch) { #endif // Only allow zooming in if you are outside the zoom out limit if (newPosDistance < currentPosDistance) { - camPos += zoomDistanceIncrement; + camPos += zoomDistanceInc; } } else { diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index b10b50ca32..10f517ae69 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -297,7 +297,7 @@ LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam) { } LPMSLLHOOKSTRUCT msg = reinterpret_cast(lParam); // block injected events (in most cases generated by touches) - bool isFromTouch = (msg->dwExtraInfo || SIGNATURE_MASK) == MOUSEEVENTF_FROMTOUCH; + bool isFromTouch = (msg->dwExtraInfo | SIGNATURE_MASK) == MOUSEEVENTF_FROMTOUCH; if (msg->flags & LLMHF_INJECTED || isFromTouch) { return 1; } diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index 6d9645b9a0..9607457a30 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -478,7 +478,7 @@ CefTouchEvent EventHandler::touchEvent(const TouchInput& input, const std::vector>& keyModVec = global::navigationHandler.inputState().pressedKeys(); for (const std::pair& keyModPair : keyModVec) { - const KeyModifier mods = keyModVec[0].second; + const KeyModifier mods = keyModPair.second; event.modifiers |= static_cast(mapToCefModifiers(mods)); } event.pointer_type = cef_pointer_type_t::CEF_POINTER_TYPE_TOUCH; diff --git a/src/interaction/scriptcamerastates.cpp b/src/interaction/scriptcamerastates.cpp index c68212177e..e9e01b81dc 100644 --- a/src/interaction/scriptcamerastates.cpp +++ b/src/interaction/scriptcamerastates.cpp @@ -35,9 +35,7 @@ namespace openspace::interaction { ScriptCameraStates::ScriptCameraStates() : CameraInteractionStates(1.0, 1.0) {} -void ScriptCameraStates::updateStateFromInput(const InputState& inputState, - double deltaTime) -{ +void ScriptCameraStates::updateStateFromInput(const InputState&, double deltaTime) { if (_localRotation != glm::dvec2(0.0)) { _localRotationState.velocity.set( _localRotation * _sensitivity, @@ -114,5 +112,4 @@ void ScriptCameraStates::addGlobalRoll(const glm::dvec2& delta) { _globalRoll += delta; } - } // namespace openspace::interaction diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index c5280097ad..cec4b87e92 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -61,7 +61,7 @@ namespace { glPushDebugGroup( GL_DEBUG_SOURCE_APPLICATION, 0, - name.length(), + static_cast(name.length()), name.data() ); } @@ -608,8 +608,12 @@ void FramebufferRenderer::updateDownscaleTextures() { GL_TEXTURE_2D, 0, GL_RGBA32F, - _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor, - _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor, + static_cast( + _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor + ), + static_cast( + _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor + ), 0, GL_RGBA, GL_FLOAT, @@ -625,8 +629,12 @@ void FramebufferRenderer::updateDownscaleTextures() { GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, - _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor, - _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor, + static_cast( + _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor + ), + static_cast( + _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor + ), 0, GL_DEPTH_COMPONENT, GL_FLOAT, @@ -928,8 +936,12 @@ void FramebufferRenderer::updateResolution() { GL_TEXTURE_2D, 0, GL_RGBA32F, - _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor, - _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor, + static_cast( + _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor + ), + static_cast( + _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor + ), 0, GL_RGBA, GL_FLOAT, @@ -945,8 +957,12 @@ void FramebufferRenderer::updateResolution() { GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, - _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor, - _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor, + static_cast( + _resolution.x * _downscaleVolumeRendering.currentDownscaleFactor + ), + static_cast( + _resolution.y * _downscaleVolumeRendering.currentDownscaleFactor + ), 0, GL_DEPTH_COMPONENT, GL_FLOAT, @@ -1313,7 +1329,12 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector if (raycaster->downscaleRender() < 1.f) { glBindFramebuffer(GL_FRAMEBUFFER, _downscaleVolumeRendering.framebuffer); const float s = raycaster->downscaleRender(); - glViewport(viewport[0], viewport[1], viewport[2] * s, viewport[3] * s); + glViewport( + viewport[0], + viewport[1], + static_cast(viewport[2] * s), + static_cast(viewport[3] * s) + ); if (_downscaleVolumeRendering.currentDownscaleFactor != s) { _downscaleVolumeRendering.currentDownscaleFactor = s; updateDownscaleTextures(); diff --git a/src/util/syncbuffer.cpp b/src/util/syncbuffer.cpp index f52cfa42dc..faa165e0ed 100644 --- a/src/util/syncbuffer.cpp +++ b/src/util/syncbuffer.cpp @@ -39,8 +39,9 @@ SyncBuffer::~SyncBuffer() {} // NOLINT void SyncBuffer::encode(const std::string& s) { ZoneScoped - int32_t anticpatedBufferSize = _encodeOffset + (sizeof(char) * s.size()) - + sizeof(int32_t); + int32_t anticpatedBufferSize = static_cast( + _encodeOffset + (sizeof(char) * s.size()) + sizeof(int32_t) + ); if (anticpatedBufferSize >= _n) { _dataStream.resize(anticpatedBufferSize); } From 0125fb7a3be4d6e6529781522f5d9e9a826241fb Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 17 Apr 2020 14:01:00 +0200 Subject: [PATCH 57/67] Add some of the additional GitHub files --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 2 +- .github/ISSUE_TEMPLATE.md | 7 +++++++ ACKNOWLEDGMENTS.md | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (75%) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 ACKNOWLEDGMENTS.md diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 75% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md index b025b07993..2366bc69ea 100644 --- a/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,4 +1,4 @@ ## How to contribute The easiest way to contribute is through a separate fork of the repository and submitting a pull-request. One of the core developers will judge the pull request and integrate it into the main `master` branch. Preferably, there is an accompanying issue (created by you or not) which is solved by the PR. In this case, feel free to use the phrase "(closes #XXX)" in the text of the pull request, where `XXX` is the number of the issue that you have solved. The PR should be in its own separate branch following the naming `pr/feature`, where `feature` is a short, descripting name of the additional feature or bug contained in the PR. -For more information we refer to the [Wiki](https://github.com/OpenSpace/OpenSpace/wiki). If there are any questions, feel free to contact us via [email](mailto:alexander.bock@me.com?subject=OpenSpace: Contributing). \ No newline at end of file +For more information we refer to the [Wiki](https://openspace.github.io). If there are any questions, feel free to contact us via [email](mailto:mail@alexanderbock.eu?subject=OpenSpace: Contributing). \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..6a26096403 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,7 @@ +<< Description of the problem >> + +<< What did you expect to happen >> +<< What did happen? >> + + +<< Attach screenshots, if possible >> \ No newline at end of file diff --git a/ACKNOWLEDGMENTS.md b/ACKNOWLEDGMENTS.md new file mode 100644 index 0000000000..a6db596dc7 --- /dev/null +++ b/ACKNOWLEDGMENTS.md @@ -0,0 +1,3 @@ +OpenSpace is funded in part by NASA under award No NNX16AB93A. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Aeronautics and Space Administration. + +OpenSpace is also funded in part by the Knut & Alice Wallenberg Foundation in Sweden and the Swedish e-Science Research Centre. From fbd5d3490acba232e68d02c1ec0da0b2c9eb74b4 Mon Sep 17 00:00:00 2001 From: GPayne Date: Sun, 19 Apr 2020 23:47:30 -0600 Subject: [PATCH 58/67] Leap year time fix for satellite tracking --- .../rendering/renderableorbitalkepler.cpp | 30 ++----------------- modules/space/translation/tletranslation.cpp | 17 +---------- 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 06e3cebcb7..620cce37d8 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -60,7 +60,7 @@ namespace { }; // Find the position of the current year in the vector; its position in -// the vector gives the number of leap seconds + // the vector gives the number of leap seconds struct LeapSecond { int year; int dayOfYear; @@ -246,9 +246,7 @@ double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochStrin // The main overview of this function: // 1. Reconstruct the full year from the YY part - // 2. Calculate the number of seconds since the beginning of the year - // 2.a Get the number of full days since the beginning of the year - // 2.b If the year is a leap year, modify the number of days + // 2. Calculate the number of days since the beginning of the year // 3. Convert the number of days to a number of seconds // 4. Get the number of leap seconds since January 1st, 2000 and remove them // 5. Adjust for the fact the epoch starts on 1st Januaray at 12:00:00, not @@ -267,18 +265,8 @@ double RenderableOrbitalKepler::epochFromSubstring(const std::string& epochStrin const int daysSince2000 = countDays(year); // 2. - // 2.a double daysInYear = std::atof(epochString.substr(2).c_str()); - // 2.b - const bool isInLeapYear = - std::find(LeapYears.begin(), LeapYears.end(), year) != LeapYears.end(); - if (isInLeapYear && daysInYear >= 60) { - // We are in a leap year, so we have an effective day more if we are - // beyond the end of february (= 31+29 days) - --daysInYear; - } - // 3 using namespace std::chrono; const int SecondsPerDay = static_cast(seconds(hours(24)).count()); @@ -309,9 +297,7 @@ double RenderableOrbitalKepler::epochFromYMDdSubstring(const std::string& epochS // The main overview of this function: // 1. Read the year value - // 2. Calculate the number of seconds since the beginning of the year - // 2.a Get the number of full days since the beginning of the year - // 2.b If the year is a leap year, modify the number of days + // 2. Calculate the number of days since the beginning of the year // 3. Convert the number of days to a number of seconds // 4. Get the number of leap seconds since January 1st, 2000 and remove them // 5. Adjust for the fact the epoch starts on 1st January at 12:00:00, not @@ -322,22 +308,12 @@ double RenderableOrbitalKepler::epochFromYMDdSubstring(const std::string& epochS const int daysSince2000 = countDays(year); // 2. - // 2.a int monthNum = std::atoi(epochString.substr(4, 2).c_str()); int dayOfMonthNum = std::atoi(epochString.substr(6, 2).c_str()); int wholeDaysInto = daysIntoGivenYear(monthNum, dayOfMonthNum); double fractionOfDay = std::atof(epochString.substr(9, 7).c_str()); double daysInYear = static_cast(wholeDaysInto) + fractionOfDay; - // 2.b - const bool isInLeapYear = - std::find(LeapYears.begin(), LeapYears.end(), year) != LeapYears.end(); - if (isInLeapYear && daysInYear >= 60) { - // We are in a leap year, so we have an effective day more if we are - // beyond the end of february (= 31+29 days) - --daysInYear; - } - // 3 using namespace std::chrono; const int SecondsPerDay = static_cast(seconds(hours(24)).count()); diff --git a/modules/space/translation/tletranslation.cpp b/modules/space/translation/tletranslation.cpp index ec5fb75137..add42596de 100644 --- a/modules/space/translation/tletranslation.cpp +++ b/modules/space/translation/tletranslation.cpp @@ -145,9 +145,7 @@ namespace { // The main overview of this function: // 1. Reconstruct the full year from the YY part - // 2. Calculate the number of seconds since the beginning of the year - // 2.a Get the number of full days since the beginning of the year - // 2.b If the year is a leap year, modify the number of days + // 2. Calculate the number of days since the beginning of the year // 3. Convert the number of days to a number of seconds // 4. Get the number of leap seconds since January 1st, 2000 and remove them // 5. Adjust for the fact the epoch starts on 1st Januaray at 12:00:00, not @@ -168,21 +166,8 @@ namespace { const int daysSince2000 = countDays(year); // 2. - // 2.a double daysInYear = std::atof(epochString.substr(2).c_str()); - // 2.b - const bool isInLeapYear = std::find( - LeapYears.begin(), - LeapYears.end(), - year - ) != LeapYears.end(); - if (isInLeapYear && daysInYear >= 60) { - // We are in a leap year, so we have an effective day more if we are - // beyond the end of february (= 31+29 days) - --daysInYear; - } - // 3 using namespace std::chrono; const int SecondsPerDay = static_cast(seconds(hours(24)).count()); From fe0cce1e2435f79732fe0aa1c8778991f5758e6a Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 20 Apr 2020 11:23:50 -0600 Subject: [PATCH 59/67] Fix for leap year that can affect asteroids only --- modules/space/rendering/renderableorbitalkepler.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 620cce37d8..f9612d567e 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -202,13 +202,20 @@ namespace { return nLeapSeconds; } - int daysIntoGivenYear(int month, int dayOfMonth) { - //month and dayCount are zero-based. Does NOT account for leap year. + int daysIntoGivenYear(int year, int month, int dayOfMonth) { + //month and dayCount are zero-based. month -= 1; int dayCount = dayOfMonth - 1; + const int February = 1; + const bool isInLeapYear = + std::find(LeapYears.begin(), LeapYears.end(), year) + != LeapYears.end(); for (int m = 0; m < month; ++m) { dayCount += DaysOfMonths[m]; + if (m == February && isInLeapYear) { + dayCount += 1; + } } return dayCount; } @@ -310,7 +317,7 @@ double RenderableOrbitalKepler::epochFromYMDdSubstring(const std::string& epochS // 2. int monthNum = std::atoi(epochString.substr(4, 2).c_str()); int dayOfMonthNum = std::atoi(epochString.substr(6, 2).c_str()); - int wholeDaysInto = daysIntoGivenYear(monthNum, dayOfMonthNum); + int wholeDaysInto = daysIntoGivenYear(year, monthNum, dayOfMonthNum); double fractionOfDay = std::atof(epochString.substr(9, 7).c_str()); double daysInYear = static_cast(wholeDaysInto) + fractionOfDay; From 9ea5c0d66fe87c4ab602ff36db51be5dec219605 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 24 Apr 2020 11:07:18 +0200 Subject: [PATCH 60/67] Update SGCT repository --- apps/OpenSpace/CMakeLists.txt | 1 + apps/OpenSpace/ext/sgct | 2 +- ext/ghoul | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index 12d4c5bd98..1d2ad1b9b9 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -111,6 +111,7 @@ target_compile_definitions(OpenSpace PRIVATE begin_header("Dependency: SGCT") set(SGCT_TEXT OFF CACHE BOOL "" FORCE) +set(SGCT_DEP_INCLUDE_FREETYPE OFF CACHE BOOL "" FORCE) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/sgct) target_include_directories(OpenSpace SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ext/sgct/include) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index addec5d680..72536d99b2 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit addec5d6804ab8df8940f5dc3b3bf81b35216ee5 +Subproject commit 72536d99b2bc463aeeec21c710cf8fd1b7a0a997 diff --git a/ext/ghoul b/ext/ghoul index 11878e0dc0..df1522a1fe 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 11878e0dc08e43ecf4bcf158a6ccc00c6160d3a5 +Subproject commit df1522a1fe6f02b4d03cd36478d9d36f4384e93e From d50dd47c72e8c146ea647bbfee2c5098bd379163 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 24 Apr 2020 11:16:20 +0200 Subject: [PATCH 61/67] Add per-scene cache directories to the gitignore (closes # 1140) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3b19c172e0..c71edd624b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ Thumbs.db # OpenSpace-generated folders and files /bin/ /cache/ +/cache-*/ /cache_gdal/ /documentation/ /logs/ From 0fcd71be71153ca50618459f26a2187bb02168f4 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 27 Apr 2020 15:08:01 +0200 Subject: [PATCH 62/67] Add the ability to invert mouse buttons for OrbitalNavigator (closes #697) --- .../openspace/interaction/mousecamerastates.h | 5 +++++ .../openspace/interaction/orbitalnavigator.h | 2 ++ src/interaction/mousecamerastates.cpp | 19 ++++++++++++++----- src/interaction/orbitalnavigator.cpp | 13 +++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/include/openspace/interaction/mousecamerastates.h b/include/openspace/interaction/mousecamerastates.h index f592dc0ed1..719dcd6926 100644 --- a/include/openspace/interaction/mousecamerastates.h +++ b/include/openspace/interaction/mousecamerastates.h @@ -34,6 +34,11 @@ public: MouseCameraStates(double sensitivity, double velocityScaleFactor); void updateStateFromInput(const InputState& inputState, double deltaTime) override; + + void setInvertMouseButton(bool value); + +private: + bool _isMouseButtonInverted = false; }; } // namespace openspace::interaction diff --git a/include/openspace/interaction/orbitalnavigator.h b/include/openspace/interaction/orbitalnavigator.h index f2ad409223..c453691809 100644 --- a/include/openspace/interaction/orbitalnavigator.h +++ b/include/openspace/interaction/orbitalnavigator.h @@ -160,6 +160,8 @@ private: properties::FloatProperty _stereoInterpolationTime; properties::FloatProperty _followRotationInterpolationTime; + properties::BoolProperty _invertMouseButtons; + MouseCameraStates _mouseStates; JoystickCameraStates _joystickStates; WebsocketCameraStates _websocketStates; diff --git a/src/interaction/mousecamerastates.cpp b/src/interaction/mousecamerastates.cpp index ba897bd1d3..36cc688170 100644 --- a/src/interaction/mousecamerastates.cpp +++ b/src/interaction/mousecamerastates.cpp @@ -40,10 +40,15 @@ MouseCameraStates::MouseCameraStates(double sensitivity, double velocityScaleFac void MouseCameraStates::updateStateFromInput(const InputState& inputState, double deltaTime) { + MouseButton primary = + _isMouseButtonInverted ? MouseButton::Button2 : MouseButton::Button1; + MouseButton secondary = + _isMouseButtonInverted ? MouseButton::Button1 : MouseButton::Button2; + glm::dvec2 mousePosition = inputState.mousePosition(); - bool button1Pressed = inputState.isMouseButtonPressed(MouseButton::Button1); - bool button2Pressed = inputState.isMouseButtonPressed(MouseButton::Button2); + bool primaryPressed = inputState.isMouseButtonPressed(primary); + bool secondaryPressed = inputState.isMouseButtonPressed(secondary); bool button3Pressed = inputState.isMouseButtonPressed(MouseButton::Button3); bool keyCtrlPressed = inputState.isKeyPressed(Key::LeftControl) | inputState.isKeyPressed(Key::RightControl); @@ -53,7 +58,7 @@ void MouseCameraStates::updateStateFromInput(const InputState& inputState, inputState.isKeyPressed(Key::RightAlt); // Update the mouse states - if (button1Pressed && !keyShiftPressed && !keyAltPressed) { + if (primaryPressed && !keyShiftPressed && !keyAltPressed) { if (keyCtrlPressed) { glm::dvec2 mousePositionDelta = _localRotationState.previousPosition - mousePosition; @@ -84,7 +89,7 @@ void MouseCameraStates::updateStateFromInput(const InputState& inputState, _globalRotationState.previousPosition = mousePosition; _globalRotationState.velocity.decelerate(deltaTime); } - if (button2Pressed || (keyAltPressed && button1Pressed)) { + if (secondaryPressed || (keyAltPressed && primaryPressed)) { glm::dvec2 mousePositionDelta = _truckMovementState.previousPosition - mousePosition; @@ -105,7 +110,7 @@ void MouseCameraStates::updateStateFromInput(const InputState& inputState, _truckMovementState.previousPosition = mousePosition; _truckMovementState.velocity.decelerate(deltaTime); } - if (button3Pressed || (keyShiftPressed && button1Pressed)) { + if (button3Pressed || (keyShiftPressed && primaryPressed)) { if (keyCtrlPressed) { glm::dvec2 mousePositionDelta = _localRollState.previousPosition - mousePosition; @@ -138,4 +143,8 @@ void MouseCameraStates::updateStateFromInput(const InputState& inputState, } } +void MouseCameraStates::setInvertMouseButton(bool value) { + _isMouseButtonInverted = value; +} + } // namespace openspace::interaction diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index 9f5e005b6e..2a49c21a82 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -185,6 +185,14 @@ namespace { "The interpolation time when toggling following focus node rotation." }; + constexpr openspace::properties::Property::PropertyInfo InvertMouseButtons = { + "InvertMouseButtons", + "Invert left and right mouse buttons", + "If this value is 'false', the left mouse button causes the camera to rotate " + "around the object and the right mouse button causes the zooming motion. If this " + "value is 'true', these two functionalities are reversed." + }; + constexpr openspace::properties::Property::PropertyInfo UseAdaptiveStereoscopicDepthInfo = { "UseAdaptiveStereoscopicDepth", @@ -249,6 +257,7 @@ OrbitalNavigator::OrbitalNavigator() , _retargetInterpolationTime(RetargetInterpolationTimeInfo, 2.0, 0.0, 10.0) , _stereoInterpolationTime(StereoInterpolationTimeInfo, 8.0, 0.0, 10.0) , _followRotationInterpolationTime(FollowRotationInterpTimeInfo, 1.0, 0.0, 10.0) + , _invertMouseButtons(InvertMouseButtons, false) , _mouseStates(_mouseSensitivity * 0.0001, 1 / (_friction.friction + 0.0000001)) , _joystickStates(_joystickSensitivity * 0.1, 1 / (_friction.friction + 0.0000001)) , _websocketStates(_websocketSensitivity, 1 / (_friction.friction + 0.0000001)) @@ -380,6 +389,10 @@ OrbitalNavigator::OrbitalNavigator() addProperty(_retargetInterpolationTime); addProperty(_stereoInterpolationTime); addProperty(_followRotationInterpolationTime); + _invertMouseButtons.onChange( + [this]() { _mouseStates.setInvertMouseButton(_invertMouseButtons); } + ); + addProperty(_invertMouseButtons); addProperty(_mouseSensitivity); addProperty(_joystickSensitivity); From 3294c53013d4d76b32c37e3a3df91c75abd21c53 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Tue, 28 Apr 2020 08:11:27 -0600 Subject: [PATCH 63/67] Increased starting distance from earth for better content view --- data/assets/asteroids.scene | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/assets/asteroids.scene b/data/assets/asteroids.scene index e68e5a87af..d7c1175baf 100644 --- a/data/assets/asteroids.scene +++ b/data/assets/asteroids.scene @@ -24,7 +24,7 @@ asset.onInitialize(function () -- Jump back one day to be able to show complete weather data on Earth. openspace.time.setTime(openspace.time.advancedTime(now, "-1d")) - openspace.globebrowsing.goToGeo("Earth", 58.5877, 16.1924, 20000000) + openspace.globebrowsing.goToGeo("Earth", 58.5877, 16.1924, 2.7e12) openspace.markInterestingNodes({ "Earth", "Mars", "Moon", "Sun" }) end) From 1b60ab1038b324e2993476cb00444f84c6949e18 Mon Sep 17 00:00:00 2001 From: GPayne Date: Mon, 4 May 2020 15:02:08 -0600 Subject: [PATCH 64/67] Fix for issue #1144 requires satellites vs request --- .../planets/earth/satellites/satellites.asset | 2 +- .../earth/satellites/satellites_interesting.asset | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset index 44c81c4ef8..601b4033f4 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset @@ -1 +1 @@ -asset.request('./satellites_interesting') +asset.require('./satellites_interesting') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset index 7d257cfc8b..71151f4358 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites_interesting.asset @@ -1,6 +1,6 @@ -asset.request('./misc/brightest') -asset.request('./communications/geostationary') -asset.request('./navigation/gps') -asset.request('./misc/spacestations') -asset.request('./misc/iss') -asset.request('./misc/tle-new') +asset.require('./misc/brightest') +asset.require('./communications/geostationary') +asset.require('./navigation/gps') +asset.require('./misc/spacestations') +asset.require('./misc/iss') +asset.require('./misc/tle-new') From 3b427bfd15995de7864efc2e86cc2b2e8f6ef41e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 10 May 2020 15:17:51 +0200 Subject: [PATCH 65/67] Cleaning up window delegate --- apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 80 ---------------------- include/openspace/engine/openspaceengine.h | 2 + include/openspace/engine/windowdelegate.h | 24 +------ modules/imgui/imguimodule.cpp | 23 ++++--- modules/imgui/imguimodule.h | 4 ++ modules/touch/src/win32_touch.cpp | 9 --- src/engine/openspaceengine.cpp | 21 +----- src/engine/openspaceengine_lua.inl | 6 -- 9 files changed, 27 insertions(+), 144 deletions(-) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 72536d99b2..df7c5414cc 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 72536d99b2bc463aeeec21c710cf8fd1b7a0a997 +Subproject commit df7c5414cc97783e0c32c212db746f49a83020a1 diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index de0052caf4..e7f534c60c 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -884,15 +884,6 @@ void setSgctDelegateFunctions() { sgct::ClusterManager::instance().setUseIgnoreSync(enabled); }; - sgctDelegate.clearAllWindows = [](const glm::vec4& clearColor) { - ZoneScoped - - for (const std::unique_ptr& window : Engine::instance().windows()) { - glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glfwSwapBuffers(window->windowHandle()); - } - }; sgctDelegate.windowHasResized = []() { ZoneScoped @@ -925,26 +916,6 @@ void setSgctDelegateFunctions() { return sgct::Engine::getTime(); }; - sgctDelegate.mousePosition = []() { - ZoneScoped - - double xPos; - double yPos; - glfwGetCursorPos(currentWindow->windowHandle(), &xPos, &yPos); - return glm::vec2(xPos, yPos); - }; - sgctDelegate.mouseButtons = [](int maxNumber) { - ZoneScoped - - uint32_t result = 0; - for (int i = 0; i < maxNumber; ++i) { - bool button = (glfwGetMouseButton(currentWindow->windowHandle(), i) != 0); - if (button) { - result |= (1 << i); - } - } - return result; - }; sgctDelegate.currentWindowSize = []() { ZoneScoped @@ -980,12 +951,6 @@ void setSgctDelegateFunctions() { ); } }; - sgctDelegate.currentWindowResolution = []() { - ZoneScoped - - ivec2 dim = currentWindow->finalFBODimensions(); - return glm::ivec2(dim.x, dim.y); - }; sgctDelegate.currentDrawBufferResolution = []() { ZoneScoped @@ -1023,11 +988,6 @@ void setSgctDelegateFunctions() { vec2 scale = currentWindow->scale(); return glm::vec2(scale.x, scale.y); }; - sgctDelegate.currentNumberOfAaSamples = []() { - ZoneScoped - - return currentWindow->numberOfAASamples(); - }; sgctDelegate.hasGuiWindow = []() { ZoneScoped @@ -1048,21 +1008,6 @@ void setSgctDelegateFunctions() { return Engine::instance().isMaster(); }; - sgctDelegate.isUsingSwapGroups = []() { - ZoneScoped - - return Window::isUsingSwapGroups(); - }; - sgctDelegate.isSwapGroupMaster = []() { - ZoneScoped - - return Window::isSwapGroupMaster(); - }; - sgctDelegate.viewProjectionMatrix = []() { - ZoneScoped - - return currentModelViewProjectionMatrix; - }; sgctDelegate.modelMatrix = []() { ZoneScoped @@ -1073,31 +1018,6 @@ void setSgctDelegateFunctions() { Engine::instance().setNearAndFarClippingPlanes(nearPlane, farPlane); }; - sgctDelegate.setEyeSeparationDistance = [](float distance) { - ZoneScoped - - Engine::instance().setEyeSeparation(distance); - }; - //sgctDelegate.viewportPixelCoordinates = []() { - // ZoneScoped - - // if (!currentWindow|| !currentViewport) { - // return glm::ivec4(0); - // } - // else { - // const int* data = cur sgct::Engine::instance()->getCurrentViewportPixelCoords(); - // return glm::ivec4(data[0], data[2], data[1], data[3]); - // } - //}; - //sgctDelegate.sendMessageToExternalControl = [](const std::vector& message) { - // ZoneScoped - - // - // sgct::Engine::instance()->sendMessageToExternalControl( - // message.data(), - // static_cast(message.size()) - // ); - //}; sgctDelegate.isFisheyeRendering = []() { ZoneScoped diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 2e076e82c4..abe5fe8687 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -120,6 +120,8 @@ private: bool _hasScheduledAssetLoading = false; std::string _scheduledAssetPathToLoad; + glm::vec2 _mousePosition; + //grabs json from each module to pass to the documentation engine. std::string _documentationJson; diff --git a/include/openspace/engine/windowdelegate.h b/include/openspace/engine/windowdelegate.h index 4dbbae6d95..0fd27ba589 100644 --- a/include/openspace/engine/windowdelegate.h +++ b/include/openspace/engine/windowdelegate.h @@ -40,8 +40,6 @@ struct WindowDelegate { void (*setSynchronization)(bool enabled) = [](bool) {}; - void (*clearAllWindows)(const glm::vec4& clearColor) = [](const glm::vec4&) {}; - bool (*windowHasResized)() = []() { return false; }; double (*averageDeltaTime)() = []() { return 0.0; }; @@ -56,47 +54,29 @@ struct WindowDelegate { double (*applicationTime)() = []() { return 0.0; }; - glm::vec2 (*mousePosition)() = []() { return glm::vec2(0.f); }; - - uint32_t (*mouseButtons)(int maxNumber) = [](int) { return uint32_t(0); }; - glm::ivec2 (*currentWindowSize)() = []() { return glm::ivec2(0); }; glm::ivec2 (*currentSubwindowSize)() = []() { return glm::ivec2(0); }; - glm::ivec2 (*currentWindowResolution)() = []() { return glm::ivec2(0); }; - glm::ivec2 (*currentDrawBufferResolution)() = []() { return glm::ivec2(0); }; glm::ivec2 (*currentViewportSize)() = []() { return glm::ivec2(0); }; glm::vec2 (*dpiScaling)() = []() { return glm::vec2(1.f); }; - int (*currentNumberOfAaSamples)() = []() { return 1; }; - bool (*hasGuiWindow)() = []() { return false; }; bool (*isGuiWindow)() = []() { return false; }; - bool (*isMaster)() = []() { return false; }; - - int (*clusterId)() = []() { return 0; }; - - bool (*isUsingSwapGroups)() = []() { return false; }; - - bool (*isSwapGroupMaster)() = []() { return false; }; - - glm::mat4 (*viewProjectionMatrix)() = []() { return glm::mat4(1.f); }; + bool (*isMaster)() = []() { return true; }; glm::mat4 (*modelMatrix)() = []() { return glm::mat4(1.f); }; void (*setNearFarClippingPlane)(float near, float far) = [](float, float) {}; - void (*setEyeSeparationDistance)(float distance) = [](float) {}; - bool (*isFisheyeRendering)() = []() { return false; }; - unsigned int(*takeScreenshot)(bool applyWarping) = [](bool) { return 0u; }; + unsigned int (*takeScreenshot)(bool applyWarping) = [](bool) { return 0u; }; void (*swapBuffer)() = []() {}; diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index 9066fe9859..a4a873c267 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -154,9 +154,6 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { global::callback::draw2D.emplace_back([&]() { ZoneScopedN("ImGUI") - // TODO emiax: Make sure this is only called for one of the eyes, in the case - // of side-by-side / top-bottom stereo. - WindowDelegate& delegate = global::windowDelegate; const bool showGui = delegate.hasGuiWindow() ? delegate.isGuiWindow() : true; if (delegate.isMaster() && showGui) { @@ -167,9 +164,6 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { return; } - glm::vec2 mousePosition = delegate.mousePosition(); - uint32_t mouseButtons = delegate.mouseButtons(2); - const double dt = std::max(delegate.averageDeltaTime(), 0.0); // We don't do any collection of immediate mode user interface, so it // is fine to open and close a frame immediately @@ -177,8 +171,8 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { static_cast(dt), glm::vec2(windowSize), resolution / windowSize, - mousePosition, - mouseButtons + _mousePosition, + _mouseButtons ); gui.endFrame(); @@ -217,10 +211,23 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } ); + global::callback::mousePosition.emplace_back( + [&](double x, double y) { + _mousePosition = glm::vec2(static_cast(x), static_cast(y)); + } + ); + global::callback::mouseButton.emplace_back( [&](MouseButton button, MouseAction action, KeyModifier) -> bool { ZoneScopedN("ImGUI") + if (action == MouseAction::Press) { + _mouseButtons |= (1 << static_cast(button)); + } + else if (action == MouseAction::Release) { + _mouseButtons &= ~(1 << static_cast(button)); + } + // A list of all the windows that can show up by themselves if (gui.isEnabled() || gui._performance.isEnabled() || gui._sceneProperty.isEnabled()) diff --git a/modules/imgui/imguimodule.h b/modules/imgui/imguimodule.h index d106967c65..e08556ffa8 100644 --- a/modules/imgui/imguimodule.h +++ b/modules/imgui/imguimodule.h @@ -38,6 +38,10 @@ public: ImGUIModule(); gui::GUI gui; + +private: + glm::vec2 _mousePosition = glm::vec2(0.f); + uint32_t _mouseButtons = 0; }; } // namespace openspace diff --git a/modules/touch/src/win32_touch.cpp b/modules/touch/src/win32_touch.cpp index 10f517ae69..7ac553205b 100644 --- a/modules/touch/src/win32_touch.cpp +++ b/modules/touch/src/win32_touch.cpp @@ -180,15 +180,6 @@ Win32TouchHook::Win32TouchHook(void* nativeWindow) { return; } - // HACK: This hack is required as long as our GLFW version is based on the touch - // branch. There is no convenient way to set a GLFWBool (uint32_t) which sets the - // state of touch-to-mouseinput interpretation. It happens to be 116 bytes into an - // internal glfw struct... - uint32_t* HACKY_PTR = (uint32_t *)GetPropW(hWnd, L"GLFW"); - HACKY_PTR += 116/sizeof(uint32_t); - *HACKY_PTR = 1; - - // Test for touch: int value = GetSystemMetrics(SM_DIGITIZER); if ((value & NID_READY) == 0) { diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index e782b56c8d..979203a8f6 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -420,11 +420,6 @@ void OpenSpaceEngine::initializeGL() { rendering::helper::initialize(); - // clear the screen so the user doesn't have to see old buffer contents left on the - // graphics card - LDEBUG("Clearing all Windows"); - global::windowDelegate.clearAllWindows(glm::vec4(0.f, 0.f, 0.f, 1.f)); - LDEBUG("Adding system components"); // Detect and log OpenCL and OpenGL versions and available devices SysCap.addComponent( @@ -1378,10 +1373,7 @@ void OpenSpaceEngine::mouseButtonCallback(MouseButton button, // Check if the user clicked on one of the 'buttons' the RenderEngine is drawing if (action == MouseAction::Press) { - bool isConsumed = global::renderEngine.mouseActivationCallback( - global::windowDelegate.mousePosition() - ); - + bool isConsumed = global::renderEngine.mouseActivationCallback(_mousePosition); if (isConsumed) { return; } @@ -1401,6 +1393,8 @@ void OpenSpaceEngine::mousePositionCallback(double x, double y) { global::navigationHandler.mousePositionCallback(x, y); global::interactionMonitor.markInteraction(); + + _mousePosition = glm::vec2(static_cast(x), static_cast(y)); } void OpenSpaceEngine::mouseScrollWheelCallback(double posX, double posY) { @@ -1547,15 +1541,6 @@ scripting::LuaLibrary OpenSpaceEngine::luaLibrary() { "Returns whether the current OpenSpace instance is the master node of a " "cluster configuration. If this instance is not part of a cluster, this " "function also returns 'true'." - }, - { - "clusterId", - &luascriptfunctions::clusterId, - {}, - "", - "Returns the zero-based identifier for this OpenSpace instance in a " - "cluster configuration. If this instance is not part of a cluster, this " - "identifier is always 0." } }, { diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index 8980499883..db0a9a70fa 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -272,10 +272,4 @@ int isMaster(lua_State* L) { return 1; } -int clusterId(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clusterId"); - ghoul::lua::push(L, global::windowDelegate.clusterId()); - return 1; -} - } // namespace openspace::luascriptfunctions From f7170a950662fafceebc5399f069598fc8e2cb0f Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 12 May 2020 15:27:24 +0200 Subject: [PATCH 66/67] Turn the scaling transformation into providing three scaling factors (x, y, z) Add NonUniformStaticScale class to provide independent scaling factors (closes #1151) --- include/openspace/scene/scale.h | 6 +- include/openspace/scene/scenegraphnode.h | 8 +- include/openspace/util/updatestructures.h | 2 +- modules/base/CMakeLists.txt | 2 + modules/base/basemodule.cpp | 2 + modules/base/scale/luascale.cpp | 12 ++- modules/base/scale/luascale.h | 2 +- modules/base/scale/nonuniformstaticscale.cpp | 79 +++++++++++++++++++ modules/base/scale/nonuniformstaticscale.h | 50 ++++++++++++ modules/base/scale/staticscale.cpp | 4 +- modules/base/scale/staticscale.h | 2 +- modules/base/scale/timedependentscale.cpp | 6 +- modules/base/scale/timedependentscale.h | 2 +- modules/globebrowsing/src/renderableglobe.cpp | 14 ++-- src/rendering/renderengine.cpp | 2 +- src/scene/scale.cpp | 2 +- src/scene/scenegraphnode.cpp | 17 ++-- 17 files changed, 172 insertions(+), 40 deletions(-) create mode 100644 modules/base/scale/nonuniformstaticscale.cpp create mode 100644 modules/base/scale/nonuniformstaticscale.h diff --git a/include/openspace/scene/scale.h b/include/openspace/scene/scale.h index ee4a113b20..117db6bafd 100644 --- a/include/openspace/scene/scale.h +++ b/include/openspace/scene/scale.h @@ -48,8 +48,8 @@ public: virtual bool initialize(); - double scaleValue() const; - virtual double scaleValue(const UpdateData& data) const = 0; + glm::dvec3 scaleValue() const; + virtual glm::dvec3 scaleValue(const UpdateData& data) const = 0; virtual void update(const UpdateData& data); static documentation::Documentation Documentation(); @@ -60,7 +60,7 @@ protected: private: bool _needsUpdate = true; double _cachedTime = -std::numeric_limits::max(); - double _cachedScale = 1.0; + glm::dvec3 _cachedScale = glm::dvec3(1.0); }; } // namespace openspace diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index ecc42bb9ff..81a3fa92c4 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -122,13 +122,13 @@ public: glm::dvec3 position() const; const glm::dmat3& rotationMatrix() const; - double scale() const; + glm::dvec3 scale() const; glm::dvec3 worldPosition() const; const glm::dmat3& worldRotationMatrix() const; glm::dmat4 modelTransform() const; glm::dmat4 inverseModelTransform() const; - double worldScale() const; + glm::dvec3 worldScale() const; bool isTimeFrameActive(const Time& time) const; SceneGraphNode* parent() const; @@ -152,7 +152,7 @@ public: private: glm::dvec3 calculateWorldPosition() const; glm::dmat3 calculateWorldRotation() const; - double calculateWorldScale() const; + glm::dvec3 calculateWorldScale() const; void computeScreenSpaceData(RenderData& newData); std::atomic _state = State::Loaded; @@ -185,7 +185,7 @@ private: // Cached transform data glm::dvec3 _worldPositionCached = glm::dvec3(0.0); glm::dmat3 _worldRotationCached = glm::dmat3(1.0); - double _worldScaleCached = 1.0; + glm::dvec3 _worldScaleCached = glm::dvec3(1.0); float _fixedBoundingSphere = 0.f; diff --git a/include/openspace/util/updatestructures.h b/include/openspace/util/updatestructures.h index 0e5281554f..3baf2ac3cc 100644 --- a/include/openspace/util/updatestructures.h +++ b/include/openspace/util/updatestructures.h @@ -38,7 +38,7 @@ struct InitializeData {}; struct TransformData { glm::dvec3 translation = glm::dvec3(0.0); glm::dmat3 rotation = glm::dmat3(1.0); - double scale = 0.0; + glm::dvec3 scale = glm::dvec3(1.0); }; struct UpdateData { diff --git a/modules/base/CMakeLists.txt b/modules/base/CMakeLists.txt index 472ed85e74..bf54a33b9d 100644 --- a/modules/base/CMakeLists.txt +++ b/modules/base/CMakeLists.txt @@ -62,6 +62,7 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.h ${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.h ${CMAKE_CURRENT_SOURCE_DIR}/scale/luascale.h + ${CMAKE_CURRENT_SOURCE_DIR}/scale/nonuniformstaticscale.h ${CMAKE_CURRENT_SOURCE_DIR}/scale/staticscale.h ${CMAKE_CURRENT_SOURCE_DIR}/scale/timedependentscale.h ${CMAKE_CURRENT_SOURCE_DIR}/timeframe/timeframeinterval.h @@ -111,6 +112,7 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rotation/luarotation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/scale/luascale.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/scale/nonuniformstaticscale.cpp ${CMAKE_CURRENT_SOURCE_DIR}/scale/staticscale.cpp ${CMAKE_CURRENT_SOURCE_DIR}/scale/timedependentscale.cpp ${CMAKE_CURRENT_SOURCE_DIR}/timeframe/timeframeinterval.cpp diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index cf79f7b00c..4c2e465b80 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -155,6 +156,7 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) { ghoul_assert(fScale, "Scale factory was not created"); fScale->registerClass("LuaScale"); + fScale->registerClass("NonUniformStaticScale"); fScale->registerClass("StaticScale"); fScale->registerClass("TimeDependentScale"); diff --git a/modules/base/scale/luascale.cpp b/modules/base/scale/luascale.cpp index cfd19f9aca..f13b485c9a 100644 --- a/modules/base/scale/luascale.cpp +++ b/modules/base/scale/luascale.cpp @@ -43,7 +43,7 @@ namespace { "scaling factor for this transformation. The script needs to define a function " "'scale' that takes the current simulation time in seconds past the J2000 epoch " "as the first argument, the current wall time as milliseconds past the J2000 " - "epoch the second argument and computes the scaling factor." + "epoch the second argument and computes the three scaling factors." }; } // namespace @@ -86,7 +86,7 @@ LuaScale::LuaScale(const ghoul::Dictionary& dictionary) : LuaScale() { _luaScriptFile = absPath(dictionary.value(ScriptInfo.identifier)); } -double LuaScale::scaleValue(const UpdateData& data) const { +glm::dvec3 LuaScale::scaleValue(const UpdateData& data) const { ghoul::lua::runScriptFile(_state, _luaScriptFile); // Get the scaling function @@ -97,7 +97,7 @@ double LuaScale::scaleValue(const UpdateData& data) const { "LuaScale", fmt::format("Script '{}' does not have a function 'scale'", _luaScriptFile) ); - return 0.0; + return glm::dvec3(1.0); } // First argument is the number of seconds past the J2000 epoch in ingame time @@ -120,7 +120,11 @@ double LuaScale::scaleValue(const UpdateData& data) const { ); } - return luaL_checknumber(_state, -1); + const double x = luaL_checknumber(_state, -1); + const double y = luaL_checknumber(_state, -2); + const double z = luaL_checknumber(_state, -3); + lua_settop(_state, 0); + return glm::dvec3(x, y, z); } } // namespace openspace diff --git a/modules/base/scale/luascale.h b/modules/base/scale/luascale.h index ce8a1fa061..1306ec476b 100644 --- a/modules/base/scale/luascale.h +++ b/modules/base/scale/luascale.h @@ -41,7 +41,7 @@ public: LuaScale(); LuaScale(const ghoul::Dictionary& dictionary); - double scaleValue(const UpdateData& data) const override; + glm::dvec3 scaleValue(const UpdateData& data) const override; static documentation::Documentation Documentation(); diff --git a/modules/base/scale/nonuniformstaticscale.cpp b/modules/base/scale/nonuniformstaticscale.cpp new file mode 100644 index 0000000000..cc9a2d487d --- /dev/null +++ b/modules/base/scale/nonuniformstaticscale.cpp @@ -0,0 +1,79 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include + +#include +#include + +namespace { + constexpr openspace::properties::Property::PropertyInfo ScaleInfo = { + "Scale", + "Scale", + "These values are used as scaling factors for the scene graph node that this " + "transformation is attached to relative to its parent." + }; +} // namespace + +namespace openspace { + +documentation::Documentation NonUniformStaticScale::Documentation() { + using namespace openspace::documentation; + return { + "Static Scaling", + "base_scale_static", + { + { + ScaleInfo.identifier, + new DoubleVector3Verifier, + Optional::No, + ScaleInfo.description + } + } + }; +} + +glm::dvec3 NonUniformStaticScale::scaleValue(const UpdateData&) const { + return _scaleValue; +} + +NonUniformStaticScale::NonUniformStaticScale() + : _scaleValue(ScaleInfo, glm::dvec3(1.0), glm::dvec3(0.1), glm::dvec3(100.0)) +{ + addProperty(_scaleValue); + + _scaleValue.onChange([this]() { + requireUpdate(); + }); +} + +NonUniformStaticScale::NonUniformStaticScale(const ghoul::Dictionary& dictionary) + : NonUniformStaticScale() +{ + documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale"); + + _scaleValue = dictionary.value(ScaleInfo.identifier); +} + +} // namespace openspace diff --git a/modules/base/scale/nonuniformstaticscale.h b/modules/base/scale/nonuniformstaticscale.h new file mode 100644 index 0000000000..ded7951c11 --- /dev/null +++ b/modules/base/scale/nonuniformstaticscale.h @@ -0,0 +1,50 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2020 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __OPENSPACE_MODULE_BASE___NONUNIFORMSTATICSCALE___H__ +#define __OPENSPACE_MODULE_BASE___NONUNIFORMSTATICSCALE___H__ + +#include + +#include + +namespace openspace { + +namespace documentation { struct Documentation; } + +class NonUniformStaticScale : public Scale { +public: + NonUniformStaticScale(); + NonUniformStaticScale(const ghoul::Dictionary& dictionary); + glm::dvec3 scaleValue(const UpdateData& data) const override; + + static documentation::Documentation Documentation(); + +private: + properties::DVec3Property _scaleValue; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___NONUNIFORMSTATICSCALE___H__ diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index bb282dfb9e..4c15f70fae 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -54,8 +54,8 @@ documentation::Documentation StaticScale::Documentation() { }; } -double StaticScale::scaleValue(const UpdateData&) const { - return _scaleValue; +glm::dvec3 StaticScale::scaleValue(const UpdateData&) const { + return glm::dvec3(_scaleValue); } StaticScale::StaticScale() : _scaleValue(ScaleInfo, 1.f, 0.1f, 100.f) { diff --git a/modules/base/scale/staticscale.h b/modules/base/scale/staticscale.h index 21e5bb6cde..f11e95a4ed 100644 --- a/modules/base/scale/staticscale.h +++ b/modules/base/scale/staticscale.h @@ -37,7 +37,7 @@ class StaticScale : public Scale { public: StaticScale(); StaticScale(const ghoul::Dictionary& dictionary); - double scaleValue(const UpdateData& data) const override; + glm::dvec3 scaleValue(const UpdateData& data) const override; static documentation::Documentation Documentation(); diff --git a/modules/base/scale/timedependentscale.cpp b/modules/base/scale/timedependentscale.cpp index 0fba563a0c..e6e731d667 100644 --- a/modules/base/scale/timedependentscale.cpp +++ b/modules/base/scale/timedependentscale.cpp @@ -108,7 +108,7 @@ TimeDependentScale::TimeDependentScale(const ghoul::Dictionary& dictionary) addProperty(_clampToPositive); } -double TimeDependentScale::scaleValue(const UpdateData& data) const { +glm::dvec3 TimeDependentScale::scaleValue(const UpdateData& data) const { if (_cachedReferenceDirty) { _cachedReference = Time::convertTime(_referenceDate); _cachedReferenceDirty = false; @@ -118,10 +118,10 @@ double TimeDependentScale::scaleValue(const UpdateData& data) const { const double dt = now - _cachedReference; if (_clampToPositive) { - return std::max(0.0, dt) * _speed; + return glm::dvec3(std::max(0.0, dt) * _speed); } else { - return dt * _speed; + return glm::dvec3(dt * _speed); } } diff --git a/modules/base/scale/timedependentscale.h b/modules/base/scale/timedependentscale.h index e2d219bf6e..3fda4e19ed 100644 --- a/modules/base/scale/timedependentscale.h +++ b/modules/base/scale/timedependentscale.h @@ -38,7 +38,7 @@ namespace documentation { struct Documentation; } class TimeDependentScale : public Scale { public: TimeDependentScale(const ghoul::Dictionary& dictionary); - double scaleValue(const UpdateData& data) const override; + glm::dvec3 scaleValue(const UpdateData& data) const override; static documentation::Documentation Documentation(); diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index b3bfcd144d..b883b6acfb 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -897,15 +897,13 @@ void RenderableGlobe::update(const UpdateData& data) { } setBoundingSphere(static_cast( - _ellipsoid.maximumRadius() * data.modelTransform.scale + _ellipsoid.maximumRadius() * glm::compMax(data.modelTransform.scale) )); glm::dmat4 translation = glm::translate(glm::dmat4(1.0), data.modelTransform.translation); glm::dmat4 rotation = glm::dmat4(data.modelTransform.rotation); - glm::dmat4 scaling = - glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale, - data.modelTransform.scale, data.modelTransform.scale)); + glm::dmat4 scaling = glm::scale(glm::dmat4(1.0), data.modelTransform.scale); _cachedModelTransform = translation * rotation * scaling; _cachedInverseModelTransform = glm::inverse(_cachedModelTransform); @@ -1118,7 +1116,9 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, // Apply an extra scaling to the height if the object is scaled _globalRenderer.program->setUniform( "heightScale", - static_cast(data.modelTransform.scale * data.camera.scaling()) + static_cast( + glm::compMax(data.modelTransform.scale) * data.camera.scaling() + ) ); } @@ -1461,7 +1461,9 @@ void RenderableGlobe::renderChunkLocally(const Chunk& chunk, const RenderData& d // Apply an extra scaling to the height if the object is scaled program.setUniform( "heightScale", - static_cast(data.modelTransform.scale * data.camera.scaling()) + static_cast( + glm::compMax(data.modelTransform.scale) * data.camera.scaling() + ) ); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index c6b06dfde5..50cf01876d 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -517,7 +517,7 @@ void RenderEngine::updateScene() { const Time& integrateFromTime = global::timeManager.integrateFromTime(); _scene->update({ - { glm::dvec3(0.0), glm::dmat3(1.0), 1.0 }, + { glm::dvec3(0.0), glm::dmat3(1.0), glm::dvec3(1.0) }, currentTime, integrateFromTime, _doPerformanceMeasurements diff --git a/src/scene/scale.cpp b/src/scene/scale.cpp index dff7b83fe6..d1eb8e59fc 100644 --- a/src/scene/scale.cpp +++ b/src/scene/scale.cpp @@ -79,7 +79,7 @@ bool Scale::initialize() { return true; } -double Scale::scaleValue() const { +glm::dvec3 Scale::scaleValue() const { return _cachedScale; } diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index aa1239cefd..dc304556eb 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -469,14 +469,7 @@ void SceneGraphNode::update(const UpdateData& data) { newUpdateData.modelTransform.translation ); glm::dmat4 rotation = glm::dmat4(newUpdateData.modelTransform.rotation); - glm::dmat4 scaling = glm::scale( - glm::dmat4(1.0), - glm::dvec3( - newUpdateData.modelTransform.scale, - newUpdateData.modelTransform.scale, - newUpdateData.modelTransform.scale - ) - ); + glm::dmat4 scaling = glm::scale(glm::dmat4(1.0), newUpdateData.modelTransform.scale); _modelTransformCached = translation * rotation * scaling; _inverseModelTransformCached = glm::inverse(_modelTransformCached); @@ -788,7 +781,7 @@ const glm::dmat3& SceneGraphNode::rotationMatrix() const { return _transform.rotation->matrix(); } -double SceneGraphNode::scale() const { +glm::dvec3 SceneGraphNode::scale() const { return _transform.scale->scaleValue(); } @@ -808,7 +801,7 @@ glm::dmat4 SceneGraphNode::inverseModelTransform() const { return _inverseModelTransformCached; } -double SceneGraphNode::worldScale() const { +glm::dvec3 SceneGraphNode::worldScale() const { return _worldScaleCached; } @@ -825,7 +818,7 @@ glm::dvec3 SceneGraphNode::calculateWorldPosition() const { if (_parent) { const glm::dvec3 wp = _parent->worldPosition(); const glm::dmat3 wrot = _parent->worldRotationMatrix(); - const double ws = _parent->worldScale(); + const glm::dvec3 ws = _parent->worldScale(); const glm::dvec3 p = position(); return wp + wrot * ws * p; @@ -859,7 +852,7 @@ glm::dmat3 SceneGraphNode::calculateWorldRotation() const { } } -double SceneGraphNode::calculateWorldScale() const { +glm::dvec3 SceneGraphNode::calculateWorldScale() const { // recursive up the hierarchy if there are parents available if (_parent) { return _parent->worldScale() * scale(); From 7c24a96b9edf627b4129853976c2e90f4fe30f84 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 12 May 2020 15:46:30 +0200 Subject: [PATCH 67/67] Add ability to change the line width of wire-type DU meshes (closes #1153) --- .../rendering/renderabledumeshes.cpp | 22 ++++++++++++++++++- .../rendering/renderabledumeshes.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index bdc7b80436..a9ce646b08 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -110,6 +110,12 @@ namespace { "objects being rendered." }; + constexpr openspace::properties::Property::PropertyInfo LineWidthInfo = { + "LineWidth", + "Line Width", + "If the DU mesh is of wire type, this value determines the width of the lines" + }; + constexpr openspace::properties::Property::PropertyInfo DrawElementsInfo = { "DrawElements", "Draw Elements", @@ -215,6 +221,12 @@ documentation::Documentation RenderableDUMeshes::Documentation() { Optional::Yes, LabelMaxSizeInfo.description }, + { + LineWidthInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LineWidthInfo.description + }, { TransformationMatrixInfo.identifier, new Matrix4x4Verifier, @@ -242,6 +254,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) , _drawLabels(DrawLabelInfo, false) , _textMinSize(LabelMinSizeInfo, 8.f, 0.5f, 24.f) , _textMaxSize(LabelMaxSizeInfo, 500.f, 0.f, 1000.f) + , _lineWidth(LineWidthInfo, 2.f, 0.f, 16.f) , _renderOption(RenderOptionInfo, properties::OptionProperty::DisplayType::Dropdown) { documentation::testSpecificationAndThrow( @@ -315,6 +328,13 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) } addProperty(_scaleFactor);*/ + if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { + _lineWidth = static_cast( + dictionary.value(LineWidthInfo.identifier) + ); + } + addProperty(_lineWidth); + if (dictionary.hasKey(DrawLabelInfo.identifier)) { _drawLabels = dictionary.value(DrawLabelInfo.identifier); } @@ -473,7 +493,7 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, case Solid: break; case Wire: - glLineWidth(2.0); + glLineWidth(_lineWidth); glDrawArrays(GL_LINE_STRIP, 0, pair.second.numV); glLineWidth(lineWidth); break; diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index 418f45eafe..bb0b6dce20 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -128,6 +128,7 @@ private: //properties::OptionProperty _blendMode; properties::FloatProperty _textMinSize; properties::FloatProperty _textMaxSize; + properties::FloatProperty _lineWidth; // DEBUG: properties::OptionProperty _renderOption;