From 393fbdca3ded65992f37e6cbcf06f48161dd7079 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Fri, 31 Jul 2020 15:59:28 -0400 Subject: [PATCH 01/11] OpenGL State Caching. --- data/assets/customization/globebrowsing.asset | 2 +- data/assets/scene/solarsystem/planets.asset | 2 + ext/ghoul | 2 +- include/openspace/rendering/renderengine.h | 6 ++- .../rendering/atmospheredeferredcaster.cpp | 38 +++--------------- .../rendering/grids/renderableboxgrid.cpp | 33 ++-------------- .../base/rendering/grids/renderablegrid.cpp | 33 ++-------------- .../rendering/grids/renderableradialgrid.cpp | 33 ++-------------- .../grids/renderablesphericalgrid.cpp | 35 ++--------------- .../rendering/renderablecartesianaxes.cpp | 27 ++----------- modules/base/rendering/renderablenodeline.cpp | 31 ++------------- .../base/rendering/screenspaceframebuffer.cpp | 6 ++- .../rendering/renderablebillboardscloud.cpp | 34 ++-------------- .../rendering/renderabledumeshes.cpp | 39 +++---------------- .../rendering/renderableplanescloud.cpp | 34 ++-------------- modules/galaxy/rendering/renderablegalaxy.cpp | 29 ++------------ modules/globebrowsing/src/tileprovider.cpp | 9 +++-- modules/space/rendering/renderablestars.cpp | 23 ++--------- src/rendering/framebufferrenderer.cpp | 36 ++++++++++------- src/rendering/renderengine.cpp | 8 ++++ 20 files changed, 95 insertions(+), 365 deletions(-) diff --git a/data/assets/customization/globebrowsing.asset b/data/assets/customization/globebrowsing.asset index bc72ae17b3..883a90d373 100644 --- a/data/assets/customization/globebrowsing.asset +++ b/data/assets/customization/globebrowsing.asset @@ -31,7 +31,7 @@ local vrt_folders = { -- We recommend using this folder for HiRISE openspace.absPath('${BASE}/../OpenSpaceData/Mars/HiRISE'), -- if not and you have a custom path for HiRISE layers, enter it below - '', + '/media/jccosta/Big SSD Data/Pessoal/Work/OpenSpaceData/Mars-Gale-Crater/CTX', }, Moon = { -- Add folders here whose contents will be automatically added to the Moon globe diff --git a/data/assets/scene/solarsystem/planets.asset b/data/assets/scene/solarsystem/planets.asset index f2ebb05379..0783d64e0d 100644 --- a/data/assets/scene/solarsystem/planets.asset +++ b/data/assets/scene/solarsystem/planets.asset @@ -6,6 +6,8 @@ asset.request('./planets/venus/atmosphere') asset.request('./planets/earth/earth') asset.request('./planets/earth/atmosphere') asset.request('./planets/earth/markers') +asset.request('./planets/earth/nycmodel/upperMan.asset') +asset.request('./planets/earth/nycmodel/lowerMan.asset') asset.request('./planets/earth/moon/moon') asset.request('./planets/mars/mars') diff --git a/ext/ghoul b/ext/ghoul index d35be27b61..bb94e276d7 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit d35be27b61140e76d8283999d9faee16977b1bfc +Subproject commit bb94e276d70aa0179889ba6ad2b8f9190b248463 diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index f850018ea2..1fd08bc8a8 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -39,7 +39,7 @@ namespace ghoul { class SharedMemory; } // ghoul namespace ghoul::fontrendering { class Font; } -namespace ghoul::opengl { class ProgramObject; } +namespace ghoul::opengl { class ProgramObject; class OpenGLStateCache; } namespace openspace { @@ -77,6 +77,8 @@ public: const Renderer& renderer() const; RendererImplementation rendererImplementation() const; + ghoul::opengl::OpenGLStateCache& openglStateCache(); + void updateShaderPrograms(); void updateRenderer(); void updateScreenSpaceRenderables(); @@ -187,6 +189,8 @@ private: ghoul::Dictionary _resolveData; ScreenLog* _log = nullptr; + ghoul::opengl::OpenGLStateCache* _openglStateCache; + properties::BoolProperty _showOverlayOnSlaves; properties::BoolProperty _showLog; properties::FloatProperty _verticalLogOffset; diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index 2191b59433..c94bc2d923 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include @@ -836,24 +837,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO, ghoul::opengl::TextureUnit deltaSMieTableTextureUnit; ghoul::opengl::TextureUnit deltaJTableTextureUnit; - // Saving current OpenGL state - GLboolean blendEnabled = glIsEnabled(GL_BLEND); - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - - if (blendEnabled) { - glDisable(GL_BLEND); - } - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); + glDisable(GL_BLEND); // =========================================================== // See Precomputed Atmosphere Scattering from Bruneton et al. paper, algorithm 4.1: @@ -1199,12 +1183,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO, } // Restores OpenGL blending state - if (blendEnabled) { - glEnable(GL_BLEND); - } - - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); + global::renderEngine.openglStateCache().setBlendState(); } void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { @@ -1223,9 +1202,9 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); GLint m_viewport[4]; - glGetIntegerv(GL_VIEWPORT, m_viewport); + global::renderEngine.openglStateCache().viewPort(m_viewport); - // Creates the FBO for the calculations + // Creates the FBO for the cFglGetalculations GLuint calcFBO; glGenFramebuffers(1, &calcFBO); glBindFramebuffer(GL_FRAMEBUFFER, calcFBO); @@ -1249,12 +1228,7 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { // Restores system state glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - glViewport( - m_viewport[0], - m_viewport[1], - m_viewport[2], - m_viewport[3] - ); + global::renderEngine.openglStateCache().setViewPortState(m_viewport); glDeleteBuffers(1, &quadCalcVBO); glDeleteVertexArrays(1, &quadCalcVAO); glDeleteFramebuffers(1, &calcFBO); diff --git a/modules/base/rendering/grids/renderableboxgrid.cpp b/modules/base/rendering/grids/renderableboxgrid.cpp index 603621c877..6d8feec0c1 100644 --- a/modules/base/rendering/grids/renderableboxgrid.cpp +++ b/modules/base/rendering/grids/renderableboxgrid.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -189,25 +190,6 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->setUniform("gridColor", _gridColor); - // Saves current state: - GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0); - GLfloat currentLineWidth; - glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); - GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH); - - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - // Changes GL state: glLineWidth(_lineWidth); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -221,17 +203,8 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - glLineWidth(currentLineWidth); - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - - if (!isBlendEnabled) { - glDisablei(GL_BLEND, 0); - } - - if (!isLineSmoothEnabled) { - glDisable(GL_LINE_SMOOTH); - } + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setLineState(); } void RenderableBoxGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index ab6b8f06e1..ca2a9246e1 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace { @@ -205,25 +206,6 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->setUniform("gridColor", _gridColor); - // Saves current state: - GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0); - GLfloat currentLineWidth; - glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); - GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH); - - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - // Changes GL state: glLineWidth(_lineWidth); glEnablei(GL_BLEND, 0); @@ -237,17 +219,8 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - glLineWidth(currentLineWidth); - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - - if (!isBlendEnabled) { - glDisablei(GL_BLEND, 0); - } - - if (!isLineSmoothEnabled) { - glDisable(GL_LINE_SMOOTH); - } + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setLineState(); } void RenderableGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderableradialgrid.cpp b/modules/base/rendering/grids/renderableradialgrid.cpp index 0e2e5315d8..c0df853352 100644 --- a/modules/base/rendering/grids/renderableradialgrid.cpp +++ b/modules/base/rendering/grids/renderableradialgrid.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace { @@ -266,25 +267,6 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) { adjustedLineWidth = _lineWidth; #endif - // Saves current state: - GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0); - GLfloat currentLineWidth; - glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); - GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH); - - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - // Changes GL state: glLineWidth(adjustedLineWidth); glEnablei(GL_BLEND, 0); @@ -300,17 +282,8 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) { _gridProgram->deactivate(); // Restores GL State - glLineWidth(currentLineWidth); - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - - if (!isBlendEnabled) { - glDisablei(GL_BLEND, 0); - } - - if (!isLineSmoothEnabled) { - glDisable(GL_LINE_SMOOTH); - } + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setLineState(); } void RenderableRadialGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderablesphericalgrid.cpp b/modules/base/rendering/grids/renderablesphericalgrid.cpp index 90fa4619d5..532f77768c 100644 --- a/modules/base/rendering/grids/renderablesphericalgrid.cpp +++ b/modules/base/rendering/grids/renderablesphericalgrid.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include namespace { @@ -209,25 +210,6 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ adjustedLineWidth = _lineWidth; #endif - // Saves current state: - GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0); - GLfloat currentLineWidth; - glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); - GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH); - - GLenum currentDepthFunction; - glGetIntegerv(GL_DEPTH_FUNC, ¤tDepthFunction); - glDepthFunc(GL_LEQUAL); - - GLenum blendEquationRGB, blendEquationAlpha, blendDestAlpha, - blendDestRGB, blendSrcAlpha, blendSrcRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - // Changes GL state: glLineWidth(adjustedLineWidth); glEnablei(GL_BLEND, 0); @@ -242,19 +224,8 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - glLineWidth(currentLineWidth); - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - - if (!isBlendEnabled) { - glDisablei(GL_BLEND, 0); - } - - if (!isLineSmoothEnabled) { - glDisable(GL_LINE_SMOOTH); - } - - glDepthFunc(currentDepthFunction); + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setLineState(); } void RenderableSphericalGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/renderablecartesianaxes.cpp b/modules/base/rendering/renderablecartesianaxes.cpp index ced04ad50e..bfc3928956 100644 --- a/modules/base/rendering/renderablecartesianaxes.cpp +++ b/modules/base/rendering/renderablecartesianaxes.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include namespace { @@ -233,21 +234,6 @@ void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&){ _program->setUniform("yColor", _yColor); _program->setUniform("zColor", _zColor); - // Saves current state: - GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0); - GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH); - GLfloat currentLineWidth; - glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); - - GLenum blendEquationRGB, blendEquationAlpha, blendDestAlpha, - blendDestRGB, blendSrcAlpha, blendSrcRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - // Changes GL state: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnablei(GL_BLEND, 0); @@ -261,15 +247,8 @@ void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&){ _program->deactivate(); // Restores GL State - glLineWidth(currentLineWidth); - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - if (!isBlendEnabled) { - glDisablei(GL_BLEND, 0); - } - if (!isLineSmoothEnabled) { - glDisable(GL_LINE_SMOOTH); - } + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setLineState(); } } // namespace openspace diff --git a/modules/base/rendering/renderablenodeline.cpp b/modules/base/rendering/renderablenodeline.cpp index 7fc1f26068..a1de634a64 100644 --- a/modules/base/rendering/renderablenodeline.cpp +++ b/modules/base/rendering/renderablenodeline.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include namespace { @@ -290,25 +291,6 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { _program->setUniform("projectionTransform", data.camera.projectionMatrix()); _program->setUniform("color", glm::vec4(_lineColor.value(), _opacity)); - // Save current state: - GLboolean isBlendEnabled = glIsEnabledi(GL_BLEND, 0); - GLboolean isLineSmoothEnabled = glIsEnabled(GL_LINE_SMOOTH); - GLfloat currentLineWidth; - glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); - - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - // Change GL state: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnablei(GL_BLEND, 0); @@ -322,15 +304,8 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { // Restore GL State unbindGL(); _program->deactivate(); - glLineWidth(currentLineWidth); - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - if (!isBlendEnabled) { - glDisablei(GL_BLEND, 0); - } - if (!isLineSmoothEnabled) { - glDisable(GL_LINE_SMOOTH); - } + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setLineState(); } void RenderableNodeLine::validateNodes() { diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index dab0c44e2b..7c01bdf16c 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include namespace { @@ -111,13 +112,16 @@ void ScreenSpaceFramebuffer::render() { if (!_renderFunctions.empty()) { GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); + //glGetIntegerv(GL_VIEWPORT, viewport); + global::renderEngine.openglStateCache().viewPort(viewport); glViewport( static_cast(-size.x * xratio), static_cast(-size.y * yratio), static_cast(resolution.x * xratio), static_cast(resolution.y * yratio) ); + global::renderEngine.openglStateCache().setViewPortState(viewport); + GLint defaultFBO = _framebuffer->getActiveObject(); _framebuffer->activate(); diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index caa8c1d84f..17896e43fd 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -779,28 +780,6 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, float fadeInVariable) { glDepthMask(false); - glEnable(GL_DEPTH_TEST); - - // Saving current OpenGL state - GLboolean blendEnabled = glIsEnabledi(GL_BLEND, 0); - - GLenum blendEquationRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - - GLenum blendEquationAlpha; - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - - GLenum blendDestAlpha; - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - - GLenum blendDestRGB; - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - - GLenum blendSrcAlpha; - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - - GLenum blendSrcRGB; - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); glEnablei(GL_BLEND, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -868,15 +847,8 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, glBindVertexArray(0); _program->deactivate(); - // Restores blending state - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - - if (!blendEnabled) { - glDisablei(GL_BLEND, 0); - } - - glDepthMask(true); + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setDepthState(); } diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index a9ce646b08..c9d286d840 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -448,30 +449,6 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, const glm::dmat4& modelViewMatrix, const glm::dmat4& projectionMatrix) { - // Saving current OpenGL state - GLfloat lineWidth = 1.0f; - glGetFloatv(GL_LINE_WIDTH, &lineWidth); - - GLboolean blendEnabled = glIsEnabledi(GL_BLEND, 0); - - GLenum blendEquationRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - - GLenum blendEquationAlpha; - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - - GLenum blendDestAlpha; - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - - GLenum blendDestRGB; - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - - GLenum blendSrcAlpha; - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - - GLenum blendSrcRGB; - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - glEnablei(GL_BLEND, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -495,7 +472,7 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, case Wire: glLineWidth(_lineWidth); glDrawArrays(GL_LINE_STRIP, 0, pair.second.numV); - glLineWidth(lineWidth); + global::renderEngine.openglStateCache().setLineState(); break; case Point: glDrawArrays(GL_POINTS, 0, pair.second.numV); @@ -509,15 +486,9 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, glBindVertexArray(0); _program->deactivate(); - // Restores blending state - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - - glDepthMask(true); - - if (!blendEnabled) { - glDisablei(GL_BLEND, 0); - } + // Restores GL State + global::renderEngine.openglStateCache().setDepthState(); + global::renderEngine.openglStateCache().setBlendState(); } void RenderableDUMeshes::renderLabels(const RenderData& data, diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index befa6a125e..a4e0bfd356 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -547,27 +548,6 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&, const glm::dmat4& projectionMatrix, const float fadeInVariable) { - // Saving current OpenGL state - GLboolean blendEnabled = glIsEnabledi(GL_BLEND, 0); - - GLenum blendEquationRGB; - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - - GLenum blendEquationAlpha; - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - - GLenum blendDestAlpha; - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - - GLenum blendDestRGB; - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - - GLenum blendSrcAlpha; - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - - GLenum blendSrcRGB; - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - glEnablei(GL_BLEND, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -610,15 +590,9 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&, glBindVertexArray(0); _program->deactivate(); - // Restores blending state - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - - glDepthMask(true); - - if (!blendEnabled) { - glDisablei(GL_BLEND, 0); - } + // Restores OpenGL Rendering State + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setDepthState(); } void RenderablePlanesCloud::renderLabels(const RenderData& data, diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index ba5a801649..fa9e4b6a51 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -632,23 +633,6 @@ void RenderableGalaxy::renderPoints(const RenderData& data) { if (!_pointsProgram) { return; } - // Saving current OpenGL state - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - GLboolean depthMask; - - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); - - glGetBooleanv(GL_DEPTH_WRITEMASK, &depthMask); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glDepthMask(false); @@ -697,14 +681,9 @@ void RenderableGalaxy::renderPoints(const RenderData& data) { _pointsProgram->deactivate(); - glEnable(GL_DEPTH_TEST); - glDepthMask(true); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - // Restores OpenGL blending state - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); - glDepthMask(depthMask); + // Restores OpenGL Rendering State + global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().setDepthState(); } void RenderableGalaxy::renderBillboards(const RenderData& data) { diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index d79aaca8a4..fc64a5ebc3 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include "cpl_minixml.h" @@ -209,9 +211,9 @@ Tile tile(TextTileProvider& t, const TileIndex& tileIndex) { // Keep track of defaultFBO and viewport to be able to reset state when done GLint defaultFBO; - GLint viewport[4]; + //GLint viewport[4]; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); - glGetIntegerv(GL_VIEWPORT, viewport); + //glGetIntegerv(GL_VIEWPORT, viewport); // Render to texture glBindFramebuffer(GL_FRAMEBUFFER, t.fbo); @@ -232,7 +234,8 @@ Tile tile(TextTileProvider& t, const TileIndex& tileIndex) { t.fontRenderer->render(*t.font, t.textPosition, t.text, t.textColor); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + global::renderEngine.openglStateCache().setViewPortState(); + //glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); tile = Tile{ texture, std::nullopt, Tile::Status::OK }; t.tileCache->put(key, t.initData.hashKey, tile); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 2778673233..8f4cc221bb 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -823,23 +824,8 @@ void RenderableStars::renderPSFToTexture() { GLint defaultFBO; glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); - GLint m_viewport[4]; - glGetIntegerv(GL_VIEWPORT, m_viewport); - - // Saving current OpenGL state - GLenum blendEquationRGB; - GLenum blendEquationAlpha; - GLenum blendDestAlpha; - GLenum blendDestRGB; - GLenum blendSrcAlpha; - GLenum blendSrcRGB; - - glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRGB); - glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); - glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); - glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRGB); - glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); - glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRGB); +// GLint m_viewport[4]; +// global::renderEngine.openglStateCache().viewPort(m_viewport); // Creates the FBO for the calculations GLuint psfFBO; @@ -941,8 +927,7 @@ void RenderableStars::renderPSFToTexture() { //glDeleteFramebuffers(1, &convolveFBO); // Restores OpenGL blending state - glBlendEquationSeparate(blendEquationRGB, blendEquationAlpha); - glBlendFuncSeparate(blendSrcRGB, blendDestRGB, blendSrcAlpha, blendDestAlpha); + global::renderEngine.openglStateCache().setBlendState(); } void RenderableStars::render(const RenderData& data, RendererTasks&) { diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 2319b58ea5..ac4edcd0bd 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -474,8 +475,22 @@ void FramebufferRenderer::initialize() { global::raycasterManager.addListener(*this); global::deferredcasterManager.addListener(*this); + // Set Default Rendering OpenGL State + + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); + glEnablei(GL_BLEND, 0); + glDisablei(GL_BLEND, 1); + glDisablei(GL_BLEND, 2); + + glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE); + + glEnable(GL_DEPTH_TEST); + // Default GL State for Blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Save State in Cache + global::renderEngine.openglStateCache().loadCurrentGLState(); } void FramebufferRenderer::deinitialize() { @@ -1159,22 +1174,14 @@ void FramebufferRenderer::updateDownscaledVolume() { void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFactor) { ZoneScoped + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); + GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); + global::renderEngine.openglStateCache().viewPort(viewport); - { - // Set OpenGL default rendering state - ZoneScopedN("Setting OpenGL state") + // Set Render Pipeline State + global::renderEngine.openglStateCache().setCachedStates(); - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); - glEnablei(GL_BLEND, 0); - glDisablei(GL_BLEND, 1); - glDisablei(GL_BLEND, 2); - - glClampColor(GL_CLAMP_READ_COLOR, GL_FALSE); - - glEnable(GL_DEPTH_TEST); - } _pingPongIndex = 0; // Measurements cache variable @@ -1531,6 +1538,9 @@ void FramebufferRenderer::performDeferredTasks( void FramebufferRenderer::setResolution(glm::ivec2 res) { _resolution = std::move(res); _dirtyResolution = true; + GLint newViewPortCoors[4]; + glGetIntegerv(GL_VIEWPORT, newViewPortCoors); + global::renderEngine.openglStateCache().setViewPortState(newViewPortCoors); } void FramebufferRenderer::setDisableHDR(bool disable) { diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index d429cd8d46..0edbfb1e0e 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include #ifdef GHOUL_USE_DEVIL @@ -944,6 +945,13 @@ RenderEngine::RendererImplementation RenderEngine::rendererImplementation() cons return _rendererImplementation; } +ghoul::opengl::OpenGLStateCache& RenderEngine::openglStateCache() { + if (_openglStateCache == nullptr) { + _openglStateCache = ghoul::opengl::OpenGLStateCache::getInstance(); + } + return *_openglStateCache; +} + float RenderEngine::globalBlackOutFactor() { return _globalBlackOutFactor; } From d9e03f402d21a5857e9e9f631d1f86785e7988f2 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Fri, 31 Jul 2020 16:01:29 -0400 Subject: [PATCH 02/11] Added missing files. --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index bb94e276d7..082f918c76 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit bb94e276d70aa0179889ba6ad2b8f9190b248463 +Subproject commit 082f918c7655728e826310ccd54d2da5437332d9 From 3d87a6b76a081e450f406067beb66b4b244ff2ad Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 10 Aug 2020 16:27:07 -0400 Subject: [PATCH 03/11] One less call to the cache. --- ext/ghoul | 2 +- src/rendering/framebufferrenderer.cpp | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 082f918c76..d4cc5f5abb 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 082f918c7655728e826310ccd54d2da5437332d9 +Subproject commit d4cc5f5abb8a27dae21f169968125d1386c3439f diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index ac4edcd0bd..f544e07025 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -1176,7 +1176,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); - GLint viewport[4]; + GLint viewport[4] = {0}; global::renderEngine.openglStateCache().viewPort(viewport); // Set Render Pipeline State @@ -1203,7 +1203,10 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac ZoneScopedN("Deferred G-Buffer") TracyGpuZone("Deferred G-Buffer") - glViewport(0, 0, _resolution.x, _resolution.y); + //glViewport(0, 0, _resolution.x, _resolution.y); + GLint vp[4] = {viewport[0], viewport[1], _resolution.x, _resolution.y}; + //GLint vp[4] = {0, 0, _resolution.x, _resolution.y}; + global::renderEngine.openglStateCache().setViewPortState(vp); glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); glDrawBuffers(3, ColorAttachment012Array); @@ -1293,8 +1296,6 @@ 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) { glBindFramebuffer(GL_FRAMEBUFFER, _fxaaBuffers.fxaaFramebuffer); glDrawBuffers(1, ColorAttachment0Array); @@ -1329,8 +1330,8 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector glBindFramebuffer(GL_FRAMEBUFFER, _exitFramebuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); + GLint viewport[4] = {0}; + global::renderEngine.openglStateCache().viewPort(viewport); ghoul::opengl::ProgramObject* exitProgram = _exitPrograms[raycaster].get(); if (exitProgram) { @@ -1342,12 +1343,14 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector if (raycaster->downscaleRender() < 1.f) { glBindFramebuffer(GL_FRAMEBUFFER, _downscaleVolumeRendering.framebuffer); const float s = raycaster->downscaleRender(); - glViewport( + GLint newVP[4] = { viewport[0], viewport[1], static_cast(viewport[2] * s), static_cast(viewport[3] * s) - ); + }; + global::renderEngine.openglStateCache().setViewPortState(newVP); + if (_downscaleVolumeRendering.currentDownscaleFactor != s) { _downscaleVolumeRendering.currentDownscaleFactor = s; updateDownscaleTextures(); @@ -1443,7 +1446,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector } if (raycaster->downscaleRender() < 1.f) { - glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + global::renderEngine.openglStateCache().setViewPortState(viewport); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _gBuffers.framebuffer); writeDownscaledVolume(); } @@ -1538,9 +1541,6 @@ void FramebufferRenderer::performDeferredTasks( void FramebufferRenderer::setResolution(glm::ivec2 res) { _resolution = std::move(res); _dirtyResolution = true; - GLint newViewPortCoors[4]; - glGetIntegerv(GL_VIEWPORT, newViewPortCoors); - global::renderEngine.openglStateCache().setViewPortState(newViewPortCoors); } void FramebufferRenderer::setDisableHDR(bool disable) { From b7886ab463d667953bbb33c0018f947b3b5773fc Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Thu, 20 Aug 2020 11:53:10 -0400 Subject: [PATCH 04/11] Updated Ghoul and removed unused code. --- ext/ghoul | 2 +- src/rendering/framebufferrenderer.cpp | 38 +++++---------------------- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index d4cc5f5abb..40c28e3d56 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit d4cc5f5abb8a27dae21f169968125d1386c3439f +Subproject commit 40c28e3d56db391fdf87b5821f5005853e88dc6e diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index f544e07025..d0fe84d5ff 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -98,31 +98,7 @@ namespace { constexpr const char* RenderFragmentShaderPath = "${SHADERS}/framebuffer/renderframebuffer.frag"; - const GLenum ColorAttachment0Array[1] = { - GL_COLOR_ATTACHMENT0 - }; - - const GLenum ColorAttachment1Array[1] = { - GL_COLOR_ATTACHMENT1 - }; - - const GLenum ColorAttachment01Array[2] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1 - }; - - const GLenum ColorAttachment03Array[2] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT3 - }; - - const GLenum ColorAttachment012Array[3] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1, - GL_COLOR_ATTACHMENT2 - }; - - const GLenum ColorAttachment0123Array[4] = { + const GLenum ColorAttachmentArray[4] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, @@ -1203,13 +1179,11 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac ZoneScopedN("Deferred G-Buffer") TracyGpuZone("Deferred G-Buffer") - //glViewport(0, 0, _resolution.x, _resolution.y); GLint vp[4] = {viewport[0], viewport[1], _resolution.x, _resolution.y}; - //GLint vp[4] = {0, 0, _resolution.x, _resolution.y}; global::renderEngine.openglStateCache().setViewPortState(vp); glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); - glDrawBuffers(3, ColorAttachment012Array); + glDrawBuffers(3, ColorAttachmentArray); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } Time time = global::timeManager.time(); @@ -1265,7 +1239,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac // 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]); + glDrawBuffers(1, &ColorAttachmentArray[_pingPongIndex]); std::unique_ptr perfInternal; if (doPerformanceMeasurements) { @@ -1276,7 +1250,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac performDeferredTasks(tasks.deferredcasterTasks); } - glDrawBuffers(1, &ColorAttachment01Array[_pingPongIndex]); + glDrawBuffers(1, &ColorAttachmentArray[_pingPongIndex]); glEnablei(GL_BLEND, 0); { @@ -1298,7 +1272,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac if (_enableFXAA) { glBindFramebuffer(GL_FRAMEBUFFER, _fxaaBuffers.fxaaFramebuffer); - glDrawBuffers(1, ColorAttachment0Array); + glDrawBuffers(1, ColorAttachmentArray); glDisable(GL_BLEND); } @@ -1472,7 +1446,7 @@ void FramebufferRenderer::performDeferredTasks( if (deferredcastProgram) { _pingPongIndex = _pingPongIndex == 0 ? 1 : 0; int fromIndex = _pingPongIndex == 0 ? 1 : 0; - glDrawBuffers(1, &ColorAttachment01Array[_pingPongIndex]); + glDrawBuffers(1, &ColorAttachmentArray[_pingPongIndex]); glDisablei(GL_BLEND, 0); glDisablei(GL_BLEND, 1); From f0c397d6be5a32022b38c316e6b6d83d499b6355 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Thu, 20 Aug 2020 15:34:40 -0400 Subject: [PATCH 05/11] Merged maste. Changed code in multiple places to have the new memory pool working on linux (experimental yet). --- CMakeLists.txt | 19 - apps/OpenSpace/CMakeLists.txt | 1 + apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 192 -------- data/assets/base.asset | 6 +- data/assets/examples/volume/toyvolume.asset | 4 +- data/assets/scene/digitaluniverse/abell.asset | 2 +- .../digitaluniverse/alternatestarlabels.asset | 2 +- .../scene/digitaluniverse/clusters.asset | 2 +- .../digitaluniverse/constellations.asset | 14 +- .../scene/digitaluniverse/deepsky.asset | 4 +- .../assets/scene/digitaluniverse/dwarfs.asset | 2 +- .../scene/digitaluniverse/exoplanets.asset | 2 +- .../digitaluniverse/globularclusters.asset | 2 +- data/assets/scene/digitaluniverse/grids.asset | 84 ++-- .../assets/scene/digitaluniverse/groups.asset | 2 +- .../scene/digitaluniverse/h2regions.asset | 2 +- .../scene/digitaluniverse/localdwarfs.asset | 2 +- .../scene/digitaluniverse/milkyway.asset | 4 +- .../digitaluniverse/obassociations.asset | 2 +- .../scene/digitaluniverse/openclusters.asset | 2 +- .../digitaluniverse/planetarynebulae.asset | 2 +- .../scene/digitaluniverse/pulsars.asset | 2 +- .../scene/digitaluniverse/starlabels.asset | 2 +- .../scene/digitaluniverse/starorbits.asset | 42 +- data/assets/scene/digitaluniverse/stars.asset | 2 +- .../scene/digitaluniverse/superclusters.asset | 2 +- .../digitaluniverse/supernovaremnants.asset | 2 +- data/assets/scene/digitaluniverse/tully.asset | 4 +- data/assets/scene/digitaluniverse/voids.asset | 2 +- .../dwarf_planets/pluto/charon.asset | 64 --- .../dwarf_planets/pluto/charon_trail.asset | 28 -- .../dwarf_planets/pluto/hydra.asset | 51 -- .../dwarf_planets/pluto/kerberos.asset | 51 -- .../solarsystem/dwarf_planets/pluto/nix.asset | 51 -- .../dwarf_planets/pluto/pluto.asset | 13 +- .../dwarf_planets/pluto/styx.asset | 51 -- .../dwarf_planets/pluto/system.asset | 12 +- .../missions/newhorizons/charon.asset | 1 + .../missions/newhorizons/pluto.asset | 1 + .../solarsystem/planets/earth/earth.asset | 250 +--------- .../solarsystem/planets/earth/moon/moon.asset | 116 +---- .../planets/earth/satellites/misc/iss.asset | 1 + .../planets/jupiter/callisto/callisto.asset | 21 +- .../planets/jupiter/europa/europa.asset | 30 +- .../planets/jupiter/ganymede/ganymede.asset | 21 +- .../solarsystem/planets/jupiter/io/io.asset | 21 +- .../solarsystem/planets/jupiter/jupiter.asset | 19 +- .../scene/solarsystem/planets/mars/mars.asset | 164 +------ .../planets/mars/moons/deimos.asset | 2 +- .../planets/mars/moons/phobos.asset | 2 +- .../solarsystem/planets/mercury/mercury.asset | 182 +------ .../solarsystem/planets/neptune/neptune.asset | 17 +- .../planets/saturn/dione/dione.asset | 21 +- .../planets/saturn/enceladus/enceladus.asset | 28 +- .../planets/saturn/iapetus/iapetus.asset | 21 +- .../planets/saturn/mimas/mimas.asset | 21 +- .../planets/saturn/rhea/rhea.asset | 21 +- .../solarsystem/planets/saturn/saturn.asset | 12 +- .../planets/saturn/tethys/tethys.asset | 21 +- .../planets/saturn/titan/titan.asset | 28 +- .../solarsystem/planets/uranus/uranus.asset | 19 +- .../solarsystem/planets/venus/venus.asset | 52 +- data/assets/scene/solarsystem/sun/sun.asset | 11 +- data/assets/util/debug_helper.asset | 10 +- data/assets/util/generate_bookmarks.asset | 3 +- include/openspace/engine/globals.h | 7 +- .../interaction/camerainteractionstates.h | 1 - .../interaction/joystickcamerastates.h | 42 +- .../interaction/joystickinputstate.h | 21 +- .../openspace/interaction/orbitalnavigator.h | 9 +- .../interaction/websocketcamerastates.h | 42 +- .../interaction/websocketinputstate.h | 21 +- .../openspace/performance/performancelayout.h | 61 --- .../performance/performancemanager.h | 94 ---- .../performance/performancemeasurement.h | 55 --- include/openspace/rendering/renderable.h | 3 +- include/openspace/rendering/renderengine.h | 2 - include/openspace/scene/rotation.h | 3 +- include/openspace/scene/scale.h | 3 +- include/openspace/scene/scene.h | 7 +- include/openspace/scene/scenegraphnode.h | 35 +- include/openspace/scene/timeframe.h | 3 +- include/openspace/scene/translation.h | 3 +- include/openspace/util/factorymanager.h | 6 +- include/openspace/util/screenlog.h | 5 +- include/openspace/util/updatestructures.h | 2 - .../rendering/atmospheredeferredcaster.cpp | 83 ++-- .../rendering/atmospheredeferredcaster.h | 7 + .../rendering/renderableatmosphere.h | 2 - modules/base/dashboard/dashboarditemangle.cpp | 5 +- modules/base/dashboard/dashboarditemdate.cpp | 5 +- .../base/dashboard/dashboarditemdistance.cpp | 5 +- .../base/dashboard/dashboarditemframerate.cpp | 13 +- .../dashboarditemparallelconnection.cpp | 5 +- .../dashboard/dashboarditempropertyvalue.cpp | 5 +- .../dashboarditemsimulationincrement.cpp | 5 +- .../base/dashboard/dashboarditemvelocity.cpp | 5 +- modules/base/rendering/modelgeometry.cpp | 3 +- .../rendering/renderablecartesianaxes.cpp | 30 +- .../base/rendering/renderablecartesianaxes.h | 8 +- modules/base/rendering/renderablelabels.cpp | 17 +- modules/base/rendering/renderablelabels.h | 4 +- modules/base/rendering/renderablemodel.cpp | 4 +- modules/base/rendering/renderablesphere.cpp | 14 +- modules/base/rendering/renderabletrail.cpp | 219 +++++---- modules/base/rendering/renderabletrail.h | 22 +- .../base/rendering/renderabletrailorbit.cpp | 11 +- .../rendering/renderabletrailtrajectory.cpp | 3 +- modules/base/rotation/timelinerotation.cpp | 4 +- modules/base/rotation/timelinerotation.h | 2 +- modules/base/shaders/axes_fs.glsl | 9 +- modules/base/timeframe/timeframeunion.h | 2 +- .../base/translation/timelinetranslation.cpp | 4 +- .../base/translation/timelinetranslation.h | 3 +- .../rendering/renderablebillboardscloud.cpp | 36 +- .../rendering/renderablebillboardscloud.h | 4 +- .../rendering/renderabledumeshes.cpp | 108 ++--- .../rendering/renderabledumeshes.h | 10 +- .../rendering/renderableplanescloud.cpp | 60 ++- .../rendering/renderableplanescloud.h | 5 +- .../rendering/renderablepoints.cpp | 26 +- .../rendering/renderablepoints.h | 1 - modules/globebrowsing/CMakeLists.txt | 1 - modules/globebrowsing/shaders/rings_fs.glsl | 13 +- .../src/dashboarditemglobelocation.cpp | 5 +- .../src/globelabelscomponent.cpp | 40 +- .../globebrowsing/src/globelabelscomponent.h | 5 +- modules/globebrowsing/src/layergroupid.cpp | 74 --- modules/globebrowsing/src/layergroupid.h | 50 +- .../globebrowsing/src/rawtiledatareader.cpp | 2 +- modules/globebrowsing/src/renderableglobe.cpp | 19 +- modules/globebrowsing/src/renderableglobe.h | 3 + modules/globebrowsing/src/ringscomponent.cpp | 28 +- modules/globebrowsing/src/ringscomponent.h | 4 +- modules/globebrowsing/src/shadowcomponent.cpp | 1 - modules/globebrowsing/src/tileprovider.cpp | 12 +- modules/globebrowsing/src/timequantizer.cpp | 6 + modules/imgui/CMakeLists.txt | 4 +- modules/imgui/imguimodule.cpp | 16 +- modules/imgui/include/gui.h | 7 +- .../imgui/include/guiperformancecomponent.h | 57 --- modules/imgui/src/gui.cpp | 10 +- modules/imgui/src/guiperformancecomponent.cpp | 457 ----------------- .../rendering/localtfbrickselector.cpp | 1 + .../rendering/simpletfbrickselector.cpp | 1 + .../rendering/tfbrickselector.cpp | 1 + modules/server/src/connection.cpp | 12 +- .../src/topics/flightcontrollertopic.cpp | 64 ++- modules/space/rendering/planetgeometry.cpp | 4 +- .../rendering/renderableorbitalkepler.cpp | 3 +- modules/space/rendering/renderablerings.cpp | 28 +- modules/space/rendering/renderablerings.h | 4 +- modules/space/rendering/renderablestars.cpp | 24 +- modules/space/rendering/renderablestars.h | 5 +- modules/space/rotation/spicerotation.h | 2 +- modules/space/shaders/rings_fs.glsl | 14 +- modules/space/shaders/star_fs.glsl | 8 +- .../space/translation/spicetranslation.cpp | 43 +- modules/space/translation/spicetranslation.h | 8 + .../dashboard/dashboarditeminstruments.cpp | 25 +- .../rendering/renderablecrawlingline.cpp | 5 +- .../rendering/renderablefov.cpp | 49 +- .../rendering/renderablefov.h | 22 +- .../rendering/renderableshadowcylinder.cpp | 21 +- .../rendering/renderableshadowcylinder.h | 6 +- .../spacecraftinstruments/shaders/fov_vs.glsl | 32 +- .../shaders/terminatorshadow_fs.glsl | 8 +- .../shaders/terminatorshadow_vs.glsl | 9 +- .../spacecraftinstruments/util/decoder.cpp | 4 +- modules/sync/syncmodule.cpp | 42 +- modules/touch/include/touchmarker.h | 4 +- modules/touch/shaders/marker_fs.glsl | 4 +- modules/touch/src/touchmarker.cpp | 14 +- .../rendering/renderabletoyvolume.cpp | 14 +- .../toyvolume/rendering/renderabletoyvolume.h | 3 +- src/CMakeLists.txt | 7 +- src/engine/globals.cpp | 14 +- src/engine/openspaceengine.cpp | 49 -- src/interaction/joystickcamerastates.cpp | 51 +- src/interaction/joystickinputstate.cpp | 28 -- src/interaction/orbitalnavigator.cpp | 14 +- src/interaction/websocketcamerastates.cpp | 49 +- src/interaction/websocketinputstate.cpp | 29 +- src/performance/performancelayout.cpp | 45 -- src/performance/performancemanager.cpp | 458 ------------------ src/performance/performancemeasurement.cpp | 53 -- src/rendering/dashboarditem.cpp | 3 +- src/rendering/framebufferrenderer.cpp | 52 -- src/rendering/loadingscreen.cpp | 25 +- src/rendering/luaconsole.cpp | 30 +- src/rendering/renderable.cpp | 17 +- src/rendering/renderengine.cpp | 159 +++--- src/rendering/screenspacerenderable.cpp | 10 +- src/scene/lightsource.cpp | 8 +- src/scene/rotation.cpp | 12 +- src/scene/scale.cpp | 12 +- src/scene/scene.cpp | 37 +- src/scene/scene_lua.inl | 4 +- src/scene/scenegraphnode.cpp | 180 +++---- src/scene/timeframe.cpp | 12 +- src/scene/translation.cpp | 13 +- src/util/resourcesynchronization.cpp | 3 +- src/util/screenlog.cpp | 6 +- src/util/spicemanager.cpp | 259 ++++++---- src/util/task.cpp | 4 +- src/util/time.cpp | 60 +-- src/util/timemanager.cpp | 2 + 208 files changed, 1484 insertions(+), 4542 deletions(-) delete mode 100644 data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset delete mode 100644 data/assets/scene/solarsystem/dwarf_planets/pluto/charon_trail.asset delete mode 100644 data/assets/scene/solarsystem/dwarf_planets/pluto/hydra.asset delete mode 100644 data/assets/scene/solarsystem/dwarf_planets/pluto/kerberos.asset delete mode 100644 data/assets/scene/solarsystem/dwarf_planets/pluto/nix.asset delete mode 100644 data/assets/scene/solarsystem/dwarf_planets/pluto/styx.asset delete mode 100644 include/openspace/performance/performancelayout.h delete mode 100644 include/openspace/performance/performancemanager.h delete mode 100644 include/openspace/performance/performancemeasurement.h delete mode 100644 modules/globebrowsing/src/layergroupid.cpp delete mode 100644 modules/imgui/include/guiperformancecomponent.h delete mode 100644 modules/imgui/src/guiperformancecomponent.cpp delete mode 100644 src/performance/performancelayout.cpp delete mode 100644 src/performance/performancemanager.cpp delete mode 100644 src/performance/performancemeasurement.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f0853c7b30..78f9078edb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,25 +202,6 @@ if (APPLE) endif () if (MSVC) - option(OPENSPACE_ENABLE_VLD "Enable the Visual Leak Detector" OFF) - if (OPENSPACE_ENABLE_VLD) - begin_dependency("Visual Leak Detector") - target_compile_definitions(openspace-core PUBLIC "OPENSPACE_ENABLE_VLD") - target_link_libraries(openspace-core ${OPENSPACE_EXT_DIR}/vld/lib/vld.lib) - target_include_directories(openspace-core PUBLIC ${OPENSPACE_EXT_DIR}/vld) - end_dependency() - endif () - - option(OPENSPACE_VTUNE_ENABLED "Include VTune support" OFF) - set(OPENSPACE_VTUNE_PATH "C:/Program Files (x86)/IntelSWTools/VTune Amplifier 2019" CACHE STRING "Path to VTune installation") - if (OPENSPACE_VTUNE_ENABLED) - begin_dependency("Intel VTune") - target_compile_definitions(openspace-core PUBLIC "OPENSPACE_HAS_VTUNE") - target_include_directories(openspace-core PUBLIC "${OPENSPACE_VTUNE_PATH}/include") - target_link_libraries(openspace-core "${OPENSPACE_VTUNE_PATH}/lib64/libittnotify.lib") - end_dependency() - endif () - option(OPENSPACE_NVTOOLS_ENABLED "Include support for Nvidia Tools Extensions" OFF) set(OPENSPACE_NVTOOLS_PATH "C:/Program Files/NVIDIA Corporation/NvToolsExt") if (OPENSPACE_NVTOOLS_ENABLED) diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index 4f948c3257..23d3ca787a 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -112,6 +112,7 @@ begin_header("Dependency: SGCT") set(SGCT_TEXT OFF CACHE BOOL "" FORCE) set(SGCT_DEP_INCLUDE_FREETYPE OFF CACHE BOOL "" FORCE) +set(SGCT_DEP_INCLUDE_FMT 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 f3094de5ba..b712e64848 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit f3094de5ba02d86ee899f4108cf066e37652c65e +Subproject commit b712e6484894d70a60277bdcf719613b217954a7 diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index b4860fdeaf..80e5ff01cb 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -82,14 +82,6 @@ #include "SpoutLibrary.h" #endif // OPENSPACE_HAS_SPOUT -#ifdef OPENSPACE_HAS_VTUNE -#include - -// If this is set to 'true', it will disable all frame markers in this file and expect -// you to place them in the code you actually want to inspect -constexpr const bool EnableDetailedVtune = false; -#endif // OPENSPACE_HAS_VTUNE - #ifdef OPENSPACE_HAS_NVTOOLS #include "nvToolsExt.h" #endif // OPENSPACE_HAS_NVTOOLS @@ -114,26 +106,6 @@ glm::mat4 currentModelMatrix; Window* FirstOpenVRWindow = nullptr; #endif -#ifdef OPENSPACE_HAS_VTUNE - -struct { - __itt_domain* init; - __itt_domain* preSync; - __itt_domain* postSyncPreDraw; - __itt_domain* render; - __itt_domain* draw2D; - __itt_domain* postDraw; - __itt_domain* keyboard; - __itt_domain* mouseButton; - __itt_domain* mousePos; - __itt_domain* mouseScroll; - __itt_domain* character; - __itt_domain* encode; - __itt_domain* decode; -} _vTune; - -#endif // OPENSPACE_HAS_VTUNE - // // SPOUT-support // @@ -242,11 +214,6 @@ LONG WINAPI generateMiniDump(EXCEPTION_POINTERS* exceptionPointers) { void mainInitFunc(GLFWwindow*) { ZoneScoped -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.init, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainInitFunc(begin)"); LDEBUG("Initializing OpenSpace Engine started"); @@ -371,23 +338,12 @@ void mainInitFunc(GLFWwindow*) { LTRACE("main::mainInitFunc(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.init, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } void mainPreSyncFunc() { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.preSync, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainPreSyncFunc(begin)"); try { @@ -474,11 +430,6 @@ void mainPreSyncFunc() { } LTRACE("main::mainPreSyncFunc(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.preSync, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } @@ -486,11 +437,6 @@ void mainPreSyncFunc() { void mainPostSyncPreDrawFunc() { ZoneScoped -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.postSyncPreDraw, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE #ifdef OPENSPACE_HAS_NVTOOLS nvtxRangePush("postSyncPreDraw"); #endif // OPENSPACE_HAS_NVTOOLS @@ -510,11 +456,6 @@ void mainPostSyncPreDrawFunc() { #ifdef OPENSPACE_HAS_NVTOOLS nvtxRangePop(); #endif // OPENSPACE_HAS_NVTOOLS -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.postSyncPreDraw, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } @@ -522,11 +463,6 @@ void mainPostSyncPreDrawFunc() { void mainRenderFunc(const sgct::RenderData& data) { ZoneScoped -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.render, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE #ifdef OPENSPACE_HAS_NVTOOLS nvtxRangePush("render"); #endif // OPENSPACE_HAS_NVTOOLS @@ -585,23 +521,12 @@ void mainRenderFunc(const sgct::RenderData& data) { #ifdef OPENSPACE_HAS_NVTOOLS nvtxRangePop(); #endif // OPENSPACE_HAS_NVTOOLS -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.render, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } void mainDraw2DFunc(const sgct::RenderData& data) { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.draw2D, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainDraw2DFunc(begin)"); currentWindow = &data.window; @@ -621,23 +546,12 @@ void mainDraw2DFunc(const sgct::RenderData& data) { glDisable(GL_DEPTH_TEST); LTRACE("main::mainDraw2DFunc(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.draw2D, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } void mainPostDrawFunc() { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.postDraw, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainPostDrawFunc(begin)"); #ifdef OPENVR_SUPPORT @@ -678,11 +592,6 @@ void mainPostDrawFunc() { #endif // OPENSPACE_HAS_SPOUT LTRACE("main::mainPostDrawFunc(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.postDraw, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } @@ -691,12 +600,6 @@ void mainKeyboardCallback(sgct::Key key, sgct::Modifier modifiers, sgct::Action int) { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.keyboard, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainKeyboardCallback(begin)"); const openspace::Key k = openspace::Key(key); @@ -705,11 +608,6 @@ void mainKeyboardCallback(sgct::Key key, sgct::Modifier modifiers, sgct::Action global::openSpaceEngine.keyboardCallback(k, m, a); LTRACE("main::mainKeyboardCallback(begin)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.keyboard, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } @@ -718,12 +616,6 @@ void mainMouseButtonCallback(sgct::MouseButton key, sgct::Modifier modifiers, sgct::Action action) { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.mouseButton, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainMouseButtonCallback(begin)"); const openspace::MouseButton k = openspace::MouseButton(key); @@ -732,53 +624,24 @@ void mainMouseButtonCallback(sgct::MouseButton key, sgct::Modifier modifiers, global::openSpaceEngine.mouseButtonCallback(k, a, m); LTRACE("main::mainMouseButtonCallback(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.mouseButton, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } void mainMousePosCallback(double x, double y) { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.mousePos, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE - global::openSpaceEngine.mousePositionCallback(x, y); - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.mousePos, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } void mainMouseScrollCallback(double posX, double posY) { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.mouseScroll, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainMouseScrollCallback(begin"); global::openSpaceEngine.mouseScrollWheelCallback(posX, posY); LTRACE("main::mainMouseScrollCallback(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.mouseScroll, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } @@ -786,43 +649,19 @@ void mainMouseScrollCallback(double posX, double posY) { void mainCharCallback(unsigned int codepoint, int modifiers) { ZoneScoped -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.character, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE - const KeyModifier m = KeyModifier(modifiers); global::openSpaceEngine.charCallback(codepoint, m); - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.character, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } std::vector mainEncodeFun() { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.encode, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainEncodeFun(begin)"); std::vector data = global::openSpaceEngine.encode(); LTRACE("main::mainEncodeFun(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.encode, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE - return data; } @@ -830,22 +669,11 @@ std::vector mainEncodeFun() { void mainDecodeFun(const std::vector& data, unsigned int) { ZoneScoped - -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_begin_v3(_vTune.decode, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE LTRACE("main::mainDecodeFun(begin)"); global::openSpaceEngine.decode(data); LTRACE("main::mainDecodeFun(end)"); -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - __itt_frame_end_v3(_vTune.decode, nullptr); - } -#endif // OPENSPACE_HAS_VTUNE } @@ -854,7 +682,6 @@ void mainLogCallback(Log::Level level, const char* message) { ZoneScoped std::string msg = message; - // Remove the trailing \n that is passed along switch (level) { case Log::Level::Debug: LDEBUGC("SGCT", msg); @@ -1102,25 +929,6 @@ int main(int argc, char** argv) { SetUnhandledExceptionFilter(generateMiniDump); #endif // WIN32 -#ifdef OPENSPACE_HAS_VTUNE - if (EnableDetailedVtune) { - _vTune.init = __itt_domain_create("init"); - _vTune.preSync = __itt_domain_create("preSync"); - _vTune.postSyncPreDraw = __itt_domain_create("postSyncPreDraw"); - _vTune.render = __itt_domain_create("render"); - _vTune.draw2D = __itt_domain_create("draw2D"); - _vTune.postDraw = __itt_domain_create("postDraw"); - _vTune.keyboard = __itt_domain_create("keyboard"); - _vTune.mouseButton = __itt_domain_create("mouseButton"); - _vTune.mousePos = __itt_domain_create("mousePos"); - _vTune.mouseScroll = __itt_domain_create("mouseScroll"); - _vTune.character = __itt_domain_create("character"); - _vTune.encode = __itt_domain_create("encode"); - _vTune.decode = __itt_domain_create("decode"); - } -#endif // OPENSPACE_HAS_VTUNE - - // Initialize the LogManager and add the console log as this will be used every time // and we need a fall back if something goes wrong between here and when we add the // logs from the configuration file. If the user requested as specific loglevel in the diff --git a/data/assets/base.asset b/data/assets/base.asset index 2901360c27..6646492c9b 100644 --- a/data/assets/base.asset +++ b/data/assets/base.asset @@ -11,10 +11,14 @@ asset.require('spice/base') asset.require('scene/solarsystem/sun/sun') asset.require('scene/solarsystem/sun/glare') -asset.require('scene/solarsystem/planets') +asset.require('scene/solarsystem/sun/default_layers') +asset.require('scene/solarsystem/planets/planets') +asset.require('scene/solarsystem/planets/default_layers') asset.require('scene/solarsystem/planets/mars/moons/phobos') asset.require('scene/solarsystem/planets/mars/moons/deimos') asset.require('scene/solarsystem/dwarf_planets/pluto/system') +asset.require('scene/solarsystem/dwarf_planets/pluto/default_layers') +asset.require('scene/solarsystem/dwarf_planets/pluto/charon/default_layers') asset.request('scene/milkyway/milkyway/volume') asset.request('scene/milkyway/constellations/constellation_art') asset.request('scene/milkyway/constellations/constellation_keybinds') diff --git a/data/assets/examples/volume/toyvolume.asset b/data/assets/examples/volume/toyvolume.asset index 93730536f1..a52f4d879d 100644 --- a/data/assets/examples/volume/toyvolume.asset +++ b/data/assets/examples/volume/toyvolume.asset @@ -8,10 +8,10 @@ local ToyVolume = { Parent = transforms.SolarSystemBarycenter.Identifier, Renderable = { Type = "RenderableToyVolume", - Size = {5, 5, 5}, + Size = { 5, 5, 5 }, ScalingExponent = 11, StepSize = 0.01, - Color = {1, 0, 0, 1} + Color = { 1, 0, 0 } }, GUI = { Path = "/Examples" diff --git a/data/assets/scene/digitaluniverse/abell.asset b/data/assets/scene/digitaluniverse/abell.asset index 287eab6c52..80b5bbbe94 100644 --- a/data/assets/scene/digitaluniverse/abell.asset +++ b/data/assets/scene/digitaluniverse/abell.asset @@ -27,7 +27,7 @@ local object = { File = speck .. "/abell.speck", Texture = textures .. "/point3A.png", LabelFile = speck .. "/abell.label", - TextColor = { 0.0, 0.8, 0.0, 1.0 }, + TextColor = { 0.0, 0.8, 0.0 }, TextSize = 22, TextMinSize = 10.0, Unit = "Mpc", diff --git a/data/assets/scene/digitaluniverse/alternatestarlabels.asset b/data/assets/scene/digitaluniverse/alternatestarlabels.asset index 2289f24eae..dcef9924a2 100644 --- a/data/assets/scene/digitaluniverse/alternatestarlabels.asset +++ b/data/assets/scene/digitaluniverse/alternatestarlabels.asset @@ -17,7 +17,7 @@ local object = { Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, LabelFile = speck .. "/stars-altlbl.label", - TextColor = { 0.4, 0.4, 0.4, 1.0 }, + TextColor = { 0.4, 0.4, 0.4 }, DrawLabels = true, TextSize = 14.7, TextMinSize = 6.0, diff --git a/data/assets/scene/digitaluniverse/clusters.asset b/data/assets/scene/digitaluniverse/clusters.asset index f0bb7ac5ea..3f0475d98b 100644 --- a/data/assets/scene/digitaluniverse/clusters.asset +++ b/data/assets/scene/digitaluniverse/clusters.asset @@ -17,7 +17,7 @@ local object = { Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, LabelFile = speck .. "/galclust.label", - TextColor = { 1.0, 0.44, 0.0, 1.0 }, + TextColor = { 1.0, 0.44, 0.0 }, DrawLabels = true, TextSize = 22, TextMinSize = 8.0, diff --git a/data/assets/scene/digitaluniverse/constellations.asset b/data/assets/scene/digitaluniverse/constellations.asset index d7aea41f79..216a320283 100644 --- a/data/assets/scene/digitaluniverse/constellations.asset +++ b/data/assets/scene/digitaluniverse/constellations.asset @@ -14,12 +14,11 @@ local constellationsExtragalactic = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 0.4, 0.2 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/constellationsEXGAL.speck", LabelFile = speck .. "/constellationsEXGAL.label", - TextColor = { 0.8, 0.8, 0.8, 0.4 }, + TextColor = { 0.8, 0.8, 0.8 }, + TextOpacity = 0.4, TextSize = 20.0, TextMinSize = 20.0, TextMaxSize = 30.0, @@ -37,12 +36,11 @@ local constellations = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 0.4, 0.2 }, - Transparency = 0.3, - ScaleFactor = 1.0, + Opacity = 0.3, File = speck .. "/constellations.speck", LabelFile = speck .. "/constellations.label", - TextColor = { 0.8, 0.8, 0.8, 0.3 }, + TextColor = { 0.8, 0.8, 0.8 }, + TextOpacity = 0.3, TextSize = 14.5, TextMaxSize = 170.0, TextMinSize = 8.0, diff --git a/data/assets/scene/digitaluniverse/deepsky.asset b/data/assets/scene/digitaluniverse/deepsky.asset index 66793c377f..4789551408 100644 --- a/data/assets/scene/digitaluniverse/deepsky.asset +++ b/data/assets/scene/digitaluniverse/deepsky.asset @@ -30,7 +30,7 @@ local deepSkyPoints = { --ColorOption = { "prox5Mpc" }, --ColorRange = { { 1.0, 30.0 } }, LabelFile = speck .. "/dso.label", - TextColor = { 0.1, 0.4, 0.6, 1.0 }, + TextColor = { 0.1, 0.4, 0.6 }, TextSize = 20.50, TextMinSize = 16.0, Unit = "Mpc", @@ -61,7 +61,7 @@ local deepSkyImages = { Type = "RenderablePlanesCloud", Enabled = false, Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.99, + Opacity = 0.99, ScaleFactor = 1.0, File = speck .. "/dso.speck", TexturePath = textures, diff --git a/data/assets/scene/digitaluniverse/dwarfs.asset b/data/assets/scene/digitaluniverse/dwarfs.asset index 507fd039d3..a302fd9154 100644 --- a/data/assets/scene/digitaluniverse/dwarfs.asset +++ b/data/assets/scene/digitaluniverse/dwarfs.asset @@ -29,7 +29,7 @@ local object = { ColorMap = speck .. "/dwarfs.cmap", ColorOption = { "typeindex" }, --ColorRange = { { 1.0, 4.0} }, - TextColor = { 0.5, 0.1, 0.2, 1.0 }, + TextColor = { 0.5, 0.1, 0.2 }, TextSize = 14.6, TextMinSize = 10.0, ScaleFactor = 370, diff --git a/data/assets/scene/digitaluniverse/exoplanets.asset b/data/assets/scene/digitaluniverse/exoplanets.asset index cd1d29aae3..7915477f17 100644 --- a/data/assets/scene/digitaluniverse/exoplanets.asset +++ b/data/assets/scene/digitaluniverse/exoplanets.asset @@ -28,7 +28,7 @@ local object = { File = speck .. "/expl.speck", LabelFile = speck .. "/expl.label", ScaleFactor = 392.5, - TextColor = { 0.3, 0.3, 0.8, 1.0 }, + TextColor = { 0.3, 0.3, 0.8 }, TextSize = 14.8, TextMaxSize = 200.0, TextMinSize = 10.0, diff --git a/data/assets/scene/digitaluniverse/globularclusters.asset b/data/assets/scene/digitaluniverse/globularclusters.asset index d7e26b6829..035052eea1 100644 --- a/data/assets/scene/digitaluniverse/globularclusters.asset +++ b/data/assets/scene/digitaluniverse/globularclusters.asset @@ -27,7 +27,7 @@ local object = { Texture = textures .. "/point4.png", PolygonSides = 5, LabelFile = speck .. "/gc.label", - TextColor = { 0.5, 0.5, 0.0, 1.0 }, + TextColor = { 0.5, 0.5, 0.0 }, ScaleFactor = 431.0, TextSize = 16.7, TextMinSize = 4.0, diff --git a/data/assets/scene/digitaluniverse/grids.asset b/data/assets/scene/digitaluniverse/grids.asset index ecddec43cf..dcb069250a 100644 --- a/data/assets/scene/digitaluniverse/grids.asset +++ b/data/assets/scene/digitaluniverse/grids.asset @@ -114,10 +114,10 @@ local eclipticLabels = { Type = "RenderableBillboardsCloud", Enabled = false, Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.65, + Opacity = 0.65, LabelFile = speck .. "/eclip.label", DrawLabels = true, - TextColor = { 0.5, 0.5, 0.5, 1.0 }, + TextColor = { 0.5, 0.5, 0.5 }, TextSize = 14.75, TextMinSize = 1.3, TextMaxSize = 50.0, @@ -168,10 +168,10 @@ local equatorialLabels = { Type = "RenderableBillboardsCloud", Enabled = false, Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.65, + Opacity = 0.65, LabelFile = speck .. "/radec.label", DrawLabels = true, - TextColor = { 0.5, 0.5, 0.5, 1.0 }, + TextColor = { 0.5, 0.5, 0.5 }, TextSize = 14.5, TextMinSize = 1.7, TextMaxSize = 70.0, @@ -212,10 +212,10 @@ local galacticLabels = { Type = "RenderableBillboardsCloud", Enabled = false, Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.65, + Opacity = 0.65, LabelFile = speck .. "/galac.label", DrawLabels = true, - TextColor = { 0.5, 0.5, 0.5, 1.0 }, + TextColor = { 0.5, 0.5, 0.5 }, TextSize = 15.8, TextMinSize = 0.5, TextMaxSize = 100.0, @@ -239,13 +239,11 @@ local plane1ld = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/1ld.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -269,13 +267,11 @@ local plane1lm = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/1lm.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/1lm.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 11.8, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -299,13 +295,11 @@ local plane1ly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/1ly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/1ly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 13.0, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -329,13 +323,11 @@ local plane10ly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/10ly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/10ly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 14.17, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -359,13 +351,11 @@ local plane100ly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/100ly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/100ly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 15.0, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -389,13 +379,11 @@ local plane1kly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/1kly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/1kly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 16.0, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -419,13 +407,11 @@ local plane10kly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/10kly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/10kly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 17.25, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -442,13 +428,11 @@ local plane100kly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/100kly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/100kly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 18.6, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -465,13 +449,11 @@ local plane1Mly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/1Mly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/1Mly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 19.6, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -488,13 +470,11 @@ local plane10Mly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/10Mly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/10Mly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 20.6, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -511,13 +491,11 @@ local plane100Mly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/100Mly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/100Mly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 21.6, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -534,13 +512,11 @@ local plane20Gly = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.4, - ScaleFactor = 1.0, + Opacity = 0.4, File = speck .. "/20Gly.speck", MeshColor = {{ 0.1, 0.5, 0.6 }}, LabelFile = speck .. "/20Gly.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 23.6, TextMinSize = 0.5, TextMaxSize = 30.0, diff --git a/data/assets/scene/digitaluniverse/groups.asset b/data/assets/scene/digitaluniverse/groups.asset index 745f054baf..682f7fb65b 100644 --- a/data/assets/scene/digitaluniverse/groups.asset +++ b/data/assets/scene/digitaluniverse/groups.asset @@ -18,7 +18,7 @@ local object = { Opacity = 0.65, --ScaleFactor = 10.0, LabelFile = speck .. "/groups.label", - TextColor = { 0.1, 0.6, 0.2, 1.0 }, + TextColor = { 0.1, 0.6, 0.2 }, TextSize = 21.5, TextMinSize = 8.0, Unit = "Mpc", diff --git a/data/assets/scene/digitaluniverse/h2regions.asset b/data/assets/scene/digitaluniverse/h2regions.asset index aee342d6e2..db9cf215c6 100644 --- a/data/assets/scene/digitaluniverse/h2regions.asset +++ b/data/assets/scene/digitaluniverse/h2regions.asset @@ -27,7 +27,7 @@ local object = { Texture = textures .."/point4.png", PolygonSides = 6, LabelFile = speck .. "/h2.label", - TextColor = { 0.5, 0.5, 0.5, 1.0 }, + TextColor = { 0.5, 0.5, 0.5 }, ScaleFactor = 420, TextSize = 16.24, TextMinSize = 4.0, diff --git a/data/assets/scene/digitaluniverse/localdwarfs.asset b/data/assets/scene/digitaluniverse/localdwarfs.asset index bd9c6ccfd7..df011129ee 100644 --- a/data/assets/scene/digitaluniverse/localdwarfs.asset +++ b/data/assets/scene/digitaluniverse/localdwarfs.asset @@ -29,7 +29,7 @@ local object = { Texture = textures .. "/point4.png", PolygonSides = 12, LabelFile = speck .. "/localgroup.label", - TextColor = { 0.3, 0.3, 1.0, 1.0 }, + TextColor = { 0.3, 0.3, 1.0 }, ScaleFactor = 465, TextSize = 18.3, TextMinSize = 7.3, diff --git a/data/assets/scene/digitaluniverse/milkyway.asset b/data/assets/scene/digitaluniverse/milkyway.asset index ee2261e5f1..814ce42fe2 100644 --- a/data/assets/scene/digitaluniverse/milkyway.asset +++ b/data/assets/scene/digitaluniverse/milkyway.asset @@ -63,7 +63,7 @@ local plane = { Type = "RenderablePlanesCloud", Enabled = true, Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.99, + Opacity = 0.99, ScaleFactor = 2.8, File = planeSpeck .. "/galaxy.speck", TexturePath = planeTextures, @@ -92,7 +92,7 @@ local homeLabel = { -- Texture = textures .. "/point3.png", DrawLabels = true, LabelFile = homespeck .. "/home.label", - TextColor = { 0.8, 0.8, 0.8, 1.0 }, + TextColor = { 0.8, 0.8, 0.8 }, TextSize = 20.50, TextMinSize = 16.0, TransformationMatrix = { diff --git a/data/assets/scene/digitaluniverse/obassociations.asset b/data/assets/scene/digitaluniverse/obassociations.asset index dd62c55c97..ad25602989 100644 --- a/data/assets/scene/digitaluniverse/obassociations.asset +++ b/data/assets/scene/digitaluniverse/obassociations.asset @@ -31,7 +31,7 @@ local object = { Texture = textures .. "/point4.png", PolygonSides = 7, LabelFile = speck .. "/ob.label", - TextColor = { 0.4, 0.5, 1.0, 1.0 }, + TextColor = { 0.4, 0.5, 1.0 }, ScaleFactor = 390.0, TextSize = 16.24, TextMinSize = 4.50, diff --git a/data/assets/scene/digitaluniverse/openclusters.asset b/data/assets/scene/digitaluniverse/openclusters.asset index a37fe37335..d060f744db 100644 --- a/data/assets/scene/digitaluniverse/openclusters.asset +++ b/data/assets/scene/digitaluniverse/openclusters.asset @@ -26,7 +26,7 @@ local object = { File = speck .. "/oc.speck", Texture = textures .. "/point4.png", PolygonSides = 12, - TextColor = { 0.05, 0.4, 0.2, 1.0 }, + TextColor = { 0.05, 0.4, 0.2 }, LabelFile = speck .. "/oc.label", ScaleFactor = 405.75, TextSize = 15.5, diff --git a/data/assets/scene/digitaluniverse/planetarynebulae.asset b/data/assets/scene/digitaluniverse/planetarynebulae.asset index 5c178355d9..685cd6d21a 100644 --- a/data/assets/scene/digitaluniverse/planetarynebulae.asset +++ b/data/assets/scene/digitaluniverse/planetarynebulae.asset @@ -27,7 +27,7 @@ local object = { Texture = textures .. "/point4.png", PolygonSides = 3, LabelFile = speck .. "/pn.label", - TextColor = { 0.25, 0.25, 0.65, 1.0 }, + TextColor = { 0.25, 0.25, 0.65 }, ScaleFactor = 425.0, TextSize = 16.24, TextMinSize = 4.5, diff --git a/data/assets/scene/digitaluniverse/pulsars.asset b/data/assets/scene/digitaluniverse/pulsars.asset index fa87280a4c..bd58260f22 100644 --- a/data/assets/scene/digitaluniverse/pulsars.asset +++ b/data/assets/scene/digitaluniverse/pulsars.asset @@ -27,7 +27,7 @@ local object = { Texture = textures .. "/point4.png", PolygonSides = 4, LabelFile = speck .. "/pulsar.label", - TextColor = { 0.7, 0.2, 0.2, 1.0 }, + TextColor = { 0.7, 0.2, 0.2 }, ScaleFactor = 424, TextSize = 15.77, TextMinSize = 4, diff --git a/data/assets/scene/digitaluniverse/starlabels.asset b/data/assets/scene/digitaluniverse/starlabels.asset index 5576bb4a9f..6e12b8e7eb 100644 --- a/data/assets/scene/digitaluniverse/starlabels.asset +++ b/data/assets/scene/digitaluniverse/starlabels.asset @@ -17,7 +17,7 @@ local object = { Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, LabelFile = speck .. "/stars.label", - TextColor = { 0.4, 0.4, 0.4, 1.0 }, + TextColor = { 0.4, 0.4, 0.4 }, DrawLabels = true, TextSize = 14.7, TextMinSize = 6.0, diff --git a/data/assets/scene/digitaluniverse/starorbits.asset b/data/assets/scene/digitaluniverse/starorbits.asset index b240a57024..212d2a9b3f 100644 --- a/data/assets/scene/digitaluniverse/starorbits.asset +++ b/data/assets/scene/digitaluniverse/starorbits.asset @@ -16,13 +16,11 @@ local sunOrbit = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = { 1.0, 0.65, 0.0 }, - Transparency = 1.0, - ScaleFactor = 1.0, + Opacity = 1.0, File = speck .. "/starorbits-Sun.speck", MeshColor = {{ 1.0, 0.65, 0.0 }}, --LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -40,13 +38,11 @@ local barnardsOrbit = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = {1.0, 1.0, 1.0}, - Transparency = 1.0, - ScaleFactor = 1.0, + Opacity = 1.0, File = speck .. "/starorbits-BarnardsStar.speck", MeshColor = {{0.39, 0.58, 0.93}}, --LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -64,13 +60,11 @@ local kapteynsOrbit = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = {1.0, 1.0, 1.0}, - Transparency = 1.0, - ScaleFactor = 1.0, + Opacity = 1.0, File = speck .. "/starorbits-KapteynsStar.speck", MeshColor = {{0.6, 0.6, 0.6}}, --LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -88,13 +82,11 @@ local lacaille9352Orbit = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = {1.0, 1.0, 1.0}, - Transparency = 1.0, - ScaleFactor = 1.0, + Opacity = 1.0, File = speck .. "/starorbits-Lacaille9352.speck", MeshColor = {{0.58, 0.0, 0.83}}, --LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -112,13 +104,11 @@ local lSR1826Orbit = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = {1.0, 1.0, 1.0}, - Transparency = 1.0, - ScaleFactor = 1.0, + Opacity = 1.0, File = speck .. "/starorbits-LSR1826+3014.speck", MeshColor = {{0.0, 0.39, 0.0}}, --LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -136,13 +126,11 @@ local lSRJ0822Orbit = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = {1.0, 1.0, 1.0}, - Transparency = 1.0, - ScaleFactor = 1.0, + Opacity = 1.0, File = speck .. "/starorbits-LSRJ0822+1700.speck", MeshColor = {{0.5, 1.0, 0.0}}, --LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, @@ -160,13 +148,11 @@ local pM_J13420Orbit = { Renderable = { Type = "RenderableDUMeshes", Enabled = false, - Color = {1.0, 1.0, 1.0}, - Transparency = 1.0, - ScaleFactor = 1.0, + Opacity = 1.0, File = speck .. "/starorbits-PM_J13420-3415.speck", MeshColor = {{0.70, 0.13, 0.13}}, --LabelFile = speck .. "/1ld.label", - TextColor = { 0.0, 0.2, 0.5, 1.0 }, + TextColor = { 0.0, 0.2, 0.5 }, TextSize = 10.3, TextMinSize = 0.5, TextMaxSize = 30.0, diff --git a/data/assets/scene/digitaluniverse/stars.asset b/data/assets/scene/digitaluniverse/stars.asset index 696c4aa739..0407908aab 100644 --- a/data/assets/scene/digitaluniverse/stars.asset +++ b/data/assets/scene/digitaluniverse/stars.asset @@ -58,7 +58,7 @@ local sunstar = { MagnitudeExponent = 6.2, SizeComposition = "Distance Modulus", RenderMethod = "Texture Based", -- or PSF - FadeInDistances = {0.0001, 0.1} + FadeInDistances = { 0.0001, 0.1 } }, GUI = { Name = "Sun", diff --git a/data/assets/scene/digitaluniverse/superclusters.asset b/data/assets/scene/digitaluniverse/superclusters.asset index 5ce754caa7..6ebbb1f488 100644 --- a/data/assets/scene/digitaluniverse/superclusters.asset +++ b/data/assets/scene/digitaluniverse/superclusters.asset @@ -27,7 +27,7 @@ local object = { File = speck .. "/superclust.speck", Texture = textures .. "/point3A.png", LabelFile = speck .. "/superclust.label", - TextColor = { 0.9, 0.9, 0.9, 1.0 }, + TextColor = { 0.9, 0.9, 0.9 }, ScaleFactor = 531.0, TextSize = 22.44, TextMinSize = 8.0, diff --git a/data/assets/scene/digitaluniverse/supernovaremnants.asset b/data/assets/scene/digitaluniverse/supernovaremnants.asset index 56b841a2e3..c821080e65 100644 --- a/data/assets/scene/digitaluniverse/supernovaremnants.asset +++ b/data/assets/scene/digitaluniverse/supernovaremnants.asset @@ -27,7 +27,7 @@ local object = { Texture = textures .. "/point4.png", PolygonSides = 7, LabelFile = speck .. "/snr.label", - TextColor = { 0.6, 0.46, 0.0, 1.0 }, + TextColor = { 0.6, 0.46, 0.0 }, ScaleFactor = 424, TextSize = 16.44, TextMinSize = 4.0, diff --git a/data/assets/scene/digitaluniverse/tully.asset b/data/assets/scene/digitaluniverse/tully.asset index d169e0c815..45ce730432 100644 --- a/data/assets/scene/digitaluniverse/tully.asset +++ b/data/assets/scene/digitaluniverse/tully.asset @@ -33,7 +33,7 @@ local tullyPoints = { ColorRange = { { 1.0, 30.0 } }, LabelFile = speck .. "/tully.label", DrawLabels = true, - TextColor = { 0.7, 0.7, 0.7, 1.0 }, + TextColor = { 0.7, 0.7, 0.7 }, TextSize = 19.36, TextMinSize = 8.2, TransformationMatrix = { @@ -64,7 +64,7 @@ local tullyImages = { Type = "RenderablePlanesCloud", Enabled = true, Color = { 1.0, 1.0, 1.0 }, - Transparency = 0.99, + Opacity = 0.99, ScaleFactor = 1.0, File = speck .. "/tully.speck", TexturePath = textures, diff --git a/data/assets/scene/digitaluniverse/voids.asset b/data/assets/scene/digitaluniverse/voids.asset index 64ca8bb4ad..420ebe54b7 100644 --- a/data/assets/scene/digitaluniverse/voids.asset +++ b/data/assets/scene/digitaluniverse/voids.asset @@ -19,7 +19,7 @@ local object = { Color = { 1.0, 1.0, 1.0 }, Opacity = 0.65, LabelFile = speck .. "/voids.label", - TextColor = { 0.296, 0.629, 1.0, 1.0 }, + TextColor = { 0.296, 0.629, 1.0 }, TextSize = 20.9, TextMinSize = 8.0, Unit = "Mpc" diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset deleted file mode 100644 index 87139c2b9e..0000000000 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon.asset +++ /dev/null @@ -1,64 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local transforms = asset.require('./transforms') -asset.require("spice/base") -asset.request('./trail') -local labelsPath = asset.require('./pluto_globelabels').LabelsPath - - - -local Charon = { - Identifier = "Charon", - Parent = transforms.PlutoBarycenter.Identifier, - Transform = { - Translation = { - Type = "SpiceTranslation", - Target = "CHARON", - Observer = "PLUTO BARYCENTER", - Kernels = NewHorizonsKernels - }, - Rotation = { - Type = "SpiceRotation", - SourceFrame = "IAU_CHARON", - DestinationFrame = "GALACTIC" - } - }, - Renderable = { - Type = "RenderableGlobe", - Radii = { 6.035E5, 6.035E5, 6.035E5 }, - SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Greyscale_USGS", - Name = "Black & White [USGS]", - FilePath = "WMS:https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/pluto/charon_simp_cyl.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=NEWHORIZONS_CHARON_MOSAIC&SRS=EPSG:4326&BBOX=-180,-90.0003,359.972,90", - Enabled = true - } - } - }, - Labels = { - Enable = false, - FileName = labelsPath .. "/charon.labels", - LabelAlignmentOption = "Horizontally", -- or Circularly - LabelsFontSize = 14.0, - LabelsSize = 8.0, - LabelsMinSize = 1.0, - LabelsMaxSize = 1500.0, - ProximityEnabled = false, - LabelsFadeInEnabled = true, - FadeInStartingDistance = 500000.0, - FadeOutStartingDistance = 1000000.0, - LabelsForceDomeRendering = true, - LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} - } - }, - Tag = { "planet_solarSystem", "planet_terrestrial" }, - GUI = { - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - - - -assetHelper.registerSceneGraphNodesAndExport(asset, { Charon }) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon_trail.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon_trail.asset deleted file mode 100644 index f1e7e19860..0000000000 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon_trail.asset +++ /dev/null @@ -1,28 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local transforms = asset.require('./transforms') -asset.require("spice/base") - - -local CharonTrailBarycentric = { - Identifier = "CharonBarycentricTrail", - Parent = transforms.PlutoBarycenter.Identifier, - Renderable = { - Type = "RenderableTrailOrbit", - Translation = { - Type = "SpiceTranslation", - Target = "CHARON", - Observer = "PLUTO BARYCENTER" - }, - Color = { 0.00, 0.62, 1.00 }, - Period = 6.38723, - Resolution = 1000 - }, - GUI = { - Name = "Charon Barycentric Trail", - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - - - -assetHelper.registerSceneGraphNodesAndExport(asset, { CharonTrailBarycentric }) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/hydra.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/hydra.asset deleted file mode 100644 index 46887461ee..0000000000 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/hydra.asset +++ /dev/null @@ -1,51 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local transforms = asset.require('./transforms') -local kernels = asset.require('./kernels').PlutoKernels - - - -local Hydra = { - Identifier = "Hydra", - Parent = transforms.PlutoBarycenter.Identifier, - Transform = { - Translation = { - Type = "SpiceTranslation", - Target = "HYDRA", - Observer = "PLUTO BARYCENTER", - Kernels = kernels - } - }, - Renderable = { - Type = "RenderableGlobe", - Radii = { 0.53E5, 0.53E5, 0.53E5 }, - SegmentsPerPatch = 64, - Layers = {} - }, - GUI = { - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - -local HydraTrail = { - Identifier = "HydraTrail", - Parent = transforms.PlutoBarycenter.Identifier, - Renderable = { - Type = "RenderableTrailOrbit", - Translation = { - Type = "SpiceTranslation", - Target = "HYDRA", - Observer = "PLUTO BARYCENTER", - }, - Color = { 0.00, 0.62, 1.00 }, - Period = 38.20177, - Resolution = 1000 - }, - GUI = { - Name = "Hydra Trail", - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - - - -assetHelper.registerSceneGraphNodesAndExport(asset, { Hydra, HydraTrail }) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/kerberos.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/kerberos.asset deleted file mode 100644 index a6f3643356..0000000000 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/kerberos.asset +++ /dev/null @@ -1,51 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local transforms = asset.require('./transforms') -local kernels = asset.require('./kernels').PlutoKernels - - - -local Kerberos = { - Identifier = "Kerberos", - Parent = transforms.PlutoBarycenter.Identifier, - Transform = { - Translation = { - Type = "SpiceTranslation", - Target = "KERBEROS", - Observer = "PLUTO BARYCENTER", - Kernels = PlutoKernels - } - }, - Renderable = { - Type = "RenderableGlobe", - Radii = { 0.1E5, 0.1E5, 0.1E5 }, - SegmentsPerPatch = 64, - Layers = {} - }, - GUI = { - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - -local KerberosTrail = { - Identifier = "KerberosTrail", - Parent = transforms.PlutoBarycenter.Identifier, - Renderable = { - Type = "RenderableTrailOrbit", - Translation = { - Type = "SpiceTranslation", - Target = "KERBEROS", - Observer = "PLUTO BARYCENTER", - }, - Color = { 0.00, 0.62, 1.00 }, - Period = 32.16756, - Resolution = 1000 - }, - GUI = { - Name = "Hydra Trail", - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - - - -assetHelper.registerSceneGraphNodesAndExport(asset, { Kerberos, KerberosTrail }) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/nix.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/nix.asset deleted file mode 100644 index 225ba93e2d..0000000000 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/nix.asset +++ /dev/null @@ -1,51 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local transforms = asset.require('./transforms') -local kernels = asset.require('./kernels').PlutoKernels - - - -local Nix = { - Identifier = "Nix", - Parent = transforms.PlutoBarycenter.Identifier, - Transform = { - Translation = { - Type = "SpiceTranslation", - Target = "NIX", - Observer = "PLUTO BARYCENTER", - Kernels = PlutoKernels - } - }, - Renderable = { - Type = "RenderableGlobe", - Radii = { 0.45E5, 0.45E5, 0.45E5 }, - SegmentsPerPatch = 64, - Layers = {} - }, - GUI = { - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - -local NixTrail = { - Identifier = "NixTrail", - Parent = transforms.PlutoBarycenter.Identifier, - Renderable = { - Type = "RenderableTrailOrbit", - Translation = { - Type = "SpiceTranslation", - Target = "NIX", - Observer = "PLUTO BARYCENTER", - }, - Color = { 0.00, 0.62, 1.00 }, - Period = 24.85463, - Resolution = 1000 - }, - GUI = { - Name = "Nix Trail", - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - - - -assetHelper.registerSceneGraphNodesAndExport(asset, { Nix, NixTrail }) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset index ce98ef30f8..c90da31679 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset @@ -26,16 +26,7 @@ local Pluto = { Type = "RenderableGlobe", Radii = { 1.173E6, 1.173E6, 1.173E6 }, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Greyscale_USGS", - Name = "Black & White [USGS]", - FilePath = "WMS:https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/pluto/pluto_simp_cyl.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=NEWHORIZONS_PLUTO_MOSAIC&SRS=EPSG:4326&BBOX=-180,-90,360,90", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/pluto.labels", @@ -50,7 +41,7 @@ local Pluto = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "planet_solarSystem", "planet_terrestrial" }, diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/styx.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/styx.asset deleted file mode 100644 index b90db619e5..0000000000 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/styx.asset +++ /dev/null @@ -1,51 +0,0 @@ -local assetHelper = asset.require('util/asset_helper') -local transforms = asset.require('./transforms') -local kernels = asset.require('./kernels').PlutoKernels - - - -local Styx = { - Identifier = "Styx", - Parent = transforms.PlutoBarycenter.Identifier, - Transform = { - Translation = { - Type = "SpiceTranslation", - Target = "STYX", - Observer = "PLUTO BARYCENTER", - Kernels = PlutoKernels - } - }, - Renderable = { - Type = "RenderableGlobe", - Radii = { 0.45E5, 0.45E5, 0.45E5 }, - SegmentsPerPatch = 64, - Layers = {} - }, - GUI = { - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - -local StyxTrail = { - Identifier = "StyxTrail", - Parent = transforms.PlutoBarycenter.Identifier, - Renderable = { - Type = "RenderableTrailOrbit", - Translation = { - Type = "SpiceTranslation", - Target = "STYX", - Observer = "PLUTO BARYCENTER", - }, - Color = { 0.00, 0.62, 1.00 }, - Period = 20.16155, - Resolution = 1000 - }, - GUI = { - Name = "Styx Trail", - Path = "/Solar System/Dwarf Planets/Pluto" - } -} - - - -assetHelper.registerSceneGraphNodesAndExport(asset, { Styx, StyxTrail }) diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset index 27f589806f..e649a45a58 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/system.asset @@ -1,10 +1,10 @@ asset.request('./trail') asset.request('./pluto') asset.request('./pluto_trail') -asset.request('./charon') -asset.request('./charon_trail') -asset.request('./hydra') -asset.request('./kerberos') -asset.request('./nix') -asset.request('./styx') +asset.request('./charon/charon') +asset.request('./charon/charon_trail') +asset.request('./minor/hydra') +asset.request('./minor/kerberos') +asset.request('./minor/nix') +asset.request('./minor/styx') diff --git a/data/assets/scene/solarsystem/missions/newhorizons/charon.asset b/data/assets/scene/solarsystem/missions/newhorizons/charon.asset index 3929571670..8f2c7d5910 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/charon.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/charon.asset @@ -100,6 +100,7 @@ local CharonShadow = { Parent = CharonProjection .Identifier, Renderable = { Type = "RenderableShadowCylinder", + Opacity = 0.25, TerminatorType = "PENUMBRAL", LightSource = "SUN", Observer = "NEW HORIZONS", diff --git a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset index 72eb98db1e..3a963722e2 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset @@ -226,6 +226,7 @@ local PlutoShadow = { Parent = PlutoProjection.Identifier, Renderable = { Type = "RenderableShadowCylinder", + Opacity = 0.25, TerminatorType = "PENUMBRAL", LightSource = "SUN", Observer = "NEW HORIZONS", diff --git a/data/assets/scene/solarsystem/planets/earth/earth.asset b/data/assets/scene/solarsystem/planets/earth/earth.asset index 1693d8ad15..c281713453 100644 --- a/data/assets/scene/solarsystem/planets/earth/earth.asset +++ b/data/assets/scene/solarsystem/planets/earth/earth.asset @@ -1,15 +1,11 @@ local transforms = asset.require('./transforms') local assetHelper = asset.require('util/asset_helper') -local texturesPath = asset.require('./earth_textures').TexturesPath local labelsPath = asset.require('./earth_globelabels').LabelsPath asset.request('./trail') - - -- local earthEllipsoid = { 6378137.0, 6378137.0, 6356752.314245 } local earthEllipsoid = { 6378137.0, 6378137.0, 6378137.0 } -local mapServiceConfigsPath = asset.localResource("map_service_configs") local Earth = { Identifier = "Earth", @@ -19,249 +15,7 @@ local Earth = { Radii = earthEllipsoid, SegmentsPerPatch = 64, PerformShading = false, - Layers = { - ColorLayers = { - { - Identifier = "ESRI_VIIRS_Combo", - Name = "ESRI VIIRS Combo", - Type = "ByLevelTileLayer", - LevelTileProviders = { - { - MaxLevel = 4, - TileProvider = { - Identifier = "Temporal_VIIRS_SNPP", - Name = "Temporal VIIRS SNPP", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "VIIRS_SNPP_CorrectedReflectance_TrueColor", - "2015-11-24", - "Today", - "1d", - "250m", - "jpg" - ), - PadTiles = false - } - }, - { - MaxLevel = 22, - TileProvider = { - Identifier = "ESRI_World_Imagery", - Name = "ESRI World Imagery", - FilePath = mapServiceConfigsPath .. "/ESRI/World_Imagery.wms", - PadTiles = false - } - }, - }, - Enabled = true, - PadTiles = false, - Fallback = { - Identifier = "Blue_Marble", - Name = "Blue Marble", - FilePath = texturesPath .. "/earth_bluemarble.jpg", - Enabled = true - } - }, - { - Identifier = "ESRI_World_Imagery", - Name = "ESRI World Imagery", - FilePath = mapServiceConfigsPath .. "/ESRI/World_Imagery.wms" - }, - { - Identifier = "ESRI_Imagery_World_2D", - Name = "ESRI Imagery World 2D", - FilePath = mapServiceConfigsPath .. "/ESRI/ESRI_Imagery_World_2D.wms" - }, - { - Identifier = "VIIRS_SNPP_Temporal", - Name = "VIIRS SNPP (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "VIIRS_SNPP_CorrectedReflectance_TrueColor", - "2015-11-24", - "Yesterday", - "1d", - "250m", - "jpg" - ) - }, - { - Identifier = "Aqua_Modis_Temporal", - Name = "Aqua Modis (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "MODIS_Aqua_CorrectedReflectance_TrueColor", - "2002-07-04", - "Yesterday", - "1d", - "250m", - "jpg" - ) - }, - { - Identifier = "Terra_Modis_Temporal", - Name = "Terra Modis (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "MODIS_Terra_CorrectedReflectance_TrueColor", - "2000-02-24", - "Yesterday", - "1d", - "250m", - "jpg" - ) - }, - { - Name = "BMNG [Utah]", - Identifier = "BMNG_Utah", - FilePath = mapServiceConfigsPath .. "/Utah/Bmng.wms" - }, - { - Name = "BMNG [Sweden]", - Identifier = "BMNG_Sweden", - FilePath = mapServiceConfigsPath .. "/LiU/Bmng.wms" - }, - { - Identifier = "AMSR2_GCOM_W1_Sea_Ice_Concentration_Temporal", - Name = "AMSR2 GCOM W1 Sea Ice Concentration (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "AMSRU2_Sea_Ice_Concentration_12km", - "2012-05-08", - "Yesterday", - "1d", - "2km", - "png" - ) - }, - { - Identifier = "MODIS_Terra_Chlorophyll_A_Temporal", - Name = "MODIS Terra Chlorophyll A (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "MODIS_Terra_Chlorophyll_A", - "2013-07-02", - "Yesterday", - "1d", - "1km", - "png" - ) - }, - { - Identifier = "GHRSST_L4_G1SST_Sea_Surface_Temperature_Temporal", - Name = "GHRSST L4 G1SST Sea Surface Temperature (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "GHRSST_L4_G1SST_Sea_Surface_Temperature", - "2010-06-21", - "2019-12-08", - "1d", - "1km", - "png" - ) - }, - { - Identifier = "GHRSST_L4_MUR_Sea_Surface_Temperature_Temporal", - Name = "GHRSST L4 MUR Sea Surface Temperature (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "GHRSST_L4_MUR_Sea_Surface_Temperature", - "2002-06-01", - "Yesterday", - "1d", - "1km", - "png" - ) - } - }, - NightLayers = { - { - Identifier = "Earth_at_Night_2012", - Name = "Earth at Night 2012", - FilePath = mapServiceConfigsPath .. "/GIBS/night/VIIRS_CityLights_2012.wms", - Enabled = true, - Fallback = { - Identifier = "Earth_Night", - Name = "Earth Night", - FilePath = texturesPath .. "/earth_night.jpg", - Enabled = true, - } - }, - { - Identifier = "Earth_at_Night_Temporal", - Name = "Earth at Night (Temporal)", - Type = "TemporalTileLayer", - FilePath = openspace.globebrowsing.createTemporalGibsGdalXml( - "VIIRS_SNPP_DayNightBand_ENCC", - "2012-05-08", - "Yesterday", - "1d", - "500m", - "png" - ) - } - }, - WaterMasks = { - { - Identifier = "MODIS_Water_Mask", - Name = "MODIS Water Mask", - FilePath = mapServiceConfigsPath .. "/GIBS/water/MODIS_Water_Mask.wms", - Enabled = true - }, - { - Name = "Gebco [Utah]", - Identifier = "Gebco_Utah", - FilePath = mapServiceConfigsPath .. "/Utah/Gebco.wms" - }, - { - Name = "Gebco [Sweden]", - Identifier = "Gebco_Sweden", - FilePath = mapServiceConfigsPath .. "/LiU/Gebco.wms" - }, - }, - Overlays = { - { - Identifier = "Coastlines", - FilePath = mapServiceConfigsPath .. "/GIBS/overlays/Coastlines.wms" - }, - { - Identifier = "Reference_Features", - Name = "Reference Features", - FilePath = mapServiceConfigsPath .. "/GIBS/overlays/Reference_Features.wms" - }, - { - Identifier = "Reference_Labels", - Name = "Reference Labels", - FilePath = mapServiceConfigsPath .. "/GIBS/overlays/Reference_Labels.wms" - }, - { - Identifier = "Tile_Indices", - Name = "Tile Indices", - Type = "TileIndexTileLayer" - }, - { - Identifier = "Size_Reference", - Name = "Size Reference", - Type = "SizeReferenceTileLayer", - Radii = earthEllipsoid - } - }, - HeightLayers = { - { - Identifier = "Terrain_tileset", - Name = "Terrain tileset", - FilePath = mapServiceConfigsPath .. "/ESRI/Terrain.wms", - Enabled = true, - TilePixelSize = 64, - Fallback = { - Name = "Earth Bluemarble Height", - Identifier = "Earth_Bluemarble_Height", - FilePath = texturesPath .. "/earth_bluemarble_height.jpg", - Enabled = true - } - } - } - }, + Layers = {}, ShadowGroup = { Source1 = { Name = "Sun", @@ -291,7 +45,7 @@ local Earth = { FadeOutStartingDistance = 80000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1500000.0, - LabelsColor = {1.0, 0.0, 0.0, 1.0} + LabelsColor = { 1.0, 0.0, 0.0 } } }, Tag = { "planet_solarSystem", "planet_terrestrial" }, diff --git a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset index 642e0a0e90..16e67dd16b 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/moon.asset +++ b/data/assets/scene/solarsystem/planets/earth/moon/moon.asset @@ -6,10 +6,6 @@ asset.require('spice/base') asset.request('./trail') local labelsPath = asset.require('./moon_labels').LabelsPath - - -local mapServiceConfigs = asset.localResource("map_service_configs") - local Moon = { Identifier = "Moon", Parent = transforms.EarthBarycenter.Identifier, @@ -29,115 +25,7 @@ local Moon = { Type = "RenderableGlobe", Radii = 1738140, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "WAC_Utah", - Name = "WAC [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Wac.wms", - Enabled = true, - Settings = { Gamma = 0.84 } - }, - { - Identifier = "WAC_Sweden", - Name = "WAC [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/WAC.wms", - Settings = { Gamma = 0.84 } - }, - { - Identifier = "ClemUvvis_Utah", - Name = "Clem Uvvis [Utah]", - FilePath = mapServiceConfigs .. "/Utah/ClemUvvis.wms", - Settings = { - Gamma = 1.14, - Multiplier = 1.4 - } - }, - { - Identifier = "ClemUvvis_Sweden", - Name = "Clem Uvvis [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Clem_Uvvis.wms", - Settings = { - Gamma = 1.14, - Multiplier = 1.4 - } - }, - { - Identifier = "UvvisHybrid_Utah", - Name = "Uvvis Hybrid [Utah]", - FilePath = mapServiceConfigs .. "/Utah/UvvisHybrid.wms", - Settings = { - Gamma = 0.52, - Multiplier = 0.65 - } - }, - { - Identifier = "UvvisHybrid_Sweden", - Name = "Uvvis Hybrid [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Uvvis_Hybrid.wms", - Settings = { - Gamma = 0.52, - Multiplier = 0.65 - } - }, - { - Identifier = "Kaguya_Utah", - Name = "Kaguya [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Kaguya.vrt", - Settings = { - Gamma = 1.0, - Multiplier = 1.23 - } - }, - { - Identifier = "Kaguya_Sweden", - Name = "Kaguya [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Kaguya.vrt", - Settings = { - Gamma = 1.0, - Multiplier = 1.23 - } - }, - { - Identifier = "Lola_Clr_Shade_Utah", - Name = "Lola Color Shade [Utah]", - FilePath = mapServiceConfigs .. "/Utah/LolaClrShade.wms" - }, - { - Identifier = "Lola_Clr_Shade_Sweden", - Name = "Lola Color Shade [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Lola_Clr_Shade.wms" - }, - { - Identifier = "Lola_Shade_Utah", - Name = "Lola Shade [Utah]", - FilePath = mapServiceConfigs .. "/Utah/LolaShade.wms" - }, - { - Identifier = "Lola_Shade_Sweden", - Name = "Lola Shade [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Lola_Shade.wms" - }, - }, - HeightLayers = { - { - Identifier = "LolaDem_Utah", - Name = "Lola DEM [Utah]", - FilePath = mapServiceConfigs .. "/Utah/LolaDem.wms", - Enabled = true, - TilePixelSize = 64, - Settings = { Multiplier = 0.5 } - }, - { - Identifier = "LolaDem_Sweden", - Name = "Lola DEM [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Lola_DEM.wms", - TilePixelSize = 64, - Settings = { Multiplier = 0.5 } - } - - } - }, + Layers = {}, ShadowGroup = { Source1 = { Name = sunAsset.Sun.Name, @@ -162,7 +50,7 @@ local Moon = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, GUI = { diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset index 72fabc4988..841a2536d9 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset @@ -24,6 +24,7 @@ local initializeAndAddNodes = function() local iss = { Identifier = "ISS", Parent = transforms.EarthInertial.Identifier, + BoundingSphere = 30, Transform = { Translation = { Type = "TLETranslation", diff --git a/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset b/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset index d0b2496e52..5b7208bf01 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/callisto/callisto.asset @@ -5,15 +5,6 @@ asset.request('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Callisto Textures", - Type = "HttpSynchronization", - Identifier = "callisto_textures", - Version = 1 -}) - local Callisto = { Identifier = "Callisto", Parent = transforms.JupiterBarycenter.Identifier, @@ -35,15 +26,7 @@ local Callisto = { Type = "RenderableGlobe", Radii = 2410000, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/callisto.jpg", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/callisto.labels", @@ -58,7 +41,7 @@ local Callisto = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_jupiter" }, diff --git a/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset b/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset index d5e455bb9f..626cb52977 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/europa/europa.asset @@ -5,17 +5,6 @@ asset.request('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath - -local map_service_configs = asset.localResource("map_service_configs") - - -local textures = asset.syncedResource({ - Name = "Europa Textures", - Type = "HttpSynchronization", - Identifier = "europa_textures", - Version = 1 -}) - local Europa = { Identifier = "Europa", Parent = transforms.JupiterBarycenter.Identifier, @@ -37,22 +26,7 @@ local Europa = { Type = "RenderableGlobe", Radii = 1560800, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/europa.jpg", - -- Enabled = true - }, - { - Identifier = "Voyager_Global_Mosaic", - Name = "Voyager Global Mosaic [Sweden]", - FilePath = map_service_configs .. "/LiU/Voyager_GalileoSSI_global_mosaic_500m.wms", - BlendMode = "Color", - Enabled = true - }, - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/europa.labels", @@ -67,7 +41,7 @@ local Europa = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_jupiter" }, diff --git a/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset b/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset index 513136ef98..dc4f65f7cf 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/ganymede/ganymede.asset @@ -5,15 +5,6 @@ asset.request('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Ganymede Textures", - Type = "HttpSynchronization", - Identifier = "ganymede_textures", - Version = 1 -}) - local Ganymede = { Identifier = "Ganymede", Parent = transforms.JupiterBarycenter.Identifier, @@ -35,15 +26,7 @@ local Ganymede = { Type = "RenderableGlobe", Radii = 2631000, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/ganymede.jpg", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/ganymede.labels", @@ -58,7 +41,7 @@ local Ganymede = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = {1.0, 1.0, 0.0} } }, Tag = { "moon_solarSystem", "moon_giants", "moon_jupiter" }, diff --git a/data/assets/scene/solarsystem/planets/jupiter/io/io.asset b/data/assets/scene/solarsystem/planets/jupiter/io/io.asset index fb10f0b3a8..0c4af55b78 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/io/io.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/io/io.asset @@ -5,15 +5,6 @@ asset.request('./trail') local kernel = asset.require('../kernels').jup310 local labelsPath = asset.require('../jupiter_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Io Textures", - Type = "HttpSynchronization", - Identifier = "io_textures", - Version = 1 -}) - local Io = { Identifier = "Io", Parent = transforms.JupiterBarycenter.Identifier, @@ -35,15 +26,7 @@ local Io = { Type = "RenderableGlobe", Radii = 1821600, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/io.jpg", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/io.labels", @@ -58,7 +41,7 @@ local Io = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_jupiter" }, diff --git a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset index 071a9cad9f..9142e7dce2 100644 --- a/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset +++ b/data/assets/scene/solarsystem/planets/jupiter/jupiter.asset @@ -3,15 +3,6 @@ local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") asset.request('./trail') - - -local textures = asset.syncedResource({ - Name = "Jupiter Textures", - Type = "HttpSynchronization", - Identifier = "jupiter_textures", - Version = 1 -}) - local Jupiter = { Identifier = "Jupiter", Parent = transforms.JupiterBarycenter.Identifier, @@ -26,15 +17,7 @@ local Jupiter = { Type = "RenderableGlobe", Radii = { 71492000.0, 71492000.0, 66854000.0 }, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/jupiter.jpg", - Enabled = true - } - } - } + Layers = {} }, Tag = { "planet_solarSystem", "planet_giants" }, GUI = { diff --git a/data/assets/scene/solarsystem/planets/mars/mars.asset b/data/assets/scene/solarsystem/planets/mars/mars.asset index f6d9b9d188..8be70b30a7 100644 --- a/data/assets/scene/solarsystem/planets/mars/mars.asset +++ b/data/assets/scene/solarsystem/planets/mars/mars.asset @@ -4,165 +4,9 @@ asset.require("spice/base") asset.request('./trail') local labelsPath = asset.require('./mars_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Mars Textures", - Type = "HttpSynchronization", - Identifier = "mars_textures", - Version = 1 -}) - -- local marsRadii = { 3396190.0, 3396190.0, 3376200.0 } local marsRadii = { 3396190.0, 3396190.0, 3396190.0 } -local mapServiceConfigs = asset.localResource("map_service_configs") - -local color_layers = { - { - Identifier = "MOC_WA_Color_Utah", - Name = "MOC WA Color [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Mars_Color.wms", - Enabled = true, - Fallback = { - Identifier = "Mars_Texture", - Name = "Mars Texture", - FilePath = textures .. "/mars.jpg", - Enabled = true - }, - Settings = { - Gamma = 1.6, - Multiplier = 1.07 - } - }, - { - Identifier = "MOC_WA_Color_LiU", - Name = "MOC WA Color [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Color.wms", - Fallback = { - Identifier = "Mars_Texture", - Name = "Mars Texture", - FilePath = textures .. "/mars.jpg", - Enabled = true - }, - Settings = { - Gamma = 1.6, - Multiplier = 1.07 - } - }, - { - Identifier = "Viking_MDIM_Utah", - Name = "Viking MDIM [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Mdim.wms" - }, - { - Identifier = "Viking_MDIM_Sweden", - Name = "Viking MDIM [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/MDIM.wms" - }, - { - Identifier = "MOLA_Pseudo_Color_Utah", - Name = "MOLA Pseudo Color [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Mola_PseudoColor.wms" - }, - { - Identifier = "MOLA_Pseudo_Color_Sweden", - Name = "MOLA Pseudo Color [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Mola_PseudoColor.wms" - }, - { - Identifier = "MOLA_HRSC_Utah", - Name = "MOLA HRSC [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Mola_HRSC.wms" - }, - { - Identifier = "MOLA_HRSC_Sweden", - Name = "MOLA HRSC [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Mola_HRSC.wms" - }, - { - Identifier = "Themis_IR_Day_Utah", - Name = "Themis IR Day [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Themis_IR_Day.wms", - BlendMode = "Color" - }, - { - Identifier = "Themis_IR_Day_Sweden", - Name = "Themis IR Day [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Themis_IR_Day.wms", - BlendMode = "Color" - }, - { - Identifier = "Themis_IR_Night_Utah", - Name = "Themis IR Night [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Themis_IR_Night.wms", - BlendMode = "Color" - }, - { - Identifier = "Themis_IR_Night_Sweden", - Name = "Themis IR Night [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Themis_IR_Night.wms", - BlendMode = "Color" - }, - { - Identifier = "CTX_Mosaic_Utah", - Name = "CTX Mosaic [Utah]", - FilePath = mapServiceConfigs .. "/Utah/CTX.wms", - BlendMode = "Color" - }, - { - Identifier = "CTX_Mosaic_Sweden", - Name = "CTX Mosaic [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/CTX.wms", - BlendMode = "Color" - }, - { - Identifier = "CTX_blended_01", - Name = "CTX Blended beta01", - FilePath = mapServiceConfigs .. "/ESRI/CTX/CTXblended.vrt", - BlendMode = "Color", - Settings = { - Gamma = 2.14, - Multiplier = 1.54 - } - } -} - -local overlay_layers = { - { - Identifier = "Indices", - Type = "TileIndexTileLayer" - }, - { - Identifier = "Size_Reference", - Name = "Size Reference", - Type = "SizeReferenceTileLayer", - Radii = marsRadii - } -} - -local height_layers = { - { - Identifier = "Mola", - Name = "Mola Elevation", - FilePath = mapServiceConfigs .. "/Mars_MGS_MOLA_DEM.wms", - TilePixelSize = 90 - }, - { - Identifier = "Mola_Europe", - Name = "Mola Elevation [Europe]", - FilePath = mapServiceConfigs .. "/LiU/Mola_Elevation.wms", - TilePixelSize = 90 - }, - { - Identifier = "Mola_Utah", - Name = "Mola Elevation [Utah]", - FilePath = mapServiceConfigs .. "/Utah/Mola_Elevation.wms", - Enabled = true, - TilePixelSize = 90 - } -} - local Mars = { Identifier = "Mars", Parent = transforms.MarsBarycenter.Identifier, @@ -177,11 +21,7 @@ local Mars = { Type = "RenderableGlobe", Radii = marsRadii, SegmentsPerPatch = 90, - Layers = { - ColorLayers = color_layers, - Overlays = overlay_layers, - HeightLayers = height_layers - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/mars.labels", @@ -196,7 +36,7 @@ local Mars = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "planet_solarSystem", "planet_terrestrial" }, diff --git a/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset b/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset index c880bf8b08..0b27982a7d 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/deimos.asset @@ -30,7 +30,7 @@ local Deimos = { }, Renderable = { Type = "RenderableGlobe", - Radii = { 15, 12.2, 11 }, + Radii = { 15000, 12200, 11000 }, SegmentsPerPatch = 90, Layers = { } diff --git a/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset b/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset index ff97e74ce2..899b674980 100644 --- a/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset +++ b/data/assets/scene/solarsystem/planets/mars/moons/phobos.asset @@ -30,7 +30,7 @@ local Phobos = { }, Renderable = { Type = "RenderableGlobe", - Radii = { 27, 22, 18 }, + Radii = { 27000, 22000, 18000 }, SegmentsPerPatch = 90, Layers = { } diff --git a/data/assets/scene/solarsystem/planets/mercury/mercury.asset b/data/assets/scene/solarsystem/planets/mercury/mercury.asset index 8eda6c5eb9..0aafae5c38 100644 --- a/data/assets/scene/solarsystem/planets/mercury/mercury.asset +++ b/data/assets/scene/solarsystem/planets/mercury/mercury.asset @@ -2,185 +2,9 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') local labelsPath = asset.require('./mercury_globelabels').LabelsPath - asset.require("spice/base") asset.request('./trail') -local textures = asset.syncedResource({ - Name = "Mercury Textures", - Type = "HttpSynchronization", - Identifier = "mercury_abundance_textures", - Version = 1 -}) - -local mapServiceConfigs = asset.localResource("map_service_configs") - -local color_layers = { - --mdis - { - Identifier = "Messenger_MDIS_Utah", - Name = "Messenger MDIS [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerMDIS.wms", - Enabled = false - }, - { - Identifier = "Messenger_MDIS_Sweden", - Name = "Messenger MDIS [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_MDIS.wms", - }, - --mossaic - { - Identifier = "Messenger_Mosaic_Utah", - Name = "Messenger Mosaic [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerMosaic.wms" - }, - { - Identifier = "Messenger_Mosaic_Sweden", - Name = "Messenger Mosaic [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_Mosaic.wms" - }, - --bdr - { - Identifier = "Messenger_BDR_Utah", - Name = "Messenger BDR [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerBDR.wms", - TilePixelSize = 360, - Enabled = true - }, - { - Identifier = "Messenger_BDR_Sweden", - Name = "Messenger BDR [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_BDR.wms", - TilePixelSize = 360, - Enabled = false - }, - --mdr - { - Identifier = "Messenger_MDR_Utah", - Name = "Messenger MDR [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerMDR.wms", - Enabled = false - }, - --mp3 - { - Identifier = "Messenger_MP3_Utah", - Name = "Messenger MP3 [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerMP3.wms", - Enabled = false - }, - --hie - { - Identifier = "Messenger_HIE_Utah", - Name = "Messenger HIE [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerHIE.wms", - Enabled = false - }, - { - Identifier = "Messenger_HIE_Sweden", - Name = "Messenger HIE [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_HIE.wms", - Enabled = false - }, - --hiw - { - Identifier = "Messenger_HIW_Utah", - Name = "Messenger HIW [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerHIW.wms", - Enabled = false - }, - { - Identifier = "Messenger_HIW_Sweden", - Name = "Messenger HIW [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_HIW.wms", - Enabled = false - }, - --loi - { - Identifier = "Messenger_LOI_Utah", - Name = "Messenger LOI [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerLOI.wms", - Enabled = false - }, - { - Identifier = "Messenger_LOI_Sweden", - Name = "Messenger LOI [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_LOI.wms", - Enabled = false - }, - --shade - { - Identifier = "Messenger_SHADE_Utah", - Name = "Messenger SHADE [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerSHADE.wms", - Settings = { - Gamma = 1.33, - Multiplier = 1.15 - }, - BlendMode = "Multiply", - Enabled = false - }, - { - Identifier = "Messenger_SHADE_Sweden", - Name = "Messenger SHADE [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_SHADE.wms", - Settings = { - Gamma = 1.33, - Multiplier = 1.15 - }, - BlendMode = "Multiply", - Enabled = false - }, - --mosaic2 aka 8 color - { - Identifier = "Messenger_Mosaic2_Utah", - Name = "Messenger Mosaic2 [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerMosaic2.wms", - Enabled = false - }, - { - Identifier = "Messenger_Mosaic2_Sweden", - Name = "Messenger Mosaic2 [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_Mosaic_2.wms", - Enabled = false - }, - --local textures, these are mineral abundance maps - { - Identifier = "alsimap_02122015", - FilePath = textures .. "/alsimap_02122015.png", - Enabled = false, - BlendMode = "Multiply", - }, - { - Identifier = "casimap_02122015", - FilePath = textures .. "/casimap_02122015.png", - Enabled = false, - BlendMode = "Multiply", - }, - { - Identifier = "fesimap_02122015", - FilePath = textures .. "/fesimap_02122015.png", - Enabled = false, - BlendMode = "Multiply", - }, - { - Identifier = "mgsimap_02122015", - FilePath = textures .. "/mgsimap_02122015.png", - Enabled = false, - Settings = { - Gamma = 1.33, - Multiplier = 1.15 - }, - BlendMode = "Multiply", - - }, - { - Identifier = "ssimap_02122015", - FilePath = textures .. "/ssimap_02122015.png", - Enabled = false, - BlendMode = "Multiply", - } -} - local Mercury = { Identifier = "Mercury", Parent = transforms.MercuryBarycenter.Identifier, @@ -198,9 +22,7 @@ local Mercury = { Body = "MERCURY", CameraMinHeight = 300, SegmentsPerPatch = 64, - Layers = { - ColorLayers = color_layers - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/Mercury.labels", @@ -214,7 +36,7 @@ local Mercury = { FadeOutStartingDistance = 80000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1500000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "planet_solarSystem", "planet_terrestrial" }, diff --git a/data/assets/scene/solarsystem/planets/neptune/neptune.asset b/data/assets/scene/solarsystem/planets/neptune/neptune.asset index 326b2ef6c0..adff2b77fd 100644 --- a/data/assets/scene/solarsystem/planets/neptune/neptune.asset +++ b/data/assets/scene/solarsystem/planets/neptune/neptune.asset @@ -3,13 +3,6 @@ local transforms = asset.require('./transforms') asset.require("spice/base") asset.request('./trail') -local textures = asset.syncedResource({ - Name = "Neptune textures", - Type = "HttpSynchronization", - Identifier = "neptune_textures", - Version = 1 -}) - local Neptune = { Identifier = "Neptune", Parent = transforms.NeptuneBarycenter.Identifier, @@ -24,15 +17,7 @@ local Neptune = { Type = "RenderableGlobe", Radii = { 24764000.0, 24764000.0, 24314000.0 }, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/neptune.jpg", - Enabled = true - } - } - } + Layers = {} }, Tag = { "planet_solarSystem", "planet_giants" }, GUI = { diff --git a/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset b/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset index ded4b6ae73..91081403c7 100644 --- a/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset +++ b/data/assets/scene/solarsystem/planets/saturn/dione/dione.asset @@ -4,15 +4,6 @@ local kernel = asset.require('../kernels').sat375 asset.request('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Dione textures", - Type = "HttpSynchronization", - Identifier = "dione_textures", - Version = 1 -}) - local Dione = { Identifier = "Dione", Parent = transforms.SaturnBarycenter.Identifier, @@ -33,15 +24,7 @@ local Dione = { Type = "RenderableGlobe", Radii = 561400, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/dione.jpg", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/dione.labels", @@ -56,7 +39,7 @@ local Dione = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_saturn" }, diff --git a/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset b/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset index 8a66735198..4dd9296794 100644 --- a/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset +++ b/data/assets/scene/solarsystem/planets/saturn/enceladus/enceladus.asset @@ -4,17 +4,6 @@ local kernel = asset.require('../kernels').sat375 asset.request('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Enceladus textures", - Type = "HttpSynchronization", - Identifier = "enceladus_textures", - Version = 1 -}) - -local mapServiceConfigsPath = asset.localResource("map_service_configs") - local Enceladus = { Identifier = "Enceladus", Parent = transforms.SaturnBarycenter.Identifier, @@ -35,20 +24,7 @@ local Enceladus = { Type = "RenderableGlobe", Radii = 252000, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/enceladus.jpg", - }, - { - Identifier = "Global_Mosaic_100m_HPF", - Name = "Cassini Global Mosaic 100m HPF", - FilePath = mapServiceConfigsPath .. "/Cassini_ISS_Global_Mosaic_100m_HPF.wms", - Enabled = true, - }, - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/enceladus.labels", @@ -63,7 +39,7 @@ local Enceladus = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_saturn" }, diff --git a/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset b/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset index 892cc2c13e..d87978c575 100644 --- a/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset +++ b/data/assets/scene/solarsystem/planets/saturn/iapetus/iapetus.asset @@ -4,15 +4,6 @@ local kernel = asset.require('../kernels').sat375 asset.request('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Iapetus textures", - Type = "HttpSynchronization", - Identifier = "iapetus_textures", - Version = 1 -}) - local Iapetus = { Identifier = "Iapetus", Parent = transforms.SaturnBarycenter.Identifier, @@ -33,15 +24,7 @@ local Iapetus = { Type = "RenderableGlobe", Radii = 734000, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/iapetus.jpg", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/iapetus.labels", @@ -56,7 +39,7 @@ local Iapetus = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_saturn" }, diff --git a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset index 53d9b7da21..122df73011 100644 --- a/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset +++ b/data/assets/scene/solarsystem/planets/saturn/mimas/mimas.asset @@ -4,15 +4,6 @@ local kernel = asset.require('../kernels').sat375 asset.request('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Mimas textures", - Type = "HttpSynchronization", - Identifier = "mimas_textures", - Version = 1 -}) - local Mimas = { Identifier = "Mimas", Parent = transforms.SaturnBarycenter.Identifier, @@ -33,15 +24,7 @@ local Mimas = { Type = "RenderableGlobe", Radii = 198000, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/mimas.jpg", - Enabled = true - } - } - }, + Layers = { }, Labels = { Enable = false, FileName = labelsPath .. "/mimas.labels", @@ -56,7 +39,7 @@ local Mimas = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_saturn" }, diff --git a/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset b/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset index 008663ecf5..a662f29c57 100644 --- a/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset +++ b/data/assets/scene/solarsystem/planets/saturn/rhea/rhea.asset @@ -4,15 +4,6 @@ local kernel = asset.require('../kernels').sat375 asset.request('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Rhea textures", - Type = "HttpSynchronization", - Identifier = "rhea_textures", - Version = 1 -}) - local Rhea = { Identifier = "Rhea", Parent = transforms.SaturnBarycenter.Identifier, @@ -33,15 +24,7 @@ local Rhea = { Type = "RenderableGlobe", Radii = 765000, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/rhea.jpg", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/rhea.labels", @@ -56,7 +39,7 @@ local Rhea = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_saturn" }, diff --git a/data/assets/scene/solarsystem/planets/saturn/saturn.asset b/data/assets/scene/solarsystem/planets/saturn/saturn.asset index aeef8db352..5a3fd508e6 100644 --- a/data/assets/scene/solarsystem/planets/saturn/saturn.asset +++ b/data/assets/scene/solarsystem/planets/saturn/saturn.asset @@ -3,8 +3,6 @@ local assetHelper = asset.require('util/asset_helper') asset.require("spice/base") asset.request('./trail') - - local textures = asset.syncedResource({ Type = "HttpSynchronization", Name = "Saturn textures", @@ -26,15 +24,7 @@ local Saturn = { Type = "RenderableGlobe", Radii = { 60268000, 60268000, 54364000 }, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/saturn.jpg", - Enabled = true - } - } - }, + Layers = {}, Rings = { Texture = textures .. "/saturn_rings.png", Size = 140445000, diff --git a/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset b/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset index fea8618180..f9ceb09277 100644 --- a/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset +++ b/data/assets/scene/solarsystem/planets/saturn/tethys/tethys.asset @@ -4,15 +4,6 @@ local kernel = asset.require('../kernels').sat375 asset.request('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath - - -local textures = asset.syncedResource({ - Name = "Tethys textures", - Type = "HttpSynchronization", - Identifier = "tethys_textures", - Version = 1 -}) - local Tethys = { Identifier = "Tethys", Parent = transforms.SaturnBarycenter.Identifier, @@ -33,15 +24,7 @@ local Tethys = { Type = "RenderableGlobe", Radii = 531100, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/tethys.jpg", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/tethys.labels", @@ -56,7 +39,7 @@ local Tethys = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_saturn" }, diff --git a/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset b/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset index a086c9eecb..b323e25ec8 100644 --- a/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset +++ b/data/assets/scene/solarsystem/planets/saturn/titan/titan.asset @@ -4,16 +4,6 @@ local kernel = asset.require('../kernels').sat375 asset.request('./trail') local labelsPath = asset.require('../saturn_globelabels').LabelsPath - -local map_service_configs = asset.localResource("map_service_configs") - -local textures = asset.syncedResource({ - Type = "HttpSynchronization", - Name = "Titan textures", - Identifier = "titan_textures", - Version = 1 -}) - local Titan = { Identifier = "Titan", Parent = transforms.SaturnBarycenter.Identifier, @@ -34,21 +24,7 @@ local Titan = { Type = "RenderableGlobe", Radii = 2576000, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/titan.jpg", - -- Enabled = true - }, - { - Identifier = "Cassini_ISS_Global_Mosaic_4km_LiU", - Name = "Cassini ISS Global Mosaic [Sweden]", - FilePath = map_service_configs .. "/LiU/ISS_P19658_Mosaic_Global_4km.wms", - Enabled = true - } - } - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/titan.labels", @@ -63,7 +39,7 @@ local Titan = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 1350000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "moon_solarSystem", "moon_giants", "moon_saturn" }, diff --git a/data/assets/scene/solarsystem/planets/uranus/uranus.asset b/data/assets/scene/solarsystem/planets/uranus/uranus.asset index 4eca496359..b25675fbf3 100644 --- a/data/assets/scene/solarsystem/planets/uranus/uranus.asset +++ b/data/assets/scene/solarsystem/planets/uranus/uranus.asset @@ -3,15 +3,6 @@ local transforms = asset.require('./transforms') asset.require("spice/base") asset.request('./trail') - - -local textures = asset.syncedResource({ - Name = "Uranus Textures", - Type = "HttpSynchronization", - Identifier = "uranus_textures", - Version = 1 -}) - local Uranus = { Identifier = "Uranus", Parent = transforms.UranusBarycenter.Identifier, @@ -26,15 +17,7 @@ local Uranus = { Type = "RenderableGlobe", Radii = { 25559000, 25559000, 24973000 }, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/uranus.jpg", - Enabled = true - } - } - } + Layers = {} }, Tag = { "planet_solarSystem", "planet_giants" }, GUI = { diff --git a/data/assets/scene/solarsystem/planets/venus/venus.asset b/data/assets/scene/solarsystem/planets/venus/venus.asset index 486f2d2cab..fa3cc3a186 100644 --- a/data/assets/scene/solarsystem/planets/venus/venus.asset +++ b/data/assets/scene/solarsystem/planets/venus/venus.asset @@ -4,51 +4,6 @@ asset.require("spice/base") asset.request('./trail') local labelsPath = asset.require('./venus_globelabels').LabelsPath -local mapServiceConfigs = asset.localResource("map_service_configs") - -local textures = asset.syncedResource({ - Name = "Venus Textures", - Type = "HttpSynchronization", - Identifier = "venus_textures", - Version = 1 -}) - -local color_layers = { - { - Identifier = "Texture", - FilePath = textures .. "/venus.jpg", - Enabled = true, - Settings = { - Opacity = 0.48, - Gamma = 0.48 - } - }, - { - Identifier = "Magellan_Mosaic_Utah", - Name = "Magellan Mosaic [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MagellanMosaic.vrt", - BlendMode = "Color", - Settings = { - Gamma = 2.0 - }, - Enabled = true - }, -} - -local height_layers = { - { - Identifier = "Magellan", - Name = "Magellan Elevation [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MagellanDEM.wms", - TilePixelSize = 64, - Settings = { - Gamma = 1.72, - Multiplier = 1.1 - }, - Enabled = true - } -} - local Venus = { Identifier = "Venus", Parent = transforms.VenusBarycenter.Identifier, @@ -69,10 +24,7 @@ local Venus = { --Radii = { 6051900.0, 6051900.0, 6051800.0 }, Radii = { 6051900.0, 6051900.0, 6051900.0 }, SegmentsPerPatch = 64, - Layers = { - ColorLayers = color_layers, - HeightLayers = height_layers - }, + Layers = {}, Labels = { Enable = false, FileName = labelsPath .. "/venus.labels", @@ -87,7 +39,7 @@ local Venus = { FadeOutStartingDistance = 1000000.0, LabelsForceDomeRendering = true, LabelsDistanceEPS = 3500000.0, - LabelsColor = {1.0, 1.0, 0.0, 1.0} + LabelsColor = { 1.0, 1.0, 0.0 } } }, Tag = { "planet_solarSystem", "planet_terrestrial" }, diff --git a/data/assets/scene/solarsystem/sun/sun.asset b/data/assets/scene/solarsystem/sun/sun.asset index 10c0ff4aec..5fabf2aa61 100644 --- a/data/assets/scene/solarsystem/sun/sun.asset +++ b/data/assets/scene/solarsystem/sun/sun.asset @@ -1,6 +1,5 @@ local assetHelper = asset.require("util/asset_helper") local transforms = asset.require("./transforms") -local textures = asset.require('./sun_textures').TexturesPath asset.require("spice/base") local Sun = { @@ -11,15 +10,7 @@ local Sun = { Enabled = false, Radii = { 6.957E8, 6.957E8, 6.957E8 }, SegmentsPerPatch = 64, - Layers = { - ColorLayers = { - { - Identifier = "Texture", - FilePath = textures .. "/sun.jpg", - Enabled = true - } - } - }, + Layers = {}, PerformShading = false }, GUI = { diff --git a/data/assets/util/debug_helper.asset b/data/assets/util/debug_helper.asset index 90e80893e2..f01d50824d 100644 --- a/data/assets/util/debug_helper.asset +++ b/data/assets/util/debug_helper.asset @@ -61,8 +61,8 @@ local addCartesianAxes = function (specification) local name = specification.Name or specification.Identifier local parent = specification.Parent or "Root" local scale = specification.Scale or 1.0 - local position = specification.Position or {0.0, 0.0, 0.0} - local rotation = specification.Rotation or {0.0, 0.0, 0.0} + local position = specification.Position or { 0.0, 0.0, 0.0 } + local rotation = specification.Rotation or { 0.0, 0.0, 0.0 } local axes = { Identifier = identifier, @@ -84,9 +84,9 @@ local addCartesianAxes = function (specification) Renderable = { Type = "RenderableCartesianAxes", Enabled = true, - XColor = {1.0, 0.0, 0.0, 1.0}, - YColor = {0.0, 1.0, 0.0, 1.0}, - ZColor = {0.0, 0.0, 1.0, 1.0} + XColor = { 1.0, 0.0, 0.0 }, + YColor = { 0.0, 1.0, 0.0 }, + ZColor = { 0.0, 0.0, 1.0 } }, GUI = { Name = name, diff --git a/data/assets/util/generate_bookmarks.asset b/data/assets/util/generate_bookmarks.asset index 8c02268e83..2e3da2a9e3 100644 --- a/data/assets/util/generate_bookmarks.asset +++ b/data/assets/util/generate_bookmarks.asset @@ -35,7 +35,8 @@ local getBookmarks = function (guiPath, bookmarkfile) Renderable = { Type = 'RenderableSphericalGrid', Enabled = false, - GridColor = { 0.3, 0.84, 1.0, 0.3}, + Opacity = 0.3, + GridColor = { 0.3, 0.84, 1.0}, LineWidth = linewidth }, GUI = { diff --git a/include/openspace/engine/globals.h b/include/openspace/engine/globals.h index 0bf76957f5..1fcfca9b96 100644 --- a/include/openspace/engine/globals.h +++ b/include/openspace/engine/globals.h @@ -37,6 +37,7 @@ class Dashboard; class DeferredcasterManager; class DownloadManager; class LuaConsole; +class MemoryManager; class MissionManager; class ModuleEngine; class OpenSpaceEngine; @@ -59,7 +60,6 @@ namespace interaction { class SessionRecording; class ShortcutManager; } // namespace interaction -namespace performance { class PerformanceManager; } namespace properties { class PropertyOwner; } namespace scripting { class ScriptEngine; @@ -76,6 +76,7 @@ Dashboard& gDashboard(); DeferredcasterManager& gDeferredcasterManager(); DownloadManager& gDownloadManager(); LuaConsole& gLuaConsole(); +MemoryManager& gMemoryManager(); MissionManager& gMissionManager(); ModuleEngine& gModuleEngine(); OpenSpaceEngine& gOpenSpaceEngine(); @@ -96,7 +97,6 @@ interaction::KeybindingManager& gKeybindingManager(); interaction::NavigationHandler& gNavigationHandler(); interaction::SessionRecording& gSessionRecording(); interaction::ShortcutManager& gShortcutManager(); -performance::PerformanceManager& gPerformanceManager(); properties::PropertyOwner& gRootPropertyOwner(); properties::PropertyOwner& gScreenSpaceRootPropertyOwner(); scripting::ScriptEngine& gScriptEngine(); @@ -110,6 +110,7 @@ static Dashboard& dashboard = detail::gDashboard(); static DeferredcasterManager& deferredcasterManager = detail::gDeferredcasterManager(); static DownloadManager& downloadManager = detail::gDownloadManager(); static LuaConsole& luaConsole = detail::gLuaConsole(); +static MemoryManager& memoryManager = detail::gMemoryManager(); static MissionManager& missionManager = detail::gMissionManager(); static ModuleEngine& moduleEngine = detail::gModuleEngine(); static OpenSpaceEngine& openSpaceEngine = detail::gOpenSpaceEngine(); @@ -134,8 +135,6 @@ static interaction::KeybindingManager& keybindingManager = detail::gKeybindingMa static interaction::NavigationHandler& navigationHandler = detail::gNavigationHandler(); static interaction::SessionRecording& sessionRecording = detail::gSessionRecording(); static interaction::ShortcutManager& shortcutManager = detail::gShortcutManager(); -static performance::PerformanceManager& performanceManager = - detail::gPerformanceManager(); static properties::PropertyOwner& rootPropertyOwner = detail::gRootPropertyOwner(); static properties::PropertyOwner& screenSpaceRootPropertyOwner = detail::gScreenSpaceRootPropertyOwner(); diff --git a/include/openspace/interaction/camerainteractionstates.h b/include/openspace/interaction/camerainteractionstates.h index 0e6f0f56a4..43912f6d5c 100644 --- a/include/openspace/interaction/camerainteractionstates.h +++ b/include/openspace/interaction/camerainteractionstates.h @@ -68,7 +68,6 @@ protected: DelayedVariable velocity; }; - double _sensitivity = 0.0; InteractionState _globalRotationState; diff --git a/include/openspace/interaction/joystickcamerastates.h b/include/openspace/interaction/joystickcamerastates.h index ade9b9d2c7..f98dda8783 100644 --- a/include/openspace/interaction/joystickcamerastates.h +++ b/include/openspace/interaction/joystickcamerastates.h @@ -106,12 +106,46 @@ private: namespace ghoul { template <> -std::string to_string( - const openspace::interaction::JoystickCameraStates::AxisType& value); +inline std::string to_string( + const openspace::interaction::JoystickCameraStates::AxisType& value) +{ + using T = openspace::interaction::JoystickCameraStates::AxisType; + switch (value) { + case T::None: return "None"; + case T::OrbitX: return "Orbit X"; + case T::OrbitY: return "Orbit Y"; + case T::ZoomIn: return "Zoom In"; + case T::ZoomOut: return "Zoom Out"; + case T::LocalRollX: return "LocalRoll X"; + case T::LocalRollY: return "LocalRoll Y"; + case T::GlobalRollX: return "GlobalRoll X"; + case T::GlobalRollY: return "GlobalRoll Y"; + case T::PanX: return "Pan X"; + case T::PanY: return "Pan Y"; + default: return ""; + } +} template <> -openspace::interaction::JoystickCameraStates::AxisType -from_string(const std::string& string); +constexpr openspace::interaction::JoystickCameraStates::AxisType +from_string(std::string_view string) +{ + using T = openspace::interaction::JoystickCameraStates::AxisType; + + if (string == "None") { return T::None; } + if (string == "Orbit X") { return T::OrbitX; } + if (string == "Orbit Y") { return T::OrbitY; } + if (string == "Zoom In") { return T::ZoomIn; } + if (string == "Zoom Out") { return T::ZoomOut; } + if (string == "LocalRoll X") { return T::LocalRollX; } + if (string == "LocalRoll Y") { return T::LocalRollY; } + if (string == "GlobalRoll X") { return T::GlobalRollX; } + if (string == "GlobalRoll Y") { return T::GlobalRollY; } + if (string == "Pan X") { return T::PanX; } + if (string == "Pan Y") { return T::PanY; } + + throw RuntimeError("Unkonwn axis type '" + std::string(string) + "'"); +} } // namespace ghoul diff --git a/include/openspace/interaction/joystickinputstate.h b/include/openspace/interaction/joystickinputstate.h index 990cb2cf14..66c46ee11c 100644 --- a/include/openspace/interaction/joystickinputstate.h +++ b/include/openspace/interaction/joystickinputstate.h @@ -25,6 +25,8 @@ #ifndef __OPENSPACE_CORE___JOYSTICKINPUTSTATE___H__ #define __OPENSPACE_CORE___JOYSTICKINPUTSTATE___H__ +#include +#include #include #include #include @@ -113,10 +115,25 @@ struct JoystickInputStates : public std::array namespace ghoul { template <> -std::string to_string(const openspace::interaction::JoystickAction& value); +inline std::string to_string(const openspace::interaction::JoystickAction& value) { + switch (value) { + case openspace::interaction::JoystickAction::Idle: return "Idle"; + case openspace::interaction::JoystickAction::Press: return "Press"; + case openspace::interaction::JoystickAction::Repeat: return "Repeat"; + case openspace::interaction::JoystickAction::Release: return "Release"; + default: throw MissingCaseException(); + } +} template <> -openspace::interaction::JoystickAction from_string(const std::string& str); +constexpr openspace::interaction::JoystickAction from_string(std::string_view string) { + if (string == "Idle") { return openspace::interaction::JoystickAction::Idle; } + if (string == "Press") { return openspace::interaction::JoystickAction::Press; } + if (string == "Repeat") { return openspace::interaction::JoystickAction::Repeat; } + if (string == "Release") { return openspace::interaction::JoystickAction::Release; } + + throw RuntimeError("Unknown action '" + std::string(string) + "'"); +} } // namespace ghoul diff --git a/include/openspace/interaction/orbitalnavigator.h b/include/openspace/interaction/orbitalnavigator.h index c453691809..e541ab23fd 100644 --- a/include/openspace/interaction/orbitalnavigator.h +++ b/include/openspace/interaction/orbitalnavigator.h @@ -65,9 +65,9 @@ public: void setCamera(Camera* camera); void clearPreviousState(); - SceneGraphNode* focusNode() const; - void setFocusNode(const SceneGraphNode* focusNode); - void setFocusNode(const std::string& focusNode); + void setFocusNode(const SceneGraphNode* focusNode, + bool resetVelocitiesOnChange = true); + void setFocusNode(const std::string& focusNode, bool resetVelocitiesOnChange = true); void setAnchorNode(const std::string& anchorNode); void setAimNode(const std::string& aimNode); @@ -121,7 +121,8 @@ private: properties::FloatProperty friction; }; - void setAnchorNode(const SceneGraphNode* anchorNode); + void setAnchorNode(const SceneGraphNode* anchorNode, + bool resetVelocitiesOnChange = true); void setAimNode(const SceneGraphNode* aimNode); Camera* _camera; diff --git a/include/openspace/interaction/websocketcamerastates.h b/include/openspace/interaction/websocketcamerastates.h index d7bbd66613..3dffe9d690 100644 --- a/include/openspace/interaction/websocketcamerastates.h +++ b/include/openspace/interaction/websocketcamerastates.h @@ -106,12 +106,46 @@ private: namespace ghoul { template <> -std::string to_string( - const openspace::interaction::WebsocketCameraStates::AxisType& type); +inline std::string to_string( + const openspace::interaction::WebsocketCameraStates::AxisType& type) +{ + using T = openspace::interaction::WebsocketCameraStates::AxisType; + switch (type) { + case T::None: return "None"; + case T::OrbitX: return "Orbit X"; + case T::OrbitY: return "Orbit Y"; + case T::ZoomIn: return "Zoom In"; + case T::ZoomOut: return "Zoom Out"; + case T::LocalRollX: return "LocalRoll X"; + case T::LocalRollY: return "LocalRoll Y"; + case T::GlobalRollX: return "GlobalRoll X"; + case T::GlobalRollY: return "GlobalRoll Y"; + case T::PanX: return "Pan X"; + case T::PanY: return "Pan Y"; + default: return ""; + } +} template <> -openspace::interaction::WebsocketCameraStates::AxisType -from_string(const std::string& string); +constexpr openspace::interaction::WebsocketCameraStates::AxisType from_string( + std::string_view string) +{ + using T = openspace::interaction::WebsocketCameraStates::AxisType; + + if (string == "None") { return T::None; } + if (string == "Orbit X") { return T::OrbitX; } + if (string == "Orbit Y") { return T::OrbitY; } + if (string == "Zoom In") { return T::ZoomIn; } + if (string == "Zoom Out") { return T::ZoomOut; } + if (string == "LocalRoll X") { return T::LocalRollX; } + if (string == "LocalRoll Y") { return T::LocalRollY; } + if (string == "GlobalRoll X") { return T::GlobalRollX; } + if (string == "GlobalRoll Y") { return T::GlobalRollY; } + if (string == "Pan X") { return T::PanX; } + if (string == "Pan Y") { return T::PanY; } + + throw RuntimeError("Unknown axis type '" + std::string(string) + "'"); +} } // namespace ghoul diff --git a/include/openspace/interaction/websocketinputstate.h b/include/openspace/interaction/websocketinputstate.h index 3068e22294..7c59c89089 100644 --- a/include/openspace/interaction/websocketinputstate.h +++ b/include/openspace/interaction/websocketinputstate.h @@ -25,6 +25,8 @@ #ifndef __OPENSPACE_CORE___WEBSOCKETINPUTSTATE___H__ #define __OPENSPACE_CORE___WEBSOCKETINPUTSTATE___H__ +#include +#include #include #include #include @@ -115,10 +117,25 @@ struct WebsocketInputStates : public std::unordered_map -std::string to_string(const openspace::interaction::WebsocketAction& action); +inline std::string to_string(const openspace::interaction::WebsocketAction& action) { + switch (action) { + case openspace::interaction::WebsocketAction::Idle: return "Idle"; + case openspace::interaction::WebsocketAction::Press: return "Press"; + case openspace::interaction::WebsocketAction::Repeat: return "Repeat"; + case openspace::interaction::WebsocketAction::Release: return "Release"; + default: throw MissingCaseException(); + } +} template <> -openspace::interaction::WebsocketAction from_string(const std::string& str); +constexpr openspace::interaction::WebsocketAction from_string(std::string_view string) { + if (string == "Idle") { return openspace::interaction::WebsocketAction::Idle; } + if (string == "Press") { return openspace::interaction::WebsocketAction::Press; } + if (string == "Repeat") { return openspace::interaction::WebsocketAction::Repeat; } + if (string == "Release") { return openspace::interaction::WebsocketAction::Release; } + + throw RuntimeError("Unknown action '" + std::string(string) + "'"); +} } // namespace ghoul diff --git a/include/openspace/performance/performancelayout.h b/include/openspace/performance/performancelayout.h deleted file mode 100644 index 85d325cf45..0000000000 --- a/include/openspace/performance/performancelayout.h +++ /dev/null @@ -1,61 +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. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_CORE___PERFORMANCELAYOUT___H__ -#define __OPENSPACE_CORE___PERFORMANCELAYOUT___H__ - -#include - -namespace openspace::performance { - -struct PerformanceLayout { - constexpr static const int8_t Version = 0; - constexpr static const int LengthName = 256; - constexpr static const int NumberValues = 256; - constexpr static const int MaxValues = 1024; - - PerformanceLayout(); - - struct SceneGraphPerformanceLayout { - char name[LengthName]; - float renderTime[NumberValues]; - float updateRenderable[NumberValues]; - float updateTranslation[NumberValues]; - float updateRotation[NumberValues]; - float updateScaling[NumberValues]; - }; - SceneGraphPerformanceLayout sceneGraphEntries[MaxValues] = {}; - int16_t nScaleGraphEntries = 0; - - struct FunctionPerformanceLayout { - char name[LengthName]; - float time[NumberValues]; - }; - FunctionPerformanceLayout functionEntries[MaxValues] = {}; - int16_t nFunctionEntries = 0; -}; - -} // namespace openspace::performance - -#endif // __OPENSPACE_CORE___PERFORMANCELAYOUT___H__ diff --git a/include/openspace/performance/performancemanager.h b/include/openspace/performance/performancemanager.h deleted file mode 100644 index 4c37fd5b81..0000000000 --- a/include/openspace/performance/performancemanager.h +++ /dev/null @@ -1,94 +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. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_CORE___PERFORMANCEMANAGER___H__ -#define __OPENSPACE_CORE___PERFORMANCEMANAGER___H__ - -#include -#include -#include -#include - -namespace ghoul { class SharedMemory; } -namespace openspace { class SceneGraphNode; } - -namespace openspace::performance { - -struct PerformanceLayout; - -class PerformanceManager { -public: - static void CreateGlobalSharedMemory(); - static void DestroyGlobalSharedMemory(); - - void setEnabled(bool enabled); - bool isEnabled() const; - - void resetPerformanceMeasurements(); - - void storeIndividualPerformanceMeasurement(const std::string& identifier, - long long microseconds); - void storeScenePerformanceMeasurements( - const std::vector& sceneNodes); - - void outputLogs(); - - void writeData(std::ofstream& out, const std::vector& data); - - std::string formatLogName(std::string nodeName); - - void logDir(std::string dir); - const std::string& logDir() const; - void prefix(std::string prefix); - const std::string& prefix() const; - - void enableLogging(); - void disableLogging(); - void toggleLogging(); - void setLogging(bool enabled); - bool loggingEnabled() const; - - PerformanceLayout* performanceData(); - -private: - bool _performanceMeasurementEnabled = false; - bool _loggingEnabled = false; - - std::string _logDir; - std::string _prefix; - std::string _ext = "log"; - - std::map individualPerformanceLocations; - - std::unique_ptr _performanceMemory; - - size_t _currentTick = 0; - - void tick(); - bool createLogDir(); -}; - -} // namespace openspace::performance - -#endif // __OPENSPACE_CORE___PERFORMANCEMANAGER___H__ diff --git a/include/openspace/performance/performancemeasurement.h b/include/openspace/performance/performancemeasurement.h deleted file mode 100644 index 3222a72479..0000000000 --- a/include/openspace/performance/performancemeasurement.h +++ /dev/null @@ -1,55 +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. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_CORE___PERFORMANCEMEASUREMENT___H__ -#define __OPENSPACE_CORE___PERFORMANCEMEASUREMENT___H__ - -#include -#include - -namespace openspace::performance { - -class PerformanceManager; - -class PerformanceMeasurement { -public: - PerformanceMeasurement(std::string identifier); - ~PerformanceMeasurement(); - -private: - std::string _identifier; - std::chrono::high_resolution_clock::time_point _startTime; -}; - -#define __MERGE_PerfMeasure(a,b) a##b -#define __LABEL_PerfMeasure(a) __MERGE_PerfMeasure(unique_name_, a) - -/// Declare a new variable for measuring the performance of the current block -#define PerfMeasure(name) \ - auto __LABEL_PerfMeasure(__LINE__) = \ - openspace::performance::PerformanceMeasurement((name)) - -} // namespace openspace::performance - -#endif // __OPENSPACE_CORE___PERFORMANCEMEASUREMENT___H__ diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 1b2817c946..281c5ef85b 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace ghoul { class Dictionary; } namespace ghoul::opengl { @@ -58,7 +59,7 @@ public: Overlay = 16 }; - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Renderable(const ghoul::Dictionary& dictionary); diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 1fd08bc8a8..00db014de8 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -181,8 +181,6 @@ private: Camera* _camera = nullptr; Scene* _scene = nullptr; - properties::BoolProperty _doPerformanceMeasurements; - std::unique_ptr _renderer; RendererImplementation _rendererImplementation = RendererImplementation::Invalid; ghoul::Dictionary _rendererData; diff --git a/include/openspace/scene/rotation.h b/include/openspace/scene/rotation.h index 995543935f..ce6970716e 100644 --- a/include/openspace/scene/rotation.h +++ b/include/openspace/scene/rotation.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul { class Dictionary; } @@ -40,7 +41,7 @@ namespace documentation { struct Documentation; } class Rotation : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Rotation(const ghoul::Dictionary& dictionary); diff --git a/include/openspace/scene/scale.h b/include/openspace/scene/scale.h index 117db6bafd..ef9230d32d 100644 --- a/include/openspace/scene/scale.h +++ b/include/openspace/scene/scale.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul { class Dictionary; } @@ -40,7 +41,7 @@ namespace documentation { struct Documentation; } class Scale : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Scale(); diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index 8a19bbfbe2..3f9f5e6d7e 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -80,12 +81,12 @@ public: /** * Attach node to the root */ - void attachNode(std::unique_ptr node); + void attachNode(ghoul::mm_unique_ptr node); /** * Detach node from the root */ - std::unique_ptr detachNode(SceneGraphNode& node); + ghoul::mm_unique_ptr detachNode(SceneGraphNode& node); /** * Set the camera of the scene @@ -262,6 +263,8 @@ private: bool isExpired = false; }; std::vector _propertyInterpolationInfos; + + ghoul::MemoryPool<4096> _memoryPool; }; } // namespace openspace diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 81a3fa92c4..adf30bdc44 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -71,14 +72,6 @@ public: BooleanType(UpdateScene); - struct PerformanceRecord { - long long renderTime; // time in ns - long long updateTimeRenderable; // time in ns - long long updateTimeTranslation; // time in ns - long long updateTimeRotation; // time in ns - long long updateTimeScaling; // time in ns - }; - static constexpr const char* RootNodeIdentifier = "Root"; static constexpr const char* KeyIdentifier = "Identifier"; static constexpr const char* KeyParentName = "Parent"; @@ -88,7 +81,7 @@ public: SceneGraphNode(); ~SceneGraphNode(); - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); void initialize(); @@ -101,8 +94,8 @@ public: void update(const UpdateData& data); void render(const RenderData& data, RendererTasks& tasks); - void attachChild(std::unique_ptr child); - std::unique_ptr detachChild(SceneGraphNode& child); + void attachChild(ghoul::mm_unique_ptr child); + ghoul::mm_unique_ptr detachChild(SceneGraphNode& child); void clearChildren(); void setParent(SceneGraphNode& parent); @@ -138,9 +131,6 @@ public: SceneGraphNode* childNode(const std::string& identifier); - const PerformanceRecord& performanceRecord() const; - - void setRenderable(std::unique_ptr renderable); const Renderable* renderable() const; Renderable* renderable(); @@ -156,7 +146,7 @@ private: void computeScreenSpaceData(RenderData& newData); std::atomic _state = State::Loaded; - std::vector> _children; + std::vector> _children; SceneGraphNode* _parent = nullptr; std::vector _dependencies; std::vector _dependentNodes; @@ -166,32 +156,29 @@ private: // might be a node that is not very interesting (for example barycenters) properties::BoolProperty _guiHidden; - PerformanceRecord _performanceRecord = { 0, 0, 0, 0, 0 }; - - std::unique_ptr _renderable; + ghoul::mm_unique_ptr _renderable; properties::StringProperty _guiPath; properties::StringProperty _guiDisplayName; // Transformation defined by ephemeris, rotation and scale struct { - std::unique_ptr translation; - std::unique_ptr rotation; - std::unique_ptr scale; + ghoul::mm_unique_ptr translation; + ghoul::mm_unique_ptr rotation; + ghoul::mm_unique_ptr scale; } _transform; - std::unique_ptr _timeFrame; + ghoul::mm_unique_ptr _timeFrame; // Cached transform data glm::dvec3 _worldPositionCached = glm::dvec3(0.0); glm::dmat3 _worldRotationCached = glm::dmat3(1.0); glm::dvec3 _worldScaleCached = glm::dvec3(1.0); - float _fixedBoundingSphere = 0.f; - glm::dmat4 _modelTransformCached = glm::dmat4(1.0); glm::dmat4 _inverseModelTransformCached = glm::dmat4(1.0); + properties::FloatProperty _boundingSphere; properties::BoolProperty _computeScreenSpaceValues; properties::IVec2Property _screenSpacePosition; properties::BoolProperty _screenVisibility; diff --git a/include/openspace/scene/timeframe.h b/include/openspace/scene/timeframe.h index 95d5aff38c..ec66a07b0b 100644 --- a/include/openspace/scene/timeframe.h +++ b/include/openspace/scene/timeframe.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul { class Dictionary; } @@ -40,7 +41,7 @@ namespace documentation { struct Documentation; } class TimeFrame : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); TimeFrame(); diff --git a/include/openspace/scene/translation.h b/include/openspace/scene/translation.h index 9a027f1e07..f40e90bd17 100644 --- a/include/openspace/scene/translation.h +++ b/include/openspace/scene/translation.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -42,7 +43,7 @@ namespace documentation { struct Documentation; } class Translation : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Translation(); diff --git a/include/openspace/util/factorymanager.h b/include/openspace/util/factorymanager.h index 3edc713b5f..7d04502609 100644 --- a/include/openspace/util/factorymanager.h +++ b/include/openspace/util/factorymanager.h @@ -28,13 +28,9 @@ #include #include +#include #include -namespace ghoul { - template class TemplateFactory; - class TemplateFactoryBase; -} // namespace ghoul - namespace openspace { /** diff --git a/include/openspace/util/screenlog.h b/include/openspace/util/screenlog.h index c6ded67ff1..1619079830 100644 --- a/include/openspace/util/screenlog.h +++ b/include/openspace/util/screenlog.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace openspace { @@ -91,8 +92,8 @@ public: * \param category The category of the log message * \param message The actual log message that was transmitted */ - void log(ghoul::logging::LogLevel level, const std::string& category, - const std::string& message) override; + void log(ghoul::logging::LogLevel level, std::string_view category, + std::string_view message) override; /** * This method removes all the stored LogEntry%s that have expired, calculated by diff --git a/include/openspace/util/updatestructures.h b/include/openspace/util/updatestructures.h index 3baf2ac3cc..0613821590 100644 --- a/include/openspace/util/updatestructures.h +++ b/include/openspace/util/updatestructures.h @@ -45,13 +45,11 @@ struct UpdateData { TransformData modelTransform; const Time time; const Time previousFrameTime; - const bool doPerformanceMeasurement; }; struct RenderData { const Camera& camera; const Time time; - bool doPerformanceMeasurement = false; int renderBinMask = -1; TransformData modelTransform; }; diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index c94bc2d923..d321ce7a3a 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -59,7 +59,6 @@ #include -#include #include #include #include @@ -71,6 +70,7 @@ #include #include #include +#include #include #include #include @@ -125,12 +125,12 @@ namespace { const GLfloat vertex_data[] = { // x y z w - -size, -size, 0.0f, 1.0f, - size, size, 0.0f, 1.0f, - -size, size, 0.0f, 1.0f, - -size, -size, 0.0f, 1.0f, - size, -size, 0.0f, 1.0f, - size, size, 0.0f, 1.0f + -size, -size, 0.f, 1.f, + size, size, 0.f, 1.f, + -size, size, 0.f, 1.f, + -size, -size, 0.f, 1.f, + size, -size, 0.f, 1.f, + size, size, 0.f, 1.f }; glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW); @@ -154,6 +154,9 @@ void AtmosphereDeferredcaster::initialize() { if (!_atmosphereCalculated) { preCalculateAtmosphereParam(); } + + std::memset(_uniformNameBuffer, 0, sizeof(_uniformNameBuffer)); + std::strcpy(_uniformNameBuffer, "shadowDataArray["); } void AtmosphereDeferredcaster::deinitialize() { @@ -181,6 +184,8 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, const DeferredcastData&, ghoul::opengl::ProgramObject& program) { + ZoneScoped + // Atmosphere Frustum Culling glm::dvec3 tPlanetPosWorld = glm::dvec3( _modelTransform * glm::dvec4(0.0, 0.0, 0.0, 1.0) @@ -297,16 +302,18 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, // Shadow calculations.. if (!_shadowConfArray.empty()) { - std::vector shadowDataArray; - shadowDataArray.reserve(_shadowConfArray.size()); + ZoneScopedN("Shadow Configuration") - for (const ShadowConfiguration & shadowConf : _shadowConfArray) { + _shadowDataArrayCache.clear(); + + for (const ShadowConfiguration& shadowConf : _shadowConfArray) { // TO REMEMBER: all distances and lengths in world coordinates are in // meters!!! We need to move this to view space... // Getting source and caster: glm::dvec3 sourcePos = SpiceManager::ref().targetPosition( shadowConf.source.first, - "SUN", "GALACTIC", + "SUN", + "GALACTIC", {}, _time, lt @@ -314,7 +321,8 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, sourcePos *= KM_TO_M; // converting to meters glm::dvec3 casterPos = SpiceManager::ref().targetPosition( shadowConf.caster.first, - "SUN", "GALACTIC", + "SUN", + "GALACTIC", {}, _time, lt @@ -385,34 +393,32 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, (shadowData.rs - shadowData.rc); shadowData.casterPositionVec = casterPos; } - shadowDataArray.push_back(shadowData); + _shadowDataArrayCache.push_back(shadowData); } - const std::string uniformVarName("shadowDataArray["); + // _uniformNameBuffer[0..15] = "shadowDataArray[" unsigned int counter = 0; - for (const ShadowRenderingStruct& sd : shadowDataArray) { - std::stringstream ss; - ss << uniformVarName << counter << "].isShadowing"; - program.setUniform(ss.str(), sd.isShadowing); + for (const ShadowRenderingStruct& sd : _shadowDataArrayCache) { + // Add the counter + char* bf = fmt::format_to( + _uniformNameBuffer + 16, + "{}", counter + ); + + std::strcpy(bf, "].isShadowing\0"); + program.setUniform(_uniformNameBuffer, sd.isShadowing); + if (sd.isShadowing) { - ss.str(std::string()); - ss << uniformVarName << counter << "].xp"; - program.setUniform(ss.str(), sd.xp); - ss.str(std::string()); - ss << uniformVarName << counter << "].xu"; - program.setUniform(ss.str(), sd.xu); - // ss.str(std::string()); - // ss << uniformVarName << counter << "].rs"; - // program.setUniform(ss.str(), sd.rs); - ss.str(std::string()); - ss << uniformVarName << counter << "].rc"; - program.setUniform(ss.str(), sd.rc); - ss.str(std::string()); - ss << uniformVarName << counter << "].sourceCasterVec"; - program.setUniform(ss.str(), sd.sourceCasterVec); - ss.str(std::string()); - ss << uniformVarName << counter << "].casterPositionVec"; - program.setUniform(ss.str(), sd.casterPositionVec); + std::strcpy(bf, "].xp\0"); + program.setUniform(_uniformNameBuffer, sd.xp); + std::strcpy(bf, "].xu\0"); + program.setUniform(_uniformNameBuffer, sd.xu); + std::strcpy(bf, "].rc\0"); + program.setUniform(_uniformNameBuffer, sd.rc); + std::strcpy(bf, "].sourceCasterVec\0"); + program.setUniform(_uniformNameBuffer, sd.sourceCasterVec); + std::strcpy(bf, "].casterPositionVec\0"); + program.setUniform(_uniformNameBuffer, sd.casterPositionVec); } counter++; } @@ -440,6 +446,8 @@ void AtmosphereDeferredcaster::postRaycast(const RenderData&, const DeferredcastData&, ghoul::opengl::ProgramObject&) { + ZoneScoped + // Deactivate the texture units _transmittanceTableTextureUnit.deactivate(); _irradianceTableTextureUnit.deactivate(); @@ -552,6 +560,9 @@ void AtmosphereDeferredcaster::setShadowConfigArray( std::vector shadowConfigArray) { _shadowConfArray = std::move(shadowConfigArray); + + _shadowDataArrayCache.clear(); + _shadowDataArrayCache.reserve(_shadowConfArray.size()); } void AtmosphereDeferredcaster::enableSunFollowing(bool enable) { diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.h b/modules/atmosphere/rendering/atmospheredeferredcaster.h index 89a250ece3..8f5cf1b75c 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.h +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -193,6 +194,12 @@ private: // Atmosphere Debugging float _calculationTextureScale = 1.f; bool _saveCalculationTextures = false; + + std::vector _shadowDataArrayCache; + // Assuming < 1000 shadow casters, the longest uniform name that we are getting is + // shadowDataArray[999].casterPositionVec + // which needs to fit into the uniform buffer + char _uniformNameBuffer[40]; }; } // openspace diff --git a/modules/atmosphere/rendering/renderableatmosphere.h b/modules/atmosphere/rendering/renderableatmosphere.h index a2cfa7f158..685ddf3830 100644 --- a/modules/atmosphere/rendering/renderableatmosphere.h +++ b/modules/atmosphere/rendering/renderableatmosphere.h @@ -27,8 +27,6 @@ #include -#include - #include #include #include diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index aaeb8cb6e1..12a0003a69 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -429,10 +429,7 @@ void DashboardItemAngle::render(glm::vec2& penPosition) { glm::vec2 DashboardItemAngle::size() const { constexpr const double Angle = 120; - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, - "Angle: " + std::to_string(Angle) - ).boundingBox; + return _font->boundingBox("Angle: " + std::to_string(Angle)); } } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp index f0e5f21d0e..4accac477f 100644 --- a/modules/base/dashboard/dashboarditemdate.cpp +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -119,10 +119,9 @@ void DashboardItemDate::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemDate::size() const { - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, + return _font->boundingBox( fmt::format("Date: {} UTC", global::timeManager.time().UTC()) - ).boundingBox; + ); } } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 1f986c4595..92e1b74365 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -463,10 +463,9 @@ glm::vec2 DashboardItemDistance::size() const { dist = { convertedD, nameForDistanceUnit(unit, convertedD != 1.0) }; } - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, + return _font->boundingBox( fmt::format("Distance from focus: {} {}", dist.first, dist.second) - ).boundingBox; + ); } } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp index 7e7c31f59b..7588c7a215 100644 --- a/modules/base/dashboard/dashboarditemframerate.cpp +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -301,21 +301,14 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemFramerate::size() const { - FrametimeType frametimeType = FrametimeType(_frametimeType.value()); - const std::string output = format( - frametimeType, - _minDeltaTimeCache, - _maxDeltaTimeCache - ); + const FrametimeType t = FrametimeType(_frametimeType.value()); + const std::string output = format(t, _minDeltaTimeCache, _maxDeltaTimeCache); if (output.empty()) { return { 0.f, 0.f }; } - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, - output - ).boundingBox; + return _font->boundingBox(output); } } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemparallelconnection.cpp b/modules/base/dashboard/dashboarditemparallelconnection.cpp index c894446637..30911be306 100644 --- a/modules/base/dashboard/dashboarditemparallelconnection.cpp +++ b/modules/base/dashboard/dashboarditemparallelconnection.cpp @@ -208,10 +208,7 @@ glm::vec2 DashboardItemParallelConnection::size() const { } if (!connectionInfo.empty()) { - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, - connectionInfo - ).boundingBox; + return _font->boundingBox(connectionInfo); } else { return { 0.f, 0.f }; diff --git a/modules/base/dashboard/dashboarditempropertyvalue.cpp b/modules/base/dashboard/dashboarditempropertyvalue.cpp index 77f9c5fa7c..c884458d7d 100644 --- a/modules/base/dashboard/dashboarditempropertyvalue.cpp +++ b/modules/base/dashboard/dashboarditempropertyvalue.cpp @@ -166,10 +166,7 @@ void DashboardItemPropertyValue::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemPropertyValue::size() const { - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, - _displayString.value() - ).boundingBox; + return _font->boundingBox(_displayString.value()); } } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index e0aa1da825..11c310943c 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -238,13 +238,12 @@ glm::vec2 DashboardItemSimulationIncrement::size() const { deltaTime = { convertedT, nameForTimeUnit(unit, convertedT != 1.0) }; } - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, + return _font->boundingBox( fmt::format( "Simulation increment: {:.1f} {:s} / second", deltaTime.first, deltaTime.second ) - ).boundingBox; + ); } } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemvelocity.cpp b/modules/base/dashboard/dashboarditemvelocity.cpp index aa0d42f394..12952fb0bb 100644 --- a/modules/base/dashboard/dashboarditemvelocity.cpp +++ b/modules/base/dashboard/dashboarditemvelocity.cpp @@ -229,10 +229,9 @@ glm::vec2 DashboardItemVelocity::size() const { dist = { convertedD, nameForDistanceUnit(unit, convertedD != 1.0) }; } - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, + return _font->boundingBox( fmt::format("Camera velocity: {} {}/s", dist.first, dist.second) - ).boundingBox; + ); } } // namespace openspace diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index 1fee2ed0cd..d597230d9f 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -81,7 +81,8 @@ std::unique_ptr ModelGeometry::createFromDictionary( const std::string& geometryType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - return factory->create(geometryType, dictionary);; + ModelGeometry* geometry = factory->create(geometryType, dictionary); + return std::unique_ptr(geometry); } ModelGeometry::ModelGeometry(const ghoul::Dictionary& dictionary) diff --git a/modules/base/rendering/renderablecartesianaxes.cpp b/modules/base/rendering/renderablecartesianaxes.cpp index bfc3928956..76f3ce42fa 100644 --- a/modules/base/rendering/renderablecartesianaxes.cpp +++ b/modules/base/rendering/renderablecartesianaxes.cpp @@ -68,19 +68,19 @@ documentation::Documentation RenderableCartesianAxes::Documentation() { { { XColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, XColorInfo.description }, { YColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, YColorInfo.description }, { ZColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, ZColorInfo.description } @@ -94,21 +94,21 @@ RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictio , _program(nullptr) , _xColor( XColorInfo, - glm::vec4(0.f, 0.f, 0.f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) + glm::vec3(1.f, 0.f, 0.f), + glm::vec3(0.f), + glm::vec3(1.f) ) , _yColor( YColorInfo, - glm::vec4(0.f, 1.f, 0.f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) + glm::vec3(0.f, 1.f, 0.f), + glm::vec3(0.f), + glm::vec3(1.f) ) , _zColor( ZColorInfo, - glm::vec4(0.f, 0.f, 1.f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) + glm::vec3(0.f, 0.f, 1.f), + glm::vec3(0.f), + glm::vec3(1.f) ) { documentation::testSpecificationAndThrow( @@ -118,19 +118,19 @@ RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictio ); if (dictionary.hasKey(XColorInfo.identifier)) { - _xColor = dictionary.value(XColorInfo.identifier); + _xColor = dictionary.value(XColorInfo.identifier); } _xColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_xColor); if (dictionary.hasKey(XColorInfo.identifier)) { - _yColor = dictionary.value(YColorInfo.identifier); + _yColor = dictionary.value(YColorInfo.identifier); } _yColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_yColor); if (dictionary.hasKey(ZColorInfo.identifier)) { - _zColor = dictionary.value(ZColorInfo.identifier); + _zColor = dictionary.value(ZColorInfo.identifier); } _zColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_zColor); diff --git a/modules/base/rendering/renderablecartesianaxes.h b/modules/base/rendering/renderablecartesianaxes.h index 600770100b..99741b9fb6 100644 --- a/modules/base/rendering/renderablecartesianaxes.h +++ b/modules/base/rendering/renderablecartesianaxes.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include namespace ghoul::opengl { class ProgramObject; } @@ -61,9 +61,9 @@ protected: ghoul::opengl::ProgramObject* _program; - properties::Vec4Property _xColor; - properties::Vec4Property _yColor; - properties::Vec4Property _zColor; + properties::Vec3Property _xColor; + properties::Vec3Property _yColor; + properties::Vec3Property _zColor; GLuint _vaoId = 0; GLuint _vBufferId = 0; diff --git a/modules/base/rendering/renderablelabels.cpp b/modules/base/rendering/renderablelabels.cpp index dfff61258d..f9f9c4958c 100644 --- a/modules/base/rendering/renderablelabels.cpp +++ b/modules/base/rendering/renderablelabels.cpp @@ -201,7 +201,7 @@ documentation::Documentation RenderableLabels::Documentation() { }, { LabelColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, LabelColorInfo.description, }, @@ -214,7 +214,7 @@ documentation::Documentation RenderableLabels::Documentation() { { LabelTextInfo.identifier, new StringVerifier, - Optional::No, + Optional::Yes, LabelTextInfo.description }, { @@ -304,9 +304,9 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) , _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown) , _labelColor( LabelColorInfo, - glm::vec4(1.f, 1.f, 1.f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) + glm::vec3(1.f, 1.f, 1.f), + glm::vec3(0.f), + glm::vec3(1.f) ) , _labelSize(LabelSizeInfo, 8.f, 0.5f, 30.f) , _fontSize(FontSizeInfo, 50.f, 1.f, 100.f) @@ -314,7 +314,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) , _labelMaxSize(LabelMaxSizeInfo, 20.f, 0.5f, 100.f) , _pixelSizeControl(PixelSizeControlInfo, false) , _enableFadingEffect(EnableFadingEffectInfo, false) - , _labelText(LabelTextInfo) + , _labelText(LabelTextInfo, "") , _fadeStartDistance(FadeStartDistInfo, 1.f, 0.f, 100.f) , _fadeEndDistance(FadeEndDistInfo, 1.f, 0.f, 100.f) , _fadeStartSpeed(FadeStartSpeedInfo, 1.f, 1.f, 100.f) @@ -338,6 +338,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary) "RenderableLabels" ); + addProperty(_opacity); registerUpdateRenderBinFromOpacity(); _blendMode.addOptions({ @@ -691,7 +692,7 @@ void RenderableLabels::renderLabels(const RenderData& data, const glm::dvec3& orthoRight, const glm::dvec3& orthoUp, float fadeInVariable) { - glm::vec4 textColor = _labelColor; + glm::vec4 textColor = glm::vec4(glm::vec3(_labelColor), 1.f); textColor.a *= fadeInVariable; textColor.a *= _opacity; @@ -718,7 +719,7 @@ void RenderableLabels::renderLabels(const RenderData& data, ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( *_font, transformedPos, - _labelText, + _labelText.value(), textColor, labelInfo ); diff --git a/modules/base/rendering/renderablelabels.h b/modules/base/rendering/renderablelabels.h index 7d0466b9d0..af3b90ece5 100644 --- a/modules/base/rendering/renderablelabels.h +++ b/modules/base/rendering/renderablelabels.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include @@ -104,7 +104,7 @@ private: float linearSmoothStepFunc(float x, float startX, float endX, float sUnit, float eUnit) const; - properties::Vec4Property _labelColor; + properties::Vec3Property _labelColor; properties::FloatProperty _labelSize; properties::FloatProperty _fontSize; properties::FloatProperty _labelMinSize; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 753a11a432..b4250a1238 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -383,7 +383,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { ); glm::dmat4 crippedModelViewTransform = glm::transpose(glm::inverse( - glm::dmat4(glm::inverse(data.camera.sgctInternal.viewMatrix())) * modelViewTransform + glm::dmat4(glm::inverse(data.camera.sgctInternal.viewMatrix())) * modelViewTransform )); _program->setUniform( @@ -425,7 +425,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) { } _geometry->render(); - + if (_disableFaceCulling) { glEnable(GL_CULL_FACE); } diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index bd46acce0c..d38c48c417 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -360,7 +360,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { ); _shader->setUniform(_uniformCache.modelViewRotation, modelViewRotation); - float adjustedTransparency = _opacity; + float adjustedOpacity = _opacity; if (!_disableFadeInDistance) { if (_fadeInThreshold > -1.0) { @@ -377,10 +377,10 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { 0.f, 1.f ); - adjustedTransparency *= fadeFactor; + adjustedOpacity *= fadeFactor; } else if (logDistCamera <= startLogFadeDistance) { - adjustedTransparency = 0.f; + adjustedOpacity = 0.f; } } @@ -398,19 +398,19 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { 0.f, 1.f ); - adjustedTransparency *= (1.f - fadeFactor); + adjustedOpacity *= (1.f - fadeFactor); } else if (logDistCamera >= stopLogFadeDistance) { - adjustedTransparency = 0.f; + adjustedOpacity = 0.f; } } } // Performance wise - if (adjustedTransparency < 0.01f) { + if (adjustedOpacity < 0.01f) { return; } - _shader->setUniform(_uniformCache.opacity, adjustedTransparency); + _shader->setUniform(_uniformCache.opacity, adjustedOpacity); _shader->setUniform(_uniformCache._mirrorTexture, _mirrorTexture.value()); ghoul::opengl::TextureUnit unit; diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index d40a6e638f..ed57c6830d 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,7 @@ namespace { constexpr const char* ProgramName = "EphemerisProgram"; constexpr const char* KeyTranslation = "Translation"; + #ifdef __APPLE__ constexpr const std::array UniformNames = { "opacity", "modelViewTransform", "projectionTransform", "color", "useLineFade", @@ -321,7 +323,105 @@ bool RenderableTrail::isReady() const { return _programObject != nullptr; } +void RenderableTrail::internalRender(bool renderLines, bool renderPoints, + const RenderData& data, + const glm::dmat4& modelTransform, + RenderInformation& info, int nVertices, int offset) +{ + ZoneScoped + + // We pass in the model view transformation matrix as double in order to maintain + // high precision for vertices; especially for the trails, a high vertex precision + // is necessary as they are usually far away from their reference + _programObject->setUniform( + _uniformCache.modelView, + data.camera.combinedViewMatrix() * modelTransform * info._localTransform + ); + + const int sorting = [](RenderInformation::VertexSorting sorting) { + switch (sorting) { + case RenderInformation::VertexSorting::NewestFirst: return 0; + case RenderInformation::VertexSorting::OldestFirst: return 1; + case RenderInformation::VertexSorting::NoSorting: return 2; + } + }(info.sorting); + + // The vertex sorting method is used to tweak the fading along the trajectory + _programObject->setUniform(_uniformCache.vertexSorting, sorting); + + // This value is subtracted from the vertex id in the case of a potential ring + // buffer (as used in RenderableTrailOrbit) to keep the first vertex at its + // brightest + _programObject->setUniform(_uniformCache.idOffset, offset); + + _programObject->setUniform(_uniformCache.nVertices, nVertices); + +#if !defined(__APPLE__) + glm::ivec2 resolution = global::renderEngine.renderingResolution(); + _programObject->setUniform(_uniformCache.resolution, resolution); + _programObject->setUniform( + _uniformCache.lineWidth, + std::ceil((2.f * 1.f + _appearance.lineWidth) * std::sqrt(2.f)) + ); +#endif + + if (renderPoints) { + // The stride parameter determines the distance between larger points and + // smaller ones + _programObject->setUniform(_uniformCache.stride, info.stride); + _programObject->setUniform(_uniformCache.pointSize, _appearance.pointSize); + } + + // Fragile! Keep in sync with fragment shader + enum RenderPhase { + RenderPhaseLines = 0, + RenderPhasePoints + }; + + glBindVertexArray(info._vaoID); + if (renderLines) { + _programObject->setUniform(_uniformCache.renderPhase, RenderPhaseLines); + // Subclasses of this renderer might be using the index array or might now be + // so we check if there is data available and if there isn't, we use the + // glDrawArrays draw call; otherwise the glDrawElements + if (info._iBufferID == 0) { + glDrawArrays( + GL_LINE_STRIP, + info.first, + info.count + ); + } + else { + glDrawElements( + GL_LINE_STRIP, + info.count, + GL_UNSIGNED_INT, + reinterpret_cast(info.first * sizeof(unsigned int)) + ); + } + } + if (renderPoints) { + // Subclasses of this renderer might be using the index array or might now be + // so we check if there is data available and if there isn't, we use the + // glDrawArrays draw call; otherwise the glDrawElements + _programObject->setUniform(_uniformCache.renderPhase, RenderPhasePoints); + if (info._iBufferID == 0) { + glDrawArrays(GL_POINTS, info.first, info.count); + } + else { + glDrawElements( + GL_POINTS, + info.count, + GL_UNSIGNED_INT, + reinterpret_cast(info.first * sizeof(unsigned int)) + ); + } + } +} +#pragma optimize("", off) void RenderableTrail::render(const RenderData& data, RendererTasks&) { + ZoneScoped + _programObject->activate(); _programObject->setUniform(_uniformCache.opacity, _opacity); @@ -341,13 +441,6 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { /*glm::ivec2 resolution = global::renderEngine.renderingResolution(); _programObject->setUniform(_uniformCache.resolution, resolution);*/ - static std::map SortingMapping = { - // Fragile! Keep in sync with shader - { RenderInformation::VertexSorting::NewestFirst, 0 }, - { RenderInformation::VertexSorting::OldestFirst, 1 }, - { RenderInformation::VertexSorting::NoSorting, 2} - }; - const bool usingFramebufferRenderer = global::renderEngine.rendererImplementation() == RenderEngine::RendererImplementation::Framebuffer; @@ -374,89 +467,6 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { glEnable(GL_PROGRAM_POINT_SIZE); } - auto render = [renderLines, renderPoints, p = _programObject, &data, - &modelTransform, pointSize = _appearance.pointSize.value(), - c = _uniformCache, lw = _appearance.lineWidth] - (RenderInformation& info, int nVertices, int offset) - { - // We pass in the model view transformation matrix as double in order to maintain - // high precision for vertices; especially for the trails, a high vertex precision - // is necessary as they are usually far away from their reference - p->setUniform( - c.modelView, - data.camera.combinedViewMatrix() * modelTransform * info._localTransform - ); - - // The vertex sorting method is used to tweak the fading along the trajectory - p->setUniform(c.vertexSorting, SortingMapping[info.sorting]); - - // This value is subtracted from the vertex id in the case of a potential ring - // buffer (as used in RenderableTrailOrbit) to keep the first vertex at its - // brightest - p->setUniform(c.idOffset, offset); - - p->setUniform(c.nVertices, nVertices); - -#if !defined(__APPLE__) - glm::ivec2 resolution = global::renderEngine.renderingResolution(); - p->setUniform(c.resolution, resolution); - p->setUniform(c.lineWidth, std::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 - p->setUniform(c.stride, info.stride); - p->setUniform(c.pointSize, pointSize); - } - - // Fragile! Keep in sync with fragment shader - enum RenderPhase { - RenderPhaseLines = 0, - RenderPhasePoints - }; - - glBindVertexArray(info._vaoID); - if (renderLines) { - p->setUniform(c.renderPhase, RenderPhaseLines); - // Subclasses of this renderer might be using the index array or might now be - // so we check if there is data available and if there isn't, we use the - // glDrawArrays draw call; otherwise the glDrawElements - if (info._iBufferID == 0) { - glDrawArrays( - GL_LINE_STRIP, - info.first, - info.count - ); - } - else { - glDrawElements( - GL_LINE_STRIP, - info.count, - GL_UNSIGNED_INT, - reinterpret_cast(info.first * sizeof(unsigned int)) - ); - } - } - if (renderPoints) { - // Subclasses of this renderer might be using the index array or might now be - // so we check if there is data available and if there isn't, we use the - // glDrawArrays draw call; otherwise the glDrawElements - p->setUniform(c.renderPhase, RenderPhasePoints); - if (info._iBufferID == 0) { - glDrawArrays(GL_POINTS, info.first, info.count); - } - else { - glDrawElements( - GL_POINTS, - info.count, - GL_UNSIGNED_INT, - reinterpret_cast(info.first * sizeof(unsigned int)) - ); - } - } - }; - // The combined size of vertices; -1 because we duplicate the penultimate point const int totalNumber = _primaryRenderInformation.count + _floatingRenderInformation.count - 1; @@ -468,29 +478,34 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { _primaryRenderInformation.first; // Culling - const double scaledRadius = glm::length( - glm::dmat3(modelTransform) * glm::dvec3(_boundingSphere, 0.0, 0.0) - ); - - glm::dvec3 trailPosWorld = glm::dvec3( + const glm::dvec3 trailPosWorld = glm::dvec3( modelTransform * _primaryRenderInformation._localTransform * glm::dvec4(0.0, 0.0, 0.0, 1.0) ); - const double distance = glm::distance( - trailPosWorld, - data.camera.eyePositionVec3() - ); + const double distance = glm::distance(trailPosWorld, data.camera.eyePositionVec3()); - if (distance > scaledRadius * DISTANCE_CULLING_RADII) { + if (distance > _boundingSphere * DISTANCE_CULLING_RADII) { return; } // Render the primary batch of vertices - render(_primaryRenderInformation, totalNumber, primaryOffset); + internalRender( + renderLines, + renderPoints, + data, + modelTransform, + _primaryRenderInformation, + totalNumber, + primaryOffset + ); // The secondary batch is optional, so we need to check whether we have any data here if (_floatingRenderInformation._vaoID != 0 && _floatingRenderInformation.count != 0) { - render( + internalRender( + renderLines, + renderPoints, + data, + modelTransform, _floatingRenderInformation, totalNumber, // -1 because we duplicate the penultimate point between the vertices diff --git a/modules/base/rendering/renderabletrail.h b/modules/base/rendering/renderabletrail.h index 7c6338ea75..41c7437409 100644 --- a/modules/base/rendering/renderabletrail.h +++ b/modules/base/rendering/renderabletrail.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -125,7 +126,7 @@ protected: std::vector _indexArray; /// The Translation object that provides the position of the individual trail points - std::unique_ptr _translation; + ghoul::mm_unique_ptr _translation; /// The RenderInformation contains information filled in by the concrete subclasses to /// be used by this class. @@ -162,22 +163,11 @@ protected: RenderInformation _floatingRenderInformation; private: + void internalRender(bool renderLines, bool renderPoints, + const RenderData& data, + const glm::dmat4& modelTransform, + RenderInformation& info, int nVertices, int offset); -/* - /// Specifies the base color of the line before fading - properties::Vec3Property _lineColor; - /// Settings that enables or disables the line fading - properties::BoolProperty _useLineFade; - /// Specifies a multiplicative factor that fades out the line - properties::FloatProperty _lineFade; - /// Line width for the line rendering part - properties::FloatProperty _lineWidth; - /// Point size for the point rendering part - properties::IntProperty _pointSize; - /// The option determining which rendering method to use - properties::OptionProperty _renderingModes; - - */ Appearance _appearance; /// Program object used to render the data stored in RenderInformation diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index b489867cf0..e2c182744a 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -237,8 +237,7 @@ void RenderableTrailOrbit::update(const UpdateData& data) { const glm::vec3 p = _translation->position({ {}, data.time, - Time(0.0), - false + Time(0.0) }); _vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z }; @@ -434,8 +433,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( const glm::vec3 p = _translation->position({ {}, Time(_lastPointTime), - Time(0.0), - false + Time(0.0) }); _vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z }; @@ -474,8 +472,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( const glm::vec3 p = _translation->position({ {}, Time(_firstPointTime), - Time(0.0), - false + Time(0.0) }); _vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z }; @@ -517,7 +514,7 @@ void RenderableTrailOrbit::fullSweep(double time) { const double secondsPerPoint = _period / (_resolution - 1); // starting at 1 because the first position is a floating current one for (int i = 1; i < _resolution; ++i) { - const glm::vec3 p = _translation->position({ {}, Time(time), Time(0.0), false }); + const glm::vec3 p = _translation->position({ {}, Time(time), Time(0.0) }); _vertexArray[i] = { p.x, p.y, p.z }; time -= secondsPerPoint; diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index 966ffd51af..5efe975a24 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -227,8 +227,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) { const glm::vec3 p = _translation->position({ {}, Time(_start + i * totalSampleInterval), - Time(0.0), - false + Time(0.0) }); _vertexArray[i] = { p.x, p.y, p.z }; } diff --git a/modules/base/rotation/timelinerotation.cpp b/modules/base/rotation/timelinerotation.cpp index 533fd21e47..53657cc1cf 100644 --- a/modules/base/rotation/timelinerotation.cpp +++ b/modules/base/rotation/timelinerotation.cpp @@ -74,7 +74,7 @@ TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary) { for (const std::string& timeString : timeStrings) { const double t = Time::convertTime(timeString); - std::unique_ptr rotation = + ghoul::mm_unique_ptr rotation = Rotation::createFromDictionary( keyframes.value(timeString) ); @@ -87,7 +87,7 @@ TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary) { glm::dmat3 TimelineRotation::matrix(const UpdateData& data) const { const double now = data.time.j2000Seconds(); - using KeyframePointer = const Keyframe>*; + using KeyframePointer = const Keyframe>*; KeyframePointer prev = _timeline.lastKeyframeBefore(now, true); KeyframePointer next = _timeline.firstKeyframeAfter(now, true); diff --git a/modules/base/rotation/timelinerotation.h b/modules/base/rotation/timelinerotation.h index a5f6a3b41a..7e1a7d9132 100644 --- a/modules/base/rotation/timelinerotation.h +++ b/modules/base/rotation/timelinerotation.h @@ -41,7 +41,7 @@ public: static documentation::Documentation Documentation(); private: - Timeline> _timeline; + Timeline> _timeline; }; } // namespace openspace diff --git a/modules/base/shaders/axes_fs.glsl b/modules/base/shaders/axes_fs.glsl index 0b1513ac46..8540409131 100644 --- a/modules/base/shaders/axes_fs.glsl +++ b/modules/base/shaders/axes_fs.glsl @@ -29,18 +29,19 @@ in float vs_screenSpaceDepth; in vec4 vs_positionViewSpace; in vec3 vs_positionModelSpace; -uniform vec4 xColor; -uniform vec4 yColor; -uniform vec4 zColor; +uniform vec3 xColor; +uniform vec3 yColor; +uniform vec3 zColor; Fragment getFragment() { Fragment frag; vec3 colorComponents = step(0.01f, vs_positionModelSpace); - frag.color = colorComponents.x * xColor + + frag.color.rgb = colorComponents.x * xColor + colorComponents.y * yColor + colorComponents.z * zColor; + frag.color.a = 1.0; frag.depth = vs_screenSpaceDepth; frag.gPosition = vs_positionViewSpace; diff --git a/modules/base/timeframe/timeframeunion.h b/modules/base/timeframe/timeframeunion.h index 0b3c761859..27a0344e7b 100644 --- a/modules/base/timeframe/timeframeunion.h +++ b/modules/base/timeframe/timeframeunion.h @@ -42,7 +42,7 @@ public: static documentation::Documentation Documentation(); private: - std::vector> _timeFrames; + std::vector> _timeFrames; }; } // namespace openspace diff --git a/modules/base/translation/timelinetranslation.cpp b/modules/base/translation/timelinetranslation.cpp index 396e39e27f..6cf6da3195 100644 --- a/modules/base/translation/timelinetranslation.cpp +++ b/modules/base/translation/timelinetranslation.cpp @@ -74,7 +74,7 @@ TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary) { for (const std::string& timeString : timeStrings) { const double t = Time::convertTime(timeString); - std::unique_ptr translation = + ghoul::mm_unique_ptr translation = Translation::createFromDictionary( keyframes.value(timeString) ); @@ -87,7 +87,7 @@ TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary) { glm::dvec3 TimelineTranslation::position(const UpdateData& data) const { const double now = data.time.j2000Seconds(); - using KeyframePointer = const Keyframe>*; + using KeyframePointer = const Keyframe>*; KeyframePointer prev = _timeline.lastKeyframeBefore(now, true); KeyframePointer next = _timeline.firstKeyframeAfter(now, true); diff --git a/modules/base/translation/timelinetranslation.h b/modules/base/translation/timelinetranslation.h index 86ef39af60..238922edd0 100644 --- a/modules/base/translation/timelinetranslation.h +++ b/modules/base/translation/timelinetranslation.h @@ -27,6 +27,7 @@ #include #include +#include namespace openspace { @@ -42,7 +43,7 @@ public: static documentation::Documentation Documentation(); private: - Timeline> _timeline; + Timeline> _timeline; }; } // namespace openspace diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 17896e43fd..82c2c3d023 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -132,6 +132,13 @@ namespace { "The text color for the astronomical object." }; + constexpr openspace::properties::Property::PropertyInfo TextOpacityInfo = { + "TextOpacity", + "Text Opacity", + "Determines the transparency of the text label, where 1 is completely opaque " + "and 0 fully transparent." + }; + constexpr openspace::properties::Property::PropertyInfo TextSizeInfo = { "TextSize", "Text Size", @@ -309,10 +316,16 @@ documentation::Documentation RenderableBillboardsCloud::Documentation() { }, { TextColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, TextColorInfo.description }, + { + TextOpacityInfo.identifier, + new DoubleVerifier, + Optional::Yes, + TextOpacityInfo.description + }, { TextSizeInfo.identifier, new DoubleVerifier, @@ -412,12 +425,8 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di , _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 600.f) , _pointColor(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _spriteTexturePath(SpriteTextureInfo) - , _textColor( - TextColorInfo, - glm::vec4(1.f, 1.f, 1.f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) - ) + , _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) + , _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f) , _textSize(TextSizeInfo, 8.f, 0.5f, 24.f) , _textMinSize(LabelMinSizeInfo, 8.f, 0.5f, 24.f) , _textMaxSize(LabelMaxSizeInfo, 20.f, 0.5f, 100.f) @@ -611,13 +620,17 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di _hasLabel = true; if (dictionary.hasKey(TextColorInfo.identifier)) { - _textColor = dictionary.value(TextColorInfo.identifier); + _textColor = dictionary.value(TextColorInfo.identifier); _hasLabel = true; } _textColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_textColor); _textColor.onChange([&]() { _textColorIsDirty = true; }); + if (dictionary.hasKey(TextOpacityInfo.identifier)) { + _textOpacity = dictionary.value(TextOpacityInfo.identifier); + } + addProperty(_textOpacity); if (dictionary.hasKey(TextSizeInfo.identifier)) { _textSize = dictionary.value(TextSizeInfo.identifier); @@ -883,9 +896,10 @@ void RenderableBillboardsCloud::renderLabels(const RenderData& data, break; } - glm::vec4 textColor = _textColor; - textColor.a *= fadeInVariable; - textColor.a *= _opacity; + glm::vec4 textColor = glm::vec4( + glm::vec3(_textColor), + _textOpacity * fadeInVariable + ); ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; labelInfo.orthoRight = orthoRight; diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.h b/modules/digitaluniverse/rendering/renderablebillboardscloud.h index 7953806824..1c95698927 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.h +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -115,7 +114,8 @@ private: properties::FloatProperty _scaleFactor; properties::Vec3Property _pointColor; properties::StringProperty _spriteTexturePath; - properties::Vec4Property _textColor; + properties::Vec3Property _textColor; + properties::FloatProperty _textOpacity; properties::FloatProperty _textSize; properties::FloatProperty _textMinSize; properties::FloatProperty _textMaxSize; diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index c9d286d840..02995e46d1 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -55,7 +55,6 @@ namespace { }; constexpr const char* KeyFile = "File"; - constexpr const char* keyColor = "Color"; constexpr const char* keyUnit = "Unit"; constexpr const char* MeterUnit = "m"; constexpr const char* KilometerUnit = "Km"; @@ -71,19 +70,19 @@ namespace { constexpr const int8_t CurrentCacheVersion = 1; constexpr const double PARSEC = 0.308567756E17; - constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { - "Transparency", - "Transparency", - "This value is a multiplicative factor that is applied to the transparency of " - "all point." - }; - constexpr openspace::properties::Property::PropertyInfo TextColorInfo = { "TextColor", "Text Color", "The text color for the astronomical object." }; + constexpr openspace::properties::Property::PropertyInfo TextOpacityInfo = { + "TextOpacity", + "Text Opacity", + "Determines the transparency of the text label, where 1 is completely opaque " + "and 0 fully transparent." + }; + constexpr openspace::properties::Property::PropertyInfo TextSizeInfo = { "TextSize", "Text Size", @@ -129,12 +128,6 @@ namespace { "Determines whether labels should be drawn or hidden." }; - constexpr openspace::properties::Property::PropertyInfo TransformationMatrixInfo = { - "TransformationMatrix", - "Transformation Matrix", - "Transformation matrix to be applied to each astronomical object." - }; - constexpr openspace::properties::Property::PropertyInfo MeshColorInfo = { "MeshColor", "Meshes colors", @@ -168,24 +161,6 @@ documentation::Documentation RenderableDUMeshes::Documentation() { "The path to the SPECK file that contains information about the " "astronomical object being rendered." }, - { - keyColor, - new Vector3Verifier, - Optional::Yes, - "Astronomical Object Color (r,g,b)." - }, - { - TransparencyInfo.identifier, - new DoubleVerifier, - Optional::Yes, - TransparencyInfo.description - }, - /*{ - ScaleFactorInfo.identifier, - new DoubleVerifier, - Optional::Yes, - ScaleFactorInfo.description - },*/ { DrawLabelInfo.identifier, new BoolVerifier, @@ -194,10 +169,16 @@ documentation::Documentation RenderableDUMeshes::Documentation() { }, { TextColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, TextColorInfo.description }, + { + TextOpacityInfo.identifier, + new DoubleVerifier, + Optional::Yes, + TextOpacityInfo.description + }, { TextSizeInfo.identifier, new DoubleVerifier, @@ -228,12 +209,6 @@ documentation::Documentation RenderableDUMeshes::Documentation() { Optional::Yes, LineWidthInfo.description }, - { - TransformationMatrixInfo.identifier, - new Matrix4x4Verifier, - Optional::Yes, - TransformationMatrixInfo.description - }, { MeshColorInfo.identifier, new Vector3ListVerifier, @@ -244,12 +219,10 @@ documentation::Documentation RenderableDUMeshes::Documentation() { }; } - RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) - //, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f) - , _textColor(TextColorInfo, glm::vec4(1.f), glm::vec4(0.f), glm::vec4(1.f)) + , _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) + , _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f) , _textSize(TextSizeInfo, 8.f, 0.5f, 24.f) , _drawElements(DrawElementsInfo, true) , _drawLabels(DrawLabelInfo, false) @@ -264,6 +237,9 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) "RenderableDUMeshes" ); + addProperty(_opacity); + registerUpdateRenderBinFromOpacity(); + if (dictionary.hasKey(KeyFile)) { _speckFile = absPath(dictionary.value(KeyFile)); _hasSpeckFile = true; @@ -310,25 +286,6 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) } } - /*if (dictionary.hasKey(keyColor)) { - _pointColor = dictionary.value(keyColor); - } - addProperty(_pointColor);*/ - - if (dictionary.hasKey(TransparencyInfo.identifier)) { - _alphaValue = static_cast( - dictionary.value(TransparencyInfo.identifier) - ); - } - addProperty(_alphaValue); - - /*if (dictionary.hasKey(ScaleFactorInfo.identifier)) { - _scaleFactor = static_cast( - dictionary.value(ScaleFactorInfo.identifier) - ); - } - addProperty(_scaleFactor);*/ - if (dictionary.hasKeyAndValue(LineWidthInfo.identifier)) { _lineWidth = static_cast( dictionary.value(LineWidthInfo.identifier) @@ -346,13 +303,17 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) _hasLabel = true; if (dictionary.hasKey(TextColorInfo.identifier)) { - _textColor = dictionary.value(TextColorInfo.identifier); + _textColor = dictionary.value(TextColorInfo.identifier); _hasLabel = true; } _textColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_textColor); _textColor.onChange([&]() { _textColorIsDirty = true; }); + if (dictionary.hasKey(TextOpacityInfo.identifier)) { + _textOpacity = dictionary.value(TextOpacityInfo.identifier); + } + addProperty(_textOpacity); if (dictionary.hasKey(TextSizeInfo.identifier)) { _textSize = dictionary.value(TextSizeInfo.identifier); @@ -370,12 +331,6 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) addProperty(_textMaxSize); } - if (dictionary.hasKey(TransformationMatrixInfo.identifier)) { - _transformationMatrix = dictionary.value( - TransformationMatrixInfo.identifier - ); - } - if (dictionary.hasKey(MeshColorInfo.identifier)) { ghoul::Dictionary colorDict = dictionary.value( MeshColorInfo.identifier @@ -386,8 +341,6 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) ); } } - - setRenderBin(Renderable::RenderBin::Opaque); } bool RenderableDUMeshes::isReady() const { @@ -459,8 +412,7 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, _program->setUniform(_uniformCache.modelViewTransform, modelViewMatrix); _program->setUniform(_uniformCache.projectionTransform, projectionMatrix); - _program->setUniform(_uniformCache.alphaValue, _alphaValue); - //_program->setUniform(_uniformCache.scaleFactor, _scaleFactor); + _program->setUniform(_uniformCache.alphaValue, _opacity); for (const std::pair& pair : _renderingMeshesMap) { _program->setUniform(_uniformCache.color, _meshColorMap[pair.second.colorIndex]); @@ -533,16 +485,17 @@ void RenderableDUMeshes::renderLabels(const RenderData& data, labelInfo.scale = pow(10.f, _textSize); labelInfo.enableDepth = true; labelInfo.enableFalseDepth = false; + + glm::vec4 textColor = glm::vec4(glm::vec3(_textColor), _textOpacity); for (const std::pair& pair : _labelData) { - //glm::vec3 scaledPos(_transformationMatrix * glm::dvec4(pair.first, 1.0)); glm::vec3 scaledPos(pair.first); scaledPos *= scale; ghoul::fontrendering::FontRenderer::defaultProjectionRenderer().render( *_font, scaledPos, pair.second, - _textColor, + textColor, labelInfo ); } @@ -870,10 +823,7 @@ bool RenderableDUMeshes::readLabelFile() { dummy.clear(); } - glm::vec3 transformedPos = glm::vec3( - _transformationMatrix * glm::dvec4(position, 1.0) - ); - _labelData.emplace_back(std::make_pair(transformedPos, label)); + _labelData.emplace_back(std::make_pair(position, label)); } while (!file.eof()); diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index bb0b6dce20..3a1fa603eb 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -118,14 +117,11 @@ private: bool _textColorIsDirty = true; bool _hasLabel = false; - properties::FloatProperty _alphaValue; - //properties::FloatProperty _scaleFactor; - //properties::Vec3Property _pointColor; - properties::Vec4Property _textColor; + properties::Vec3Property _textColor; + properties::FloatProperty _textOpacity; properties::FloatProperty _textSize; properties::BoolProperty _drawElements; properties::BoolProperty _drawLabels; - //properties::OptionProperty _blendMode; properties::FloatProperty _textMinSize; properties::FloatProperty _textMaxSize; properties::FloatProperty _lineWidth; @@ -147,8 +143,6 @@ private: std::vector> _labelData; int _nValuesPerAstronomicalObject = 0; - glm::dmat4 _transformationMatrix = glm::dmat4(1.0); - std::unordered_map _meshColorMap; std::unordered_map _renderingMeshesMap; }; diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index a4e0bfd356..a5525fc346 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -69,13 +69,6 @@ namespace { BlendModeAdditive }; - constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { - "Transparency", - "Transparency", - "This value is a multiplicative factor that is applied to the transparency of " - "all points." - }; - constexpr openspace::properties::Property::PropertyInfo ScaleFactorInfo = { "ScaleFactor", "Scale Factor", @@ -89,6 +82,13 @@ namespace { "The text color for the astronomical object." }; + constexpr openspace::properties::Property::PropertyInfo TextOpacityInfo = { + "TextOpacity", + "Text Opacity", + "Determines the transparency of the text label, where 1 is completely opaque " + "and 0 fully transparent." + }; + constexpr openspace::properties::Property::PropertyInfo TextSizeInfo = { "TextSize", "Text Size", @@ -201,12 +201,6 @@ documentation::Documentation RenderablePlanesCloud::Documentation() { "The path to the SPECK file that contains information about the " "astronomical object being rendered." }, - { - TransparencyInfo.identifier, - new DoubleVerifier, - Optional::No, - TransparencyInfo.description - }, { ScaleFactorInfo.identifier, new DoubleVerifier, @@ -215,10 +209,16 @@ documentation::Documentation RenderablePlanesCloud::Documentation() { }, { TextColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, TextColorInfo.description }, + { + TextOpacityInfo.identifier, + new DoubleVerifier, + Optional::Yes, + TextOpacityInfo.description + }, { TextSizeInfo.identifier, new DoubleVerifier, @@ -298,14 +298,9 @@ documentation::Documentation RenderablePlanesCloud::Documentation() { RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) , _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 10000.f) - , _textColor( - TextColorInfo, - glm::vec4(1.0f, 1.0, 1.0f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) - ) + , _textColor(TextColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) + , _textOpacity(TextOpacityInfo, 1.f, 0.f, 1.f) , _textSize(TextSizeInfo, 8.0, 0.5, 24.0) , _drawElements(DrawElementsInfo, true) , _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown) @@ -325,6 +320,8 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary "RenderablePlanesCloud" ); + addProperty(_opacity); + if (dictionary.hasKey(KeyFile)) { _speckFile = absPath(dictionary.value(KeyFile)); _hasSpeckFile = true; @@ -372,13 +369,6 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary _unit = Meter; } - if (dictionary.hasKey(TransparencyInfo.identifier)) { - _alphaValue = static_cast( - dictionary.value(TransparencyInfo.identifier) - ); - } - addProperty(_alphaValue); - if (dictionary.hasKey(ScaleFactorInfo.identifier)) { _scaleFactor = static_cast( dictionary.value(ScaleFactorInfo.identifier) @@ -394,13 +384,17 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary _hasLabel = true; if (dictionary.hasKey(TextColorInfo.identifier)) { - _textColor = dictionary.value(TextColorInfo.identifier); + _textColor = dictionary.value(TextColorInfo.identifier); _hasLabel = true; } _textColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_textColor); _textColor.onChange([&]() { _textColorIsDirty = true; }); + if (dictionary.hasKey(TextOpacityInfo.identifier)) { + _textOpacity = dictionary.value(TextOpacityInfo.identifier); + } + addProperty(_textOpacity); if (dictionary.hasKey(TextSizeInfo.identifier)) { _textSize = dictionary.value(TextSizeInfo.identifier); @@ -560,7 +554,7 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&, _uniformCache.modelViewProjectionTransform, modelViewProjectionMatrix ); - _program->setUniform(_uniformCache.alphaValue, _alphaValue); + _program->setUniform(_uniformCache.alphaValue, _opacity); _program->setUniform(_uniformCache.fadeInValue, fadeInVariable); GLint viewport[4]; @@ -625,8 +619,10 @@ void RenderablePlanesCloud::renderLabels(const RenderData& data, break; } - glm::vec4 textColor = _textColor; - textColor.a *= fadeInVariable * _opacity; + glm::vec4 textColor = glm::vec4( + glm::vec3(_textColor), + _textOpacity * fadeInVariable + ); ghoul::fontrendering::FontRenderer::ProjectedLabelsInformation labelInfo; labelInfo.orthoRight = orthoRight; diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.h b/modules/digitaluniverse/rendering/renderableplanescloud.h index bf7cced594..96d2813edb 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.h +++ b/modules/digitaluniverse/rendering/renderableplanescloud.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -116,9 +115,9 @@ private: int _planeStartingIndexPos = 0; int _textureVariableIndex = 0; - properties::FloatProperty _alphaValue; properties::FloatProperty _scaleFactor; - properties::Vec4Property _textColor; + properties::Vec3Property _textColor; + properties::FloatProperty _textOpacity; properties::FloatProperty _textSize; properties::BoolProperty _drawElements; properties::OptionProperty _blendMode; diff --git a/modules/digitaluniverse/rendering/renderablepoints.cpp b/modules/digitaluniverse/rendering/renderablepoints.cpp index 22054c2734..d48ddd9313 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.cpp +++ b/modules/digitaluniverse/rendering/renderablepoints.cpp @@ -72,13 +72,6 @@ namespace { "The path to the texture that should be used as the point sprite." }; - constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { - "Transparency", - "Transparency", - "This value is a multiplicative factor that is applied to the transparency of " - "all points." - }; - constexpr openspace::properties::Property::PropertyInfo ScaleFactorInfo = { "ScaleFactor", "Scale Factor", @@ -131,12 +124,6 @@ documentation::Documentation RenderablePoints::Documentation() { Optional::Yes, SpriteTextureInfo.description }, - { - TransparencyInfo.identifier, - new DoubleVerifier, - Optional::No, - TransparencyInfo.description - }, { ScaleFactorInfo.identifier, new DoubleVerifier, @@ -157,7 +144,6 @@ documentation::Documentation RenderablePoints::Documentation() { RenderablePoints::RenderablePoints(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) , _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f) , _pointColor( ColorInfo, @@ -173,6 +159,9 @@ RenderablePoints::RenderablePoints(const ghoul::Dictionary& dictionary) "RenderablePoints" ); + addProperty(_opacity); + registerUpdateRenderBinFromOpacity(); + _speckFile = absPath(dictionary.value(KeyFile)); if (dictionary.hasKey(keyUnit)) { @@ -233,13 +222,6 @@ RenderablePoints::RenderablePoints(const ghoul::Dictionary& dictionary) _hasColorMapFile = true; } - if (dictionary.hasKey(TransparencyInfo.identifier)) { - _alphaValue = static_cast( - dictionary.value(TransparencyInfo.identifier) - ); - } - addProperty(_alphaValue); - if (dictionary.hasKey(ScaleFactorInfo.identifier)) { _scaleFactor = static_cast( dictionary.value(ScaleFactorInfo.identifier) @@ -322,7 +304,7 @@ void RenderablePoints::render(const RenderData& data, RendererTasks&) { _program->setUniform(_uniformCache.color, _pointColor); _program->setUniform(_uniformCache.sides, 4); - _program->setUniform(_uniformCache.alphaValue, _alphaValue); + _program->setUniform(_uniformCache.alphaValue, _opacity); _program->setUniform(_uniformCache.scaleFactor, _scaleFactor); if (_hasSpriteTexture) { diff --git a/modules/digitaluniverse/rendering/renderablepoints.h b/modules/digitaluniverse/rendering/renderablepoints.h index 58731d3c56..1b27786097 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.h +++ b/modules/digitaluniverse/rendering/renderablepoints.h @@ -87,7 +87,6 @@ private: bool _spriteTextureIsDirty = true; bool _hasColorMapFile = false; - properties::FloatProperty _alphaValue; properties::FloatProperty _scaleFactor; properties::Vec3Property _pointColor; properties::StringProperty _spriteTexturePath; diff --git a/modules/globebrowsing/CMakeLists.txt b/modules/globebrowsing/CMakeLists.txt index 70834fe46a..a609917a01 100644 --- a/modules/globebrowsing/CMakeLists.txt +++ b/modules/globebrowsing/CMakeLists.txt @@ -75,7 +75,6 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/layer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/layeradjustment.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/layergroup.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/layergroupid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/layermanager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/layerrendersettings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/memoryawaretilecache.cpp diff --git a/modules/globebrowsing/shaders/rings_fs.glsl b/modules/globebrowsing/shaders/rings_fs.glsl index b18d5d71a8..04cf03d2cc 100644 --- a/modules/globebrowsing/shaders/rings_fs.glsl +++ b/modules/globebrowsing/shaders/rings_fs.glsl @@ -35,7 +35,7 @@ in vec4 shadowCoords; uniform sampler2DShadow shadowMapTexture; uniform sampler1D ringTexture; uniform vec2 textureOffset; -uniform float transparency; +uniform float colorFilterValue; uniform vec3 sunPosition; uniform float _nightFactor; @@ -67,12 +67,11 @@ Fragment getFragment() { } vec4 diffuse = texture(ringTexture, texCoord); - float colorValue = length(diffuse.rgb); - // times 3 as length of vec3(1.0, 1.0, 1.0) will return 3 and we want - // to normalize the transparency value to [0,1] - if (colorValue < 3.0 * transparency) { - diffuse.a = pow(colorValue / (3.0 * transparency), 1); - //diffuse.a = (colorValue / 3.0) * transparency; + // divided by 3 as length of vec3(1.0, 1.0, 1.0) will return 3 and we want + // to normalize the alpha value to [0,1] + float colorValue = length(diffuse.rgb) / 3.0; + if (colorValue < colorFilterValue) { + diffuse.a = colorValue * colorFilterValue; if (diffuse.a < 0.65) discard; } diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.cpp b/modules/globebrowsing/src/dashboarditemglobelocation.cpp index 6fee2ccdc5..183e08ea8d 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.cpp +++ b/modules/globebrowsing/src/dashboarditemglobelocation.cpp @@ -199,10 +199,9 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { ); } glm::vec2 DashboardItemGlobeLocation::size() const { - return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, + return _font->boundingBox( fmt::format("Position: {}, {} Altitude: {}", 1.f, 1.f, 1.f) - ).boundingBox; + ); } } // namespace openspace diff --git a/modules/globebrowsing/src/globelabelscomponent.cpp b/modules/globebrowsing/src/globelabelscomponent.cpp index 2e678a03c6..28c9b60409 100644 --- a/modules/globebrowsing/src/globelabelscomponent.cpp +++ b/modules/globebrowsing/src/globelabelscomponent.cpp @@ -51,7 +51,7 @@ namespace { constexpr const double LabelFadeRangeConst = 1500.0; constexpr const double RangeAngularCoefConst = 0.8; - constexpr const float MinTransparencyValueConst = 0.009f; + constexpr const float MinOpacityValueConst = 0.009f; enum LabelRenderingAlignmentType { Horizontally = 0, @@ -109,6 +109,12 @@ namespace { "Labels Color" }; + constexpr openspace::properties::Property::PropertyInfo LabelsOpacityInfo = { + "LabelsOpacity", + "Labels Opacity", + "Labels Opacity" + }; + constexpr openspace::properties::Property::PropertyInfo LabelsFadeInStartingDistanceInfo = { @@ -210,10 +216,16 @@ documentation::Documentation GlobeLabelsComponent::Documentation() { }, { LabelsColorInfo.identifier, - new Vector4Verifier(), + new DoubleVector3Verifier, Optional::Yes, LabelsColorInfo.description }, + { + LabelsOpacityInfo.identifier, + new DoubleVerifier, + Optional::Yes, + LabelsOpacityInfo.description + }, { LabelsFadeInStartingDistanceInfo.identifier, new DoubleVerifier, @@ -270,10 +282,11 @@ GlobeLabelsComponent::GlobeLabelsComponent() , _labelsMinHeight(LabelsMinHeightInfo, 100.0, 0.0, 10000.0) , _labelsColor( LabelsColorInfo, - glm::vec4(1.f, 1.f, 0.f, 1.f), - glm::vec4(0.f), - glm::vec4(1.f) + glm::vec3(1.f, 1.f, 0.f), + glm::vec3(0.f), + glm::vec3(1.f) ) + , _labelsOpacity(LabelsOpacityInfo, 1.f, 0.f, 1.f) , _labelsFadeInDist(LabelsFadeInStartingDistanceInfo, 1e6, 1e3, 1e8) , _labelsFadeOutDist(LabelsFadeOutStartingDistanceInfo, 1e4, 1, 1e7) , _labelsFadeInEnabled(LabelsFadeInEnabledInfo, false) @@ -291,6 +304,7 @@ GlobeLabelsComponent::GlobeLabelsComponent() addProperty(_labelsMinHeight); _labelsColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_labelsColor); + addProperty(_labelsOpacity); addProperty(_labelsFadeInDist); addProperty(_labelsFadeOutDist); addProperty(_labelsMinSize); @@ -355,7 +369,11 @@ void GlobeLabelsComponent::initialize(const ghoul::Dictionary& dictionary, } if (dictionary.hasKey(LabelsColorInfo.identifier)) { - _labelsColor = dictionary.value(LabelsColorInfo.identifier); + _labelsColor = dictionary.value(LabelsColorInfo.identifier); + } + + if (dictionary.hasKey(LabelsOpacityInfo.identifier)) { + _labelsOpacity = dictionary.value(LabelsOpacityInfo.identifier); } if (dictionary.hasKey(LabelsFadeInEnabledInfo.identifier)) { @@ -642,7 +660,7 @@ void GlobeLabelsComponent::draw(const RenderData& data) { double funcValue = a * distanceCameraGlobeWorld + b; varyingOpacity *= static_cast(std::min(funcValue, 1.0)); - if (varyingOpacity < MinTransparencyValueConst) { + if (varyingOpacity < MinOpacityValueConst) { return; } } @@ -657,7 +675,7 @@ void GlobeLabelsComponent::draw(const RenderData& data) { double funcValue = a * distanceCameraGlobeWorld + b; varyingOpacity *= static_cast(std::min(funcValue, 1.0)); - if (varyingOpacity < MinTransparencyValueConst) { + if (varyingOpacity < MinOpacityValueConst) { return; } } @@ -670,8 +688,10 @@ void GlobeLabelsComponent::renderLabels(const RenderData& data, float distToCamera, float fadeInVariable ) { - glm::vec4 textColor = _labelsColor; - textColor.a *= fadeInVariable; + glm::vec4 textColor = glm::vec4( + glm::vec3(_labelsColor), + _labelsOpacity * fadeInVariable + ); glm::dvec4 cameraUpVecWorld = glm::dvec4(data.camera.lookUpVectorWorldSpace(), 0.0); diff --git a/modules/globebrowsing/src/globelabelscomponent.h b/modules/globebrowsing/src/globelabelscomponent.h index 98371f39e6..1bded12791 100644 --- a/modules/globebrowsing/src/globelabelscomponent.h +++ b/modules/globebrowsing/src/globelabelscomponent.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -89,7 +89,8 @@ private: properties::IntProperty _labelsMinSize; properties::FloatProperty _labelsSize; properties::FloatProperty _labelsMinHeight; - properties::Vec4Property _labelsColor; + properties::Vec3Property _labelsColor; + properties::FloatProperty _labelsOpacity; properties::FloatProperty _labelsFadeInDist; properties::FloatProperty _labelsFadeOutDist; properties::BoolProperty _labelsFadeInEnabled; diff --git a/modules/globebrowsing/src/layergroupid.cpp b/modules/globebrowsing/src/layergroupid.cpp deleted file mode 100644 index bf1ff8f0fc..0000000000 --- a/modules/globebrowsing/src/layergroupid.cpp +++ /dev/null @@ -1,74 +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 - -using namespace openspace::globebrowsing::layergroupid; - -namespace ghoul { - -template <> -TypeID from_string(const std::string& string) { - for (int i = 0; i < NUM_LAYER_TYPES; ++i) { - if (string == LAYER_TYPE_NAMES[i]) { - return static_cast(i); - } - } - return TypeID::Unknown; -} - -template <> -openspace::globebrowsing::layergroupid::GroupID from_string(const std::string& string) { - for (int i = 0; i < NUM_LAYER_GROUPS; ++i) { - if (string == LAYER_GROUP_IDENTIFIERS[i]) { - return static_cast(i); - } - } - return GroupID::Unknown; -} - -template <> -openspace::globebrowsing::layergroupid::AdjustmentTypeID from_string( - const std::string& string) -{ - for (int i = 0; i < NUM_ADJUSTMENT_TYPES; ++i) { - if (string == ADJUSTMENT_TYPE_NAMES[i]) { - return static_cast(i); - } - } - return AdjustmentTypeID::None; -} - -template <> -openspace::globebrowsing::layergroupid::BlendModeID from_string(const std::string& string) -{ - for (int i = 0; i < NUM_BLEND_MODES; ++i) { - if (string == BLEND_MODE_NAMES[i]) { - return static_cast(i); - } - } - return BlendModeID::Normal; -} - -} // namespace ghoul diff --git a/modules/globebrowsing/src/layergroupid.h b/modules/globebrowsing/src/layergroupid.h index 16c0c92c11..e2c28e503b 100644 --- a/modules/globebrowsing/src/layergroupid.h +++ b/modules/globebrowsing/src/layergroupid.h @@ -30,7 +30,7 @@ namespace openspace::globebrowsing::layergroupid { -static constexpr int NUM_LAYER_GROUPS = 5; +static constexpr const int NUM_LAYER_GROUPS = 5; static constexpr const char* LAYER_GROUP_IDENTIFIERS[NUM_LAYER_GROUPS] = { "HeightLayers", "ColorLayers", @@ -56,7 +56,7 @@ enum GroupID { Unknown, }; -static constexpr int NUM_LAYER_TYPES = 8; +static constexpr const int NUM_LAYER_TYPES = 8; static constexpr const char* LAYER_TYPE_NAMES[NUM_LAYER_TYPES] = { "DefaultTileLayer", "SingleImageTileLayer", @@ -124,18 +124,52 @@ enum class BlendModeID { namespace ghoul { template <> -openspace::globebrowsing::layergroupid::TypeID from_string(const std::string& string); +constexpr openspace::globebrowsing::layergroupid::TypeID from_string( + std::string_view string) +{ + for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_LAYER_TYPES; ++i) { + if (string == openspace::globebrowsing::layergroupid::LAYER_TYPE_NAMES[i]) { + return static_cast(i); + } + } + return openspace::globebrowsing::layergroupid::TypeID::Unknown; +} template <> -openspace::globebrowsing::layergroupid::GroupID from_string(const std::string& string); +constexpr openspace::globebrowsing::layergroupid::GroupID from_string( + std::string_view string) +{ + for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_LAYER_GROUPS; ++i) { + if (string == openspace::globebrowsing::layergroupid::LAYER_GROUP_IDENTIFIERS[i]) { + return static_cast(i); + } + } + return openspace::globebrowsing::layergroupid::GroupID::Unknown; +} template <> -openspace::globebrowsing::layergroupid::AdjustmentTypeID from_string( - const std::string& string); +constexpr openspace::globebrowsing::layergroupid::AdjustmentTypeID from_string( + std::string_view string) +{ + for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_ADJUSTMENT_TYPES; ++i) { + if (string == openspace::globebrowsing::layergroupid::ADJUSTMENT_TYPE_NAMES[i]) { + return static_cast(i); + } + } + return openspace::globebrowsing::layergroupid::AdjustmentTypeID::None; +} template <> -openspace::globebrowsing::layergroupid::BlendModeID from_string( - const std::string& string); +constexpr openspace::globebrowsing::layergroupid::BlendModeID from_string( + std::string_view string) +{ + for (int i = 0; i < openspace::globebrowsing::layergroupid::NUM_BLEND_MODES; ++i) { + if (string == openspace::globebrowsing::layergroupid::BLEND_MODE_NAMES[i]) { + return static_cast(i); + } + } + return openspace::globebrowsing::layergroupid::BlendModeID::Normal; +} } // ghoul diff --git a/modules/globebrowsing/src/rawtiledatareader.cpp b/modules/globebrowsing/src/rawtiledatareader.cpp index a602008e1a..43791302ea 100644 --- a/modules/globebrowsing/src/rawtiledatareader.cpp +++ b/modules/globebrowsing/src/rawtiledatareader.cpp @@ -564,7 +564,7 @@ void RawTileDataReader::initialize() { const int numOverviews = _dataset->GetRasterBand(1)->GetOverviewCount(); _maxChunkLevel = static_cast(-tileLevelDifference); if (numOverviews > 0) { - _maxChunkLevel += numOverviews - 1; + _maxChunkLevel += numOverviews; } _maxChunkLevel = std::max(_maxChunkLevel, 2); } diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 6eed17af08..00b1d1adcf 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include #include #include @@ -609,6 +607,8 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) addPropertySubOwner(_debugPropertyOwner); addPropertySubOwner(_layerManager); + _traversalMemory.reserve(512); + //================================================================ //======== Reads Shadow (Eclipses) Entries in mod file =========== //================================================================ @@ -1171,19 +1171,18 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, std::array local; int localCount = 0; - auto traversal = [&global, &globalCount, &local, &localCount, + auto traversal = [&global, &globalCount, &local, &localCount, this, cutoff = _debugProperties.modelSpaceRenderingCutoffLevel](const Chunk& node) { ZoneScopedN("traversal") - std::vector Q; - Q.reserve(256); + _traversalMemory.clear(); // Loop through nodes in breadths first order - Q.push_back(&node); - while (!Q.empty()) { - const Chunk* n = Q.front(); - Q.erase(Q.begin()); + _traversalMemory.push_back(&node); + while (!_traversalMemory.empty()) { + const Chunk* n = _traversalMemory.front(); + _traversalMemory.erase(_traversalMemory.begin()); if (isLeaf(*n) && n->isVisible) { if (n->tileIndex.level < cutoff) { @@ -1199,7 +1198,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, // Add children to queue, if any if (!isLeaf(*n)) { for (int i = 0; i < 4; ++i) { - Q.push_back(n->children[i]); + _traversalMemory.push_back(n->children[i]); } } } diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index 59f2c51b38..5774bba960 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -258,6 +258,9 @@ private: ghoul::ReusableTypedMemoryPool _chunkPool; + std::vector _traversalMemory; + + Chunk _leftRoot; // Covers all negative longitudes Chunk _rightRoot; // Covers all positive longitudes diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index 4a45be2517..7bf3a70d73 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", "colorFilterValue", "_nightFactor", "sunPosition", "ringTexture", "shadowMatrix", "shadowMapTexture", "zFightingPercentage" }; @@ -91,11 +91,11 @@ namespace { "of the night side occurs." }; - constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { - "Transparency", - "Transparency", - "This value determines the transparency of part of the rings depending on the " - "color values. For this value v, the transparency is equal to length(color) / v." + constexpr openspace::properties::Property::PropertyInfo ColorFilterInfo = { + "ColorFilter", + "Color Filter", + "This value affects the filtering out of part of the rings depending on the " + "color values of the texture. The higher value, the more rings are filtered out." }; constexpr openspace::properties::Property::PropertyInfo ZFightingPercentageInfo = { @@ -146,10 +146,10 @@ documentation::Documentation RingsComponent::Documentation() { NightFactorInfo.description }, { - TransparencyInfo.identifier, + ColorFilterInfo.identifier, new DoubleVerifier, Optional::Yes, - TransparencyInfo.description + ColorFilterInfo.description }, { ZFightingPercentageInfo.identifier, @@ -173,7 +173,7 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) , _size(SizeInfo, 1.f, 0.f, 1e25f) , _offset(OffsetInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(1.f)) , _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f) - , _transparency(TransparencyInfo, 0.15f, 0.f, 1.f) + , _colorFilter(ColorFilterInfo, 0.15f, 0.f, 1.f) , _enabled({ "Enabled", "Enabled", "Enable/Disable Rings" }, true) , _zFightingPercentage(ZFightingPercentageInfo, 0.995f, 0.000001f, 1.f) , _nShadowSamples(NumberShadowSamplesInfo, 2, 1, 7) @@ -228,9 +228,9 @@ void RingsComponent::initialize() { } addProperty(_nightFactor); - if (_ringsDictionary.hasKeyAndValue(TransparencyInfo.identifier)) { - _transparency = static_cast( - _ringsDictionary.value(TransparencyInfo.identifier) + if (_ringsDictionary.hasKeyAndValue(ColorFilterInfo.identifier)) { + _colorFilter = static_cast( + _ringsDictionary.value(ColorFilterInfo.identifier) ); } @@ -248,7 +248,7 @@ void RingsComponent::initialize() { _nShadowSamples.onChange([this]() { compileShadowShader(); }); addProperty(_nShadowSamples); - addProperty(_transparency); + addProperty(_colorFilter); } bool RingsComponent::isReady() const { @@ -327,7 +327,7 @@ void RingsComponent::draw(const RenderData& data, modelViewProjectionTransform ); _shader->setUniform(_uniformCache.textureOffset, _offset); - _shader->setUniform(_uniformCache.transparency, _transparency); + _shader->setUniform(_uniformCache.colorFilterValue, _colorFilter); _shader->setUniform(_uniformCache.nightFactor, _nightFactor); _shader->setUniform(_uniformCache.sunPosition, _sunPosition); _shader->setUniform(_uniformCache.zFightingPercentage, _zFightingPercentage); diff --git a/modules/globebrowsing/src/ringscomponent.h b/modules/globebrowsing/src/ringscomponent.h index 62980e1bf6..d6c7351a90 100644 --- a/modules/globebrowsing/src/ringscomponent.h +++ b/modules/globebrowsing/src/ringscomponent.h @@ -81,14 +81,14 @@ private: properties::FloatProperty _size; properties::Vec2Property _offset; properties::FloatProperty _nightFactor; - properties::FloatProperty _transparency; + properties::FloatProperty _colorFilter; properties::BoolProperty _enabled; properties::FloatProperty _zFightingPercentage; properties::IntProperty _nShadowSamples; std::unique_ptr _shader; std::unique_ptr _geometryOnlyShader; - UniformCache(modelViewProjectionMatrix, textureOffset, transparency, nightFactor, + UniformCache(modelViewProjectionMatrix, textureOffset, colorFilterValue, nightFactor, sunPosition, ringTexture, shadowMatrix, shadowMapTexture, zFightingPercentage ) _uniformCache; UniformCache(modelViewProjectionMatrix, textureOffset, ringTexture diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index 0662c50566..aacf1f8e04 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -350,7 +350,6 @@ RenderData ShadowComponent::begin(const RenderData& data) { RenderData lightRenderData{ *_lightCamera, data.time, - data.doPerformanceMeasurement, data.renderBinMask, data.modelTransform }; diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index fc64a5ebc3..3c0a3240e1 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -48,8 +48,8 @@ namespace ghoul { template <> - openspace::globebrowsing::tileprovider::TemporalTileProvider::TimeFormatType - from_string(const std::string& string) + constexpr openspace::globebrowsing::tileprovider::TemporalTileProvider::TimeFormatType + from_string(std::string_view string) { using namespace openspace::globebrowsing::tileprovider; if (string == "YYYY-MM-DD") { @@ -68,7 +68,7 @@ namespace ghoul { return TemporalTileProvider::TimeFormatType::YYYYMMDD_hhmm; } else { - throw ghoul::RuntimeError("Unknown timeformat " + string); + throw ghoul::RuntimeError("Unknown timeformat '" + std::string(string) + "'"); } } } // namespace ghoul @@ -522,8 +522,8 @@ std::unique_ptr createFromDictionary(layergroupid::TypeID layerTyp const char* type = layergroupid::LAYER_TYPE_NAMES[static_cast(layerTypeID)]; auto factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(type, dictionary); - return result; + TileProvider* result = factory->create(type, dictionary); + return std::unique_ptr(result); } TileProvider::TileProvider() : properties::PropertyOwner({ "tileProvider" }) {} @@ -1296,8 +1296,6 @@ void reset(TileProvider& tp) { int maxLevel(TileProvider& tp) { - ZoneScoped - switch (tp.type) { case Type::DefaultTileProvider: { DefaultTileProvider& t = static_cast(tp); diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 67f7288d62..e6b660c988 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -33,6 +33,12 @@ #include #include +// @TODO (abock, 2020-08-07) All of the time handling in this class should be cleaned up +// a bit. There are lots of conversions between ISO strings for time and Time +// objects and back which eat up performance. For example, the TimeRange should +// operate on Time objects rather than date strings and the DateTime likewise (if +// this class needs to exist at all) + namespace openspace::globebrowsing { namespace { diff --git a/modules/imgui/CMakeLists.txt b/modules/imgui/CMakeLists.txt index 0e043a9479..2809fbbffc 100644 --- a/modules/imgui/CMakeLists.txt +++ b/modules/imgui/CMakeLists.txt @@ -34,8 +34,8 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/guiglobebrowsingcomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guihelpcomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guijoystickcomponent.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/guimemorycomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guimissioncomponent.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/guiperformancecomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guiparallelcomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guipropertycomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guishortcutscomponent.h @@ -54,8 +54,8 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/guiglobebrowsingcomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guihelpcomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guijoystickcomponent.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/guimemorycomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guimissioncomponent.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/guiperformancecomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guiparallelcomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guipropertycomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guishortcutscomponent.cpp diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index a4a873c267..7cc9fd6fab 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -184,9 +184,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { ZoneScopedN("ImGUI") // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() ||gui._sceneProperty.isEnabled()) { return gui.keyCallback(key, mod, action); } else { @@ -200,9 +198,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { ZoneScopedN("ImGUI") // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() || gui._sceneProperty.isEnabled()) { return gui.charCallback(codepoint, modifier); } else { @@ -229,9 +225,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() || gui._sceneProperty.isEnabled()) { return gui.mouseButtonCallback(button, action); } else { @@ -245,9 +239,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { ZoneScopedN("ImGUI") // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() || gui._sceneProperty.isEnabled()) { return gui.mouseWheelCallback(posY); } else { diff --git a/modules/imgui/include/gui.h b/modules/imgui/include/gui.h index e428631d89..b9f959d7b6 100644 --- a/modules/imgui/include/gui.h +++ b/modules/imgui/include/gui.h @@ -33,9 +33,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -106,12 +106,12 @@ public: GuiFilePathComponent _filePath; GuiAssetComponent _asset; GuiGlobeBrowsingComponent _globeBrowsing; - GuiPerformanceComponent _performance; GuiPropertyComponent _globalProperty; GuiPropertyComponent _sceneProperty; GuiPropertyComponent _screenSpaceProperty; GuiPropertyComponent _moduleProperty; + GuiMemoryComponent _memoryComponent; GuiPropertyComponent _virtualProperty; GuiSpaceTimeComponent _spaceTime; @@ -139,6 +139,7 @@ private: &_virtualProperty, &_globalProperty, &_moduleProperty, + &_memoryComponent, &_spaceTime, &_mission, @@ -153,8 +154,6 @@ private: &_joystick, &_filePath, - &_performance, - &_help }; diff --git a/modules/imgui/include/guiperformancecomponent.h b/modules/imgui/include/guiperformancecomponent.h deleted file mode 100644 index 36bbd7c146..0000000000 --- a/modules/imgui/include/guiperformancecomponent.h +++ /dev/null @@ -1,57 +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. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_MODULE_IMGUI___GUIPERFORMANCECOMPONENT___H__ -#define __OPENSPACE_MODULE_IMGUI___GUIPERFORMANCECOMPONENT___H__ - -#include - -#include -#include -#include - -namespace ghoul { class SharedMemory; } - -namespace openspace::gui { - -class GuiPerformanceComponent : public GuiComponent { -public: - GuiPerformanceComponent(); - ~GuiPerformanceComponent(); - - void render() override; - -protected: - std::unique_ptr _performanceMemory; - - properties::IntProperty _sortingSelection; - - properties::BoolProperty _sceneGraphIsEnabled; - properties::BoolProperty _functionsIsEnabled; - properties::BoolProperty _outputLogs; -}; - -} // namespace openspace::gui - -#endif // __OPENSPACE_MODULE_IMGUI___GUIPERFORMANCECOMPONENT___H__ diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index 04a6dd092b..d9b4ed4bc2 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -443,12 +442,6 @@ void GUI::endFrame() { ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); } - _performance.setEnabled(global::performanceManager.isEnabled()); - - if (_performance.isEnabled()) { - _performance.render(); - } - if (_isEnabled) { render(); @@ -461,8 +454,7 @@ void GUI::endFrame() { ImGui::Render(); - const bool shouldRender = _performance.isEnabled() || _isEnabled; - if (!shouldRender) { + if (!_isEnabled) { return; } diff --git a/modules/imgui/src/guiperformancecomponent.cpp b/modules/imgui/src/guiperformancecomponent.cpp deleted file mode 100644 index 7a7a495e3d..0000000000 --- a/modules/imgui/src/guiperformancecomponent.cpp +++ /dev/null @@ -1,457 +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 - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - enum Sorting { - NoSorting = -1, - UpdateTranslation = 0, - UpdateRotation = 1, - UpdateScaling = 2, - UpdateRender = 3, - Render = 4, - Total = 5 - }; - - constexpr openspace::properties::Property::PropertyInfo SortingSelectionInfo = { - "SortingSelection", - "Sorting", - "This value determines the sorting order of the performance measurements." - }; - - constexpr openspace::properties::Property::PropertyInfo SceneGraphEnabledInfo = { - "ShowSceneGraph", - "Show Scene Graph Measurements", - "If this value is enabled, the window showing the measurements for the scene " - "graph values is visible." - }; - - constexpr openspace::properties::Property::PropertyInfo FunctionsEnabledInfo = { - "ShowFunctions", - "Show Function Measurements", - "If this value is enabled, the window showing the measurements for the " - "individual functions is visible." - }; - - constexpr openspace::properties::Property::PropertyInfo OutputLogsInfo = { - "OutputLogs", - "Output Logs", - "" // @TODO Missing documentation - }; - -} // namespace - -namespace openspace::gui { - -GuiPerformanceComponent::GuiPerformanceComponent() - : GuiComponent("PerformanceComponent", "Performance Component") - , _sortingSelection(SortingSelectionInfo, -1, -1, 6) - , _sceneGraphIsEnabled(SceneGraphEnabledInfo, false) - , _functionsIsEnabled(FunctionsEnabledInfo, false) - , _outputLogs(OutputLogsInfo, false) -{ - addProperty(_sortingSelection); - - addProperty(_sceneGraphIsEnabled); - addProperty(_functionsIsEnabled); - addProperty(_outputLogs); -} - -GuiPerformanceComponent::~GuiPerformanceComponent() {} // NOLINT - -void GuiPerformanceComponent::render() { - if (!global::performanceManager.isEnabled()) { - return; - } - - using ghoul::SharedMemory; - using namespace performance; - - ImGui::SetNextWindowCollapsed(_isCollapsed); - bool v = _isEnabled; - ImGui::Begin("Performance", &v); - _isEnabled = v; - _isCollapsed = ImGui::IsWindowCollapsed(); - - PerformanceLayout* layout = global::performanceManager.performanceData(); - - v = _sceneGraphIsEnabled; - ImGui::Checkbox("SceneGraph", &v); - _sceneGraphIsEnabled = v; - v = _functionsIsEnabled; - ImGui::Checkbox("Functions", &v); - _functionsIsEnabled = v; - v = _outputLogs; - ImGui::Checkbox("Output Logs", &v); - global::performanceManager.setLogging(v); - // Need to catch if it's unsuccessful - v = global::performanceManager.loggingEnabled(); - _outputLogs = v; - - ImGui::Spacing(); - - if (ImGui::Button("Reset measurements")) { - global::performanceManager.resetPerformanceMeasurements(); - } - - if (_sceneGraphIsEnabled) { - bool sge = _sceneGraphIsEnabled; - ImGui::Begin("SceneGraph", &sge); - _sceneGraphIsEnabled = sge; - - // The indices correspond to the index into the average array further below - ImGui::Text("Sorting"); - int sorting = _sortingSelection; - ImGui::RadioButton("No Sorting", &sorting, Sorting::NoSorting); - ImGui::RadioButton("UpdateTranslation", &sorting, Sorting::UpdateTranslation); - ImGui::RadioButton("UpdateRotation", &sorting, Sorting::UpdateRotation); - ImGui::RadioButton("UpdateScaling", &sorting, Sorting::UpdateScaling); - ImGui::RadioButton("UpdateRender", &sorting, Sorting::UpdateRender); - ImGui::RadioButton("RenderTime", &sorting, Sorting::Render); - ImGui::RadioButton("TotalTime", &sorting, Sorting::Total); - _sortingSelection = sorting; - - // Later, we will sort this indices list instead of the real values for - // performance reasons - std::vector indices(layout->nScaleGraphEntries); - std::iota(indices.begin(), indices.end(), 0); - - // Ordering: - // updateTranslation - // updateRotation - // updateScaling - // UpdateRender - // RenderTime - std::vector> averages( - layout->nScaleGraphEntries, - { 0.f, 0.f, 0.f, 0.f, 0.f } - ); - - std::vector, 5>> minMax( - layout->nScaleGraphEntries - ); - - for (int i = 0; i < layout->nScaleGraphEntries; ++i) { - const PerformanceLayout::SceneGraphPerformanceLayout& entry = - layout->sceneGraphEntries[i]; - - int nValues[5] = { 0, 0, 0, 0, 0 }; - - // Compute the averages and count the number of values so we don't divide - // by 0 later - for (int j = 0; j < PerformanceLayout::NumberValues; ++j) { - averages[i][0] += entry.updateTranslation[j]; - if (entry.updateTranslation[j] != 0.f) { - ++(nValues[0]); - } - averages[i][1] += entry.updateRotation[j]; - if (entry.updateRotation[j] != 0.f) { - ++(nValues[1]); - } - averages[i][2] += entry.updateScaling[j]; - if (entry.updateScaling[j] != 0.f) { - ++(nValues[2]); - } - averages[i][3] += entry.updateRenderable[j]; - if (entry.updateRenderable[j] != 0.f) { - ++(nValues[3]); - } - averages[i][4] += entry.renderTime[j]; - if (entry.renderTime[j] != 0.f) { - ++(nValues[4]); - } - } - - if (nValues[0] != 0) { - averages[i][0] /= static_cast(nValues[0]); - } - if (nValues[1] != 0) { - averages[i][1] /= static_cast(nValues[1]); - } - if (nValues[2] != 0) { - averages[i][2] /= static_cast(nValues[2]); - } - if (nValues[3] != 0) { - averages[i][3] /= static_cast(nValues[3]); - } - if (nValues[4] != 0) { - averages[i][4] /= static_cast(nValues[4]); - } - - // Get the minimum/maximum values for each of the components so that we - // can scale the plot by these numbers - auto minmaxTranslation = std::minmax_element( - std::begin(entry.updateTranslation), - std::end(entry.updateTranslation) - ); - minMax[i][0] = std::make_pair( - *(minmaxTranslation.first), - *(minmaxTranslation.second) - ); - - auto minmaxRotation = std::minmax_element( - std::begin(entry.updateRotation), - std::end(entry.updateRotation) - ); - minMax[i][1] = std::make_pair( - *(minmaxRotation.first), - *(minmaxRotation.second) - ); - - auto minmaxScaling = std::minmax_element( - std::begin(entry.updateScaling), - std::end(entry.updateScaling) - ); - minMax[i][2] = std::make_pair( - *(minmaxScaling.first), - *(minmaxScaling.second) - ); - - auto minmaxUpdateRenderable = std::minmax_element( - std::begin(entry.updateRenderable), - std::end(entry.updateRenderable) - ); - minMax[i][3] = std::make_pair( - *(minmaxUpdateRenderable.first), - *(minmaxUpdateRenderable.second) - ); - - auto minmaxRendering = std::minmax_element( - std::begin(entry.renderTime), - std::end(entry.renderTime) - ); - minMax[i][4] = std::make_pair( - *(minmaxRendering.first), - *(minmaxRendering.second) - ); - } - - // If we don't want to sort, we will leave the indices list alone, thus - // leaving them in the regular ordering - Sorting selection = Sorting(sorting); - if (selection != Sorting::NoSorting) { - std::function sortFunc; - - if (selection == Sorting::Total) { - // If we do want to sort totally, we need to sum all the averages and - // use that as the criterion - sortFunc = [&averages](size_t a, size_t b) { - const float sumA = std::accumulate( - std::begin(averages[a]), - std::end(averages[a]), - 0.f - ); - - const float sumB = std::accumulate( - std::begin(averages[b]), - std::end(averages[b]), - 0.f - ); - - return sumA > sumB; - }; - } - else { - // otherwise we use the sorting index - sortFunc = [sel = _sortingSelection, &averages](size_t a, size_t b) { - return averages[a][sel] > averages[b][sel]; - }; - } - - std::sort(indices.begin(), indices.end(), sortFunc); - } - else { - // NoSorting -> So we sort by names instead - std::sort( - indices.begin(), - indices.end(), - [layout](size_t a, size_t b) { - return std::string(layout->sceneGraphEntries[a].name) < - std::string(layout->sceneGraphEntries[b].name); - } - ); - } - - for (int i = 0; i < layout->nScaleGraphEntries; ++i) { - // We are using the indices list as an additional level of indirection - // into the respective values so that the list will be sorted by whatever - // criterion we selected previously - - const PerformanceLayout::SceneGraphPerformanceLayout& entry = - layout->sceneGraphEntries[indices[i]]; - - if (ImGui::CollapsingHeader(entry.name)) { - const std::string& updateTranslationTime = std::to_string( - entry.updateTranslation[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateTranslation\nAverage: {}us", - averages[indices[i]][0] - ).c_str(), - &entry.updateTranslation[0], - PerformanceLayout::NumberValues, - 0, - updateTranslationTime.c_str(), - minMax[indices[i]][0].first, - minMax[indices[i]][0].second, - ImVec2(0, 40) - ); - - const std::string& updateRotationTime = std::to_string( - entry.updateRotation[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateRotation\nAverage: {}us", - averages[indices[i]][1] - ).c_str(), - &entry.updateRotation[0], - PerformanceLayout::NumberValues, - 0, - updateRotationTime.c_str(), - minMax[indices[i]][1].first, - minMax[indices[i]][1].second, - ImVec2(0, 40) - ); - - const std::string& updateScalingTime = std::to_string( - entry.updateScaling[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateScaling\nAverage: {}us", - averages[indices[i]][2] - ).c_str(), - &entry.updateScaling[0], - PerformanceLayout::NumberValues, - 0, - updateScalingTime.c_str(), - minMax[indices[i]][2].first, - minMax[indices[i]][2].second, - ImVec2(0, 40) - ); - - const std::string& updateRenderableTime = std::to_string( - entry.updateRenderable[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateRender\nAverage: {}us", - averages[indices[i]][3] - ).c_str(), - &entry.updateRenderable[0], - PerformanceLayout::NumberValues, - 0, - updateRenderableTime.c_str(), - minMax[indices[i]][3].first, - minMax[indices[i]][3].second, - ImVec2(0, 40) - ); - - const std::string& renderTime = std::to_string( - entry.renderTime[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "RenderTime\nAverage: {}us", - averages[indices[i]][4] - ).c_str(), - &entry.renderTime[0], - PerformanceLayout::NumberValues, - 0, - renderTime.c_str(), - minMax[indices[i]][4].first, - minMax[indices[i]][4].second, - ImVec2(0, 40) - ); - } - } - ImGui::End(); - } - - if (_functionsIsEnabled) { - bool fe = _functionsIsEnabled; - ImGui::Begin("Functions", &fe); - _functionsIsEnabled = fe; - - for (int i = 0; i < layout->nFunctionEntries; ++i) { - using namespace performance; - - const PerformanceLayout::FunctionPerformanceLayout& entry = - layout->functionEntries[i]; - - float avg = 0.f; - int count = 0; - for (int j = 0; j < PerformanceLayout::NumberValues; ++j) { - avg += layout->functionEntries[i].time[j]; - if (layout->functionEntries[i].time[j] != 0.f) { - ++count; - } - } - if (count > 0) { - avg /= count; - } - - auto minmax = std::minmax_element( - std::begin(layout->functionEntries[i].time), - std::end(layout->functionEntries[i].time) - ); - - const std::string& renderTime = std::to_string( - entry.time[PerformanceLayout::NumberValues - 1] - ) + "us"; - ImGui::PlotLines( - fmt::format("{}\nAverage: {}us", entry.name, avg).c_str(), - &entry.time[0], - PerformanceLayout::NumberValues, - 0, - renderTime.c_str(), - *(minmax.first), - *(minmax.second), - ImVec2(0, 40) - ); - } - ImGui::End(); - } - - ImGui::End(); -} - -} // namespace openspace::gui diff --git a/modules/multiresvolume/rendering/localtfbrickselector.cpp b/modules/multiresvolume/rendering/localtfbrickselector.cpp index 37d2cd70e4..b663438232 100644 --- a/modules/multiresvolume/rendering/localtfbrickselector.cpp +++ b/modules/multiresvolume/rendering/localtfbrickselector.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace { bool compareSplitPoints(const openspace::BrickSelection& a, diff --git a/modules/multiresvolume/rendering/simpletfbrickselector.cpp b/modules/multiresvolume/rendering/simpletfbrickselector.cpp index 78d99e7796..90acc37e7b 100644 --- a/modules/multiresvolume/rendering/simpletfbrickselector.cpp +++ b/modules/multiresvolume/rendering/simpletfbrickselector.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace { constexpr const char* _loggerCat = "SimpleTfBrickSelector"; diff --git a/modules/multiresvolume/rendering/tfbrickselector.cpp b/modules/multiresvolume/rendering/tfbrickselector.cpp index 75036f1a09..8e5a46020c 100644 --- a/modules/multiresvolume/rendering/tfbrickselector.cpp +++ b/modules/multiresvolume/rendering/tfbrickselector.cpp @@ -29,6 +29,7 @@ #include #include #include +#include namespace { bool compareSplitPoints(const openspace::BrickSelection& a, diff --git a/modules/server/src/connection.cpp b/modules/server/src/connection.cpp index acb284217d..e845ad1d9d 100644 --- a/modules/server/src/connection.cpp +++ b/modules/server/src/connection.cpp @@ -83,8 +83,14 @@ Connection::Connection(std::unique_ptr s, _topicFactory.registerClass( AuthenticationTopicKey, - [password](bool, const ghoul::Dictionary&) { - return new AuthorizationTopic(password); + [password](bool, const ghoul::Dictionary&, ghoul::MemoryPoolBase* pool) { + if (pool) { + void* ptr = pool->allocate(sizeof(AuthorizationTopic)); + return new (ptr) AuthorizationTopic(password); + } + else { + return new AuthorizationTopic(password); + } } ); @@ -178,7 +184,7 @@ void Connection::handleJson(const nlohmann::json& json) { return; } - std::unique_ptr topic = _topicFactory.create(type); + std::unique_ptr topic = std::unique_ptr(_topicFactory.create(type)); topic->initialize(this, topicId); topic->handleJson(*payloadJson); if (!topic->isDone()) { diff --git a/modules/server/src/topics/flightcontrollertopic.cpp b/modules/server/src/topics/flightcontrollertopic.cpp index 6d8dc96573..3e2289c5a5 100644 --- a/modules/server/src/topics/flightcontrollertopic.cpp +++ b/modules/server/src/topics/flightcontrollertopic.cpp @@ -75,6 +75,11 @@ namespace { // Change focus JSON keys constexpr const char* FocusKey = "focus"; + constexpr const char* AnchorKey = "anchor"; + constexpr const char* AimKey = "aim"; + constexpr const char* ResetVelocitiesKey = "resetVelocities"; + constexpr const char* RetargetAnchorKey = "retargetAnchor"; + constexpr const char* RetargetAimKey = "retargetAim"; constexpr const char* SceneNodeName = "identifier"; constexpr const char* SceneNodeEnabled = "enabled"; @@ -282,31 +287,68 @@ void FlightControllerTopic::setInterestingTimes() { } void FlightControllerTopic::updateView(const nlohmann::json& json) const { - if (json.find(FocusKey) != json.end()) { - changeFocus(json); - } + if (json.find(RenderableKey) != json.end()) { setRenderableEnabled(json); } + else { + changeFocus(json); + } } void FlightControllerTopic::changeFocus(const nlohmann::json& json) const { - if (json[FocusKey].find(SceneNodeName) == json[FocusKey].end()) { + if (json.find(FocusKey) == json.end()) { const std::string j = json; LWARNING( fmt::format("Could not find {} key in JSON. JSON was:\n{}", FocusKey, j) ); - return; + if (json.find(AimKey) == json.end()) { + const std::string j = json; + LWARNING( + fmt::format("Could not find {} key in JSON. JSON was:\n{}", AimKey, j) + ); + if (json.find(AnchorKey) == json.end()) { + const std::string j = json; + LWARNING(fmt::format( + "Could not find {} key in JSON. JSON was:\n{}", AnchorKey, j + )); + return; + } + } } - const std::string focus = json[FocusKey][SceneNodeName]; - const SceneGraphNode* node = global::renderEngine.scene()->sceneGraphNode(focus); - if (node) { - global::navigationHandler.orbitalNavigator().setFocusNode(node->identifier()); - global::navigationHandler.orbitalNavigator().startRetargetAnchor(); + const std::string focus = json.find(FocusKey) != json.end() ? json[FocusKey] : ""; + const std::string aim = json.find(AimKey) != json.end() ? json[AimKey] : ""; + const std::string anchor = json.find(AnchorKey) != json.end() ? json[AnchorKey] : ""; + + const bool resetVelocities = json[ResetVelocitiesKey]; + const bool retargetAnchor = json[RetargetAnchorKey]; + const bool retargetAim = json[RetargetAimKey]; + + Scene* scene = global::renderEngine.scene(); + const SceneGraphNode* focusNode = scene->sceneGraphNode(focus); + const SceneGraphNode* aimNode = scene->sceneGraphNode(aim); + const SceneGraphNode* anchorNode = scene->sceneGraphNode(anchor); + if (focusNode) { + global::navigationHandler.orbitalNavigator().setFocusNode( + focusNode, + resetVelocities + ); } else { - LWARNING(fmt::format("Could not find node named {}", focus)); + if (aimNode) { + global::navigationHandler.orbitalNavigator().setAimNode(aim); + } + if (anchorNode) { + global::navigationHandler.orbitalNavigator().setAnchorNode(anchor); + } + } + + if (retargetAnchor) { + global::navigationHandler.orbitalNavigator().startRetargetAnchor(); + } + if (retargetAim) { + global::navigationHandler.orbitalNavigator().startRetargetAim(); } } diff --git a/modules/space/rendering/planetgeometry.cpp b/modules/space/rendering/planetgeometry.cpp index 5a5a782015..12410506bd 100644 --- a/modules/space/rendering/planetgeometry.cpp +++ b/modules/space/rendering/planetgeometry.cpp @@ -63,8 +63,8 @@ std::unique_ptr PlanetGeometry::createFromDictionary( std::string geometryType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(geometryType, dictionary); - return result; + PlanetGeometry* result = factory->create(geometryType, dictionary); + return std::unique_ptr(result); } PlanetGeometry::PlanetGeometry() : properties::PropertyOwner({ "PlanetGeometry" }) {} diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 2ec587e4cb..5e902942d2 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -546,8 +546,7 @@ void RenderableOrbitalKepler::updateBuffers() { glm::dvec3 position = _keplerTranslator.position({ {}, Time(timeOffset + orbit.epoch), - Time(0.0), - false + Time(0.0) }); _vertexBufferData[vertexBufIdx].x = static_cast(position.x); diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 1a30124232..1291ccbe4d 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -39,7 +39,7 @@ namespace { constexpr const std::array UniformNames = { - "modelViewProjectionTransform", "textureOffset", "transparency", "_nightFactor", + "modelViewProjectionTransform", "textureOffset", "colorFilterValue", "_nightFactor", "sunPosition", "texture1" }; @@ -73,11 +73,11 @@ namespace { "of the night side occurs." }; - constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { - "Transparency", - "Transparency", - "This value determines the transparency of part of the rings depending on the " - "color values. For this value v, the transparency is equal to length(color) / v." + constexpr openspace::properties::Property::PropertyInfo ColorFilterInfo = { + "ColorFilter", + "Color Filter", + "This value affects the filtering out of part of the rings depending on the " + "color values of the texture. The higher value, the more rings are filtered out." }; } // namespace @@ -119,10 +119,10 @@ documentation::Documentation RenderableRings::Documentation() { NightFactorInfo.description }, { - TransparencyInfo.identifier, + ColorFilterInfo.identifier, new DoubleVerifier, Optional::Yes, - TransparencyInfo.description + ColorFilterInfo.description } } }; @@ -134,7 +134,7 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary) , _size(SizeInfo, 1.f, 0.f, 1e25f) , _offset(OffsetInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(1.f)) , _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f) - , _transparency(TransparencyInfo, 0.15f, 0.f, 1.f) + , _colorFilter(ColorFilterInfo, 0.15f, 0.f, 1.f) { using ghoul::filesystem::File; @@ -169,12 +169,12 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary) } addProperty(_nightFactor); - if (dictionary.hasKeyAndValue(TransparencyInfo.identifier)) { - _transparency = static_cast( - dictionary.value(TransparencyInfo.identifier) + if (dictionary.hasKeyAndValue(ColorFilterInfo.identifier)) { + _colorFilter = static_cast( + dictionary.value(ColorFilterInfo.identifier) ); } - addProperty(_transparency); + addProperty(_colorFilter); } bool RenderableRings::isReady() const { @@ -226,7 +226,7 @@ void RenderableRings::render(const RenderData& data, RendererTasks&) { data.camera.projectionMatrix() * glm::mat4(modelViewTransform) ); _shader->setUniform(_uniformCache.textureOffset, _offset); - _shader->setUniform(_uniformCache.transparency, _transparency); + _shader->setUniform(_uniformCache.colorFilterValue, _colorFilter); _shader->setUniform(_uniformCache.nightFactor, _nightFactor); _shader->setUniform(_uniformCache.sunPosition, _sunPosition); diff --git a/modules/space/rendering/renderablerings.h b/modules/space/rendering/renderablerings.h index d850670051..35152b1629 100644 --- a/modules/space/rendering/renderablerings.h +++ b/modules/space/rendering/renderablerings.h @@ -66,10 +66,10 @@ private: properties::FloatProperty _size; properties::Vec2Property _offset; properties::FloatProperty _nightFactor; - properties::FloatProperty _transparency; + properties::FloatProperty _colorFilter; std::unique_ptr _shader; - UniformCache(modelViewProjection, textureOffset, transparency, nightFactor, + UniformCache(modelViewProjection, textureOffset, colorFilterValue, nightFactor, sunPosition, texture) _uniformCache; std::unique_ptr _texture; std::unique_ptr _textureFile; diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 8f4cc221bb..4fa2a213bd 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -166,13 +166,6 @@ namespace { "The path to the texture that should be used as the base shape for the stars." };*/ - constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { - "Transparency", - "Transparency", - "This value is a multiplicative factor that is applied to the transparency of " - "all stars." - }; - // PSF constexpr openspace::properties::Property::PropertyInfo MagnitudeExponentInfo = { "MagnitudeExponent", @@ -432,10 +425,9 @@ 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)) + , _fixedColor(FixedColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _filterOutOfRange(FilterOutOfRangeInfo, false) , _pointSpreadFunctionTexturePath(PsfTextureInfo) - , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) , _psfMethodOption( PSFMethodOptionInfo, properties::OptionProperty::DisplayType::Dropdown @@ -479,6 +471,9 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) "RenderableStars" ); + addProperty(_opacity); + registerUpdateRenderBinFromOpacity(); + _speckFile = absPath(dictionary.value(KeyFile)); _speckFile.onChange([&]() { _speckFileIsDirty = true; }); addProperty(_speckFile); @@ -606,13 +601,6 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) }); _userProvidedTextureOwner.addProperty(_pointSpreadFunctionTexturePath); - if (dictionary.hasKey(TransparencyInfo.identifier)) { - _alphaValue = static_cast( - dictionary.value(TransparencyInfo.identifier) - ); - } - _parametersOwner.addProperty(_alphaValue); - _psfMethodOption.addOption(PsfMethodSpencer, "Spencer's Function"); _psfMethodOption.addOption(PsfMethodMoffat, "Moffat's Function"); _psfMethodOption = PsfMethodSpencer; @@ -1005,10 +993,10 @@ void RenderableStars::render(const RenderData& data, RendererTasks&) { const double funcValue = a * distCamera + b; fadeInVariable *= static_cast(funcValue > 1.f ? 1.f : funcValue); - _program->setUniform(_uniformCache.alphaValue, _alphaValue * fadeInVariable); + _program->setUniform(_uniformCache.alphaValue, _opacity * fadeInVariable); } else { - _program->setUniform(_uniformCache.alphaValue, _alphaValue); + _program->setUniform(_uniformCache.alphaValue, _opacity); } ghoul::opengl::TextureUnit psfUnit; diff --git a/modules/space/rendering/renderablestars.h b/modules/space/rendering/renderablestars.h index 7e36d0aafb..946f9b917b 100644 --- a/modules/space/rendering/renderablestars.h +++ b/modules/space/rendering/renderablestars.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -98,13 +98,12 @@ private: properties::StringProperty _otherDataColorMapPath; properties::Vec2Property _otherDataRange; std::unique_ptr _otherDataColorMapTexture; - properties::Vec4Property _fixedColor; + properties::Vec3Property _fixedColor; properties::BoolProperty _filterOutOfRange; properties::StringProperty _pointSpreadFunctionTexturePath; std::unique_ptr _pointSpreadFunctionTexture; std::unique_ptr _pointSpreadFunctionFile; - properties::FloatProperty _alphaValue; properties::OptionProperty _psfMethodOption; properties::OptionProperty _psfMultiplyOption; properties::FloatProperty _lumCent; diff --git a/modules/space/rotation/spicerotation.h b/modules/space/rotation/spicerotation.h index b1c0cb3ec5..c10c31e38c 100644 --- a/modules/space/rotation/spicerotation.h +++ b/modules/space/rotation/spicerotation.h @@ -46,7 +46,7 @@ public: private: properties::StringProperty _sourceFrame; properties::StringProperty _destinationFrame; - std::unique_ptr _timeFrame; + ghoul::mm_unique_ptr _timeFrame; }; } // namespace openspace diff --git a/modules/space/shaders/rings_fs.glsl b/modules/space/shaders/rings_fs.glsl index b9d4e484c8..ffa20731da 100644 --- a/modules/space/shaders/rings_fs.glsl +++ b/modules/space/shaders/rings_fs.glsl @@ -32,7 +32,7 @@ in vec4 vs_position; uniform sampler1D texture1; uniform vec2 textureOffset; -uniform float transparency; +uniform float colorFilterValue; uniform bool hasSunPosition; uniform vec3 sunPosition; @@ -60,11 +60,13 @@ Fragment getFragment() { } vec4 diffuse = texture(texture1, texCoord); - float colorValue = length(diffuse.rgb); - // times 3 as length of vec3(1.0, 1.0, 1.0) will return 3 and we want - // to normalize the transparency value to [0,1] - if (colorValue < 3.0 * transparency) { - diffuse.a = pow(colorValue / (3.0 * transparency), 1); + // divided by 3 as length of vec3(1.0, 1.0, 1.0) will return 3 and we want + // to normalize the alpha value to [0,1] + float colorValue = length(diffuse.rgb) / 3.0; + if (colorValue < colorFilterValue) { + diffuse.a = colorValue * colorFilterValue; + if (diffuse.a < 0.65) + discard; } // The normal for the one plane depends on whether we are dealing diff --git a/modules/space/shaders/star_fs.glsl b/modules/space/shaders/star_fs.glsl index 329e7e513c..46c6ebb4a0 100644 --- a/modules/space/shaders/star_fs.glsl +++ b/modules/space/shaders/star_fs.glsl @@ -36,7 +36,7 @@ uniform sampler1D colorTexture; uniform sampler2D psfTexture; uniform float alphaValue; -uniform vec4 fixedColor; +uniform vec3 fixedColor; uniform int colorOption; @@ -93,17 +93,13 @@ Fragment getFragment() { } break; case COLOROPTION_FIXEDCOLOR: - color = fixedColor; + color = vec4(fixedColor, 1.0); break; } 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; diff --git a/modules/space/translation/spicetranslation.cpp b/modules/space/translation/spicetranslation.cpp index 1e1dcd6de2..8eadaca8d1 100644 --- a/modules/space/translation/spicetranslation.cpp +++ b/modules/space/translation/spicetranslation.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace { constexpr const char* KeyKernels = "Kernels"; @@ -114,6 +115,7 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) : _target(TargetInfo) , _observer(ObserverInfo) , _frame(FrameInfo, DefaultReferenceFrame) + , _cachedFrame(DefaultReferenceFrame) { documentation::testSpecificationAndThrow( Documentation(), @@ -121,13 +123,6 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) "SpiceTranslation" ); - _target = dictionary.value(TargetInfo.identifier); - _observer = dictionary.value(ObserverInfo.identifier); - - if (dictionary.hasKey(FrameInfo.identifier)) { - _frame = dictionary.value(FrameInfo.identifier); - } - auto loadKernel = [](const std::string& kernel) { if (!FileSys.fileExists(kernel)) { throw SpiceManager::SpiceException("Kernel '" + kernel + "' does not exist"); @@ -156,31 +151,45 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) } } - auto update = [this](){ + _target.onChange([this]() { + _cachedTarget = _target; requireUpdate(); notifyObservers(); - }; - - _target.onChange(update); + }); addProperty(_target); - _observer.onChange(update); + _observer.onChange([this]() { + _cachedObserver = _observer; + requireUpdate(); + notifyObservers(); + }); addProperty(_observer); - _frame.onChange(update); + _frame.onChange([this]() { + _cachedFrame = _frame; + requireUpdate(); + notifyObservers(); + }); addProperty(_frame); + + _target = dictionary.value(TargetInfo.identifier); + _observer = dictionary.value(ObserverInfo.identifier); + + if (dictionary.hasKey(FrameInfo.identifier)) { + _frame = dictionary.value(FrameInfo.identifier); + } } glm::dvec3 SpiceTranslation::position(const UpdateData& data) const { double lightTime = 0.0; return SpiceManager::ref().targetPosition( - _target, - _observer, - _frame, + _cachedTarget, + _cachedObserver, + _cachedFrame, {}, data.time.j2000Seconds(), lightTime - ) * glm::pow(10.0, 3.0); + ) * 1000.0; } } // namespace openspace diff --git a/modules/space/translation/spicetranslation.h b/modules/space/translation/spicetranslation.h index e2136952e0..3c09a87340 100644 --- a/modules/space/translation/spicetranslation.h +++ b/modules/space/translation/spicetranslation.h @@ -44,6 +44,14 @@ private: properties::StringProperty _observer; properties::StringProperty _frame; + // We are accessing these values every frame and when retrieving a string from the + // StringProperty, it allocates some new memory, which we want to prevent. Until the + // property can return a const ref of the string, we keep a local copy as the target, + // observer, and frame are not likely to change very often + std::string _cachedTarget; + std::string _cachedObserver; + std::string _cachedFrame; + glm::dvec3 _position = glm::dvec3(0.0); }; diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index 3b8f594346..84eda4956f 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -337,23 +337,21 @@ glm::vec2 DashboardItemInstruments::size() const { size = addToBoundingbox( size, - renderer.boundingBox(*_font, "Next instrument activity:").boundingBox + _font->boundingBox("Next instrument activity:") ); size = addToBoundingbox( size, - renderer.boundingBox( - *_font, + _font->boundingBox( fmt::format("{:.0f} s {:s} {:.1f} %", remaining, progress, t * 100.f) - ).boundingBox + ) ); size = addToBoundingbox( size, - renderer.boundingBox( - *_font, + _font->boundingBox( fmt::format("Data acquisition time: {}", str) - ).boundingBox + ) ); } std::pair nextTarget = sequencer.nextTarget(currentTime); @@ -363,9 +361,6 @@ glm::vec2 DashboardItemInstruments::size() const { return size; } - using FR = ghoul::fontrendering::FontRenderer; - FR& renderer = FR::defaultRenderer(); - const int timeleft = static_cast(nextTarget.first - currentTime); const int hour = timeleft / 3600; @@ -393,20 +388,16 @@ glm::vec2 DashboardItemInstruments::size() const { size = addToBoundingbox( size, - renderer.boundingBox( - *_font, + _font->boundingBox( fmt::format("Data acquisition adjacency: [{}:{}:{}]", hh, mm, ss) - ).boundingBox + ) ); size.y += _font->height(); size = addToBoundingbox( size, - ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_font, - "Active Instruments:" - ).boundingBox + _font->boundingBox("Active Instruments:") ); return size; } diff --git a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp index d3dd6614b3..2ba4d88f6c 100644 --- a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp +++ b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp @@ -49,8 +49,9 @@ namespace { }; } // namespace -// @TODO: This clas is not properly working anymore and needs to be substantially -// rewritten +// @TODO: This class is not properly working anymore and needs to be substantially +// rewritten. When doing so, make sure that any color property uses three +// values, not four. The opacity should be handled separately namespace openspace { diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index 12e2d4de1d..9da17a57b1 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -256,13 +256,48 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) , _drawSolid(DrawSolidInfo, false) , _standOffDistance(StandoffDistanceInfo, 0.9999, 0.99, 1.0, 0.000001) , _colors({ - { DefaultStartColorInfo, glm::vec4(0.4f) }, - { DefaultEndColorInfo, glm::vec4(0.85f, 0.85f, 0.85f, 1.f) }, - { ActiveColorInfo, glm::vec4(0.f, 1.f, 0.f, 1.f) }, - { TargetInFovInfo, glm::vec4(0.f, 0.5f, 0.7f, 1.f) }, - { IntersectionStartInfo, glm::vec4(1.f, 0.89f, 0.f, 1.f) }, - { IntersectionEndInfo, glm::vec4(1.f, 0.29f, 0.f, 1.f) }, - { SquareColorInfo, glm::vec4(0.85f, 0.85f, 0.85f, 1.f) } + { + DefaultStartColorInfo, + glm::vec3(0.4f), + glm::vec3(0.f), + glm::vec3(1.f) + }, + { + DefaultEndColorInfo, + glm::vec3(0.85f), + glm::vec3(0.f), + glm::vec3(1.f) + }, + { + ActiveColorInfo, + glm::vec3(0.f, 1.f, 0.f), + glm::vec3(0.f), + glm::vec3(1.f) + }, + { + TargetInFovInfo, + glm::vec3(0.f, 0.5f, 0.7f), + glm::vec3(0.f), + glm::vec3(1.f) + }, + { + IntersectionStartInfo, + glm::vec3(1.f, 0.89f, 0.f), + glm::vec3(0.f), + glm::vec3(1.f) + }, + { + IntersectionEndInfo, + glm::vec3(1.f, 0.29f, 0.f), + glm::vec3(0.f), + glm::vec3(1.f) + }, + { + SquareColorInfo, + glm::vec3(0.85f), + glm::vec3(0.f), + glm::vec3(1.f) + } }) { documentation::testSpecificationAndThrow( diff --git a/modules/spacecraftinstruments/rendering/renderablefov.h b/modules/spacecraftinstruments/rendering/renderablefov.h index dca23e19d3..082e6cb1fd 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.h +++ b/modules/spacecraftinstruments/rendering/renderablefov.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -69,15 +69,15 @@ private: void updateGPU(); void insertPoint(std::vector& arr, glm::vec4 p, glm::vec4 c); - glm::vec4 squareColor(float t) const { + glm::vec3 squareColor(float t) const { return _colors.active.value() * t + _colors.square.value() * (1 - t); } - glm::vec4 endColor(float t) const { + glm::vec3 endColor(float t) const { return _colors.active.value() * t + _colors.intersectionEnd.value() * (1 - t); } - glm::vec4 fovColor(float t) const { + glm::vec3 fovColor(float t) const { return _colors.active.value() * t + _colors.targetInFieldOfView.value() * (1 - t); } @@ -150,13 +150,13 @@ private: RenderInformation _fieldOfViewBounds; struct { - properties::Vec4Property defaultStart; // Start color for uninteresting times - properties::Vec4Property defaultEnd; // End color for uninteresting times - properties::Vec4Property active; // Color use when a field-of-view is projecting - properties::Vec4Property targetInFieldOfView; // Color to use for target in fov - properties::Vec4Property intersectionStart; // Color at the start of intersection - properties::Vec4Property intersectionEnd; // Color at the end of intersection - properties::Vec4Property square; // Color for the orthogonal square + properties::Vec3Property defaultStart; // Start color for uninteresting times + properties::Vec3Property defaultEnd; // End color for uninteresting times + properties::Vec3Property active; // Color use when a field-of-view is projecting + properties::Vec3Property targetInFieldOfView; // Color to use for target in fov + properties::Vec3Property intersectionStart; // Color at the start of intersection + properties::Vec3Property intersectionEnd; // Color at the end of intersection + properties::Vec3Property square; // Color for the orthogonal square } _colors; }; diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 3bef08edd9..df97458c92 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -38,8 +38,8 @@ namespace { constexpr const char* ProgramName = "ShadowCylinderProgram"; constexpr const char* MainFrame = "GALACTIC"; - constexpr const std::array UniformNames = { - "modelViewProjectionTransform", "shadowColor" + constexpr const std::array UniformNames = { + "modelViewProjectionTransform", "shadowColor", "opacity" }; constexpr openspace::properties::Property::PropertyInfo NumberPointsInfo = { @@ -135,7 +135,7 @@ documentation::Documentation RenderableShadowCylinder::Documentation() { }, { ShadowColorInfo.identifier, - new DoubleVector4Verifier, + new DoubleVector3Verifier, Optional::Yes, ShadowColorInfo.description }, @@ -189,11 +189,7 @@ RenderableShadowCylinder::RenderableShadowCylinder(const ghoul::Dictionary& dict : Renderable(dictionary) , _numberOfPoints(NumberPointsInfo, 190, 1, 300) , _shadowLength(ShadowLengthInfo, 0.1f, 0.f, 0.5f) - , _shadowColor( - ShadowColorInfo, - glm::vec4(1.f, 1.f, 1.f, 0.25f), - glm::vec4(0.f), glm::vec4(1.f) - ) + , _shadowColor(ShadowColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _terminatorType( TerminatorTypeInfo, properties::OptionProperty::DisplayType::Dropdown @@ -210,6 +206,9 @@ RenderableShadowCylinder::RenderableShadowCylinder(const ghoul::Dictionary& dict "RenderableShadowCylinder" ); + addProperty(_opacity); + registerUpdateRenderBinFromOpacity(); + if (dictionary.hasKey(NumberPointsInfo.identifier)) { _numberOfPoints = static_cast( dictionary.value(NumberPointsInfo.identifier) @@ -227,7 +226,7 @@ RenderableShadowCylinder::RenderableShadowCylinder(const ghoul::Dictionary& dict if (dictionary.hasKey(ShadowColorInfo.identifier)) { - _shadowColor = dictionary.value(ShadowLengthInfo.identifier); + _shadowColor = dictionary.value(ShadowLengthInfo.identifier); } _shadowColor.setViewOption(properties::Property::ViewOptions::Color); addProperty(_shadowColor); @@ -306,6 +305,8 @@ bool RenderableShadowCylinder::isReady() const { void RenderableShadowCylinder::render(const RenderData& data, RendererTasks&) { glDepthMask(false); + glDisable(GL_CULL_FACE); + _shader->activate(); // Model transform and view transform needs to be in double precision @@ -321,6 +322,7 @@ void RenderableShadowCylinder::render(const RenderData& data, RendererTasks&) { ); _shader->setUniform(_uniformCache.shadowColor, _shadowColor); + _shader->setUniform(_uniformCache.opacity, _opacity); glBindVertexArray(_vao); glDrawArrays(GL_TRIANGLE_STRIP, 0, static_cast(_vertices.size())); @@ -328,6 +330,7 @@ void RenderableShadowCylinder::render(const RenderData& data, RendererTasks&) { _shader->deactivate(); + glDisable(GL_CULL_FACE); glDepthMask(true); } diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h index 85be7ab556..236f519470 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -70,7 +70,7 @@ private: properties::IntProperty _numberOfPoints; properties::FloatProperty _shadowLength; - properties::Vec4Property _shadowColor; + properties::Vec3Property _shadowColor; properties::OptionProperty _terminatorType; properties::StringProperty _lightSource; properties::StringProperty _observer; @@ -79,7 +79,7 @@ private: properties::OptionProperty _aberration; ghoul::opengl::ProgramObject* _shader = nullptr; - UniformCache(modelViewProjectionTransform, shadowColor) _uniformCache; + UniformCache(modelViewProjectionTransform, shadowColor, opacity) _uniformCache; glm::dmat3 _stateMatrix = glm::dmat3(1.0); diff --git a/modules/spacecraftinstruments/shaders/fov_vs.glsl b/modules/spacecraftinstruments/shaders/fov_vs.glsl index 489f38ec48..2bf1ff5fde 100644 --- a/modules/spacecraftinstruments/shaders/fov_vs.glsl +++ b/modules/spacecraftinstruments/shaders/fov_vs.glsl @@ -34,13 +34,13 @@ out vec4 vs_positionScreenSpace; uniform mat4 modelViewProjectionTransform; -uniform vec4 defaultColorStart; -uniform vec4 defaultColorEnd; -uniform vec4 activeColor; -uniform vec4 targetInFieldOfViewColor; -uniform vec4 intersectionStartColor; -uniform vec4 intersectionEndColor; -uniform vec4 squareColor; +uniform vec3 defaultColorStart; +uniform vec3 defaultColorEnd; +uniform vec3 activeColor; +uniform vec3 targetInFieldOfViewColor; +uniform vec3 intersectionStartColor; +uniform vec3 intersectionEndColor; +uniform vec3 squareColor; uniform float interpolation; // This needs to be synced with the RenderableFov header @@ -60,29 +60,31 @@ void main() { vs_positionScreenSpace = z_normalization(positionClipSpace); gl_Position = vs_positionScreenSpace; + vec3 color; switch (colorInformation) { case VertexColorTypeDefaultStart: - vs_color = defaultColorStart; + color = defaultColorStart; break; case VertexColorTypeDefaultEnd: - vs_color = defaultColorEnd; + color = defaultColorEnd; break; case VertexColorTypeInFieldOfView: - vs_color = activeColor * interpolation + targetInFieldOfViewColor * (1 - interpolation); + color = activeColor * interpolation + targetInFieldOfViewColor * (1 - interpolation); break; case VertexColorTypeActive: - vs_color = activeColor; + color = activeColor; break; case VertexColorTypeIntersectionStart: - vs_color = intersectionStartColor; + color = intersectionStartColor; break; case VertexColorTypeIntersectionEnd: - vs_color = activeColor * interpolation + intersectionEndColor * (1 - interpolation); + color = activeColor * interpolation + intersectionEndColor * (1 - interpolation); break; case VertexColorTypeSquare: - vs_color = activeColor * interpolation + squareColor * (1 - interpolation); + color = activeColor * interpolation + squareColor * (1 - interpolation); break; default: - vs_color = vec4(1.0, 0.0, 1.0, 1.0); + color = vec3(1.0, 0.0, 1.0); } + vs_color = vec4(color, 1.0); } diff --git a/modules/spacecraftinstruments/shaders/terminatorshadow_fs.glsl b/modules/spacecraftinstruments/shaders/terminatorshadow_fs.glsl index 1fafbc02a2..bf7c29b1fb 100644 --- a/modules/spacecraftinstruments/shaders/terminatorshadow_fs.glsl +++ b/modules/spacecraftinstruments/shaders/terminatorshadow_fs.glsl @@ -26,15 +26,13 @@ #include "fragment.glsl" in vec4 vs_positionScreenSpace; -in vec4 vs_point_velocity; -in vec4 vs_color; - -uniform vec3 color; +in vec3 vs_color; +uniform float opacity; Fragment getFragment() { Fragment frag; - frag.color = vs_color; + frag.color = vec4(vs_color, opacity); frag.depth = vs_positionScreenSpace.w; return frag; diff --git a/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl b/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl index c837cac53b..55fd791490 100644 --- a/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl +++ b/modules/spacecraftinstruments/shaders/terminatorshadow_vs.glsl @@ -28,22 +28,19 @@ layout(location = 0) in vec4 in_point_position; -out vec4 vs_color; +out vec3 vs_color; out vec4 vs_positionScreenSpace; uniform mat4 modelViewProjectionTransform; -uniform vec4 objectVelocity; - -uniform uint nVertices; -uniform vec4 shadowColor; +uniform vec3 shadowColor; void main() { if (mod(gl_VertexID,2) == 0.0) { vs_color = shadowColor; } else { - vs_color = vec4(0.0); + vs_color = vec3(0.0); } // Transform the damn psc to homogenous coordinate diff --git a/modules/spacecraftinstruments/util/decoder.cpp b/modules/spacecraftinstruments/util/decoder.cpp index 1006d856d4..64a6344a04 100644 --- a/modules/spacecraftinstruments/util/decoder.cpp +++ b/modules/spacecraftinstruments/util/decoder.cpp @@ -36,8 +36,8 @@ std::unique_ptr Decoder::createFromDictionary( const std::string& type) { ghoul::TemplateFactory* factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(type, dictionary); - return result; + Decoder* result = factory->create(type, dictionary); + return std::unique_ptr(result); } } // namespace openspace diff --git a/modules/sync/syncmodule.cpp b/modules/sync/syncmodule.cpp index 0bba0d59a0..1d36c420c2 100644 --- a/modules/sync/syncmodule.cpp +++ b/modules/sync/syncmodule.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace { @@ -78,22 +79,41 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) { fSynchronization->registerClass( "HttpSynchronization", - [this](bool, const ghoul::Dictionary& dictionary) { - return new HttpSynchronization( - dictionary, - _synchronizationRoot, - _synchronizationRepositories - ); + [this](bool, const ghoul::Dictionary& dictionary, ghoul::MemoryPoolBase* pool) { + if (pool) { + void* ptr = pool->allocate(sizeof(HttpSynchronization)); + return new (ptr) HttpSynchronization( + dictionary, + _synchronizationRoot, + _synchronizationRepositories + ); + } + else { + return new HttpSynchronization( + dictionary, + _synchronizationRoot, + _synchronizationRepositories + ); + } } ); fSynchronization->registerClass( "UrlSynchronization", - [this](bool, const ghoul::Dictionary& dictionary) { - return new UrlSynchronization( - dictionary, - _synchronizationRoot - ); + [this](bool, const ghoul::Dictionary& dictionary, ghoul::MemoryPoolBase* pool) { + if (pool) { + void* ptr = pool->allocate(sizeof(UrlSynchronization)); + return new (ptr) UrlSynchronization( + dictionary, + _synchronizationRoot + ); + } + else { + return new UrlSynchronization( + dictionary, + _synchronizationRoot + ); + } } ); diff --git a/modules/touch/include/touchmarker.h b/modules/touch/include/touchmarker.h index 43d2d7be94..26ed9e18bf 100644 --- a/modules/touch/include/touchmarker.h +++ b/modules/touch/include/touchmarker.h @@ -58,12 +58,12 @@ private: properties::BoolProperty _visible; properties::FloatProperty _radiusSize; - properties::FloatProperty _transparency; + properties::FloatProperty _opacity; properties::FloatProperty _thickness; properties::Vec3Property _color; std::unique_ptr _shader; - UniformCache(radius, transparency, thickness, color) _uniformCache; + UniformCache(radius, opacity, thickness, color) _uniformCache; std::vector _vertexData; GLuint _quad = 0; diff --git a/modules/touch/shaders/marker_fs.glsl b/modules/touch/shaders/marker_fs.glsl index 9d04a92a38..2425e5323a 100644 --- a/modules/touch/shaders/marker_fs.glsl +++ b/modules/touch/shaders/marker_fs.glsl @@ -28,7 +28,7 @@ in vec2 out_position; uniform float radius; -uniform float transparency; +uniform float opacity; uniform float thickness; uniform vec3 color; @@ -47,7 +47,7 @@ Fragment getFragment() { // calculate lighting vec3 light_dir = vec3(0.0, 0.0, 1.0); float diffuse = max(0.0, dot(light_dir, n)); - float alpha = min(pow(sqrt(mag), thickness), transparency); + float alpha = min(pow(sqrt(mag), thickness), opacity); Fragment frag; frag.color = vec4(color * diffuse, alpha); diff --git a/modules/touch/src/touchmarker.cpp b/modules/touch/src/touchmarker.cpp index 386007074c..8abd11e7e8 100644 --- a/modules/touch/src/touchmarker.cpp +++ b/modules/touch/src/touchmarker.cpp @@ -32,7 +32,7 @@ namespace { constexpr const std::array UniformNames = { - "radius", "transparency", "thickness", "color" + "radius", "opacity", "thickness", "color" }; constexpr openspace::properties::Property::PropertyInfo VisibilityInfo = { @@ -47,9 +47,9 @@ namespace { "" // @TODO Missing documentation }; - constexpr openspace::properties::Property::PropertyInfo TransparencyInfo = { - "Transparency", - "Marker transparency", + constexpr openspace::properties::Property::PropertyInfo OpacityInfo = { + "Opacity", + "Marker opacity", "" // @TODO Missing documentation }; @@ -71,13 +71,13 @@ TouchMarker::TouchMarker() : properties::PropertyOwner({ "TouchMarker" }) , _visible(VisibilityInfo, true) , _radiusSize(RadiusInfo, 30.f, 0.f, 100.f) - , _transparency(TransparencyInfo, 0.8f, 0.f, 1.f) + , _opacity(OpacityInfo, 0.8f, 0.f, 1.f) , _thickness(ThicknessInfo, 2.f, 0.f, 4.f ) , _color(ColorInfo, glm::vec3(0.96f, 0.2f, 0.2f), glm::vec3(0.f), glm::vec3(1.f)) { addProperty(_visible); addProperty(_radiusSize); - addProperty(_transparency); + addProperty(_opacity); addProperty(_thickness); _color.setViewOption(properties::Property::ViewOptions::Color); addProperty(_color); @@ -117,7 +117,7 @@ void TouchMarker::render(const std::vector& list) { _shader->activate(); _shader->setUniform(_uniformCache.radius, _radiusSize); - _shader->setUniform(_uniformCache.transparency, _transparency); + _shader->setUniform(_uniformCache.opacity, _opacity); _shader->setUniform(_uniformCache.thickness, _thickness); _shader->setUniform(_uniformCache.color, _color.value()); diff --git a/modules/toyvolume/rendering/renderabletoyvolume.cpp b/modules/toyvolume/rendering/renderabletoyvolume.cpp index 46dc7ffca8..7a3d3b9479 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.cpp +++ b/modules/toyvolume/rendering/renderabletoyvolume.cpp @@ -92,7 +92,7 @@ RenderableToyVolume::RenderableToyVolume(const ghoul::Dictionary& dictionary) glm::vec3(0.f), glm::vec3(glm::two_pi()) ) - , _color(ColorInfo, glm::vec4(1.f, 0.f, 0.f, 0.1f), glm::vec4(0.f), glm::vec4(1.f)) + , _color(ColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f)) , _downScaleVolumeRendering(DownscaleVolumeRenderingInfo, 1.f, 0.1f, 1.f) { if (dictionary.hasKeyAndValue(ScalingExponentInfo.identifier)) { @@ -113,8 +113,8 @@ RenderableToyVolume::RenderableToyVolume(const ghoul::Dictionary& dictionary) _rotation = dictionary.value(RotationInfo.identifier); } - if (dictionary.hasKeyAndValue(ColorInfo.identifier)) { - _color = dictionary.value(ColorInfo.identifier); + if (dictionary.hasKeyAndValue(ColorInfo.identifier)) { + _color = dictionary.value(ColorInfo.identifier); } if (dictionary.hasKeyAndValue(StepSizeInfo.identifier)) { @@ -141,7 +141,8 @@ RenderableToyVolume::RenderableToyVolume(const ghoul::Dictionary& dictionary) RenderableToyVolume::~RenderableToyVolume() {} void RenderableToyVolume::initializeGL() { - _raycaster = std::make_unique(_color); + glm::vec4 color(glm::vec3(_color), _opacity); + _raycaster = std::make_unique(color); _raycaster->initialize(); global::raycasterManager.attachRaycaster(*_raycaster.get()); @@ -163,6 +164,7 @@ void RenderableToyVolume::initializeGL() { addProperty(_translation); addProperty(_rotation); addProperty(_color); + addProperty(_opacity); addProperty(_downScaleVolumeRendering); } @@ -196,7 +198,9 @@ void RenderableToyVolume::update(const UpdateData& data) { std::pow(10.f, static_cast(_scalingExponent)) ); - _raycaster->setColor(_color); + glm::vec4 color(glm::vec3(_color), _opacity); + + _raycaster->setColor(color); _raycaster->setStepSize(_stepSize); _raycaster->setModelTransform(transform); _raycaster->setTime(data.time.j2000Seconds()); diff --git a/modules/toyvolume/rendering/renderabletoyvolume.h b/modules/toyvolume/rendering/renderabletoyvolume.h index 4f4692534b..d42988639d 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.h +++ b/modules/toyvolume/rendering/renderabletoyvolume.h @@ -30,7 +30,6 @@ #include #include #include -#include namespace openspace { @@ -54,7 +53,7 @@ private: properties::FloatProperty _stepSize; properties::Vec3Property _translation; properties::Vec3Property _rotation; - properties::Vec4Property _color; + properties::Vec3Property _color; properties::FloatProperty _downScaleVolumeRendering; std::unique_ptr _raycaster; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ea989bb7b..8453570bf8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,9 +70,6 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/network/parallelpeer.cpp ${OPENSPACE_BASE_DIR}/src/network/parallelpeer_lua.inl ${OPENSPACE_BASE_DIR}/src/network/parallelserver.cpp - ${OPENSPACE_BASE_DIR}/src/performance/performancemeasurement.cpp - ${OPENSPACE_BASE_DIR}/src/performance/performancelayout.cpp - ${OPENSPACE_BASE_DIR}/src/performance/performancemanager.cpp ${OPENSPACE_BASE_DIR}/src/properties/optionproperty.cpp ${OPENSPACE_BASE_DIR}/src/properties/property.cpp ${OPENSPACE_BASE_DIR}/src/properties/propertyowner.cpp @@ -253,9 +250,6 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/network/parallelpeer.h ${OPENSPACE_BASE_DIR}/include/openspace/network/parallelserver.h ${OPENSPACE_BASE_DIR}/include/openspace/network/messagestructures.h - ${OPENSPACE_BASE_DIR}/include/openspace/performance/performancemeasurement.h - ${OPENSPACE_BASE_DIR}/include/openspace/performance/performancelayout.h - ${OPENSPACE_BASE_DIR}/include/openspace/performance/performancemanager.h ${OPENSPACE_BASE_DIR}/include/openspace/properties/numericalproperty.h ${OPENSPACE_BASE_DIR}/include/openspace/properties/numericalproperty.inl ${OPENSPACE_BASE_DIR}/include/openspace/properties/optionproperty.h @@ -370,6 +364,7 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/util/httprequest.h ${OPENSPACE_BASE_DIR}/include/openspace/util/job.h ${OPENSPACE_BASE_DIR}/include/openspace/util/keys.h + ${OPENSPACE_BASE_DIR}/include/openspace/util/memorymanager.h ${OPENSPACE_BASE_DIR}/include/openspace/util/mouse.h ${OPENSPACE_BASE_DIR}/include/openspace/util/openspacemodule.h ${OPENSPACE_BASE_DIR}/include/openspace/util/progressbar.h diff --git a/src/engine/globals.cpp b/src/engine/globals.cpp index 34effc2cc5..8a28ea5070 100644 --- a/src/engine/globals.cpp +++ b/src/engine/globals.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -51,8 +50,9 @@ #include #include #include -#include +#include #include +#include #include #include #include @@ -88,6 +88,11 @@ LuaConsole& gLuaConsole() { return g; } +MemoryManager& gMemoryManager() { + static MemoryManager g; + return g; +} + MissionManager& gMissionManager() { static MissionManager g; return g; @@ -188,11 +193,6 @@ interaction::ShortcutManager& gShortcutManager() { return g; } -performance::PerformanceManager& gPerformanceManager() { - static performance::PerformanceManager g; - return g; -} - properties::PropertyOwner& gRootPropertyOwner() { static properties::PropertyOwner g({ "" }); return g; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index ecb0e65150..b3beab370e 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -41,8 +41,6 @@ #include #include #include -#include -#include #include #include #include @@ -87,10 +85,6 @@ #include #include -#if defined(_MSC_VER) && defined(OPENSPACE_ENABLE_VLD) -#include -#endif - #ifdef __APPLE__ #include #endif // __APPLE__ @@ -1057,18 +1051,8 @@ void OpenSpaceEngine::writeSceneDocumentation() { void OpenSpaceEngine::preSynchronization() { ZoneScoped - LTRACE("OpenSpaceEngine::preSynchronization(begin)"); - //std::this_thread::sleep_for(std::chrono::milliseconds(10)); - - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::preSynchronization" - ); - } - FileSys.triggerFilesystemEvents(); if (_hasScheduledAssetLoading) { @@ -1132,16 +1116,8 @@ void OpenSpaceEngine::preSynchronization() { void OpenSpaceEngine::postSynchronizationPreDraw() { ZoneScoped - LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::postSynchronizationPreDraw" - ); - } - bool master = global::windowDelegate.isMaster(); global::syncEngine.postSynchronization(SyncEngine::IsMaster(master)); @@ -1209,16 +1185,8 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view const glm::mat4& projectionMatrix) { ZoneScoped - LTRACE("OpenSpaceEngine::render(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::render" - ); - } - const bool isGuiWindow = global::windowDelegate.hasGuiWindow() ? global::windowDelegate.isGuiWindow() : @@ -1241,16 +1209,8 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view void OpenSpaceEngine::drawOverlays() { ZoneScoped - LTRACE("OpenSpaceEngine::drawOverlays(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::drawOverlays" - ); - } - const bool isGuiWindow = global::windowDelegate.hasGuiWindow() ? global::windowDelegate.isGuiWindow() : @@ -1260,7 +1220,6 @@ void OpenSpaceEngine::drawOverlays() { global::renderEngine.renderOverlays(_shutdown); global::luaConsole.render(); global::sessionRecording.render(); - } for (const std::function& func : global::callback::draw2D) { @@ -1274,16 +1233,8 @@ void OpenSpaceEngine::drawOverlays() { void OpenSpaceEngine::postDraw() { ZoneScoped - LTRACE("OpenSpaceEngine::postDraw(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::postDraw" - ); - } - global::renderEngine.postDraw(); for (const std::function& func : global::callback::postDraw) { diff --git a/src/interaction/joystickcamerastates.cpp b/src/interaction/joystickcamerastates.cpp index 351379d7c3..bb0a73514d 100644 --- a/src/interaction/joystickcamerastates.cpp +++ b/src/interaction/joystickcamerastates.cpp @@ -27,9 +27,9 @@ #include #include #include -#include - +#include #include +#include namespace openspace::interaction { @@ -224,50 +224,3 @@ std::vector JoystickCameraStates::buttonCommand(int button) const { } // namespace openspace::interaction - -namespace ghoul { - -template <> -std::string to_string(const openspace::interaction::JoystickCameraStates::AxisType& value) -{ - using T = openspace::interaction::JoystickCameraStates::AxisType; - switch (value) { - case T::None: return "None"; - case T::OrbitX: return "Orbit X"; - case T::OrbitY: return "Orbit Y"; - case T::ZoomIn: return "Zoom In"; - case T::ZoomOut: return "Zoom Out"; - case T::LocalRollX: return "LocalRoll X"; - case T::LocalRollY: return "LocalRoll Y"; - case T::GlobalRollX: return "GlobalRoll X"; - case T::GlobalRollY: return "GlobalRoll Y"; - case T::PanX: return "Pan X"; - case T::PanY: return "Pan Y"; - default: return ""; - } -} - -template <> -openspace::interaction::JoystickCameraStates::AxisType from_string( - const std::string& string) -{ - using T = openspace::interaction::JoystickCameraStates::AxisType; - - static const std::map Map = { - { "None", T::None }, - { "Orbit X", T::OrbitX }, - { "Orbit Y", T::OrbitY }, - { "Zoom In", T::ZoomIn }, - { "Zoom Out", T::ZoomOut }, - { "LocalRoll X", T::LocalRollX }, - { "LocalRoll Y", T::LocalRollY }, - { "GlobalRoll X", T::GlobalRollX }, - { "GlobalRoll Y", T::GlobalRollY }, - { "Pan X", T::PanX }, - { "Pan Y", T::PanY } - }; - - return Map.at(string); -} - -} // namespace ghoul diff --git a/src/interaction/joystickinputstate.cpp b/src/interaction/joystickinputstate.cpp index 5e58b92aca..70815d0581 100644 --- a/src/interaction/joystickinputstate.cpp +++ b/src/interaction/joystickinputstate.cpp @@ -68,31 +68,3 @@ bool JoystickInputStates::button(int button, JoystickAction action) const { } } // namespace openspace::interaction - -namespace ghoul { - -template <> -std::string to_string(const openspace::interaction::JoystickAction& value) { - switch (value) { - case openspace::interaction::JoystickAction::Idle: return "Idle"; - case openspace::interaction::JoystickAction::Press: return "Press"; - case openspace::interaction::JoystickAction::Repeat: return "Repeat"; - case openspace::interaction::JoystickAction::Release: return "Release"; - default: return ""; - } -} - -template <> -openspace::interaction::JoystickAction from_string(const std::string& string) { - static const std::map Map = { - { "Idle", openspace::interaction::JoystickAction::Idle }, - { "Press", openspace::interaction::JoystickAction::Press }, - { "Repeat", openspace::interaction::JoystickAction::Repeat }, - { "Release", openspace::interaction::JoystickAction::Release } - }; - - return Map.at(string); - -} - -} // namespace ghoul diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index b383eef56e..4268b5c180 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -659,17 +659,21 @@ glm::dvec3 OrbitalNavigator::cameraToSurfaceVector(const glm::dvec3& cameraPos, return centerToActualSurface - posDiff; } -void OrbitalNavigator::setFocusNode(const SceneGraphNode* focusNode) { - setAnchorNode(focusNode); +void OrbitalNavigator::setFocusNode(const SceneGraphNode* focusNode, + bool resetVelocitiesOnChange) +{ + setAnchorNode(focusNode, resetVelocitiesOnChange); setAimNode(nullptr); } -void OrbitalNavigator::setFocusNode(const std::string& focusNode) { +void OrbitalNavigator::setFocusNode(const std::string& focusNode, bool) { _anchor.set(focusNode); _aim.set(std::string("")); } -void OrbitalNavigator::setAnchorNode(const SceneGraphNode* anchorNode) { +void OrbitalNavigator::setAnchorNode(const SceneGraphNode* anchorNode, + bool resetVelocitiesOnChange) +{ if (!_anchorNode) { _directlySetStereoDistance = true; } @@ -679,7 +683,7 @@ void OrbitalNavigator::setAnchorNode(const SceneGraphNode* anchorNode) { // Need to reset velocities after the actual switch in anchor node, // since the reset behavior depends on the anchor node. - if (changedAnchor) { + if (changedAnchor && resetVelocitiesOnChange) { resetVelocities(); } diff --git a/src/interaction/websocketcamerastates.cpp b/src/interaction/websocketcamerastates.cpp index c97bb5901a..0881607a9a 100644 --- a/src/interaction/websocketcamerastates.cpp +++ b/src/interaction/websocketcamerastates.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -212,52 +213,4 @@ std::vector WebsocketCameraStates::buttonCommand(int button) const return result; } - } // namespace openspace::interaction - -namespace ghoul { - -template <> -std::string to_string(const openspace::interaction::WebsocketCameraStates::AxisType& type) -{ - using T = openspace::interaction::WebsocketCameraStates::AxisType; - switch (type) { - case T::None: return "None"; - case T::OrbitX: return "Orbit X"; - case T::OrbitY: return "Orbit Y"; - case T::ZoomIn: return "Zoom In"; - case T::ZoomOut: return "Zoom Out"; - case T::LocalRollX: return "LocalRoll X"; - case T::LocalRollY: return "LocalRoll Y"; - case T::GlobalRollX: return "GlobalRoll X"; - case T::GlobalRollY: return "GlobalRoll Y"; - case T::PanX: return "Pan X"; - case T::PanY: return "Pan Y"; - default: return ""; - } -} - -template <> -openspace::interaction::WebsocketCameraStates::AxisType from_string( - const std::string& string) -{ - using T = openspace::interaction::WebsocketCameraStates::AxisType; - - static const std::map Map = { - { "None", T::None }, - { "Orbit X", T::OrbitX }, - { "Orbit Y", T::OrbitY }, - { "Zoom In", T::ZoomIn }, - { "Zoom Out", T::ZoomOut }, - { "LocalRoll X", T::LocalRollX }, - { "LocalRoll Y", T::LocalRollY }, - { "GlobalRoll X", T::GlobalRollX }, - { "GlobalRoll Y", T::GlobalRollY }, - { "Pan X", T::PanX }, - { "Pan Y", T::PanY } - }; - - return Map.at(string); -} - -} // namespace ghoul diff --git a/src/interaction/websocketinputstate.cpp b/src/interaction/websocketinputstate.cpp index 9ccccf12cb..2c918d84e8 100644 --- a/src/interaction/websocketinputstate.cpp +++ b/src/interaction/websocketinputstate.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -71,31 +72,3 @@ bool WebsocketInputStates::button(int button, WebsocketAction action) const { } } // namespace openspace::interaction - -namespace ghoul { - -template <> -std::string to_string(const openspace::interaction::WebsocketAction& action) { - switch (action) { - case openspace::interaction::WebsocketAction::Idle: return "Idle"; - case openspace::interaction::WebsocketAction::Press: return "Press"; - case openspace::interaction::WebsocketAction::Repeat: return "Repeat"; - case openspace::interaction::WebsocketAction::Release: return "Release"; - default: return ""; - } -} - -template <> -openspace::interaction::WebsocketAction from_string(const std::string& string) { - static const std::map Map = { - { "Idle", openspace::interaction::WebsocketAction::Idle }, - { "Press", openspace::interaction::WebsocketAction::Press }, - { "Repeat", openspace::interaction::WebsocketAction::Repeat }, - { "Release", openspace::interaction::WebsocketAction::Release } - }; - - return Map.at(string); - -} - -} // namespace ghoul diff --git a/src/performance/performancelayout.cpp b/src/performance/performancelayout.cpp deleted file mode 100644 index 0fbbb12788..0000000000 --- a/src/performance/performancelayout.cpp +++ /dev/null @@ -1,45 +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 - -#include - -namespace openspace::performance { - -PerformanceLayout::PerformanceLayout() { - std::memset( - sceneGraphEntries, - 0, - MaxValues * sizeof(SceneGraphPerformanceLayout) - ); - - std::memset( - functionEntries, - 0, - MaxValues * sizeof(FunctionPerformanceLayout) - ); -} - -} // namespace openspace::performance diff --git a/src/performance/performancemanager.cpp b/src/performance/performancemanager.cpp deleted file mode 100644 index bd4b60096c..0000000000 --- a/src/performance/performancemanager.cpp +++ /dev/null @@ -1,458 +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 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - constexpr const char* _loggerCat = "PerformanceManager"; - - constexpr const char* GlobalSharedMemoryName = "OpenSpacePerformanceMeasurementData"; - // Probably 255 performance blocks per node are enough, so we can get away with - // 4 bytes (one uint8_t for the number, one uint8_t for the reference count to keep - // the global memory alive, and 2 bytes to enforce alignment) - constexpr const size_t GlobalSharedMemorySize = 4; - - struct GlobalMemory { - uint8_t number; - uint8_t referenceCount; - - std::array alignment; - }; - - constexpr const char* LocalSharedMemoryNameBase = "PerformanceMeasurement_"; -} // namespace - -namespace openspace::performance { - -// The Performance Manager will use a level of indirection in order to support multiple -// PerformanceManagers running in parallel: -// The ghoul::SharedData block addressed by OpenSpacePerformanceMeasurementSharedData -// will only get allocated once and contains the total number of allocated shared memory -// blocks alongside a list of names of these blocks - -void PerformanceManager::CreateGlobalSharedMemory() { - static_assert( - sizeof(GlobalMemory) == GlobalSharedMemorySize, - "The global memory struct does not fit the allocated global memory space" - ); - - if (ghoul::SharedMemory::exists(GlobalSharedMemoryName)) { - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - ++(m->referenceCount); - LINFO(fmt::format( - "Using global shared memory block for performance measurements. " - "Reference count: {}", - int(m->referenceCount) - )); - sharedMemory.releaseLock(); - } - else { - LINFO("Creating global shared memory block for performance measurements"); - ghoul::SharedMemory::create(GlobalSharedMemoryName, GlobalSharedMemorySize); - - // Initialize the data - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - new (sharedMemory.memory()) GlobalMemory; - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - m->number = 0; - m->referenceCount = 1; - sharedMemory.releaseLock(); - } -} - -void PerformanceManager::DestroyGlobalSharedMemory() { - if (!ghoul::SharedMemory::exists(GlobalSharedMemoryName)) { - LWARNING("Global shared memory for Performance measurements did not exist"); - return; - } - - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - --(m->referenceCount); - LINFO(fmt::format( - "Global shared performance memory reference count: {}", - static_cast(m->referenceCount) - )); - if (m->referenceCount == 0) { - LINFO("Removing global shared performance memory"); - - // When the global memory is deleted, we have to get rid of all local memory as - // well. In principle, none should be left, but OpenSpace crashing might leave - // some of the memory orphaned - for (int i = 0; i < std::numeric_limits::max(); ++i) { - std::string localName = LocalSharedMemoryNameBase + std::to_string(i); - if (ghoul::SharedMemory::exists(localName)) { - LINFO(fmt::format("Removing shared memory: {}", localName)); - ghoul::SharedMemory::remove(localName); - } - } - - ghoul::SharedMemory::remove(GlobalSharedMemoryName); - } - sharedMemory.releaseLock(); -} - -void PerformanceManager::setEnabled(bool enabled) { - _logDir = absPath("${BASE}"); - _prefix = "PM-"; - - _performanceMeasurementEnabled = enabled; - - if (enabled) { - PerformanceManager::CreateGlobalSharedMemory(); - - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - defer { - sharedMemory.releaseLock(); - }; - - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - - // The the first free block (which also coincides with the number of blocks - uint8_t blockIndex = m->number; - ++(m->number); - - const std::string& localName = LocalSharedMemoryNameBase + - std::to_string(blockIndex); - - // Compute the total size - const int totalSize = sizeof(PerformanceLayout); - LINFO(fmt::format("Create shared memory '{}' of {} bytes", localName, totalSize)); - - if (ghoul::SharedMemory::exists(localName)) { - throw ghoul::RuntimeError( - "Shared Memory '" + localName + "' block already existed" - ); - } - - ghoul::SharedMemory::create(localName, totalSize); - - _performanceMemory = std::make_unique(localName); - // Using the placement-new to create a PerformanceLayout in the shared memory - new (_performanceMemory->memory()) PerformanceLayout; - } - else { - if (loggingEnabled()) { - outputLogs(); - } - - if (_performanceMemory) { - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - --(m->number); - sharedMemory.releaseLock(); - - LINFO(fmt::format("Remove shared memory '{}'", _performanceMemory->name())); - ghoul::SharedMemory::remove(_performanceMemory->name()); - - _performanceMemory = nullptr; - } - - PerformanceManager::DestroyGlobalSharedMemory(); - } -} - -bool PerformanceManager::isEnabled() const { - return _performanceMeasurementEnabled; -} - -void PerformanceManager::resetPerformanceMeasurements() { - // Using the placement-new to create a PerformanceLayout in the shared memory - _performanceMemory->acquireLock(); - new (_performanceMemory->memory()) PerformanceLayout; - _performanceMemory->releaseLock(); - - individualPerformanceLocations.clear(); -} - -void PerformanceManager::outputLogs() { - // Log Layout values - PerformanceLayout* layout = performanceData(); - const size_t writeStart = (PerformanceLayout::NumberValues - 1) - _currentTick; - - // Log function performance - for (int16_t n = 0; n < layout->nFunctionEntries; n++) { - const PerformanceLayout::FunctionPerformanceLayout& function = - layout->functionEntries[n]; - std::string filename = formatLogName(function.name); - std::ofstream out = std::ofstream( - absPath(std::move(filename)), - std::ofstream::out | std::ofstream::app - ); - - // Comma separate data - for (size_t i = writeStart; i < PerformanceLayout::NumberValues; i++) { - const std::vector& data = { function.time[i] }; - writeData(out, data); - } - out.close(); - } - - // Log scene object performance - for (int16_t n = 0; n < layout->nScaleGraphEntries; n++) { - const PerformanceLayout::SceneGraphPerformanceLayout node = - layout->sceneGraphEntries[n]; - - // Open file - std::string filename = formatLogName(node.name); - std::ofstream out = std::ofstream( - absPath(std::move(filename)), - std::ofstream::out | std::ofstream::app - ); - - // Comma separate data - for (size_t i = writeStart; i < PerformanceLayout::NumberValues; i++) { - const std::vector data = { - node.renderTime[i], - node.updateRenderable[i], - node.updateRotation[i], - node.updateScaling[i], - node.updateTranslation[i] - }; - writeData(out, data); - } - out.close(); - } -} - -void PerformanceManager::writeData(std::ofstream& out, const std::vector& data) { - for (size_t i = 0; i < data.size() - 1; i++) { - out << data[i] << ","; - } - out << data[data.size() - 1] << "\n"; -} - - std::string PerformanceManager::formatLogName(std::string nodeName) { - // Replace any colons with dashes - std::replace(nodeName.begin(), nodeName.end(), ':', '-'); - // Replace spaces with underscore - std::replace(nodeName.begin(), nodeName.end(), ' ', '_'); - return _logDir + "/" + _prefix + nodeName + "." + _ext; -} - -void PerformanceManager::logDir(std::string dir) { - _logDir = absPath(std::move(dir)); -} - -const std::string& PerformanceManager::logDir() const { - return _logDir; -} - -void PerformanceManager::prefix(std::string prefix) { - _prefix = std::move(prefix); -} - -const std::string& PerformanceManager::prefix() const { - return _prefix; -} - -void PerformanceManager::enableLogging() { - setLogging(true); -} - -void PerformanceManager::disableLogging() { - setLogging(false); -} - -void PerformanceManager::toggleLogging() { - setLogging(!_loggingEnabled); -} - -void PerformanceManager::setLogging(bool enabled) { - // Create the log directory if it doesn't exist. Do it here, so that it - // only tests once each time output is enabled - if (enabled) { - // If it can't create the directory, it's not logging so set false - enabled = createLogDir(); - } - - _loggingEnabled = enabled; -} - -bool PerformanceManager::createLogDir() { - // Done if it exists - ghoul::filesystem::Directory dir(_logDir); - if (FileSys.directoryExists(dir)) { - return true; - } - - // Error and set false if can't create - try { - FileSys.createDirectory(dir, ghoul::filesystem::FileSystem::Recursive::Yes); - } - catch (const ghoul::filesystem::FileSystem::FileSystemException& e) { - LERROR(fmt::format("Could not create log directory: {}", e.message)); - return false; - } - return true; -} - -bool PerformanceManager::loggingEnabled() const { - return _loggingEnabled; -} - -PerformanceLayout* PerformanceManager::performanceData() { - void* ptr = _performanceMemory->memory(); - return reinterpret_cast(ptr); -} - -void PerformanceManager::tick() { - _currentTick = (_currentTick + 1) % PerformanceLayout::NumberValues; -} - -void PerformanceManager::storeIndividualPerformanceMeasurement( - const std::string& identifier, - long long microseconds) -{ - if (!_performanceMemory) { - // If someone called the PerfMeasure macro without checking whether we are - // currently set-up for recording, we don't want to crash, so we just discard - return; - } - - PerformanceLayout* layout = performanceData(); - _performanceMemory->acquireLock(); - - auto it = individualPerformanceLocations.find(identifier); - PerformanceLayout::FunctionPerformanceLayout* p = nullptr; - if (it == individualPerformanceLocations.end()) { - p = &(layout->functionEntries[layout->nFunctionEntries]); - individualPerformanceLocations[identifier] = layout->nFunctionEntries; - ++(layout->nFunctionEntries); - } - else { - p = &(layout->functionEntries[it->second]); - } -#ifdef _MSC_VER - strcpy_s(p->name, identifier.length() + 1, identifier.c_str()); -#else - strcpy(p->name, identifier.c_str()); -#endif - - std::rotate( - std::begin(p->time), - std::next(std::begin(p->time)), - std::end(p->time) - ); - p->time[PerformanceLayout::NumberValues - 1] = static_cast(microseconds); - - _performanceMemory->releaseLock(); -} - -void PerformanceManager::storeScenePerformanceMeasurements( - const std::vector& sceneNodes) -{ - PerformanceLayout* layout = performanceData(); - _performanceMemory->acquireLock(); - - const int nNodes = static_cast(sceneNodes.size()); - layout->nScaleGraphEntries = static_cast(nNodes); - for (int i = 0; i < nNodes; ++i) { - const SceneGraphNode& node = *sceneNodes[i]; - - memset(layout->sceneGraphEntries[i].name, 0, PerformanceLayout::LengthName); -#ifdef _MSC_VER - strcpy_s( - layout->sceneGraphEntries[i].name, - node.identifier().length() + 1, - node.identifier().c_str() - ); -#else - strcpy(layout->sceneGraphEntries[i].name, node.identifier().c_str()); -#endif - - const SceneGraphNode::PerformanceRecord& r = node.performanceRecord(); - PerformanceLayout::SceneGraphPerformanceLayout& entry = - layout->sceneGraphEntries[i]; - - // Covert nano to microseconds - constexpr const float Micro = 1000.f; - - std::rotate( - std::begin(entry.renderTime), - std::next(std::begin(entry.renderTime)), - std::end(entry.renderTime) - ); - entry.renderTime[PerformanceLayout::NumberValues - 1] = r.renderTime / Micro; - - std::rotate( - std::begin(entry.updateTranslation), - std::next(std::begin(entry.updateTranslation)), - std::end(entry.updateTranslation) - ); - entry.updateTranslation[PerformanceLayout::NumberValues - 1] = - r.updateTimeTranslation / Micro; - - std::rotate( - std::begin(entry.updateRotation), - std::next(std::begin(entry.updateRotation)), - std::end(entry.updateRotation) - ); - entry.updateRotation[PerformanceLayout::NumberValues - 1] = - r.updateTimeRotation / Micro; - - std::rotate( - std::begin(entry.updateScaling), - std::next(std::begin(entry.updateScaling)), - std::end(entry.updateScaling) - ); - entry.updateScaling[PerformanceLayout::NumberValues - 1] = - r.updateTimeScaling / Micro; - - std::rotate( - std::begin(entry.updateRenderable), - std::next(std::begin(entry.updateRenderable)), - std::end(entry.updateRenderable) - ); - entry.updateRenderable[PerformanceLayout::NumberValues - 1] = - r.updateTimeRenderable / Micro; - } - _performanceMemory->releaseLock(); - - if (_loggingEnabled && _currentTick == PerformanceLayout::NumberValues - 1) { - outputLogs(); - } - - tick(); -} - -} // namespace openspace::performance diff --git a/src/performance/performancemeasurement.cpp b/src/performance/performancemeasurement.cpp deleted file mode 100644 index a529f70ea9..0000000000 --- a/src/performance/performancemeasurement.cpp +++ /dev/null @@ -1,53 +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 - -#include -#include -#include - -namespace openspace::performance { - -PerformanceMeasurement::PerformanceMeasurement(std::string identifier) - : _identifier(std::move(identifier)) -{ - glFinish(); - _startTime = std::chrono::high_resolution_clock::now(); -} - -PerformanceMeasurement::~PerformanceMeasurement() { - glFinish(); - auto endTime = std::chrono::high_resolution_clock::now(); - auto duration = std::chrono::duration_cast( - endTime - _startTime - ).count(); - - global::performanceManager.storeIndividualPerformanceMeasurement( - std::move(_identifier), - duration - ); -} - -} // namespace openspace::performance diff --git a/src/rendering/dashboarditem.cpp b/src/rendering/dashboarditem.cpp index 6b807b909f..a075d500ed 100644 --- a/src/rendering/dashboarditem.cpp +++ b/src/rendering/dashboarditem.cpp @@ -95,7 +95,8 @@ std::unique_ptr DashboardItem::createFromDictionary( const std::string& dashboardType = dictionary.value(KeyType); - return factory->create(dashboardType, std::move(dictionary)); + DashboardItem* item = factory->create(dashboardType, std::move(dictionary)); + return std::unique_ptr(item); } DashboardItem::DashboardItem(const ghoul::Dictionary& dictionary) diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index d0fe84d5ff..a97ceb4f69 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -26,8 +26,6 @@ #include #include -#include -#include #include #include #include @@ -514,14 +512,6 @@ 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" - ); - } _hdrFilteringProgram->activate(); ghoul::opengl::TextureUnit hdrFeedingTextureUnit; @@ -554,15 +544,6 @@ void FramebufferRenderer::applyTMO(float blackoutFactor) { } void FramebufferRenderer::applyFXAA() { - const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); - std::unique_ptr perfInternal; - - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::FXAA" - ); - } - _fxaaProgram->activate(); ghoul::opengl::TextureUnit renderedTextureUnit; @@ -636,15 +617,6 @@ void FramebufferRenderer::updateDownscaleTextures() { } void FramebufferRenderer::writeDownscaledVolume() { - const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); - std::unique_ptr perfInternal; - - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::writeDownscaledVolume" - ); - } - // Saving current OpenGL state GLboolean blendEnabled = glIsEnabledi(GL_BLEND, 0); @@ -1160,16 +1132,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac _pingPongIndex = 0; - // Measurements cache variable - const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); - - std::unique_ptr perf; - if (doPerformanceMeasurements) { - perf = std::make_unique( - "FramebufferRenderer::render" - ); - } - if (!scene || !camera) { return; } @@ -1191,7 +1153,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac RenderData data = { *camera, std::move(time), - doPerformanceMeasurements, 0, {} }; @@ -1218,13 +1179,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac // Run Volume Tasks { GLDebugGroup group("Raycaster Tasks"); - - std::unique_ptr perfInternal; - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::raycasterTasks" - ); - } performRaycasterTasks(tasks.raycasterTasks); if (HasGLDebugInfo) { @@ -1241,12 +1195,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glBindFramebuffer(GL_FRAMEBUFFER, _pingPongBuffers.framebuffer); glDrawBuffers(1, &ColorAttachmentArray[_pingPongIndex]); - std::unique_ptr perfInternal; - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::deferredTasks" - ); - } performDeferredTasks(tasks.deferredcasterTasks); } diff --git a/src/rendering/loadingscreen.cpp b/src/rendering/loadingscreen.cpp index 9694115f51..8f7fb9fc0e 100644 --- a/src/rendering/loadingscreen.cpp +++ b/src/rendering/loadingscreen.cpp @@ -268,16 +268,15 @@ void LoadingScreen::render() { "Loading..."; // We use "Loading" to center the text, but render "Loading..." to make it look more // pleasing - const FR::BoundingBoxInformation bbox = renderer.boundingBox( - *_loadingFont, + const glm::vec2 bbox = _loadingFont->boundingBox( headline.substr(0, headline.size() - 2) ); const glm::vec2 loadingLl = glm::vec2( - res.x / 2.f - bbox.boundingBox.x / 2.f, + res.x / 2.f - bbox.x / 2.f, res.y * LoadingTextPosition ); - const glm::vec2 loadingUr = loadingLl + bbox.boundingBox; + const glm::vec2 loadingUr = loadingLl + bbox; renderer.render(*_loadingFont, loadingLl, headline); @@ -286,16 +285,13 @@ void LoadingScreen::render() { if (_showMessage) { std::lock_guard guard(_messageMutex); - FR::BoundingBoxInformation bboxMessage = renderer.boundingBox( - *_messageFont, - _message - ); + const glm::vec2 bboxMessage = _messageFont->boundingBox(_message); messageLl = glm::vec2( - res.x / 2.f - bboxMessage.boundingBox.x / 2.f, + res.x / 2.f - bboxMessage.x / 2.f, res.y * StatusMessageOffset ); - messageUr = messageLl + bboxMessage.boundingBox; + messageUr = messageLl + bboxMessage; renderer.render(*_messageFont, messageLl, _message); @@ -322,8 +318,7 @@ void LoadingScreen::render() { if (!item.hasLocation) { // Compute a new location - const FR::BoundingBoxInformation b = renderer.boundingBox( - *_itemFont, + const glm::vec2 b = _itemFont->boundingBox( (item.name + " 100%\n99999999/99999999") ); @@ -338,15 +333,15 @@ void LoadingScreen::render() { for (; i < MaxNumberLocationSamples && !foundSpace; ++i) { std::uniform_int_distribution distX( 15, - static_cast(res.x - b.boundingBox.x - 15) + static_cast(res.x - b.x - 15) ); std::uniform_int_distribution distY( 15, - static_cast(res.y - b.boundingBox.y - 15) + static_cast(res.y - b.y - 15) ); ll = { distX(_randomEngine), distY(_randomEngine) }; - ur = ll + b.boundingBox; + ur = ll + b; // Test against logo and text const bool logoOverlap = rectOverlaps( diff --git a/src/rendering/luaconsole.cpp b/src/rendering/luaconsole.cpp index 84a4f3ba79..20a302f976 100644 --- a/src/rendering/luaconsole.cpp +++ b/src/rendering/luaconsole.cpp @@ -599,19 +599,12 @@ void LuaConsole::update() { // Compute the height by simulating _historyFont number of lines and checking // what the bounding box for that text would be. using namespace ghoul::fontrendering; - const size_t nLines = std::min( - static_cast(_historyLength), - _commandsHistory.size() - ); - const FontRenderer::BoundingBoxInformation& bbox = - FontRenderer::defaultRenderer().boundingBox( - *_historyFont, - std::string(nLines, '\n') - ); + + const float height = _historyFont->height() * (_commandsHistory.size() + 1); // Update the full height and the target height. // Add the height of the entry line and space for a separator. - _fullHeight = (bbox.boundingBox.y + EntryFontSize + SeparatorSpace); + _fullHeight = (height + EntryFontSize + SeparatorSpace); _targetHeight = _isVisible ? _fullHeight : 0; // The first frame is going to be finished in approx 10 us, which causes a floating @@ -629,7 +622,7 @@ void LuaConsole::update() { _currentHeight += static_cast(dHeight); - _currentHeight = std::max(0.0f, _currentHeight); + _currentHeight = std::max(0.f, _currentHeight); _currentHeight = std::min(static_cast(res.y), _currentHeight); } @@ -683,10 +676,8 @@ void LuaConsole::render() { using namespace ghoul::fontrendering; // Compute the current width of the string and console prefix. - const float currentWidth = FontRenderer::defaultRenderer().boundingBox( - *_font, - "> " + currentCommand - ).boundingBox.x + inputLocation.x; + const float currentWidth = + _font->boundingBox("> " + currentCommand).x + inputLocation.x; // Compute the overflow in pixels const float overflow = currentWidth - res.x * 0.995f; @@ -792,13 +783,8 @@ void LuaConsole::render() { res.y - _currentHeight + EntryFontSize ); - const FontRenderer::BoundingBoxInformation bbox = - FontRenderer::defaultRenderer().boundingBox(*_font, text); - - return glm::vec2( - loc.x + res.x - bbox.boundingBox.x - 10.f, - loc.y - ); + const glm::vec2 bbox = _font->boundingBox(text); + return glm::vec2(loc.x + res.x - bbox.x - 10.f, loc.y); }; if (_remoteScripting) { diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 8e11770be0..453e040829 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -26,8 +26,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -44,8 +46,9 @@ namespace { constexpr openspace::properties::Property::PropertyInfo OpacityInfo = { "Opacity", - "Transparency", - "This value determines the transparency of this object." + "Opacity", + "This value determines the opacity of this renderable. A value of 0 means " + "completely transparent." }; constexpr openspace::properties::Property::PropertyInfo RenderableTypeInfo = { @@ -97,7 +100,7 @@ documentation::Documentation Renderable::Documentation() { }; } -std::unique_ptr Renderable::createFromDictionary( +ghoul::mm_unique_ptr Renderable::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Renderable"); @@ -106,8 +109,12 @@ std::unique_ptr Renderable::createFromDictionary( auto factory = FactoryManager::ref().factory(); ghoul_assert(factory, "Renderable factory did not exist"); - std::unique_ptr result = factory->create(renderableType, dictionary); - return result; + Renderable* result = factory->create( + renderableType, + dictionary, + &global::memoryManager.PersistentMemory + ); + return ghoul::mm_unique_ptr(result); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 0edbfb1e0e..4653c618a9 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include #include #include @@ -258,7 +256,6 @@ namespace openspace { RenderEngine::RenderEngine() : properties::PropertyOwner({ "RenderEngine" }) - , _doPerformanceMeasurements(PerformanceInfo) , _showOverlayOnSlaves(ShowOverlaySlavesInfo, false) , _showLog(ShowLogInfo, true) , _verticalLogOffset(VerticalLogOffsetInfo, 0.f, 0.f, 1.f) @@ -298,11 +295,6 @@ RenderEngine::RenderEngine() glm::vec3(glm::pi()) ) { - _doPerformanceMeasurements.onChange([this](){ - global::performanceManager.setEnabled(_doPerformanceMeasurements); - }); - addProperty(_doPerformanceMeasurements); - addProperty(_showOverlayOnSlaves); addProperty(_showLog); addProperty(_verticalLogOffset); @@ -529,8 +521,7 @@ void RenderEngine::updateScene() { _scene->update({ TransformData{ glm::dvec3(0.0), glm::dmat3(1.0), glm::dvec3(1.0) }, currentTime, - integrateFromTime, - _doPerformanceMeasurements + integrateFromTime }); LTRACE("RenderEngine::updateSceneGraph(end)"); @@ -805,14 +796,10 @@ void RenderEngine::renderEndscreen() { glViewport(0, 0, res.x, res.y); using FR = ghoul::fontrendering::FontRenderer; - using BBox = FR::BoundingBoxInformation; - BBox size = FR::defaultRenderer().boundingBox( - *_fontDate, - "Shutting down" - ); + const glm::vec2 size = _fontDate->boundingBox("Shutting down"); glm::vec2 penPosition = glm::vec2( - fontResolution().x / 2 - size.boundingBox.x / 2, - fontResolution().y / 2 - size.boundingBox.y / 2 + fontResolution().x / 2 - size.x / 2, + fontResolution().y / 2 - size.y / 2 ); RenderFont(*_fontDate, penPosition, "Shutting down"); } @@ -822,15 +809,13 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) { timer = std::max(timer, 0.f); - using BBox = ghoul::fontrendering::FontRenderer::BoundingBoxInformation; - BBox size = ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( - *_fontDate, + const glm::vec2 size = _fontDate->boundingBox( fmt::format("Shutdown in: {:.2f}s/{:.2f}s", timer, fullTime) ); glm::vec2 penPosition = glm::vec2( - fontResolution().x - size.boundingBox.x - 10, - fontResolution().y - size.boundingBox.y + fontResolution().x - size.x - 10, + fontResolution().y - size.y ); RenderFont( @@ -853,13 +838,6 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) { void RenderEngine::renderDashboard() { ZoneScoped - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "Main Dashboard::render" - ); - } - glm::vec2 dashboardStart = global::dashboard.getStartPositionOffset(); glm::vec2 penPosition = glm::vec2( dashboardStart.x, @@ -889,12 +867,6 @@ void RenderEngine::postDraw() { ++_frameNumber; - if (global::performanceManager.isEnabled()) { - global::performanceManager.storeScenePerformanceMeasurements( - scene()->allSceneGraphNodes() - ); - } - #ifdef OPENSPACE_WITH_INSTRUMENTATION if (_saveFrameInformation) { _frameInfo.frames.push_back({ @@ -1276,13 +1248,9 @@ void RenderEngine::renderCameraInformation() { const glm::vec4 EnabledColor = glm::vec4(0.2f, 0.75f, 0.2f, 1.f); const glm::vec4 DisabledColor = glm::vec4(0.55f, 0.2f, 0.2f, 1.f); - using FR = ghoul::fontrendering::FontRenderer; - const FR::BoundingBoxInformation rotationBox = FR::defaultRenderer().boundingBox( - *_fontInfo, - "Rotation" - ); + const glm::vec2 rotationBox = _fontInfo->boundingBox("Rotation"); - float penPosY = fontResolution().y - rotationBox.boundingBox.y; + float penPosY = fontResolution().y - rotationBox.y; constexpr const float YSeparation = 5.f; constexpr const float XSeparation = 5.f; @@ -1290,53 +1258,49 @@ void RenderEngine::renderCameraInformation() { const interaction::OrbitalNavigator& nav = global::navigationHandler.orbitalNavigator(); + using FR = ghoul::fontrendering::FontRenderer; + _cameraButtonLocations.rotation = { - fontResolution().x - rotationBox.boundingBox.x - XSeparation, + fontResolution().x - rotationBox.x - XSeparation, fontResolution().y - penPosY, - rotationBox.boundingBox.x, - rotationBox.boundingBox.y + rotationBox.x, + rotationBox.y }; FR::defaultRenderer().render( *_fontInfo, - glm::vec2(fontResolution().x - rotationBox.boundingBox.x - XSeparation, penPosY), + glm::vec2(fontResolution().x - rotationBox.x - XSeparation, penPosY), "Rotation", nav.hasRotationalFriction() ? EnabledColor : DisabledColor ); - penPosY -= rotationBox.boundingBox.y + YSeparation; + penPosY -= rotationBox.y + YSeparation; - FR::BoundingBoxInformation zoomBox = FR::defaultRenderer().boundingBox( - *_fontInfo, - "Zoom" - ); + const glm::vec2 zoomBox = _fontInfo->boundingBox("Zoom"); _cameraButtonLocations.zoom = { - fontResolution().x - zoomBox.boundingBox.x - XSeparation, + fontResolution().x - zoomBox.x - XSeparation, fontResolution().y - penPosY, - zoomBox.boundingBox.x, - zoomBox.boundingBox.y + zoomBox.x, + zoomBox.y }; FR::defaultRenderer().render( *_fontInfo, - glm::vec2(fontResolution().x - zoomBox.boundingBox.x - XSeparation, penPosY), + glm::vec2(fontResolution().x - zoomBox.x - XSeparation, penPosY), "Zoom", nav.hasZoomFriction() ? EnabledColor : DisabledColor ); - penPosY -= zoomBox.boundingBox.y + YSeparation; + penPosY -= zoomBox.y + YSeparation; - FR::BoundingBoxInformation rollBox = FR::defaultRenderer().boundingBox( - *_fontInfo, - "Roll" - ); + const glm::vec2 rollBox = _fontInfo->boundingBox("Roll"); _cameraButtonLocations.roll = { - fontResolution().x - rollBox.boundingBox.x - XSeparation, + fontResolution().x - rollBox.x - XSeparation, fontResolution().y - penPosY, - rollBox.boundingBox.x, - rollBox.boundingBox.y + rollBox.x, + rollBox.y }; FR::defaultRenderer().render( *_fontInfo, - glm::vec2(fontResolution().x - rollBox.boundingBox.x - XSeparation, penPosY), + glm::vec2(fontResolution().x - rollBox.x - XSeparation, penPosY), "Roll", nav.hasRollFriction() ? EnabledColor : DisabledColor ); @@ -1369,20 +1333,16 @@ void RenderEngine::renderVersionInformation() { } using FR = ghoul::fontrendering::FontRenderer; - const FR::BoundingBoxInformation versionBox = FR::defaultRenderer().boundingBox( - *_fontInfo, - versionString - ); + const glm::vec2 versionBox = _fontInfo->boundingBox(versionString); - const FR::BoundingBoxInformation commitBox = FR::defaultRenderer().boundingBox( - *_fontInfo, + const glm::vec2 commitBox = _fontInfo->boundingBox( fmt::format("{}@{}", OPENSPACE_GIT_BRANCH, OPENSPACE_GIT_COMMIT) ); FR::defaultRenderer().render( *_fontInfo, glm::vec2( - fontResolution().x - versionBox.boundingBox.x - 10.f, + fontResolution().x - versionBox.x - 10.f, 5.f ), versionString, @@ -1397,10 +1357,7 @@ void RenderEngine::renderVersionInformation() { // checking for that is a bit brittle) FR::defaultRenderer().render( *_fontInfo, - glm::vec2( - fontResolution().x - commitBox.boundingBox.x - 10.f, - versionBox.boundingBox.y + 5.f - ), + glm::vec2(fontResolution().x - commitBox.x - 10.f, versionBox.y + 5.f), OPENSPACE_GIT_FULL, glm::vec4(0.5, 0.5, 0.5, 1.f) ); @@ -1449,46 +1406,44 @@ void RenderEngine::renderScreenLog() { if (alpha <= 0.f) { break; } - - const std::string lvl = "(" + ghoul::to_string(e->level) + ")"; - const std::string& message = e->message.substr(0, MessageLength); + const std::string_view lvl = ghoul::to_string(e->level); + const std::string_view message = + std::string_view(e->message).substr(0, MessageLength); nr += std::count(message.begin(), message.end(), '\n'); const glm::vec4 white(0.9f, 0.9f, 0.9f, alpha); + std::string str = fmt::format( + "{:<15} {}{}", + e->timeString, + e->category.substr(0, CategoryLength), + e->category.length() > CategoryLength ? "..." : "" + ); + RenderFont( *_fontLog, glm::vec2( 10.f, _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset ), - fmt::format( - "{:<15} {}{}", - e->timeString, - e->category.substr(0, CategoryLength), - e->category.length() > CategoryLength ? "..." : "" - ), + str, white ); - glm::vec4 color = glm::vec4(0.f); - switch (e->level) { - case ghoul::logging::LogLevel::Debug: - color = glm::vec4(0.f, 1.f, 0.f, alpha); - break; - case ghoul::logging::LogLevel::Warning: - color = glm::vec4(1.f, 1.f, 0.f, alpha); - break; - case ghoul::logging::LogLevel::Error: - color = glm::vec4(1.f, 0.f, 0.f, alpha); - break; - case ghoul::logging::LogLevel::Fatal: - color = glm::vec4(0.3f, 0.3f, 0.85f, alpha); - break; - default: - color = white; - break; - } + const glm::vec4 color = [alpha, white](ScreenLog::LogLevel level) { + switch (level) { + case ghoul::logging::LogLevel::Debug: + return glm::vec4(0.f, 1.f, 0.f, alpha); + case ghoul::logging::LogLevel::Warning: + return glm::vec4(1.f, 1.f, 0.f, alpha); + case ghoul::logging::LogLevel::Error: + return glm::vec4(1.f, 0.f, 0.f, alpha); + case ghoul::logging::LogLevel::Fatal: + return glm::vec4(0.3f, 0.3f, 0.85f, alpha); + default: + return white; + } + }(e->level); RenderFont( *_fontLog, @@ -1496,7 +1451,7 @@ void RenderEngine::renderScreenLog() { 10 + 30 * _fontLog->pointSize(), _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset ), - lvl, + fmt::format("({})", lvl), color ); diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index ed9b3fbbeb..49df254322 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -307,10 +307,12 @@ std::unique_ptr ScreenSpaceRenderable::createFromDictiona ); const std::string& renderableType = dictionary.value(KeyType); - return FactoryManager::ref().factory()->create( - renderableType, - dictionary - ); + ScreenSpaceRenderable* ssr = + FactoryManager::ref().factory()->create( + renderableType, + dictionary + ); + return std::unique_ptr(ssr); } std::string ScreenSpaceRenderable::makeUniqueIdentifier(std::string name) { diff --git a/src/scene/lightsource.cpp b/src/scene/lightsource.cpp index cee754cfec..be63cf1a30 100644 --- a/src/scene/lightsource.cpp +++ b/src/scene/lightsource.cpp @@ -91,12 +91,12 @@ std::unique_ptr LightSource::createFromDictionary( const std::string timeFrameType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(timeFrameType, dictionary); - + LightSource* source = factory->create(timeFrameType, dictionary); + const std::string identifier = dictionary.value(KeyIdentifier); - result->setIdentifier(identifier); + source->setIdentifier(identifier); - return result; + return std::unique_ptr(source); } LightSource::LightSource() diff --git a/src/scene/rotation.cpp b/src/scene/rotation.cpp index 9f0233ece7..9c26296f87 100644 --- a/src/scene/rotation.cpp +++ b/src/scene/rotation.cpp @@ -26,7 +26,9 @@ #include #include +#include #include +#include #include #include #include @@ -59,15 +61,19 @@ documentation::Documentation Rotation::Documentation() { }; } -std::unique_ptr Rotation::createFromDictionary( +ghoul::mm_unique_ptr Rotation::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Rotation"); const std::string& rotationType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(rotationType, dictionary); - return result; + Rotation* result = factory->create( + rotationType, + dictionary, + &global::memoryManager.PersistentMemory + ); + return ghoul::mm_unique_ptr(result); } Rotation::Rotation() : properties::PropertyOwner({ "Rotation" }) {} diff --git a/src/scene/scale.cpp b/src/scene/scale.cpp index d1eb8e59fc..2083dcb172 100644 --- a/src/scene/scale.cpp +++ b/src/scene/scale.cpp @@ -26,7 +26,9 @@ #include #include +#include #include +#include #include #include #include @@ -58,15 +60,19 @@ documentation::Documentation Scale::Documentation() { }; } -std::unique_ptr Scale::createFromDictionary(const ghoul::Dictionary& dictionary) { +ghoul::mm_unique_ptr Scale::createFromDictionary(const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Scale"); std::string scaleType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(scaleType, dictionary); + Scale* result = factory->create( + scaleType, + dictionary, + &global::memoryManager.PersistentMemory + ); result->setIdentifier("Scale"); - return result; + return ghoul::mm_unique_ptr(result); } Scale::Scale() : properties::PropertyOwner({ "Scale" }) {} diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index cbfed9a5b9..aa2e434579 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -90,11 +90,11 @@ Scene::~Scene() { _rootDummy.setScene(nullptr); } -void Scene::attachNode(std::unique_ptr node) { +void Scene::attachNode(ghoul::mm_unique_ptr node) { _rootDummy.attachChild(std::move(node)); } -std::unique_ptr Scene::detachNode(SceneGraphNode& node) { +ghoul::mm_unique_ptr Scene::detachNode(SceneGraphNode& node) { return _rootDummy.detachChild(node); } @@ -303,11 +303,11 @@ void Scene::update(const UpdateData& data) { ZoneScoped std::vector initializedNodes = _initializer->takeInitializedNodes(); - for (SceneGraphNode* node : initializedNodes) { try { node->initializeGL(); - } catch (const ghoul::RuntimeError& e) { + } + catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.message); } } @@ -316,9 +316,7 @@ void Scene::update(const UpdateData& data) { } for (SceneGraphNode* node : _topologicallySortedNodes) { try { - LTRACE("Scene::update(begin '" + node->identifier() + "')"); node->update(data); - LTRACE("Scene::update(end '" + node->identifier() + "')"); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.what()); @@ -335,9 +333,7 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) { for (SceneGraphNode* node : _topologicallySortedNodes) { try { - LTRACE("Scene::render(begin '" + node->identifier() + "')"); node->render(data, tasks); - LTRACE("Scene::render(end '" + node->identifier() + "')"); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.what()); @@ -345,20 +341,19 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) { if (global::callback::webBrowserPerformanceHotfix) { (*global::callback::webBrowserPerformanceHotfix)(); } + } - { - ZoneScopedN("Get Error Hack") + { + ZoneScopedN("Get Error Hack") - // @TODO(abock 2019-08-19) This glGetError call is a hack to prevent the GPU - // thread and the CPU thread from diverging too much, particularly the - // uploading of a lot of textures for the globebrowsing planets can cause a - // hard stuttering effect. Asking for a glGetError after every rendering call - // will force the threads to implicitly synchronize and thus prevent the - // stuttering. The better solution would be to reduce the number of uploads - // per frame, use a staggered buffer, or something else like that preventing a - // large spike in uploads - glGetError(); - } + // @TODO(abock 2019-08-19) This glGetError call is a hack to prevent the GPU + // thread and the CPU thread from diverging too much, particularly the uploading + // of a lot of textures for the globebrowsing planets can cause a hard stuttering + // effect. Asking for a glGetError after every rendering call will force the + // threads to implicitly synchronize and thus prevent the stuttering. The better + // solution would be to reduce the number of uploads per frame, use a staggered + // buffer, or something else like that preventing a large spike in uploads + glGetError(); } } @@ -419,7 +414,7 @@ SceneGraphNode* Scene::loadNode(const ghoul::Dictionary& nodeDictionary) { } } - std::unique_ptr node = SceneGraphNode::createFromDictionary( + ghoul::mm_unique_ptr node = SceneGraphNode::createFromDictionary( nodeDictionary ); if (!node) { diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 37aa928996..67ed7b2991 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -594,7 +594,9 @@ int removeSceneGraphNode(lua_State* L) { [&removeNode, &markedList](SceneGraphNode* localNode) { std::vector children = localNode->children(); - std::unique_ptr n = localNode->parent()->detachChild(*localNode); + ghoul::mm_unique_ptr n = localNode->parent()->detachChild( + *localNode + ); ghoul_assert(n.get() == localNode, "Wrong node returned from detaching"); for (SceneGraphNode* c : children) { diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 32147034f9..2344ee9f77 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -56,7 +57,7 @@ namespace { constexpr openspace::properties::Property::PropertyInfo ComputeScreenSpaceInfo = { "ComputeScreenSpaceData", - "Screen Space Data", + "Compute Screen Space Data", "If this value is set to 'true', the screenspace-based properties are calculated " "at regular intervals. If these values are set to 'false', they are not updated." }; @@ -64,35 +65,43 @@ namespace { constexpr openspace::properties::Property::PropertyInfo ScreenSpacePositionInfo = { "ScreenSpacePosition", "ScreenSpacePosition", - "" // @TODO Missing documentation + "The x,y position in screen space. Can be used for placing GUI elements", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo ScreenVisibilityInfo = { "ScreenVisibility", "ScreenVisibility", - "" // @TODO Missing documentation + "Determines if the node is currently visible on screen", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo DistanceFromCamToNodeInfo = { "DistanceFromCamToNode", "DistanceFromCamToNode", - "" // @TODO Missing documentation + "The distance from the camera to the node surface", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo ScreenSizeRadiusInfo = { "ScreenSizeRadius", "ScreenSizeRadius", - "" // @TODO Missing documentation + "The screen size of the radius of the node", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo VisibilityDistanceInfo = { "VisibilityDistance", "VisibilityDistance", - "" // @TODO Missing documentation + "The distace in world coordinates between node and camera " + "at which the screenspace object will become visible", + openspace::properties::Property::Visibility::Hidden }; - constexpr const char* KeyFixedBoundingSphere = "FixedBoundingSphere"; constexpr openspace::properties::Property::PropertyInfo BoundingSphereInfo = { "BoundingSphere", "Bounding Sphere", "The bounding sphere of the scene graph node. This can be the " - "bounding sphere of a renderable or a fixed bounding sphere. " + "bounding sphere of an attached renderable or directly specified to the node. " + "If there is a boundingsphere on both the renderable and the node, the largest " + "number will be picked.", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo GuiPathInfo = { @@ -127,7 +136,7 @@ namespace openspace { int SceneGraphNode::nextIndex = 0; #endif // Debugging_Core_SceneGraphNode_Indices -std::unique_ptr SceneGraphNode::createFromDictionary( +ghoul::mm_unique_ptr SceneGraphNode::createFromDictionary( const ghoul::Dictionary& dictionary) { openspace::documentation::testSpecificationAndThrow( @@ -136,7 +145,9 @@ std::unique_ptr SceneGraphNode::createFromDictionary( "SceneGraphNode" ); - std::unique_ptr result = std::make_unique(); + SceneGraphNode* n = global::memoryManager.PersistentMemory.alloc(); + ghoul::mm_unique_ptr result = ghoul::mm_unique_ptr(n); + #ifdef Debugging_Core_SceneGraphNode_Indices result->index = nextIndex++; #endif // Debugging_Core_SceneGraphNode_Indices @@ -155,6 +166,11 @@ std::unique_ptr SceneGraphNode::createFromDictionary( result->addProperty(result->_guiHidden); } + if (dictionary.hasKey(BoundingSphereInfo.identifier)) { + result->_boundingSphere = dictionary.value(BoundingSphereInfo.identifier); + result->_boundingSphere.setVisibility(properties::Property::Visibility::All); + } + if (dictionary.hasKey(KeyTransformTranslation)) { ghoul::Dictionary translationDictionary; dictionary.getValue(KeyTransformTranslation, translationDictionary); @@ -246,6 +262,19 @@ std::unique_ptr SceneGraphNode::createFromDictionary( LDEBUG(fmt::format( "Successfully created renderable for '{}'", result->identifier() )); + + // If the renderable child has a larger bounding sphere, we allow it tooverride + if (result->_renderable->boundingSphere() > result->_boundingSphere) { + result->_boundingSphere = result->_renderable->boundingSphere(); + + if (dictionary.hasKey(BoundingSphereInfo.identifier)) { + LWARNING(fmt::format( + "The specified property 'BoundingSphere' for '{}' was overwritten " + "by a child renderable", + result->_identifier + )); + } + } } if (dictionary.hasKey(KeyTag)) { @@ -273,11 +302,6 @@ std::unique_ptr SceneGraphNode::createFromDictionary( result->addProperty(result->_guiPath); } - if (dictionary.hasKey(KeyFixedBoundingSphere)) { - result->_fixedBoundingSphere = static_cast( - dictionary.value(KeyFixedBoundingSphere) - ); - } LDEBUG(fmt::format("Successfully created SceneGraphNode '{}'", result->identifier())); @@ -291,10 +315,17 @@ SceneGraphNode::SceneGraphNode() , _guiPath(GuiPathInfo) , _guiDisplayName(GuiNameInfo) , _transform { - std::make_unique(), - std::make_unique(), - std::make_unique() + ghoul::mm_unique_ptr( + global::memoryManager.PersistentMemory.alloc() + ), + ghoul::mm_unique_ptr( + global::memoryManager.PersistentMemory.alloc() + ), + ghoul::mm_unique_ptr( + global::memoryManager.PersistentMemory.alloc() + ) } + , _boundingSphere(properties::FloatProperty(BoundingSphereInfo, 0.f)) , _computeScreenSpaceValues(ComputeScreenSpaceInfo, false) , _screenSpacePosition( properties::IVec2Property(ScreenSpacePositionInfo, glm::ivec2(-1, -1)) @@ -310,6 +341,7 @@ SceneGraphNode::SceneGraphNode() addProperty(_distFromCamToNode); addProperty(_screenSizeRadius); addProperty(_visibilityDistance); + addProperty(_boundingSphere); } SceneGraphNode::~SceneGraphNode() {} // NOLINT @@ -384,13 +416,13 @@ void SceneGraphNode::deinitializeGL() { void SceneGraphNode::traversePreOrder(const std::function& fn) { fn(this); - for (std::unique_ptr& child : _children) { + for (ghoul::mm_unique_ptr& child : _children) { child->traversePreOrder(fn); } } void SceneGraphNode::traversePostOrder(const std::function& fn) { - for (std::unique_ptr& child : _children) { + for (ghoul::mm_unique_ptr& child : _children) { child->traversePostOrder(fn); } fn(this); @@ -409,51 +441,15 @@ void SceneGraphNode::update(const UpdateData& data) { } if (_transform.translation) { - if (data.doPerformanceMeasurement) { - glFinish(); - const auto start = std::chrono::high_resolution_clock::now(); - - _transform.translation->update(data); - - glFinish(); - const auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeTranslation = (end - start).count(); - } - else { - _transform.translation->update(data); - } + _transform.translation->update(data); } if (_transform.rotation) { - if (data.doPerformanceMeasurement) { - glFinish(); - const auto start = std::chrono::high_resolution_clock::now(); - - _transform.rotation->update(data); - - glFinish(); - const auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeRotation = (end - start).count(); - } - else { - _transform.rotation->update(data); - } + _transform.rotation->update(data); } if (_transform.scale) { - if (data.doPerformanceMeasurement) { - glFinish(); - const auto start = std::chrono::high_resolution_clock::now(); - - _transform.scale->update(data); - - glFinish(); - const auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeScaling = (end - start).count(); - } - else { - _transform.scale->update(data); - } + _transform.scale->update(data); } UpdateData newUpdateData = data; @@ -477,19 +473,7 @@ void SceneGraphNode::update(const UpdateData& data) { _inverseModelTransformCached = glm::inverse(_modelTransformCached); if (_renderable && _renderable->isReady()) { - if (data.doPerformanceMeasurement) { - glFinish(); - auto start = std::chrono::high_resolution_clock::now(); - - _renderable->update(newUpdateData); - - glFinish(); - auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeRenderable = (end - start).count(); - } - else { - _renderable->update(newUpdateData); - } + _renderable->update(newUpdateData); } } @@ -504,7 +488,6 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { RenderData newData = { data.camera, data.time, - data.doPerformanceMeasurement, data.renderBinMask, { _worldPositionCached, _worldRotationCached, _worldScaleCached } }; @@ -513,30 +496,15 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { return; } - bool visible = _renderable && - _renderable->isVisible() && - _renderable->isReady() && - _renderable->isEnabled() && - _renderable->matchesRenderBinMask(data.renderBinMask); + const bool visible = _renderable && _renderable->isVisible() && + _renderable->isReady() && _renderable->isEnabled() && + _renderable->matchesRenderBinMask(data.renderBinMask); if (!visible) { return; } - if (data.doPerformanceMeasurement) { - glFinish(); - auto start = std::chrono::high_resolution_clock::now(); - - _renderable->render(newData, tasks); - if (_computeScreenSpaceValues) { - computeScreenSpaceData(newData); - } - - glFinish(); - auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.renderTime = (end - start).count(); - } - else { + { TracyGpuZone("Render") _renderable->render(newData, tasks); @@ -552,7 +520,7 @@ void SceneGraphNode::setParent(SceneGraphNode& parent) { parent.attachChild(_parent->detachChild(*this)); } -void SceneGraphNode::attachChild(std::unique_ptr child) { +void SceneGraphNode::attachChild(ghoul::mm_unique_ptr child) { ghoul_assert(child != nullptr, "Child may not be null"); ghoul_assert(child->parent() == nullptr, "Child may not already have a parent"); @@ -565,7 +533,7 @@ void SceneGraphNode::attachChild(std::unique_ptr child) { childRaw->setScene(_scene); } -std::unique_ptr SceneGraphNode::detachChild(SceneGraphNode& child) { +ghoul::mm_unique_ptr SceneGraphNode::detachChild(SceneGraphNode& child) { ghoul_assert( child._dependentNodes.empty(), "Nodes cannot depend on a node being detached" @@ -575,7 +543,7 @@ std::unique_ptr SceneGraphNode::detachChild(SceneGraphNode& chil const auto iter = std::find_if( _children.begin(), _children.end(), - [&child] (const std::unique_ptr& c) { + [&child] (const ghoul::mm_unique_ptr& c) { return &child == c.get(); } ); @@ -595,7 +563,7 @@ std::unique_ptr SceneGraphNode::detachChild(SceneGraphNode& chil // Remove link between parent and child child._parent = nullptr; - std::unique_ptr c = std::move(*iter); + ghoul::mm_unique_ptr c = std::move(*iter); _children.erase(iter); return c; @@ -605,7 +573,7 @@ void SceneGraphNode::clearChildren() { traversePreOrder([](SceneGraphNode* node) { node->clearDependencies(); }); - for (const std::unique_ptr& c : _children) { + for (const ghoul::mm_unique_ptr& c : _children) { if (_scene) { c->setScene(nullptr); } @@ -898,22 +866,14 @@ void SceneGraphNode::setScene(Scene* scene) { std::vector SceneGraphNode::children() const { std::vector nodes; - for (const std::unique_ptr& child : _children) { + for (const ghoul::mm_unique_ptr& child : _children) { nodes.push_back(child.get()); } return nodes; } float SceneGraphNode::boundingSphere() const { - if (_renderable) { - return _renderable->boundingSphere(); - } - return _fixedBoundingSphere; -} - -// renderable -void SceneGraphNode::setRenderable(std::unique_ptr renderable) { - _renderable = std::move(renderable); + return _boundingSphere; } const Renderable* SceneGraphNode::renderable() const { @@ -929,7 +889,7 @@ SceneGraphNode* SceneGraphNode::childNode(const std::string& id) { return this; } else { - for (std::unique_ptr& it : _children) { + for (ghoul::mm_unique_ptr& it : _children) { SceneGraphNode* tmp = it->childNode(id); if (tmp) { return tmp; @@ -939,8 +899,4 @@ SceneGraphNode* SceneGraphNode::childNode(const std::string& id) { return nullptr; } -const SceneGraphNode::PerformanceRecord& SceneGraphNode::performanceRecord() const { - return _performanceRecord; -} - } // namespace openspace diff --git a/src/scene/timeframe.cpp b/src/scene/timeframe.cpp index 5ac45d5d65..ce01f44227 100644 --- a/src/scene/timeframe.cpp +++ b/src/scene/timeframe.cpp @@ -26,7 +26,9 @@ #include #include +#include #include +#include #include #include #include @@ -58,7 +60,7 @@ documentation::Documentation TimeFrame::Documentation() { }; } -std::unique_ptr TimeFrame::createFromDictionary( +ghoul::mm_unique_ptr TimeFrame::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "TimeFrame"); @@ -66,9 +68,13 @@ std::unique_ptr TimeFrame::createFromDictionary( const std::string timeFrameType = dictionary.value(KeyType); auto factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(timeFrameType, dictionary); + TimeFrame* result = factory->create( + timeFrameType, + dictionary/*, + &global::memoryManager.PersistentMemory*/ + ); result->setIdentifier("TimeFrame"); - return result; + return ghoul::mm_unique_ptr(result); } TimeFrame::TimeFrame() : properties::PropertyOwner({ "TimeFrame" }) {} diff --git a/src/scene/translation.cpp b/src/scene/translation.cpp index 3e95735a8b..44fea72bfc 100644 --- a/src/scene/translation.cpp +++ b/src/scene/translation.cpp @@ -25,9 +25,10 @@ #include #include +#include #include +#include #include - #include #include #include @@ -58,7 +59,7 @@ documentation::Documentation Translation::Documentation() { }; } -std::unique_ptr Translation::createFromDictionary( +ghoul::mm_unique_ptr Translation::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Translation"); @@ -66,9 +67,13 @@ std::unique_ptr Translation::createFromDictionary( const std::string& translationType = dictionary.value(KeyType); ghoul::TemplateFactory* factory = FactoryManager::ref().factory(); - std::unique_ptr result = factory->create(translationType, dictionary); + Translation* result = factory->create( + translationType, + dictionary, + &global::memoryManager.PersistentMemory + ); result->setIdentifier("Translation"); - return result; + return ghoul::mm_unique_ptr(result); } Translation::Translation() : properties::PropertyOwner({ "Translation" }) {} diff --git a/src/util/resourcesynchronization.cpp b/src/util/resourcesynchronization.cpp index 7199b7a82a..0af28f3c18 100644 --- a/src/util/resourcesynchronization.cpp +++ b/src/util/resourcesynchronization.cpp @@ -78,7 +78,8 @@ std::unique_ptr ResourceSynchronization::createFromDict auto factory = FactoryManager::ref().factory(); ghoul_assert(factory, "ResourceSynchronization factory did not exist"); - return factory->create(synchronizationType, dictionary); + ResourceSynchronization* sync = factory->create(synchronizationType, dictionary); + return std::unique_ptr(sync); } ResourceSynchronization::ResourceSynchronization(const ghoul::Dictionary& dictionary) { diff --git a/src/util/screenlog.cpp b/src/util/screenlog.cpp index c5ff3f67e2..6733f0a8b3 100644 --- a/src/util/screenlog.cpp +++ b/src/util/screenlog.cpp @@ -48,15 +48,15 @@ void ScreenLog::removeExpiredEntries() { _entries.erase(rit, _entries.end() ); } -void ScreenLog::log(LogLevel level, const string& category, const string& message) { +void ScreenLog::log(LogLevel level, std::string_view category, std::string_view message) { std::lock_guard guard(_mutex); if (level >= _logLevel) { _entries.push_back({ level, std::chrono::steady_clock::now(), Log::timeString(), - category, - message + static_cast(category), + static_cast(message) }); } } diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 618f432e03..f7b940bc5b 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "SpiceUsr.h" #include "SpiceZpr.h" @@ -45,23 +46,12 @@ namespace { // This method checks if one of the previous SPICE methods has failed. If it has, an // exception with the SPICE error message is thrown // If an error occurred, true is returned, otherwise, false - bool throwOnSpiceError(const std::string& errorMessage) { - SpiceBoolean failed = failed_c(); + void throwSpiceError(const std::string& errorMessage) { if (openspace::SpiceManager::ref().exceptionHandling()) { - if (failed) { - char buffer[SpiceErrorBufferSize]; - getmsg_c("LONG", SpiceErrorBufferSize, buffer); - reset_c(); - throw openspace::SpiceManager::SpiceException( - errorMessage + ": " + buffer - ); - } - else { - return false; - } - } - else { - return failed; + char buffer[SpiceErrorBufferSize]; + getmsg_c("LONG", SpiceErrorBufferSize, buffer); + reset_c(); + throw openspace::SpiceManager::SpiceException(errorMessage + ": " + buffer); } } @@ -82,7 +72,7 @@ namespace { default: throw ghoul::MissingCaseException(); } } -} +} // namespace #include "spicemanager_lua.inl" @@ -250,7 +240,9 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) { // Reset the current directory to the previous one FileSys.setCurrentDirectory(currentDirectory); - throwOnSpiceError("Kernel loading"); + if (failed_c()) { + throwSpiceError("Kernel loading"); + } std::string fileExtension = ghoul::filesystem::File( path, @@ -426,7 +418,11 @@ void getValueInternal(const std::string& body, const std::string& value, int siz SpiceInt n; bodvrd_c(body.c_str(), value.c_str(), size, &n, v); - throwOnSpiceError(fmt::format("Error getting value '{}' for body '{}'", value, body)); + if (failed_c()) { + throwSpiceError( + fmt::format("Error getting value '{}' for body '{}'", value, body) + ); + } } void SpiceManager::getValue(const std::string& body, const std::string& value, @@ -467,9 +463,11 @@ double SpiceManager::spacecraftClockToET(const std::string& craft, double craftT int craftId = naifId(craft); double et; sct2e_c(craftId, craftTicks, &et); - throwOnSpiceError(fmt::format( - "Error transforming spacecraft clock of '{}' at time {}", craft, craftTicks - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error transforming spacecraft clock of '{}' at time {}", craft, craftTicks + )); + } return et; } @@ -478,7 +476,9 @@ double SpiceManager::ephemerisTimeFromDate(const std::string& timeString) const double et; str2et_c(timeString.c_str(), &et); - throwOnSpiceError(fmt::format("Error converting date '{}'", timeString)); + if (failed_c()) { + throwSpiceError(fmt::format("Error converting date '{}'", timeString)); + } return et; } @@ -490,11 +490,13 @@ std::string SpiceManager::dateFromEphemerisTime(double ephemerisTime, constexpr const int BufferSize = 256; SpiceChar buffer[BufferSize]; timout_c(ephemerisTime, formatString.c_str(), BufferSize - 1, buffer); - throwOnSpiceError( - fmt::format("Error converting ephemeris time '{}' to date with format '{}'", - ephemerisTime, formatString - ) - ); + if (failed_c()) { + throwSpiceError( + fmt::format("Error converting ephemeris time '{}' to date with format '{}'", + ephemerisTime, formatString + ) + ); + } return std::string(buffer); } @@ -535,10 +537,12 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target, glm::value_ptr(position), &lightTime ); - throwOnSpiceError(fmt::format( - "Error getting position from '{}' to '{}' in reference frame '{}' at time {}", - target, observer, referenceFrame, ephemerisTime - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error getting position from '{}' to '{}' in frame '{}' at time {}", + target, observer, referenceFrame, ephemerisTime + )); + } return position; } else if (targetHasCoverage) { @@ -598,11 +602,13 @@ glm::dmat3 SpiceManager::frameTransformationMatrix(const std::string& from, reinterpret_cast(glm::value_ptr(transform)) ); - throwOnSpiceError( - fmt::format("Error converting from frame '{}' to frame '{}' at time '{}'", - from, to, ephemerisTime - ) - ); + if (failed_c()) { + throwSpiceError( + fmt::format("Error converting from frame '{}' to frame '{}' at time '{}'", + from, to, ephemerisTime + ) + ); + } // The rox-major, column-major order are switched in GLM and SPICE, so we have to // transpose the matrix before we can return it @@ -645,11 +651,13 @@ SpiceManager::SurfaceInterceptResult SpiceManager::surfaceIntercept( ); result.interceptFound = (found == SPICETRUE); - throwOnSpiceError(fmt::format( - "Error retrieving surface intercept on target '{}' viewed from observer '{}' in " - "reference frame '{}' at time '{}'", - target, observer, referenceFrame, ephemerisTime - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error retrieving surface intercept on target '{}' viewed from observer '{}' " + "in reference frame '{}' at time '{}'", + target, observer, referenceFrame, ephemerisTime + )); + } return result; } @@ -679,10 +687,12 @@ bool SpiceManager::isTargetInFieldOfView(const std::string& target, &visible ); - throwOnSpiceError(fmt::format( - "Checking if target '{}' is in view of instrument '{}' failed", - target, instrument - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Checking if target '{}' is in view of instrument '{}' failed", + target, instrument + )); + } return visible == SPICETRUE; } @@ -712,11 +722,13 @@ SpiceManager::TargetStateResult SpiceManager::targetState(const std::string& tar &result.lightTime ); - throwOnSpiceError(fmt::format( - "Error retrieving state of target '{}' viewed from observer '{}' in reference " - "frame '{}' at time '{}'", - target, observer, referenceFrame, ephemerisTime - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error retrieving state of target '{}' viewed from observer '{}' in " + "reference frame '{}' at time '{}'", + target, observer, referenceFrame, ephemerisTime + )); + } memmove(glm::value_ptr(result.position), buffer, sizeof(double) * 3); memmove(glm::value_ptr(result.velocity), buffer + 3, sizeof(double) * 3); @@ -738,11 +750,13 @@ SpiceManager::TransformMatrix SpiceManager::stateTransformMatrix( ephemerisTime, reinterpret_cast(m.data()) ); - throwOnSpiceError(fmt::format( - "Error retrieved state transform matrix from frame '{}' to frame '{}' at time " - "'{}'", - sourceFrame, destinationFrame, ephemerisTime - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error retrieved state transform matrix from frame '{}' to frame '{}' at " + "time '{}'", + sourceFrame, destinationFrame, ephemerisTime + )); + } return m; } @@ -761,7 +775,9 @@ glm::dmat3 SpiceManager::positionTransformMatrix(const std::string& sourceFrame, reinterpret_cast(glm::value_ptr(result)) ); - throwOnSpiceError(""); + if (failed_c()) { + throwSpiceError(""); + } SpiceBoolean success = !(failed_c()); reset_c(); if (!success) { @@ -792,11 +808,13 @@ glm::dmat3 SpiceManager::positionTransformMatrix(const std::string& sourceFrame, ephemerisTimeTo, reinterpret_cast(glm::value_ptr(result)) ); - throwOnSpiceError(fmt::format( - "Error retrieving position transform matrix from '{}' at time '{}' to frame '{}' " - "at time '{}'", - sourceFrame, ephemerisTimeFrom, destinationFrame, ephemerisTimeTo - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error retrieving position transform matrix from '{}' at time '{}' to frame " + "'{}' at time '{}'", + sourceFrame, ephemerisTimeFrom, destinationFrame, ephemerisTimeTo + )); + } return glm::transpose(result); } @@ -828,10 +846,10 @@ SpiceManager::FieldOfViewResult SpiceManager::fieldOfView(int instrument) const boundsArr // the bounds ); - bool failed = throwOnSpiceError(fmt::format( - "Error getting field-of-view parameters for instrument '{}'", instrument - )); - if (failed) { + if (failed_c()) { + throwSpiceError(fmt::format( + "Error getting field-of-view parameters for instrument '{}'", instrument + )); return res; } @@ -887,11 +905,13 @@ SpiceManager::TerminatorEllipseResult SpiceManager::terminatorEllipse( glm::value_ptr(res.observerPosition), reinterpret_cast(res.terminatorPoints.data()) ); - throwOnSpiceError(fmt::format( - "Error getting terminator ellipse for target '{}' from observer '{}' in frame " - "'{}' with light source '{}' at time '{}'", - target, observer, frame, lightSource, ephemerisTime - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error getting terminator ellipse for target '{}' from observer '{}' in " + "frame '{}' with light source '{}' at time '{}'", + target, observer, frame, lightSource, ephemerisTime + )); + } return res; } @@ -914,7 +934,9 @@ void SpiceManager::findCkCoverage(const std::string& path) { SPICEDOUBLE_CELL(cover, WinSiz); ckobj_c(path.c_str(), &ids); - throwOnSpiceError("Error finding Ck Coverage"); + if (failed_c()) { + throwSpiceError("Error finding Ck Coverage"); + } for (SpiceInt i = 0; i < card_c(&ids); ++i) { const SpiceInt frame = SPICE_CELL_ELEM_I(&ids, i); // NOLINT @@ -927,7 +949,9 @@ void SpiceManager::findCkCoverage(const std::string& path) { scard_c(0, &cover); ckcov_c(path.c_str(), frame, SPICEFALSE, "SEGMENT", 0.0, "TDB", &cover); - throwOnSpiceError("Error finding Ck Coverage"); + if (failed_c()) { + throwSpiceError("Error finding Ck Coverage"); + } // Get the number of intervals in the coverage window. const SpiceInt numberOfIntervals = wncard_c(&cover); @@ -936,7 +960,9 @@ void SpiceManager::findCkCoverage(const std::string& path) { // Get the endpoints of the jth interval. SpiceDouble b, e; wnfetd_c(&cover, j, &b, &e); - throwOnSpiceError("Error finding Ck Coverage"); + if (failed_c()) { + throwSpiceError("Error finding Ck Coverage"); + } _ckCoverageTimes[frame].insert(e); _ckCoverageTimes[frame].insert(b); @@ -964,7 +990,9 @@ void SpiceManager::findSpkCoverage(const std::string& path) { SPICEDOUBLE_CELL(cover, WinSiz); spkobj_c(path.c_str(), &ids); - throwOnSpiceError("Error finding Spk ID for coverage"); + if (failed_c()) { + throwSpiceError("Error finding Spk ID for coverage"); + } for (SpiceInt i = 0; i < card_c(&ids); ++i) { const SpiceInt obj = SPICE_CELL_ELEM_I(&ids, i); // NOLINT @@ -977,7 +1005,9 @@ void SpiceManager::findSpkCoverage(const std::string& path) { scard_c(0, &cover); spkcov_c(path.c_str(), obj, &cover); - throwOnSpiceError("Error finding Spk coverage"); + if (failed_c()) { + throwSpiceError("Error finding Spk coverage"); + } // Get the number of intervals in the coverage window. const SpiceInt numberOfIntervals = wncard_c(&cover); @@ -986,7 +1016,9 @@ void SpiceManager::findSpkCoverage(const std::string& path) { //Get the endpoints of the jth interval. SpiceDouble b, e; wnfetd_c(&cover, j, &b, &e); - throwOnSpiceError("Error finding Spk coverage"); + if (failed_c()) { + throwSpiceError("Error finding Spk coverage"); + } // insert all into coverage time set, the windows could be merged @AA _spkCoverageTimes[obj].insert(e); @@ -1003,6 +1035,8 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target, double ephemerisTime, double& lightTime) const { + ZoneScoped + ghoul_assert(!target.empty(), "Target must not be empty"); ghoul_assert(!observer.empty(), "Observer must not be empty"); ghoul_assert(!referenceFrame.empty(), "Reference frame must not be empty"); @@ -1039,10 +1073,13 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target, glm::value_ptr(pos), &lightTime ); - throwOnSpiceError(fmt::format( - "Error estimating position for target '{}' with observer '{}' in frame '{}'", - target, observer, referenceFrame - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error estimating position for '{}' with observer '{}' in frame '{}'", + target, observer, referenceFrame + )); + } + } else if (coveredTimes.upper_bound(ephemerisTime) == coveredTimes.end()) { // coverage earlier, fetch last position @@ -1055,10 +1092,12 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target, glm::value_ptr(pos), &lightTime ); - throwOnSpiceError(fmt::format( - "Error estimating position for target '{}' with observer '{}' in frame '{}'", - target, observer, referenceFrame - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error estimating position for '{}' with observer '{}' in frame '{}'", + target, observer, referenceFrame + )); + } } else { // coverage both earlier and later, interpolate these positions @@ -1088,10 +1127,12 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target, <Later ); - throwOnSpiceError(fmt::format( - "Error estimating position for target '{}' with observer '{}' in frame '{}'", - target, observer, referenceFrame - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error estimating position for '{}' with observer '{}' in frame '{}'", + target, observer, referenceFrame + )); + } // linear interpolation const double t = (ephemerisTime - timeEarlier) / (timeLater - timeEarlier); @@ -1132,10 +1173,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram *(coveredTimes.begin()), reinterpret_cast(glm::value_ptr(result)) ); - throwOnSpiceError(fmt::format( - "Error estimating transform matrix from frame '{}' to from '{}' at time '{}'", - fromFrame, toFrame, time - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error estimating transform matrix from '{}' to from '{}' at time '{}'", + fromFrame, toFrame, time + )); + } } else if (coveredTimes.upper_bound(time) == coveredTimes.end()) { // coverage earlier, fetch last transform @@ -1145,10 +1188,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram *(coveredTimes.rbegin()), reinterpret_cast(glm::value_ptr(result)) ); - throwOnSpiceError(fmt::format( - "Error estimating transform matrix from frame '{}' to from '{}' at time '{}'", - fromFrame, toFrame, time - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error estimating transform matrix from frame '{}' to '{}' at time '{}'", + fromFrame, toFrame, time + )); + } } else { // coverage both earlier and later, interpolate these transformations @@ -1162,10 +1207,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram earlier, reinterpret_cast(glm::value_ptr(earlierTransform)) ); - throwOnSpiceError(fmt::format( - "Error estimating transform matrix from frame '{}' to from '{}' at time '{}'", - fromFrame, toFrame, time - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error estimating transform matrix from frame '{}' to '{}' at time '{}'", + fromFrame, toFrame, time + )); + } glm::dmat3 laterTransform = glm::dmat3(1.0); pxform_c( @@ -1174,10 +1221,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram later, reinterpret_cast(glm::value_ptr(laterTransform)) ); - throwOnSpiceError(fmt::format( - "Error estimating transform matrix from frame '{}' to from '{}' at time '{}'", - fromFrame, toFrame, time - )); + if (failed_c()) { + throwSpiceError(fmt::format( + "Error estimating transform matrix from frame '{}' to '{}' at time '{}'", + fromFrame, toFrame, time + )); + } const double t = (time - earlier) / (later - earlier); result = earlierTransform * (1.0 - t) + laterTransform * t; diff --git a/src/util/task.cpp b/src/util/task.cpp index 81a3bce488..b6de0c29a7 100644 --- a/src/util/task.cpp +++ b/src/util/task.cpp @@ -61,8 +61,8 @@ std::unique_ptr Task::createFromDictionary(const ghoul::Dictionary& dictio std::string taskType = dictionary.value("Type"); auto factory = FactoryManager::ref().factory(); - std::unique_ptr task = factory->create(taskType, dictionary); - return task; + Task* task = factory->create(taskType, dictionary); + return std::unique_ptr(task); } } // namespace openspace diff --git a/src/util/time.cpp b/src/util/time.cpp index 9773a6f43d..819ef4788f 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "time_lua.inl" @@ -79,50 +80,25 @@ std::string Time::UTC() const { std::string Time::ISO8601() const { std::string datetime = SpiceManager::ref().dateFromEphemerisTime(_time); - const std::string& month = datetime.substr(5, 3); + std::string_view month = std::string_view(datetime).substr(5, 3); - std::string MM; - if (month == "JAN") { - MM = "01"; - } - else if (month == "FEB") { - MM = "02"; - } - else if (month == "MAR") { - MM = "03"; - } - else if (month == "APR") { - MM = "04"; - } - else if (month == "MAY") { - MM = "05"; - } - else if (month == "JUN") { - MM = "06"; - } - else if (month == "JUL") { - MM = "07"; - } - else if (month == "AUG") { - MM = "08"; - } - else if (month == "SEP") { - MM = "09"; - } - else if (month == "OCT") { - MM = "10"; - } - else if (month == "NOV") { - MM = "11"; - } - else if (month == "DEC") { - MM = "12"; - } - else { - ghoul_assert(false, "Bad month"); - } + std::string_view mm = [](std::string_view month) { + if (month == "JAN") { return "-01-"; } + else if (month == "FEB") { return "-02-"; } + else if (month == "MAR") { return "-03-"; } + else if (month == "APR") { return "-04-"; } + else if (month == "MAY") { return "-05-"; } + else if (month == "JUN") { return "-06-"; } + else if (month == "JUL") { return "-07-"; } + else if (month == "AUG") { return "-08-"; } + else if (month == "SEP") { return "-09-"; } + else if (month == "OCT") { return "-10-"; } + else if (month == "NOV") { return "-11-"; } + else if (month == "DEC") { return "-12-"; } + else { throw ghoul::MissingCaseException(); } + }(month); - datetime.replace(4, 5, "-" + MM + "-"); + datetime.replace(4, 5, mm); return datetime; } diff --git a/src/util/timemanager.cpp b/src/util/timemanager.cpp index e1ecf58d74..ca95d401fd 100644 --- a/src/util/timemanager.cpp +++ b/src/util/timemanager.cpp @@ -214,6 +214,8 @@ TimeKeyframeData TimeManager::interpolate(double applicationTime) { } void TimeManager::progressTime(double dt) { + ZoneScoped + _integrateFromTime = static_cast(_currentTime); // Frames | 1 2 | // |------------------------------------| From 8aa087843bc020a44dbeb7f034fea1941e47d2cd Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Thu, 20 Aug 2020 16:11:19 -0400 Subject: [PATCH 06/11] Merged master again. --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index 40c28e3d56..d7d95dbc3e 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 40c28e3d56db391fdf87b5821f5005853e88dc6e +Subproject commit d7d95dbc3e5dcadd2f455fea989071ad4c514318 From 11ad1df86376f1980a017a4470e8c57b28d28498 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 24 Aug 2020 13:50:36 -0400 Subject: [PATCH 07/11] Removed personal configuration. --- data/assets/customization/globebrowsing.asset | 1 - 1 file changed, 1 deletion(-) diff --git a/data/assets/customization/globebrowsing.asset b/data/assets/customization/globebrowsing.asset index 95f5c661ac..2401b7e508 100644 --- a/data/assets/customization/globebrowsing.asset +++ b/data/assets/customization/globebrowsing.asset @@ -31,7 +31,6 @@ local vrt_folders = { -- We recommend using this folder for HiRISE openspace.absPath('${BASE}/../OpenSpaceData/Mars/HiRISE'), -- if not and you have a custom path for HiRISE layers, enter it below - '/media/jccosta/Big SSD Data/Pessoal/Work/OpenSpaceData/Mars-Gale-Crater/CTX', }, Moon = { -- Add folders here whose contents will be automatically added to the Moon globe From 2cca45189801dfbbc688e5e19ff2f31883521907 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 25 Aug 2020 13:47:03 +0200 Subject: [PATCH 08/11] Coding style adaptations Adapt to changes in Ghoul --- data/assets/customization/globebrowsing.asset | 1 + ext/ghoul | 2 +- include/openspace/rendering/renderengine.h | 8 ++++++-- include/openspace/util/screenlog.h | 2 +- .../rendering/atmospheredeferredcaster.cpp | 8 ++++---- .../base/rendering/grids/renderableboxgrid.cpp | 6 +++--- modules/base/rendering/grids/renderablegrid.cpp | 4 ++-- .../base/rendering/grids/renderableradialgrid.cpp | 4 ++-- .../rendering/grids/renderablesphericalgrid.cpp | 4 ++-- .../base/rendering/renderablecartesianaxes.cpp | 4 ++-- modules/base/rendering/renderablenodeline.cpp | 4 ++-- modules/base/rendering/screenspaceframebuffer.cpp | 4 ++-- .../rendering/renderablebillboardscloud.cpp | 4 ++-- .../rendering/renderabledumeshes.cpp | 6 +++--- .../rendering/renderableplanescloud.cpp | 4 ++-- modules/galaxy/rendering/renderablegalaxy.cpp | 4 ++-- modules/globebrowsing/src/tileprovider.cpp | 2 +- modules/space/rendering/renderablestars.cpp | 2 +- src/rendering/framebufferrenderer.cpp | 15 +++++++-------- src/rendering/renderengine.cpp | 2 +- 20 files changed, 47 insertions(+), 43 deletions(-) diff --git a/data/assets/customization/globebrowsing.asset b/data/assets/customization/globebrowsing.asset index 2401b7e508..dcff5f418e 100644 --- a/data/assets/customization/globebrowsing.asset +++ b/data/assets/customization/globebrowsing.asset @@ -31,6 +31,7 @@ local vrt_folders = { -- We recommend using this folder for HiRISE openspace.absPath('${BASE}/../OpenSpaceData/Mars/HiRISE'), -- if not and you have a custom path for HiRISE layers, enter it below + '' }, Moon = { -- Add folders here whose contents will be automatically added to the Moon globe diff --git a/ext/ghoul b/ext/ghoul index d7d95dbc3e..f4837e7cf2 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit d7d95dbc3e5dcadd2f455fea989071ad4c514318 +Subproject commit f4837e7cf2ec3166ba82164eb12510b811382ece diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 00db014de8..420491f030 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -35,11 +35,15 @@ #include namespace ghoul { + namespace fontrendering { class Font; } + namespace opengl { + class ProgramObject; + class OpenGLStateCache; + } // namespace opengl + class Dictionary; class SharedMemory; } // ghoul -namespace ghoul::fontrendering { class Font; } -namespace ghoul::opengl { class ProgramObject; class OpenGLStateCache; } namespace openspace { diff --git a/include/openspace/util/screenlog.h b/include/openspace/util/screenlog.h index 1619079830..ed8de1228e 100644 --- a/include/openspace/util/screenlog.h +++ b/include/openspace/util/screenlog.h @@ -29,8 +29,8 @@ #include #include -#include #include +#include namespace openspace { diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index d321ce7a3a..783b70f4b7 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -1194,7 +1194,7 @@ void AtmosphereDeferredcaster::executeCalculations(GLuint quadCalcVAO, } // Restores OpenGL blending state - global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().resetBlendState(); } void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { @@ -1213,9 +1213,9 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { glGetIntegerv(GL_FRAMEBUFFER_BINDING, &defaultFBO); GLint m_viewport[4]; - global::renderEngine.openglStateCache().viewPort(m_viewport); + global::renderEngine.openglStateCache().viewport(m_viewport); - // Creates the FBO for the cFglGetalculations + // Creates the FBO for the calculations GLuint calcFBO; glGenFramebuffers(1, &calcFBO); glBindFramebuffer(GL_FRAMEBUFFER, calcFBO); @@ -1239,7 +1239,7 @@ void AtmosphereDeferredcaster::preCalculateAtmosphereParam() { // Restores system state glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - global::renderEngine.openglStateCache().setViewPortState(m_viewport); + global::renderEngine.openglStateCache().setViewportState(m_viewport); glDeleteBuffers(1, &quadCalcVBO); glDeleteVertexArrays(1, &quadCalcVAO); glDeleteFramebuffers(1, &calcFBO); diff --git a/modules/base/rendering/grids/renderableboxgrid.cpp b/modules/base/rendering/grids/renderableboxgrid.cpp index 6d8feec0c1..672ebc2e6d 100644 --- a/modules/base/rendering/grids/renderableboxgrid.cpp +++ b/modules/base/rendering/grids/renderableboxgrid.cpp @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include #include namespace { @@ -203,8 +203,8 @@ void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setLineState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetLineState(); } void RenderableBoxGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index ca2a9246e1..1bd1617c42 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -219,8 +219,8 @@ void RenderableGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setLineState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetLineState(); } void RenderableGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderableradialgrid.cpp b/modules/base/rendering/grids/renderableradialgrid.cpp index c0df853352..7e94730f67 100644 --- a/modules/base/rendering/grids/renderableradialgrid.cpp +++ b/modules/base/rendering/grids/renderableradialgrid.cpp @@ -282,8 +282,8 @@ void RenderableRadialGrid::render(const RenderData& data, RendererTasks&) { _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setLineState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetLineState(); } void RenderableRadialGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/grids/renderablesphericalgrid.cpp b/modules/base/rendering/grids/renderablesphericalgrid.cpp index 532f77768c..8c537ced91 100644 --- a/modules/base/rendering/grids/renderablesphericalgrid.cpp +++ b/modules/base/rendering/grids/renderablesphericalgrid.cpp @@ -224,8 +224,8 @@ void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ _gridProgram->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setLineState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetLineState(); } void RenderableSphericalGrid::update(const UpdateData&) { diff --git a/modules/base/rendering/renderablecartesianaxes.cpp b/modules/base/rendering/renderablecartesianaxes.cpp index 76f3ce42fa..152fbea5a8 100644 --- a/modules/base/rendering/renderablecartesianaxes.cpp +++ b/modules/base/rendering/renderablecartesianaxes.cpp @@ -247,8 +247,8 @@ void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&){ _program->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setLineState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetLineState(); } } // namespace openspace diff --git a/modules/base/rendering/renderablenodeline.cpp b/modules/base/rendering/renderablenodeline.cpp index a1de634a64..34f579126c 100644 --- a/modules/base/rendering/renderablenodeline.cpp +++ b/modules/base/rendering/renderablenodeline.cpp @@ -304,8 +304,8 @@ void RenderableNodeLine::render(const RenderData& data, RendererTasks&) { // Restore GL State unbindGL(); _program->deactivate(); - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setLineState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetLineState(); } void RenderableNodeLine::validateNodes() { diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index 7c01bdf16c..ab5b8f4620 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -113,14 +113,14 @@ void ScreenSpaceFramebuffer::render() { if (!_renderFunctions.empty()) { GLint viewport[4]; //glGetIntegerv(GL_VIEWPORT, viewport); - global::renderEngine.openglStateCache().viewPort(viewport); + global::renderEngine.openglStateCache().viewport(viewport); glViewport( static_cast(-size.x * xratio), static_cast(-size.y * yratio), static_cast(resolution.x * xratio), static_cast(resolution.y * yratio) ); - global::renderEngine.openglStateCache().setViewPortState(viewport); + global::renderEngine.openglStateCache().setViewportState(viewport); GLint defaultFBO = _framebuffer->getActiveObject(); _framebuffer->activate(); diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 82c2c3d023..97b8834666 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -860,8 +860,8 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, glBindVertexArray(0); _program->deactivate(); - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setDepthState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetDepthState(); } diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index 02995e46d1..38f12c8326 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -424,7 +424,7 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, case Wire: glLineWidth(_lineWidth); glDrawArrays(GL_LINE_STRIP, 0, pair.second.numV); - global::renderEngine.openglStateCache().setLineState(); + global::renderEngine.openglStateCache().resetLineState(); break; case Point: glDrawArrays(GL_POINTS, 0, pair.second.numV); @@ -439,8 +439,8 @@ void RenderableDUMeshes::renderMeshes(const RenderData&, _program->deactivate(); // Restores GL State - global::renderEngine.openglStateCache().setDepthState(); - global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().resetDepthState(); + global::renderEngine.openglStateCache().resetBlendState(); } void RenderableDUMeshes::renderLabels(const RenderData& data, diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index a5525fc346..48cce16a4e 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -585,8 +585,8 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&, _program->deactivate(); // Restores OpenGL Rendering State - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setDepthState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetDepthState(); } void RenderablePlanesCloud::renderLabels(const RenderData& data, diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index fa9e4b6a51..c80a5c4ed2 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -682,8 +682,8 @@ void RenderableGalaxy::renderPoints(const RenderData& data) { _pointsProgram->deactivate(); // Restores OpenGL Rendering State - global::renderEngine.openglStateCache().setBlendState(); - global::renderEngine.openglStateCache().setDepthState(); + global::renderEngine.openglStateCache().resetBlendState(); + global::renderEngine.openglStateCache().resetDepthState(); } void RenderableGalaxy::renderBillboards(const RenderData& data) { diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index 3c0a3240e1..a9969b716a 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -234,7 +234,7 @@ Tile tile(TextTileProvider& t, const TileIndex& tileIndex) { t.fontRenderer->render(*t.font, t.textPosition, t.text, t.textColor); glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO); - global::renderEngine.openglStateCache().setViewPortState(); + global::renderEngine.openglStateCache().resetViewportState(); //glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); tile = Tile{ texture, std::nullopt, Tile::Status::OK }; diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 4fa2a213bd..8ccaf2d100 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -915,7 +915,7 @@ void RenderableStars::renderPSFToTexture() { //glDeleteFramebuffers(1, &convolveFBO); // Restores OpenGL blending state - global::renderEngine.openglStateCache().setBlendState(); + global::renderEngine.openglStateCache().resetBlendState(); } void RenderableStars::render(const RenderData& data, RendererTasks&) { diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index a97ceb4f69..439bf063c3 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -450,7 +450,6 @@ void FramebufferRenderer::initialize() { global::deferredcasterManager.addListener(*this); // Set Default Rendering OpenGL State - glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); glEnablei(GL_BLEND, 0); glDisablei(GL_BLEND, 1); @@ -1124,8 +1123,8 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_defaultFBO); - GLint viewport[4] = {0}; - global::renderEngine.openglStateCache().viewPort(viewport); + GLint viewport[4] = { 0 }; + global::renderEngine.openglStateCache().viewport(viewport); // Set Render Pipeline State global::renderEngine.openglStateCache().setCachedStates(); @@ -1142,7 +1141,7 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac TracyGpuZone("Deferred G-Buffer") GLint vp[4] = {viewport[0], viewport[1], _resolution.x, _resolution.y}; - global::renderEngine.openglStateCache().setViewPortState(vp); + global::renderEngine.openglStateCache().setViewportState(vp); glBindFramebuffer(GL_FRAMEBUFFER, _gBuffers.framebuffer); glDrawBuffers(3, ColorAttachmentArray); @@ -1252,8 +1251,8 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector glBindFramebuffer(GL_FRAMEBUFFER, _exitFramebuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - GLint viewport[4] = {0}; - global::renderEngine.openglStateCache().viewPort(viewport); + GLint viewport[4] = { 0 }; + global::renderEngine.openglStateCache().viewport(viewport); ghoul::opengl::ProgramObject* exitProgram = _exitPrograms[raycaster].get(); if (exitProgram) { @@ -1271,7 +1270,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector static_cast(viewport[2] * s), static_cast(viewport[3] * s) }; - global::renderEngine.openglStateCache().setViewPortState(newVP); + global::renderEngine.openglStateCache().setViewportState(newVP); if (_downscaleVolumeRendering.currentDownscaleFactor != s) { _downscaleVolumeRendering.currentDownscaleFactor = s; @@ -1368,7 +1367,7 @@ void FramebufferRenderer::performRaycasterTasks(const std::vector } if (raycaster->downscaleRender() < 1.f) { - global::renderEngine.openglStateCache().setViewPortState(viewport); + global::renderEngine.openglStateCache().setViewportState(viewport); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, _gBuffers.framebuffer); writeDownscaledVolume(); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 4653c618a9..3cecff94a0 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -919,7 +919,7 @@ RenderEngine::RendererImplementation RenderEngine::rendererImplementation() cons ghoul::opengl::OpenGLStateCache& RenderEngine::openglStateCache() { if (_openglStateCache == nullptr) { - _openglStateCache = ghoul::opengl::OpenGLStateCache::getInstance(); + _openglStateCache = ghoul::opengl::OpenGLStateCache::instance(); } return *_openglStateCache; } From 313e1801a866b3f14df5eb36ae2146c35b11523a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 25 Aug 2020 13:53:26 +0200 Subject: [PATCH 09/11] Update Ghoul repository --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index f4837e7cf2..8af1b3a19c 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit f4837e7cf2ec3166ba82164eb12510b811382ece +Subproject commit 8af1b3a19c5d001ae0e1039c460bd42c6f3b78a2 From 463bb6b86894c899322f5420cbc0a1b78f6ea205 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 4 Sep 2020 14:03:22 +0200 Subject: [PATCH 10/11] Update ghoul repository --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index d18c7bb1fb..44420f45cb 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit d18c7bb1fb9ad05421f0b9ed7022ab0c214407ae +Subproject commit 44420f45cba1738847046b70b29b25e28c3284ef From 13a62a5f79c34722a1fc41fdb1738e264790a863 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 4 Sep 2020 16:19:39 +0200 Subject: [PATCH 11/11] Missing commit --- src/rendering/framebufferrenderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index f6ef01d54b..bb8cf2e839 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -1149,8 +1149,8 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac GLint viewport[4] = { 0 }; global::renderEngine.openglStateCache().viewport(viewport); - // Set Render Pipeline State - global::renderEngine.openglStateCache().setCachedStates(); + // Reset Render Pipeline State + global::renderEngine.openglStateCache().resetCachedStates(); _pingPongIndex = 0;