From 8428c0da7b51056753827b3895c37702712b7df0 Mon Sep 17 00:00:00 2001 From: Lovisa Hassler Date: Wed, 15 Jul 2020 20:57:48 +0200 Subject: [PATCH 1/9] Adding bounding sphere property to scenegraph node --- include/openspace/scene/scenegraphnode.h | 3 +-- src/scene/scenegraphnode.cpp | 27 ++++++++++++++---------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 81a3fa92c4..67cb8add12 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -187,11 +187,10 @@ private: glm::dmat3 _worldRotationCached = glm::dmat3(1.0); glm::dvec3 _worldScaleCached = glm::dvec3(1.0); - float _fixedBoundingSphere = 0.f; - glm::dmat4 _modelTransformCached = glm::dmat4(1.0); glm::dmat4 _inverseModelTransformCached = glm::dmat4(1.0); + properties::FloatProperty _boundingSphere; properties::BoolProperty _computeScreenSpaceValues; properties::IVec2Property _screenSpacePosition; properties::BoolProperty _screenVisibility; diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 32147034f9..3d0ca0a63a 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -86,13 +86,14 @@ namespace { "VisibilityDistance", "" // @TODO Missing documentation }; - constexpr const char* KeyFixedBoundingSphere = "FixedBoundingSphere"; constexpr openspace::properties::Property::PropertyInfo BoundingSphereInfo = { "BoundingSphere", "Bounding Sphere", "The bounding sphere of the scene graph node. This can be the " - "bounding sphere of a renderable or a fixed bounding sphere. " + "bounding sphere of an attached renderable or directly specified to the node. " + "If there is a boundingsphere on both the renderable and the ndoe, the largest number will be picked. ", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo GuiPathInfo = { @@ -155,6 +156,11 @@ std::unique_ptr SceneGraphNode::createFromDictionary( result->addProperty(result->_guiHidden); } + if (dictionary.hasKey(BoundingSphereInfo.identifier)) { + result->_boundingSphere = dictionary.value(BoundingSphereInfo.identifier); + result->_boundingSphere.setVisibility(openspace::properties::Property::Visibility::All); + } + if (dictionary.hasKey(KeyTransformTranslation)) { ghoul::Dictionary translationDictionary; dictionary.getValue(KeyTransformTranslation, translationDictionary); @@ -246,6 +252,11 @@ std::unique_ptr SceneGraphNode::createFromDictionary( LDEBUG(fmt::format( "Successfully created renderable for '{}'", result->identifier() )); + + // If the renderable child has a bounding sphere that is larger, we allow it to override + result->_boundingSphere.setValue(std::max(result->_renderable->boundingSphere(), + result->_boundingSphere.value() + )); } if (dictionary.hasKey(KeyTag)) { @@ -273,11 +284,6 @@ std::unique_ptr SceneGraphNode::createFromDictionary( result->addProperty(result->_guiPath); } - if (dictionary.hasKey(KeyFixedBoundingSphere)) { - result->_fixedBoundingSphere = static_cast( - dictionary.value(KeyFixedBoundingSphere) - ); - } LDEBUG(fmt::format("Successfully created SceneGraphNode '{}'", result->identifier())); @@ -295,6 +301,7 @@ SceneGraphNode::SceneGraphNode() std::make_unique(), std::make_unique() } + , _boundingSphere(properties::FloatProperty(BoundingSphereInfo, 0.0f)) , _computeScreenSpaceValues(ComputeScreenSpaceInfo, false) , _screenSpacePosition( properties::IVec2Property(ScreenSpacePositionInfo, glm::ivec2(-1, -1)) @@ -310,6 +317,7 @@ SceneGraphNode::SceneGraphNode() addProperty(_distFromCamToNode); addProperty(_screenSizeRadius); addProperty(_visibilityDistance); + addProperty(_boundingSphere); } SceneGraphNode::~SceneGraphNode() {} // NOLINT @@ -905,10 +913,7 @@ std::vector SceneGraphNode::children() const { } float SceneGraphNode::boundingSphere() const { - if (_renderable) { - return _renderable->boundingSphere(); - } - return _fixedBoundingSphere; + return _boundingSphere.value(); } // renderable From 9f10814466711f19b7b648205d0c3556e4485975 Mon Sep 17 00:00:00 2001 From: Lovisa Hassler Date: Wed, 15 Jul 2020 20:58:15 +0200 Subject: [PATCH 2/9] Adding bounding sphere to ISS --- .../scene/solarsystem/planets/earth/satellites/misc/iss.asset | 1 + 1 file changed, 1 insertion(+) diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset index 72fabc4988..841a2536d9 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset @@ -24,6 +24,7 @@ local initializeAndAddNodes = function() local iss = { Identifier = "ISS", Parent = transforms.EarthInertial.Identifier, + BoundingSphere = 30, Transform = { Translation = { Type = "TLETranslation", From b70f8422a1ca42ec6ee82c919a2741c17d561581 Mon Sep 17 00:00:00 2001 From: Lovisa Hassler Date: Wed, 15 Jul 2020 20:58:48 +0200 Subject: [PATCH 3/9] Hiding Screen space properties and updating documentation --- src/scene/scenegraphnode.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 3d0ca0a63a..eea6ef5269 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -56,7 +56,7 @@ namespace { constexpr openspace::properties::Property::PropertyInfo ComputeScreenSpaceInfo = { "ComputeScreenSpaceData", - "Screen Space Data", + "Compute Screen Space Data", "If this value is set to 'true', the screenspace-based properties are calculated " "at regular intervals. If these values are set to 'false', they are not updated." }; @@ -64,27 +64,33 @@ namespace { constexpr openspace::properties::Property::PropertyInfo ScreenSpacePositionInfo = { "ScreenSpacePosition", "ScreenSpacePosition", - "" // @TODO Missing documentation + "The x,y position in screen space. Can be used for placing GUI elements", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo ScreenVisibilityInfo = { "ScreenVisibility", "ScreenVisibility", - "" // @TODO Missing documentation + "Determines if the node is currently visible on screen", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo DistanceFromCamToNodeInfo = { "DistanceFromCamToNode", "DistanceFromCamToNode", - "" // @TODO Missing documentation + "The distance from the camera to the node surface", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo ScreenSizeRadiusInfo = { "ScreenSizeRadius", "ScreenSizeRadius", - "" // @TODO Missing documentation + "The screen size of the radius of the node", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo VisibilityDistanceInfo = { "VisibilityDistance", "VisibilityDistance", - "" // @TODO Missing documentation + "The distace in world coordinates between node and camera " + "at which the screenspace object will become visible", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo BoundingSphereInfo = { From 8d5a56e6ef231b6ed2de76255aedd30d8934875c Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Thu, 16 Jul 2020 09:57:37 +0200 Subject: [PATCH 4/9] Use vec3 color representation for fixed color in RenderableStars --- data/assets/scene/digitaluniverse/stars.asset | 2 +- modules/space/rendering/renderablestars.cpp | 2 +- modules/space/rendering/renderablestars.h | 4 ++-- modules/space/shaders/star_fs.glsl | 8 ++------ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/data/assets/scene/digitaluniverse/stars.asset b/data/assets/scene/digitaluniverse/stars.asset index 696c4aa739..0407908aab 100644 --- a/data/assets/scene/digitaluniverse/stars.asset +++ b/data/assets/scene/digitaluniverse/stars.asset @@ -58,7 +58,7 @@ local sunstar = { MagnitudeExponent = 6.2, SizeComposition = "Distance Modulus", RenderMethod = "Texture Based", -- or PSF - FadeInDistances = {0.0001, 0.1} + FadeInDistances = { 0.0001, 0.1 } }, GUI = { Name = "Sun", diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 585c43a94e..d995e754e5 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -424,7 +424,7 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) glm::vec2(-10.f, -10.f), glm::vec2(10.f, 10.f) ) - , _fixedColor(FixedColorInfo, glm::vec4(1.f), glm::vec4(0.f), glm::vec4(1.f)) + , _fixedColor(FixedColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _filterOutOfRange(FilterOutOfRangeInfo, false) , _pointSpreadFunctionTexturePath(PsfTextureInfo) , _psfMethodOption( diff --git a/modules/space/rendering/renderablestars.h b/modules/space/rendering/renderablestars.h index 9ab74c787d..946f9b917b 100644 --- a/modules/space/rendering/renderablestars.h +++ b/modules/space/rendering/renderablestars.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include @@ -98,7 +98,7 @@ private: properties::StringProperty _otherDataColorMapPath; properties::Vec2Property _otherDataRange; std::unique_ptr _otherDataColorMapTexture; - properties::Vec4Property _fixedColor; + properties::Vec3Property _fixedColor; properties::BoolProperty _filterOutOfRange; properties::StringProperty _pointSpreadFunctionTexturePath; std::unique_ptr _pointSpreadFunctionTexture; diff --git a/modules/space/shaders/star_fs.glsl b/modules/space/shaders/star_fs.glsl index 329e7e513c..46c6ebb4a0 100644 --- a/modules/space/shaders/star_fs.glsl +++ b/modules/space/shaders/star_fs.glsl @@ -36,7 +36,7 @@ uniform sampler1D colorTexture; uniform sampler2D psfTexture; uniform float alphaValue; -uniform vec4 fixedColor; +uniform vec3 fixedColor; uniform int colorOption; @@ -93,17 +93,13 @@ Fragment getFragment() { } break; case COLOROPTION_FIXEDCOLOR: - color = fixedColor; + color = vec4(fixedColor, 1.0); break; } vec4 textureColor = texture(psfTexture, 0.5 * psfCoords + 0.5); vec4 fullColor = vec4(color.rgb, textureColor.a); fullColor.a *= alphaValue; - - if (colorOption == COLOROPTION_FIXEDCOLOR) { - fullColor.a *= fixedColor.a; - } if (fullColor.a == 0) { discard; From 93135d5b1831cdbb5d6735b0cf03d5deb85594f2 Mon Sep 17 00:00:00 2001 From: Lovisa Hassler Date: Fri, 17 Jul 2020 18:35:55 +0200 Subject: [PATCH 5/9] Warn if child overwrites specified bounding sphere --- src/scene/scenegraphnode.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index eea6ef5269..63ef67b4e6 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -260,9 +260,17 @@ std::unique_ptr SceneGraphNode::createFromDictionary( )); // If the renderable child has a bounding sphere that is larger, we allow it to override - result->_boundingSphere.setValue(std::max(result->_renderable->boundingSphere(), - result->_boundingSphere.value() - )); + if (result->_renderable->boundingSphere() > result->_boundingSphere.value()) { + result->_boundingSphere.setValue(result->_renderable->boundingSphere()); + + if (dictionary.hasKey(BoundingSphereInfo.identifier)) { + LWARNING(fmt::format( + "The specified property 'BoundingSphere' for '{}' was overwritten by a child renderable", + result->_identifier + )); + } + } + } if (dictionary.hasKey(KeyTag)) { From 9b1c11763dbb075a82f06b5397e5e0182e398c8a Mon Sep 17 00:00:00 2001 From: Lovisa Hassler Date: Fri, 17 Jul 2020 18:38:27 +0200 Subject: [PATCH 6/9] Spell mistake fix --- src/scene/scenegraphnode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 63ef67b4e6..d07988625f 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -98,7 +98,7 @@ namespace { "Bounding Sphere", "The bounding sphere of the scene graph node. This can be the " "bounding sphere of an attached renderable or directly specified to the node. " - "If there is a boundingsphere on both the renderable and the ndoe, the largest number will be picked. ", + "If there is a boundingsphere on both the renderable and the node, the largest number will be picked. ", openspace::properties::Property::Visibility::Hidden }; From 08173a258c9f40c01831326ce2501fc13f9ad844 Mon Sep 17 00:00:00 2001 From: John Riedel Date: Wed, 22 Jul 2020 17:29:02 -0600 Subject: [PATCH 7/9] update mercury.asset file references to match capitalization of actual file name (#1260) --- data/assets/scene/solarsystem/planets/mercury/mercury.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/mercury/mercury.asset b/data/assets/scene/solarsystem/planets/mercury/mercury.asset index 9bba1841fb..71c7ff4ded 100644 --- a/data/assets/scene/solarsystem/planets/mercury/mercury.asset +++ b/data/assets/scene/solarsystem/planets/mercury/mercury.asset @@ -20,7 +20,7 @@ local color_layers = { { Identifier = "Messenger_MDIS_Utah", Name = "Messenger MDIS [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerMDIS.wms", + FilePath = mapServiceConfigs .. "/Utah/MessengerMdis.wms", Enabled = false }, { @@ -122,7 +122,7 @@ local color_layers = { { Identifier = "Messenger_SHADE_Sweden", Name = "Messenger SHADE [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_SHADE.wms", + FilePath = mapServiceConfigs .. "/LiU/Messenger_Shade.wms", Settings = { Gamma = 1.33, Multiplier = 1.15 From e1fafb4dd36c779bd194aff9345adf8dfa29ad70 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 23 Jul 2020 11:30:03 +0200 Subject: [PATCH 8/9] Fix capitalization of Mercury map files (closes #1260) --- data/assets/scene/solarsystem/planets/mercury/mercury.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/mercury/mercury.asset b/data/assets/scene/solarsystem/planets/mercury/mercury.asset index 9bba1841fb..71c7ff4ded 100644 --- a/data/assets/scene/solarsystem/planets/mercury/mercury.asset +++ b/data/assets/scene/solarsystem/planets/mercury/mercury.asset @@ -20,7 +20,7 @@ local color_layers = { { Identifier = "Messenger_MDIS_Utah", Name = "Messenger MDIS [Utah]", - FilePath = mapServiceConfigs .. "/Utah/MessengerMDIS.wms", + FilePath = mapServiceConfigs .. "/Utah/MessengerMdis.wms", Enabled = false }, { @@ -122,7 +122,7 @@ local color_layers = { { Identifier = "Messenger_SHADE_Sweden", Name = "Messenger SHADE [Sweden]", - FilePath = mapServiceConfigs .. "/LiU/Messenger_SHADE.wms", + FilePath = mapServiceConfigs .. "/LiU/Messenger_Shade.wms", Settings = { Gamma = 1.33, Multiplier = 1.15 From e8c220d92a737df95caeff2555f349911cf84b2e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 31 Jul 2020 14:28:31 +0200 Subject: [PATCH 9/9] Small coding style fixes --- src/scene/scenegraphnode.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index d07988625f..14db241e45 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -98,7 +98,8 @@ namespace { "Bounding Sphere", "The bounding sphere of the scene graph node. This can be the " "bounding sphere of an attached renderable or directly specified to the node. " - "If there is a boundingsphere on both the renderable and the node, the largest number will be picked. ", + "If there is a boundingsphere on both the renderable and the node, the largest " + "number will be picked.", openspace::properties::Property::Visibility::Hidden }; @@ -164,7 +165,7 @@ std::unique_ptr SceneGraphNode::createFromDictionary( if (dictionary.hasKey(BoundingSphereInfo.identifier)) { result->_boundingSphere = dictionary.value(BoundingSphereInfo.identifier); - result->_boundingSphere.setVisibility(openspace::properties::Property::Visibility::All); + result->_boundingSphere.setVisibility(properties::Property::Visibility::All); } if (dictionary.hasKey(KeyTransformTranslation)) { @@ -259,18 +260,18 @@ std::unique_ptr SceneGraphNode::createFromDictionary( "Successfully created renderable for '{}'", result->identifier() )); - // If the renderable child has a bounding sphere that is larger, we allow it to override - if (result->_renderable->boundingSphere() > result->_boundingSphere.value()) { - result->_boundingSphere.setValue(result->_renderable->boundingSphere()); + // If the renderable child has a larger bounding sphere, we allow it tooverride + if (result->_renderable->boundingSphere() > result->_boundingSphere) { + result->_boundingSphere = result->_renderable->boundingSphere(); if (dictionary.hasKey(BoundingSphereInfo.identifier)) { LWARNING(fmt::format( - "The specified property 'BoundingSphere' for '{}' was overwritten by a child renderable", + "The specified property 'BoundingSphere' for '{}' was overwritten " + "by a child renderable", result->_identifier )); } } - } if (dictionary.hasKey(KeyTag)) { @@ -315,7 +316,7 @@ SceneGraphNode::SceneGraphNode() std::make_unique(), std::make_unique() } - , _boundingSphere(properties::FloatProperty(BoundingSphereInfo, 0.0f)) + , _boundingSphere(properties::FloatProperty(BoundingSphereInfo, 0.f)) , _computeScreenSpaceValues(ComputeScreenSpaceInfo, false) , _screenSpacePosition( properties::IVec2Property(ScreenSpacePositionInfo, glm::ivec2(-1, -1)) @@ -927,7 +928,7 @@ std::vector SceneGraphNode::children() const { } float SceneGraphNode::boundingSphere() const { - return _boundingSphere.value(); + return _boundingSphere; } // renderable