diff --git a/data/scene/debugglobe/debugglobe.mod b/data/scene/debugglobe/debugglobe.mod index ae21e2f03a..d9d4c660c7 100644 --- a/data/scene/debugglobe/debugglobe.mod +++ b/data/scene/debugglobe/debugglobe.mod @@ -1,23 +1,9 @@ return { - -- Earth barycenter module - { - Name = "EarthBarycenter", - Parent = "SolarSystemBarycenter", - Static = true, - Ephemeris = { - Type = "Spice", - Body = "EARTH BARYCENTER", - Reference = "ECLIPJ2000", - Observer = "SUN", - Kernels = { - "${OPENSPACE_DATA}/spice/de430_1850-2150.bsp" - } - }, - }, + -- RenderableGlobe module { Name = "DebugGlobe", - Parent = "EarthBarycenter", + Parent = "Root", Renderable = { Type = "RenderableGlobe", Frame = "IAU_EARTH", @@ -67,11 +53,7 @@ return { Enabled = true, }, --[[ - { - Name = "Mars Viking Clr", - FilePath = "textures/Mars_Viking_ClrMosaic_global_925m_longlat_full.vrt", - Enabled = true, - }, + { Name = "On Mercury Color", FilePath = "map_service_configs/mercury/OnMercuryColor.xml", @@ -86,7 +68,7 @@ return { { Name = "CTX Mosaic", FilePath = "map_service_configs/mars/CTX_Mosaic.xml", - Enabled = false, + Enabled = true, }, --[[ @@ -129,7 +111,6 @@ return { }, }, HeightMaps = { - { Name = "Mola Elevation", FilePath = "map_service_configs/mars/Mola_Elevation.xml", @@ -173,30 +154,4 @@ return { }, GuiName = "/Solar/Planets/DebugGlobe" }, - -- EarthTrail module - { - Name = "EarthTrail", - Parent = "SolarSystemBarycenter", - Renderable = { - Type = "RenderableTrail", - Body = "EARTH", - Frame = "GALACTIC", - Observer = "SUN", - RGB = { 0.5, 0.8, 1.0}, - TropicalOrbitPeriod = 365.242, - EarthOrbitRatio = 1, - DayLength = 24 - }, - GuiName = "/Solar/EarthTrail" - } - --[[, - { - Name = "DebugPlane", - Parent = "DebugGlobe", - Renderable = { - Type = "RenderableDebugPlane", - Texture = 34, - Size = { 1, 7 } - } - }]] } diff --git a/data/scene/globebrowsing-debug.scene b/data/scene/globebrowsing-debug.scene new file mode 100644 index 0000000000..ef64c4ef0d --- /dev/null +++ b/data/scene/globebrowsing-debug.scene @@ -0,0 +1,46 @@ +function preInitialization() + --[[ + The scripts in this function are executed after the scene is loaded but before the + scene elements have been initialized, thus they should be used to set the time at + which the scene should start and other settings that might determine initialization + critical objects. + ]]-- + + --openspace.time.setTime(openspace.time.currentWallTime()) + openspace.spice.loadKernel("${SPICE}/naif0011.tls") + openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + + openspace.time.setTime("2015 NOV 24 00:00:00") + + + dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) +end + +function postInitialization() + openspace.printInfo("Setting default values") + + openspace.setInteractionMode('GlobeBrowsing') + + openspace.time.setDeltaTime(0) + openspace.restoreCameraStateFromFile("debugstart.view") + openspace.resetCameraDirection() + openspace.gui.show() + + openspace.printInfo("Done setting default values") +end + + +return { + ScenePath = ".", + CommonFolder = "common", + Camera = { + Focus = "DebugGlobe", + Position = {3428016.852415, 616607.056698, 60430.587719}, + Rotation = {0.178551, -0.280661, 0.916566, 0.221935}, + }, + + Modules = { + "debugglobe" + } +} + diff --git a/data/scene/lodmars/lodmars.mod b/data/scene/lodmars/lodmars.mod index 351bf423d3..df4f916d82 100644 --- a/data/scene/lodmars/lodmars.mod +++ b/data/scene/lodmars/lodmars.mod @@ -48,7 +48,6 @@ return { { Name = "MARS_Viking_MDIM21", FilePath = "map_service_configs/MARS_Viking_MDIM21.xml", - Enabled = true, }, { Name = "Mars Viking Clr", diff --git a/data/scene/rosetta/67P/67P.data b/data/scene/rosetta/67P/67P.data index 0cfd6a4b07..3c899a9480 100644 --- a/data/scene/rosetta/67P/67P.data +++ b/data/scene/rosetta/67P/67P.data @@ -1,6 +1,7 @@ return { FileRequest = { - { Identifier = "67p_textures", Destination = "textures", Version = 2 } + { Identifier = "67p_textures", Destination = "textures", Version = 2 }, + { Identifier = "rosettaimages", Destination = "rosettaimages", Version = 1} }, TorrentFiles = { { File = "67P_rotated_5_130.obj.torrent", Destination = "obj" }, diff --git a/ext/ghoul b/ext/ghoul index 9e4431d254..6174b77164 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 9e4431d25403ab1cf0ae0be064f26ecf8f849bb9 +Subproject commit 6174b77164829df44d3511c670e59a113c74caec diff --git a/ext/sgct b/ext/sgct index 0a2d0241f4..70cde82e33 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit 0a2d0241f40ffbabac22bcd5c55a8c782a938685 +Subproject commit 70cde82e331406d8bfe406d0e606fefa89d873c7 diff --git a/include/openspace/interaction/controller.h b/include/openspace/interaction/controller.h index 636b810ebe..3afb45b8df 100644 --- a/include/openspace/interaction/controller.h +++ b/include/openspace/interaction/controller.h @@ -50,4 +50,4 @@ protected: } // namespace interaction } // namespace openspace -#endif // __CONTROLLER_H__ \ No newline at end of file +#endif // __CONTROLLER_H__ diff --git a/include/openspace/interaction/deviceidentifier.h b/include/openspace/interaction/deviceidentifier.h index 0497699149..e021fac9aa 100644 --- a/include/openspace/interaction/deviceidentifier.h +++ b/include/openspace/interaction/deviceidentifier.h @@ -52,4 +52,4 @@ private: } // namespace openspace -#endif \ No newline at end of file +#endif diff --git a/include/openspace/interaction/externalcontrol/externalconnectioncontroller.h b/include/openspace/interaction/externalcontrol/externalconnectioncontroller.h index 09e952e10e..6af23c76b4 100644 --- a/include/openspace/interaction/externalcontrol/externalconnectioncontroller.h +++ b/include/openspace/interaction/externalcontrol/externalconnectioncontroller.h @@ -21,4 +21,4 @@ private: } // namespace openspace -#endif \ No newline at end of file +#endif diff --git a/include/openspace/interaction/externalcontrol/externalcontrol.h b/include/openspace/interaction/externalcontrol/externalcontrol.h index 986749135b..10dad0815e 100644 --- a/include/openspace/interaction/externalcontrol/externalcontrol.h +++ b/include/openspace/interaction/externalcontrol/externalcontrol.h @@ -26,4 +26,4 @@ protected: } // namespace openspace -#endif \ No newline at end of file +#endif diff --git a/include/openspace/network/messagestructures.h b/include/openspace/network/messagestructures.h index 16f3a8fd8b..e2e3adc313 100644 --- a/include/openspace/network/messagestructures.h +++ b/include/openspace/network/messagestructures.h @@ -162,4 +162,4 @@ namespace openspace{ } // namespace openspace -#endif // __MESSAGESTRUCTURES_H__ \ No newline at end of file +#endif // __MESSAGESTRUCTURES_H__ diff --git a/include/openspace/network/networkengine.h b/include/openspace/network/networkengine.h index a2e8f6fdb3..9a4febd7aa 100644 --- a/include/openspace/network/networkengine.h +++ b/include/openspace/network/networkengine.h @@ -75,4 +75,4 @@ private: } // namespace openspace -#endif // __NETWORKENGINE_H__ \ No newline at end of file +#endif // __NETWORKENGINE_H__ diff --git a/include/openspace/network/parallelconnection.h b/include/openspace/network/parallelconnection.h index d47c157eb3..9073d1f18b 100644 --- a/include/openspace/network/parallelconnection.h +++ b/include/openspace/network/parallelconnection.h @@ -205,4 +205,4 @@ namespace openspace{ } // namespace openspace -#endif // __OSPARALLELCONNECTION_H__ \ No newline at end of file +#endif // __OSPARALLELCONNECTION_H__ diff --git a/include/openspace/openspace.h b/include/openspace/openspace.h index 75fb83e1c8..181547f5b4 100644 --- a/include/openspace/openspace.h +++ b/include/openspace/openspace.h @@ -39,4 +39,4 @@ const std::string OPENSPACE_VERSION_STRING = "prerelease-9 (IPS)"; } // namespace openspace -#endif // __OPENSPACE_H__ \ No newline at end of file +#endif // __OPENSPACE_H__ diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index 50fea9aaeb..42bca29af6 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -125,4 +125,4 @@ private: } // namespace properties } // namespace openspace -#endif // __STRINGPROPERTY_H__ \ No newline at end of file +#endif // __STRINGPROPERTY_H__ diff --git a/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h index dc482badfe..b86aea9870 100644 --- a/include/openspace/properties/selectionproperty.h +++ b/include/openspace/properties/selectionproperty.h @@ -79,4 +79,4 @@ bool PropertyDelegate>>::toString(std::string& } // namespace properties } // namespace openspace -#endif // __SELECTIONPROPERTY_H__ \ No newline at end of file +#endif // __SELECTIONPROPERTY_H__ diff --git a/include/openspace/properties/stringproperty.h b/include/openspace/properties/stringproperty.h index 3b06601b13..eb01a2dc07 100644 --- a/include/openspace/properties/stringproperty.h +++ b/include/openspace/properties/stringproperty.h @@ -35,4 +35,4 @@ REGISTER_TEMPLATEPROPERTY_HEADER(StringProperty, std::string); } // namespace properties } // namespace openspace -#endif // __STRINGPROPERTY_H__ \ No newline at end of file +#endif // __STRINGPROPERTY_H__ diff --git a/include/openspace/query/query.h b/include/openspace/query/query.h index a48c55aed3..98d2844f68 100644 --- a/include/openspace/query/query.h +++ b/include/openspace/query/query.h @@ -48,4 +48,4 @@ std::vector allProperties(); } // namespace -#endif // __QUERY_H__ \ No newline at end of file +#endif // __QUERY_H__ diff --git a/include/openspace/util/camera.h b/include/openspace/util/camera.h index a9d9f0a9c5..7357ce9c8c 100644 --- a/include/openspace/util/camera.h +++ b/include/openspace/util/camera.h @@ -218,4 +218,4 @@ namespace openspace { }; } // namespace openspace -#endif // __CAMERA_H__ \ No newline at end of file +#endif // __CAMERA_H__ diff --git a/include/openspace/util/syncbuffer.h b/include/openspace/util/syncbuffer.h index db60750fee..6a63b41a9a 100644 --- a/include/openspace/util/syncbuffer.h +++ b/include/openspace/util/syncbuffer.h @@ -116,4 +116,4 @@ private: } // namespace openspace -#endif // SYNCBUFFER_H \ No newline at end of file +#endif // SYNCBUFFER_H diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index fb0c619703..19724e482d 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -84,4 +84,4 @@ private: } // namespace openspace -#endif // __RENDERABLEMODEL_H__ \ No newline at end of file +#endif // __RENDERABLEMODEL_H__ diff --git a/modules/base/rendering/renderableplanet.h b/modules/base/rendering/renderableplanet.h index 7f38b0d9ad..11df2513df 100644 --- a/modules/base/rendering/renderableplanet.h +++ b/modules/base/rendering/renderableplanet.h @@ -218,4 +218,4 @@ private: } // namespace openspace -#endif // __RENDERABLEPLANET_H__ \ No newline at end of file +#endif // __RENDERABLEPLANET_H__ diff --git a/modules/base/rendering/screenspaceimage.cpp b/modules/base/rendering/screenspaceimage.cpp index b0106d129a..fa208ee104 100644 --- a/modules/base/rendering/screenspaceimage.cpp +++ b/modules/base/rendering/screenspaceimage.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include diff --git a/modules/base/shaders/rings_fs.glsl b/modules/base/shaders/rings_fs.glsl index 9b12688943..8a7c237de3 100644 --- a/modules/base/shaders/rings_fs.glsl +++ b/modules/base/shaders/rings_fs.glsl @@ -73,10 +73,10 @@ Fragment getFragment() { // The plane is oriented on the xz plane // WARNING: This might not be the case for Uranus if (gl_FrontFacing) { - normal = vec3(0.0, 1.0, 0.0); + normal = vec3(-1.0, 0.0, 0.0); } else { - normal = vec3(0.0, -1.0, 0.0); + normal = vec3(1.0, 0.0, 0.0); } // Reduce the color of the fragment by the user factor diff --git a/modules/base/shaders/screenspace_fs.glsl b/modules/base/shaders/screenspace_fs.glsl index bd72b4a47f..9ab37b56af 100644 --- a/modules/base/shaders/screenspace_fs.glsl +++ b/modules/base/shaders/screenspace_fs.glsl @@ -32,9 +32,7 @@ in vec4 vs_position; #include "fragment.glsl" #include "PowerScaling/powerScaling_fs.hglsl" - - -Fragment getFragment(){ +Fragment getFragment() { Fragment frag; // power scale coordinates for depth. w value is set to 1.0. @@ -44,6 +42,7 @@ Fragment getFragment(){ if(frag.color.a == 0.0f){ discard; } + frag.depth = denormalizeFloat(depth); return frag; diff --git a/modules/base/shaders/screenspace_vs.glsl b/modules/base/shaders/screenspace_vs.glsl index f29f63a06a..02849b3537 100644 --- a/modules/base/shaders/screenspace_vs.glsl +++ b/modules/base/shaders/screenspace_vs.glsl @@ -36,6 +36,6 @@ out vec4 vs_position; void main(){ vs_st = in_st; - vs_position = ViewProjectionMatrix*ModelTransform*in_position; + vs_position = ViewProjectionMatrix * ModelTransform * in_position; gl_Position = vec4(vs_position); -} \ No newline at end of file +} diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index 27c9a51aae..1894705a8a 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -71,6 +71,7 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.h ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentqueue.h ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.h + ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.h ) @@ -122,6 +123,7 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/other/lrucache.inl ${CMAKE_CURRENT_SOURCE_DIR}/other/concurrentjobmanager.inl ${CMAKE_CURRENT_SOURCE_DIR}/other/statscollector.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/other/threadpool.cpp ) source_group("Source Files" FILES ${SOURCE_FILES}) diff --git a/modules/globebrowsing/chunk/chunkrenderer.h b/modules/globebrowsing/chunk/chunkrenderer.h index aaf53e8485..7649c38146 100644 --- a/modules/globebrowsing/chunk/chunkrenderer.h +++ b/modules/globebrowsing/chunk/chunkrenderer.h @@ -42,6 +42,7 @@ #include +#include namespace ghoul { diff --git a/modules/globebrowsing/geometry/aabb.h b/modules/globebrowsing/geometry/aabb.h index ac02a3b39b..d153c5bd7e 100644 --- a/modules/globebrowsing/geometry/aabb.h +++ b/modules/globebrowsing/geometry/aabb.h @@ -96,4 +96,4 @@ namespace openspace { } // namespace openspace -#endif // __AABB_H__ \ No newline at end of file +#endif // __AABB_H__ diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index c009139f9e..00dc07daa3 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -61,7 +61,7 @@ namespace openspace { , _saveOrThrowCamera(properties::BoolProperty("saveOrThrowCamera", "saveOrThrowCamera")) , _resetTileProviders(properties::BoolProperty("resetTileProviders", "resetTileProviders")) , _cameraMinHeight(properties::FloatProperty("cameraMinHeight", "cameraMinHeight", 100.0f, 0.0f, 1000.0f)) - , lodScaleFactor(properties::FloatProperty("lodScaleFactor", "lodScaleFactor", 5.0f, 1.0f, 50.0f)) + , lodScaleFactor(properties::FloatProperty("lodScaleFactor", "lodScaleFactor", 10.0f, 1.0f, 50.0f)) , debugSelection(ReferencedBoolSelection("Debug", "Debug")) , atmosphereEnabled(properties::BoolProperty(" Atmosphere", " Atmosphere", false)) { diff --git a/modules/globebrowsing/meshes/grid.h b/modules/globebrowsing/meshes/grid.h index 3d9860a521..00728991c4 100644 --- a/modules/globebrowsing/meshes/grid.h +++ b/modules/globebrowsing/meshes/grid.h @@ -71,4 +71,4 @@ protected: const int _ySegments; }; } // namespace openspace -#endif // __GRIDGEOMETRY_H__ \ No newline at end of file +#endif // __GRIDGEOMETRY_H__ diff --git a/modules/globebrowsing/meshes/trianglesoup.cpp b/modules/globebrowsing/meshes/trianglesoup.cpp index ee1a7bf90c..adfbad88e8 100644 --- a/modules/globebrowsing/meshes/trianglesoup.cpp +++ b/modules/globebrowsing/meshes/trianglesoup.cpp @@ -175,4 +175,4 @@ void TriangleSoup::drawUsingActiveProgram() { glBindVertexArray(0); } -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/modules/globebrowsing/meshes/trianglesoup.h b/modules/globebrowsing/meshes/trianglesoup.h index 37a00dee3a..d2291e8a66 100644 --- a/modules/globebrowsing/meshes/trianglesoup.h +++ b/modules/globebrowsing/meshes/trianglesoup.h @@ -100,4 +100,4 @@ private: } // namespace openspace -#endif // __TRIANGLESOUP_H__ \ No newline at end of file +#endif // __TRIANGLESOUP_H__ diff --git a/modules/globebrowsing/other/concurrentjobmanager.h b/modules/globebrowsing/other/concurrentjobmanager.h index 323c90b292..e34bbf3c16 100644 --- a/modules/globebrowsing/other/concurrentjobmanager.h +++ b/modules/globebrowsing/other/concurrentjobmanager.h @@ -32,7 +32,8 @@ #include #include -#include +#include +//#include #include @@ -64,7 +65,7 @@ namespace openspace { template class ConcurrentJobManager{ public: - ConcurrentJobManager(std::shared_ptr pool) : threadPool(pool) + ConcurrentJobManager(std::shared_ptr pool) : threadPool(pool) { } @@ -75,14 +76,19 @@ namespace openspace { void enqueueJob(std::shared_ptr> job) { - threadPool->queue([this, job]() { + //threadPool->queue([this, job]() { + // job->execute(); + // _finishedJobs.push(job); + //}); + threadPool->enqueue([this, job]() { job->execute(); _finishedJobs.push(job); }); } void clearEnqueuedJobs() { - threadPool->clearRemainingTasks(); + //threadPool->clearRemainingTasks(); + threadPool->clearTasks(); } std::shared_ptr> popFinishedJob() { @@ -95,14 +101,15 @@ namespace openspace { } void reset() { - threadPool->clearRemainingTasks(); + //threadPool->clearRemainingTasks(); + threadPool->clearTasks(); } private: ConcurrentQueue>> _finishedJobs; - std::shared_ptr threadPool; + std::shared_ptr threadPool; }; diff --git a/modules/globebrowsing/other/threadpool.cpp b/modules/globebrowsing/other/threadpool.cpp new file mode 100644 index 0000000000..50618c49fb --- /dev/null +++ b/modules/globebrowsing/other/threadpool.cpp @@ -0,0 +1,123 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + + + +namespace openspace { + + Worker::Worker(ThreadPool& pool) + : pool(pool) + { + + } + + void Worker::operator()() { + std::function task; + while (true) { + + // acquire lock + { + std::unique_lock lock(pool.queue_mutex); + + // look for a work item + while (!pool.stop && pool.tasks.empty()) { + // if there are none wait for notification + pool.condition.wait(lock); + } + + if (pool.stop) { // exit if the pool is stopped + return; + } + + // get the task from the queue + task = pool.tasks.front(); + pool.tasks.pop_front(); + + }// release lock + + // execute the task + task(); + } + + + } + + + + + + ThreadPool::ThreadPool(size_t numThreads) + : stop(false) + { + for (size_t i = 0; i < numThreads; ++i) { + workers.push_back(std::thread(Worker(*this))); + } + } + + // the destructor joins all threads + ThreadPool::~ThreadPool() { + // stop all threads + stop = true; + condition.notify_all(); + + // join them + for (size_t i = 0; i < workers.size(); ++i) { + workers[i].join(); + } + } + + + // add new work item to the pool + void ThreadPool::enqueue(std::function f) { + { // acquire lock + std::unique_lock lock(queue_mutex); + + // add the task + tasks.push_back(f); + } // release lock + + // wake up one thread + condition.notify_one(); + } + + void ThreadPool::clearTasks() { + { // acquire lock + std::unique_lock lock(queue_mutex); + tasks.clear(); + } // release lock + } + + +} // namespace openspace \ No newline at end of file diff --git a/modules/globebrowsing/other/threadpool.h b/modules/globebrowsing/other/threadpool.h new file mode 100644 index 0000000000..00f0964705 --- /dev/null +++ b/modules/globebrowsing/other/threadpool.h @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __THREAD_POOL_H__ +#define __THREAD_POOL_H__ + +#include +#include +#include +#include +#include + +#include + +#include + + + +// Implementatin based on http://progsch.net/wordpress/?p=81 + +namespace openspace { + + + class ThreadPool; + + class Worker { + public: + Worker(ThreadPool& pool); + void operator()(); + private: + ThreadPool& pool; + }; + + class ThreadPool { + public: + ThreadPool(size_t numThreads); + ~ThreadPool(); + + void enqueue(std::function f); + void clearTasks(); + + private: + friend class Worker; + + std::vector workers; + + std::deque> tasks; + + std::mutex queue_mutex; + std::condition_variable condition; + + bool stop; + }; + + +} // namespace openspace + + + +#endif // __THREAD_POOL_H__ \ No newline at end of file diff --git a/modules/globebrowsing/tile/asynctilereader.cpp b/modules/globebrowsing/tile/asynctilereader.cpp index d83f965506..fe523b8442 100644 --- a/modules/globebrowsing/tile/asynctilereader.cpp +++ b/modules/globebrowsing/tile/asynctilereader.cpp @@ -117,9 +117,9 @@ namespace openspace { AsyncTileDataProvider::AsyncTileDataProvider( std::shared_ptr tileDataset, - std::shared_ptr pool) + std::shared_ptr pool) : _tileDataset(tileDataset) - , _threadPool(pool) + , _concurrentJobManager(pool) { } @@ -135,12 +135,11 @@ namespace openspace { bool AsyncTileDataProvider::enqueueTileIO(const ChunkIndex& chunkIndex) { if (satisfiesEnqueueCriteria(chunkIndex)) { - const static auto job = [](const ChunkIndex& chunkIndex, std::shared_ptr tileDataset) { - return tileDataset->readTileData(chunkIndex); - }; + auto job = std::make_shared(_tileDataset, chunkIndex); + //auto job = std::make_shared(_tileDataset, chunkIndex, tileDiskCache, "ReadAndWrite"); + _concurrentJobManager.enqueueJob(job); + _enqueuedTileRequests[chunkIndex.hashKey()] = chunkIndex; - FutureResult futureResult = _threadPool->queue(job, chunkIndex, _tileDataset); - _futureTileIOResults[chunkIndex.hashKey()] = std::move(futureResult); return true; } return false; @@ -148,16 +147,8 @@ namespace openspace { std::vector> AsyncTileDataProvider::getTileIOResults() { std::vector> readyResults; - auto it = _futureTileIOResults.begin(); - while(it != _futureTileIOResults.end()) { - std::future_status status = it->second.wait_for(std::chrono::seconds(0)); - if (status == std::future_status::ready) { - readyResults.push_back(it->second.get()); - it = _futureTileIOResults.erase(it); - } - else { - it++; - } + while (_concurrentJobManager.numFinishedJobs() > 0) { + readyResults.push_back(_concurrentJobManager.popFinishedJob()->product()); } return readyResults; } @@ -165,19 +156,28 @@ namespace openspace { bool AsyncTileDataProvider::satisfiesEnqueueCriteria(const ChunkIndex& chunkIndex) const { // only allow tile to be enqueued if it's not already enqueued - return _futureTileIOResults.find(chunkIndex.hashKey()) == _futureTileIOResults.end(); + //return _futureTileIOResults.find(chunkIndex.hashKey()) == _futureTileIOResults.end(); + return _enqueuedTileRequests.find(chunkIndex.hashKey()) == _enqueuedTileRequests.end(); + } void AsyncTileDataProvider::reset() { - _futureTileIOResults.clear(); - _threadPool->stop(ghoul::ThreadPool::RunRemainingTasks::No); - _threadPool->start(); + //_futureTileIOResults.clear(); + //_threadPool->stop(ghoul::ThreadPool::RunRemainingTasks::No); + //_threadPool->start(); + _enqueuedTileRequests.clear(); + _concurrentJobManager.reset(); + while (_concurrentJobManager.numFinishedJobs() > 0) { + _concurrentJobManager.popFinishedJob(); + } getTextureDataProvider()->reset(); } void AsyncTileDataProvider::clearRequestQueue() { - _threadPool->clearRemainingTasks(); - _futureTileIOResults.clear(); + //_threadPool->clearRemainingTasks(); + //_futureTileIOResults.clear(); + _concurrentJobManager.clearEnqueuedJobs(); + _enqueuedTileRequests.clear(); } } // namespace openspace diff --git a/modules/globebrowsing/tile/asynctilereader.h b/modules/globebrowsing/tile/asynctilereader.h index 57d072fdf7..7b9b95994e 100644 --- a/modules/globebrowsing/tile/asynctilereader.h +++ b/modules/globebrowsing/tile/asynctilereader.h @@ -33,7 +33,8 @@ #include #include -#include +#include +//#include #include @@ -118,7 +119,7 @@ namespace openspace { public: AsyncTileDataProvider(std::shared_ptr textureDataProvider, - std::shared_ptr pool); + std::shared_ptr pool); ~AsyncTileDataProvider(); @@ -136,12 +137,13 @@ namespace openspace { virtual bool satisfiesEnqueueCriteria(const ChunkIndex&) const; private: - using FutureResult = std::future>; + std::shared_ptr _tileDataset; - std::shared_ptr _threadPool; - std::unordered_map _futureTileIOResults; + ConcurrentJobManager _concurrentJobManager; + std::unordered_map _enqueuedTileRequests; + }; diff --git a/modules/globebrowsing/tile/tiledataset.cpp b/modules/globebrowsing/tile/tiledataset.cpp index a28a79e8c2..ae4a917138 100644 --- a/modules/globebrowsing/tile/tiledataset.cpp +++ b/modules/globebrowsing/tile/tiledataset.cpp @@ -63,9 +63,9 @@ namespace openspace { } - TileDataLayout::TileDataLayout(GDALDataset* dataSet, GLuint _glType) { + TileDataLayout::TileDataLayout(GDALDataset* dataSet, GLuint preferredGlType) { // Assume all raster bands have the same data type - gdalType = _glType != 0 ? TileDataType::getGdalDataType(glType) : dataSet->GetRasterBand(1)->GetRasterDataType(); + gdalType = preferredGlType != 0 ? TileDataType::getGdalDataType(preferredGlType) : dataSet->GetRasterBand(1)->GetRasterDataType(); glType = TileDataType::getOpenGLDataType(gdalType); numRasters = dataSet->GetRasterCount(); bytesPerDatum = TileDataType::numberOfBytes(gdalType); @@ -640,6 +640,7 @@ namespace openspace { size_t largestIndex = (end.y - 1) * io.write.bytesPerLine + (end.x - 1) * _dataLayout.bytesPerPixel; ghoul_assert(largestIndex <= io.write.totalNumBytes, "Invalid write region"); + char * dataDest = dataDestination; // OBS! GDAL reads pixels top to bottom, but we want our pixels bottom to top. diff --git a/modules/globebrowsing/tile/tiledataset.h b/modules/globebrowsing/tile/tiledataset.h index 81975f8c6b..cd68c671c7 100644 --- a/modules/globebrowsing/tile/tiledataset.h +++ b/modules/globebrowsing/tile/tiledataset.h @@ -47,7 +47,7 @@ namespace openspace { struct TileDataLayout { TileDataLayout(); - TileDataLayout(GDALDataset* dataSet, GLuint glType); + TileDataLayout(GDALDataset* dataSet, GLuint preferredGlType); GDALDataType gdalType; GLuint glType; diff --git a/modules/globebrowsing/tile/tileproviderfactory.cpp b/modules/globebrowsing/tile/tileproviderfactory.cpp index 1582b05553..c1a88c4d22 100644 --- a/modules/globebrowsing/tile/tileproviderfactory.cpp +++ b/modules/globebrowsing/tile/tileproviderfactory.cpp @@ -23,6 +23,7 @@ ****************************************************************************************/ #include +#include #include #include @@ -89,7 +90,7 @@ namespace openspace { config.minimumTilePixelSize = initData.minimumPixelSize; auto tileDataset = std::make_shared(desc, config); - auto threadPool = std::make_shared(1); + auto threadPool = std::make_shared(1); auto tileReader = std::make_shared(tileDataset, threadPool); auto tileCache = std::make_shared(initData.cacheSize); auto tileProvider = std::make_shared(tileReader, tileCache, initData.framesUntilRequestQueueFlush); diff --git a/modules/iswa/rendering/textureplane.cpp b/modules/iswa/rendering/textureplane.cpp index 6276fb9900..2f032f1062 100644 --- a/modules/iswa/rendering/textureplane.cpp +++ b/modules/iswa/rendering/textureplane.cpp @@ -21,9 +21,11 @@ * 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 namespace { const std::string _loggerCat = "TexturePlane"; diff --git a/modules/iswa/util/dataprocessor.h b/modules/iswa/util/dataprocessor.h index 75ecd78da0..767c75d80b 100644 --- a/modules/iswa/util/dataprocessor.h +++ b/modules/iswa/util/dataprocessor.h @@ -76,4 +76,5 @@ protected: }; } // namespace openspace -#endif //__DATAPROCESSOR_H__ \ No newline at end of file + +#endif //__DATAPROCESSOR_H__ diff --git a/modules/newhorizons/shaders/renderableModelProjection_vs.glsl b/modules/newhorizons/shaders/renderableModelProjection_vs.glsl index 583c841193..20c64bd812 100644 --- a/modules/newhorizons/shaders/renderableModelProjection_vs.glsl +++ b/modules/newhorizons/shaders/renderableModelProjection_vs.glsl @@ -46,7 +46,7 @@ void main() { vec4 tmp = in_position; vec4 position = pscTransform(tmp, ModelTransform); - vs_position = tmp; + vs_position = position; vec4 raw_pos = psc_to_meter(in_position, _scaling); ProjTexCoord = ProjectorMatrix * ModelTransform * raw_pos; diff --git a/modules/newhorizons/util/hongkangparser.h b/modules/newhorizons/util/hongkangparser.h index 1a739cd4b6..ef1db0023d 100644 --- a/modules/newhorizons/util/hongkangparser.h +++ b/modules/newhorizons/util/hongkangparser.h @@ -75,4 +75,4 @@ private: }; } -#endif //__HONGKANGPARSER_H__ \ No newline at end of file +#endif //__HONGKANGPARSER_H__ diff --git a/modules/newhorizons/util/instrumentdecoder.cpp b/modules/newhorizons/util/instrumentdecoder.cpp index f945e31e4c..b575f0cf32 100644 --- a/modules/newhorizons/util/instrumentdecoder.cpp +++ b/modules/newhorizons/util/instrumentdecoder.cpp @@ -73,4 +73,4 @@ std::vector InstrumentDecoder::getTranslation(){ return _spiceIDs; } -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/modules/newhorizons/util/labelparser.h b/modules/newhorizons/util/labelparser.h index 65fe473c01..c0cf393ce6 100644 --- a/modules/newhorizons/util/labelparser.h +++ b/modules/newhorizons/util/labelparser.h @@ -75,4 +75,4 @@ private: bool _badDecoding; }; } -#endif //__LABELPARSER_H__ \ No newline at end of file +#endif //__LABELPARSER_H__ diff --git a/modules/newhorizons/util/scannerdecoder.cpp b/modules/newhorizons/util/scannerdecoder.cpp index fdb836c620..aae509a0a9 100644 --- a/modules/newhorizons/util/scannerdecoder.cpp +++ b/modules/newhorizons/util/scannerdecoder.cpp @@ -50,4 +50,4 @@ void ScannerDecoder::setStopCommand(std::string stopCommand){ _abort = stopCommand; } -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/modules/newhorizons/util/targetdecoder.cpp b/modules/newhorizons/util/targetdecoder.cpp index 05f1253699..d0b48033ed 100644 --- a/modules/newhorizons/util/targetdecoder.cpp +++ b/modules/newhorizons/util/targetdecoder.cpp @@ -48,4 +48,4 @@ std::vector TargetDecoder::getTranslation(){ return _names; } -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/openspace.cfg b/openspace.cfg index e93eb61dd9..aafd84b3c7 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -9,6 +9,9 @@ return { -- of all entities that will be visible during an instance of OpenSpace -- Scene = "${SCENE}/default-moon.scene", -- Scene = "${SCENE}/default.scene", + + --Scene = "${SCENE}/globebrowsing.scene", + -- Scene = "${SCENE}/globebrowsing-debug.scene", -- Scene = "${SCENE}/globebrowsing.scene", -- Scene = "${SCENE}/rosetta.scene", -- Scene = "${SCENE}/dawn.scene", @@ -35,8 +38,8 @@ return { Light = "${FONTS}/Roboto/Roboto-Regular.ttf" }, Logging = { - LogLevel = "Info", - ImmediateFlush = false, + LogLevel = "Debug", + ImmediateFlush = true, Logs = { { Type = "HTML", FileName = "${BASE_PATH}/log.html", Append = false } }, diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 66c5a8ea39..5452416a32 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -639,6 +639,7 @@ InteractionHandler::InteractionHandler() return; } setFocusNode(node); + resetCameraDirection(); }); _coordinateSystem.onChange([this]() { diff --git a/src/scene/ephemeris.cpp b/src/scene/ephemeris.cpp index 77ea663dba..f7088b3234 100644 --- a/src/scene/ephemeris.cpp +++ b/src/scene/ephemeris.cpp @@ -64,4 +64,4 @@ bool Ephemeris::initialize() { void Ephemeris::update(const UpdateData& data) {} -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/src/util/progressbar.cpp b/src/util/progressbar.cpp index 0b667d713c..d38dd33c82 100644 --- a/src/util/progressbar.cpp +++ b/src/util/progressbar.cpp @@ -55,4 +55,4 @@ void ProgressBar::print(int current) { _previous = iprogress; }; -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/src/util/screenlog.cpp b/src/util/screenlog.cpp index 18d0e7e5de..6299b87a7b 100644 --- a/src/util/screenlog.cpp +++ b/src/util/screenlog.cpp @@ -65,4 +65,4 @@ const std::vector& ScreenLog::entries() const { return _entries; } -} // namespace openspace \ No newline at end of file +} // namespace openspace diff --git a/support/cmake/support_macros.cmake b/support/cmake/support_macros.cmake index b2781d778b..97162c2eda 100644 --- a/support/cmake/support_macros.cmake +++ b/support/cmake/support_macros.cmake @@ -68,7 +68,12 @@ function (set_compile_settings project) set_property(TARGET ${project} PROPERTY CXX_STANDARD_REQUIRED On) if (MSVC) - target_compile_options(${project} PUBLIC "/MP" "/wd4201" "/wd4127") + target_compile_options(${project} PUBLIC + "/MP" # Multi-threading support + "/ZI" # Edit and continue support + "/wd4201" # Disable nameless struct warning + "/wd4127" # Disable conditional expression is constant warning + ) if (OPENSPACE_WARNINGS_AS_ERRORS) target_compile_options(${project} PUBLIC "/WX") endif () @@ -126,7 +131,7 @@ function (add_external_dependencies) libOpenSpace # sgct sgct_light glew glfw png16_static quat tinythreadpp tinyxml2static turbojpeg-static - vrpn zlibstatic + vrpn ${GLFW_LIBRARIES} )