From 8cc5250df8e2e52b15807bcf09868756ae5f4fd3 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Fri, 26 Jan 2018 11:07:22 +0100 Subject: [PATCH 001/131] Automatically compute reasonable aspect ratio (#457) Automatically compute reasonable aspect ratio in sgct lua helper --- scripts/configuration_helper.lua | 80 ++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/scripts/configuration_helper.lua b/scripts/configuration_helper.lua index 0c339505d6..a0767db7ab 100644 --- a/scripts/configuration_helper.lua +++ b/scripts/configuration_helper.lua @@ -360,15 +360,6 @@ end function generateSingleWindowConfig(arg) -- First some type checking - assert( - type(arg[1]) == "number" or type(arg[1]) == "nil", - "First argument must be a number or nil" - ) - assert( - type(arg[2]) == "number" or type(arg[2]) == "nil", - "Second argument must be a number or nil" - ) - assert( type(arg["res"]) == "table" or type(arg["res"]) == "nil", "res must be a table or nil" @@ -400,10 +391,6 @@ function generateSingleWindowConfig(arg) if (type(arg["windowSize"]) == "table") then assert(type(arg["windowSize"][1]) == "number", "windowPos[1] must be a number") assert(type(arg["windowSize"][2]) == "number", "windowPos[2] must be a number") - assert( - type(arg[1]) == "nil" and type(arg[2]) == "nil", - "Only windowSize or the first and second arguments can be set. Not both" - ) end assert( @@ -594,9 +581,7 @@ function generateSingleWindowConfig(arg) end if not arg["windowSize"] then - arg["windowSize"] = {} - arg["windowSize"][1] = arg[1] or 1280 - arg["windowSize"][2] = arg[2] or 720 + arg["windowSize"] = {1280, 720} end arg["scene"] = generateScene(arg) @@ -609,6 +594,35 @@ function generateSingleWindowConfig(arg) end +function normalizeArg(arg) + arg = arg or {} + + if (type(arg["windowSize"]) == "table") then + assert( + type(arg[1]) == "nil" and type(arg[2]) == "nil", + "Only windowSize or the first and second arguments can be set. Not both" + ) + end + assert( + type(arg[1]) == "number" or type(arg[1]) == "nil", + "First argument must be a number or nil" + ) + assert( + type(arg[2]) == "number" or type(arg[2]) == "nil", + "Second argument must be a number or nil" + ) + if (type(arg[1]) == "number") then + if (type(arg[2]) == "nil") then + arg[2] = arg[1] * 9/16 + end + arg["windowSize"] = { arg[1], arg[2] } + arg[1] = nil + arg[2] = nil + end + + return arg +end + function sgct.makeConfig(config) local configFile = os.tmpname() @@ -624,7 +638,12 @@ end function sgct.config.single(arg) - arg = arg or {} + arg = normalizeArg(arg) + + assert( + type(arg["windowSize"]) == "table" or type(arg["windowSize"]) == "nil", + "windowSize must be a table or nil" + ) assert( type(arg["fov"]) == "table" or type(arg["fov"]) == "nil", @@ -635,9 +654,32 @@ function sgct.config.single(arg) assert(type(arg["fov"]["right"]) == "number", "fov['right'] must be a number") assert(type(arg["fov"]["up"]) == "number", "fov['up'] must be a number") assert(type(arg["fov"]["down"]) == "number", "fov['down'] must be a number") + else + if (type(arg["windowSize"]) == "table") then + assert(type(arg["windowSize"][1]) == "number", "windowPos[1] must be a number") + assert(type(arg["windowSize"][2]) == "number", "windowPos[2] must be a number") + + local ratio = arg["windowSize"][1] / arg["windowSize"][2] + local horizontalFov = 30 + local verticalFov = 30 + + if (ratio > 1) then + verticalFov = horizontalFov / ratio + else + horizontalFov = verticalFov * ratio + end + + arg["fov"] = { + down = verticalFov, + up = verticalFov, + left = horizontalFov, + right = horizontalFov + } + else + arg["fov"] = { down = 16.875, up = 16.875, left = 30.0, right = 30.0 } + end end - arg["fov"] = arg["fov"] or { down = 16.875, up = 16.875, left = 30.0, right = 30.0 } arg["viewport"] = generateSingleViewportFOV( arg["fov"]["down"], arg["fov"]["up"], @@ -651,7 +693,7 @@ end function sgct.config.fisheye(arg) - arg = arg or {} + arg = normalizeArg(arg) assert( type(arg["fov"]) == "number" or type(arg["fov"]) == "nil", From dfdc906c58a28b49d19d8b4e8c79e413ab5bcc67 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 5 Feb 2018 14:51:58 -0500 Subject: [PATCH 002/131] Temporarily disabled scaleFactor for meshes. --- .../rendering/renderabledumeshes.cpp | 14 +++++++------- .../digitaluniverse/rendering/renderabledumeshes.h | 4 ++-- modules/digitaluniverse/shaders/dumesh_vs.glsl | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index f3f0f15b86..8483131250 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -69,12 +69,12 @@ namespace { "all point." }; - static const openspace::properties::Property::PropertyInfo ScaleFactorInfo = { + /*static const openspace::properties::Property::PropertyInfo ScaleFactorInfo = { "ScaleFactor", "Scale Factor", "This value is used as a multiplicative factor that is applied to the apparent " "size of each point." - }; + };*/ static const openspace::properties::Property::PropertyInfo ColorInfo = { "Color", @@ -179,12 +179,12 @@ documentation::Documentation RenderableDUMeshes::Documentation() { Optional::Yes, TransparencyInfo.description }, - { + /*{ ScaleFactorInfo.identifier, new DoubleVerifier, Optional::Yes, ScaleFactorInfo.description - }, + },*/ { DrawLabelInfo.identifier, new BoolVerifier, @@ -246,7 +246,7 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) , _hasLabel(false) , _labelDataIsDirty(true) , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) - , _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f) + //, _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 64.f) , _textColor( TextColorInfo, glm::vec4(1.0f, 1.0, 1.0f, 1.f), @@ -328,12 +328,12 @@ RenderableDUMeshes::RenderableDUMeshes(const ghoul::Dictionary& dictionary) } addProperty(_alphaValue); - if (dictionary.hasKey(ScaleFactorInfo.identifier)) { + /*if (dictionary.hasKey(ScaleFactorInfo.identifier)) { _scaleFactor = static_cast( dictionary.value(ScaleFactorInfo.identifier) ); } - addProperty(_scaleFactor); + addProperty(_scaleFactor);*/ if (dictionary.hasKey(DrawLabelInfo.identifier)) { _drawLabels = dictionary.value(DrawLabelInfo.identifier); diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index 61de6221b2..4610da81ba 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -126,7 +126,7 @@ private: bool _labelDataIsDirty; properties::FloatProperty _alphaValue; - properties::FloatProperty _scaleFactor; + //properties::FloatProperty _scaleFactor; //properties::Vec3Property _pointColor; properties::Vec4Property _textColor; properties::FloatProperty _textSize; @@ -141,7 +141,7 @@ private: std::unique_ptr _program; UniformCache(modelViewTransform, projectionTransform, alphaValue, - scaleFactor, color) _uniformCache; + /*scaleFactor,*/ color) _uniformCache; std::unique_ptr _fontRenderer; std::shared_ptr _font; diff --git a/modules/digitaluniverse/shaders/dumesh_vs.glsl b/modules/digitaluniverse/shaders/dumesh_vs.glsl index 912dadc826..8cebedd32a 100644 --- a/modules/digitaluniverse/shaders/dumesh_vs.glsl +++ b/modules/digitaluniverse/shaders/dumesh_vs.glsl @@ -30,7 +30,6 @@ in vec3 in_position; uniform dmat4 modelViewTransform; uniform dmat4 projectionTransform; -uniform float scaleFactor; out float vs_screenSpaceDepth; out vec4 vs_positionViewSpace; From 9667b6eac5064572bc63096496a30ec4780c6874 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 5 Feb 2018 15:13:34 -0500 Subject: [PATCH 003/131] Removed unused uniforms and renamed shader files. --- .../rendering/renderablebillboardscloud.cpp | 18 +- .../rendering/renderablebillboardscloud.h | 2 +- .../shaders/billboard2_gs.glsl | 191 ----------------- .../digitaluniverse/shaders/billboard_fs.glsl | 51 +++-- .../digitaluniverse/shaders/billboard_gs.glsl | 198 +++++++++++++----- ...llboard2_fs.glsl => billboard_old_fs.glsl} | 49 ++--- .../shaders/billboard_old_gs.glsl | 97 +++++++++ ...llboard2_vs.glsl => billboard_old_vs.glsl} | 22 +- .../digitaluniverse/shaders/billboard_vs.glsl | 22 +- 9 files changed, 320 insertions(+), 330 deletions(-) delete mode 100644 modules/digitaluniverse/shaders/billboard2_gs.glsl rename modules/digitaluniverse/shaders/{billboard2_fs.glsl => billboard_old_fs.glsl} (75%) create mode 100644 modules/digitaluniverse/shaders/billboard_old_gs.glsl rename modules/digitaluniverse/shaders/{billboard2_vs.glsl => billboard_old_vs.glsl} (79%) diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 783e7e2ed6..fefd27f5bb 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -627,13 +627,11 @@ void RenderableBillboardsCloud::initializeGL() { _program = renderEngine.buildRenderProgram( "RenderableBillboardsCloud", - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_vs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_fs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_gs.glsl") + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_fs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_gs.glsl") ); - //_uniformCache.projection = _program->uniformLocation("projection"); - //_uniformCache.modelView = _program->uniformLocation("modelViewTransform"); _uniformCache.modelViewProjection = _program->uniformLocation( "modelViewProjectionTransform" ); @@ -646,7 +644,6 @@ void RenderableBillboardsCloud::initializeGL() { _uniformCache.minBillboardSize = _program->uniformLocation("minBillboardSize"); _uniformCache.maxBillboardSize = _program->uniformLocation("maxBillboardSize"); _uniformCache.color = _program->uniformLocation("color"); - //_uniformCache.sides = _program->uniformLocation("sides"); _uniformCache.alphaValue = _program->uniformLocation("alphaValue"); _uniformCache.scaleFactor = _program->uniformLocation("scaleFactor"); _uniformCache.up = _program->uniformLocation("up"); @@ -736,8 +733,7 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, "screenSize", glm::vec2(OsEng.renderEngine().renderingResolution()) ); - //_program->setUniform(_uniformCache.projection, projMatrix); - //_program->setUniform(_uniformCache.modelView, modelViewMatrix); + _program->setUniform(_uniformCache.modelViewProjection, projMatrix * modelViewMatrix); _program->setUniform( _uniformCache.cameraPos, @@ -750,10 +746,6 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, ) ); - //_program->setUniform("cameraPosition", data.camera.positionVec3()); - //_program->setUniform("cameraLookUp", data.camera.lookUpVectorWorldSpace()); - - _program->setUniform(_uniformCache.renderOption, _renderOption.value()); glm::dvec4 centerScreenWorld = glm::inverse(data.camera.combinedViewMatrix()) * glm::dvec4(0.0, 0.0, 0.0, 1.0); @@ -763,7 +755,6 @@ void RenderableBillboardsCloud::renderBillboards(const RenderData& data, _program->setUniform(_uniformCache.minBillboardSize, _billboardMinSize); // in pixels _program->setUniform(_uniformCache.maxBillboardSize, _billboardMaxSize); // in pixels _program->setUniform(_uniformCache.color, _pointColor); - //_program->setUniform(_uniformCache.sides, 4); _program->setUniform(_uniformCache.alphaValue, _alphaValue); _program->setUniform(_uniformCache.scaleFactor, _scaleFactor); @@ -934,7 +925,6 @@ void RenderableBillboardsCloud::render(const RenderData& data, RendererTasks&) { glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale)); glm::dmat4 modelViewMatrix = data.camera.combinedViewMatrix() * modelMatrix; - // glm::mat4 viewMatrix = data.camera.viewMatrix(); glm::mat4 projectionMatrix = data.camera.projectionMatrix(); glm::dmat4 modelViewProjectionMatrix = glm::dmat4(projectionMatrix) * diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.h b/modules/digitaluniverse/rendering/renderablebillboardscloud.h index 64c0e1fca4..e7979ec440 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.h +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.h @@ -142,7 +142,7 @@ private: std::unique_ptr _spriteTexture; std::unique_ptr _spriteTextureFile; std::unique_ptr _program; - UniformCache(projection, modelView, modelViewProjection, cameraPos, cameraLookup, + UniformCache(modelViewProjection, cameraPos, cameraLookup, renderOption, centerSceenInWorldPos, minBillboardSize, maxBillboardSize, color, sides, alphaValue, scaleFactor, up, right, fadeInValue, screenSize, spriteTexture, polygonTexture, hasPolygon, hasColormap) _uniformCache; diff --git a/modules/digitaluniverse/shaders/billboard2_gs.glsl b/modules/digitaluniverse/shaders/billboard2_gs.glsl deleted file mode 100644 index af5b7acc9f..0000000000 --- a/modules/digitaluniverse/shaders/billboard2_gs.glsl +++ /dev/null @@ -1,191 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2018 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -#include "PowerScaling/powerScalingMath.hglsl" - -layout(points) in; -layout(triangle_strip, max_vertices = 6) out; - -//uniform dmat4 transformMatrix; -uniform dmat4 modelViewProjectionTransform; -uniform float scaleFactor; -uniform dvec3 up; -uniform dvec3 right; -uniform dvec3 cameraPosition; -uniform dvec3 cameraLookUp; -uniform dvec4 centerScreenInWorldPosition; -uniform int renderOption; -uniform vec2 screenSize; -uniform float maxBillboardSize; -uniform float minBillboardSize; - -in vec4 colorMap[]; - -out vec4 gs_colorMap; -out vec2 texCoord; -out float vs_screenSpaceDepth; -out float ta; - -const double PARSEC = 0.308567756e17LF; - -const vec2 corners[4] = vec2[4]( - vec2(0.0, 0.0), - vec2(1.0, 0.0), - vec2(1.0, 1.0), - vec2(0.0, 1.0) -); - - -void main() { - ta = 1.0f; - vec4 pos = gl_in[0].gl_Position; - gs_colorMap = colorMap[0]; - - double scaleMultiply = exp(scaleFactor/10); - dvec3 scaledRight = dvec3(0.0); - dvec3 scaledUp = dvec3(0.0); - - if (renderOption == 0) { - scaledRight = scaleMultiply * right/2.0f; - scaledUp = scaleMultiply * up/2.0f; - } else if (renderOption == 1) { - dvec3 normal = normalize(cameraPosition - dvec3(pos.xyz)); - dvec3 newRight = normalize(cross(cameraLookUp, normal)); - dvec3 newUp = cross(normal, newRight); - scaledRight = scaleMultiply * newRight/2.0f; - scaledUp = scaleMultiply * newUp/2.0f; - } else if (renderOption == 2) { - dvec3 normal = normalize(centerScreenInWorldPosition.xyz - dvec3(pos.xyz)); - dvec3 newRight = normalize(cross(cameraLookUp, normal)); - dvec3 newUp = cross(normal, newRight); - scaledRight = scaleMultiply * newRight/2.0f; - scaledUp = scaleMultiply * newUp/2.0f; - } - - double unit = PARSEC; - - // Must be the same as the enum in RenderableBillboardsCloud.h - if (pos.w == 1.f) { - unit = 1E3; - } else if (pos.w == 2.f) { - unit = PARSEC; - } else if (pos.w == 3.f) { - unit = 1E3 * PARSEC; - } else if (pos.w == 4.f) { - unit = 1E6 * PARSEC; - } else if (pos.w == 5.f) { - unit = 1E9 * PARSEC; - } else if (pos.w == 6.f) { - unit = 306391534.73091 * PARSEC; - } - - //dvec4 dpos = transformMatrix * dvec4(dvec3(pos.xyz) * unit, 1.0); - dvec4 dpos = dvec4(dvec3(pos.xyz) * unit, 1.0); - - // texCoord = corners[0]; - vec4 initialPosition = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w))); - vs_screenSpaceDepth = initialPosition.w; - - // texCoord = corners[1]; - vec4 secondPosition = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w))); - - //texCoord = corners[2]; - vec4 crossCorner = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w))); - - // texCoord = corners[3]; - vec4 thirdPosition = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w))); - - // Testing size: - vec4 topRight = secondPosition/secondPosition.w; - topRight = ((topRight + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0); - vec4 bottomLeft = initialPosition/initialPosition.w; - bottomLeft = ((bottomLeft + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0); - - float height = abs(topRight.y - bottomLeft.y); - float width = abs(topRight.x - bottomLeft.x); - float var = (height + width); - - if ((height > maxBillboardSize) || - (width > maxBillboardSize)) { - - // Set maximum size as Carter's instructions - float correctionScale = height > maxBillboardSize ? maxBillboardSize / (topRight.y - bottomLeft.y) : - maxBillboardSize / (topRight.x - bottomLeft.x); - - scaledRight = correctionScale * scaleMultiply * right/2.0f; - scaledUp = correctionScale * scaleMultiply * up/2.0f; - initialPosition = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w))); - vs_screenSpaceDepth = initialPosition.w; - secondPosition = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w))); - crossCorner = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w))); - thirdPosition = z_normalization(vec4(modelViewProjectionTransform * - dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w))); - - // Fade-out - // float maxVar = 2.0f * maxBillboardSize; - // float minVar = maxBillboardSize; - // ta = 1.0f - ( (var - minVar)/(maxVar - minVar) ); - // if (ta == 0.0f) - // return; - } - else if (width < 2.0f * minBillboardSize) { - //return; - float maxVar = 2.0f * minBillboardSize; - float minVar = minBillboardSize; - ta = ( (var - minVar)/(maxVar - minVar) ); - if (ta == 0.0f) - return; - } - - // Build primitive - texCoord = corners[0]; - gl_Position = initialPosition; - EmitVertex(); - texCoord = corners[1]; - gl_Position = secondPosition; - EmitVertex(); - texCoord = corners[2]; - gl_Position = crossCorner; - EmitVertex(); - EndPrimitive(); // First Triangle - texCoord = corners[0]; - gl_Position = initialPosition; - EmitVertex(); - texCoord = corners[2]; - gl_Position = crossCorner; - EmitVertex(); - texCoord = corners[3]; - gl_Position = thirdPosition; - EmitVertex(); - EndPrimitive(); // Second Triangle -} diff --git a/modules/digitaluniverse/shaders/billboard_fs.glsl b/modules/digitaluniverse/shaders/billboard_fs.glsl index a705ddcec4..809c628a82 100644 --- a/modules/digitaluniverse/shaders/billboard_fs.glsl +++ b/modules/digitaluniverse/shaders/billboard_fs.glsl @@ -24,41 +24,46 @@ #include "fragment.glsl" -//in vec4 gs_colorMap; -in float gs_screenSpaceDepth; +in vec4 gs_colorMap; +in float vs_screenSpaceDepth; in vec2 texCoord; +in float ta; -//uniform bool hasColorMap; uniform float alphaValue; uniform vec3 color; uniform sampler2D spriteTexture; +uniform sampler2D polygonTexture; +uniform bool hasColorMap; +uniform bool hasPolygon; +uniform float fadeInValue; Fragment getFragment() { vec4 textureColor = texture(spriteTexture, texCoord); - vec4 fullColor = vec4(0.0); - - //if (hasColorMap) { - // fullColor = vec4(gs_colorMap.rgb * textureColor.rgb, textureColor.a); - // } - //else { - fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a); - // } - - //fullColor.a *= alphaValue; - - //if (fullColor.a == 0) { - // discard; - //} - //fullColor = vec4(textureColor.rgb, 1.0); - fullColor = vec4(1.0); + vec4 fullColor = vec4(1.0); + + if (hasColorMap) { + fullColor = vec4(gs_colorMap.rgb * textureColor.rgb, gs_colorMap.a * textureColor.a * alphaValue); + } else if (hasPolygon) { + vec4 polygon = texture(polygonTexture, texCoord); + fullColor = vec4(color.rgb * textureColor.rgb + polygon.rgb, textureColor.a * alphaValue); + } else { + fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a * alphaValue); + } + + fullColor.a *= fadeInValue * ta; + + if (fullColor.a == 0.f) { + discard; + } Fragment frag; - frag.color = fullColor; - frag.depth = gs_screenSpaceDepth; - frag.gPosition = vec4(1e27, 1e27, 1e27, 1.0); + frag.color = fullColor; + frag.depth = vs_screenSpaceDepth; + frag.gPosition = vec4(1e32, 1e32, 1e32, 1.0); frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); - + + return frag; } diff --git a/modules/digitaluniverse/shaders/billboard_gs.glsl b/modules/digitaluniverse/shaders/billboard_gs.glsl index e0ec5486f4..af5b7acc9f 100644 --- a/modules/digitaluniverse/shaders/billboard_gs.glsl +++ b/modules/digitaluniverse/shaders/billboard_gs.glsl @@ -27,71 +27,165 @@ #include "PowerScaling/powerScalingMath.hglsl" layout(points) in; -layout(triangle_strip, max_vertices = 4) out; -//layout(points, max_vertices = 1) out; +layout(triangle_strip, max_vertices = 6) out; -in vec4 orig_position[]; -//in vec4 colorMap[]; -in float vs_screenSpaceDepth[]; - -out vec2 texCoord; -out float billboardSize; -out float gs_screenSpaceDepth; -//out vec4 gs_colorMap; - -uniform mat4 projection; +//uniform dmat4 transformMatrix; +uniform dmat4 modelViewProjectionTransform; uniform float scaleFactor; -uniform float minBillboardSize; +uniform dvec3 up; +uniform dvec3 right; +uniform dvec3 cameraPosition; +uniform dvec3 cameraLookUp; +uniform dvec4 centerScreenInWorldPosition; +uniform int renderOption; uniform vec2 screenSize; +uniform float maxBillboardSize; +uniform float minBillboardSize; + +in vec4 colorMap[]; + +out vec4 gs_colorMap; +out vec2 texCoord; +out float vs_screenSpaceDepth; +out float ta; + +const double PARSEC = 0.308567756e17LF; const vec2 corners[4] = vec2[4]( - vec2(0.0, 1.0), - vec2(0.0, 0.0), - vec2(1.0, 1.0), - vec2(1.0, 0.0) + vec2(0.0, 0.0), + vec2(1.0, 0.0), + vec2(1.0, 1.0), + vec2(0.0, 1.0) ); void main() { - gs_screenSpaceDepth = vs_screenSpaceDepth[0]; - //gs_colorMap = colorMap[0]; + ta = 1.0f; + vec4 pos = gl_in[0].gl_Position; + gs_colorMap = colorMap[0]; + + double scaleMultiply = exp(scaleFactor/10); + dvec3 scaledRight = dvec3(0.0); + dvec3 scaledUp = dvec3(0.0); - // if ((orig_position[0].x == 0.0) && - // (orig_position[0].y == 0.0) && - // (orig_position[0].z == 0.0)) - // { - // return; - // } - - //float modifiedSpriteSize = exp((-30.623 - 0.5) * 1.0) * scaleFactor * 2000; - - float modifiedSpriteSize = - exp((-30.623 - (-5.0)) * 0.462) * 1.0 * 2000; - - vec4 projPos[4]; - for (int i = 0; i < 4; ++i) { - vec4 p1 = gl_in[0].gl_Position; - p1.xy += vec2(modifiedSpriteSize * (corners[i] - vec2(0.5))); - projPos[i] = projection * p1; + if (renderOption == 0) { + scaledRight = scaleMultiply * right/2.0f; + scaledUp = scaleMultiply * up/2.0f; + } else if (renderOption == 1) { + dvec3 normal = normalize(cameraPosition - dvec3(pos.xyz)); + dvec3 newRight = normalize(cross(cameraLookUp, normal)); + dvec3 newUp = cross(normal, newRight); + scaledRight = scaleMultiply * newRight/2.0f; + scaledUp = scaleMultiply * newUp/2.0f; + } else if (renderOption == 2) { + dvec3 normal = normalize(centerScreenInWorldPosition.xyz - dvec3(pos.xyz)); + dvec3 newRight = normalize(cross(cameraLookUp, normal)); + dvec3 newUp = cross(normal, newRight); + scaledRight = scaleMultiply * newRight/2.0f; + scaledUp = scaleMultiply * newUp/2.0f; } - // Calculate the positions of the lower left and upper right corners of the - // billboard in screen-space - vec2 ll = (((projPos[1].xy / projPos[1].w) + 1.0) / 2.0) * screenSize; - vec2 ur = (((projPos[2].xy / projPos[2].w) + 1.0) / 2.0) * screenSize; + double unit = PARSEC; - // The billboard is smaller than one pixel, we can discard it - float sizeInPixels = length(ll - ur); - //if (sizeInPixels < minBillboardSize) { - // return; - //} - - for (int i = 0; i < 4; i++) { - gl_Position = projPos[i]; - texCoord = corners[i]; - billboardSize = sizeInPixels; - EmitVertex(); + // Must be the same as the enum in RenderableBillboardsCloud.h + if (pos.w == 1.f) { + unit = 1E3; + } else if (pos.w == 2.f) { + unit = PARSEC; + } else if (pos.w == 3.f) { + unit = 1E3 * PARSEC; + } else if (pos.w == 4.f) { + unit = 1E6 * PARSEC; + } else if (pos.w == 5.f) { + unit = 1E9 * PARSEC; + } else if (pos.w == 6.f) { + unit = 306391534.73091 * PARSEC; } - EndPrimitive(); + //dvec4 dpos = transformMatrix * dvec4(dvec3(pos.xyz) * unit, 1.0); + dvec4 dpos = dvec4(dvec3(pos.xyz) * unit, 1.0); + + // texCoord = corners[0]; + vec4 initialPosition = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w))); + vs_screenSpaceDepth = initialPosition.w; + + // texCoord = corners[1]; + vec4 secondPosition = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w))); + + //texCoord = corners[2]; + vec4 crossCorner = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w))); + + // texCoord = corners[3]; + vec4 thirdPosition = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w))); + + // Testing size: + vec4 topRight = secondPosition/secondPosition.w; + topRight = ((topRight + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0); + vec4 bottomLeft = initialPosition/initialPosition.w; + bottomLeft = ((bottomLeft + vec4(1.0)) / vec4(2.0)) * vec4(screenSize.x, screenSize.y, 1.0, 1.0); + + float height = abs(topRight.y - bottomLeft.y); + float width = abs(topRight.x - bottomLeft.x); + float var = (height + width); + + if ((height > maxBillboardSize) || + (width > maxBillboardSize)) { + + // Set maximum size as Carter's instructions + float correctionScale = height > maxBillboardSize ? maxBillboardSize / (topRight.y - bottomLeft.y) : + maxBillboardSize / (topRight.x - bottomLeft.x); + + scaledRight = correctionScale * scaleMultiply * right/2.0f; + scaledUp = correctionScale * scaleMultiply * up/2.0f; + initialPosition = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz - scaledRight - scaledUp, dpos.w))); + vs_screenSpaceDepth = initialPosition.w; + secondPosition = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz + scaledRight - scaledUp, dpos.w))); + crossCorner = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz + scaledUp + scaledRight, dpos.w))); + thirdPosition = z_normalization(vec4(modelViewProjectionTransform * + dvec4(dpos.xyz + scaledUp - scaledRight, dpos.w))); + + // Fade-out + // float maxVar = 2.0f * maxBillboardSize; + // float minVar = maxBillboardSize; + // ta = 1.0f - ( (var - minVar)/(maxVar - minVar) ); + // if (ta == 0.0f) + // return; + } + else if (width < 2.0f * minBillboardSize) { + //return; + float maxVar = 2.0f * minBillboardSize; + float minVar = minBillboardSize; + ta = ( (var - minVar)/(maxVar - minVar) ); + if (ta == 0.0f) + return; + } + + // Build primitive + texCoord = corners[0]; + gl_Position = initialPosition; + EmitVertex(); + texCoord = corners[1]; + gl_Position = secondPosition; + EmitVertex(); + texCoord = corners[2]; + gl_Position = crossCorner; + EmitVertex(); + EndPrimitive(); // First Triangle + texCoord = corners[0]; + gl_Position = initialPosition; + EmitVertex(); + texCoord = corners[2]; + gl_Position = crossCorner; + EmitVertex(); + texCoord = corners[3]; + gl_Position = thirdPosition; + EmitVertex(); + EndPrimitive(); // Second Triangle } diff --git a/modules/digitaluniverse/shaders/billboard2_fs.glsl b/modules/digitaluniverse/shaders/billboard_old_fs.glsl similarity index 75% rename from modules/digitaluniverse/shaders/billboard2_fs.glsl rename to modules/digitaluniverse/shaders/billboard_old_fs.glsl index 809c628a82..a705ddcec4 100644 --- a/modules/digitaluniverse/shaders/billboard2_fs.glsl +++ b/modules/digitaluniverse/shaders/billboard_old_fs.glsl @@ -24,46 +24,41 @@ #include "fragment.glsl" -in vec4 gs_colorMap; -in float vs_screenSpaceDepth; +//in vec4 gs_colorMap; +in float gs_screenSpaceDepth; in vec2 texCoord; -in float ta; +//uniform bool hasColorMap; uniform float alphaValue; uniform vec3 color; uniform sampler2D spriteTexture; -uniform sampler2D polygonTexture; -uniform bool hasColorMap; -uniform bool hasPolygon; -uniform float fadeInValue; Fragment getFragment() { vec4 textureColor = texture(spriteTexture, texCoord); - - vec4 fullColor = vec4(1.0); - - if (hasColorMap) { - fullColor = vec4(gs_colorMap.rgb * textureColor.rgb, gs_colorMap.a * textureColor.a * alphaValue); - } else if (hasPolygon) { - vec4 polygon = texture(polygonTexture, texCoord); - fullColor = vec4(color.rgb * textureColor.rgb + polygon.rgb, textureColor.a * alphaValue); - } else { - fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a * alphaValue); - } + vec4 fullColor = vec4(0.0); - fullColor.a *= fadeInValue * ta; + //if (hasColorMap) { + // fullColor = vec4(gs_colorMap.rgb * textureColor.rgb, textureColor.a); + // } + //else { + fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a); + // } - if (fullColor.a == 0.f) { - discard; - } + //fullColor.a *= alphaValue; + + //if (fullColor.a == 0) { + // discard; + //} + + //fullColor = vec4(textureColor.rgb, 1.0); + fullColor = vec4(1.0); Fragment frag; - frag.color = fullColor; - frag.depth = vs_screenSpaceDepth; - frag.gPosition = vec4(1e32, 1e32, 1e32, 1.0); + frag.color = fullColor; + frag.depth = gs_screenSpaceDepth; + frag.gPosition = vec4(1e27, 1e27, 1e27, 1.0); frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); - - + return frag; } diff --git a/modules/digitaluniverse/shaders/billboard_old_gs.glsl b/modules/digitaluniverse/shaders/billboard_old_gs.glsl new file mode 100644 index 0000000000..e0ec5486f4 --- /dev/null +++ b/modules/digitaluniverse/shaders/billboard_old_gs.glsl @@ -0,0 +1,97 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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. * + ****************************************************************************************/ + +#version __CONTEXT__ + +#include "PowerScaling/powerScalingMath.hglsl" + +layout(points) in; +layout(triangle_strip, max_vertices = 4) out; +//layout(points, max_vertices = 1) out; + +in vec4 orig_position[]; +//in vec4 colorMap[]; +in float vs_screenSpaceDepth[]; + +out vec2 texCoord; +out float billboardSize; +out float gs_screenSpaceDepth; +//out vec4 gs_colorMap; + +uniform mat4 projection; +uniform float scaleFactor; +uniform float minBillboardSize; +uniform vec2 screenSize; + +const vec2 corners[4] = vec2[4]( + vec2(0.0, 1.0), + vec2(0.0, 0.0), + vec2(1.0, 1.0), + vec2(1.0, 0.0) +); + + +void main() { + gs_screenSpaceDepth = vs_screenSpaceDepth[0]; + //gs_colorMap = colorMap[0]; + + // if ((orig_position[0].x == 0.0) && + // (orig_position[0].y == 0.0) && + // (orig_position[0].z == 0.0)) + // { + // return; + // } + + //float modifiedSpriteSize = exp((-30.623 - 0.5) * 1.0) * scaleFactor * 2000; + + float modifiedSpriteSize = + exp((-30.623 - (-5.0)) * 0.462) * 1.0 * 2000; + + vec4 projPos[4]; + for (int i = 0; i < 4; ++i) { + vec4 p1 = gl_in[0].gl_Position; + p1.xy += vec2(modifiedSpriteSize * (corners[i] - vec2(0.5))); + projPos[i] = projection * p1; + } + + // Calculate the positions of the lower left and upper right corners of the + // billboard in screen-space + vec2 ll = (((projPos[1].xy / projPos[1].w) + 1.0) / 2.0) * screenSize; + vec2 ur = (((projPos[2].xy / projPos[2].w) + 1.0) / 2.0) * screenSize; + + // The billboard is smaller than one pixel, we can discard it + float sizeInPixels = length(ll - ur); + //if (sizeInPixels < minBillboardSize) { + // return; + //} + + for (int i = 0; i < 4; i++) { + gl_Position = projPos[i]; + texCoord = corners[i]; + billboardSize = sizeInPixels; + EmitVertex(); + } + + EndPrimitive(); +} diff --git a/modules/digitaluniverse/shaders/billboard2_vs.glsl b/modules/digitaluniverse/shaders/billboard_old_vs.glsl similarity index 79% rename from modules/digitaluniverse/shaders/billboard2_vs.glsl rename to modules/digitaluniverse/shaders/billboard_old_vs.glsl index 8065466a64..1b15e54005 100644 --- a/modules/digitaluniverse/shaders/billboard2_vs.glsl +++ b/modules/digitaluniverse/shaders/billboard_old_vs.glsl @@ -26,12 +26,24 @@ #include "PowerScaling/powerScaling_vs.hglsl" -in vec4 in_position; -in vec4 in_colormap; +in dvec4 in_position; +//in dvec4 in_colormap; -out vec4 colorMap; +uniform dmat4 modelViewTransform; +uniform mat4 projection; + +out float vs_screenSpaceDepth; +out vec4 orig_position; +//out vec4 colorMap; void main() { - colorMap = in_colormap; - gl_Position = vec4(in_position); + orig_position = vec4(in_position); + //colorMap = vec4(in_colormap); + + vec4 positionViewSpace = vec4(modelViewTransform * in_position); + vec4 positionScreenSpace = vec4(z_normalization(projection * positionViewSpace)); + //vec4 positionScreenSpace = vec4(projection * positionViewSpace); + vs_screenSpaceDepth = positionScreenSpace.w; + + gl_Position = positionViewSpace; } \ No newline at end of file diff --git a/modules/digitaluniverse/shaders/billboard_vs.glsl b/modules/digitaluniverse/shaders/billboard_vs.glsl index 1b15e54005..8065466a64 100644 --- a/modules/digitaluniverse/shaders/billboard_vs.glsl +++ b/modules/digitaluniverse/shaders/billboard_vs.glsl @@ -26,24 +26,12 @@ #include "PowerScaling/powerScaling_vs.hglsl" -in dvec4 in_position; -//in dvec4 in_colormap; +in vec4 in_position; +in vec4 in_colormap; -uniform dmat4 modelViewTransform; -uniform mat4 projection; - -out float vs_screenSpaceDepth; -out vec4 orig_position; -//out vec4 colorMap; +out vec4 colorMap; void main() { - orig_position = vec4(in_position); - //colorMap = vec4(in_colormap); - - vec4 positionViewSpace = vec4(modelViewTransform * in_position); - vec4 positionScreenSpace = vec4(z_normalization(projection * positionViewSpace)); - //vec4 positionScreenSpace = vec4(projection * positionViewSpace); - vs_screenSpaceDepth = positionScreenSpace.w; - - gl_Position = positionViewSpace; + colorMap = in_colormap; + gl_Position = vec4(in_position); } \ No newline at end of file From c320abb1bd0a4576824b3049a3a3333a0e127708 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 5 Feb 2018 15:13:52 -0500 Subject: [PATCH 004/131] Removed unused shaders files. --- .../shaders/billboard_old_fs.glsl | 64 ------------ .../shaders/billboard_old_gs.glsl | 97 ------------------- .../shaders/billboard_old_vs.glsl | 49 ---------- 3 files changed, 210 deletions(-) delete mode 100644 modules/digitaluniverse/shaders/billboard_old_fs.glsl delete mode 100644 modules/digitaluniverse/shaders/billboard_old_gs.glsl delete mode 100644 modules/digitaluniverse/shaders/billboard_old_vs.glsl diff --git a/modules/digitaluniverse/shaders/billboard_old_fs.glsl b/modules/digitaluniverse/shaders/billboard_old_fs.glsl deleted file mode 100644 index a705ddcec4..0000000000 --- a/modules/digitaluniverse/shaders/billboard_old_fs.glsl +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2018 * - * * - * 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 "fragment.glsl" - -//in vec4 gs_colorMap; -in float gs_screenSpaceDepth; -in vec2 texCoord; - -//uniform bool hasColorMap; -uniform float alphaValue; -uniform vec3 color; -uniform sampler2D spriteTexture; - -Fragment getFragment() { - - vec4 textureColor = texture(spriteTexture, texCoord); - vec4 fullColor = vec4(0.0); - - //if (hasColorMap) { - // fullColor = vec4(gs_colorMap.rgb * textureColor.rgb, textureColor.a); - // } - //else { - fullColor = vec4(color.rgb * textureColor.rgb, textureColor.a); - // } - - //fullColor.a *= alphaValue; - - //if (fullColor.a == 0) { - // discard; - //} - - //fullColor = vec4(textureColor.rgb, 1.0); - fullColor = vec4(1.0); - - Fragment frag; - frag.color = fullColor; - frag.depth = gs_screenSpaceDepth; - frag.gPosition = vec4(1e27, 1e27, 1e27, 1.0); - frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); - - return frag; -} diff --git a/modules/digitaluniverse/shaders/billboard_old_gs.glsl b/modules/digitaluniverse/shaders/billboard_old_gs.glsl deleted file mode 100644 index e0ec5486f4..0000000000 --- a/modules/digitaluniverse/shaders/billboard_old_gs.glsl +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2018 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -#include "PowerScaling/powerScalingMath.hglsl" - -layout(points) in; -layout(triangle_strip, max_vertices = 4) out; -//layout(points, max_vertices = 1) out; - -in vec4 orig_position[]; -//in vec4 colorMap[]; -in float vs_screenSpaceDepth[]; - -out vec2 texCoord; -out float billboardSize; -out float gs_screenSpaceDepth; -//out vec4 gs_colorMap; - -uniform mat4 projection; -uniform float scaleFactor; -uniform float minBillboardSize; -uniform vec2 screenSize; - -const vec2 corners[4] = vec2[4]( - vec2(0.0, 1.0), - vec2(0.0, 0.0), - vec2(1.0, 1.0), - vec2(1.0, 0.0) -); - - -void main() { - gs_screenSpaceDepth = vs_screenSpaceDepth[0]; - //gs_colorMap = colorMap[0]; - - // if ((orig_position[0].x == 0.0) && - // (orig_position[0].y == 0.0) && - // (orig_position[0].z == 0.0)) - // { - // return; - // } - - //float modifiedSpriteSize = exp((-30.623 - 0.5) * 1.0) * scaleFactor * 2000; - - float modifiedSpriteSize = - exp((-30.623 - (-5.0)) * 0.462) * 1.0 * 2000; - - vec4 projPos[4]; - for (int i = 0; i < 4; ++i) { - vec4 p1 = gl_in[0].gl_Position; - p1.xy += vec2(modifiedSpriteSize * (corners[i] - vec2(0.5))); - projPos[i] = projection * p1; - } - - // Calculate the positions of the lower left and upper right corners of the - // billboard in screen-space - vec2 ll = (((projPos[1].xy / projPos[1].w) + 1.0) / 2.0) * screenSize; - vec2 ur = (((projPos[2].xy / projPos[2].w) + 1.0) / 2.0) * screenSize; - - // The billboard is smaller than one pixel, we can discard it - float sizeInPixels = length(ll - ur); - //if (sizeInPixels < minBillboardSize) { - // return; - //} - - for (int i = 0; i < 4; i++) { - gl_Position = projPos[i]; - texCoord = corners[i]; - billboardSize = sizeInPixels; - EmitVertex(); - } - - EndPrimitive(); -} diff --git a/modules/digitaluniverse/shaders/billboard_old_vs.glsl b/modules/digitaluniverse/shaders/billboard_old_vs.glsl deleted file mode 100644 index 1b15e54005..0000000000 --- a/modules/digitaluniverse/shaders/billboard_old_vs.glsl +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2018 * - * * - * 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. * - ****************************************************************************************/ - -#version __CONTEXT__ - -#include "PowerScaling/powerScaling_vs.hglsl" - -in dvec4 in_position; -//in dvec4 in_colormap; - -uniform dmat4 modelViewTransform; -uniform mat4 projection; - -out float vs_screenSpaceDepth; -out vec4 orig_position; -//out vec4 colorMap; - -void main() { - orig_position = vec4(in_position); - //colorMap = vec4(in_colormap); - - vec4 positionViewSpace = vec4(modelViewTransform * in_position); - vec4 positionScreenSpace = vec4(z_normalization(projection * positionViewSpace)); - //vec4 positionScreenSpace = vec4(projection * positionViewSpace); - vs_screenSpaceDepth = positionScreenSpace.w; - - gl_Position = positionViewSpace; -} \ No newline at end of file From c57fc0d47350fea87003986b64344ba9a002b027 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 5 Feb 2018 15:58:20 -0500 Subject: [PATCH 005/131] Minor coding style fixes --- .../spacecraftinstruments/util/imagesequencer.cpp | 14 ++++++-------- .../spacecraftinstruments/util/imagesequencer.h | 6 ++---- src/scene/scale.cpp | 3 +-- src/scene/sceneinitializer.cpp | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/modules/spacecraftinstruments/util/imagesequencer.cpp b/modules/spacecraftinstruments/util/imagesequencer.cpp index 263f569097..0a347d835f 100644 --- a/modules/spacecraftinstruments/util/imagesequencer.cpp +++ b/modules/spacecraftinstruments/util/imagesequencer.cpp @@ -269,11 +269,9 @@ float ImageSequencer::instrumentActiveTime(const std::string& instrumentID) cons return -1.f; } -bool ImageSequencer::getImagePaths(std::vector& captures, - std::string projectee, - std::string instrumentRequest, - double sinceTime) { - +bool ImageSequencer::getImagePaths(std::vector& captures, std::string projectee, + std::string instrumentRequest, double sinceTime) +{ // check if this instance is either in range or // a valid candidate to recieve data if (!instrumentActive(instrumentRequest) && !OsEng.timeManager().time().timeJumped()) @@ -283,9 +281,9 @@ bool ImageSequencer::getImagePaths(std::vector& captures, //if (!Time::ref().timeJumped() && projectee == getCurrentTarget().second) if (_subsetMap[projectee]._range.includes(_currentTime) || - _subsetMap[projectee]._range.includes(sinceTime)){ - auto compareTime = [](const Image &a, - const Image &b)->bool{ + _subsetMap[projectee]._range.includes(sinceTime)) + { + auto compareTime = [](const Image& a, const Image& b) -> bool { return a.timeRange.start < b.timeRange.start; }; // for readability we store the iterators diff --git a/modules/spacecraftinstruments/util/imagesequencer.h b/modules/spacecraftinstruments/util/imagesequencer.h index 930cae3e36..4628696a24 100644 --- a/modules/spacecraftinstruments/util/imagesequencer.h +++ b/modules/spacecraftinstruments/util/imagesequencer.h @@ -125,10 +125,8 @@ public: * makes the request. If an instance is not registered in the class then the singleton * returns false and no projections will occur. */ - bool getImagePaths(std::vector& captures, - std::string projectee, - std::string instrumentRequest, - double sinceTime); + bool getImagePaths(std::vector& captures, std::string projectee, + std::string instrumentRequest, double sinceTime); /* * returns true if instrumentID is within a capture range. diff --git a/src/scene/scale.cpp b/src/scene/scale.cpp index 546e4c8620..9a439d9d56 100644 --- a/src/scene/scale.cpp +++ b/src/scene/scale.cpp @@ -84,8 +84,7 @@ bool Scale::initialize() { return true; } -double Scale::scaleValue() const -{ +double Scale::scaleValue() const { return _cachedScale; } diff --git a/src/scene/sceneinitializer.cpp b/src/scene/sceneinitializer.cpp index 15be7e731a..c47830714a 100644 --- a/src/scene/sceneinitializer.cpp +++ b/src/scene/sceneinitializer.cpp @@ -76,7 +76,7 @@ void MultiThreadedSceneInitializer::initializeNode(SceneGraphNode* node) { loadingScreen.updateItem( node->name(), LoadingScreen::ItemStatus::Started, - 0.0f + 0.f ); std::lock_guard g(_mutex); From 65abb03e06de76b7a6e4a961b5792b5a3c4952af Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 5 Feb 2018 15:58:57 -0500 Subject: [PATCH 006/131] Removed unused code in RenderablePlanesCloud and changed gPosition for planes. --- modules/digitaluniverse/rendering/renderableplanescloud.cpp | 3 --- modules/digitaluniverse/shaders/plane_fs.glsl | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index 06b032dbd9..a9a915b84a 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -530,7 +530,6 @@ void RenderablePlanesCloud::initializeGL() { "modelViewProjectionTransform" ); _uniformCache.alphaValue = _program->uniformLocation("alphaValue"); - //_uniformCache.scaleFactor = _program->uniformLocation("scaleFactor"); _uniformCache.fadeInValue = _program->uniformLocation("fadeInValue"); _uniformCache.galaxyTexture = _program->uniformLocation("galaxyTexture"); @@ -606,7 +605,6 @@ void RenderablePlanesCloud::renderPlanes(const RenderData&, modelViewProjectionMatrix ); _program->setUniform(_uniformCache.alphaValue, _alphaValue); - _program->setUniform(_uniformCache.scaleFactor, _scaleFactor); _program->setUniform(_uniformCache.fadeInValue, fadeInVariable); GLint viewport[4]; @@ -847,7 +845,6 @@ void RenderablePlanesCloud::update(const UpdateData&) { "modelViewProjectionTransform" ); _uniformCache.alphaValue = _program->uniformLocation("alphaValue"); - _uniformCache.scaleFactor = _program->uniformLocation("scaleFactor"); _uniformCache.fadeInValue = _program->uniformLocation("fadeInValue"); _uniformCache.galaxyTexture = _program->uniformLocation("galaxyTexture"); } diff --git a/modules/digitaluniverse/shaders/plane_fs.glsl b/modules/digitaluniverse/shaders/plane_fs.glsl index 382bf62509..fc7b7b3fbb 100644 --- a/modules/digitaluniverse/shaders/plane_fs.glsl +++ b/modules/digitaluniverse/shaders/plane_fs.glsl @@ -56,8 +56,8 @@ Fragment getFragment() { // } //frag.color = texture(galaxyTexture, vs_st); - frag.depth = vs_screenSpaceDepth; - frag.gPosition = vec4(1e27, 1e27, 1e27, 1.0); + frag.depth = vs_screenSpaceDepth; + frag.gPosition = vec4(vs_screenSpaceDepth, vs_screenSpaceDepth, vs_screenSpaceDepth, 1.0); frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0); return frag; From ebe1159f00135f844207f11b6910f474440f3dc6 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 5 Feb 2018 17:37:13 -0500 Subject: [PATCH 007/131] WMS file cleanup --- .../ESRI/ESRI_Imagery_World_2D.wms | 32 ++--- .../map_service_configs/ESRI/Terrain.wms | 14 +- .../ESRI/World_Imagery.wms | 40 +++--- ...RS_SNPP_CorrectedReflectance_TrueColor.wms | 54 +++---- .../GIBS/night/VIIRS_CityLights_2012.wms | 44 +++--- .../GIBS/overlays/Coastlines.wms | 44 +++--- .../GIBS/overlays/Reference_Features.wms | 44 +++--- .../GIBS/overlays/Reference_Labels.wms | 44 +++--- .../GIBS/water/MODIS_Water_Mask.wms | 44 +++--- .../earth/map_service_configs/Utah/Bmng.wms | 40 +++--- .../earth/map_service_configs/Utah/Gebco.wms | 40 +++--- .../other/MLS_O3_46hPa_Day.wms | 36 ++--- .../moon/map_service_configs/OnMoonColor.wms | 133 +++++++++--------- .../map_service_configs/Utah/ClemUvvis.wms | 40 +++--- .../moon/map_service_configs/Utah/Kaguya.wms | 40 +++--- .../map_service_configs/Utah/LolaClrShade.wms | 40 +++--- .../moon/map_service_configs/Utah/LolaDem.wms | 42 +++--- .../map_service_configs/Utah/LolaShade.wms | 40 +++--- .../map_service_configs/Utah/UvvisHybrid.wms | 40 +++--- .../moon/map_service_configs/Utah/Wac.wms | 40 +++--- .../mars/map_service_configs/AWS/CTX.wms | 32 ++--- .../mars/map_service_configs/AWS/Mdim.wms | 42 +++--- .../AWS/Mola_Elevation.wms | 44 +++--- .../AWS/Mola_PseudoColor.wms | 42 +++--- .../map_service_configs/AWS/Themis_IR_Day.wms | 42 +++--- .../AWS/Themis_IR_Night.wms | 42 +++--- .../mars/map_service_configs/LiU/CTX.wms | 2 +- .../LiU/Mola_Elevation.wms | 2 +- .../MARS_Viking_MDIM21.wms | 32 ++--- .../map_service_configs/Mars_MGS_MOLA_DEM.wms | 34 ++--- .../mars/map_service_configs/Utah/CTX.wms | 44 +++--- .../map_service_configs/Utah/Mars_Color.wms | 40 +++--- .../mars/map_service_configs/Utah/Mdim.wms | 40 +++--- .../Utah/MolaCTX_Elevation.wms | 2 +- .../Utah/Mola_Elevation.wms | 36 ++--- .../map_service_configs/Utah/Mola_HRSC.wms | 40 +++--- .../Utah/Mola_PseudoColor.wms | 40 +++--- .../Utah/Themis_IR_Day.wms | 42 +++--- .../Utah/Themis_IR_Night.wms | 26 ++-- .../AMNH/OnMercuryColor.wms | 60 ++++---- .../AMNH/OnMercuryElevationGaskell.wms | 48 +++---- .../AMNH/OnMercuryImage.wms | 62 ++++---- .../map_service_configs/AWS/MessengerMdis.wms | 38 ++--- .../AWS/MessengerMosaic.wms | 38 ++--- .../Utah/MessengerMdis.wms | 40 +++--- .../Utah/MessengerMosaic.wms | 40 +++--- 46 files changed, 920 insertions(+), 921 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/ESRI_Imagery_World_2D.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/ESRI_Imagery_World_2D.wms index 4d1aa46be8..7a1703861c 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/ESRI_Imagery_World_2D.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/ESRI_Imagery_World_2D.wms @@ -1,18 +1,18 @@ - - http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/${z}/${y}/${x} - - - 15 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 3 - 5 - false - 5 + + http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/${z}/${y}/${x} + + + 15 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 3 + 5 + false + 5 diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/Terrain.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/Terrain.wms index f2e134436d..25ba9e13da 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/Terrain.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/Terrain.wms @@ -1,9 +1,9 @@ - - http://198.102.45.23/arcgis/rest/services/worldelevation3d/terrain3d? - GCS_Elevation - - 2 - 5 - false + + http://198.102.45.23/arcgis/rest/services/worldelevation3d/terrain3d? + GCS_Elevation + + 2 + 5 + false diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/World_Imagery.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/World_Imagery.wms index b89bc8b01c..f7021fd20f 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/World_Imagery.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/ESRI/World_Imagery.wms @@ -1,22 +1,22 @@ - - http://wi.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/WMTS/tile/1.0.0/World_Imagery/default/default/${z}/${y}/${x}.jpg - - - -180.0 - 90 - 180 - -89.999999 - 19 - 2 - 1 - top - - EPSG:4326 - 256 - 256 - 3 - 5 - false - 5 + + http://wi.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/WMTS/tile/1.0.0/World_Imagery/default/default/${z}/${y}/${x}.jpg + + + -180.0 + 90 + 180 + -89.999999 + 19 + 2 + 1 + top + + EPSG:4326 + 256 + 256 + 3 + 5 + false + 5 diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/Temporal_VIIRS_SNPP_CorrectedReflectance_TrueColor.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/Temporal_VIIRS_SNPP_CorrectedReflectance_TrueColor.wms index 2674f50b62..0b1d8ea47b 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/Temporal_VIIRS_SNPP_CorrectedReflectance_TrueColor.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/Temporal_VIIRS_SNPP_CorrectedReflectance_TrueColor.wms @@ -1,29 +1,29 @@ - 2015-11-24 - Yesterday - 1d - YYYY-MM-DD - - - https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/VIIRS_SNPP_CorrectedReflectance_TrueColor/default/${OpenSpaceTimeId}/250m/${z}/${y}/${x}.jpg - - - -180.0 - 90 - 396.0 - -198 - 8 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 3 - true - 400 - true - 5 - + 2015-11-24 + Yesterday + 1d + YYYY-MM-DD + + + https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/VIIRS_SNPP_CorrectedReflectance_TrueColor/default/${OpenSpaceTimeId}/250m/${z}/${y}/${x}.jpg + + + -180.0 + 90 + 396.0 + -198 + 8 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 3 + true + 400 + true + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/night/VIIRS_CityLights_2012.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/night/VIIRS_CityLights_2012.wms index 211fddd690..127d6f752e 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/night/VIIRS_CityLights_2012.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/night/VIIRS_CityLights_2012.wms @@ -1,24 +1,24 @@ - - https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/VIIRS_CityLights_2012/default/2013-08-21/500m/${z}/${y}/${x}.jpg - - - -180.0 - 90 - 396.0 - -198 - 7 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 4 - 5 - true - 400 - true - 5 + + https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/VIIRS_CityLights_2012/default/2013-08-21/500m/${z}/${y}/${x}.jpg + + + -180.0 + 90 + 396.0 + -198 + 7 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 4 + 5 + true + 400 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Coastlines.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Coastlines.wms index 20a0215de5..2e659163ad 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Coastlines.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Coastlines.wms @@ -1,24 +1,24 @@ - - https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/Coastlines/default/2013-08-21/250m/${z}/${y}/${x}.png - - - -180.0 - 90 - 396.0 - -198 - 9 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 4 - true - 400 - true - 5 - 5 + + https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/Coastlines/default/2013-08-21/250m/${z}/${y}/${x}.png + + + -180.0 + 90 + 396.0 + -198 + 9 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 4 + true + 400 + true + 5 + 5 diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Features.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Features.wms index 5da21ec8ec..f17448aa25 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Features.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Features.wms @@ -1,24 +1,24 @@ - - https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/Reference_Features/default/2013-08-21/250m/${z}/${y}/${x}.png - - - -180.0 - 90 - 396.0 - -198 - 9 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 4 - 5 - true - 400 - true - 5 + + https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/Reference_Features/default/2013-08-21/250m/${z}/${y}/${x}.png + + + -180.0 + 90 + 396.0 + -198 + 9 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 4 + 5 + true + 400 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Labels.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Labels.wms index 8818175e3f..309239e575 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Labels.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/overlays/Reference_Labels.wms @@ -1,24 +1,24 @@ - - https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/Reference_Labels/default/2013-08-21/250m/${z}/${y}/${x}.png - - - -180.0 - 90 - 396.0 - -198 - 9 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 4 - 5 - true - 400 - true - 5 + + https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/Reference_Labels/default/2013-08-21/250m/${z}/${y}/${x}.png + + + -180.0 + 90 + 396.0 + -198 + 9 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 4 + 5 + true + 400 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/water/MODIS_Water_Mask.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/water/MODIS_Water_Mask.wms index 1511bf1a02..57df99fa5a 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/water/MODIS_Water_Mask.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/GIBS/water/MODIS_Water_Mask.wms @@ -1,24 +1,24 @@ - - https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/MODIS_Water_Mask/default/2013-08-21/250m/${z}/${y}/${x}.png - - - -180.0 - 90 - 396.0 - -198 - 7 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 4 - 5 - true - 400,204,404 - true - 5 + + https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/MODIS_Water_Mask/default/2013-08-21/250m/${z}/${y}/${x}.png + + + -180.0 + 90 + 396.0 + -198 + 7 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 4 + 5 + true + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Bmng.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Bmng.wms index d1a74cf747..41ef501061 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Bmng.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Bmng.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Earth/Bmng/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 86400 - 43200 - 8 - top - - EPSG:4326 - 240 - 240 - 3 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Earth/Bmng/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 86400 + 43200 + 8 + top + + EPSG:4326 + 240 + 240 + 3 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Gebco.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Gebco.wms index 3334c9be5b..0388510a06 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Gebco.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/Utah/Gebco.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Earth/Gebco/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 43200 - 21600 - 6 - top - - EPSG:4326 - 360 - 360 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Earth/Gebco/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 43200 + 21600 + 6 + top + + EPSG:4326 + 360 + 360 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/map_service_configs/other/MLS_O3_46hPa_Day.wms b/data/assets/scene/solarsystem/planets/earth/map_service_configs/other/MLS_O3_46hPa_Day.wms index 14a070cab7..888a1fcf2a 100644 --- a/data/assets/scene/solarsystem/planets/earth/map_service_configs/other/MLS_O3_46hPa_Day.wms +++ b/data/assets/scene/solarsystem/planets/earth/map_service_configs/other/MLS_O3_46hPa_Day.wms @@ -1,20 +1,20 @@ - - http://map1.vis.earthdata.nasa.gov/wmts-geo/MLS_O3_46hPa_Day/default/2013-08-21/EPSG4326_2km/${z}/${y}/${x}.png - - - -180.0 - 90 - 396.0 - -198 - 5 - 2 - 1 - top - - EPSG:4326 - 512 - 512 - 4 - 5 + + http://map1.vis.earthdata.nasa.gov/wmts-geo/MLS_O3_46hPa_Day/default/2013-08-21/EPSG4326_2km/${z}/${y}/${x}.png + + + -180.0 + 90 + 396.0 + -198 + 5 + 2 + 1 + top + + EPSG:4326 + 512 + 512 + 4 + 5 \ No newline at end of file diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/OnMoonColor.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/OnMoonColor.wms index 36d27be119..a8895878f8 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/OnMoonColor.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/OnMoonColor.wms @@ -1,69 +1,68 @@ - - http://onmoon.lmmp.nasa.gov/wms.cgi? - LRO WAC Mosaic, LMMP + + http://onmoon.lmmp.nasa.gov/wms.cgi? + LRO WAC Mosaic, LMMP - - - - - -180.0 - 90 - 180.0 - -90 - 20 - 2 - 1 - top - - 512 - 512 - true - 400 - true - 5 - \ No newline at end of file + + + + -180.0 + 90 + 180.0 + -90 + 20 + 2 + 1 + top + + 512 + 512 + true + 400 + true + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/ClemUvvis.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/ClemUvvis.wms index 8a31b546a6..7ed9bdc4fd 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/ClemUvvis.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/ClemUvvis.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Moon/ClemUvvis/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 92160 - 46080 - 7 - top - - GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Moon/ClemUvvis/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 92160 + 46080 + 7 + top + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.wms index 03e2b01d64..16c2e42981 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Kaguya.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Moon/Kaguya/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 1474560 - 737280 - 11 - top - - GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Moon/Kaguya/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 1474560 + 737280 + 11 + top + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaClrShade.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaClrShade.wms index 4d8b7e7682..e0f69129ea 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaClrShade.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaClrShade.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Moon/LolaClrShade/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 92160 - 46080 - 7 - top - - GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 3 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Moon/LolaClrShade/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 92160 + 46080 + 7 + top + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 3 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaDem.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaDem.wms index bd915a7cc7..2638f369ff 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaDem.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaDem.wms @@ -1,22 +1,22 @@ - - http://asgard.sci.utah.edu/Moon/LolaDem/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 92160 - 46080 - 7 - top - - Int16 - GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Moon/LolaDem/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 92160 + 46080 + 7 + top + + Int16 + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaShade.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaShade.wms index 7cde4903fe..d2c2d11bd2 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaShade.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/LolaShade.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Moon/LolaShade/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 92160 - 46080 - 7 - top - - GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Moon/LolaShade/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 92160 + 46080 + 7 + top + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/UvvisHybrid.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/UvvisHybrid.wms index 979d459733..2d8adff129 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/UvvisHybrid.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/UvvisHybrid.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Moon/UvvisHybrid/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 184320 - 92160 - 8 - top - - GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Moon/UvvisHybrid/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 184320 + 92160 + 8 + top + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Wac.wms b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Wac.wms index 16dd40b9df..64b7bb221b 100644 --- a/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Wac.wms +++ b/data/assets/scene/solarsystem/planets/earth/moon/map_service_configs/Utah/Wac.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Moon/Wac/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 109164 - 54582 - 8 - top - - GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Moon/Wac/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 109164 + 54582 + 8 + top + + GEOGCS["GCS_Moon_2000",DATUM["D_Moon_2000",SPHEROID["Moon_2000_IAU_IAG",1737400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/CTX.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/CTX.wms index 4ba793e528..148dc55d16 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/CTX.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/CTX.wms @@ -1,18 +1,18 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/CTX/tile/${z}/${y}/${x} - - - -180.0 90.0 - 180.0 -90.0 - 4194304 2097152 - 12 top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 512 512 - 2 - 5 - 400,204,404 - true - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/CTX/tile/${z}/${y}/${x} + + + -180.0 90.0 + 180.0 -90.0 + 4194304 2097152 + 12 top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 512 512 + 2 + 5 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mdim.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mdim.wms index 846e73ab06..350934bdc7 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mdim.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mdim.wms @@ -1,23 +1,23 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/Mdim/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 92160 - 46080 - 7 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 3 - 10 - 400,204,404 - true - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/Mdim/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 92160 + 46080 + 7 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 3 + 10 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_Elevation.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_Elevation.wms index 27845059d8..75f50e4234 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_Elevation.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_Elevation.wms @@ -1,24 +1,24 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/MolaElevation/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 46080 - 23040 - 6 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 1 - Int16 - 10 - 400,204,404 - true - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/MolaElevation/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 46080 + 23040 + 6 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 1 + Int16 + 10 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_PseudoColor.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_PseudoColor.wms index d82dd045b3..a72a5b8fd3 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_PseudoColor.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Mola_PseudoColor.wms @@ -1,23 +1,23 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/MolaPseudoColor/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 46080 - 23040 - 6 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 3 - 10 - 400,204,404 - true - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/MolaPseudoColor/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 46080 + 23040 + 6 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 3 + 10 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Day.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Day.wms index d389d9cb07..bb8c28f2ce 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Day.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Day.wms @@ -1,23 +1,23 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/ThemisIRDay/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 213390 - 106695 - 9 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 1 - 10 - 400,204,404 - true - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/ThemisIRDay/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 213390 + 106695 + 9 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Night.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Night.wms index 619b10abdf..e6e249f089 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Night.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/AWS/Themis_IR_Night.wms @@ -1,23 +1,23 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/ThemisIRNight/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 213388 - 71130 - 9 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 1 - 10 - 400,204,404 - true - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mars/ThemisIRNight/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 213388 + 71130 + 9 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms index 0e1bf3fdf2..7c0effdee4 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms @@ -15,4 +15,4 @@ 400,204,404 true 5 - \ No newline at end of file + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms index edc9ef8554..de304c2a37 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms @@ -12,4 +12,4 @@ false 5 - \ No newline at end of file + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/MARS_Viking_MDIM21.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/MARS_Viking_MDIM21.wms index 255b89aa34..81d024b430 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/MARS_Viking_MDIM21.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/MARS_Viking_MDIM21.wms @@ -1,17 +1,17 @@ - - http://d1poygwgh8gv6r.cloudfront.net/catalog/Mars_Viking_MDIM21_ClrMosaic_global_232m/1.0.0//default/default028mm/${z}/${y}/${x}.jpg - image/jpg - - - 8 - 2 - 1 - top - - EPSG:4326 - 256 - 256 - 3 - 5 - \ No newline at end of file + + http://d1poygwgh8gv6r.cloudfront.net/catalog/Mars_Viking_MDIM21_ClrMosaic_global_232m/1.0.0//default/default028mm/${z}/${y}/${x}.jpg + image/jpg + + + 8 + 2 + 1 + top + + EPSG:4326 + 256 + 256 + 3 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Mars_MGS_MOLA_DEM.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Mars_MGS_MOLA_DEM.wms index 7ab798943c..b50fc7ba32 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Mars_MGS_MOLA_DEM.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Mars_MGS_MOLA_DEM.wms @@ -1,18 +1,18 @@ - - http://d1poygwgh8gv6r.cloudfront.net/catalog/Mars_MGS_MOLA_DEM_mosaic_global_463m_8/1.0.0//default/default028mm/${z}/${y}/${x}.png - image/png - - - 5 - 2 - 1 - top - - Byte - EPSG:4326 - 256 - 256 - 2 - 5 - \ No newline at end of file + + http://d1poygwgh8gv6r.cloudfront.net/catalog/Mars_MGS_MOLA_DEM_mosaic_global_463m_8/1.0.0//default/default028mm/${z}/${y}/${x}.png + image/png + + + 5 + 2 + 1 + top + + Byte + EPSG:4326 + 256 + 256 + 2 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/CTX.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/CTX.wms index c8d10b8742..d8e966aa18 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/CTX.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/CTX.wms @@ -1,23 +1,23 @@ - - http://asgard.sci.utah.edu/Mars/CTX/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 4194304 - 2097152 - 13 - top - - GEOGCS["Mars 2000", DATUM["D_Mars_2000", SPHEROID["MARS_2000_IAU_IAG",3396190.0,169.894447222361179]],PRIMEM["Greenwich"0],UNIT["Decimal_Degree",0.0174532925199433]] - 256 - 256 - 2 - 10 - 400,204,404 - true - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Mars/CTX/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 4194304 + 2097152 + 13 + top + + GEOGCS["Mars 2000", DATUM["D_Mars_2000", SPHEROID["MARS_2000_IAU_IAG",3396190.0,169.894447222361179]],PRIMEM["Greenwich"0],UNIT["Decimal_Degree",0.0174532925199433]] + 256 + 256 + 2 + 10 + 400,204,404 + true + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mars_Color.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mars_Color.wms index a476a28a8d..9129fa1e8c 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mars_Color.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mars_Color.wms @@ -1,21 +1,21 @@ - - http://openspace.sci.utah.edu/Mars/mainColV007/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 92160 - 46080 - 7 - top - - - 512 - 512 - 3 - 10 - 5 - \ No newline at end of file + + http://openspace.sci.utah.edu/Mars/mainColV007/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 92160 + 46080 + 7 + top + + + 512 + 512 + 3 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mdim.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mdim.wms index 29da57810c..dc18b3da8a 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mdim.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mdim.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Mars/Mdim/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 92160 - 46080 - 7 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 3 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Mars/Mdim/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 92160 + 46080 + 7 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 3 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/MolaCTX_Elevation.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/MolaCTX_Elevation.wms index 4ffc086c3f..ea53ebdead 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/MolaCTX_Elevation.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/MolaCTX_Elevation.wms @@ -12,4 +12,4 @@ false 5 - \ No newline at end of file + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_Elevation.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_Elevation.wms index d539e7f542..8814e5f641 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_Elevation.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_Elevation.wms @@ -1,22 +1,22 @@ - - http://asgard.sci.utah.edu/Mars/MolaElevation/tile/${z}/${y}/${x} - - + + http://asgard.sci.utah.edu/Mars/MolaElevation/tile/${z}/${y}/${x} + + -180.0 - 90.0 - 180.0 - -90.0 + 90.0 + 180.0 + -90.0 46080 23040 - 6 - top - - Int16 - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 1 - 10 - 5 - \ No newline at end of file + 6 + top + + Int16 + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_HRSC.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_HRSC.wms index ce9d396e9c..bc86d93875 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_HRSC.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_HRSC.wms @@ -1,21 +1,21 @@ - - http://openspace.sci.utah.edu/Mars/MolaHRSC/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 106694 - 53347 - 7 - top - - - 512 - 512 - 3 - 10 - 5 - \ No newline at end of file + + http://openspace.sci.utah.edu/Mars/MolaHRSC/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 106694 + 53347 + 7 + top + + + 512 + 512 + 3 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_PseudoColor.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_PseudoColor.wms index 9f6139c196..44758ddfeb 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_PseudoColor.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Mola_PseudoColor.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Mars/MolaPseudoColor/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 46080 - 23040 - 6 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 360 - 360 - 3 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Mars/MolaPseudoColor/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 46080 + 23040 + 6 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 360 + 360 + 3 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Day.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Day.wms index d8d475504c..8184e24be9 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Day.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Day.wms @@ -1,23 +1,23 @@ - - http://asgard.sci.utah.edu/Mars/ThemisIRDay/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 213390 - 106695 - 9 - top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 1 - 10 - 400,204,404 - true - 5 + + http://asgard.sci.utah.edu/Mars/ThemisIRDay/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 213390 + 106695 + 9 + top + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Night.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Night.wms index 66c168b0df..16c4c4380f 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Night.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/Utah/Themis_IR_Night.wms @@ -1,8 +1,8 @@ - - http://asgard.sci.utah.edu/Mars/ThemisIRNight/tile/${z}/${y}/${x} - - + + http://asgard.sci.utah.edu/Mars/ThemisIRNight/tile/${z}/${y}/${x} + + -180.0 90.0 180.0 @@ -11,13 +11,13 @@ 106695 9 top - - GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 1 - 10 - 400,204,404 - true - 5 + + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 400,204,404 + true + 5 diff --git a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryColor.wms b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryColor.wms index 4083bfbba8..f16e0e2b06 100644 --- a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryColor.wms +++ b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryColor.wms @@ -1,31 +1,31 @@ - - http://192.168.1.167/OnMercury/wms.cgi? - Color 665m - - - - -180.0 - 90 - 180.0 - -90 - 20 - 2 - 1 - top - - 5 - 512 - 512 - \ No newline at end of file + + http://192.168.1.167/OnMercury/wms.cgi? + Color 665m + + + + -180.0 + 90 + 180.0 + -90 + 20 + 2 + 1 + top + + 5 + 512 + 512 + diff --git a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryElevationGaskell.wms b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryElevationGaskell.wms index e2d677c0e4..9769b967a0 100644 --- a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryElevationGaskell.wms +++ b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryElevationGaskell.wms @@ -1,25 +1,25 @@ - - http://192.168.1.167/OnMercury/wms.cgi? - - Elevation 16bit, Gaskell - - - -180.0 - 90 - 180.0 - -90 - 8 - 2 - 1 - top - - 512 - 512 - 5 - \ No newline at end of file + + http://192.168.1.167/OnMercury/wms.cgi? + + Elevation 16bit, Gaskell + + + -180.0 + 90 + 180.0 + -90 + 8 + 2 + 1 + top + + 512 + 512 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryImage.wms b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryImage.wms index a5b597346f..ceded0e510 100644 --- a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryImage.wms +++ b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AMNH/OnMercuryImage.wms @@ -1,32 +1,32 @@ - - http://192.168.1.167/OnMercury/wms.cgi? - Mercury Image - - - - -180.0 - 90 - 180.0 - -90 - 20 - 2 - 1 - top - - 512 - 512 - 5 - \ No newline at end of file + + http://192.168.1.167/OnMercury/wms.cgi? + Mercury Image + + + + -180.0 + 90 + 180.0 + -90 + 20 + 2 + 1 + top + + 512 + 512 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMdis.wms b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMdis.wms index c8e340ca3c..ff78793136 100644 --- a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMdis.wms +++ b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMdis.wms @@ -1,21 +1,21 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mercury/MessengerMdis/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 61324 - 30662 - 7 - top - - GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 1 - 10 - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mercury/MessengerMdis/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 61324 + 30662 + 7 + top + + GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 5 diff --git a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMosaic.wms b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMosaic.wms index 1370ac5bee..15c7e11d5f 100644 --- a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMosaic.wms +++ b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/AWS/MessengerMosaic.wms @@ -1,21 +1,21 @@ - - http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mercury/MessengerMosaic/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 23054 - 11527 - 6 - top - - GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 3 - 10 - 5 + + http://planetarydev-1803629091.us-west-2.elb.amazonaws.com/Mercury/MessengerMosaic/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 23054 + 11527 + 6 + top + + GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 3 + 10 + 5 diff --git a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMdis.wms b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMdis.wms index d5ca8f0b3b..912125a723 100644 --- a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMdis.wms +++ b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMdis.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Mercury/MessengerMdis/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 61324 - 30662 - 7 - top - - GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 1 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Mercury/MessengerMdis/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 61324 + 30662 + 7 + top + + GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 + 10 + 5 + diff --git a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMosaic.wms b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMosaic.wms index d309e5d25e..f5b1b51626 100644 --- a/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMosaic.wms +++ b/data/assets/scene/solarsystem/planets/mercury/map_service_configs/Utah/MessengerMosaic.wms @@ -1,21 +1,21 @@ - - http://asgard.sci.utah.edu/Mercury/MessengerMosaic/tile/${z}/${y}/${x} - - - -180.0 - 90.0 - 180.0 - -90.0 - 23054 - 11527 - 6 - top - - GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] - 256 - 256 - 3 - 10 - 5 - \ No newline at end of file + + http://asgard.sci.utah.edu/Mercury/MessengerMosaic/tile/${z}/${y}/${x} + + + -180.0 + 90.0 + 180.0 + -90.0 + 23054 + 11527 + 6 + top + + GEOGCS["GCS_Mercury_2015",DATUM["D_Mercury_2015",SPHEROID["Mercury_2015",2439400.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 3 + 10 + 5 + From 7db0b89da2490da834fbf8b9655e58c832ebc5e6 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Tue, 6 Feb 2018 09:38:27 +0100 Subject: [PATCH 008/131] Remove deleted files from CMakeLists --- modules/digitaluniverse/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/digitaluniverse/CMakeLists.txt b/modules/digitaluniverse/CMakeLists.txt index 32c4632ea5..8c2ca6c144 100644 --- a/modules/digitaluniverse/CMakeLists.txt +++ b/modules/digitaluniverse/CMakeLists.txt @@ -50,9 +50,6 @@ set(SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_gs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard_vs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard2_fs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard2_gs.glsl - ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboard2_vs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboardpolygon_fs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboardpolygon_gs.glsl ${CMAKE_CURRENT_SOURCE_DIR}/shaders/billboardpolygon_vs.glsl From f7a3fa9ebfd36f6350c76ba4b6838368efcc30b8 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 6 Feb 2018 10:10:42 -0500 Subject: [PATCH 009/131] Update sgct repository Make use of new sync parametrization to disable messages and set waitout time to 15 minutes (closes #488) --- apps/OpenSpace/main.cpp | 4 ++++ ext/sgct | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 1b2b2f8b48..402bf0ef18 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -622,6 +622,10 @@ int main_main(int argc, char** argv) { bool initSuccess = SgctEngine->init(versionMapping[glVersion]); + // Do not print message if slaves are waiting for the master + // Only timeout after 15 minutes + SgctEngine->setSyncParameters(false, 15.f * 60.f); + if (!initSuccess) { LFATAL("Initializing failed"); cleanup(IsInitialized::No); diff --git a/ext/sgct b/ext/sgct index 7f56f724c1..278d45d9df 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit 7f56f724c1103effcec217dd66513c42eb1545e1 +Subproject commit 278d45d9df82094abfd177026d0dfce7be67eaca From 7b611abfe0868d8c9b3d06cc653e02f43e5e1bd0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 6 Feb 2018 10:25:29 -0500 Subject: [PATCH 010/131] Enable closing of filepath window using the ImGUI controls (closes #485) --- modules/imgui/src/guifilepathcomponent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/imgui/src/guifilepathcomponent.cpp b/modules/imgui/src/guifilepathcomponent.cpp index 521e347eef..87267ae31f 100644 --- a/modules/imgui/src/guifilepathcomponent.cpp +++ b/modules/imgui/src/guifilepathcomponent.cpp @@ -39,6 +39,7 @@ void GuiFilePathComponent::render() { bool v = _isEnabled; ImGui::Begin("File Path", &v); + _isEnabled = v; _isCollapsed = ImGui::IsWindowCollapsed(); ImGui::Text( From 02bb5e68b686ff78c657d3770fa0dc33bacfc8b9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 6 Feb 2018 11:03:35 -0500 Subject: [PATCH 011/131] Add global timeout of 3 seconds to GDAL request Remove duplicate opening of GDAL datasets on failure (closes #478) --- .../gdalrawtiledatareader.cpp | 19 ++++------------- .../tile/rawtiledatareader/gdalwrapper.cpp | 21 +++++++------------ 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp b/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp index 92e6a3d177..59791f02a4 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp @@ -133,6 +133,9 @@ void GdalRawTileDataReader::initialize() { throw ghoul::RuntimeError("File path must not be empty"); } _dataset = openGdalDataset(_datasetFilePath); + if (!_dataset) { + throw ghoul::RuntimeError("Failed to load dataset: " + _datasetFilePath); + } // Assume all raster bands have the same data type _gdalDatasetMetaDataCached.rasterCount = _dataset->GetRasterCount(); @@ -223,21 +226,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead( } GDALDataset* GdalRawTileDataReader::openGdalDataset(const std::string& filePath) { - GDALDataset* dataset = static_cast( - GDALOpen(filePath.c_str(), GA_ReadOnly) - ); - if (!dataset) { - using namespace ghoul::filesystem; - // std::string correctedPath = FileSystem::ref().pathByAppendingComponent( - // _initDirectory, filePath - // ); - - dataset = static_cast(GDALOpen(filePath.c_str(), GA_ReadOnly)); - if (!dataset) { - throw ghoul::RuntimeError("Failed to load dataset:\n" + filePath); - } - } - return dataset; + return static_cast(GDALOpen(filePath.c_str(), GA_ReadOnly)); } int GdalRawTileDataReader::calculateTileLevelDifference(int minimumPixelSize) const { diff --git a/modules/globebrowsing/tile/rawtiledatareader/gdalwrapper.cpp b/modules/globebrowsing/tile/rawtiledatareader/gdalwrapper.cpp index 0b2fcc97ca..47e7b8bba0 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/gdalwrapper.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/gdalwrapper.cpp @@ -117,23 +117,18 @@ GdalWrapper::GdalWrapper(size_t maximumCacheSize, size_t maximumMaximumCacheSize 0, // Minimum: No caching static_cast(maximumMaximumCacheSize / (1024ULL * 1024ULL)), // Maximum 1 // Step: One MB - ) { + ) +{ addProperty(_logGdalErrors); addProperty(_gdalMaximumCacheSize); GDALAllRegister(); - CPLSetConfigOption( - "GDAL_DATA", - absPath("${MODULE_GLOBEBROWSING}/gdal_data").c_str() - ); - CPLSetConfigOption( - "CPL_TMPDIR", - absPath("${BASE}").c_str() - ); - CPLSetConfigOption( - "GDAL_HTTP_UNSAFESSL", - "YES" - ); + CPLSetConfigOption("GDAL_DATA", absPath("${MODULE_GLOBEBROWSING}/gdal_data").c_str()); + CPLSetConfigOption("CPL_TMPDIR", absPath("${BASE}").c_str()); + CPLSetConfigOption("GDAL_HTTP_UNSAFESSL", "YES"); + + CPLSetConfigOption("GDAL_HTTP_TIMEOUT", "3"); // 3 seconds + setGdalProxyConfiguration(); CPLSetErrorHandler(gdalErrorHandler); From 8551d6799e3240bc4fbb64732fa8a79cb59302e9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 6 Feb 2018 11:34:42 -0500 Subject: [PATCH 012/131] Update Ghoul repository (closes #483) Do not let exception leak out of OpenSpaceEngine::create method Add double dash to long name commandline arguments --- apps/OpenSpace/main.cpp | 36 ++++++++++++++++++++++++++++------ ext/ghoul | 2 +- src/engine/openspaceengine.cpp | 11 ++++++----- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 1b2b2f8b48..a4d2a14d5a 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -506,12 +506,36 @@ int main_main(int argc, char** argv) { // @CLEANUP: Replace the return valua with throwing an exception --abock std::vector sgctArguments; bool requestQuit = false; - openspace::OpenSpaceEngine::create( - argc, argv, - std::make_unique(), - sgctArguments, - requestQuit - ); + try { + openspace::OpenSpaceEngine::create( + argc, argv, + std::make_unique(), + sgctArguments, + requestQuit + ); + } + catch (const ghoul::RuntimeError& e) { + // Write out all of the information about the exception and flush the logs + LFATALC(e.component, e.message); + LogMgr.flushLogs(); + return EXIT_FAILURE; + } + catch (const ghoul::AssertionException& e) { + // We don't want to catch the assertion exception as we won't be able to add a + // breakpoint for debugging + LFATALC("Assertion failed", e.what()); + throw; + } + catch (const std::exception& e) { + LFATALC("Exception", e.what()); + LogMgr.flushLogs(); + return EXIT_FAILURE; + } + catch (...) { + LFATALC("Exception", "Unknown exception"); + LogMgr.flushLogs(); + return EXIT_FAILURE; + } if (requestQuit) { return EXIT_SUCCESS; diff --git a/ext/ghoul b/ext/ghoul index e7389ac131..0830bb186a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit e7389ac131f23df5b7d7982f2a77b5ecff8b9115 +Subproject commit 0830bb186a10f83d4e7d7791b584a1a7235c2e3c diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index eed8aab633..59c5b1a435 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -312,7 +312,7 @@ void OpenSpaceEngine::create(int argc, char** argv, if (!FileSys.fileExists(configurationFilePath)) { throw ghoul::FileNotFoundError( - "Configuration file '" + configurationFilePath + "' not found" + "Configuration file '" + configurationFilePath + "'" ); } LINFO("Configuration Path: '" << configurationFilePath << "'"); @@ -821,26 +821,26 @@ void OpenSpaceEngine::writeStaticDocumentation() { void OpenSpaceEngine::gatherCommandlineArguments() { commandlineArgumentPlaceholders.configurationName = ""; _commandlineParser->addCommand(std::make_unique>( - commandlineArgumentPlaceholders.configurationName, "-config", "-c", + commandlineArgumentPlaceholders.configurationName, "--config", "-c", "Provides the path to the OpenSpace configuration file" )); commandlineArgumentPlaceholders.sgctConfigurationName = ""; _commandlineParser->addCommand(std::make_unique>( - commandlineArgumentPlaceholders.sgctConfigurationName, "-sgct", "-s", + commandlineArgumentPlaceholders.sgctConfigurationName, "--sgct", "-s", "Provides the path to the SGCT configuration file, overriding the value set in " "the OpenSpace configuration file" )); commandlineArgumentPlaceholders.sceneName = ""; _commandlineParser->addCommand(std::make_unique>( - commandlineArgumentPlaceholders.sceneName, "-scene", "", "Provides the path to " + commandlineArgumentPlaceholders.sceneName, "--scene", "", "Provides the path to " "the scene file, overriding the value set in the OpenSpace configuration file" )); commandlineArgumentPlaceholders.cacheFolder = ""; _commandlineParser->addCommand(std::make_unique>( - commandlineArgumentPlaceholders.cacheFolder, "-cacheDir", "", "Provides the " + commandlineArgumentPlaceholders.cacheFolder, "--cacheDir", "", "Provides the " "path to a cache file, overriding the value set in the OpenSpace configuration " "file" )); @@ -1231,6 +1231,7 @@ void OpenSpaceEngine::preSynchronization() { FileSys.triggerFilesystemEvents(); if (_hasScheduledAssetLoading) { + LINFO("Loading asset: " << _scheduledAssetPathToLoad); loadSingleAsset(_scheduledAssetPathToLoad); _hasScheduledAssetLoading = false; _scheduledAssetPathToLoad = ""; From 4a9142cef7cb822abb44aa91906a99be542f8df7 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 7 Feb 2018 15:52:08 -0500 Subject: [PATCH 013/131] Change "Now" to "Today" in TemporalTileProvider (closes #495) --- .../tile/tileprovider/temporaltileprovider.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp index f4ad66055d..2f5092b084 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp @@ -160,7 +160,7 @@ std::string TemporalTileProvider::consumeTemporalMetaData(const std::string& xml std::string timeEnd = getXMLValue( node, TemporalXMLTags::TIME_END, - "Now" + "Today" ); std::string timeIdFormat = getXMLValue( node, @@ -168,12 +168,13 @@ std::string TemporalTileProvider::consumeTemporalMetaData(const std::string& xml "YYYY-MM-DDThh:mm:ssZ" ); - Time start; start.setTime(timeStart); + Time start; + start.setTime(timeStart); Time end(Time::now()); if (timeEnd == "Yesterday") { end.advanceTime(-60.0 * 60.0 * 24.0); // Go back one day } - else if (timeEnd != "Now") { + else if (timeEnd != "Today") { end.setTime(timeEnd); } From 03789cd30744202389d3e5d26fc5ecec7e3e73fa Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 7 Feb 2018 16:47:31 -0500 Subject: [PATCH 014/131] Add button to refocus camera on object closes #465 --- modules/imgui/src/guispacetimecomponent.cpp | 16 ++++++++++++++++ src/interaction/navigationhandler.cpp | 15 +++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index 6f61a91312..3c6abd1328 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -148,6 +148,22 @@ void GuiSpaceTimeComponent::render() { ); } + ImGui::SameLine(); + bool pressed = ImGui::Button("Refocus"); + if (pressed) { + // To refocus, we are first clearing the origin property before setting it back + // to its old value. The property mechanism's onChange does not fire if the same + // value is set again, hence the need for the clearing + OsEng.scriptEngine().queueScript( + R"( + local o = openspace.getPropertyValue('NavigationHandler.Origin'); + openspace.setPropertyValue('NavigationHandler.Origin', ''); + openspace.setPropertyValue('NavigationHandler.Origin', o); + )", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f); ImGui::Separator(); diff --git a/src/interaction/navigationhandler.cpp b/src/interaction/navigationhandler.cpp index aa9bcf2f20..dbe74a635c 100644 --- a/src/interaction/navigationhandler.cpp +++ b/src/interaction/navigationhandler.cpp @@ -74,6 +74,10 @@ NavigationHandler::NavigationHandler() , _useKeyFrameInteraction(KeyFrameInfo, false) { _origin.onChange([this]() { + if (_origin.value().empty()) { + return; + } + SceneGraphNode* node = sceneGraphNode(_origin.value()); if (!node) { LWARNING( @@ -213,17 +217,12 @@ void NavigationHandler::setCameraStateFromDictionary(const ghoul::Dictionary& ca if (!readSuccessful) { throw ghoul::RuntimeError( - "Position, Rotation and Focus need to be defined for camera dictionary."); - } - - SceneGraphNode* node = sceneGraphNode(focus); - if (!node) { - throw ghoul::RuntimeError( - "Could not find a node in scenegraph called '" + focus + "'"); + "Position, Rotation and Focus need to be defined for camera dictionary." + ); } // Set state - setFocusNode(node); + _origin = focus; _camera->setPositionVec3(cameraPosition); _camera->setRotation(glm::dquat( cameraRotation.x, cameraRotation.y, cameraRotation.z, cameraRotation.w)); From ecee6c8d1be33b2801eea4681bb821f0a16a33e6 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 7 Feb 2018 17:15:17 -0500 Subject: [PATCH 015/131] Add properties to toggle simplification in Simulation Time and distance dashboard items (closes #461) --- .../base/dashboard/dashboarditemdistance.cpp | 35 +++++++++++++++-- .../base/dashboard/dashboarditemdistance.h | 2 + .../dashboarditemsimulationincrement.cpp | 38 ++++++++++++++++--- .../dashboarditemsimulationincrement.h | 2 + 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 64ce6ab217..d5cd9e4879 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -82,6 +82,14 @@ namespace { "If a scene graph node is selected as type, this value specifies the name of the " "node that is to be used as the destination for computing the distance." }; + + static const openspace::properties::Property::PropertyInfo SimplificationInfo = { + "Simplification", + "Simplification", + "If this value is enabled, the distace is displayed in nuanced units, such as " + "km, AU, light years, parsecs, etc. If this value is disabled, it is always " + "displayed in meters." + }; } // namespace namespace openspace { @@ -136,6 +144,12 @@ documentation::Documentation DashboardItemDistance::Documentation() { new StringVerifier, Optional::Yes, DestinationNodeNameInfo.description + }, + { + SimplificationInfo.identifier, + new BoolVerifier, + Optional::Yes, + SimplificationInfo.description } } }; @@ -145,6 +159,7 @@ DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary) : DashboardItem("Distance") , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) + , _doSimplification(SimplificationInfo, true) , _source{ properties::OptionProperty( SourceTypeInfo, @@ -288,6 +303,11 @@ DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary) } addProperty(_destination.nodeName); + if (dictionary.hasKey(SimplificationInfo.identifier)) { + _doSimplification = dictionary.value(SimplificationInfo.identifier); + } + addProperty(_doSimplification); + _font = OsEng.fontManager().font(_fontName, _fontSize); } @@ -354,8 +374,12 @@ void DashboardItemDistance::render(glm::vec2& penPosition) { _source ); - double distance = glm::length(sourceInfo.first - destinationInfo.first); - std::pair dist = simplifyDistance(distance); + double d = glm::length(sourceInfo.first - destinationInfo.first); + std::pair dist = + _doSimplification.value() ? + simplifyDistance(d) : + std::make_pair(d, d == 1.0 ? std::string("meter") : std::string("meters")); + penPosition.y -= _font->height(); RenderFont( *_font, @@ -369,8 +393,11 @@ void DashboardItemDistance::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemDistance::size() const { - double distance = 1e20; - std::pair dist = simplifyDistance(distance); + double d = glm::length(1e20); + std::pair dist = + _doSimplification.value() ? + simplifyDistance(d) : + std::make_pair(d, d == 1.0 ? std::string("meter") : std::string("meters")); return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( *_font, diff --git a/modules/base/dashboard/dashboarditemdistance.h b/modules/base/dashboard/dashboarditemdistance.h index 13707db606..38667efb82 100644 --- a/modules/base/dashboard/dashboarditemdistance.h +++ b/modules/base/dashboard/dashboarditemdistance.h @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -71,6 +72,7 @@ private: properties::StringProperty _fontName; properties::FloatProperty _fontSize; + properties::BoolProperty _doSimplification; diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 35d19c281f..1740b7b6b9 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -49,6 +49,14 @@ namespace { "Font Size", "This value determines the size of the font that is used to render the date." }; + + static const openspace::properties::Property::PropertyInfo SimplificationInfo = { + "Simplification", + "Time Simplification", + "If this value is enabled, the time is displayed in nuanced units, such as " + "minutes, hours, days, years, etc. If this value is disabled, it is always " + "displayed in seconds." + }; } // namespace namespace openspace { @@ -75,6 +83,12 @@ documentation::Documentation DashboardItemSimulationIncrement::Documentation() { new IntVerifier, Optional::Yes, FontSizeInfo.description + }, + { + SimplificationInfo.identifier, + new BoolVerifier, + Optional::Yes, + SimplificationInfo.description } } }; @@ -85,6 +99,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( : DashboardItem("Simulation Increment") , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) + , _doSimplification(SimplificationInfo, true) { documentation::testSpecificationAndThrow( Documentation(), @@ -110,13 +125,21 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( }); addProperty(_fontSize); + if (dictionary.hasKey(SimplificationInfo.identifier)) { + _doSimplification = dictionary.value(SimplificationInfo.identifier); + } + addProperty(_doSimplification); + _font = OsEng.fontManager().font(_fontName, _fontSize); } void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { - std::pair deltaTime = simplifyTime( - OsEng.timeManager().time().deltaTime() - ); + double t = OsEng.timeManager().time().deltaTime(); + std::pair deltaTime = + _doSimplification.value() ? + simplifyTime(t) : + std::make_pair(t, t == 1.0 ? std::string("second") : std::string("seconds")); + penPosition.y -= _font->height(); RenderFont( *_font, @@ -128,9 +151,12 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemSimulationIncrement::size() const { - std::pair deltaTime = simplifyTime( - OsEng.timeManager().time().deltaTime() - ); + double t = OsEng.timeManager().time().deltaTime(); + std::pair deltaTime = + _doSimplification.value() ? + simplifyTime(t) : + std::make_pair(t, t == 1.0 ? std::string("seconds") : std::string("second")); + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( *_font, "Simulation increment: %.1f %s / second", diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.h b/modules/base/dashboard/dashboarditemsimulationincrement.h index 6d2da47181..905c2cd1c2 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.h +++ b/modules/base/dashboard/dashboarditemsimulationincrement.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul::fontrendering { @@ -51,6 +52,7 @@ public: private: properties::StringProperty _fontName; properties::FloatProperty _fontSize; + properties::BoolProperty _doSimplification; std::shared_ptr _font; }; From 3c284fc908431d1069a7b9ead58fc7e7ec605a08 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 7 Feb 2018 17:47:24 -0500 Subject: [PATCH 016/131] Set the follow focus node rotation distance for the NewHorizons scene to 20 times the planet's radius (closes #480) --- data/assets/newhorizons.scene | 2 ++ 1 file changed, 2 insertions(+) diff --git a/data/assets/newhorizons.scene b/data/assets/newhorizons.scene index 7dc6f9f881..6775c5683a 100644 --- a/data/assets/newhorizons.scene +++ b/data/assets/newhorizons.scene @@ -162,6 +162,8 @@ asset.onInitialize(function () "Pluto", "NewHorizons", "Charon" }) + openspace.setPropertyValueSingle('NavigationHandler.OrbitalNavigator.FollowFocusNodeRotationDistance', 20.000000); + openspace.addVirtualProperty( "BoolProperty", "Show Trails", From 471c030567a6e6045bc3a19200105ec0b23227f8 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Thu, 8 Feb 2018 13:25:39 +0100 Subject: [PATCH 017/131] Fix torrent bug and improve stability of asset loader --- include/openspace/scene/asset.h | 1 + modules/sync/syncmodule.cpp | 5 ++ modules/sync/tasks/syncassettask.cpp | 2 +- modules/sync/torrentclient.cpp | 112 +++++++++++++++++---------- modules/sync/torrentclient.h | 8 +- src/scene/asset.cpp | 13 ++-- src/scene/assetloader.cpp | 16 +++- src/scene/assetmanager.cpp | 1 + 8 files changed, 109 insertions(+), 49 deletions(-) diff --git a/include/openspace/scene/asset.h b/include/openspace/scene/asset.h index 3466aa78f5..020576c9f5 100644 --- a/include/openspace/scene/asset.h +++ b/include/openspace/scene/asset.h @@ -80,6 +80,7 @@ public: State state() const; void addSynchronization(std::shared_ptr synchronization); + void clearSynchronizations(); std::vector> ownSynchronizations() const; void syncStateChanged(ResourceSynchronization::State s); diff --git a/modules/sync/syncmodule.cpp b/modules/sync/syncmodule.cpp index 41aef124a5..40d96048ad 100644 --- a/modules/sync/syncmodule.cpp +++ b/modules/sync/syncmodule.cpp @@ -106,6 +106,11 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) { fTask->registerClass("SyncAssetTask"); _torrentClient.initialize(); + + // Deinitialize + OsEng.registerModuleCallback(OpenSpaceEngine::CallbackOption::Deinitialize, [&] { + _torrentClient.deinitialize(); + }); } std::vector SyncModule::documentations() const { diff --git a/modules/sync/tasks/syncassettask.cpp b/modules/sync/tasks/syncassettask.cpp index 03fe15aaaa..e79c0142d1 100644 --- a/modules/sync/tasks/syncassettask.cpp +++ b/modules/sync/tasks/syncassettask.cpp @@ -68,7 +68,7 @@ void SyncAssetTask::perform(const Task::ProgressCallback & progressCallback) { scripting::ScriptEngine scriptEngine; registerCoreClasses(scriptEngine); - ; + for (OpenSpaceModule* m : OsEng.moduleEngine().modules()) { scriptEngine.addLibrary(m->luaLibrary()); diff --git a/modules/sync/torrentclient.cpp b/modules/sync/torrentclient.cpp index f81260c4b7..a37e2f0663 100644 --- a/modules/sync/torrentclient.cpp +++ b/modules/sync/torrentclient.cpp @@ -30,7 +30,7 @@ namespace { constexpr const char* _loggerCat = "TorrentClient"; - std::chrono::milliseconds PollInterval(200); + std::chrono::milliseconds PollInterval(1000); } // namespace namespace openspace { @@ -53,14 +53,11 @@ TorrentError::TorrentError(std::string component) namespace openspace { TorrentClient::TorrentClient() - : _keepRunning(true) + : _active(false) {} TorrentClient::~TorrentClient() { - std::lock_guard guard(_mutex); - _keepRunning = false; - _torrentThread.join(); - _session = nullptr; + deinitialize(); } void TorrentClient::initialize() { @@ -92,40 +89,65 @@ void TorrentClient::initialize() { _session->listen_on(std::make_pair(20280, 20290), ec); _session->start_upnp(); + _active = true; + _torrentThread = std::thread([this]() { - while (_keepRunning) { + while (_active) { pollAlerts(); - std::this_thread::sleep_for(PollInterval); + std::unique_lock lock(_abortMutex); + _abortNotifier.wait_for(lock, PollInterval); } }); } +void TorrentClient::deinitialize() { + if (!_active) { + return; + } + + _active = false; + _abortNotifier.notify_all(); + if (_torrentThread.joinable()) { + _torrentThread.join(); + } + + std::vector handles = _session->get_torrents(); + for (lt::torrent_handle h : handles) { + _session->remove_torrent(h); + } + _torrents.clear(); + + _session->abort(); + _session = nullptr; +} + void TorrentClient::pollAlerts() { + // Libtorrent does not seem to reliably generate alerts for all added torrents. + // To make sure that the program does not keep waiting for already finished + // downsloads, we go through the whole list of torrents when polling. + // However, in theory, the commented code below should be more efficient: + /* std::vector alerts; { std::lock_guard guard(_mutex); _session->pop_alerts(&alerts); } - - for (lt::alert const* a : alerts) { - //LINFO(a->message()); - // if we receive the finished alert or an error, we're done - if (const lt::torrent_finished_alert* alert = - lt::alert_cast(a)) - { - notify(alert->handle.id()); - } - if (const lt::piece_finished_alert* alert = - lt::alert_cast(a)) - { - notify(alert->handle.id()); - } - if (const lt::torrent_error_alert* alert = - lt::alert_cast(a)) + for (lt::alert* a : alerts) { + if (const lt::torrent_alert* alert = + dynamic_cast(a)) { notify(alert->handle.id()); } } + */ + std::vector handles; + { + std::lock_guard guard(_mutex); + handles = _session->get_torrents(); + } + for (lt::torrent_handle h : handles) { + notify(h.id()); + } } TorrentClient::TorrentId TorrentClient::addTorrentFile(std::string torrentFile, @@ -167,6 +189,11 @@ TorrentClient::TorrentId TorrentClient::addMagnetLink(std::string magnetLink, } libtorrent::error_code ec; libtorrent::add_torrent_params p = libtorrent::parse_magnet_uri(magnetLink, ec); + + if (ec) { + LERROR(magnetLink << ": " << ec.message()); + } + p.save_path = destination; p.storage_mode = libtorrent::storage_mode_allocate; @@ -195,24 +222,29 @@ void TorrentClient::removeTorrent(TorrentId id) { } void TorrentClient::notify(TorrentId id) { - std::lock_guard guard(_mutex); - - auto torrent = _torrents.find(id); - if (torrent == _torrents.end()) { - return; - } - - libtorrent::torrent_handle h = torrent->second.handle; - libtorrent::torrent_status status = h.status(); - + TorrentProgressCallback callback; TorrentProgress progress; - progress.finished = status.is_finished; - progress.nTotalBytesKnown = status.total_wanted > 0; - progress.nTotalBytes = status.total_wanted; - progress.nDownloadedBytes = status.total_wanted_done; + { + std::lock_guard guard(_mutex); - torrent->second.callback(progress); + auto torrent = _torrents.find(id); + if (torrent == _torrents.end()) { + return; + } + + libtorrent::torrent_handle h = torrent->second.handle; + libtorrent::torrent_status status = h.status(); + + progress.finished = status.is_finished; + progress.nTotalBytesKnown = status.total_wanted > 0; + progress.nTotalBytes = status.total_wanted; + progress.nDownloadedBytes = status.total_wanted_done; + + callback = torrent->second.callback; + } + + callback(progress); } } // namespace openspace @@ -227,6 +259,8 @@ TorrentClient::~TorrentClient() {} void TorrentClient::initialize() {} +void TorrentClient::deinitialize() {} + void TorrentClient::pollAlerts() {} TorrentClient::TorrentId TorrentClient::addTorrentFile(std::string, std::string, diff --git a/modules/sync/torrentclient.h b/modules/sync/torrentclient.h index cb9a2158b1..7e82485eb5 100644 --- a/modules/sync/torrentclient.h +++ b/modules/sync/torrentclient.h @@ -57,6 +57,7 @@ public: using TorrentId = int32_t; virtual void initialize() = 0; + virtual void deinitialize() = 0; virtual TorrentId addTorrentFile(std::string torrentFile, std::string destination, TorrentProgressCallback cb) = 0; @@ -78,6 +79,7 @@ public: #include #include #include +#include #include #include "libtorrent/torrent_handle.hpp" @@ -92,6 +94,7 @@ public: virtual ~TorrentClient(); void initialize() override; + void deinitialize() override; TorrentId addTorrentFile(std::string torrentFile, std::string destination, TorrentProgressCallback cb) override; @@ -116,7 +119,9 @@ private: std::unique_ptr _session; std::thread _torrentThread; std::mutex _mutex; - std::atomic_bool _keepRunning; + std::atomic_bool _active; + std::mutex _abortMutex; + std::condition_variable _abortNotifier; }; } // namespace openspace @@ -131,6 +136,7 @@ public: virtual ~TorrentClient(); void initialize() override; + void deinitialize() override; TorrentId addTorrentFile(std::string torrentFile, std::string destination, TorrentProgressCallback cb) override; diff --git a/src/scene/asset.cpp b/src/scene/asset.cpp index 8ab5ae24ae..ed9993c18d 100644 --- a/src/scene/asset.cpp +++ b/src/scene/asset.cpp @@ -80,12 +80,7 @@ Asset::Asset(AssetLoader* loader, , _assetPath(assetPath) {} -Asset::~Asset() { - for (const SynchronizationWatcher::WatchHandle& h : _syncWatches) { - _synchronizationWatcher->unwatchSynchronization(h); - } - _loader->untrackAsset(this); -} +Asset::~Asset() {} std::string Asset::resolveLocalResource(std::string resourceName) { std::string currentAssetDirectory = assetDirectory(); @@ -186,6 +181,12 @@ void Asset::addSynchronization(std::shared_ptr synchron _syncWatches.push_back(watch); } +void Asset::clearSynchronizations() { + for (const SynchronizationWatcher::WatchHandle& h : _syncWatches) { + _synchronizationWatcher->unwatchSynchronization(h); + } +} + void Asset::syncStateChanged(ResourceSynchronization::State state) { if (state == ResourceSynchronization::State::Resolved) { diff --git a/src/scene/assetloader.cpp b/src/scene/assetloader.cpp index 0642694ac5..0ac7d72549 100644 --- a/src/scene/assetloader.cpp +++ b/src/scene/assetloader.cpp @@ -106,6 +106,7 @@ AssetLoader::AssetLoader(ghoul::lua::LuaState& luaState, AssetLoader::~AssetLoader() { _currentAsset = nullptr; _rootAsset = nullptr; + luaL_unref(*_luaState, LUA_REGISTRYINDEX, _assetsTableRef); } void AssetLoader::trackAsset(std::shared_ptr asset) { @@ -279,14 +280,17 @@ void AssetLoader::unloadAsset(std::shared_ptr asset) { luaL_unref(*_luaState, LUA_REGISTRYINDEX, ref); } } - _onDependencyInitializationFunctionRefs[asset.get()].clear(); + _onDependencyInitializationFunctionRefs.erase(asset.get()); for (const auto& it : _onDependencyDeinitializationFunctionRefs[asset.get()]) { for (int ref : it.second) { luaL_unref(*_luaState, LUA_REGISTRYINDEX, ref); } } - _onDependencyDeinitializationFunctionRefs[asset.get()].clear(); + _onDependencyDeinitializationFunctionRefs.erase(asset.get()); + + asset->clearSynchronizations(); + untrackAsset(asset.get()); } std::string AssetLoader::generateAssetPath(const std::string& baseDirectory, @@ -484,6 +488,8 @@ void AssetLoader::callOnInitialize(Asset* asset) { luaL_checkstring(*_luaState, -1) ); } + // Clean up lua stack, in case the pcall left anything there. + lua_settop(*_luaState, 0); } } @@ -497,6 +503,8 @@ void AssetLoader::callOnDeinitialize(Asset * asset) { luaL_checkstring(*_luaState, -1) ); } + // Clean up lua stack, in case the pcall left anything there. + lua_settop(*_luaState, 0); } } @@ -509,6 +517,8 @@ void AssetLoader::callOnDependencyInitialize(Asset* asset, Asset* dependant) { asset->assetFilePath() + ": " + luaL_checkstring(*_luaState, -1) ); } + // Clean up lua stack, in case the pcall left anything there. + lua_settop(*_luaState, 0); } // Potential Todo: // Call dependency->onInitialize with the asset table @@ -525,6 +535,8 @@ void AssetLoader::callOnDependencyDeinitialize(Asset* asset, Asset* dependant) { asset->assetFilePath() + ": " + luaL_checkstring(*_luaState, -1) ); } + // Clean up lua stack, in case the pcall left anything there. + lua_settop(*_luaState, 0); } } diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index f810038df9..7f8669ecdd 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -53,6 +53,7 @@ void AssetManager::initialize() { void AssetManager::deinitialize() { _assetLoader->rootAsset()->deinitialize(); + _assetLoader->rootAsset()->unload(); _assetLoader->removeAssetListener(this); _assetLoader = nullptr; } From 7f6f04df5b11a2f30f3178d786e57064da4fd099 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 8 Feb 2018 09:54:38 -0500 Subject: [PATCH 018/131] Update Kameleon submodule --- modules/kameleon/ext/kameleon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/kameleon/ext/kameleon b/modules/kameleon/ext/kameleon index 3de739a553..1b4549edc7 160000 --- a/modules/kameleon/ext/kameleon +++ b/modules/kameleon/ext/kameleon @@ -1 +1 @@ -Subproject commit 3de739a55387051fb6fdfd327ad761dffa317420 +Subproject commit 1b4549edc74ef371730ef9d39c1ffa0efe90a985 From d9f874472eb447ed2e6c623cab9edac3c160cd3c Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 8 Feb 2018 10:19:53 -0500 Subject: [PATCH 019/131] Add comment informing the user of not using single backslashes in paths --- data/assets/customization/globebrowsing.asset | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/assets/customization/globebrowsing.asset b/data/assets/customization/globebrowsing.asset index 81fabf615c..105a2b18b0 100644 --- a/data/assets/customization/globebrowsing.asset +++ b/data/assets/customization/globebrowsing.asset @@ -2,7 +2,11 @@ -- example: -- asset.require('../scene/solarsystem/planets/mars/mars') --- Add folders to this list that contain .info files describing HiRISE patches +-- Add folders to this list that contain .info files describing patches +-- OBS: Even on Windows, you have to use forward slashes (/) or double backslashes (\\) +-- rather than single backslashes (\) as they are otherwise interpreted as escape +-- sequences +-- For example: C:/OpenSpace or C:\\OpenSpace rather than C:\OpenSpace local vrt_folders = { Mars = { -- Add folders here whose contents will be automatically added to the Mars globe From d5f158ad0b9463d7bf91d1007464fe878beeb9f8 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 8 Feb 2018 12:18:38 -0500 Subject: [PATCH 020/131] Add the ability to DashboardItemSimulationIncrement and DashboardItemDistance to specify fixed unit --- include/openspace/util/distanceconversion.h | 34 ++- include/openspace/util/timeconversion.h | 27 +- .../base/dashboard/dashboarditemdistance.cpp | 73 +++++- .../base/dashboard/dashboarditemdistance.h | 1 + .../dashboarditemsimulationincrement.cpp | 75 +++++- .../dashboarditemsimulationincrement.h | 2 + modules/imgui/src/guispacetimecomponent.cpp | 241 ++++++++++-------- src/util/distanceconversion.cpp | 166 ++++++++++-- src/util/timeconversion.cpp | 116 ++++++++- 9 files changed, 588 insertions(+), 147 deletions(-) diff --git a/include/openspace/util/distanceconversion.h b/include/openspace/util/distanceconversion.h index c8a2125793..27a36840f3 100644 --- a/include/openspace/util/distanceconversion.h +++ b/include/openspace/util/distanceconversion.h @@ -25,12 +25,44 @@ #ifndef __OPENSPACE_CORE___DISTANCECONVERSION___H__ #define __OPENSPACE_CORE___DISTANCECONVERSION___H__ +#include #include #include namespace openspace { -std::pair simplifyDistance(double meters); +enum class DistanceUnit { + Nanometer = 0, + Micrometer, + Millimeter, + Meter, + Kilometer, + AU, + Lighthour, + Lightday, + Lightmonth, + Lightyear, + Parsec, + Kiloparsec, + Megaparsec, + Gigaparsec +}; +constexpr std::array(DistanceUnit::Gigaparsec) + 1> +DistanceUnits = { + DistanceUnit::Nanometer, DistanceUnit::Micrometer, DistanceUnit::Millimeter, + DistanceUnit::Meter, DistanceUnit::Kilometer, DistanceUnit::AU, + DistanceUnit::Lighthour, DistanceUnit::Lightday, DistanceUnit::Lightmonth, + DistanceUnit::Lightyear, DistanceUnit::Parsec, DistanceUnit::Kiloparsec, + DistanceUnit::Megaparsec, DistanceUnit::Gigaparsec +}; + +std::pair simplifyDistance(double meters, + bool forceSingularForm = false); + +double convertDistance(double meters, DistanceUnit requestedUnit); + +std::string nameForDistanceUnit(DistanceUnit unit, bool pluralForm = false); +DistanceUnit distanceUnitFromString(const std::string& unit); } // namespace openspace diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index f90760219e..6e5f349936 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -25,12 +25,37 @@ #ifndef __OPENSPACE_CORE___TIMECONVERSION___H__ #define __OPENSPACE_CORE___TIMECONVERSION___H__ +#include #include #include namespace openspace { -std::pair simplifyTime(double seconds); +enum class TimeUnit { + Nanosecond = 0, + Microsecond, + Millisecond, + Second, + Minute, + Hour, + Day, + Month, + Year +}; +constexpr std::array(TimeUnit::Year) + 1> +TimeUnits = { + TimeUnit::Nanosecond, TimeUnit::Microsecond, TimeUnit::Millisecond, + TimeUnit::Second, TimeUnit::Minute, TimeUnit::Hour, TimeUnit::Day, + TimeUnit::Month, TimeUnit::Year +}; + +std::pair simplifyTime(double seconds, + bool forceSingularForm = false); + +double convertTime(double seconds, TimeUnit requestedUnit); + +std::string nameForTimeUnit(TimeUnit unit, bool pluralForm = false); +TimeUnit timeUnitFromString(const std::string& unit); } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index d5cd9e4879..2d8c0aa9ff 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -90,6 +90,26 @@ namespace { "km, AU, light years, parsecs, etc. If this value is disabled, it is always " "displayed in meters." }; + + static const openspace::properties::Property::PropertyInfo RequestedUnitInfo = { + "RequestedUnit", + "Requested Unit", + "If the simplification is disabled, this distance unit is used as a destination " + "to convert the meters into." + }; + + std::vector unitList() { + std::vector res(openspace::DistanceUnits.size()); + std::transform( + openspace::DistanceUnits.begin(), + openspace::DistanceUnits.end(), + res.begin(), + [](openspace::DistanceUnit unit) -> std::string { + return nameForDistanceUnit(unit); + } + ); + return res; + } } // namespace namespace openspace { @@ -150,6 +170,12 @@ documentation::Documentation DashboardItemDistance::Documentation() { new BoolVerifier, Optional::Yes, SimplificationInfo.description + }, + { + RequestedUnitInfo.identifier, + new StringInListVerifier(unitList()), + Optional::Yes, + RequestedUnitInfo.description } } }; @@ -160,6 +186,7 @@ DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) , _doSimplification(SimplificationInfo, true) + , _requestedUnit(RequestedUnitInfo, properties::OptionProperty::DisplayType::Dropdown) , _source{ properties::OptionProperty( SourceTypeInfo, @@ -306,8 +333,28 @@ DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary) if (dictionary.hasKey(SimplificationInfo.identifier)) { _doSimplification = dictionary.value(SimplificationInfo.identifier); } + _doSimplification.onChange([this]() { + if (_doSimplification) { + _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); + } + else { + _requestedUnit.setVisibility(properties::Property::Visibility::User); + } + }); addProperty(_doSimplification); + for (DistanceUnit u : DistanceUnits) { + _requestedUnit.addOption(static_cast(u), nameForDistanceUnit(u)); + } + _requestedUnit = static_cast(DistanceUnit::Meter); + if (dictionary.hasKey(RequestedUnitInfo.identifier)) { + std::string value = dictionary.value(RequestedUnitInfo.identifier); + DistanceUnit unit = distanceUnitFromString(value); + _requestedUnit = static_cast(unit); + } + _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); + addProperty(_requestedUnit); + _font = OsEng.fontManager().font(_fontName, _fontSize); } @@ -375,10 +422,15 @@ void DashboardItemDistance::render(glm::vec2& penPosition) { ); double d = glm::length(sourceInfo.first - destinationInfo.first); - std::pair dist = - _doSimplification.value() ? - simplifyDistance(d) : - std::make_pair(d, d == 1.0 ? std::string("meter") : std::string("meters")); + std::pair dist; + if (_doSimplification) { + dist = simplifyDistance(d); + } + else { + DistanceUnit unit = static_cast(_requestedUnit.value()); + double convertedD = convertDistance(d, unit); + dist = { convertedD, nameForDistanceUnit(unit, convertedD != 1.0) }; + } penPosition.y -= _font->height(); RenderFont( @@ -394,10 +446,15 @@ void DashboardItemDistance::render(glm::vec2& penPosition) { glm::vec2 DashboardItemDistance::size() const { double d = glm::length(1e20); - std::pair dist = - _doSimplification.value() ? - simplifyDistance(d) : - std::make_pair(d, d == 1.0 ? std::string("meter") : std::string("meters")); + std::pair dist; + if (_doSimplification) { + dist = simplifyDistance(d); + } + else { + DistanceUnit unit = static_cast(_requestedUnit.value()); + double convertedD = convertDistance(d, unit); + dist = { convertedD, nameForDistanceUnit(unit, convertedD != 1.0) }; + } return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( *_font, diff --git a/modules/base/dashboard/dashboarditemdistance.h b/modules/base/dashboard/dashboarditemdistance.h index 38667efb82..e482690d49 100644 --- a/modules/base/dashboard/dashboarditemdistance.h +++ b/modules/base/dashboard/dashboarditemdistance.h @@ -73,6 +73,7 @@ private: properties::StringProperty _fontName; properties::FloatProperty _fontSize; properties::BoolProperty _doSimplification; + properties::OptionProperty _requestedUnit; diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 1740b7b6b9..6126e62476 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -57,6 +57,26 @@ namespace { "minutes, hours, days, years, etc. If this value is disabled, it is always " "displayed in seconds." }; + + static const openspace::properties::Property::PropertyInfo RequestedUnitInfo = { + "RequestedUnit", + "Requested Unit", + "If the simplification is disabled, this time unit is used as a destination to " + "convert the seconds into." + }; + + std::vector unitList() { + std::vector res(openspace::TimeUnits.size()); + std::transform( + openspace::TimeUnits.begin(), + openspace::TimeUnits.end(), + res.begin(), + [](openspace::TimeUnit unit) -> std::string { + return nameForTimeUnit(unit); + } + ); + return res; + } } // namespace namespace openspace { @@ -89,6 +109,12 @@ documentation::Documentation DashboardItemSimulationIncrement::Documentation() { new BoolVerifier, Optional::Yes, SimplificationInfo.description + }, + { + RequestedUnitInfo.identifier, + new StringInListVerifier(unitList()), + Optional::Yes, + RequestedUnitInfo.description } } }; @@ -100,6 +126,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) , _doSimplification(SimplificationInfo, true) + , _requestedUnit(RequestedUnitInfo, properties::OptionProperty::DisplayType::Dropdown) { documentation::testSpecificationAndThrow( Documentation(), @@ -128,18 +155,43 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( if (dictionary.hasKey(SimplificationInfo.identifier)) { _doSimplification = dictionary.value(SimplificationInfo.identifier); } + _doSimplification.onChange([this]() { + if (_doSimplification) { + _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); + } + else { + _requestedUnit.setVisibility(properties::Property::Visibility::User); + } + }); addProperty(_doSimplification); + for (TimeUnit u : TimeUnits) { + _requestedUnit.addOption(static_cast(u), nameForTimeUnit(u)); + } + _requestedUnit = static_cast(TimeUnit::Second); + if (dictionary.hasKey(RequestedUnitInfo.identifier)) { + std::string value = dictionary.value(RequestedUnitInfo.identifier); + TimeUnit unit = timeUnitFromString(value); + _requestedUnit = static_cast(unit); + } + _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); + addProperty(_requestedUnit); + _font = OsEng.fontManager().font(_fontName, _fontSize); } void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { double t = OsEng.timeManager().time().deltaTime(); - std::pair deltaTime = - _doSimplification.value() ? - simplifyTime(t) : - std::make_pair(t, t == 1.0 ? std::string("second") : std::string("seconds")); - + std::pair deltaTime; + if (_doSimplification) { + deltaTime = simplifyTime(t); + } + else { + TimeUnit unit = static_cast(_requestedUnit.value()); + double convertedT = convertTime(t, unit); + deltaTime = { convertedT, nameForTimeUnit(unit, convertedT != 1.0) }; + } + penPosition.y -= _font->height(); RenderFont( *_font, @@ -152,10 +204,15 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { glm::vec2 DashboardItemSimulationIncrement::size() const { double t = OsEng.timeManager().time().deltaTime(); - std::pair deltaTime = - _doSimplification.value() ? - simplifyTime(t) : - std::make_pair(t, t == 1.0 ? std::string("seconds") : std::string("second")); + std::pair deltaTime; + if (_doSimplification) { + deltaTime = simplifyTime(t); + } + else { + TimeUnit unit = static_cast(_requestedUnit.value()); + double convertedT = convertTime(t, unit); + deltaTime = { convertedT, nameForTimeUnit(unit, convertedT != 1.0) }; + } return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( *_font, diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.h b/modules/base/dashboard/dashboarditemsimulationincrement.h index 905c2cd1c2..aa16677579 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.h +++ b/modules/base/dashboard/dashboarditemsimulationincrement.h @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -53,6 +54,7 @@ private: properties::StringProperty _fontName; properties::FloatProperty _fontSize; properties::BoolProperty _doSimplification; + properties::OptionProperty _requestedUnit; std::shared_ptr _font; }; diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index 3c6abd1328..c432cedfaa 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -28,12 +28,13 @@ #include #include -#include -#include #include #include #include #include +#include +#include +#include #include @@ -277,36 +278,72 @@ void GuiSpaceTimeComponent::render() { showTooltip("OBS: A month here equals 30 days.", _tooltipDelay); ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f); +// +// { +// float deltaTime = static_cast(OsEng.timeManager().time().deltaTime()); +// //std::pair dt = simplifyTime(deltaTime, true); +// +// +// //float val = dt.first; +// ImGui::InputFloat("", &val); +// +// //bool ImGui::Combo(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items) +// +// const char* TimeSteps = "nanoseconds / second\0microseconds / second\0\ +//milliseconds / second\0seconds / second\0minutes / second\0hours / second\0days / second\ +//months / second\0years / second\0"; +// +// std::string nodeNames = ""; +// for (SceneGraphNode* n : nodes) { +// nodeNames += n->name() + '\0'; +// } +// +// auto iCurrentFocus = std::find(nodes.begin(), nodes.end(), currentFocus); +// if (!nodes.empty()) { +// // Only check if we found the current focus node if we have any nodes at all +// // only then it would be a real error +// ghoul_assert(iCurrentFocus != nodes.end(), "Focus node not found"); +// } +// int currentPosition = static_cast(std::distance(nodes.begin(), iCurrentFocus)); +// +// +// bool hasChanged = ImGui::Combo("", ); +// +// bool hasChanged = ImGui::Combo("", ¤tPosition, nodeNames.c_str()); +// +// } +// - bool minMaxChanged = ImGui::InputFloat( - "Time slider range", - &_localMinMaxDeltatime - ); - if (minMaxChanged) { - _minMaxDeltaTime = _localMinMaxDeltatime; - } - float deltaTime = static_cast(OsEng.timeManager().time().deltaTime()); - bool deltaChanged = ImGui::SliderFloat( - "Delta Time", - &deltaTime, - -_minMaxDeltaTime, - _minMaxDeltaTime, - "%.6f", - 5.f - ); - if (deltaChanged) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - showTooltip( - "This determines the simulation time increment, that is the passage of time in " - "OpenSpace relative to a wall clock. Times are expressed as simulation time / " - "real world time.", - _tooltipDelay - ); + //bool minMaxChanged = ImGui::InputFloat( + // "Time slider range", + // &_localMinMaxDeltatime + //); + //if (minMaxChanged) { + // _minMaxDeltaTime = _localMinMaxDeltatime; + //} + + //float deltaTime = static_cast(OsEng.timeManager().time().deltaTime()); + //bool deltaChanged = ImGui::SliderFloat( + // "Delta Time", + // &deltaTime, + // -_minMaxDeltaTime, + // _minMaxDeltaTime, + // "%.6f", + // 5.f + //); + //if (deltaChanged) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //showTooltip( + // "This determines the simulation time increment, that is the passage of time in " + // "OpenSpace relative to a wall clock. Times are expressed as simulation time / " + // "real world time.", + // _tooltipDelay + //); bool isPaused = OsEng.timeManager().time().paused(); @@ -321,87 +358,87 @@ void GuiSpaceTimeComponent::render() { ); } - bool minusDs = ImGui::Button("-1d/s"); - if (minusDs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(-24 * 60 * 60) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool minusDs = ImGui::Button("-1d/s"); + //if (minusDs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(-24 * 60 * 60) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool minusHs = ImGui::Button("-1h/s"); - if (minusHs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(-60 * 60) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool minusHs = ImGui::Button("-1h/s"); + //if (minusHs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(-60 * 60) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool minusMs = ImGui::Button("-1min/s"); - if (minusMs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(-60) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool minusMs = ImGui::Button("-1min/s"); + //if (minusMs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(-60) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool minusSs = ImGui::Button("-1s/s"); - if (minusSs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(-1) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool minusSs = ImGui::Button("-1s/s"); + //if (minusSs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(-1) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool zero = ImGui::Button("0"); - if (zero) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(0) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool zero = ImGui::Button("0"); + //if (zero) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(0) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool plusSs = ImGui::Button("+1s/s"); - if (plusSs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(1) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool plusSs = ImGui::Button("+1s/s"); + //if (plusSs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(1) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool plusMs = ImGui::Button("1min/s"); - if (plusMs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(60) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool plusMs = ImGui::Button("1min/s"); + //if (plusMs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(60) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool plusHs = ImGui::Button("1h/s"); - if (plusHs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(60 * 60) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool plusHs = ImGui::Button("1h/s"); + //if (plusHs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(60 * 60) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); - bool plusDs = ImGui::Button("1d/s"); - if (plusDs) { - OsEng.scriptEngine().queueScript( - "openspace.time.setDeltaTime(" + std::to_string(24 * 60 * 60) + ")", - scripting::ScriptEngine::RemoteScripting::Yes - ); - } - ImGui::SameLine(); + //bool plusDs = ImGui::Button("1d/s"); + //if (plusDs) { + // OsEng.scriptEngine().queueScript( + // "openspace.time.setDeltaTime(" + std::to_string(24 * 60 * 60) + ")", + // scripting::ScriptEngine::RemoteScripting::Yes + // ); + //} + //ImGui::SameLine(); ImGui::End(); diff --git a/src/util/distanceconversion.cpp b/src/util/distanceconversion.cpp index ba7eeb5d05..e0e53243c6 100644 --- a/src/util/distanceconversion.cpp +++ b/src/util/distanceconversion.cpp @@ -27,60 +27,75 @@ #include #include +#include + +namespace { + constexpr bool equal(char const* lhs, char const* rhs) { + while (*lhs || *rhs) { + if (*lhs++ != *rhs++) { + return false; + } + } + return true; + } +} namespace openspace { -std::pair simplifyDistance(double meters) { +std::pair simplifyDistance(double meters, bool forceSingularForm) { double metersVal = glm::abs(meters); if (metersVal == 0.0) { - return { 0.0, "meters"}; + return { 0.0, forceSingularForm ? "meter" : "meters"}; } else if (metersVal > 1e-3 && metersVal < 1e3) { - return { meters, meters == 1.0 ? "meter" : "meters" }; + return { meters, (meters == 1.0 || forceSingularForm) ? "meter" : "meters" }; } if (metersVal < 1e-9) { - return { meters / 1e-9, (meters / 1e-9) == 1.0 ? "nanometer" : "nanometers" }; + double val = meters / 1e-9; + return { val, (val == 1.0 || forceSingularForm) ? "nanometer" : "nanometers" }; } else if (metersVal < 1e-6) { - return { meters / 1e-6, (meters / 1e-6) == 1.0 ? "micrometer" : "micrometers" }; + double val = meters / 1e-6; + return { val, (val == 1.0 || forceSingularForm) ? "micrometer" : "micrometers" }; } else if (metersVal < 1e-3) { - return { meters / 1e-3, (meters / 1e-3) == 1.0 ? "millimeter" : "millimeters" }; + double val = meters / 1e-3; + return { val, (val == 1.0 || forceSingularForm) ? "millimeter" : "millimeters" }; } if (metersVal > (1e9 * distanceconstants::Parsec)) { double val = meters / (1e9 * distanceconstants::Parsec); - return { val, val == 1.0 ? "Gigaparsec" : "Gigaparsecs" }; + return { val, (val == 1.0 || forceSingularForm) ? "Gigaparsec" : "Gigaparsecs" }; } else if (metersVal > (1e6 * distanceconstants::Parsec)) { double val = meters / (1e6 * distanceconstants::Parsec); - return { val, val == 1.0 ? "Megaparsec" : "Megaparsecs" }; + return { val, (val == 1.0 || forceSingularForm) ? "Megaparsec" : "Megaparsecs" }; } else if (metersVal > (1e3 * distanceconstants::Parsec)) { double val = meters / (1e3 * distanceconstants::Parsec); - return { val, val == 1.0 ? "Kiloparsec" : "Kiloparsecs" }; + return { val, (val == 1.0 || forceSingularForm) ? "Kiloparsec" : "Kiloparsecs" }; } else if (metersVal > distanceconstants::Parsec) { double val = meters / distanceconstants::Parsec; - return { val, val == 1.0 ? "Parsec" : "Parsecs" }; + return { val, (val == 1.0 || forceSingularForm) ? "Parsec" : "Parsecs" }; } else if (metersVal > distanceconstants::LightYear) { double val = meters / distanceconstants::LightYear; - return { val, val == 1.0 ? "Lightyear" : "Lightyears" }; + return { val, (val == 1.0 || forceSingularForm) ? "Lightyear" : "Lightyears" }; } else if (metersVal > distanceconstants::LightMonth) { double val = meters / distanceconstants::LightMonth; - return { val, val == 1.0 ? "Lightmonth" : "Lightmonths" }; + return { val, (val == 1.0 || forceSingularForm) ? "Lightmonth" : "Lightmonths" }; } else if (metersVal > distanceconstants::LightDay) { double val = meters / distanceconstants::LightDay; - return { val, val == 1.0 ? "Lightday" : "Lightdays" }; + return { val, (val == 1.0 || forceSingularForm) ? "Lightday" : "Lightdays" }; } else if (metersVal > distanceconstants::LightHour) { - double val = meters / distanceconstants::LightDay; - return { val, val == 1.0 ? "Lighthour" : "Lighthours" }; + double val = meters / distanceconstants::LightHour; + return { val, (val == 1.0 || forceSingularForm) ? "Lighthour" : "Lighthours" }; } else if (metersVal > distanceconstants::AstronomicalUnit) { return { meters / distanceconstants::AstronomicalUnit, "AU" }; @@ -90,4 +105,125 @@ std::pair simplifyDistance(double meters) { } } + +double convertDistance(double meters, DistanceUnit requestedUnit) { + switch (requestedUnit) { + case DistanceUnit::Nanometer: + return meters / 1e-9; + case DistanceUnit::Micrometer: + return meters / 1e-6; + case DistanceUnit::Millimeter: + return meters / 1e-3; + case DistanceUnit::Meter: + return meters; + case DistanceUnit::Kilometer: + return meters / 1000.0; + case DistanceUnit::AU: + return meters / distanceconstants::AstronomicalUnit; + case DistanceUnit::Lighthour: + return meters / distanceconstants::LightHour; + case DistanceUnit::Lightday: + return meters / distanceconstants::LightDay; + case DistanceUnit::Lightmonth: + return meters / distanceconstants::LightMonth; + case DistanceUnit::Lightyear: + return meters / distanceconstants::LightYear; + case DistanceUnit::Parsec: + return meters / distanceconstants::Parsec; + case DistanceUnit::Kiloparsec: + return meters / (1e3 * distanceconstants::Parsec); + case DistanceUnit::Megaparsec: + return meters / (1e6 * distanceconstants::Parsec); + case DistanceUnit::Gigaparsec: + return meters / (1e9 * distanceconstants::Parsec); + default: + throw ghoul::MissingCaseException(); + } +} + +std::string nameForDistanceUnit(DistanceUnit unit, bool pluralForm) { + switch (unit) { + case DistanceUnit::Nanometer: + return pluralForm ? "nanometers" : "nanometer"; + case DistanceUnit::Micrometer: + return pluralForm ? "micrometers" : "micrometer"; + case DistanceUnit::Millimeter: + return pluralForm ? "millimeters" : "millimeter"; + case DistanceUnit::Meter: + return pluralForm ? "meters" : "meter"; + case DistanceUnit::Kilometer: + return "km"; + case DistanceUnit::AU: + return "AU"; + case DistanceUnit::Lighthour: + return pluralForm ? "lighthours" : "lighthour"; + case DistanceUnit::Lightday: + return pluralForm ? "lightdays" : "lightday"; + case DistanceUnit::Lightmonth: + return pluralForm ? "lightmonths" : "lightmonth"; + case DistanceUnit::Lightyear: + return pluralForm ? "lightyears" : "lightyear"; + case DistanceUnit::Parsec: + return pluralForm ? "parsecs" : "parsec"; + case DistanceUnit::Kiloparsec: + return pluralForm ? "kiloparsecs" : "kiloparsec"; + case DistanceUnit::Megaparsec: + return pluralForm ? "megaparsecs" : "megaparsec"; + case DistanceUnit::Gigaparsec: + return pluralForm ? "gigaparsecs" : "gigaparsec"; + default: + throw ghoul::MissingCaseException(); + } +} + + +DistanceUnit distanceUnitFromString(const std::string& unit) { + if (unit == "nanometer" || unit == "nanometers") { + return DistanceUnit::Nanometer; + } + else if (unit == "micrometer" || unit == "micrometers") { + return DistanceUnit::Micrometer; + } + else if (unit == "millimeter" || unit == "millimeters") { + return DistanceUnit::Millimeter; + } + else if (unit == "meter" || unit == "meters") { + return DistanceUnit::Meter; + } + else if (unit == "km") { + return DistanceUnit::Kilometer; + } + else if (unit == "AU") { + return DistanceUnit::AU; + } + else if (unit == "lighthour" || unit == "lighthours") { + return DistanceUnit::Lighthour; + } + else if (unit == "lightday" || unit == "lightdays") { + return DistanceUnit::Lightday; + } + else if (unit == "lightmonth" || unit == "lightmonths") { + return DistanceUnit::Lightmonth; + } + else if (unit == "lightyear" || unit == "lightyears") { + return DistanceUnit::Lightyear; + } + else if (unit == "parsec" || unit == "parsecs") { + return DistanceUnit::Parsec; + } + else if (unit == "kiloparsec" || unit == "kiloparsecs") { + return DistanceUnit::Kiloparsec; + } + else if (unit == "megaparsec" || unit == "megaparsecs") { + return DistanceUnit::Megaparsec; + } + else if (unit == "gigaparsec" || unit == "gigaparsecs") { + return DistanceUnit::Gigaparsec; + } + else { + throw ghoul::MissingCaseException(); + } +} + + } // namespace openspace diff --git a/src/util/timeconversion.cpp b/src/util/timeconversion.cpp index 4971165a5c..fd2b2d67ca 100644 --- a/src/util/timeconversion.cpp +++ b/src/util/timeconversion.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -44,46 +45,139 @@ namespace { namespace openspace { -std::pair simplifyTime(double seconds) { +std::pair simplifyTime(double seconds, bool forceSingularForm) { double secondsVal = glm::abs(seconds); - if (secondsVal > 1e-3 && secondsVal < SecondsPerMinute) { - return { seconds, seconds == 1.0 ? "second" : "seconds" }; + if (secondsVal == 0.0) { + return { 0.0, forceSingularForm ? "second" : "seconds" }; + } + else if (secondsVal > 1e-3 && secondsVal < SecondsPerMinute) { + return { seconds, (seconds == 1.0 || forceSingularForm) ? "second" : "seconds" }; } if (secondsVal <= 1e-9) { double val = seconds / 1e-9; - return { val, val == 1.0 ? "nanosecond" : "nanoseconds" }; + return { val, (val == 1.0 || forceSingularForm) ? "nanosecond" : "nanoseconds" }; } else if (secondsVal <= 1e-6) { double val = seconds / 1e-6; - return { val, val == 1.0 ? "microsecond" : "microseconds" }; + return { + val, + (val == 1.0 || forceSingularForm) ? "microsecond" : "microseconds" + }; } else if (secondsVal <= 1e-3) { double val = seconds / 1e-3; - return { val, val == 1.0 ? "millisecond" : "milliseconds" }; + return { + val, + (val == 1.0 || forceSingularForm) ? "millisecond" : "milliseconds" + }; } if (secondsVal >= SecondsPerYear) { double val = seconds / SecondsPerYear; - return { val, val == 1.0 ? "year" : "years" }; + return { val, (val == 1.0 || forceSingularForm) ? "year" : "years" }; } else if (secondsVal >= SecondsPerMonth) { double val = seconds / SecondsPerMonth; - return { val, val == 1.0 ? "month" : "months" }; + return { val, (val == 1.0 || forceSingularForm) ? "month" : "months" }; } else if (secondsVal >= SecondsPerDay) { double val = seconds / SecondsPerDay; - return { val, val == 1.0 ? "day" : "days" }; + return { val, (val == 1.0 || forceSingularForm) ? "day" : "days" }; } else if (secondsVal >= SecondsPerHour) { double val = seconds / SecondsPerHour; - return { val, val == 1.0 ? "hour" : "hours" }; + return { val, (val == 1.0 || forceSingularForm) ? "hour" : "hours" }; } else { double val = seconds / SecondsPerMinute; - return { val, val == 1.0 ? "minute" : "minutes" }; + return { val, (val == 1.0 || forceSingularForm) ? "minute" : "minutes" }; } } +double convertTime(double seconds, TimeUnit requestedUnit) { + switch (requestedUnit) { + case TimeUnit::Nanosecond: + return seconds / 1e-9; + case TimeUnit::Microsecond: + return seconds / 1e-6; + case TimeUnit::Millisecond: + return seconds / 1e-3; + case TimeUnit::Second: + return seconds; + case TimeUnit::Minute: + return seconds / SecondsPerMinute; + case TimeUnit::Hour: + return seconds / SecondsPerHour; + case TimeUnit::Day: + return seconds / SecondsPerDay; + case TimeUnit::Month: + return seconds / SecondsPerMonth; + case TimeUnit::Year: + return seconds / SecondsPerYear; + default: + throw ghoul::MissingCaseException(); + } +} + +std::string nameForTimeUnit(TimeUnit unit, bool pluralForm) { + switch (unit) { + case TimeUnit::Nanosecond: + return pluralForm ? "nanoseconds" : "nanosecond"; + case TimeUnit::Microsecond: + return pluralForm ? "microseconds" : "microsecond"; + case TimeUnit::Millisecond: + return pluralForm ? "milliseconds" : "millisecond"; + case TimeUnit::Second: + return pluralForm ? "seconds" : "second"; + case TimeUnit::Minute: + return pluralForm ? "minutes" : "minute"; + case TimeUnit::Hour: + return pluralForm ? "hours" : "hour"; + case TimeUnit::Day: + return pluralForm ? "days" : "day"; + case TimeUnit::Month: + return pluralForm ? "months" : "month"; + case TimeUnit::Year: + return pluralForm ? "years" : "year"; + default: + throw ghoul::MissingCaseException(); + } +} + +TimeUnit timeUnitFromString(const std::string& unit) { + if (unit == "nanosecond" || unit == "nanoseconds") { + return TimeUnit::Nanosecond; + } + else if (unit == "microsecond" || unit == "microseconds") { + return TimeUnit::Microsecond; + } + else if (unit == "millisecond" || unit == "milliseconds") { + return TimeUnit::Millisecond; + } + else if (unit == "second" || unit == "seconds") { + return TimeUnit::Second; + } + else if (unit == "minute" || unit == "minutes") { + return TimeUnit::Minute; + } + else if (unit == "hour" || unit == "hours") { + return TimeUnit::Hour; + } + else if (unit == "day" || unit == "days") { + return TimeUnit::Day; + } + else if (unit == "month" || unit == "months") { + return TimeUnit::Month; + } + else if (unit == "year" || unit == "years") { + return TimeUnit::Year; + } + else { + throw ghoul::MissingCaseException(); + } +} + + } // namespace openspace From cd33ec06c94cb0c5befd057b467cf01b2b593eac Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 8 Feb 2018 17:42:22 -0500 Subject: [PATCH 021/131] Cleanup of distance and time conversion classes, Modifies GuiSpaceTimeComponent Changed previous slider into text field + dropbox Added acceleration slider Added shuffle slider (closes #479) --- ext/ghoul | 2 +- include/openspace/util/distanceconversion.h | 165 +++++++- include/openspace/util/timeconversion.h | 175 ++++++++- .../base/dashboard/dashboarditemdistance.cpp | 2 +- .../dashboarditemsimulationincrement.cpp | 6 +- modules/imgui/include/guispacetimecomponent.h | 18 +- modules/imgui/src/guispacetimecomponent.cpp | 367 +++++++++++------- src/util/distanceconversion.cpp | 133 ------- src/util/timeconversion.cpp | 101 +---- 9 files changed, 575 insertions(+), 394 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 0830bb186a..2b5e82a6ff 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 0830bb186a10f83d4e7d7791b584a1a7235c2e3c +Subproject commit 2b5e82a6ff061bebd9c8b605160dafc6ade2ad65 diff --git a/include/openspace/util/distanceconversion.h b/include/openspace/util/distanceconversion.h index 27a36840f3..80a3a962da 100644 --- a/include/openspace/util/distanceconversion.h +++ b/include/openspace/util/distanceconversion.h @@ -25,6 +25,11 @@ #ifndef __OPENSPACE_CORE___DISTANCECONVERSION___H__ #define __OPENSPACE_CORE___DISTANCECONVERSION___H__ +#include + +#include +#include + #include #include #include @@ -47,6 +52,39 @@ enum class DistanceUnit { Megaparsec, Gigaparsec }; + +// Assumption: Unit names are sequential in memory +constexpr const char* DistanceUnitNanometer = "nanometer"; +constexpr const char* DistanceUnitMicrometer = "micrometer"; +constexpr const char* DistanceUnitMillimeter = "millimeter"; +constexpr const char* DistanceUnitMeter = "meter"; +constexpr const char* DistanceUnitKilometer = "km"; +constexpr const char* DistanceUnitAU = "AU"; +constexpr const char* DistanceUnitLighthour = "lighthour"; +constexpr const char* DistanceUnitLightday = "lightday"; +constexpr const char* DistanceUnitLightmonth = "lightmonth"; +constexpr const char* DistanceUnitLightyear = "lightyear"; +constexpr const char* DistanceUnitParsec = "parsec"; +constexpr const char* DistanceUnitKiloparsec = "kiloparsec"; +constexpr const char* DistanceUnitMegaparsec = "megaparsec"; +constexpr const char* DistanceUnitGigaparsec = "gigaparsec"; + +// Assumption: Unit names are sequential in memory +constexpr const char* DistanceUnitNanometers = "nanometers"; +constexpr const char* DistanceUnitMicrometers = "micrometers"; +constexpr const char* DistanceUnitMillimeters = "millimeters"; +constexpr const char* DistanceUnitMeters = "meters"; +constexpr const char* DistanceUnitKilometers = "km"; +constexpr const char* DistanceUnitAUs = "AU"; +constexpr const char* DistanceUnitLighthours = "lighthours"; +constexpr const char* DistanceUnitLightdays = "lightdays"; +constexpr const char* DistanceUnitLightmonths = "lightmonths"; +constexpr const char* DistanceUnitLightyears = "lightyears"; +constexpr const char* DistanceUnitParsecs = "parsecs"; +constexpr const char* DistanceUnitKiloparsecs = "kiloparsecs"; +constexpr const char* DistanceUnitMegaparsecs = "megaparsecs"; +constexpr const char* DistanceUnitGigaparsecs = "gigaparsecs"; + constexpr std::array(DistanceUnit::Gigaparsec) + 1> DistanceUnits = { DistanceUnit::Nanometer, DistanceUnit::Micrometer, DistanceUnit::Millimeter, @@ -56,13 +94,132 @@ DistanceUnits = { DistanceUnit::Megaparsec, DistanceUnit::Gigaparsec }; +constexpr std::array(DistanceUnit::Gigaparsec) + 1> +DistanceUnitNamesSingular = { + DistanceUnitNanometer, DistanceUnitMicrometer, DistanceUnitMillimeter, + DistanceUnitMeter, DistanceUnitKilometer, DistanceUnitAU, DistanceUnitLighthour, + DistanceUnitLightday, DistanceUnitLightmonth, DistanceUnitLightyear, + DistanceUnitParsec, DistanceUnitKiloparsec, DistanceUnitMegaparsec, + DistanceUnitGigaparsec +}; + +constexpr std::array(DistanceUnit::Gigaparsec) + 1> +DistanceUnitNamesPlural = { + DistanceUnitNanometers, DistanceUnitMicrometers, DistanceUnitMillimeters, + DistanceUnitMeters, DistanceUnitKilometers, DistanceUnitAUs, DistanceUnitLighthours, + DistanceUnitLightdays, DistanceUnitLightmonths, DistanceUnitLightyears, + DistanceUnitParsecs, DistanceUnitKiloparsecs, DistanceUnitMegaparsecs, + DistanceUnitGigaparsecs +}; + +constexpr bool isValidDistanceUnitName(const char* name) { + int i = 0; + for (const char* val : DistanceUnitNamesSingular) { + if (ghoul::equal(name, val)) { + return true; + } + ++i; + } + + i = 0; + for (const char* val : DistanceUnitNamesPlural) { + if (ghoul::equal(name, val)) { + return true; + } + ++i; + } + return false; +} + +constexpr const char* nameForDistanceUnit(DistanceUnit unit, bool pluralForm = false) { + switch (unit) { + case DistanceUnit::Nanometer: + case DistanceUnit::Micrometer: + case DistanceUnit::Millimeter: + case DistanceUnit::Meter: + case DistanceUnit::Kilometer: + case DistanceUnit::AU: + case DistanceUnit::Lighthour: + case DistanceUnit::Lightday: + case DistanceUnit::Lightmonth: + case DistanceUnit::Lightyear: + case DistanceUnit::Parsec: + case DistanceUnit::Kiloparsec: + case DistanceUnit::Megaparsec: + case DistanceUnit::Gigaparsec: + if (pluralForm) { + return DistanceUnitNamesPlural[static_cast(unit)]; + } + else { + return DistanceUnitNamesSingular[static_cast(unit)]; + } + default: + throw ghoul::MissingCaseException(); + } +} + +constexpr DistanceUnit distanceUnitFromString(const char* unitName) { + int i = 0; + for (const char* val : DistanceUnitNamesSingular) { + if (ghoul::equal(unitName, val)) { + return static_cast(i); + } + ++i; + } + + i = 0; + for (const char* val : DistanceUnitNamesPlural) { + if (ghoul::equal(unitName, val)) { + return static_cast(i); + } + ++i; + } + + ghoul_assert(false, "Unit name is not a valid name"); + throw ghoul::MissingCaseException(); +} + + + + + std::pair simplifyDistance(double meters, bool forceSingularForm = false); -double convertDistance(double meters, DistanceUnit requestedUnit); - -std::string nameForDistanceUnit(DistanceUnit unit, bool pluralForm = false); -DistanceUnit distanceUnitFromString(const std::string& unit); +constexpr double convertDistance(double meters, DistanceUnit requestedUnit) { + switch (requestedUnit) { + case DistanceUnit::Nanometer: + return meters / 1e-9; + case DistanceUnit::Micrometer: + return meters / 1e-6; + case DistanceUnit::Millimeter: + return meters / 1e-3; + case DistanceUnit::Meter: + return meters; + case DistanceUnit::Kilometer: + return meters / 1000.0; + case DistanceUnit::AU: + return meters / distanceconstants::AstronomicalUnit; + case DistanceUnit::Lighthour: + return meters / distanceconstants::LightHour; + case DistanceUnit::Lightday: + return meters / distanceconstants::LightDay; + case DistanceUnit::Lightmonth: + return meters / distanceconstants::LightMonth; + case DistanceUnit::Lightyear: + return meters / distanceconstants::LightYear; + case DistanceUnit::Parsec: + return meters / distanceconstants::Parsec; + case DistanceUnit::Kiloparsec: + return meters / (1e3 * distanceconstants::Parsec); + case DistanceUnit::Megaparsec: + return meters / (1e6 * distanceconstants::Parsec); + case DistanceUnit::Gigaparsec: + return meters / (1e9 * distanceconstants::Parsec); + default: + throw ghoul::MissingCaseException(); + } +} } // namespace openspace diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index 6e5f349936..c9ea8452eb 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -25,12 +25,29 @@ #ifndef __OPENSPACE_CORE___TIMECONVERSION___H__ #define __OPENSPACE_CORE___TIMECONVERSION___H__ +#include +#include + #include +#include #include #include namespace openspace { +constexpr double SecondsPerYear = 31556952; // seconds in average Gregorian year +constexpr double SecondsPerMonth = SecondsPerYear / 12; +constexpr double SecondsPerDay = static_cast( + std::chrono::seconds(std::chrono::hours(24)).count() +); +constexpr double SecondsPerHour = static_cast( + std::chrono::seconds(std::chrono::hours(1)).count() +); +constexpr double SecondsPerMinute = static_cast( + std::chrono::seconds(std::chrono::minutes(1)).count() +); + +// Assumption: static_cast(TimeUnit) == position in the list enum class TimeUnit { Nanosecond = 0, Microsecond, @@ -42,20 +59,168 @@ enum class TimeUnit { Month, Year }; -constexpr std::array(TimeUnit::Year) + 1> -TimeUnits = { + +// Assumption: Unit names are sequential in memory +constexpr const char* TimeUnitNanosecond = "nanosecond"; +constexpr const char* TimeUnitMicrosecond = "microsecond"; +constexpr const char* TimeUnitMillisecond = "millisecond"; +constexpr const char* TimeUnitSecond = "second"; +constexpr const char* TimeUnitMinute = "minute"; +constexpr const char* TimeUnitHour = "hour"; +constexpr const char* TimeUnitDay = "day"; +constexpr const char* TimeUnitMonth = "month"; +constexpr const char* TimeUnitYear = "year"; + +// Assumption: Unit names are sequential in memory +constexpr const char* TimeUnitNanoseconds = "nanoseconds"; +constexpr const char* TimeUnitMicroseconds = "microseconds"; +constexpr const char* TimeUnitMilliseconds = "milliseconds"; +constexpr const char* TimeUnitSeconds = "seconds"; +constexpr const char* TimeUnitMinutes = "minutes"; +constexpr const char* TimeUnitHours = "hours"; +constexpr const char* TimeUnitDays = "days"; +constexpr const char* TimeUnitMonths = "months"; +constexpr const char* TimeUnitYears = "years"; + +constexpr std::array(TimeUnit::Year) + 1> TimeUnits = { TimeUnit::Nanosecond, TimeUnit::Microsecond, TimeUnit::Millisecond, TimeUnit::Second, TimeUnit::Minute, TimeUnit::Hour, TimeUnit::Day, TimeUnit::Month, TimeUnit::Year }; +constexpr std::array(TimeUnit::Year) + 1> +TimeUnitNamesSingular = { + TimeUnitNanosecond, TimeUnitMicrosecond, TimeUnitMillisecond, TimeUnitSecond, + TimeUnitMinute, TimeUnitHour, TimeUnitDay, TimeUnitMonth, TimeUnitYear +}; + +constexpr std::array(TimeUnit::Year) + 1> +TimeUnitNamesPlural = { + TimeUnitNanoseconds, TimeUnitMicroseconds, TimeUnitMilliseconds, TimeUnitSeconds, + TimeUnitMinutes, TimeUnitHours, TimeUnitDays, TimeUnitMonths, TimeUnitYears +}; + +constexpr bool isValidTimeUnitName(const char* name) { + int i = 0; + for (const char* val : TimeUnitNamesSingular) { + if (ghoul::equal(name, val)) { + return true; + } + ++i; + } + + i = 0; + for (const char* val : TimeUnitNamesPlural) { + if (ghoul::equal(name, val)) { + return true; + } + ++i; + } + return false; +} + +constexpr const char* nameForTimeUnit(TimeUnit unit, bool pluralForm = false) { + switch (unit) { + case TimeUnit::Nanosecond: + case TimeUnit::Microsecond: + case TimeUnit::Millisecond: + case TimeUnit::Second: + case TimeUnit::Minute: + case TimeUnit::Hour: + case TimeUnit::Day: + case TimeUnit::Month: + case TimeUnit::Year: + if (pluralForm) { + return TimeUnitNamesPlural[static_cast(unit)]; + } + else { + return TimeUnitNamesSingular[static_cast(unit)]; + } + default: + throw ghoul::MissingCaseException(); + } +} + +constexpr TimeUnit timeUnitFromString(const char* unitName) { + int i = 0; + for (const char* val : TimeUnitNamesSingular) { + if (ghoul::equal(unitName, val)) { + return static_cast(i); + } + ++i; + } + + i = 0; + for (const char* val : TimeUnitNamesPlural) { + if (ghoul::equal(unitName, val)) { + return static_cast(i); + } + ++i; + } + + ghoul_assert(false, "Unit name is not a valid name"); + throw ghoul::MissingCaseException(); +} + + + std::pair simplifyTime(double seconds, bool forceSingularForm = false); -double convertTime(double seconds, TimeUnit requestedUnit); +constexpr double convertTime(double t, TimeUnit sourceUnit, TimeUnit destinationUnit) { + double seconds = t; + switch (sourceUnit) { + case TimeUnit::Nanosecond: + seconds = t * 1e-9; + break; + case TimeUnit::Microsecond: + seconds = t * 1e-6; + break; + case TimeUnit::Millisecond: + seconds = t * 1e-3; + break; + case TimeUnit::Minute: + seconds = t * SecondsPerMinute; + break; + case TimeUnit::Hour: + seconds = t * SecondsPerHour; + break; + case TimeUnit::Day: + seconds = t * SecondsPerDay; + break; + case TimeUnit::Month: + seconds = t * SecondsPerMonth; + break; + case TimeUnit::Year: + seconds = t * SecondsPerYear; + break; + default: ; + } + + switch (destinationUnit) { + case TimeUnit::Nanosecond: + return seconds / 1e-9; + case TimeUnit::Microsecond: + return seconds / 1e-6; + case TimeUnit::Millisecond: + return seconds / 1e-3; + case TimeUnit::Second: + return seconds; + case TimeUnit::Minute: + return seconds / SecondsPerMinute; + case TimeUnit::Hour: + return seconds / SecondsPerHour; + case TimeUnit::Day: + return seconds / SecondsPerDay; + case TimeUnit::Month: + return seconds / SecondsPerMonth; + case TimeUnit::Year: + return seconds / SecondsPerYear; + default: + throw ghoul::MissingCaseException(); + } +} -std::string nameForTimeUnit(TimeUnit unit, bool pluralForm = false); -TimeUnit timeUnitFromString(const std::string& unit); } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 2d8c0aa9ff..9f0954a657 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -349,7 +349,7 @@ DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary) _requestedUnit = static_cast(DistanceUnit::Meter); if (dictionary.hasKey(RequestedUnitInfo.identifier)) { std::string value = dictionary.value(RequestedUnitInfo.identifier); - DistanceUnit unit = distanceUnitFromString(value); + DistanceUnit unit = distanceUnitFromString(value.c_str()); _requestedUnit = static_cast(unit); } _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 6126e62476..0e56cadb3a 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -171,7 +171,7 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( _requestedUnit = static_cast(TimeUnit::Second); if (dictionary.hasKey(RequestedUnitInfo.identifier)) { std::string value = dictionary.value(RequestedUnitInfo.identifier); - TimeUnit unit = timeUnitFromString(value); + TimeUnit unit = timeUnitFromString(value.c_str()); _requestedUnit = static_cast(unit); } _requestedUnit.setVisibility(properties::Property::Visibility::Hidden); @@ -188,7 +188,7 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { } else { TimeUnit unit = static_cast(_requestedUnit.value()); - double convertedT = convertTime(t, unit); + double convertedT = convertTime(t, TimeUnit::Second, unit); deltaTime = { convertedT, nameForTimeUnit(unit, convertedT != 1.0) }; } @@ -210,7 +210,7 @@ glm::vec2 DashboardItemSimulationIncrement::size() const { } else { TimeUnit unit = static_cast(_requestedUnit.value()); - double convertedT = convertTime(t, unit); + double convertedT = convertTime(t, TimeUnit::Second, unit); deltaTime = { convertedT, nameForTimeUnit(unit, convertedT != 1.0) }; } diff --git a/modules/imgui/include/guispacetimecomponent.h b/modules/imgui/include/guispacetimecomponent.h index 81c4ff416a..41dbc556eb 100644 --- a/modules/imgui/include/guispacetimecomponent.h +++ b/modules/imgui/include/guispacetimecomponent.h @@ -28,6 +28,7 @@ #include #include +#include namespace openspace::gui { @@ -37,8 +38,21 @@ public: void render() override; private: - properties::FloatProperty _minMaxDeltaTime; - float _localMinMaxDeltatime; // We don't want the default display inside the component + float _deltaTime; + int _deltaTimeUnit; // aka static_cast(TimeUnit) + + float _accelerationDelta; + + double _oldDeltaTime; + float _slidingDelta; + + bool _firstFrame; + + std::string _timeUnits; + + + //properties::FloatProperty _minMaxDeltaTime; + //float _localMinMaxDeltatime; // We don't want the default display inside the component }; } // namespace openspace::gui diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index c432cedfaa..88e652392e 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -36,16 +36,18 @@ #include #include +#include + #include namespace { static const ImVec2 Size = ImVec2(350, 500); - static const openspace::properties::Property::PropertyInfo MinMaxInfo = { - "MinMax", - "Minimum/Maximum value for delta time", - "This value determines the minimum and maximum value for the delta time slider." - }; + //static const openspace::properties::Property::PropertyInfo MinMaxInfo = { + // "MinMax", + // "Minimum/Maximum value for delta time", + // "This value determines the minimum and maximum value for the delta time slider." + //}; void showTooltip(const std::string& message, double delay) { // Hackish way to enfore a window size for TextWrapped (SetNextWindowSize did not @@ -74,13 +76,19 @@ namespace openspace::gui { GuiSpaceTimeComponent::GuiSpaceTimeComponent() : GuiComponent("Space/Time") - , _minMaxDeltaTime(MinMaxInfo, 100000.f, 0.f, 1e8f, 1.f, 5.f) - , _localMinMaxDeltatime(100000.f) + , _deltaTime(0.f) + , _deltaTimeUnit(static_cast(TimeUnit::Second)) + , _accelerationDelta(0.f) + , _slidingDelta(0.f) + , _firstFrame(true) + //, _minMaxDeltaTime(MinMaxInfo, 100000.f, 0.f, 1e8f, 1.f, 5.f) + //, _localMinMaxDeltatime(100000.f) { - _minMaxDeltaTime.onChange([this]() { - _localMinMaxDeltatime = _minMaxDeltaTime; - }); - addProperty(_minMaxDeltaTime); + + //_minMaxDeltaTime.onChange([this]() { + // _localMinMaxDeltatime = _minMaxDeltaTime; + //}); + //addProperty(_minMaxDeltaTime); } void GuiSpaceTimeComponent::render() { @@ -279,71 +287,140 @@ void GuiSpaceTimeComponent::render() { ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 20.f); // -// { -// float deltaTime = static_cast(OsEng.timeManager().time().deltaTime()); -// //std::pair dt = simplifyTime(deltaTime, true); -// -// -// //float val = dt.first; -// ImGui::InputFloat("", &val); -// -// //bool ImGui::Combo(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items) -// -// const char* TimeSteps = "nanoseconds / second\0microseconds / second\0\ -//milliseconds / second\0seconds / second\0minutes / second\0hours / second\0days / second\ -//months / second\0years / second\0"; -// -// std::string nodeNames = ""; -// for (SceneGraphNode* n : nodes) { -// nodeNames += n->name() + '\0'; -// } -// -// auto iCurrentFocus = std::find(nodes.begin(), nodes.end(), currentFocus); -// if (!nodes.empty()) { -// // Only check if we found the current focus node if we have any nodes at all -// // only then it would be a real error -// ghoul_assert(iCurrentFocus != nodes.end(), "Focus node not found"); -// } -// int currentPosition = static_cast(std::distance(nodes.begin(), iCurrentFocus)); -// -// -// bool hasChanged = ImGui::Combo("", ); -// -// bool hasChanged = ImGui::Combo("", ¤tPosition, nodeNames.c_str()); -// -// } -// + { + float deltaTime = static_cast(OsEng.timeManager().time().deltaTime()); + if (_firstFrame) { + std::pair dt = simplifyTime(deltaTime); + _deltaTime = dt.first; + _deltaTimeUnit = static_cast(timeUnitFromString(dt.second.c_str())); - //bool minMaxChanged = ImGui::InputFloat( - // "Time slider range", - // &_localMinMaxDeltatime - //); - //if (minMaxChanged) { - // _minMaxDeltaTime = _localMinMaxDeltatime; - //} + _timeUnits = std::accumulate( + openspace::TimeUnits.begin(), + openspace::TimeUnits.end(), + std::string(""), + [](const std::string& a, const openspace::TimeUnit& unit) { + return a + nameForTimeUnit(unit, true) + " / second" + '\0'; + } + ); + + _firstFrame = false; + } + + _deltaTime = convertTime( + deltaTime, + TimeUnit::Second, + static_cast(_deltaTimeUnit) + ); + + bool valueChanged = ImGui::InputFloat( + "##inputValueDeltaTime", + &_deltaTime, + 1.f, + 100.f, + -1, + ImGuiInputTextFlags_EnterReturnsTrue + ); + ImGui::SameLine(); + + bool unitChanged = ImGui::Combo( + "##inputUnit", + &_deltaTimeUnit, + _timeUnits.c_str() + ); + + if (valueChanged) { + LINFOC("valueChanged", valueChanged); + // If the value changed, we want to change the delta time to the new value + + double newDeltaTime = convertTime( + _deltaTime, + static_cast(_deltaTimeUnit), + TimeUnit::Second + ); + + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(newDeltaTime) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + if (unitChanged) { + LINFOC("unitChanged", unitChanged); + // If only the unit changes, we keep the delta time, but need to convert the + // value to the new unit + + _deltaTime = convertTime( + deltaTime, + TimeUnit::Second, + static_cast(_deltaTimeUnit) + ); + } + } + + ImGui::Text("%s", "Time Slider"); + bool accelerationDeltaChanged = ImGui::SliderFloat( + "Delta Time Acceleration", + &_accelerationDelta, + -100.f, + 100.f, + "%.6f" + ); + + if (accelerationDeltaChanged || ImGui::IsItemActive() || ImGui::IsItemClicked()) { + double newDeltaTime = convertTime( + _deltaTime + _accelerationDelta, + static_cast(_deltaTimeUnit), + TimeUnit::Second + ); + + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(newDeltaTime) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + else { + _accelerationDelta = 0.f; + } + + _deltaTime -= _slidingDelta; + + bool firstSlidingValue = _slidingDelta == 0.f; + bool slidingDeltaChanged = ImGui::SliderFloat( + "Delta Time Slider", + &_slidingDelta, + -100.f, + 100.f, + "%.6f" + ); + firstSlidingValue &= _slidingDelta != 0.f; + + if (slidingDeltaChanged) { + if (firstSlidingValue) { + _oldDeltaTime = _deltaTime; + } + + double newDeltaTime = convertTime( + _deltaTime + _slidingDelta, + static_cast(_deltaTimeUnit), + TimeUnit::Second + ); + + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(newDeltaTime) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + if (!ImGui::IsItemActive() && !ImGui::IsItemClicked()) { + if (_slidingDelta != 0.f) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(_oldDeltaTime) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + + } + _slidingDelta = 0.f; + } - //float deltaTime = static_cast(OsEng.timeManager().time().deltaTime()); - //bool deltaChanged = ImGui::SliderFloat( - // "Delta Time", - // &deltaTime, - // -_minMaxDeltaTime, - // _minMaxDeltaTime, - // "%.6f", - // 5.f - //); - //if (deltaChanged) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //showTooltip( - // "This determines the simulation time increment, that is the passage of time in " - // "OpenSpace relative to a wall clock. Times are expressed as simulation time / " - // "real world time.", - // _tooltipDelay - //); bool isPaused = OsEng.timeManager().time().paused(); @@ -358,87 +435,87 @@ void GuiSpaceTimeComponent::render() { ); } - //bool minusDs = ImGui::Button("-1d/s"); - //if (minusDs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(-24 * 60 * 60) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool minusDs = ImGui::Button("-1d/s"); + if (minusDs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(-24 * 60 * 60) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool minusHs = ImGui::Button("-1h/s"); - //if (minusHs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(-60 * 60) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool minusHs = ImGui::Button("-1h/s"); + if (minusHs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(-60 * 60) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool minusMs = ImGui::Button("-1min/s"); - //if (minusMs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(-60) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool minusMs = ImGui::Button("-1min/s"); + if (minusMs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(-60) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool minusSs = ImGui::Button("-1s/s"); - //if (minusSs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(-1) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool minusSs = ImGui::Button("-1s/s"); + if (minusSs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(-1) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool zero = ImGui::Button("0"); - //if (zero) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(0) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool zero = ImGui::Button("0"); + if (zero) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(0) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool plusSs = ImGui::Button("+1s/s"); - //if (plusSs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(1) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool plusSs = ImGui::Button("+1s/s"); + if (plusSs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(1) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool plusMs = ImGui::Button("1min/s"); - //if (plusMs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(60) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool plusMs = ImGui::Button("1min/s"); + if (plusMs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(60) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool plusHs = ImGui::Button("1h/s"); - //if (plusHs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(60 * 60) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool plusHs = ImGui::Button("1h/s"); + if (plusHs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(60 * 60) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); - //bool plusDs = ImGui::Button("1d/s"); - //if (plusDs) { - // OsEng.scriptEngine().queueScript( - // "openspace.time.setDeltaTime(" + std::to_string(24 * 60 * 60) + ")", - // scripting::ScriptEngine::RemoteScripting::Yes - // ); - //} - //ImGui::SameLine(); + bool plusDs = ImGui::Button("1d/s"); + if (plusDs) { + OsEng.scriptEngine().queueScript( + "openspace.time.setDeltaTime(" + std::to_string(24 * 60 * 60) + ")", + scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::SameLine(); ImGui::End(); diff --git a/src/util/distanceconversion.cpp b/src/util/distanceconversion.cpp index e0e53243c6..89b9150954 100644 --- a/src/util/distanceconversion.cpp +++ b/src/util/distanceconversion.cpp @@ -27,18 +27,6 @@ #include #include -#include - -namespace { - constexpr bool equal(char const* lhs, char const* rhs) { - while (*lhs || *rhs) { - if (*lhs++ != *rhs++) { - return false; - } - } - return true; - } -} namespace openspace { @@ -105,125 +93,4 @@ std::pair simplifyDistance(double meters, bool forceSingula } } - -double convertDistance(double meters, DistanceUnit requestedUnit) { - switch (requestedUnit) { - case DistanceUnit::Nanometer: - return meters / 1e-9; - case DistanceUnit::Micrometer: - return meters / 1e-6; - case DistanceUnit::Millimeter: - return meters / 1e-3; - case DistanceUnit::Meter: - return meters; - case DistanceUnit::Kilometer: - return meters / 1000.0; - case DistanceUnit::AU: - return meters / distanceconstants::AstronomicalUnit; - case DistanceUnit::Lighthour: - return meters / distanceconstants::LightHour; - case DistanceUnit::Lightday: - return meters / distanceconstants::LightDay; - case DistanceUnit::Lightmonth: - return meters / distanceconstants::LightMonth; - case DistanceUnit::Lightyear: - return meters / distanceconstants::LightYear; - case DistanceUnit::Parsec: - return meters / distanceconstants::Parsec; - case DistanceUnit::Kiloparsec: - return meters / (1e3 * distanceconstants::Parsec); - case DistanceUnit::Megaparsec: - return meters / (1e6 * distanceconstants::Parsec); - case DistanceUnit::Gigaparsec: - return meters / (1e9 * distanceconstants::Parsec); - default: - throw ghoul::MissingCaseException(); - } -} - -std::string nameForDistanceUnit(DistanceUnit unit, bool pluralForm) { - switch (unit) { - case DistanceUnit::Nanometer: - return pluralForm ? "nanometers" : "nanometer"; - case DistanceUnit::Micrometer: - return pluralForm ? "micrometers" : "micrometer"; - case DistanceUnit::Millimeter: - return pluralForm ? "millimeters" : "millimeter"; - case DistanceUnit::Meter: - return pluralForm ? "meters" : "meter"; - case DistanceUnit::Kilometer: - return "km"; - case DistanceUnit::AU: - return "AU"; - case DistanceUnit::Lighthour: - return pluralForm ? "lighthours" : "lighthour"; - case DistanceUnit::Lightday: - return pluralForm ? "lightdays" : "lightday"; - case DistanceUnit::Lightmonth: - return pluralForm ? "lightmonths" : "lightmonth"; - case DistanceUnit::Lightyear: - return pluralForm ? "lightyears" : "lightyear"; - case DistanceUnit::Parsec: - return pluralForm ? "parsecs" : "parsec"; - case DistanceUnit::Kiloparsec: - return pluralForm ? "kiloparsecs" : "kiloparsec"; - case DistanceUnit::Megaparsec: - return pluralForm ? "megaparsecs" : "megaparsec"; - case DistanceUnit::Gigaparsec: - return pluralForm ? "gigaparsecs" : "gigaparsec"; - default: - throw ghoul::MissingCaseException(); - } -} - - -DistanceUnit distanceUnitFromString(const std::string& unit) { - if (unit == "nanometer" || unit == "nanometers") { - return DistanceUnit::Nanometer; - } - else if (unit == "micrometer" || unit == "micrometers") { - return DistanceUnit::Micrometer; - } - else if (unit == "millimeter" || unit == "millimeters") { - return DistanceUnit::Millimeter; - } - else if (unit == "meter" || unit == "meters") { - return DistanceUnit::Meter; - } - else if (unit == "km") { - return DistanceUnit::Kilometer; - } - else if (unit == "AU") { - return DistanceUnit::AU; - } - else if (unit == "lighthour" || unit == "lighthours") { - return DistanceUnit::Lighthour; - } - else if (unit == "lightday" || unit == "lightdays") { - return DistanceUnit::Lightday; - } - else if (unit == "lightmonth" || unit == "lightmonths") { - return DistanceUnit::Lightmonth; - } - else if (unit == "lightyear" || unit == "lightyears") { - return DistanceUnit::Lightyear; - } - else if (unit == "parsec" || unit == "parsecs") { - return DistanceUnit::Parsec; - } - else if (unit == "kiloparsec" || unit == "kiloparsecs") { - return DistanceUnit::Kiloparsec; - } - else if (unit == "megaparsec" || unit == "megaparsecs") { - return DistanceUnit::Megaparsec; - } - else if (unit == "gigaparsec" || unit == "gigaparsecs") { - return DistanceUnit::Gigaparsec; - } - else { - throw ghoul::MissingCaseException(); - } -} - - } // namespace openspace diff --git a/src/util/timeconversion.cpp b/src/util/timeconversion.cpp index fd2b2d67ca..eb61bc6950 100644 --- a/src/util/timeconversion.cpp +++ b/src/util/timeconversion.cpp @@ -25,23 +25,8 @@ #include #include -#include -#include - -namespace { - constexpr double SecondsPerYear = 31556952; // seconds in average Gregorian year - constexpr double SecondsPerMonth = SecondsPerYear / 12; - constexpr double SecondsPerDay = static_cast( - std::chrono::seconds(std::chrono::hours(24)).count() - ); - constexpr double SecondsPerHour = static_cast( - std::chrono::seconds(std::chrono::hours(1)).count() - ); - constexpr double SecondsPerMinute = static_cast( - std::chrono::seconds(std::chrono::minutes(1)).count() - ); -} // namespace +#include namespace openspace { @@ -96,88 +81,4 @@ std::pair simplifyTime(double seconds, bool forceSingularFo } } -double convertTime(double seconds, TimeUnit requestedUnit) { - switch (requestedUnit) { - case TimeUnit::Nanosecond: - return seconds / 1e-9; - case TimeUnit::Microsecond: - return seconds / 1e-6; - case TimeUnit::Millisecond: - return seconds / 1e-3; - case TimeUnit::Second: - return seconds; - case TimeUnit::Minute: - return seconds / SecondsPerMinute; - case TimeUnit::Hour: - return seconds / SecondsPerHour; - case TimeUnit::Day: - return seconds / SecondsPerDay; - case TimeUnit::Month: - return seconds / SecondsPerMonth; - case TimeUnit::Year: - return seconds / SecondsPerYear; - default: - throw ghoul::MissingCaseException(); - } -} - -std::string nameForTimeUnit(TimeUnit unit, bool pluralForm) { - switch (unit) { - case TimeUnit::Nanosecond: - return pluralForm ? "nanoseconds" : "nanosecond"; - case TimeUnit::Microsecond: - return pluralForm ? "microseconds" : "microsecond"; - case TimeUnit::Millisecond: - return pluralForm ? "milliseconds" : "millisecond"; - case TimeUnit::Second: - return pluralForm ? "seconds" : "second"; - case TimeUnit::Minute: - return pluralForm ? "minutes" : "minute"; - case TimeUnit::Hour: - return pluralForm ? "hours" : "hour"; - case TimeUnit::Day: - return pluralForm ? "days" : "day"; - case TimeUnit::Month: - return pluralForm ? "months" : "month"; - case TimeUnit::Year: - return pluralForm ? "years" : "year"; - default: - throw ghoul::MissingCaseException(); - } -} - -TimeUnit timeUnitFromString(const std::string& unit) { - if (unit == "nanosecond" || unit == "nanoseconds") { - return TimeUnit::Nanosecond; - } - else if (unit == "microsecond" || unit == "microseconds") { - return TimeUnit::Microsecond; - } - else if (unit == "millisecond" || unit == "milliseconds") { - return TimeUnit::Millisecond; - } - else if (unit == "second" || unit == "seconds") { - return TimeUnit::Second; - } - else if (unit == "minute" || unit == "minutes") { - return TimeUnit::Minute; - } - else if (unit == "hour" || unit == "hours") { - return TimeUnit::Hour; - } - else if (unit == "day" || unit == "days") { - return TimeUnit::Day; - } - else if (unit == "month" || unit == "months") { - return TimeUnit::Month; - } - else if (unit == "year" || unit == "years") { - return TimeUnit::Year; - } - else { - throw ghoul::MissingCaseException(); - } -} - - } // namespace openspace From 4f9085b9c60b44bc05829def1bdc56a22f4b2ad7 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 8 Feb 2018 17:53:11 -0500 Subject: [PATCH 022/131] Small fixes to GuiSpaceTimeComponent --- modules/imgui/src/guispacetimecomponent.cpp | 28 ++++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index 88e652392e..41f5104e52 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -292,7 +293,7 @@ void GuiSpaceTimeComponent::render() { if (_firstFrame) { std::pair dt = simplifyTime(deltaTime); - _deltaTime = dt.first; + _deltaTime = static_cast(dt.first); _deltaTimeUnit = static_cast(timeUnitFromString(dt.second.c_str())); _timeUnits = std::accumulate( @@ -307,10 +308,12 @@ void GuiSpaceTimeComponent::render() { _firstFrame = false; } - _deltaTime = convertTime( - deltaTime, - TimeUnit::Second, - static_cast(_deltaTimeUnit) + _deltaTime = static_cast( + convertTime( + deltaTime, + TimeUnit::Second, + static_cast(_deltaTimeUnit) + ) ); bool valueChanged = ImGui::InputFloat( @@ -330,7 +333,6 @@ void GuiSpaceTimeComponent::render() { ); if (valueChanged) { - LINFOC("valueChanged", valueChanged); // If the value changed, we want to change the delta time to the new value double newDeltaTime = convertTime( @@ -345,14 +347,15 @@ void GuiSpaceTimeComponent::render() { ); } if (unitChanged) { - LINFOC("unitChanged", unitChanged); // If only the unit changes, we keep the delta time, but need to convert the // value to the new unit - _deltaTime = convertTime( - deltaTime, - TimeUnit::Second, - static_cast(_deltaTimeUnit) + _deltaTime = static_cast( + convertTime( + deltaTime, + TimeUnit::Second, + static_cast(_deltaTimeUnit) + ) ); } } @@ -367,8 +370,9 @@ void GuiSpaceTimeComponent::render() { ); if (accelerationDeltaChanged || ImGui::IsItemActive() || ImGui::IsItemClicked()) { + // We want the value to change by _accelerationDelta every 100 ms real world time double newDeltaTime = convertTime( - _deltaTime + _accelerationDelta, + _deltaTime + _accelerationDelta * OsEng.windowWrapper().deltaTime() * 10, static_cast(_deltaTimeUnit), TimeUnit::Second ); From a85eddff4e8f69f7131c4b93136f03124031b299 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Fri, 9 Feb 2018 16:43:29 +0100 Subject: [PATCH 023/131] Clean up lua stack and weak pointers --- include/openspace/engine/openspaceengine.h | 1 + .../openspace/interaction/navigationhandler.h | 1 + include/openspace/scene/asset.h | 2 +- .../globebrowsing/globebrowsingmodule_lua.inl | 23 +++++++- src/engine/moduleengine.cpp | 1 + src/engine/moduleengine_lua.inl | 1 + src/engine/openspaceengine_lua.inl | 22 ++++++-- src/engine/wrapper/windowwrapper.cpp | 2 + src/interaction/keybindingmanager_lua.inl | 10 ++++ src/interaction/navigationhandler_lua.inl | 9 ++++ src/mission/missionmanager_lua.inl | 8 +++ src/network/parallelconnection_lua.inl | 8 +++ src/rendering/dashboard.cpp | 1 + src/rendering/dashboard_lua.inl | 6 +++ src/rendering/renderengine_lua.inl | 11 ++++ src/scene/asset.cpp | 52 ++++++++++++------- src/scene/assetloader.cpp | 48 ++++++++++++++++- src/scene/scene_lua.inl | 19 +++++-- src/scripting/scriptengine.cpp | 8 +++ src/scripting/scriptengine_lua.inl | 13 +++++ src/scripting/scriptscheduler_lua.inl | 3 ++ src/util/spicemanager_lua.inl | 8 +++ src/util/time_lua.inl | 9 ++++ 23 files changed, 236 insertions(+), 30 deletions(-) diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 54c70fb2f7..386da78ffd 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/include/openspace/interaction/navigationhandler.h b/include/openspace/interaction/navigationhandler.h index 6137e1f4da..9ab9e08f20 100644 --- a/include/openspace/interaction/navigationhandler.h +++ b/include/openspace/interaction/navigationhandler.h @@ -36,6 +36,7 @@ #include #include +#include namespace openspace { class Camera; diff --git a/include/openspace/scene/asset.h b/include/openspace/scene/asset.h index 020576c9f5..e1185694ff 100644 --- a/include/openspace/scene/asset.h +++ b/include/openspace/scene/asset.h @@ -90,7 +90,7 @@ public: * i.e. if this and all required assets loaded without errors. */ bool load(); - bool hasLoadedParent() const; + bool hasLoadedParent(); bool isLoaded() const; void unload(); void unloadIfUnwanted(); diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 4e37ed0162..e4a14583d0 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -81,14 +81,17 @@ int addLayer(lua_State* L) { } catch (const ghoul::lua::LuaFormatException& e) { LERRORC("addLayerFromDictionary", e.what()); + lua_settop(L, 0); return 0; } + lua_settop(L, 0); std::shared_ptr layer = globe->layerManager()->addLayer(groupID, d); if (layer) { layer->initialize(); } + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -113,6 +116,8 @@ int deleteLayer(lua_State* L) { const std::string LayerGroupName = luaL_checkstring(L, LayerGroupLocation); const std::string LayerName = luaL_checkstring(L, NameLocation); + lua_settop(L, 0); + // Get the node and make sure it exists SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(GlobeName); if (!node) { @@ -133,6 +138,7 @@ int deleteLayer(lua_State* L) { globe->layerManager()->deleteLayer(groupID, LayerName); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -148,10 +154,12 @@ int goToChunk(lua_State* L) { int x = static_cast(lua_tonumber(L, 1)); int y = static_cast(lua_tonumber(L, 2)); int level = static_cast(lua_tonumber(L, 3)); + lua_settop(L, 0); OsEng.moduleEngine().module()->goToChunk(x, y, level); -return 0; + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); + return 0; } int goToGeo(lua_State* L) { @@ -174,6 +182,8 @@ int goToGeo(lua_State* L) { altitude); } + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -202,10 +212,13 @@ int getGeoPosition(lua_State* L) { double altitude = glm::length(cameraPositionModelSpace - posHandle.centerToReferenceSurface); + lua_settop(L, 0); + lua_pushnumber(L, Angle::fromRadians(geo2.lat).asDegrees()); lua_pushnumber(L, Angle::fromRadians(geo2.lon).asDegrees()); lua_pushnumber(L, altitude); + ghoul_assert(lua_gettop(L) == 3, "Incorrect number of items left on stack"); return 3; } @@ -220,6 +233,7 @@ int loadWMSCapabilities(lua_State* L) { std::string name = lua_tostring(L, -3); std::string globe = lua_tostring(L, -2); std::string url = lua_tostring(L, -1); + lua_settop(L, 0); OsEng.moduleEngine().module()->loadWMSCapabilities( std::move(name), @@ -227,6 +241,7 @@ int loadWMSCapabilities(lua_State* L) { std::move(url) ); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -238,7 +253,11 @@ int removeWMSServer(lua_State* L) { } std::string name = lua_tostring(L, -1); + + lua_settop(L, 0); OsEng.moduleEngine().module()->removeWMSServer(name); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -253,6 +272,7 @@ int capabilities(lua_State* L) { GlobeBrowsingModule::Capabilities cap = OsEng.moduleEngine().module()->capabilities(name); + lua_settop(L, 0); lua_newtable(L); for (unsigned long i = 0; i < cap.size(); ++i) { const GlobeBrowsingModule::Layer& l = cap[i]; @@ -270,6 +290,7 @@ int capabilities(lua_State* L) { lua_rawseti(L, -2, i + 1); } + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } #endif // GLOBEBROWSING_USE_GDAL diff --git a/src/engine/moduleengine.cpp b/src/engine/moduleengine.cpp index 506ee3efa0..d806a69f0e 100644 --- a/src/engine/moduleengine.cpp +++ b/src/engine/moduleengine.cpp @@ -30,6 +30,7 @@ #include #include +#include #include diff --git a/src/engine/moduleengine_lua.inl b/src/engine/moduleengine_lua.inl index 87aca7e4c6..8176fabf44 100644 --- a/src/engine/moduleengine_lua.inl +++ b/src/engine/moduleengine_lua.inl @@ -57,6 +57,7 @@ int isLoaded(lua_State* L) { else lua_pushboolean(L, 0); + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index 26463aa004..276b5f2afb 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -41,6 +41,7 @@ int toggleShutdown(lua_State* L) { OsEng.toggleShutdownMode(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -58,6 +59,7 @@ int writeDocumentation(lua_State* L) { OsEng.writeStaticDocumentation(); OsEng.writeSceneDocumentation(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -115,10 +117,13 @@ int addVirtualProperty(lua_State* L) { ); } else { + lua_settop(L, 0); return luaL_error(L, "Unknown property type '%s'", type.c_str()); } + lua_settop(L, 0); OsEng.virtualPropertyManager().addProperty(std::move(prop)); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -134,8 +139,10 @@ int removeVirtualProperty(lua_State* L) { } const std::string name = lua_tostring(L, -1); + lua_settop(L, 0); properties::Property* p = OsEng.virtualPropertyManager().property(name); OsEng.virtualPropertyManager().removeProperty(p); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -146,8 +153,8 @@ int removeVirtualProperty(lua_State* L) { */ int removeAllVirtualProperties(lua_State* L) { const int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + if (nArguments != 0) { + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); } std::vector ps = OsEng.virtualPropertyManager().properties(); @@ -155,6 +162,8 @@ int removeAllVirtualProperties(lua_State* L) { OsEng.virtualPropertyManager().removeProperty(p); delete p; } + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -171,6 +180,7 @@ int addTag(lua_State* L) { const std::string uri = lua_tostring(L, -2); const std::string tag = lua_tostring(L, -1); + lua_settop(L, 0); SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(uri); if (!node) { @@ -179,6 +189,7 @@ int addTag(lua_State* L) { node->addTag(std::move(tag)); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -195,6 +206,7 @@ int removeTag(lua_State* L) { const std::string uri = lua_tostring(L, -2); const std::string tag = lua_tostring(L, -1); + lua_settop(L, 0); SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(uri); if (!node) { @@ -203,6 +215,7 @@ int removeTag(lua_State* L) { node->removeTag(tag); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -217,6 +230,7 @@ int downloadFile(lua_State* L) { return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments); std::string uri = luaL_checkstring(L, -2); std::string savePath = luaL_checkstring(L, -1); + lua_settop(L, 0); const std::string _loggerCat = "OpenSpaceEngine"; LINFO("Downloading file from " << uri); @@ -229,7 +243,9 @@ int downloadFile(lua_State* L) { errorMsg += ": " + future->errorMessage; return luaL_error(L, errorMsg.c_str()); } - return 1; + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); + return 0; } } // namespace luascriptfunctions diff --git a/src/engine/wrapper/windowwrapper.cpp b/src/engine/wrapper/windowwrapper.cpp index fa4e590620..c77d7286fc 100644 --- a/src/engine/wrapper/windowwrapper.cpp +++ b/src/engine/wrapper/windowwrapper.cpp @@ -41,6 +41,8 @@ int setSynchronization(lua_State* L) { bool b = lua_toboolean(L, -1) != 0; OsEng.windowWrapper().setSynchronization(b); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/interaction/keybindingmanager_lua.inl b/src/interaction/keybindingmanager_lua.inl index edb1972467..ec1f0d0096 100644 --- a/src/interaction/keybindingmanager_lua.inl +++ b/src/interaction/keybindingmanager_lua.inl @@ -69,6 +69,8 @@ int bindKey(lua_State* L) { std::move(documentation) ); + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -115,6 +117,8 @@ int bindKeyLocal(lua_State* L) { std::move(documentation) ); + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -131,6 +135,7 @@ int getKeyBindings(lua_State* L) { } std::string key = luaL_checkstring(L, -1); + lua_settop(L, 0); using KeyInformation = interaction::KeyBindingManager::KeyInformation; @@ -153,6 +158,8 @@ int getKeyBindings(lua_State* L) { lua_settable(L, -3); ++i; } + + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -168,9 +175,11 @@ int clearKey(lua_State* L) { } std::string key = luaL_checkstring(L, -1); + lua_settop(L, 0); OsEng.keyBindingManager().removeKeyBinding(key); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -187,6 +196,7 @@ int clearKeys(lua_State* L) { OsEng.keyBindingManager().resetKeyBindings(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/interaction/navigationhandler_lua.inl b/src/interaction/navigationhandler_lua.inl index 1f0c76678b..173fa84dee 100644 --- a/src/interaction/navigationhandler_lua.inl +++ b/src/interaction/navigationhandler_lua.inl @@ -33,12 +33,14 @@ int restoreCameraStateFromFile(lua_State* L) { } std::string cameraStateFilePath = luaL_checkstring(L, -1); + lua_settop(L, 0); if (cameraStateFilePath.empty()) { return luaL_error(L, "filepath string is empty"); } OsEng.navigationHandler().restoreCameraStateFromFile(cameraStateFilePath); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -53,8 +55,12 @@ int setCameraState(lua_State* L) { ghoul::lua::luaDictionaryFromState(L, dictionary); OsEng.navigationHandler().setCameraStateFromDictionary(dictionary); } catch (const ghoul::RuntimeError& e) { + lua_settop(L, 0); return luaL_error(L, "Could not set camera state: %s", e.what()); } + + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -67,12 +73,14 @@ int saveCameraStateToFile(lua_State* L) { } std::string cameraStateFilePath = luaL_checkstring(L, -1); + lua_settop(L, 0); if (cameraStateFilePath.empty()) { return luaL_error(L, "filepath string is empty"); } OsEng.navigationHandler().saveCameraStateToFile(cameraStateFilePath); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -85,6 +93,7 @@ int resetCameraDirection(lua_State* L) { } OsEng.navigationHandler().resetCameraDirection(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/mission/missionmanager_lua.inl b/src/mission/missionmanager_lua.inl index 381293d821..fac99a845d 100644 --- a/src/mission/missionmanager_lua.inl +++ b/src/mission/missionmanager_lua.inl @@ -36,6 +36,8 @@ int loadMission(lua_State* L) { } std::string name = MissionManager::ref().loadMission(absPath(missionFileName)); lua_pushstring(L, name.c_str()); + + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -55,6 +57,8 @@ int unloadMission(lua_State* L) { } MissionManager::ref().unloadMission(missionName); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -72,6 +76,8 @@ int hasMission(lua_State* L) { bool hasMission = MissionManager::ref().hasMission(missionName); lua_pushboolean(L, hasMission); + + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -86,6 +92,8 @@ int setCurrentMission(lua_State* L) { return luaL_error(L, "Mission name is empty"); } MissionManager::ref().setCurrentMission(missionName); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/network/parallelconnection_lua.inl b/src/network/parallelconnection_lua.inl index b63a5e80ca..02ddb5aba4 100644 --- a/src/network/parallelconnection_lua.inl +++ b/src/network/parallelconnection_lua.inl @@ -31,6 +31,8 @@ int connect(lua_State* L) { if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().clientConnect(); } + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -41,6 +43,8 @@ int disconnect(lua_State* L) { if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().signalDisconnect(); } + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -51,6 +55,8 @@ int requestHostship(lua_State* L) { if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().requestHostship(); } + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -61,6 +67,8 @@ int resignHostship(lua_State* L) { if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().resignHostship(); } + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/rendering/dashboard.cpp b/src/rendering/dashboard.cpp index 1b4cca20d2..8bf9f3a158 100644 --- a/src/rendering/dashboard.cpp +++ b/src/rendering/dashboard.cpp @@ -27,6 +27,7 @@ #include #include +#include #include "dashboard_lua.inl" namespace openspace { diff --git a/src/rendering/dashboard_lua.inl b/src/rendering/dashboard_lua.inl index bca0d67444..bc8f29eb58 100644 --- a/src/rendering/dashboard_lua.inl +++ b/src/rendering/dashboard_lua.inl @@ -46,10 +46,14 @@ int addDashboardItem(lua_State* L) { } catch (const ghoul::lua::LuaFormatException& e) { LERRORC("addDashboardItem", e.what()); + lua_settop(L, 0); return 0; } + lua_settop(L, 0); OsEng.dashboard().addDashboardItem(DashboardItem::createFromDictionary(d)); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } else { @@ -68,6 +72,8 @@ int removeDashboardItems(lua_State* L) { } OsEng.dashboard().removeDashboardItems(); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/rendering/renderengine_lua.inl b/src/rendering/renderengine_lua.inl index cbdf30b31b..463bfdb592 100644 --- a/src/rendering/renderengine_lua.inl +++ b/src/rendering/renderengine_lua.inl @@ -41,6 +41,8 @@ int setRenderer(lua_State* L) { } std::string r = lua_tostring(L, -1); OsEng.renderEngine().setRendererFromString(r); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -61,6 +63,8 @@ int toggleFade(lua_State* L) { int direction = OsEng.renderEngine().globalBlackOutFactor() == fadedIn ? -1 : 1; OsEng.renderEngine().startFading(direction, static_cast(t)); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -78,6 +82,8 @@ int fadeIn(lua_State* L) { double t = luaL_checknumber(L, -1); OsEng.renderEngine().startFading(1, static_cast(t)); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } /** @@ -94,6 +100,8 @@ int fadeOut(lua_State* L) { double t = luaL_checknumber(L, -1); OsEng.renderEngine().startFading(-1, static_cast(t)); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -119,6 +127,7 @@ int addScreenSpaceRenderable(lua_State* L) { ); OsEng.renderEngine().addScreenSpaceRenderable(s); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -140,11 +149,13 @@ int removeScreenSpaceRenderable(lua_State* L) { "removeScreenSpaceRenderable", errorLocation(L) << "Could not find ScreenSpaceRenderable '" << name << "'" ); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } OsEng.renderEngine().removeScreenSpaceRenderable(s); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/scene/asset.cpp b/src/scene/asset.cpp index ed9993c18d..23c1aa0db9 100644 --- a/src/scene/asset.cpp +++ b/src/scene/asset.cpp @@ -27,6 +27,7 @@ #include +#include #include #include @@ -185,10 +186,10 @@ void Asset::clearSynchronizations() { for (const SynchronizationWatcher::WatchHandle& h : _syncWatches) { _synchronizationWatcher->unwatchSynchronization(h); } + _syncWatches.clear(); } -void Asset::syncStateChanged(ResourceSynchronization::State state) -{ +void Asset::syncStateChanged(ResourceSynchronization::State state) { if (state == ResourceSynchronization::State::Resolved) { if (!isSynchronized() && isSyncResolveReady()) { setState(State::SyncResolved); @@ -274,28 +275,39 @@ bool Asset::isSyncingOrResolved() const { s == State::InitializationFailed; } -bool Asset::hasLoadedParent() const { - for (const auto& p : _requiringAssets) { - std::shared_ptr parent = p.lock(); - if (!parent) { - continue; - } - if (parent->isLoaded()) { - return true; +bool Asset::hasLoadedParent() { + { + std::vector>::iterator it = _requiringAssets.begin(); + while (it != _requiringAssets.end()) { + std::shared_ptr parent = it->lock(); + if (!parent) { + it = _requiringAssets.erase(it); + continue; + } + if (parent->isLoaded()) { + return true; + } + ++it; } } - for (const auto& p : _requestingAssets) { - std::shared_ptr parent = p.lock(); - if (!parent) { - continue; - } - if (parent->isLoaded()) { - return true; - } - if (parent->hasLoadedParent()) { - return true; + { + std::vector>::iterator it = _requestingAssets.begin(); + while (it != _requestingAssets.end()) { + std::shared_ptr parent = it->lock(); + if (!parent) { + it = _requestingAssets.erase(it); + continue; + } + if (parent->isLoaded()) { + return true; + } + if (parent->hasLoadedParent()) { + return true; + } + ++it; } } + return false; } diff --git a/src/scene/assetloader.cpp b/src/scene/assetloader.cpp index 0ac7d72549..f4dbb8fc37 100644 --- a/src/scene/assetloader.cpp +++ b/src/scene/assetloader.cpp @@ -145,6 +145,8 @@ void AssetLoader::setUpAssetLuaTable(Asset* asset) { |- onDeinitialize */ + int top = lua_gettop(*_luaState); + // Push the global table of AssetInfos to the lua stack. lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, _assetsTableRef); int globalTableIndex = lua_gettop(*_luaState); @@ -227,9 +229,11 @@ void AssetLoader::setUpAssetLuaTable(Asset* asset) { // Extend global asset info table (pushed to the lua stack earlier) // with this AssetInfo table lua_setfield(*_luaState, globalTableIndex, asset->id().c_str()); + lua_settop(*_luaState, top); } void AssetLoader::tearDownAssetLuaTable(Asset* asset) { + int top = lua_gettop(*_luaState); // Push the global table of AssetInfos to the lua stack. lua_rawgeti(*_luaState, LUA_REGISTRYINDEX, _assetsTableRef); int globalTableIndex = lua_gettop(*_luaState); @@ -238,9 +242,11 @@ void AssetLoader::tearDownAssetLuaTable(Asset* asset) { // Clear entry from global asset table (pushed to the lua stack earlier) lua_setfield(*_luaState, globalTableIndex, asset->id().c_str()); + lua_settop(*_luaState, top); } bool AssetLoader::loadAsset(std::shared_ptr asset) { + int top = lua_gettop(*_luaState); std::shared_ptr parentAsset = _currentAsset; setCurrentAsset(asset); @@ -251,6 +257,7 @@ bool AssetLoader::loadAsset(std::shared_ptr asset) { if (!FileSys.fileExists(asset->assetFilePath())) { LERROR("Could not load asset '" << asset->assetFilePath() << "': File does not exist."); + lua_settop(*_luaState, top); return false; } @@ -258,9 +265,11 @@ bool AssetLoader::loadAsset(std::shared_ptr asset) { ghoul::lua::runScriptFile(*_luaState, asset->assetFilePath()); } catch (const ghoul::lua::LuaRuntimeException& e) { LERROR("Could not load asset '" << asset->assetFilePath() << "': " << e.message); + lua_settop(*_luaState, top); return false; } + lua_settop(*_luaState, top); return true; } @@ -384,6 +393,7 @@ int AssetLoader::onInitializeLua(Asset* asset) { SCRIPT_CHECK_ARGUMENTS("onInitialize", *_luaState, 1, nArguments); int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onInitializationFunctionRefs[asset].push_back(referenceIndex); + lua_settop(*_luaState, 0); return 0; } @@ -392,6 +402,7 @@ int AssetLoader::onDeinitializeLua(Asset* asset) { SCRIPT_CHECK_ARGUMENTS("onDeinitialize", *_luaState, 1, nArguments); int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onDeinitializationFunctionRefs[asset].push_back(referenceIndex); + lua_settop(*_luaState, 0); return 0; } @@ -401,7 +412,7 @@ int AssetLoader::onInitializeDependencyLua(Asset* dependant, Asset* dependency) int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onDependencyInitializationFunctionRefs[dependant][dependency] .push_back(referenceIndex); - + lua_settop(*_luaState, 0); return 0; } @@ -411,7 +422,7 @@ int AssetLoader::onDeinitializeDependencyLua(Asset* dependant, Asset* dependency int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onDependencyDeinitializationFunctionRefs[dependant][dependency] .push_back(referenceIndex); - + lua_settop(*_luaState, 0); return 0; } @@ -547,7 +558,10 @@ int AssetLoader::localResourceLua(Asset* asset) { std::string resourceName = luaL_checkstring(*_luaState, -1); std::string resolved = asset->resolveLocalResource(resourceName); + lua_settop(*_luaState, 0); lua_pushstring(*_luaState, resolved.c_str()); + + ghoul_assert(lua_gettop(*_luaState) == 1, "Incorrect number of items left on stack"); return 1; } @@ -565,17 +579,23 @@ int AssetLoader::syncedResourceLua(Asset* asset) { asset->addSynchronization(sync); + lua_settop(*_luaState, 0); lua_pushstring(*_luaState, absolutePath.c_str()); + + ghoul_assert(lua_gettop(*_luaState) == 1, "Incorrect number of items left on stack"); return 1; } void AssetLoader::setCurrentAsset(std::shared_ptr asset) { + int top = lua_gettop(*_luaState); + _currentAsset = asset; // Set `asset` lua global to point to the current asset table if (asset == _rootAsset) { lua_pushnil(*_luaState); lua_setglobal(*_luaState, AssetGlobalVariableName); + lua_settop(*_luaState, top); return; } @@ -583,6 +603,8 @@ void AssetLoader::setCurrentAsset(std::shared_ptr asset) { lua_getfield(*_luaState, -1, asset->id().c_str()); lua_getfield(*_luaState, -1, AssetTableName); lua_setglobal(*_luaState, AssetGlobalVariableName); + + lua_settop(*_luaState, top); } int AssetLoader::requireLua(Asset* dependant) { @@ -590,6 +612,7 @@ int AssetLoader::requireLua(Asset* dependant) { SCRIPT_CHECK_ARGUMENTS("require", *_luaState, 1, nArguments); std::string assetName = luaL_checkstring(*_luaState, 1); + lua_settop(*_luaState, 0); std::shared_ptr dependency = require(assetName); @@ -614,6 +637,12 @@ int AssetLoader::requireLua(Asset* dependant) { lua_pushvalue(*_luaState, exportsTableIndex); lua_pushvalue(*_luaState, dependencyTableIndex); + + lua_replace(*_luaState, 2); + lua_replace(*_luaState, 1); + lua_settop(*_luaState, 2); + + ghoul_assert(lua_gettop(*_luaState) == 2, "Incorrect number of items left on stack"); return 2; } @@ -622,6 +651,7 @@ int AssetLoader::requestLua(Asset* parent) { SCRIPT_CHECK_ARGUMENTS("request", *_luaState, 1, nArguments); std::string assetName = luaL_checkstring(*_luaState, 1); + lua_settop(*_luaState, 0); std::shared_ptr child = request(assetName); @@ -635,6 +665,11 @@ int AssetLoader::requestLua(Asset* parent) { int dependencyTableIndex = lua_gettop(*_luaState); lua_pushvalue(*_luaState, dependencyTableIndex); + + lua_replace(*_luaState, 1); + lua_settop(*_luaState, 1); + + ghoul_assert(lua_gettop(*_luaState) == 1, "Incorrect number of items left on stack"); return 1; } @@ -647,7 +682,9 @@ int AssetLoader::existsLua(Asset* asset) { ghoul::filesystem::Directory directory = currentDirectory(); std::string path = generateAssetPath(directory, assetName); + lua_settop(*_luaState, 0); lua_pushboolean(*_luaState, FileSys.fileExists(path)); + ghoul_assert(lua_gettop(*_luaState) == 1, "Incorrect number of items left on stack"); return 1; } @@ -665,10 +702,15 @@ int AssetLoader::exportAssetLua(Asset* asset) { // push the second argument lua_pushvalue(*_luaState, 2); lua_setfield(*_luaState, exportsTableIndex, exportName.c_str()); + + lua_settop(*_luaState, 0); + ghoul_assert(lua_gettop(*_luaState) == 0, "Incorrect number of items left on stack"); return 0; } void AssetLoader::addLuaDependencyTable(Asset* dependant, Asset* dependency) { + int top = lua_gettop(*_luaState); + const std::string dependantId = dependant->id(); const std::string dependencyId = dependency->id(); @@ -701,6 +743,8 @@ void AssetLoader::addLuaDependencyTable(Asset* dependant, Asset* dependency) { // Register the dependant table on the imported asset's dependants table. lua_setfield(*_luaState, dependantsTableIndex, dependantId.c_str()); + + lua_settop(*_luaState, top); } void AssetLoader::addAssetListener(AssetListener* listener) { diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 89c037e9c7..25bfeea128 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -320,10 +320,13 @@ int property_getValue(lua_State* L) { "property_getValue", errorLocation(L) << "Property with URL '" << uri << "' was not found" ); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; - } - else + } else { prop->getLuaValue(L); + } + + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -340,6 +343,7 @@ int loadScene(lua_State* L) { std::string sceneFile = luaL_checkstring(L, -1); OsEng.scheduleLoadSingleAsset(sceneFile); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -377,6 +381,9 @@ int addSceneGraphNode(lua_State* L) { } catch (const ghoul::RuntimeError& e) { return luaL_error(L, "Error loading scene graph node: %s", e.what()); } + + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -405,7 +412,10 @@ int removeSceneGraphNode(lua_State* L) { } node->deinitializeGL(); parent->detachChild(*node); - return 1; + + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); + return 0; } @@ -416,7 +426,10 @@ int hasSceneGraphNode(lua_State* L) { std::string nodeName = luaL_checkstring(L, -1); SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(nodeName); + lua_settop(L, 0); lua_pushboolean(L, node != nullptr); + + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index fa72088b0d..167c96d26f 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -81,6 +81,8 @@ void ScriptEngine::deinitialize() { void ScriptEngine::initializeLuaState(lua_State* state) { LDEBUG("Create openspace base library"); + int top = lua_gettop(state); + lua_newtable(state); lua_setglobal(state, OpenSpaceLibraryName.c_str()); @@ -88,6 +90,8 @@ void ScriptEngine::initializeLuaState(lua_State* state) { for (LuaLibrary& lib : _registeredLibraries) { registerLuaLibrary(state, lib); } + + lua_settop(state, top); } ghoul::lua::LuaState * ScriptEngine::luaState() { @@ -462,6 +466,7 @@ void ScriptEngine::remapPrintFunction() { bool ScriptEngine::registerLuaLibrary(lua_State* state, LuaLibrary& library) { ghoul_assert(state, "State must not be nullptr"); + int top = lua_gettop(state); lua_getglobal(state, OpenSpaceLibraryName.c_str()); if (library.name.empty()) { @@ -471,6 +476,7 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, LuaLibrary& library) { else { const bool allowed = isLibraryNameAllowed(state, library.name); if (!allowed) { + lua_settop(state, top); return false; } @@ -492,6 +498,8 @@ bool ScriptEngine::registerLuaLibrary(lua_State* state, LuaLibrary& library) { // Pop the table lua_pop(state, 1); } + + lua_settop(state, top); return true; } diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 2f0096ae5a..c7e948f4be 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -71,6 +71,8 @@ int walkCommon(lua_State* L, Func func) { ); } + lua_settop(L, 0); + // Copy values into the lua_State lua_newtable(L); @@ -79,6 +81,7 @@ int walkCommon(lua_State* L, Func func) { lua_rawseti(L, -2, i + 1); } + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } } // namespace @@ -115,6 +118,7 @@ int printInternal(ghoul::logging::LogLevel level, lua_State* L) { LOGC(level, "print", lua_tostring(L, -1)); break; } + lua_settop(L, 0); return 0; } @@ -197,6 +201,8 @@ int absolutePath(lua_State* L) { } std::string path = luaL_checkstring(L, -1); + lua_settop(L, 0); + path = absPath(path); //path = FileSys.convertPathSeparator(path, '/'); lua_pushstring(L, path.c_str()); @@ -217,6 +223,7 @@ int setPathToken(lua_State* L) { const std::string path = luaL_checkstring(L, -1); const std::string pathToken = luaL_checkstring(L, -2); + lua_settop(L, 0); FileSys.registerPathToken( pathToken, path, @@ -238,6 +245,8 @@ int fileExists(lua_State* L) { const std::string file = luaL_checkstring(L, -1); const bool e = FileSys.fileExists(absPath(file)); + + lua_settop(L, 0); lua_pushboolean(L, (e ? 1 : 0)); return 1; } @@ -255,6 +264,8 @@ int directoryExists(lua_State* L) { const std::string file = luaL_checkstring(L, -1); const bool e = FileSys.directoryExists(absPath(file)); + + lua_settop(L, 0); lua_pushboolean(L, (e ? 1 : 0)); return 1; } @@ -315,6 +326,8 @@ int directoryForPath(lua_State* L) { const std::string file = luaL_checkstring(L, -1); const std::string path = ghoul::filesystem::File(file).directoryName(); + + lua_settop(L, 0); lua_pushstring(L, path.c_str()); return 1; } diff --git a/src/scripting/scriptscheduler_lua.inl b/src/scripting/scriptscheduler_lua.inl index 05e94a2590..489108ab67 100644 --- a/src/scripting/scriptscheduler_lua.inl +++ b/src/scripting/scriptscheduler_lua.inl @@ -39,6 +39,7 @@ int loadFile(lua_State* L) { ghoul::lua::loadDictionaryFromFile(missionFileName, L) ); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -84,6 +85,7 @@ int loadScheduledScript(lua_State* L) { return luaL_error(L, "Expected %i-%i arguments, got %i", 2, 4, nArguments); } + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -95,6 +97,7 @@ int clear(lua_State* L) { OsEng.scriptScheduler().clearSchedule(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/util/spicemanager_lua.inl b/src/util/spicemanager_lua.inl index f080bd4f8e..f93c4a32f1 100644 --- a/src/util/spicemanager_lua.inl +++ b/src/util/spicemanager_lua.inl @@ -49,7 +49,10 @@ int loadKernel(lua_State* L) { } unsigned int result = SpiceManager::ref().loadKernel(argument); + lua_settop(L, 0); lua_pushnumber(L, result); + + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -71,6 +74,8 @@ int unloadKernel(lua_State* L) { ghoul::lua::errorLocation(L) << "Expected argument of type 'string' or 'number'" ); + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -84,6 +89,9 @@ int unloadKernel(lua_State* L) { SpiceManager::ref().unloadKernel(argument); } + lua_settop(L, 0); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index 7d711e9151..9c9c36d65a 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -46,6 +46,7 @@ int time_setDeltaTime(lua_State* L) { if (isNumber) { double value = lua_tonumber(L, -1); OsEng.timeManager().time().setDeltaTime(value); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } else { @@ -67,6 +68,7 @@ int time_setDeltaTime(lua_State* L) { */ int time_deltaTime(lua_State* L) { lua_pushnumber(L, OsEng.timeManager().time().deltaTime()); + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -82,6 +84,7 @@ int time_togglePause(lua_State* L) { } OsEng.timeManager().time().togglePause(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -98,6 +101,8 @@ int time_setPause(lua_State* L) { bool pause = lua_toboolean(L, -1) == 1; OsEng.timeManager().time().setPause(pause); + + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -137,6 +142,7 @@ int time_setTime(lua_State* L) { OsEng.timeManager().time().setTime(time); return 0; } + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -148,6 +154,7 @@ int time_setTime(lua_State* L) { */ int time_currentTime(lua_State* L) { lua_pushnumber(L, OsEng.timeManager().time().j2000Seconds()); + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -159,6 +166,7 @@ int time_currentTime(lua_State* L) { */ int time_currentTimeUTC(lua_State* L) { lua_pushstring(L, OsEng.timeManager().time().UTC().c_str()); + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } @@ -182,6 +190,7 @@ int time_currentWallTime(lua_State* L) { utcTime->tm_sec ); lua_pushstring(L, time.c_str()); + ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; } From 2cd16e54b118c1af3c41d3a6a69a20a789c6cb41 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 9 Feb 2018 13:15:21 -0500 Subject: [PATCH 024/131] Replace initialize list of LuaLibrary with explicit instantiation (closes #477) --- modules/globebrowsing/globebrowsingmodule.cpp | 164 +++++++++--------- 1 file changed, 83 insertions(+), 81 deletions(-) diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 5608b2dafe..f106725005 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -226,92 +226,94 @@ globebrowsing::cache::MemoryAwareTileCache* GlobeBrowsingModule::tileCache() { scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const { std::string listLayerGroups = layerGroupNamesList(); - return { - "globebrowsing", + + scripting::LuaLibrary res; + res.name = "globebrowsing"; + res.functions = { { - { - "addLayer", - &globebrowsing::luascriptfunctions::addLayer, - {}, - "string, string, table", - "Adds a layer to the specified globe. The first argument specifies the " - "name of the scene graph node of which to add the layer. The renderable " - "of the specified scene graph node needs to be a renderable globe. " - "The second argument is the layer group which can be any of " - + listLayerGroups + ". The third argument is the dictionary defining the " - "layer." - }, - { - "deleteLayer", - &globebrowsing::luascriptfunctions::deleteLayer, - {}, - "string, string", - "Removes a layer from the specified globe. The first argument specifies " - "the name of the scene graph node of which to remove the layer. " - "The renderable of the specified scene graph node needs to be a " - "renderable globe. The second argument is the layer group which can be " - "any of " + listLayerGroups + ". The third argument is the dictionary" - "defining the layer." - }, - { - "goToChunk", - &globebrowsing::luascriptfunctions::goToChunk, - {}, - "void", - "Go to chunk with given index x, y, level" - }, - { - "goToGeo", - &globebrowsing::luascriptfunctions::goToGeo, - {}, - "number, number, number", - "Go to geographic coordinates latitude and longitude" - }, - { - "getGeoPosition", - &globebrowsing::luascriptfunctions::getGeoPosition, - {}, - "void", - "Get geographic coordinates of the camera poosition in latitude, " - "longitude, and altitude" - }, -#ifdef GLOBEBROWSING_USE_GDAL - { - "loadWMSCapabilities", - &globebrowsing::luascriptfunctions::loadWMSCapabilities, - {}, - "string, string, string", - "Loads and parses the WMS capabilities xml file from a remote server. " - "The first argument is the name of the capabilities that can be used to " - "later refer to the set of capabilities. The second argument is the " - "globe for which this server is applicable. The third argument is the " - "URL at which the capabilities file can be found." - }, - { - "removeWMSServer", - &globebrowsing::luascriptfunctions::removeWMSServer, - {}, - "string", - "Removes the WMS server identified by the first argument from the list " - "of available servers. The parameter corrsponds to the first argument in " - "the loadWMSCapabilities call that was used to load the WMS server." - }, - { - "capabilitiesWMS", - &globebrowsing::luascriptfunctions::capabilities, - {}, - "string", - "Returns an array of tables that describe the available layers that are " - "supported by the WMS server identified by the provided name. The 'URL'" - "component of the returned table can be used in the 'FilePath' argument " - "for a call to the 'addLayer' function to add the value to a globe." - } -#endif // GLOBEBROWSING_USE_GDAL + "addLayer", + &globebrowsing::luascriptfunctions::addLayer, + {}, + "string, string, table", + "Adds a layer to the specified globe. The first argument specifies the " + "name of the scene graph node of which to add the layer. The renderable " + "of the specified scene graph node needs to be a renderable globe. " + "The second argument is the layer group which can be any of " + + listLayerGroups + ". The third argument is the dictionary defining the " + "layer." }, { - absPath("${MODULE_GLOBEBROWSING}/scripts/layer_support.lua") + "deleteLayer", + &globebrowsing::luascriptfunctions::deleteLayer, + {}, + "string, string", + "Removes a layer from the specified globe. The first argument specifies " + "the name of the scene graph node of which to remove the layer. " + "The renderable of the specified scene graph node needs to be a " + "renderable globe. The second argument is the layer group which can be " + "any of " + listLayerGroups + ". The third argument is the dictionary" + "defining the layer." + }, + { + "goToChunk", + &globebrowsing::luascriptfunctions::goToChunk, + {}, + "void", + "Go to chunk with given index x, y, level" + }, + { + "goToGeo", + &globebrowsing::luascriptfunctions::goToGeo, + {}, + "number, number, number", + "Go to geographic coordinates latitude and longitude" + }, + { + "getGeoPosition", + &globebrowsing::luascriptfunctions::getGeoPosition, + {}, + "void", + "Get geographic coordinates of the camera poosition in latitude, " + "longitude, and altitude" + }, +#ifdef GLOBEBROWSING_USE_GDAL + { + "loadWMSCapabilities", + &globebrowsing::luascriptfunctions::loadWMSCapabilities, + {}, + "string, string, string", + "Loads and parses the WMS capabilities xml file from a remote server. " + "The first argument is the name of the capabilities that can be used to " + "later refer to the set of capabilities. The second argument is the " + "globe for which this server is applicable. The third argument is the " + "URL at which the capabilities file can be found." + }, + { + "removeWMSServer", + &globebrowsing::luascriptfunctions::removeWMSServer, + {}, + "string", + "Removes the WMS server identified by the first argument from the list " + "of available servers. The parameter corrsponds to the first argument in " + "the loadWMSCapabilities call that was used to load the WMS server." + }, + { + "capabilitiesWMS", + &globebrowsing::luascriptfunctions::capabilities, + {}, + "string", + "Returns an array of tables that describe the available layers that are " + "supported by the WMS server identified by the provided name. The 'URL'" + "component of the returned table can be used in the 'FilePath' argument " + "for a call to the 'addLayer' function to add the value to a globe." } +#endif // GLOBEBROWSING_USE_GDAL }; + res.scripts = { + absPath("${MODULE_GLOBEBROWSING}/scripts/layer_support.lua") + }; + + return res; } void GlobeBrowsingModule::goToChunk(int x, int y, int level) { From baa73f2af1fc258a2d8c0605a916cb6aaedb273f Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 12 Feb 2018 08:52:16 -0500 Subject: [PATCH 025/131] Partial compile fix for Jenkins --- include/openspace/util/timeconversion.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index c9ea8452eb..72cb04cf49 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -158,12 +158,9 @@ constexpr TimeUnit timeUnitFromString(const char* unitName) { ++i; } - ghoul_assert(false, "Unit name is not a valid name"); throw ghoul::MissingCaseException(); } - - std::pair simplifyTime(double seconds, bool forceSingularForm = false); From 539c0d755496df3be98e702883e701c86fda567a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 12 Feb 2018 10:12:56 -0500 Subject: [PATCH 026/131] Fixing correct C++17 specification in CMake (trying to fix #501) --- ext/ghoul | 2 +- include/openspace/util/timeconversion.h | 4 ++-- support/cmake/set_openspace_compile_settings.cmake | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 2b5e82a6ff..84604ec42f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 2b5e82a6ff061bebd9c8b605160dafc6ade2ad65 +Subproject commit 84604ec42f6b43a690a3b86d1e9ea93738ea9f7c diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index 72cb04cf49..a36c92aff0 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -82,13 +82,13 @@ constexpr const char* TimeUnitDays = "days"; constexpr const char* TimeUnitMonths = "months"; constexpr const char* TimeUnitYears = "years"; -constexpr std::array(TimeUnit::Year) + 1> TimeUnits = { +constexpr const std::array(TimeUnit::Year) + 1> TimeUnits = { TimeUnit::Nanosecond, TimeUnit::Microsecond, TimeUnit::Millisecond, TimeUnit::Second, TimeUnit::Minute, TimeUnit::Hour, TimeUnit::Day, TimeUnit::Month, TimeUnit::Year }; -constexpr std::array(TimeUnit::Year) + 1> +constexpr const std::array(TimeUnit::Year) + 1> TimeUnitNamesSingular = { TimeUnitNanosecond, TimeUnitMicrosecond, TimeUnitMillisecond, TimeUnitSecond, TimeUnitMinute, TimeUnitHour, TimeUnitDay, TimeUnitMonth, TimeUnitYear diff --git a/support/cmake/set_openspace_compile_settings.cmake b/support/cmake/set_openspace_compile_settings.cmake index a2efd237d1..78a82ef70b 100644 --- a/support/cmake/set_openspace_compile_settings.cmake +++ b/support/cmake/set_openspace_compile_settings.cmake @@ -24,7 +24,7 @@ function (set_openspace_compile_settings project) set_property(TARGET ${project} PROPERTY CXX_STANDARD 17) - set_property(TARGET ${project} PROPERTY CXX_STANDARD_REQUIRED On) + set_property(TARGET ${project} PROPERTY CXX_STANDARD_REQUIRED ON) if (MSVC) target_compile_options( From d4e9438fd9323d6155ea0b0317246fd007846657 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Mon, 12 Feb 2018 11:35:32 -0500 Subject: [PATCH 027/131] Fixed issue 435. --- modules/space/shaders/star_vs.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/space/shaders/star_vs.glsl b/modules/space/shaders/star_vs.glsl index ed6ff8d193..7ff61c0f5e 100644 --- a/modules/space/shaders/star_vs.glsl +++ b/modules/space/shaders/star_vs.glsl @@ -52,7 +52,7 @@ void main() { vec4 position = pscTransform(tmp, mat4(1.0)); // G-Buffer - vs_gPosition = position; + vs_gPosition = view * (vec4(1E19, 1E19, 1E19, 1.0) * position); position = view * position; From 6723cda7c97c8b8cf4a468e8f98ba87295db36ca Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 12 Feb 2018 11:36:46 -0500 Subject: [PATCH 028/131] Make use of new constexpr MissingCaseException --- ext/ghoul | 2 +- include/openspace/util/timeconversion.h | 34 ++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 84604ec42f..6053fa8c0f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 84604ec42f6b43a690a3b86d1e9ea93738ea9f7c +Subproject commit 6053fa8c0f3d2100794716e9f691784d3a752993 diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index a36c92aff0..dd268850b9 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -121,23 +121,23 @@ constexpr bool isValidTimeUnitName(const char* name) { constexpr const char* nameForTimeUnit(TimeUnit unit, bool pluralForm = false) { switch (unit) { - case TimeUnit::Nanosecond: - case TimeUnit::Microsecond: - case TimeUnit::Millisecond: - case TimeUnit::Second: - case TimeUnit::Minute: - case TimeUnit::Hour: - case TimeUnit::Day: - case TimeUnit::Month: - case TimeUnit::Year: - if (pluralForm) { - return TimeUnitNamesPlural[static_cast(unit)]; - } - else { - return TimeUnitNamesSingular[static_cast(unit)]; - } - default: - throw ghoul::MissingCaseException(); + case TimeUnit::Nanosecond: + case TimeUnit::Microsecond: + case TimeUnit::Millisecond: + case TimeUnit::Second: + case TimeUnit::Minute: + case TimeUnit::Hour: + case TimeUnit::Day: + case TimeUnit::Month: + case TimeUnit::Year: + if (pluralForm) { + return TimeUnitNamesPlural[static_cast(unit)]; + } + else { + return TimeUnitNamesSingular[static_cast(unit)]; + } + default: + throw ghoul::MissingCaseException(); } } From 5fe6c89b9886d5adb444ba72658d6078243b9193 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 12 Feb 2018 13:06:15 -0500 Subject: [PATCH 029/131] Try to make Jenkins happy --- ext/ghoul | 2 +- include/openspace/util/timeconversion.h | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 6053fa8c0f..ff05da55fa 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 6053fa8c0f3d2100794716e9f691784d3a752993 +Subproject commit ff05da55fafffb871a43afe13ded248ea8a5206e diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index dd268850b9..a6d3a4feeb 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -142,10 +142,12 @@ constexpr const char* nameForTimeUnit(TimeUnit unit, bool pluralForm = false) { } constexpr TimeUnit timeUnitFromString(const char* unitName) { + int found = -1; int i = 0; for (const char* val : TimeUnitNamesSingular) { if (ghoul::equal(unitName, val)) { - return static_cast(i); + found = i; + break; } ++i; } @@ -153,12 +155,18 @@ constexpr TimeUnit timeUnitFromString(const char* unitName) { i = 0; for (const char* val : TimeUnitNamesPlural) { if (ghoul::equal(unitName, val)) { - return static_cast(i); + found = i; + break; } ++i; } - throw ghoul::MissingCaseException(); + if (found != -1) { + return static_cast(found); + } + else { + throw ghoul::MissingCaseException(); + } } std::pair simplifyTime(double seconds, From cddde1c307e4b56dbd6a709e122c287321821d17 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 12 Feb 2018 15:46:36 -0500 Subject: [PATCH 030/131] Fix DistanceConversion --- ext/ghoul | 2 +- include/openspace/util/distanceconversion.h | 22 ++++++++++++++------- include/openspace/util/timeconversion.h | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index ff05da55fa..f05a67467b 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit ff05da55fafffb871a43afe13ded248ea8a5206e +Subproject commit f05a67467bbcfb2332b04fc5dfad9116284459d1 diff --git a/include/openspace/util/distanceconversion.h b/include/openspace/util/distanceconversion.h index 80a3a962da..9331b26364 100644 --- a/include/openspace/util/distanceconversion.h +++ b/include/openspace/util/distanceconversion.h @@ -85,7 +85,7 @@ constexpr const char* DistanceUnitKiloparsecs = "kiloparsecs"; constexpr const char* DistanceUnitMegaparsecs = "megaparsecs"; constexpr const char* DistanceUnitGigaparsecs = "gigaparsecs"; -constexpr std::array(DistanceUnit::Gigaparsec) + 1> +constexpr const std::array(DistanceUnit::Gigaparsec) + 1> DistanceUnits = { DistanceUnit::Nanometer, DistanceUnit::Micrometer, DistanceUnit::Millimeter, DistanceUnit::Meter, DistanceUnit::Kilometer, DistanceUnit::AU, @@ -94,7 +94,7 @@ DistanceUnits = { DistanceUnit::Megaparsec, DistanceUnit::Gigaparsec }; -constexpr std::array(DistanceUnit::Gigaparsec) + 1> +constexpr const std::array(DistanceUnit::Gigaparsec) + 1> DistanceUnitNamesSingular = { DistanceUnitNanometer, DistanceUnitMicrometer, DistanceUnitMillimeter, DistanceUnitMeter, DistanceUnitKilometer, DistanceUnitAU, DistanceUnitLighthour, @@ -103,7 +103,7 @@ DistanceUnitNamesSingular = { DistanceUnitGigaparsec }; -constexpr std::array(DistanceUnit::Gigaparsec) + 1> +constexpr const std::array(DistanceUnit::Gigaparsec) + 1> DistanceUnitNamesPlural = { DistanceUnitNanometers, DistanceUnitMicrometers, DistanceUnitMillimeters, DistanceUnitMeters, DistanceUnitKilometers, DistanceUnitAUs, DistanceUnitLighthours, @@ -159,10 +159,12 @@ constexpr const char* nameForDistanceUnit(DistanceUnit unit, bool pluralForm = f } constexpr DistanceUnit distanceUnitFromString(const char* unitName) { + int found = -1; int i = 0; for (const char* val : DistanceUnitNamesSingular) { if (ghoul::equal(unitName, val)) { - return static_cast(i); + found = i; + break; } ++i; } @@ -170,13 +172,19 @@ constexpr DistanceUnit distanceUnitFromString(const char* unitName) { i = 0; for (const char* val : DistanceUnitNamesPlural) { if (ghoul::equal(unitName, val)) { - return static_cast(i); + found = i; + break; } ++i; } - ghoul_assert(false, "Unit name is not a valid name"); - throw ghoul::MissingCaseException(); + + if (found != -1) { + return static_cast(found); + } + else { + throw ghoul::MissingCaseException(); + } } diff --git a/include/openspace/util/timeconversion.h b/include/openspace/util/timeconversion.h index a6d3a4feeb..0cee0d746c 100644 --- a/include/openspace/util/timeconversion.h +++ b/include/openspace/util/timeconversion.h @@ -94,7 +94,7 @@ TimeUnitNamesSingular = { TimeUnitMinute, TimeUnitHour, TimeUnitDay, TimeUnitMonth, TimeUnitYear }; -constexpr std::array(TimeUnit::Year) + 1> +constexpr const std::array(TimeUnit::Year) + 1> TimeUnitNamesPlural = { TimeUnitNanoseconds, TimeUnitMicroseconds, TimeUnitMilliseconds, TimeUnitSeconds, TimeUnitMinutes, TimeUnitHours, TimeUnitDays, TimeUnitMonths, TimeUnitYears From fc104c8b3d1f4e9768a83bb2790022fba52e7e67 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 12 Feb 2018 16:17:51 -0500 Subject: [PATCH 031/131] Fix compile issue with asserts --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index f05a67467b..3ca461988a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit f05a67467bbcfb2332b04fc5dfad9116284459d1 +Subproject commit 3ca461988afebf98f9d31173e5a9ae93aea6c190 From ddb03976bc8c03e808cbd49a3df9c0fe56efd752 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 12 Feb 2018 21:42:53 -0500 Subject: [PATCH 032/131] Update Ghoul repository --- ext/ghoul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/ghoul b/ext/ghoul index 3ca461988a..c8d02417ef 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 3ca461988afebf98f9d31173e5a9ae93aea6c190 +Subproject commit c8d02417ef2bb16887e94adea8c82ab38716e7ec From 9a5ae0d950f4990ae4e54c40e892617ff0080b80 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 13 Feb 2018 10:38:47 -0500 Subject: [PATCH 033/131] Update version number --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20c192da47..c73f31f0f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ message(STATUS "Generating OpenSpace project") set(OPENSPACE_VERSION_MAJOR 0) set(OPENSPACE_VERSION_MINOR 11) -set(OPENSPACE_VERSION_PATCH 0) +set(OPENSPACE_VERSION_PATCH 1) set(OPENSPACE_VERSION_STRING "Beta-1") set(OPENSPACE_BASE_DIR "${PROJECT_SOURCE_DIR}") From b77b54e0f6f1a2a62d5b5a6269fa2f1f3e2b9349 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Wed, 14 Feb 2018 17:15:35 +0100 Subject: [PATCH 034/131] Clear lua stack in property_getValue --- src/scene/scene_lua.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 25bfeea128..1d3050f0b9 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -313,6 +313,7 @@ int property_getValue(lua_State* L) { SCRIPT_CHECK_ARGUMENTS("property_getValue", L, 1, nArguments); std::string uri = luaL_checkstring(L, -1); + lua_settop(L, 0); openspace::properties::Property* prop = property(uri); if (!prop) { From 9848eea5ac78cac82499a9f240d603a72c5d28bd Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 14 Feb 2018 17:16:54 -0500 Subject: [PATCH 035/131] Update Ghoul repository Adjust OnExit to use defer instead --- ext/ghoul | 2 +- .../imgui/src/guiglobebrowsingcomponent.cpp | 6 ++--- src/engine/openspaceengine.cpp | 23 +++++++------------ src/performance/performancemanager.cpp | 6 +++-- src/scene/assetloader.cpp | 6 ++--- src/scene/scene.cpp | 1 - src/util/taskloader.cpp | 1 - 7 files changed, 18 insertions(+), 27 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 84604ec42f..96d695afba 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 84604ec42f6b43a690a3b86d1e9ea93738ea9f7c +Subproject commit 96d695afba4cf8c06f11d64377228c7d665c3cee diff --git a/modules/imgui/src/guiglobebrowsingcomponent.cpp b/modules/imgui/src/guiglobebrowsingcomponent.cpp index 88c868f911..b752529318 100644 --- a/modules/imgui/src/guiglobebrowsingcomponent.cpp +++ b/modules/imgui/src/guiglobebrowsingcomponent.cpp @@ -39,9 +39,8 @@ #include #include -#include - #include +#include #include @@ -70,8 +69,7 @@ void GuiGlobeBrowsingComponent::render() { ImGui::Begin("Globe Browsing", &e, WindowSize, 0.5f); _isEnabled = e; _isCollapsed = ImGui::IsWindowCollapsed(); - OnExit([]() {ImGui::End(); }); // We escape early from this function in a few places - + defer { ImGui::End(); }; // Render the list of planets std::vector nodes = diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 59c5b1a435..a61dfbc0ad 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -72,7 +72,6 @@ #include #include -#include #include #include #include @@ -80,6 +79,7 @@ #include #include #include +#include #include #include @@ -636,12 +636,10 @@ void OpenSpaceEngine::loadSingleAsset(const std::string& assetPath) { windowWrapper().setBarrier(false); windowWrapper().setSynchronization(false); - OnExit( - [this]() { - windowWrapper().setSynchronization(true); - windowWrapper().setBarrier(true); - } - ); + defer { + windowWrapper().setSynchronization(true); + windowWrapper().setBarrier(true); + }; if (assetPath == "") { return; @@ -1352,10 +1350,6 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, ); } - OnExit([] { - LTRACE("OpenSpaceEngine::render(end)"); - }); - const bool isGuiWindow = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true; if (isGuiWindow) { @@ -1368,14 +1362,11 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, func(); } - + LTRACE("OpenSpaceEngine::render(end)"); } void OpenSpaceEngine::drawOverlays() { LTRACE("OpenSpaceEngine::drawOverlays(begin)"); - OnExit([] { - LTRACE("OpenSpaceEngine::drawOverlays(end)"); - }); std::unique_ptr perf; if (OsEng.renderEngine().performanceManager()) { @@ -1408,6 +1399,8 @@ void OpenSpaceEngine::drawOverlays() { for (const auto& func : _moduleCallbacks.draw2D) { func(); } + + LTRACE("OpenSpaceEngine::drawOverlays(end)"); } void OpenSpaceEngine::postDraw() { diff --git a/src/performance/performancemanager.cpp b/src/performance/performancemanager.cpp index 69b67f7cf3..c8aa7093e5 100644 --- a/src/performance/performancemanager.cpp +++ b/src/performance/performancemanager.cpp @@ -28,8 +28,8 @@ #include #include +#include #include -#include #include #include @@ -142,7 +142,9 @@ PerformanceManager::PerformanceManager(std::string loggingDirectory, std::string ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); sharedMemory.acquireLock(); - OnExit([&](){sharedMemory.releaseLock();}); + defer { + sharedMemory.releaseLock(); + }; GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); diff --git a/src/scene/assetloader.cpp b/src/scene/assetloader.cpp index f4dbb8fc37..97f35d7bcf 100644 --- a/src/scene/assetloader.cpp +++ b/src/scene/assetloader.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -250,9 +250,9 @@ bool AssetLoader::loadAsset(std::shared_ptr asset) { std::shared_ptr parentAsset = _currentAsset; setCurrentAsset(asset); - ghoul::OnScopeExit e([this, parentAsset] { + defer { setCurrentAsset(parentAsset); - }); + }; if (!FileSys.fileExists(asset->assetFilePath())) { LERROR("Could not load asset '" << asset->assetFilePath() << diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index fc41935d2e..b53e3247bb 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/src/util/taskloader.cpp b/src/util/taskloader.cpp index fb3ddfdd0d..1278b6b9f5 100644 --- a/src/util/taskloader.cpp +++ b/src/util/taskloader.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include From 475a9f6937d57b531d76d5ba2f7a72dc0ba57826 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 15 Feb 2018 10:37:49 -0500 Subject: [PATCH 036/131] Hide the overlay information on slave nodes --- include/openspace/engine/openspaceengine.h | 25 ++++++++++--------- include/openspace/rendering/renderengine.h | 15 ++++++++---- src/engine/openspaceengine.cpp | 20 ++++------------ src/rendering/renderengine.cpp | 28 ++++++++++++++++++++++ 4 files changed, 56 insertions(+), 32 deletions(-) diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 386da78ffd..33d40baead 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -72,8 +72,21 @@ namespace scripting { class ScriptScheduler; } // namespace scripting + // Structure that is responsible for the delayed shutdown of the application +struct ShutdownInformation { + // Whether the application is currently in shutdown mode (i.e. counting down the + // timer and closing it at '0' + bool inShutdown; + // Total amount of time the application will wait before actually shutting down + float waitTime; + // Current state of the countdown; if it reaches '0', the application will + // close + float timer; +}; + class OpenSpaceEngine { public: + static void create(int argc, char** argv, std::unique_ptr windowWrapper, std::vector& sgctArguments, @@ -249,17 +262,7 @@ private: std::vector> mouseScrollWheel; } _moduleCallbacks; - // Structure that is responsible for the delayed shutdown of the application - struct { - // Whether the application is currently in shutdown mode (i.e. counting down the - // timer and closing it at '0' - bool inShutdown; - // Total amount of time the application will wait before actually shutting down - float waitTime; - // Current state of the countdown; if it reaches '0', the application will - // close - float timer; - } _shutdown; + ShutdownInformation _shutdown; // The first frame might take some more time in the update loop, so we need to know to // disable the synchronization; otherwise a hardware sync will kill us after 1 minute diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 6433da0aeb..c25600c091 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -53,6 +53,7 @@ class Scene; class SceneManager; class ScreenLog; class ScreenSpaceRenderable; +struct ShutdownInformation; class Syncable; class SyncBuffer; @@ -90,11 +91,7 @@ public: void render(const glm::mat4& sceneMatrix, const glm::mat4& viewMatrix, const glm::mat4& projectionMatrix); - void renderScreenLog(); - void renderVersionInformation(); - void renderCameraInformation(); - void renderShutdownInformation(float timer, float fullTime); - void renderDashboard(); + void renderOverlays(const ShutdownInformation& shutdownInfo); void postDraw(); // Performance measurements @@ -174,6 +171,13 @@ private: void setRenderer(std::unique_ptr renderer); RendererImplementation rendererFromString(const std::string& method) const; + void renderScreenLog(); + void renderVersionInformation(); + void renderCameraInformation(); + void renderShutdownInformation(float timer, float fullTime); + void renderDashboard(); + + Camera* _camera; Scene* _scene; std::unique_ptr _raycasterManager; @@ -188,6 +192,7 @@ private: ghoul::Dictionary _resolveData; ScreenLog* _log; + properties::BoolProperty _showOverlayOnSlaves; properties::BoolProperty _showLog; properties::BoolProperty _showVersionInfo; properties::BoolProperty _showCameraInfo; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index a61dfbc0ad..2581fa3ec2 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1347,7 +1347,7 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, perf = std::make_unique( "OpenSpaceEngine::render", OsEng.renderEngine().performanceManager() - ); + ); } const bool isGuiWindow = @@ -1373,26 +1373,14 @@ void OpenSpaceEngine::drawOverlays() { perf = std::make_unique( "OpenSpaceEngine::drawOverlays", OsEng.renderEngine().performanceManager() - ); + ); } const bool isGuiWindow = _windowWrapper->hasGuiWindow() ? _windowWrapper->isGuiWindow() : true; if (isGuiWindow) { - _renderEngine->renderScreenLog(); - _renderEngine->renderVersionInformation(); - _renderEngine->renderDashboard(); - - if (!_shutdown.inShutdown) { - // We render the camera information in the same location as the shutdown info - // and we won't need this if we are shutting down - _renderEngine->renderCameraInformation(); - } - else { - // If we are in shutdown mode, we can display the remaining time - _renderEngine->renderShutdownInformation(_shutdown.timer, _shutdown.waitTime); - } + _renderEngine->renderOverlays(_shutdown); _console->render(); } @@ -1411,7 +1399,7 @@ void OpenSpaceEngine::postDraw() { perf = std::make_unique( "OpenSpaceEngine::postDraw", OsEng.renderEngine().performanceManager() - ); + ); } _renderEngine->postDraw(); diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 3527e261fa..538fc2df7b 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -116,6 +116,13 @@ namespace { "example)." }; + static const openspace::properties::Property::PropertyInfo ShowOverlaySlavesInfo = { + "ShowOverlayOnSlaves", + "Show Overlay Information on Slaves", + "If this value is enabled, the overlay information text is also automatically " + "rendered on the slave nodes. This values is disabled by default." + }; + static const openspace::properties::Property::PropertyInfo ShowLogInfo = { "ShowLog", "Show the on-screen log", @@ -226,6 +233,7 @@ RenderEngine::RenderEngine() , _renderer(nullptr) , _rendererImplementation(RendererImplementation::Invalid) , _log(nullptr) + , _showOverlayOnSlaves(ShowOverlaySlavesInfo, false) , _showLog(ShowLogInfo, true) , _showVersionInfo(ShowVersionInfo, true) , _showCameraInfo(ShowCameraInfo, true) @@ -276,6 +284,7 @@ RenderEngine::RenderEngine() }); addProperty(_doPerformanceMeasurements); + addProperty(_showOverlayOnSlaves); addProperty(_showLog); addProperty(_showVersionInfo); addProperty(_showCameraInfo); @@ -602,6 +611,25 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat LTRACE("RenderEngine::render(end)"); } +void RenderEngine::renderOverlays(const ShutdownInformation& info) { + const bool isMaster = OsEng.windowWrapper().isMaster(); + if (isMaster || _showOverlayOnSlaves) { + renderScreenLog(); + renderVersionInformation(); + renderDashboard(); + + if (!info.inShutdown) { + // We render the camera information in the same location as the shutdown info + // and we won't need this if we are shutting down + renderCameraInformation(); + } + else { + // If we are in shutdown mode, we can display the remaining time + renderShutdownInformation(info.timer, info.waitTime); + } + } +} + void RenderEngine::renderShutdownInformation(float timer, float fullTime) { timer = timer < 0.f ? 0.f : timer; From 6d7608037094a972626fd52860f0961e44a09fe3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 15 Feb 2018 17:56:12 -0500 Subject: [PATCH 037/131] Simplify script precondition argument checks --- ext/ghoul | 2 +- include/openspace/scripting/script_helper.h | 35 ---------- .../base/rendering/screenspacedashboard.cpp | 14 ++-- .../globebrowsing/globebrowsingmodule_lua.inl | 65 +++++-------------- modules/iswa/util/iswamanager.cpp | 1 - src/CMakeLists.txt | 1 - src/engine/moduleengine_lua.inl | 13 ++-- src/engine/wrapper/windowwrapper.cpp | 5 +- src/interaction/keybindingmanager_lua.inl | 38 ++++------- src/interaction/navigationhandler_lua.inl | 37 ++++------- src/mission/missionmanager_lua.inl | 34 ++++------ src/network/parallelconnection.cpp | 1 - src/network/parallelconnection_lua.inl | 12 ++-- src/rendering/dashboard_lua.inl | 10 +-- src/rendering/renderengine_lua.inl | 36 +++------- src/scene/assetloader.cpp | 50 +++++++------- src/scene/assetmanager.cpp | 2 - src/scene/assetmanager_lua.inl | 27 ++++---- src/scene/scene.cpp | 1 - src/scene/scene_lua.inl | 26 +++----- src/scripting/scriptengine_lua.inl | 60 ++++++----------- src/scripting/scriptscheduler_lua.inl | 22 +++---- src/scripting/systemcapabilitiesbinding.cpp | 11 ++-- src/util/spicemanager_lua.inl | 11 +--- src/util/time_lua.inl | 11 +--- 25 files changed, 171 insertions(+), 354 deletions(-) delete mode 100644 include/openspace/scripting/script_helper.h diff --git a/ext/ghoul b/ext/ghoul index 96d695afba..dcbf53a697 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 96d695afba4cf8c06f11d64377228c7d665c3cee +Subproject commit dcbf53a6972bcfddf3136fc89258db8c4f22dbd3 diff --git a/include/openspace/scripting/script_helper.h b/include/openspace/scripting/script_helper.h deleted file mode 100644 index b6ad1cf90d..0000000000 --- a/include/openspace/scripting/script_helper.h +++ /dev/null @@ -1,35 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2018 * - * * - * 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___SCRIPT_HELPER___H__ -#define __OPENSPACE_CORE___SCRIPT_HELPER___H__ - -#define SCRIPT_CHECK_ARGUMENTS(__category__, __stack__, __reqArg__, __realArg__) \ - if (__realArg__ != __reqArg__) { \ - LERRORC(__category__, ghoul::lua::errorLocation(__stack__) << "Expected " << \ - __reqArg__ << " arguments, got " << __realArg__); \ - return 0; \ - } - -#endif // __OPENSPACE_CORE___SCRIPT_HELPER___H__ diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index 107fe9bbb7..df3bf45500 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -61,10 +61,7 @@ namespace luascriptfunctions { * addDashboardItemToScreenSpace(string, table): */ int addDashboardItemToScreenSpace(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 2) { - return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::addDashboardItemToScreenSpace"); std::string name = luaL_checkstring(L, -2); int type = lua_type(L, -1); @@ -97,6 +94,8 @@ int addDashboardItemToScreenSpace(lua_State* L) { } dash->dashboard().addDashboardItem(DashboardItem::createFromDictionary(d)); + + lua_settop(L, 0); return 0; } } @@ -106,12 +105,9 @@ int addDashboardItemToScreenSpace(lua_State* L) { * removeDashboardItemsFromScreenSpace(string): */ int removeDashboardItemsFromScreenSpace(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeDashboardItemsFromScreenSpace"); - std::string name = luaL_checkstring(L, -1); + std::string name = ghoul::lua::checkStringAndPop(L); std::shared_ptr ssr = OsEng.renderEngine().screenSpaceRenderable(name); diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index e4a14583d0..c35807d5c8 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -41,17 +41,14 @@ namespace openspace::globebrowsing::luascriptfunctions { *Adds a layer to the specified globe. */ int addLayer(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::addLayer"); + using ghoul::lua::errorLocation; // Argument locations const int GlobeLocation = -3; const int LayerGroupLocation = -2; - int nArguments = lua_gettop(L); - if (nArguments != 3) { - return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments); - } - // String arguments const std::string GlobeName = luaL_checkstring(L, GlobeLocation); const std::string LayerGroupName = luaL_checkstring(L, LayerGroupLocation); @@ -99,6 +96,8 @@ int addLayer(lua_State* L) { Deletes a layer from the specified globe. */ int deleteLayer(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::deleteLayer"); + using ghoul::lua::errorLocation; // Argument locations @@ -106,11 +105,6 @@ int deleteLayer(lua_State* L) { const int LayerGroupLocation = -2; const int NameLocation = -1; - int nArguments = lua_gettop(L); - if (nArguments != 3) { - return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments); - } - // String arguments const std::string GlobeName = luaL_checkstring(L, GlobeLocation); const std::string LayerGroupName = luaL_checkstring(L, LayerGroupLocation); @@ -143,13 +137,9 @@ int deleteLayer(lua_State* L) { } int goToChunk(lua_State* L) { - using ghoul::lua::luaTypeToString; + ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::goToChunk"); - // Check arguments - int nArguments = lua_gettop(L); - if (nArguments != 3) { - return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments); - } + using ghoul::lua::luaTypeToString; int x = static_cast(lua_tonumber(L, 1)); int y = static_cast(lua_tonumber(L, 2)); @@ -163,13 +153,10 @@ int goToChunk(lua_State* L) { } int goToGeo(lua_State* L) { + int nArguments = ghoul::lua::checkArgumentsAndThrow(L, 2, 3, "lua::goToGeo"); + using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 2 && nArguments != 3) { - return luaL_error(L, "Expected 2 or 3 arguments."); - } - double latitude = lua_tonumber(L, 1); double longitude = lua_tonumber(L, 2); @@ -188,10 +175,8 @@ int goToGeo(lua_State* L) { } int getGeoPosition(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) { - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::getGeoPosition"); + GlobeBrowsingModule* module = OsEng.moduleEngine().module(); RenderableGlobe* globe = module->castFocusNodeRenderableToGlobe(); if (!globe) { @@ -224,16 +209,11 @@ int getGeoPosition(lua_State* L) { #ifdef GLOBEBROWSING_USE_GDAL int loadWMSCapabilities(lua_State* L) { - int nArguments = lua_gettop(L); + ghoul::lua::checkArgumentsAndThrow(L, 3, "lua::loadWMSCapabilities"); - if (nArguments != 3) { - return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments); - } - - std::string name = lua_tostring(L, -3); - std::string globe = lua_tostring(L, -2); - std::string url = lua_tostring(L, -1); - lua_settop(L, 0); + std::string url = ghoul::lua::checkStringAndPop(L); + std::string globe = ghoul::lua::checkStringAndPop(L); + std::string name = ghoul::lua::checkStringAndPop(L); OsEng.moduleEngine().module()->loadWMSCapabilities( std::move(name), @@ -246,15 +226,10 @@ int loadWMSCapabilities(lua_State* L) { } int removeWMSServer(lua_State* L) { - int nArguments = lua_gettop(L); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeWMSServer"); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + std::string name = ghoul::lua::checkStringAndPop(L); - std::string name = lua_tostring(L, -1); - - lua_settop(L, 0); OsEng.moduleEngine().module()->removeWMSServer(name); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); @@ -262,13 +237,9 @@ int removeWMSServer(lua_State* L) { } int capabilities(lua_State* L) { - int nArguments = lua_gettop(L); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::capabilities"); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } - - std::string name = lua_tostring(L, -1); + std::string name = ghoul::lua::checkStringAndPop(L); GlobeBrowsingModule::Capabilities cap = OsEng.moduleEngine().module()->capabilities(name); diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index 48bda3fc38..df829853f4 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 758585038b..58dde2a0ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -323,7 +323,6 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/scene/scenelicensewriter.h ${OPENSPACE_BASE_DIR}/include/openspace/scene/scenegraphnode.h ${OPENSPACE_BASE_DIR}/include/openspace/scripting/lualibrary.h - ${OPENSPACE_BASE_DIR}/include/openspace/scripting/script_helper.h ${OPENSPACE_BASE_DIR}/include/openspace/scripting/scriptengine.h ${OPENSPACE_BASE_DIR}/include/openspace/scripting/scriptscheduler.h ${OPENSPACE_BASE_DIR}/include/openspace/scripting/systemcapabilitiesbinding.h diff --git a/src/engine/moduleengine_lua.inl b/src/engine/moduleengine_lua.inl index 8176fabf44..e2db06bcc0 100644 --- a/src/engine/moduleengine_lua.inl +++ b/src/engine/moduleengine_lua.inl @@ -33,13 +33,12 @@ namespace openspace::luascriptfunctions { * Checks whether the passed OpenSpaceModule is loaded or not */ int isLoaded(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::isLoaded"); const int type = lua_type(L, -1); - if (type != LUA_TSTRING) + if (type != LUA_TSTRING) { return luaL_error(L, "Expected argument of type 'string'"); + } std::string moduleName = lua_tostring(L, -1); std::vector modules = OsEng.moduleEngine().modules(); @@ -52,10 +51,12 @@ int isLoaded(lua_State* L) { } ); - if (it != modules.end()) + if (it != modules.end()) { lua_pushboolean(L, 1); - else + } + else { lua_pushboolean(L, 0); + } ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); return 1; diff --git a/src/engine/wrapper/windowwrapper.cpp b/src/engine/wrapper/windowwrapper.cpp index c77d7286fc..3cc0d7fcad 100644 --- a/src/engine/wrapper/windowwrapper.cpp +++ b/src/engine/wrapper/windowwrapper.cpp @@ -34,10 +34,7 @@ namespace luascriptfunctions { int setSynchronization(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setSynchronization"); bool b = lua_toboolean(L, -1) != 0; OsEng.windowWrapper().setSynchronization(b); diff --git a/src/interaction/keybindingmanager_lua.inl b/src/interaction/keybindingmanager_lua.inl index ec1f0d0096..6dfece8285 100644 --- a/src/interaction/keybindingmanager_lua.inl +++ b/src/interaction/keybindingmanager_lua.inl @@ -34,10 +34,7 @@ namespace openspace::luascriptfunctions { int bindKey(lua_State* L) { using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 2 && nArguments != 3) { - return luaL_error(L, "Expected %i or %i arguments, got %i", 2, 3, nArguments); - } + int nArguments = ghoul::lua::checkArgumentsAndThrow(L, 2, 3, "lua::bindKey"); int KeyLocation = nArguments == 3 ? -3 : -2; int CommandLocation = nArguments == 3 ? -2 : -1; @@ -69,7 +66,7 @@ int bindKey(lua_State* L) { std::move(documentation) ); - lua_settop(L, 0); + lua_pop(L, nArguments); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -82,10 +79,8 @@ int bindKey(lua_State* L) { int bindKeyLocal(lua_State* L) { using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 2 && nArguments != 3) { - return luaL_error(L, "Expected %i or %i arguments, got %i", 2, 3, nArguments); - } + int nArguments = ghoul::lua::checkArgumentsAndThrow(L, 2, 3, "lua::bindKeyLocal"); + int KeyLocation = nArguments == 3 ? -3 : -2; int CommandLocation = nArguments == 3 ? -2 : -1; @@ -115,9 +110,9 @@ int bindKeyLocal(lua_State* L) { iKey.modifier, std::move(command), std::move(documentation) - ); + ); - lua_settop(L, 0); + lua_pop(L, nArguments); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -129,13 +124,9 @@ int bindKeyLocal(lua_State* L) { * local or remote key binds */ int getKeyBindings(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::getKeyBindings"); - std::string key = luaL_checkstring(L, -1); - lua_settop(L, 0); + std::string key = ghoul::lua::checkStringAndPop(L); using KeyInformation = interaction::KeyBindingManager::KeyInformation; @@ -169,13 +160,9 @@ int getKeyBindings(lua_State* L) { * Clears the keybinding of the key named as argument */ int clearKey(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::clearKey"); - std::string key = luaL_checkstring(L, -1); - lua_settop(L, 0); + std::string key = ghoul::lua::checkStringAndPop(L); OsEng.keyBindingManager().removeKeyBinding(key); @@ -189,10 +176,7 @@ int clearKey(lua_State* L) { * Clears all key bindings */ int clearKeys(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) { - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearKeys"); OsEng.keyBindingManager().resetKeyBindings(); diff --git a/src/interaction/navigationhandler_lua.inl b/src/interaction/navigationhandler_lua.inl index 173fa84dee..9839d56fe1 100644 --- a/src/interaction/navigationhandler_lua.inl +++ b/src/interaction/navigationhandler_lua.inl @@ -25,30 +25,24 @@ namespace openspace::luascriptfunctions { int restoreCameraStateFromFile(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::restoreCameraStateFromFile"); + using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } - - std::string cameraStateFilePath = luaL_checkstring(L, -1); - lua_settop(L, 0); + std::string cameraStateFilePath = ghoul::lua::checkStringAndPop(L); if (cameraStateFilePath.empty()) { return luaL_error(L, "filepath string is empty"); } OsEng.navigationHandler().restoreCameraStateFromFile(cameraStateFilePath); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } int setCameraState(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setCameraState"); try { ghoul::Dictionary dictionary; @@ -59,40 +53,37 @@ int setCameraState(lua_State* L) { return luaL_error(L, "Could not set camera state: %s", e.what()); } + // @CLEANUP: When luaDictionaryFromState doesn't leak space anymore, remove the next + // line ---abock(2018-02-15) lua_settop(L, 0); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } int saveCameraStateToFile(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::saveCameraStateToFile"); + using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } - - std::string cameraStateFilePath = luaL_checkstring(L, -1); - lua_settop(L, 0); + std::string cameraStateFilePath = ghoul::lua::checkStringAndPop(L); if (cameraStateFilePath.empty()) { return luaL_error(L, "filepath string is empty"); } OsEng.navigationHandler().saveCameraStateToFile(cameraStateFilePath); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } int resetCameraDirection(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::resetCameraDirection"); + using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 0) { - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - } - OsEng.navigationHandler().resetCameraDirection(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } diff --git a/src/mission/missionmanager_lua.inl b/src/mission/missionmanager_lua.inl index fac99a845d..24b998e230 100644 --- a/src/mission/missionmanager_lua.inl +++ b/src/mission/missionmanager_lua.inl @@ -25,15 +25,13 @@ namespace openspace::luascriptfunctions { int loadMission(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadMission"); - std::string missionFileName = luaL_checkstring(L, -1); + std::string missionFileName = ghoul::lua::checkStringAndPop(L); if (missionFileName.empty()) { return luaL_error(L, "Filepath is empty"); } + std::string name = MissionManager::ref().loadMission(absPath(missionFileName)); lua_pushstring(L, name.c_str()); @@ -42,14 +40,11 @@ int loadMission(lua_State* L) { } int unloadMission(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::unloadMission"); - std::string missionName = luaL_checkstring(L, -1); + std::string missionName = ghoul::lua::checkStringAndPop(L); if (missionName.empty()) { - return luaL_error(L, "Missing name is empty"); + return luaL_error(L, "Mission name is empty"); } if (!MissionManager::ref().hasMission(missionName)) { @@ -63,16 +58,13 @@ int unloadMission(lua_State* L) { } int hasMission(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::hasMission"); - std::string missionName = luaL_checkstring(L, -1); + std::string missionName = ghoul::lua::checkStringAndPop(L); if (missionName.empty()) { return luaL_error(L, "Missing name is empty"); } - + bool hasMission = MissionManager::ref().hasMission(missionName); lua_pushboolean(L, hasMission); @@ -82,15 +74,13 @@ int hasMission(lua_State* L) { } int setCurrentMission(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setCurrentMission"); - std::string missionName = luaL_checkstring(L, -1); + std::string missionName = ghoul::lua::checkStringAndPop(L); if (missionName.empty()) { return luaL_error(L, "Mission name is empty"); } + MissionManager::ref().setCurrentMission(missionName); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); diff --git a/src/network/parallelconnection.cpp b/src/network/parallelconnection.cpp index a71a21b898..b8672de32b 100644 --- a/src/network/parallelconnection.cpp +++ b/src/network/parallelconnection.cpp @@ -82,7 +82,6 @@ using SocketResultType = size_t; #include #include #include -#include #include #include diff --git a/src/network/parallelconnection_lua.inl b/src/network/parallelconnection_lua.inl index 02ddb5aba4..df8ae51841 100644 --- a/src/network/parallelconnection_lua.inl +++ b/src/network/parallelconnection_lua.inl @@ -25,8 +25,7 @@ namespace openspace::luascriptfunctions { int connect(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("connect", L, 0, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::connect"); if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().clientConnect(); @@ -37,8 +36,7 @@ int connect(lua_State* L) { } int disconnect(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("disconnect", L, 0, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::disconnect"); if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().signalDisconnect(); @@ -49,8 +47,7 @@ int disconnect(lua_State* L) { } int requestHostship(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("requestHostship", L, 0, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::requestHostship"); if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().requestHostship(); @@ -61,8 +58,7 @@ int requestHostship(lua_State* L) { } int resignHostship(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("resignHostship", L, 0, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::resignHostship"); if (OsEng.windowWrapper().isMaster()) { OsEng.parallelConnection().resignHostship(); diff --git a/src/rendering/dashboard_lua.inl b/src/rendering/dashboard_lua.inl index bc8f29eb58..90de001788 100644 --- a/src/rendering/dashboard_lua.inl +++ b/src/rendering/dashboard_lua.inl @@ -33,10 +33,7 @@ namespace openspace::luascriptfunctions { * addDashboardItem(table): */ int addDashboardItem(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::addDashboardItem"); int type = lua_type(L, -1); if (type == LUA_TTABLE) { @@ -66,10 +63,7 @@ int addDashboardItem(lua_State* L) { * removeDashboardItems(): */ int removeDashboardItems(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments > 1) { - return luaL_error(L, "Expected %i or %i arguments, got %i", 0, 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::removeDashboardItems"); OsEng.dashboard().removeDashboardItems(); diff --git a/src/rendering/renderengine_lua.inl b/src/rendering/renderengine_lua.inl index 463bfdb592..c41da879b7 100644 --- a/src/rendering/renderengine_lua.inl +++ b/src/rendering/renderengine_lua.inl @@ -30,10 +30,7 @@ namespace openspace::luascriptfunctions { * Set renderer */ int setRenderer(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::setRenderer"); const int type = lua_type(L, -1); if (type != LUA_TSTRING) { @@ -52,10 +49,7 @@ int setRenderer(lua_State* L) { * Toggle a global fade over (float) seconds */ int toggleFade(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::toggleFade"); double t = luaL_checknumber(L, -1); @@ -74,10 +68,7 @@ int toggleFade(lua_State* L) { * start a global fadein over (float) seconds */ int fadeIn(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::fadeIn"); double t = luaL_checknumber(L, -1); @@ -92,10 +83,7 @@ int fadeIn(lua_State* L) { * start a global fadeout over (float) seconds */ int fadeOut(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::fadeOut"); double t = luaL_checknumber(L, -1); @@ -106,12 +94,9 @@ int fadeOut(lua_State* L) { } int addScreenSpaceRenderable(lua_State* L) { - using ghoul::lua::errorLocation; + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::addScreenSpaceRenderable"); - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + using ghoul::lua::errorLocation; ghoul::Dictionary d; try { @@ -132,14 +117,11 @@ int addScreenSpaceRenderable(lua_State* L) { } int removeScreenSpaceRenderable(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeScreenSpaceRenderable"); + using ghoul::lua::errorLocation; - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } - - std::string name = luaL_checkstring(L, -1); + std::string name = ghoul::lua::checkStringAndPop(L); std::shared_ptr s = OsEng.renderEngine().screenSpaceRenderable( name diff --git a/src/scene/assetloader.cpp b/src/scene/assetloader.cpp index 97f35d7bcf..b69063f9ee 100644 --- a/src/scene/assetloader.cpp +++ b/src/scene/assetloader.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -389,39 +388,43 @@ std::shared_ptr AssetLoader::getAsset(std::string name) { } int AssetLoader::onInitializeLua(Asset* asset) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("onInitialize", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::onInitialize"); + int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onInitializationFunctionRefs[asset].push_back(referenceIndex); + lua_settop(*_luaState, 0); return 0; } int AssetLoader::onDeinitializeLua(Asset* asset) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("onDeinitialize", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::onDeinitialize"); + int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onDeinitializationFunctionRefs[asset].push_back(referenceIndex); + lua_settop(*_luaState, 0); return 0; } int AssetLoader::onInitializeDependencyLua(Asset* dependant, Asset* dependency) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("onInitialize", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::onInitializeDependency"); + int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onDependencyInitializationFunctionRefs[dependant][dependency] .push_back(referenceIndex); + lua_settop(*_luaState, 0); return 0; } int AssetLoader::onDeinitializeDependencyLua(Asset* dependant, Asset* dependency) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("onDeinitialize", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::onDeinitializeDependency"); + int referenceIndex = luaL_ref(*_luaState, LUA_REGISTRYINDEX); _onDependencyDeinitializationFunctionRefs[dependant][dependency] .push_back(referenceIndex); + lua_settop(*_luaState, 0); return 0; } @@ -496,7 +499,7 @@ void AssetLoader::callOnInitialize(Asset* asset) { if (lua_pcall(*_luaState, 0, 0, 0) != LUA_OK) { throw ghoul::lua::LuaRuntimeException( "When initializing " + asset->assetFilePath() + ": " + - luaL_checkstring(*_luaState, -1) + ghoul::lua::checkStringAndPop(*_luaState) ); } // Clean up lua stack, in case the pcall left anything there. @@ -511,7 +514,7 @@ void AssetLoader::callOnDeinitialize(Asset * asset) { if (lua_pcall(*_luaState, 0, 0, 0) != LUA_OK) { throw ghoul::lua::LuaRuntimeException( "When deinitializing " + asset->assetFilePath() + ": " + - luaL_checkstring(*_luaState, -1) + ghoul::lua::checkStringAndPop(*_luaState) ); } // Clean up lua stack, in case the pcall left anything there. @@ -525,7 +528,7 @@ void AssetLoader::callOnDependencyInitialize(Asset* asset, Asset* dependant) { if (lua_pcall(*_luaState, 0, 0, 0) != LUA_OK) { throw ghoul::lua::LuaRuntimeException( "When initializing dependency " + dependant->assetFilePath() + " -> " + - asset->assetFilePath() + ": " + luaL_checkstring(*_luaState, -1) + asset->assetFilePath() + ": " + ghoul::lua::checkStringAndPop(*_luaState) ); } // Clean up lua stack, in case the pcall left anything there. @@ -543,7 +546,7 @@ void AssetLoader::callOnDependencyDeinitialize(Asset* asset, Asset* dependant) { if (lua_pcall(*_luaState, 0, 0, 0) != LUA_OK) { throw ghoul::lua::LuaRuntimeException( "When deinitializing dependency " + dependant->assetFilePath() + " -> " + - asset->assetFilePath() + ": " + luaL_checkstring(*_luaState, -1) + asset->assetFilePath() + ": " + ghoul::lua::checkStringAndPop(*_luaState) ); } // Clean up lua stack, in case the pcall left anything there. @@ -552,13 +555,11 @@ void AssetLoader::callOnDependencyDeinitialize(Asset* asset, Asset* dependant) { } int AssetLoader::localResourceLua(Asset* asset) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("localResource", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::localResourceLua"); - std::string resourceName = luaL_checkstring(*_luaState, -1); + std::string resourceName = ghoul::lua::checkStringAndPop(*_luaState); std::string resolved = asset->resolveLocalResource(resourceName); - lua_settop(*_luaState, 0); lua_pushstring(*_luaState, resolved.c_str()); ghoul_assert(lua_gettop(*_luaState) == 1, "Incorrect number of items left on stack"); @@ -566,8 +567,7 @@ int AssetLoader::localResourceLua(Asset* asset) { } int AssetLoader::syncedResourceLua(Asset* asset) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("syncedResource", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::syncedResourceLua"); ghoul::Dictionary d; ghoul::lua::luaDictionaryFromState(*_luaState, d); @@ -608,8 +608,7 @@ void AssetLoader::setCurrentAsset(std::shared_ptr asset) { } int AssetLoader::requireLua(Asset* dependant) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("require", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::require"); std::string assetName = luaL_checkstring(*_luaState, 1); lua_settop(*_luaState, 0); @@ -647,8 +646,7 @@ int AssetLoader::requireLua(Asset* dependant) { } int AssetLoader::requestLua(Asset* parent) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("request", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::request"); std::string assetName = luaL_checkstring(*_luaState, 1); lua_settop(*_luaState, 0); @@ -674,8 +672,7 @@ int AssetLoader::requestLua(Asset* parent) { } int AssetLoader::existsLua(Asset* asset) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("exists", *_luaState, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 1, "lua::exists"); std::string assetName = luaL_checkstring(*_luaState, 1); @@ -689,8 +686,7 @@ int AssetLoader::existsLua(Asset* asset) { } int AssetLoader::exportAssetLua(Asset* asset) { - int nArguments = lua_gettop(*_luaState); - SCRIPT_CHECK_ARGUMENTS("exportAsset", *_luaState, 2, nArguments); + ghoul::lua::checkArgumentsAndThrow(*_luaState, 2, "lua::exportAsset"); std::string exportName = luaL_checkstring(*_luaState, 1); diff --git a/src/scene/assetmanager.cpp b/src/scene/assetmanager.cpp index 7f8669ecdd..e91abf9b1a 100644 --- a/src/scene/assetmanager.cpp +++ b/src/scene/assetmanager.cpp @@ -24,8 +24,6 @@ #include -#include - #include #include #include diff --git a/src/scene/assetmanager_lua.inl b/src/scene/assetmanager_lua.inl index 5b79682208..a02c6ad58a 100644 --- a/src/scene/assetmanager_lua.inl +++ b/src/scene/assetmanager_lua.inl @@ -25,34 +25,39 @@ namespace openspace::luascriptfunctions::asset { int add(lua_State* state) { - AssetManager *assetManager = + ghoul::lua::checkArgumentsAndThrow(state, 1, "lua::add"); + + AssetManager* assetManager = reinterpret_cast(lua_touserdata(state, lua_upvalueindex(1))); - int nArguments = lua_gettop(state); - SCRIPT_CHECK_ARGUMENTS("add", state, 1, nArguments); - std::string assetName = luaL_checkstring(state, -1); + std::string assetName = ghoul::lua::checkStringAndPop(state); assetManager->add(assetName); + return 0; } int remove(lua_State* state) { - AssetManager *assetManager = + ghoul::lua::checkArgumentsAndThrow(state, 1, "lua::remove"); + + + AssetManager* assetManager = reinterpret_cast(lua_touserdata(state, lua_upvalueindex(1))); - int nArguments = lua_gettop(state); - SCRIPT_CHECK_ARGUMENTS("remove", state, 1, nArguments); - std::string assetName = luaL_checkstring(state, -1); + std::string assetName = ghoul::lua::checkStringAndPop(state); assetManager->remove(assetName); + return 0; } int removeAll(lua_State* state) { - AssetManager *assetManager = + ghoul::lua::checkArgumentsAndThrow(state, 0, "lua::removeAll"); + + + AssetManager* assetManager = reinterpret_cast(lua_touserdata(state, lua_upvalueindex(1))); - int nArguments = lua_gettop(state); - SCRIPT_CHECK_ARGUMENTS("removeAll", state, 0, nArguments); assetManager->removeAll(); + return 0; } diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index b53e3247bb..4fbfdc25fc 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 1d3050f0b9..2f0e22050d 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -169,8 +169,7 @@ int property_setValueSingle(lua_State* L) { using ghoul::lua::errorLocation; using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("property_setValueSingle", L, 2, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::property_setValueSingle"); std::string uri = luaL_checkstring(L, -2); const int type = lua_type(L, -1); @@ -226,8 +225,8 @@ int property_setValue(lua_State* L) { using ghoul::lua::errorLocation; using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("property_setGroup", L, 2, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::property_setGroup"); + std::string regex = luaL_checkstring(L, -2); std::string groupName; @@ -271,8 +270,8 @@ int property_setValueRegex(lua_State* L) { using ghoul::lua::errorLocation; using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("property_setValueRegex<", L, 2, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::property_setValueRegex"); + std::string regex = luaL_checkstring(L, -2); std::string groupName; @@ -309,8 +308,7 @@ int property_getValue(lua_State* L) { static const std::string _loggerCat = "property_getValue"; using ghoul::lua::errorLocation; - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("property_getValue", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::property_getValue"); std::string uri = luaL_checkstring(L, -1); lua_settop(L, 0); @@ -338,8 +336,7 @@ int property_getValue(lua_State* L) { * be passed to the setPropertyValue method. */ int loadScene(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("loadScene", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadScene"); std::string sceneFile = luaL_checkstring(L, -1); OsEng.scheduleLoadSingleAsset(sceneFile); @@ -351,8 +348,7 @@ int loadScene(lua_State* L) { int addSceneGraphNode(lua_State* L) { using ghoul::lua::errorLocation; - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("addSceneGraphNode", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::addSceneGraphNode"); ghoul::Dictionary d; try { @@ -391,8 +387,7 @@ int addSceneGraphNode(lua_State* L) { int removeSceneGraphNode(lua_State* L) { using ghoul::lua::errorLocation; - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("removeSceneGraphNode", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeSceneGraphNode"); std::string nodeName = luaL_checkstring(L, -1); SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(nodeName); @@ -421,8 +416,7 @@ int removeSceneGraphNode(lua_State* L) { int hasSceneGraphNode(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("hasSceneGraphNode", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::hasSceneGraphNode"); std::string nodeName = luaL_checkstring(L, -1); SceneGraphNode* node = OsEng.renderEngine().scene()->sceneGraphNode(nodeName); diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index c7e948f4be..91a61df7ae 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -31,10 +31,7 @@ namespace { // Defining a common walk function that works off a pointer-to-member function template int walkCommon(lua_State* L, Func func) { - const int nArguments = lua_gettop(L); - if (nArguments < 1 || nArguments > 3) { - return luaL_error(L, "Expected %i-%i arguments, got %i", 1, 3, nArguments); - } + int nArguments = ghoul::lua::checkArgumentsAndThrow(L, { 1, 3 }, "lua::walkCommon"); std::vector result; if (nArguments == 1) { @@ -87,13 +84,9 @@ int walkCommon(lua_State* L, Func func) { } // namespace int printInternal(ghoul::logging::LogLevel level, lua_State* L) { - using ghoul::lua::luaTypeToString; - const std::string _loggerCat = "print"; + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::printInternal"); - const int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + using ghoul::lua::luaTypeToString; const int type = lua_type(L, -1); switch (type) { @@ -195,13 +188,9 @@ int printFatal(lua_State* L) { * tokens and returns the absolute path. */ int absolutePath(lua_State* L) { - const int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %d arguments, got %d", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::absolutePath"); - std::string path = luaL_checkstring(L, -1); - lua_settop(L, 0); + std::string path = ghoul::lua::checkStringAndPop(L); path = absPath(path); //path = FileSys.convertPathSeparator(path, '/'); @@ -216,19 +205,17 @@ int absolutePath(lua_State* L) { * argument. If the path token already exists, it will be silently overridden. */ int setPathToken(lua_State* L) { - const int nArguments = lua_gettop(L); - if (nArguments != 2) { - return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 2, "lua::setPathToken"); + + const std::string path = ghoul::lua::checkStringAndPop(L); + const std::string pathToken = ghoul::lua::checkStringAndPop(L); - const std::string path = luaL_checkstring(L, -1); - const std::string pathToken = luaL_checkstring(L, -2); - lua_settop(L, 0); FileSys.registerPathToken( pathToken, path, ghoul::filesystem::FileSystem::Override::Yes ); + return 0; } @@ -238,16 +225,13 @@ int setPathToken(lua_State* L) { * Checks whether the provided file exists */ int fileExists(lua_State* L) { - const int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::fileExists"); - const std::string file = luaL_checkstring(L, -1); + const std::string file = ghoul::lua::checkStringAndPop(L); const bool e = FileSys.fileExists(absPath(file)); - lua_settop(L, 0); lua_pushboolean(L, (e ? 1 : 0)); + return 1; } @@ -257,15 +241,12 @@ int fileExists(lua_State* L) { * Checks whether the provided file exists */ int directoryExists(lua_State* L) { - const int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::directoryExists"); - const std::string file = luaL_checkstring(L, -1); + + const std::string file = ghoul::lua::checkStringAndPop(L); const bool e = FileSys.directoryExists(absPath(file)); - lua_settop(L, 0); lua_pushboolean(L, (e ? 1 : 0)); return 1; } @@ -319,16 +300,13 @@ int walkDirectoryFolder(lua_State* L) { * 'C:\\OpenSpace\\foobar'." */ int directoryForPath(lua_State* L) { - const int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::directoryForPath"); - const std::string file = luaL_checkstring(L, -1); + const std::string file = ghoul::lua::checkStringAndPop(L); const std::string path = ghoul::filesystem::File(file).directoryName(); - lua_settop(L, 0); lua_pushstring(L, path.c_str()); + return 1; } diff --git a/src/scripting/scriptscheduler_lua.inl b/src/scripting/scriptscheduler_lua.inl index 489108ab67..ab32cbf98c 100644 --- a/src/scripting/scriptscheduler_lua.inl +++ b/src/scripting/scriptscheduler_lua.inl @@ -25,12 +25,9 @@ namespace openspace::luascriptfunctions { int loadFile(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadFile"); - std::string missionFileName = luaL_checkstring(L, -1); + std::string missionFileName = ghoul::lua::checkStringAndPop(L); if (missionFileName.empty()) { return luaL_error(L, "filepath string is empty"); } @@ -44,7 +41,12 @@ int loadFile(lua_State* L) { } int loadScheduledScript(lua_State* L) { - int nArguments = lua_gettop(L); + int nArguments = ghoul::lua::checkArgumentsAndThrow( + L, + { 2, 4 }, + "lua::loadScheduledScript" + ); + if (nArguments == 2) { OsEng.scriptScheduler().loadScripts({ { @@ -81,19 +83,13 @@ int loadScheduledScript(lua_State* L) { } }); } - else { - return luaL_error(L, "Expected %i-%i arguments, got %i", 2, 4, nArguments); - } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } int clear(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) { - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clear"); OsEng.scriptScheduler().clearSchedule(); diff --git a/src/scripting/systemcapabilitiesbinding.cpp b/src/scripting/systemcapabilitiesbinding.cpp index 66c9bf3ee0..5c237bafd1 100644 --- a/src/scripting/systemcapabilitiesbinding.cpp +++ b/src/scripting/systemcapabilitiesbinding.cpp @@ -24,7 +24,6 @@ #include -#include #include #include @@ -84,10 +83,9 @@ int extensions(lua_State* L) { namespace luascripting::opengl { int hasOpenGLVersion(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::hasOpenGLVersion"); - std::vector v = ghoul::tokenizeString(luaL_checkstring(L, -1)); + std::vector v = ghoul::tokenizeString(ghoul::lua::checkStringAndPop(L)); if (v.size() != 2 && v.size() != 3) { LERRORC("hasVersion", ghoul::lua::errorLocation(L) << "Malformed version string"); return 0; @@ -144,10 +142,9 @@ int extensions(lua_State* L) { } int isExtensionSupported(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("hasVersion", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::hasExtension"); - std::string extension = luaL_checkstring(L, -1); + std::string extension = ghoul::lua::checkStringAndPop(L); lua_pushboolean(L, OpenGLCap.isExtensionSupported(extension)); return 1; diff --git a/src/util/spicemanager_lua.inl b/src/util/spicemanager_lua.inl index f93c4a32f1..330c167475 100644 --- a/src/util/spicemanager_lua.inl +++ b/src/util/spicemanager_lua.inl @@ -22,8 +22,6 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include - namespace openspace::luascriptfunctions { /** @@ -34,8 +32,7 @@ namespace openspace::luascriptfunctions { */ int loadKernel(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("loadKernel", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadKernel"); bool isString = (lua_isstring(L, -1) == 1); if (!isString) { @@ -43,13 +40,12 @@ int loadKernel(lua_State* L) { return 0; } - std::string argument = lua_tostring(L, -1); + std::string argument = ghoul::lua::checkStringAndPop(L); if (!FileSys.fileExists(argument)) { return luaL_error(L, "Kernel file '%s' did not exist", argument.c_str()); } unsigned int result = SpiceManager::ref().loadKernel(argument); - lua_settop(L, 0); lua_pushnumber(L, result); ghoul_assert(lua_gettop(L) == 1, "Incorrect number of items left on stack"); @@ -62,8 +58,7 @@ int loadKernel(lua_State* L) { * automatically resolved. */ int unloadKernel(lua_State* L) { - int nArguments = lua_gettop(L); - SCRIPT_CHECK_ARGUMENTS("unloadKernel", L, 1, nArguments); + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::loadKernel"); bool isString = (lua_isstring(L, -1) == 1); bool isNumber = (lua_isnumber(L, -1) == 1); diff --git a/src/util/time_lua.inl b/src/util/time_lua.inl index 9c9c36d65a..396a86f552 100644 --- a/src/util/time_lua.inl +++ b/src/util/time_lua.inl @@ -78,12 +78,10 @@ int time_deltaTime(lua_State* L) { * Toggles a pause functionm i.e. setting the delta time to 0 and restoring it afterwards */ int time_togglePause(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 0) { - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::time_togglePause"); OsEng.timeManager().time().togglePause(); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; } @@ -94,10 +92,7 @@ int time_togglePause(lua_State* L) { * Toggles a pause functionm i.e. setting the delta time to 0 and restoring it afterwards */ int time_setPause(lua_State* L) { - int nArguments = lua_gettop(L); - if (nArguments != 1) { - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - } + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::time_setPause"); bool pause = lua_toboolean(L, -1) == 1; OsEng.timeManager().time().setPause(pause); From 315b1251722d54365bfbec160744c2272ee9a7f1 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 19 Feb 2018 08:06:51 -0500 Subject: [PATCH 038/131] Various New Horizons fixes - Make it possible to toggle labels again - Remove Spice calls that lead to exceptions every frame - Rearrange loading of Spice kernels to reduce error messages - Set image sequence to hybrid - Fix height exaggeration slider value range - Display "No image" for image radio buttons - Use correct texture clamping method to prevent polar pinch color issue with LinearMipMap - Add documentation to ImageSequence --- data/assets/newhorizons.scene | 2 +- .../missions/newhorizons/hydra.asset | 7 +--- .../missions/newhorizons/kernels.asset | 4 +- .../missions/newhorizons/nix.asset | 7 +--- .../missions/newhorizons/pluto.asset | 2 +- .../missions/newhorizons/styx.asset | 7 +--- ext/ghoul | 2 +- .../rendering/renderableplanetprojection.cpp | 15 ++++--- .../shaders/renderablePlanet_vs.glsl | 2 +- .../util/projectioncomponent.cpp | 39 ++++++++++++------- 10 files changed, 43 insertions(+), 44 deletions(-) diff --git a/data/assets/newhorizons.scene b/data/assets/newhorizons.scene index 6775c5683a..fb2e606c93 100644 --- a/data/assets/newhorizons.scene +++ b/data/assets/newhorizons.scene @@ -99,7 +99,7 @@ local Keybindings = { }, { Key = "l", - Command = sceneHelper.property.invert('Labels.renderable.performFading'), + Command = sceneHelper.property.invert('Labels.renderable.Enabled'), Documentation = "Toggles the visibility of the labels for the New Horizons instruments.", Local = false }, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset b/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset index 67a779a3db..fee5678fb3 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset @@ -20,12 +20,7 @@ local Hydra = { Target = "HYDRA", Observer = "PLUTO BARYCENTER", Kernels = kernels .. "/new_horizons/spk/NavSE_plu047_od122.bsp" - }, - Rotation = { - Type = "SpiceRotation", - SourceFrame = "IAU_HYDRA", - DestinationFrame = "GALACTIC" - }, + } }, Renderable = { Type = "RenderablePlanet", diff --git a/data/assets/scene/solarsystem/missions/newhorizons/kernels.asset b/data/assets/scene/solarsystem/missions/newhorizons/kernels.asset index 9eab5ce96a..cb2d56be64 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/kernels.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/kernels.asset @@ -10,14 +10,14 @@ local NewHorizonsKernels = { Kernels .. "/new_horizons/spk/NavSE_plu047_od122.bsp", Kernels .. "/new_horizons/spk/NavPE_de433_od122.bsp", + Kernels .. "/new_horizons/sclk/new-horizons_1121.tsc", + Kernels .. "/new_horizons/ck/nh_scispi_2015_pred.bc", Kernels .. "/new_horizons/ck/nh_scispi_2015_recon.bc", Kernels .. "/new_horizons/ck/nh_lorri_wcs.bc", Kernels .. "/new_horizons/smithed_pc_and_sp/PLU_LORRI_ALL_161216.bc", - Kernels .. "/new_horizons/sclk/new-horizons_1121.tsc", - Kernels .. "/new_horizons/pck/nh_targets_v001.tpc", Kernels .. "/new_horizons/pck/nh_pcnh_005.tpc", diff --git a/data/assets/scene/solarsystem/missions/newhorizons/nix.asset b/data/assets/scene/solarsystem/missions/newhorizons/nix.asset index 449f759893..69861dad60 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/nix.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/nix.asset @@ -20,12 +20,7 @@ local Nix = { Target = "NIX", Observer = "PLUTO BARYCENTER", Kernels = kernels.Kernels .. "/new_horizons/spk/NavSE_plu047_od122.bsp" - }, - Rotation = { - Type = "SpiceRotation", - SourceFrame = "IAU_NIX", - DestinationFrame = "ECLIPJ2000" - }, + } }, Renderable = { Type = "RenderablePlanet", diff --git a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset index d5c3531670..95f284de27 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset @@ -74,7 +74,7 @@ local Pluto = { Projection = { Sequence = images, EventFile = assets .. "/core_v9h_obs_getmets_v8_time_fix_nofrcd_mld.txt", - SequenceType = "image-sequence", + SequenceType = "hybrid", Observer = "NEW HORIZONS", Target = "PLUTO", Aberration = "NONE", diff --git a/data/assets/scene/solarsystem/missions/newhorizons/styx.asset b/data/assets/scene/solarsystem/missions/newhorizons/styx.asset index 21c45cceca..e09b9f0072 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/styx.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/styx.asset @@ -20,12 +20,7 @@ local Styx = { Target = "STYX", Observer = "PLUTO BARYCENTER", Kernels = kernels.Kernels .. "/new_horizons/spk/NavSE_plu047_od122.bsp" - }, - Rotation = { - Type = "SpiceRotation", - SourceFrame = "IAU_STYX", - DestinationFrame = "GALACTIC" - }, + } }, Renderable = { Type = "RenderablePlanet", diff --git a/ext/ghoul b/ext/ghoul index dcbf53a697..55b899e347 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit dcbf53a6972bcfddf3136fc89258db8c4f22dbd3 +Subproject commit 55b899e347b392da6469404605714e26cddd7942 diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 3430224be6..457d7746fc 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -61,6 +61,8 @@ namespace { // const char* keyShading = "PerformShading"; constexpr const char* _mainFrame = "GALACTIC"; + constexpr const char* NoImageText = "No Image"; + static const openspace::properties::Property::PropertyInfo ColorTexturePathsInfo = { "ColorTexturePaths", "Color Texture", @@ -175,7 +177,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _fboProgramObject(nullptr) , _baseTexture(nullptr) , _heightMapTexture(nullptr) - , _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 100.f) + , _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 1e6f, 1.f, 3.f) , _meridianShift(MeridianShiftInfo, false) , _capture(false) { @@ -199,7 +201,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& _projectionComponent.initialize(dict.value(KeyProjection)); - _colorTexturePaths.addOption(0, ""); + _colorTexturePaths.addOption(0, NoImageText); _colorTexturePaths.onChange([this](){ _colorTextureDirty = true; }); @@ -244,7 +246,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& - _heightMapTexturePaths.addOption(0, ""); + _heightMapTexturePaths.addOption(0, NoImageText); _heightMapTexturePaths.onChange([this]() { _heightMapTextureDirty = true; }); @@ -713,13 +715,16 @@ void RenderablePlanetProjection::loadColorTexture() { // We delete the texture first in order to free up the memory, which could otherwise // run out in the case of two large textures _baseTexture = nullptr; - if (!selectedPath.empty()) { + if (selectedPath != NoImageText) { _baseTexture = ghoul::io::TextureReader::ref().loadTexture( absPath(selectedPath) ); if (_baseTexture) { ghoul::opengl::convertTextureFormat(*_baseTexture, Texture::Format::RGB); _baseTexture->uploadTexture(); + _baseTexture->setWrapping( + { Texture::WrappingMode::Repeat, Texture::WrappingMode::MirroredRepeat} + ); _baseTexture->setFilter(Texture::FilterMode::LinearMipMap); } } @@ -732,7 +737,7 @@ void RenderablePlanetProjection::loadHeightTexture() { // We delete the texture first in order to free up the memory, which could otherwise // run out in the case of two large textures _heightMapTexture = nullptr; - if (!selectedPath.empty()) { + if (selectedPath != NoImageText) { _heightMapTexture = ghoul::io::TextureReader::ref().loadTexture( absPath(selectedPath) ); diff --git a/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl b/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl index 2487529354..9da9b299a6 100644 --- a/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl +++ b/modules/spacecraftinstruments/shaders/renderablePlanet_vs.glsl @@ -60,7 +60,7 @@ void main() { } float height = texture(heightTexture, st).s; vec3 displacementDirection = (normalize(tmp.xyz)); - float displacementFactor = height * _heightExaggeration / 750.0; + float displacementFactor = height * _heightExaggeration; tmp.xyz += displacementDirection * displacementFactor; } diff --git a/modules/spacecraftinstruments/util/projectioncomponent.cpp b/modules/spacecraftinstruments/util/projectioncomponent.cpp index a460ca38f0..a33775728f 100644 --- a/modules/spacecraftinstruments/util/projectioncomponent.cpp +++ b/modules/spacecraftinstruments/util/projectioncomponent.cpp @@ -150,6 +150,17 @@ documentation::Documentation ProjectionComponent::Documentation() { Optional::No, "The aspect ratio of the instrument in relation between x and y axis" }, + { + keySequenceType, + new StringInListVerifier( + { sequenceTypeImage, sequenceTypePlaybook, sequenceTypeHybrid } + ), + Optional::Yes, + "This value determines which type of sequencer is used for generating " + "image schedules. The 'playbook' is using a custom format designed by " + "the New Horizons team, the 'image-sequence' uses lbl files from a " + "directory, and the 'hybrid' uses both methods." + }, { keyProjObserver, new StringAnnotationVerifier("A SPICE name of the observing object"), @@ -402,11 +413,8 @@ bool ProjectionComponent::initializeGL() { absPath(placeholderFile) ); if (texture) { - texture->uploadTexture(); - // TODO: AnisotropicMipMap crashes on ATI cards ---abock - //_textureProj->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); texture->setFilter(Texture::FilterMode::LinearMipMap); - texture->setWrapping(Texture::WrappingMode::ClampToBorder); + texture->setWrapping(Texture::WrappingMode::ClampToEdge); } _placeholderTexture = std::move(texture); @@ -944,6 +952,7 @@ void ProjectionComponent::clearAllProjections() { } void ProjectionComponent::generateMipMap() { + _projectionTexture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap); _mipMapDirty = false; } @@ -967,10 +976,10 @@ std::shared_ptr ProjectionComponent::loadProjectionTextu if (texture->format() == Texture::Format::Red) ghoul::opengl::convertTextureFormat(*texture, Texture::Format::RGB); texture->uploadTexture(); - // TODO: AnisotropicMipMap crashes on ATI cards ---abock - //_textureProj->setFilter(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap); + texture->setWrapping( + { Texture::WrappingMode::Repeat, Texture::WrappingMode::MirroredRepeat } + ); texture->setFilter(Texture::FilterMode::LinearMipMap); - texture->setWrapping(Texture::WrappingMode::ClampToBorder); } return std::move(texture); } @@ -979,15 +988,17 @@ bool ProjectionComponent::generateProjectionLayerTexture(const ivec2& size) { LINFO( "Creating projection texture of size '" << size.x << ", " << size.y << "'" ); - _projectionTexture = std::make_unique ( + using namespace ghoul::opengl; + _projectionTexture = std::make_unique( glm::uvec3(size, 1), - ghoul::opengl::Texture::Format::RGBA + Texture::Format::RGBA ); if (_projectionTexture) { _projectionTexture->uploadTexture(); - //_projectionTexture->setFilter( - // ghoul::opengl::Texture::FilterMode::AnisotropicMipMap - //); + _projectionTexture->setWrapping( + { Texture::WrappingMode::Repeat, Texture::WrappingMode::MirroredRepeat } + ); + _projectionTexture->setFilter(Texture::FilterMode::LinearMipMap); } if (_dilation.isEnabled) { @@ -1018,9 +1029,7 @@ bool ProjectionComponent::generateProjectionLayerTexture(const ivec2& size) { } } - return _projectionTexture != nullptr; - } bool ProjectionComponent::generateDepthTexture(const ivec2& size) { @@ -1032,7 +1041,7 @@ bool ProjectionComponent::generateDepthTexture(const ivec2& size) { glm::uvec3(size, 1), ghoul::opengl::Texture::Format::DepthComponent, GL_DEPTH_COMPONENT32F - ); + ); if (_shadowing.texture) { _shadowing.texture->uploadTexture(); From f0e459d05e8ad5a82a9bd5dbeb7b0fb589b61b37 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 19 Feb 2018 09:42:31 -0500 Subject: [PATCH 039/131] Add settings for ambient brightness on RenderablePlanet --- .../rendering/renderableplanetprojection.cpp | 21 +++++++++++++++++++ .../rendering/renderableplanetprojection.h | 6 ++++-- .../shaders/renderablePlanet_fs.glsl | 4 ++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 457d7746fc..494491dbc3 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -109,6 +109,12 @@ namespace { "meridian has changed through the New Horizons mission and this requires this " "shift." }; + + static const openspace::properties::Property::PropertyInfo AmbientBrightnessInfo = { + "AmbientBrightness", + "Ambient Brightness", + "This value determines the ambient brightness of the dark side of the planet." + }; } // namespace namespace openspace { @@ -160,6 +166,12 @@ documentation::Documentation RenderablePlanetProjection::Documentation() { new BoolVerifier, Optional::Yes, MeridianShiftInfo.description + }, + { + AmbientBrightnessInfo.identifier, + new DoubleVerifier, + Optional::Yes, + AmbientBrightnessInfo.description } } }; @@ -179,6 +191,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& , _heightMapTexture(nullptr) , _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 1e6f, 1.f, 3.f) , _meridianShift(MeridianShiftInfo, false) + , _ambientBrightness(AmbientBrightnessInfo, 0.075f, 0.f, 1.f) , _capture(false) { documentation::testSpecificationAndThrow( @@ -309,6 +322,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& addProperty(_heightExaggeration); addProperty(_meridianShift); + addProperty(_ambientBrightness); } RenderablePlanetProjection::~RenderablePlanetProjection() {} @@ -331,6 +345,9 @@ void RenderablePlanetProjection::initializeGL() { "_heightExaggeration" ); _mainUniformCache.meridianShift = _programObject->uniformLocation("_meridianShift"); + _mainUniformCache.ambientBrightness = _programObject->uniformLocation( + "_ambientBrightness" + ); _mainUniformCache.projectionFading = _programObject->uniformLocation( "_projectionFading" ); @@ -600,6 +617,7 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&) ); _programObject->setUniform(_mainUniformCache.heightExaggeration, _heightExaggeration); _programObject->setUniform(_mainUniformCache.meridianShift, _meridianShift); + _programObject->setUniform(_mainUniformCache.ambientBrightness, _ambientBrightness); _programObject->setUniform( _mainUniformCache.projectionFading, _projectionComponent.projectionFading() @@ -645,6 +663,9 @@ void RenderablePlanetProjection::update(const UpdateData& data) { _mainUniformCache.meridianShift = _programObject->uniformLocation( "_meridianShift" ); + _mainUniformCache.ambientBrightness = _programObject->uniformLocation( + "_ambientBrightness" + ); _mainUniformCache.projectionFading = _programObject->uniformLocation( "_projectionFading" ); diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h index 517fea6599..30728d1b7c 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h @@ -79,8 +79,9 @@ private: std::unique_ptr _programObject; std::unique_ptr _fboProgramObject; UniformCache(sunPos, modelTransform, modelViewProjectionTransform, hasBaseMap, - hasHeightMap, heightExaggeration, meridianShift, projectionFading, - baseTexture, projectionTexture, heightTexture) _mainUniformCache; + hasHeightMap, heightExaggeration, meridianShift, ambientBrightness, + projectionFading, baseTexture, projectionTexture, heightTexture) + _mainUniformCache; UniformCache(projectionTexture, projectorMatrix, modelTransform, scaling, boresight, radius, segments) _fboUniformCache; @@ -90,6 +91,7 @@ private: properties::FloatProperty _heightExaggeration; properties::BoolProperty _meridianShift; + properties::FloatProperty _ambientBrightness; std::unique_ptr _geometry; diff --git a/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl b/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl index 1e6795e571..ff58aa917b 100644 --- a/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl +++ b/modules/spacecraftinstruments/shaders/renderablePlanet_fs.glsl @@ -32,6 +32,7 @@ in vec2 vs_st; uniform sampler2D baseTexture; uniform sampler2D projectionTexture; uniform bool _meridianShift; +uniform float _ambientBrightness; uniform float _projectionFading; @@ -51,8 +52,7 @@ Fragment getFragment() { vec3 l_pos = sun_pos; // sun vec3 l_dir = normalize(l_pos - objpos.xyz); - const float terminatorBrightness = 0.4; - float intensity = min(max(5 * dot(n,l_dir), terminatorBrightness), 1); + float intensity = min(max(5 * dot(n,l_dir), _ambientBrightness), 1); // float shine = 0.0001; vec4 ambient = vec4(0.0, 0.0, 0.0, 1.0); From a112ebcec796780736e7d466fdd2036be312d4bb Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 19 Feb 2018 16:28:18 -0500 Subject: [PATCH 040/131] Specify simplification of field of view renderables --- .../missions/newhorizons/fov.asset | 3 +- .../rendering/renderablefov.cpp | 89 ++++++++++++++----- .../rendering/renderablefov.h | 1 + 3 files changed, 70 insertions(+), 23 deletions(-) diff --git a/data/assets/scene/solarsystem/missions/newhorizons/fov.asset b/data/assets/scene/solarsystem/missions/newhorizons/fov.asset index a5614476f2..260742ac55 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/fov.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/fov.asset @@ -267,7 +267,8 @@ local AliceAirglow = { "Pluto", "Charon", -- "Jupiter", "Io", "Europa", "Ganymede", "Callisto" - } + }, + SimplifyBounds = true }, Transform = { Translation = { diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index c34551e2d6..eff9c2f308 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -33,6 +33,8 @@ #include #include +#include +#include #include #include @@ -40,18 +42,22 @@ #include namespace { - const char* KeyBody = "Body"; - const char* KeyFrame = "Frame"; + constexpr const char* KeyBody = "Body"; + constexpr const char* KeyFrame = "Frame"; // const char* KeyColor = "RGB"; - const char* KeyInstrument = "Instrument"; - const char* KeyInstrumentName = "Name"; - const char* KeyInstrumentAberration = "Aberration"; + constexpr const char* KeyInstrument = "Instrument"; + constexpr const char* KeyInstrumentName = "Name"; + constexpr const char* KeyInstrumentAberration = "Aberration"; - const char* KeyPotentialTargets = "PotentialTargets"; - const char* KeyFrameConversions = "FrameConversions"; + constexpr const char* KeyPotentialTargets = "PotentialTargets"; + constexpr const char* KeyFrameConversions = "FrameConversions"; + + constexpr const char* KeyBoundsSimplification = "SimplifyBounds"; const int InterpolationSteps = 5; + + const double Epsilon = 1e-4; static const openspace::properties::Property::PropertyInfo LineWidthInfo = { "LineWidth", @@ -130,7 +136,6 @@ namespace { "the case that there is no intersection and that the instrument is not currently " "active." }; - } // namespace namespace openspace { @@ -214,6 +219,15 @@ documentation::Documentation RenderableFov::Documentation() { new DoubleVerifier, Optional::Yes, StandoffDistanceInfo.description + }, + { + KeyBoundsSimplification, + new BoolVerifier, + Optional::Yes, + "If this value is set to 'true' the field-of-views bounds values will be " + "simplified on load. Bound vectors will be removed if they are the " + "strict linear interpolation between the two neighboring vectors. This " + "value is disabled on default." } } }; @@ -285,6 +299,10 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) )); } + if (dictionary.hasKey(KeyBoundsSimplification)) { + _simplifyBounds = dictionary.value(KeyBoundsSimplification); + } + addProperty(_lineWidth); addProperty(_drawSolid); addProperty(_standOffDistance); @@ -342,6 +360,33 @@ void RenderableFov::initializeGL() { "RenderableFov" ); } + + if (_simplifyBounds) { + const size_t sizeBefore = res.bounds.size(); + for (size_t i = 1; i < res.bounds.size() - 1; ++i) { + const glm::dvec3& prev = res.bounds[i - 1]; + const glm::dvec3& curr = res.bounds[i]; + const glm::dvec3& next = res.bounds[i + 1]; + + const double area = glm::length( + glm::cross((curr - prev), (next - prev)) + ); + + const bool isCollinear = area < Epsilon; + + if (isCollinear) { + res.bounds.erase(res.bounds.begin() + i); + + // Need to subtract one as we have shortened the array and the next + // item is now on the current position + --i; + } + } + const size_t sizeAfter = res.bounds.size(); + + LINFOC(_instrument.name, "Simplified from " << sizeBefore << " to " << sizeAfter); + } + _instrument.bounds = std::move(res.bounds); _instrument.boresight = std::move(res.boresightVector); @@ -1315,24 +1360,24 @@ void RenderableFov::update(const UpdateData& data) { } std::pair RenderableFov::determineTarget(double time) { + SpiceManager::UseException oldValue = SpiceManager::ref().exceptionHandling(); + defer { SpiceManager::ref().setExceptionHandling(oldValue); }; + // First, for all potential targets, check whether they are in the field of view for (const std::string& pt : _instrument.potentialTargets) { - try { - bool inFOV = SpiceManager::ref().isTargetInFieldOfView( - pt, - _instrument.spacecraft, - _instrument.name, - SpiceManager::FieldOfViewMethod::Ellipsoid, - _instrument.aberrationCorrection, - time - ); + bool inFOV = SpiceManager::ref().isTargetInFieldOfView( + pt, + _instrument.spacecraft, + _instrument.name, + SpiceManager::FieldOfViewMethod::Ellipsoid, + _instrument.aberrationCorrection, + time + ); - if (inFOV) { - _previousTarget = pt; - return { pt, true }; - } + if (inFOV) { + _previousTarget = pt; + return { pt, true }; } - catch (const openspace::SpiceManager::SpiceException&) {} } // If none of the targets is in field of view, either use the last target or if there diff --git a/modules/spacecraftinstruments/rendering/renderablefov.h b/modules/spacecraftinstruments/rendering/renderablefov.h index 909c2a0010..5fcbcf1e06 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.h +++ b/modules/spacecraftinstruments/rendering/renderablefov.h @@ -100,6 +100,7 @@ private: // instance variables bool _rebuild = false; + bool _simplifyBounds = false; //std::vector _fovBounds; //std::vector _fovPlane; From 9ad1d7e3ed8accc4a7eefead5ff15afb5db6a8d4 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 19 Feb 2018 16:29:38 -0500 Subject: [PATCH 041/131] Reduce default sensitivity of Orbital Navigator Rename internal macros to reduce compiler warnings --- ext/ghoul | 2 +- include/openspace/performance/performancemeasurement.h | 6 +++--- src/interaction/orbitalnavigator.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 55b899e347..7d15e645e3 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 55b899e347b392da6469404605714e26cddd7942 +Subproject commit 7d15e645e306590e73fa97630ef74cfbd707213f diff --git a/include/openspace/performance/performancemeasurement.h b/include/openspace/performance/performancemeasurement.h index 923dce44ab..024541dae6 100644 --- a/include/openspace/performance/performancemeasurement.h +++ b/include/openspace/performance/performancemeasurement.h @@ -48,12 +48,12 @@ private: std::chrono::high_resolution_clock::time_point _startTime; }; -#define __MERGE(a,b) a##b -#define __LABEL(a) __MERGE(unique_name_, a) +#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(__LINE__) = \ + auto __LABEL_PerfMeasure(__LINE__) = \ openspace::performance::PerformanceMeasurement(\ (name), \ OsEng.renderEngine().performanceManager() \ diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index 06ed097435..6642f22ebe 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -105,7 +105,7 @@ OrbitalNavigator::OrbitalNavigator() : properties::PropertyOwner({ "OrbitalNavigator" }) , _followFocusNodeRotationDistance(FollowFocusNodeInfo, 5.0f, 0.0f, 20.f) , _minimumAllowedDistance(MinimumDistanceInfo, 10.0f, 0.0f, 10000.f) - , _sensitivity(SensitivityInfo, 20.0f, 1.0f, 50.f) + , _sensitivity(SensitivityInfo, 15.0f, 1.0f, 50.f) , _mouseStates(_sensitivity * pow(10.0, -4), 1 / (_friction.friction + 0.0000001)) { auto smoothStep = From ebb4a12ef9571d15b9b0571710e60dd230fcd928 Mon Sep 17 00:00:00 2001 From: GPayne Date: Thu, 22 Feb 2018 14:38:10 -0700 Subject: [PATCH 042/131] Modified satellite content to work with new asset architecture. Still has a problem with require vs. request asset. --- data/assets/default.scene | 1 + .../earth/satellites/satellite_data.asset | 7 ++ .../planets/earth/satellites/satellites.asset | 114 ++++++++++++------ 3 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 data/assets/scene/solarsystem/planets/earth/satellites/satellite_data.asset diff --git a/data/assets/default.scene b/data/assets/default.scene index 364d38fcab..56383f8b05 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -8,6 +8,7 @@ asset.require('scene/solarsystem/planets') asset.require('scene/solarsystem/planets/mars/moons/phobos') asset.require('scene/solarsystem/planets/mars/moons/deimos') assetHelper.requestAll(asset, 'scene/digitaluniverse') +asset.request('scene/solarsystem/planets/earth/satellites/satellites') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellite_data.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellite_data.asset new file mode 100644 index 0000000000..165df33b7c --- /dev/null +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellite_data.asset @@ -0,0 +1,7 @@ +local SatDataPath = asset.syncedResource({ + Name = "Satellite Data", + Type = "HttpSynchronization", + Identifier = "satellite_data", + Version = 2 +}) +asset.export("SatDataPath", SatDataPath) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset index c7673bacd4..ba9e1c8d9e 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset @@ -1,11 +1,16 @@ -local transforms = asset.require('../transforms') local assetHelper = asset.require('util/asset_helper') +local transforms = asset.require('scene/solarsystem/planets/earth/transforms') + +--local satDataPath = asset.require('./satellite_data').SatDataPath +local satDataPath = asset.request('./satellite_data').SatDataPath +satDataPath = "C:\\Users\\openspace\\Desktop\\OpenSpace_20180207\\sync\\http\\satellite_data\\2" + -- Waiting for URL based download - ---[[ DOWNLOAD = false + + function dirListing(dirname) f = io.popen('ls ' .. dirname) files = {} @@ -58,23 +63,23 @@ function checkTleFileFormat(lineArr) end -function getSat(title, file, lineNum) +function getSat(title, file, lineNum, textureFile) return { Name = title, - Parent = "EarthInertial", + Parent = transforms.EarthInertial.Name, Renderable = { Type = "RenderablePlane", Size = 3e4, Origin = "Center", Body = "TLE", Billboard = true, - Texture = "satB.png" + Texture = textureFile }, Transform = { Translation = { Type = "TLETranslation", Body = title, - Observer = "EarthInertial", + Observer = transforms.EarthInertial.Name, File = file, LineNum = lineNum }, @@ -89,16 +94,15 @@ end function getSatTrail(title, file, lineNum, per, color) trailName = title .. "_trail" - return { Name = trailName, - Parent = "EarthInertial", + Parent = transforms.EarthInertial.Name, Renderable = { Type = "RenderableTrailOrbit", Translation = { Type = "TLETranslation", Body = title, - Observer = "EarthInertial", + Observer = transforms.EarthInertial.Name, File = file, LineNum = lineNum }, @@ -110,6 +114,54 @@ function getSatTrail(title, file, lineNum, per, color) } end +function printSatElements_debug(satElem) + print(">SATELLITE") + print(" " .. satElem.Name) + print(" " .. satElem.Parent) + print(" (Renderable)") + print(" " .. satElem.Renderable.Type) + print(" " .. satElem.Renderable.Size) + print(" " .. satElem.Renderable.Origin) + print(" " .. satElem.Renderable.Body) + if satElem.Renderable.Billboard then + print(" Billboard = true") + end + print(" " .. satElem.Renderable.Texture) + print(" (Transform.Translation)") + print(" " .. satElem.Transform.Translation.Type) + print(" " .. satElem.Transform.Translation.Body) + print(" " .. satElem.Transform.Translation.Observer) + print(" " .. satElem.Transform.Translation.File) + print(" " .. satElem.Transform.Translation.LineNum) + print(" (Transform.Scale)") + print(" " .. satElem.Transform.Scale.Type) + print(" " .. satElem.Transform.Scale.Scale) + print(" (GuiPath)") + print(" " .. satElem.GuiPath) +end + +function printSatTrailElements_debug(satElem) + print(">SAT_TRAIL") + print(" " .. satElem.Name) + print(" " .. satElem.Parent) + print(" (Renderable)") + print(" " .. satElem.Renderable.Type) + print(" " .. satElem.Renderable.Translation.Type) + print(" " .. satElem.Renderable.Translation.Body) + print(" " .. satElem.Renderable.Translation.Observer) + print(" " .. satElem.Renderable.Translation.File) + print(" " .. satElem.Renderable.Translation.LineNum) + print(" ((Misc))") + print(" (color)") + print(" " .. satElem.Renderable.Color[1] .. "," + .. satElem.Renderable.Color[2] .. "," + .. satElem.Renderable.Color[3]) + print(" " .. satElem.Renderable.Period) + print(" " .. satElem.Renderable.Resolution) + print(" (GuiPath)") + print(" " .. satElem.GuiPath) +end + ------------------------------------------------------------- --Name, URL, and color scheme for each satellite group satelliteGroups = { @@ -127,22 +179,23 @@ satelliteGroups = { }, } -modElements = {} -fileErr = "" for sOrbit in values(satelliteGroups) do + fileErr = "" filename = sOrbit.url:match("([^/]+)$") filenameSansExt = filename:gsub(filename:match "(%.%w+)$", "") - sOrbit.path = "satellites/tle/" .. filename - + + sOrbit.path = satDataPath .. "/tle/" .. filename + sOrbit.texturePath = satDataPath .. "/" .. "satB.png" + if DOWNLOAD then openspace.downloadFile(sOrbit.url, sOrbit.path) end - sOrbit.path = "../" .. sOrbit.path - pathFromScenegraphParent = "./" .. sOrbit.path - + local sat_var + local satTrail_var + line = {} - myfile = io.open(sOrbit.path, "r") - lines = getNumLinesInFile(sOrbit.path) + myfile = io.open(satDataPath .. "/tle/" .. filename, "r") + lines = getNumLinesInFile(satDataPath .. "/tle/" .. filename) --now loop through the tle file and get each set of 3 lines if myfile then for n=1,lines,3 do @@ -153,9 +206,12 @@ for sOrbit in values(satelliteGroups) do title = trimString(line[1]) per = getPeriodFromFile(line[3]) per = 1.0 / per * 2 --trail for 2x a single revolution - table.insert(modElements, getSat(filenameSansExt .. "_" .. title, pathFromScenegraphParent, n)) - table.insert(modElements, getSatTrail(filenameSansExt .. "_" .. title, - pathFromScenegraphParent, n, per, sOrbit.trailColor)) + satName = filenameSansExt .. "_" .. title + --register satellite object and trail + sat_var = getSat(satName, sOrbit.path, n, sOrbit.texturePath) + assetHelper.registerSceneGraphNodesAndExport(asset, {sat_var}) + satTrail_var = getSatTrail(satName, sOrbit.path, n, per, sOrbit.trailColor) + assetHelper.registerSceneGraphNodesAndExport(asset, {satTrail_var}) else fileErr = " TLE file syntax error on line " .. n .. ": " .. sOrbit.path break @@ -165,15 +221,5 @@ for sOrbit in values(satelliteGroups) do fileErr = " File not found: " .. sOrbit.path break end -end -assert(fileErr == "", fileErr) - - -if (fileErr == "") then - return modElements -else - return "Invalid file: " .. fileErr -end - - -]] \ No newline at end of file + assert(fileErr == "", fileErr) +end \ No newline at end of file From 58f79a88511a88d7c494130952581171c2d57afe Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 23 Feb 2018 13:24:35 -0500 Subject: [PATCH 043/131] Issue/518 (#529) * Adding ScreenSpaceSpout object to display spout textures in screen space * Enable the clearing of option properties * Fix crash in ScreenSpaceImageLocal specification * Split RenderablePlane into RenderablePlaneImageLocal and RenderablePlaneImageOnline * Add RenderablePlane Spout * Rename Texture parameter in ScreenSpaceImageOnline into URL Closes #518 --- apps/OpenSpace/CMakeLists.txt | 19 -- .../examples/renderableplaneimageonline.asset | 24 ++ data/assets/examples/screenspacespout.asset | 23 ++ .../missions/newhorizons/charon.asset | 2 +- .../missions/newhorizons/hydra.asset | 2 +- .../missions/newhorizons/kerberos.asset | 2 +- .../missions/newhorizons/nix.asset | 2 +- .../missions/newhorizons/pluto.asset | 4 +- .../missions/newhorizons/styx.asset | 2 +- .../solarsystem/planets/earth/markers.asset | 2 +- .../planets/earth/satellites/satellites.asset | 2 +- data/assets/scene/solarsystem/sun/glare.asset | 2 +- .../assets/scene/solarsystem/sun/marker.asset | 2 +- include/openspace/properties/optionproperty.h | 5 + .../rendering/screenspacerenderable.h | 6 +- modules/base/CMakeLists.txt | 4 + modules/base/basemodule.cpp | 6 +- modules/base/rendering/renderableplane.cpp | 93 ++----- modules/base/rendering/renderableplane.h | 15 +- .../rendering/renderableplaneimagelocal.cpp | 139 ++++++++++ .../rendering/renderableplaneimagelocal.h | 68 +++++ .../rendering/renderableplaneimageonline.cpp | 170 ++++++++++++ .../rendering/renderableplaneimageonline.h | 72 ++++++ .../base/rendering/screenspaceframebuffer.cpp | 6 + .../base/rendering/screenspaceframebuffer.h | 4 + .../base/rendering/screenspaceimagelocal.cpp | 5 + .../base/rendering/screenspaceimagelocal.h | 4 + .../base/rendering/screenspaceimageonline.cpp | 29 ++- .../base/rendering/screenspaceimageonline.h | 4 + modules/imgui/src/gui.cpp | 4 +- modules/spout/CMakeLists.txt | 51 ++++ .../OpenSpace => modules/spout}/ext/readme.md | 0 .../spout}/ext/spout/SpoutLibrary.dll | Bin .../spout}/ext/spout/SpoutLibrary.h | 0 .../spout}/ext/spout/SpoutLibrary.lib | Bin modules/spout/include.cmake | 3 + modules/spout/renderableplanespout.cpp | 243 +++++++++++++++++ modules/spout/renderableplanespout.h | 74 ++++++ modules/spout/screenspacespout.cpp | 244 ++++++++++++++++++ modules/spout/screenspacespout.h | 74 ++++++ modules/spout/spoutlibrary.h | 34 +++ modules/spout/spoutmodule.cpp | 51 ++++ modules/spout/spoutmodule.h | 43 +++ src/properties/optionproperty.cpp | 10 +- src/rendering/renderengine_lua.inl | 1 + src/rendering/screenspacerenderable.cpp | 22 +- 46 files changed, 1430 insertions(+), 142 deletions(-) create mode 100644 data/assets/examples/renderableplaneimageonline.asset create mode 100644 data/assets/examples/screenspacespout.asset create mode 100644 modules/base/rendering/renderableplaneimagelocal.cpp create mode 100644 modules/base/rendering/renderableplaneimagelocal.h create mode 100644 modules/base/rendering/renderableplaneimageonline.cpp create mode 100644 modules/base/rendering/renderableplaneimageonline.h create mode 100644 modules/spout/CMakeLists.txt rename {apps/OpenSpace => modules/spout}/ext/readme.md (100%) rename {apps/OpenSpace => modules/spout}/ext/spout/SpoutLibrary.dll (100%) rename {apps/OpenSpace => modules/spout}/ext/spout/SpoutLibrary.h (100%) rename {apps/OpenSpace => modules/spout}/ext/spout/SpoutLibrary.lib (100%) create mode 100644 modules/spout/include.cmake create mode 100644 modules/spout/renderableplanespout.cpp create mode 100644 modules/spout/renderableplanespout.h create mode 100644 modules/spout/screenspacespout.cpp create mode 100644 modules/spout/screenspacespout.h create mode 100644 modules/spout/spoutlibrary.h create mode 100644 modules/spout/spoutmodule.cpp create mode 100644 modules/spout/spoutmodule.h diff --git a/apps/OpenSpace/CMakeLists.txt b/apps/OpenSpace/CMakeLists.txt index 5aa70960a1..9ca9d6e316 100644 --- a/apps/OpenSpace/CMakeLists.txt +++ b/apps/OpenSpace/CMakeLists.txt @@ -68,25 +68,6 @@ if (OPENSPACE_OPENVR_SUPPORT) endif() endif() -##### -# Spout -##### -if (WIN32) - option(OPENSPACE_SPOUT_SUPPORT "Build OpenSpace application with Spout support" OFF) -endif () - -if (OPENSPACE_SPOUT_SUPPORT) - set(SPOUT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/ext/spout) - set(SPOUT_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/ext/spout/SpoutLibrary.lib) - set(SPOUT_DEFINITIONS "OPENSPACE_HAS_SPOUT") - - set(SGCT_SPOUT_SUPPORT ON CACHE BOOL "" FORCE) -endif () - -if (OPENSPACE_SPOUT_SUPPORT) - add_external_library_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/ext/spout/SpoutLibrary.dll) -endif () - set(MACOSX_BUNDLE_ICON_FILE openspace.icns) create_new_application(OpenSpace diff --git a/data/assets/examples/renderableplaneimageonline.asset b/data/assets/examples/renderableplaneimageonline.asset new file mode 100644 index 0000000000..fd48f1d35f --- /dev/null +++ b/data/assets/examples/renderableplaneimageonline.asset @@ -0,0 +1,24 @@ +-- This asset requires OpenSpace to be built with the OPENSPACE_MODULE_SPOUT enabled + +local assetHelper = asset.require("util/asset_helper") +local transforms = asset.require("scene/solarsystem/sun/transforms") + + + +local RenderablePlaneImageOnline = { + Name = "RenderablePlaneImageOnline", + Parent = transforms.SolarSystemBarycenter.Name, + Renderable = { + Type = "RenderablePlaneImageOnline", + Size = 3.0E11, + Origin = "Center", + Billboard = true, + URL = "http://data.openspaceproject.com/examples/renderableplaneimageonline.jpg" + }, + GuiPath = "/Examples" +} + + + +local objects = { RenderablePlaneImageOnline } +assetHelper.registerSceneGraphNodesAndExport(asset, objects) diff --git a/data/assets/examples/screenspacespout.asset b/data/assets/examples/screenspacespout.asset new file mode 100644 index 0000000000..54cc619cd5 --- /dev/null +++ b/data/assets/examples/screenspacespout.asset @@ -0,0 +1,23 @@ +-- This asset requires OpenSpace to be built with the OPENSPACE_MODULE_SPOUT enabled + +local assetHelper = asset.require("util/asset_helper") +local transforms = asset.require("scene/solarsystem/sun/transforms") + + + +local Spout = { + Name = "Spouty", + Parent = transforms.SolarSystemBarycenter.Name, + Renderable = { + Type = "RenderablePlaneSpout", + Size = 3.0E11, + Origin = "Center", + Billboard = true + }, + GuiPath = "/Examples" +} + + + +local objects = { Spout } +assetHelper.registerSceneGraphNodesAndExport(asset, objects) diff --git a/data/assets/scene/solarsystem/missions/newhorizons/charon.asset b/data/assets/scene/solarsystem/missions/newhorizons/charon.asset index 4622be1bca..4de0e626c7 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/charon.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/charon.asset @@ -79,7 +79,7 @@ local CharonText = { } }, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 10^6.3, Origin = "Center", Billboard = true, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset b/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset index fee5678fb3..3e84d77c43 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/hydra.asset @@ -47,7 +47,7 @@ local HydraText = { }, }, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 10.0^6.3, Origin = "Center", Billboard = true, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/kerberos.asset b/data/assets/scene/solarsystem/missions/newhorizons/kerberos.asset index c9d4ecce41..2ad3560809 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/kerberos.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/kerberos.asset @@ -51,7 +51,7 @@ local KerberosText = { }, }, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 10^6.3, Origin = "Center", Billboard = true, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/nix.asset b/data/assets/scene/solarsystem/missions/newhorizons/nix.asset index 69861dad60..f1b251131e 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/nix.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/nix.asset @@ -38,7 +38,7 @@ local NixText = { Name = "NixText", Parent = Nix.Name, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 10^6.3, Origin = "Center", Billboard = true, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset index 95f284de27..8d45caf643 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset @@ -185,7 +185,7 @@ local PlutoBarycenterLabel = { Name = "PlutoBarycenterLabel", Parent = transforms.PlutoBarycenter.Name, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Billboard = true, Size = 5E4, Texture = encounterTextures .. "/barycenter.png", @@ -204,7 +204,7 @@ local PlutoText = { }, }, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 10^6.3, Origin = "Center", Billboard = true, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/styx.asset b/data/assets/scene/solarsystem/missions/newhorizons/styx.asset index e09b9f0072..ada45ff6c5 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/styx.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/styx.asset @@ -46,7 +46,7 @@ local StyxText = { }, }, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 10^6.3, Origin = "Center", Billboard = true, diff --git a/data/assets/scene/solarsystem/planets/earth/markers.asset b/data/assets/scene/solarsystem/planets/earth/markers.asset index 6ceb9458e5..ffb25ffb8a 100644 --- a/data/assets/scene/solarsystem/planets/earth/markers.asset +++ b/data/assets/scene/solarsystem/planets/earth/markers.asset @@ -8,7 +8,7 @@ local EarthMarker = { Name = "EarthMarker", Parent = transforms.EarthIAU.Name, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Enabled = false, Size = 3.0E11, Origin = "Center", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset b/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset index c7673bacd4..6b498b155a 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/satellites.asset @@ -63,7 +63,7 @@ function getSat(title, file, lineNum) Name = title, Parent = "EarthInertial", Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 3e4, Origin = "Center", Body = "TLE", diff --git a/data/assets/scene/solarsystem/sun/glare.asset b/data/assets/scene/solarsystem/sun/glare.asset index 94a2682d92..fd35d5cc16 100644 --- a/data/assets/scene/solarsystem/sun/glare.asset +++ b/data/assets/scene/solarsystem/sun/glare.asset @@ -9,7 +9,7 @@ local SunGlare = { Name = "SunGlare", Parent = transforms.SolarSystemBarycenter.Name, Renderable = { - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 1.3*10^10.5, Origin = "Center", Billboard = true, diff --git a/data/assets/scene/solarsystem/sun/marker.asset b/data/assets/scene/solarsystem/sun/marker.asset index bb4d2c26c8..604ad37456 100644 --- a/data/assets/scene/solarsystem/sun/marker.asset +++ b/data/assets/scene/solarsystem/sun/marker.asset @@ -10,7 +10,7 @@ local SunMarker = { Parent = transforms.SolarSystemBarycenter.Name, Renderable = { Enabled = false, - Type = "RenderablePlane", + Type = "RenderablePlaneImageLocal", Size = 3.0E11, Origin = "Center", Billboard = true, diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index 646dcd4930..1ab8db03ba 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -110,6 +110,11 @@ public: */ const std::vector