diff --git a/data/assets/customization/globebrowsing.asset b/data/assets/customization/globebrowsing.asset index bc72ae17b3..2d6b09b63e 100644 --- a/data/assets/customization/globebrowsing.asset +++ b/data/assets/customization/globebrowsing.asset @@ -58,10 +58,12 @@ asset.onInitialize(function () -- Add local patches described at the top of this file for obj, list in pairs(vrt_folders) do for _, dir in pairs(list) do - openspace.globebrowsing.addBlendingLayersFromDirectory(dir, obj) + if (dir ~= '') then + openspace.globebrowsing.addBlendingLayersFromDirectory(dir, obj) - if CreateFocusNodes then - openspace.globebrowsing.addFocusNodesFromDirectory(dir, obj) + if CreateFocusNodes then + openspace.globebrowsing.addFocusNodesFromDirectory(dir, obj) + end end end end diff --git a/data/assets/scene/digitaluniverse/stars.asset b/data/assets/scene/digitaluniverse/stars.asset index 696c4aa739..0407908aab 100644 --- a/data/assets/scene/digitaluniverse/stars.asset +++ b/data/assets/scene/digitaluniverse/stars.asset @@ -58,7 +58,7 @@ local sunstar = { MagnitudeExponent = 6.2, SizeComposition = "Distance Modulus", RenderMethod = "Texture Based", -- or PSF - FadeInDistances = {0.0001, 0.1} + FadeInDistances = { 0.0001, 0.1 } }, GUI = { Name = "Sun", diff --git a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset index 72fabc4988..841a2536d9 100644 --- a/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset +++ b/data/assets/scene/solarsystem/planets/earth/satellites/misc/iss.asset @@ -24,6 +24,7 @@ local initializeAndAddNodes = function() local iss = { Identifier = "ISS", Parent = transforms.EarthInertial.Identifier, + BoundingSphere = 30, Transform = { Translation = { Type = "TLETranslation", diff --git a/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/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; diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 32147034f9..14db241e45 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,35 +64,43 @@ namespace { constexpr openspace::properties::Property::PropertyInfo ScreenSpacePositionInfo = { "ScreenSpacePosition", "ScreenSpacePosition", - "" // @TODO Missing documentation + "The x,y position in screen space. Can be used for placing GUI elements", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo ScreenVisibilityInfo = { "ScreenVisibility", "ScreenVisibility", - "" // @TODO Missing documentation + "Determines if the node is currently visible on screen", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo DistanceFromCamToNodeInfo = { "DistanceFromCamToNode", "DistanceFromCamToNode", - "" // @TODO Missing documentation + "The distance from the camera to the node surface", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo ScreenSizeRadiusInfo = { "ScreenSizeRadius", "ScreenSizeRadius", - "" // @TODO Missing documentation + "The screen size of the radius of the node", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo VisibilityDistanceInfo = { "VisibilityDistance", "VisibilityDistance", - "" // @TODO Missing documentation + "The distace in world coordinates between node and camera " + "at which the screenspace object will become visible", + openspace::properties::Property::Visibility::Hidden }; - constexpr const char* KeyFixedBoundingSphere = "FixedBoundingSphere"; constexpr openspace::properties::Property::PropertyInfo BoundingSphereInfo = { "BoundingSphere", "Bounding Sphere", "The bounding sphere of the scene graph node. This can be the " - "bounding sphere of a renderable or a fixed bounding sphere. " + "bounding sphere of an attached renderable or directly specified to the node. " + "If there is a boundingsphere on both the renderable and the node, the largest " + "number will be picked.", + openspace::properties::Property::Visibility::Hidden }; constexpr openspace::properties::Property::PropertyInfo GuiPathInfo = { @@ -155,6 +163,11 @@ std::unique_ptr SceneGraphNode::createFromDictionary( result->addProperty(result->_guiHidden); } + if (dictionary.hasKey(BoundingSphereInfo.identifier)) { + result->_boundingSphere = dictionary.value(BoundingSphereInfo.identifier); + result->_boundingSphere.setVisibility(properties::Property::Visibility::All); + } + if (dictionary.hasKey(KeyTransformTranslation)) { ghoul::Dictionary translationDictionary; dictionary.getValue(KeyTransformTranslation, translationDictionary); @@ -246,6 +259,19 @@ std::unique_ptr SceneGraphNode::createFromDictionary( LDEBUG(fmt::format( "Successfully created renderable for '{}'", result->identifier() )); + + // If the renderable child has a larger bounding sphere, we allow it tooverride + if (result->_renderable->boundingSphere() > result->_boundingSphere) { + result->_boundingSphere = result->_renderable->boundingSphere(); + + if (dictionary.hasKey(BoundingSphereInfo.identifier)) { + LWARNING(fmt::format( + "The specified property 'BoundingSphere' for '{}' was overwritten " + "by a child renderable", + result->_identifier + )); + } + } } if (dictionary.hasKey(KeyTag)) { @@ -273,11 +299,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 +316,7 @@ SceneGraphNode::SceneGraphNode() std::make_unique(), std::make_unique() } + , _boundingSphere(properties::FloatProperty(BoundingSphereInfo, 0.f)) , _computeScreenSpaceValues(ComputeScreenSpaceInfo, false) , _screenSpacePosition( properties::IVec2Property(ScreenSpacePositionInfo, glm::ivec2(-1, -1)) @@ -310,6 +332,7 @@ SceneGraphNode::SceneGraphNode() addProperty(_distFromCamToNode); addProperty(_screenSizeRadius); addProperty(_visibilityDistance); + addProperty(_boundingSphere); } SceneGraphNode::~SceneGraphNode() {} // NOLINT @@ -905,10 +928,7 @@ std::vector SceneGraphNode::children() const { } float SceneGraphNode::boundingSphere() const { - if (_renderable) { - return _renderable->boundingSphere(); - } - return _fixedBoundingSphere; + return _boundingSphere; } // renderable