From bf34c3a01661269d899e2fdfae2f28e968e8bed3 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 23 Jun 2021 00:40:22 +0200 Subject: [PATCH] Add the ability to RenderableFOV to always draw the field of view frustum --- .../rendering/renderablefov.cpp | 17 ++++++++++++++++- .../rendering/renderablefov.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index 775abfec35..9435d3b3bb 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -66,6 +66,13 @@ namespace { "making it more visible." }; + constexpr openspace::properties::Property::PropertyInfo AlwaysDrawFovInfo = { + "AlwaysDrawFov", + "Always Draw FOV", + "If this value is enabled, the field of view will always be drawn, regardless of " + "whether image information has been loaded or not" + }; + constexpr openspace::properties::Property::PropertyInfo DefaultStartColorInfo = { "Colors.DefaultStart", "Start of default color", @@ -160,6 +167,10 @@ namespace { // A table describing the instrument whose field of view should be rendered Instrument instrument; + // If this value is set to 'true', the field of view specified here will always be + // rendered, regardless of whether image information is currently available or not + std::optional alwaysDrawFov; + // A list of potential targets (specified as SPICE names) that the field of view // should be tested against std::vector potentialTargets; @@ -192,6 +203,7 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _lineWidth(LineWidthInfo, 1.f, 1.f, 20.f) , _standOffDistance(StandoffDistanceInfo, 0.9999, 0.99, 1.0, 0.000001) + , _alwaysDrawFov(AlwaysDrawFovInfo, false) , _colors({ { DefaultStartColorInfo, glm::vec3(0.4f), glm::vec3(0.f), glm::vec3(1.f) }, { DefaultEndColorInfo, glm::vec3(0.85f), glm::vec3(0.f), glm::vec3(1.f) }, @@ -239,6 +251,9 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) _standOffDistance = p.standOffDistance.value_or(_standOffDistance); addProperty(_standOffDistance); + + _alwaysDrawFov = p.alwaysDrawFov.value_or(_alwaysDrawFov); + addProperty(_alwaysDrawFov); _simplifyBounds = p.simplifyBounds.value_or(_simplifyBounds); @@ -769,7 +784,7 @@ void RenderableFov::render(const RenderData& data, RendererTasks&) { } void RenderableFov::update(const UpdateData& data) { - _drawFOV = false; + _drawFOV = _alwaysDrawFov; if (ImageSequencer::ref().isReady()) { _drawFOV = ImageSequencer::ref().isInstrumentActive( data.time.j2000Seconds(), diff --git a/modules/spacecraftinstruments/rendering/renderablefov.h b/modules/spacecraftinstruments/rendering/renderablefov.h index 6ae7fe6513..f1a9c00352 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.h +++ b/modules/spacecraftinstruments/rendering/renderablefov.h @@ -77,6 +77,7 @@ private: // properties properties::FloatProperty _lineWidth; properties::DoubleProperty _standOffDistance; + properties::BoolProperty _alwaysDrawFov; ghoul::opengl::ProgramObject* _program = nullptr; UniformCache(modelViewProjection, defaultColorStart, defaultColorEnd, activeColor, targetInFieldOfViewColor, intersectionStartColor, intersectionEndColor,