Merge pull request #1258 from OpenSpace/issue/1238

Issue/1238
This commit is contained in:
Alexander Bock
2020-07-31 14:29:22 +02:00
committed by GitHub
3 changed files with 39 additions and 19 deletions
@@ -24,6 +24,7 @@ local initializeAndAddNodes = function()
local iss = {
Identifier = "ISS",
Parent = transforms.EarthInertial.Identifier,
BoundingSphere = 30,
Transform = {
Translation = {
Type = "TLETranslation",
+1 -2
View File
@@ -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;
+37 -17
View File
@@ -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> SceneGraphNode::createFromDictionary(
result->addProperty(result->_guiHidden);
}
if (dictionary.hasKey(BoundingSphereInfo.identifier)) {
result->_boundingSphere = dictionary.value<float>(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> 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> SceneGraphNode::createFromDictionary(
result->addProperty(result->_guiPath);
}
if (dictionary.hasKey(KeyFixedBoundingSphere)) {
result->_fixedBoundingSphere = static_cast<float>(
dictionary.value<double>(KeyFixedBoundingSphere)
);
}
LDEBUG(fmt::format("Successfully created SceneGraphNode '{}'", result->identifier()));
@@ -295,6 +316,7 @@ SceneGraphNode::SceneGraphNode()
std::make_unique<StaticRotation>(),
std::make_unique<StaticScale>()
}
, _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*> SceneGraphNode::children() const {
}
float SceneGraphNode::boundingSphere() const {
if (_renderable) {
return _renderable->boundingSphere();
}
return _fixedBoundingSphere;
return _boundingSphere;
}
// renderable