From 3b4a50fa3ee448e1c3feee53968dc3b5f7d45843 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Fri, 6 Dec 2024 10:35:51 +0100 Subject: [PATCH 1/2] :wrench: Make HDR flare and planet dot sizes configurable --- plugins/csp-trajectories/src/Plugin.cpp | 16 +++++++++++----- plugins/csp-trajectories/src/Plugin.hpp | 6 ++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/csp-trajectories/src/Plugin.cpp b/plugins/csp-trajectories/src/Plugin.cpp index 85d725985..64c92796e 100644 --- a/plugins/csp-trajectories/src/Plugin.cpp +++ b/plugins/csp-trajectories/src/Plugin.cpp @@ -77,6 +77,8 @@ void from_json(nlohmann::json const& j, Plugin::Settings& o) { cs::core::Settings::deserialize(j, "enableLDRFlares", o.mEnableLDRFlares); cs::core::Settings::deserialize(j, "enableHDRFlares", o.mEnableHDRFlares); cs::core::Settings::deserialize(j, "enablePlanetMarks", o.mEnablePlanetMarks); + cs::core::Settings::deserialize(j, "hdrFlareScale", o.mHDRFlareScale); + cs::core::Settings::deserialize(j, "planetMarkScale", o.mPlanetMarkScale); } void to_json(nlohmann::json& j, Plugin::Settings const& o) { @@ -85,6 +87,8 @@ void to_json(nlohmann::json& j, Plugin::Settings const& o) { cs::core::Settings::serialize(j, "enableLDRFlares", o.mEnableLDRFlares); cs::core::Settings::serialize(j, "enableHDRFlares", o.mEnableHDRFlares); cs::core::Settings::serialize(j, "enablePlanetMarks", o.mEnablePlanetMarks); + cs::core::Settings::serialize(j, "hdrFlareScale", o.mHDRFlareScale); + cs::core::Settings::serialize(j, "planetMarkScale", o.mPlanetMarkScale); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -180,7 +184,7 @@ void Plugin::update() { }; // Trajectory dots as well as the HDR flares should be constant in size on screen. Therefore, we - // have to compute thei solid angle based on the current field of view. + // have to compute their solid angle based on the current field of view. VistaTransformMatrix proj = GetVistaSystem()->GetDisplayManager()->GetCurrentRenderInfo()->m_matProjection; float fov2 = std::pow(std::min(std::atan(1.F / proj[1][1]), std::atan(1.F / proj[0][0])), 2.F); @@ -189,7 +193,8 @@ void Plugin::update() { bool dotsEnabled = mPluginSettings->mEnablePlanetMarks.get(); for (auto const& dot : mTrajectoryDots) { if (updateVisibility(dot, dotsEnabled)) { - dot->pSolidAngle = 0.0002F * fov2; + double dotScale = mPluginSettings->mPlanetMarkScale.get() * mPluginSettings->mPlanetMarkScale.get(); + dot->pSolidAngle = 0.0002F * fov2 * dotScale; } } @@ -237,8 +242,9 @@ void Plugin::update() { double bodySolidAngle = 4.0 * glm::pi() * std::pow(std::sin(bodyAngularSize * 0.5), 2.0); - double maxSolidAngle = 0.005 * fov2; // The flare will not get larger than this. - double minSolidAngle = 0.00005 * fov2; // The flare will not get smaller than this. + double flareScale = mPluginSettings->mHDRFlareScale.get() * mPluginSettings->mHDRFlareScale.get(); + double maxSolidAngle = 0.005 * fov2 * flareScale; // The flare will not get larger than this. + double minSolidAngle = 0.00005 * fov2 * flareScale; // The flare will not get smaller than this. // We make the flare a bit larger than the body to ensure that it covers the body completely. double flareSolidAngle = glm::clamp(bodySolidAngle * 1.2, minSolidAngle, maxSolidAngle); @@ -249,7 +255,7 @@ void Plugin::update() { // out between fadeEndSolidAngle and maxSolidAngle. if (object->getIsBodyVisible()) { // The flare is faded out between fadeEndSolidAngle and maxSolidAngle. - double fadeEndSolidAngle = 0.0005 * fov2; + double fadeEndSolidAngle = 0.0005 * fov2 * flareScale; alpha = glm::clamp( 1.0 - (flareSolidAngle - fadeEndSolidAngle) / (maxSolidAngle - fadeEndSolidAngle), 0.0, diff --git a/plugins/csp-trajectories/src/Plugin.hpp b/plugins/csp-trajectories/src/Plugin.hpp index cd8b42fee..59199f0ee 100644 --- a/plugins/csp-trajectories/src/Plugin.hpp +++ b/plugins/csp-trajectories/src/Plugin.hpp @@ -83,6 +83,12 @@ class Plugin : public cs::core::PluginBase { /// Toggles dots at runtime. cs::utils::DefaultProperty mEnablePlanetMarks{true}; + + /// Scaling factor for HDR flares. + cs::utils::DefaultProperty mHDRFlareScale{1.0}; + + /// Scaling factor for dots. + cs::utils::DefaultProperty mPlanetMarkScale{1.0}; }; void init() override; From eb51498dcf98f3528fbe5fd935e460f5e8d0998f Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Sun, 5 Jan 2025 07:15:46 +0100 Subject: [PATCH 2/2] :sparkles: Apply clang-format --- plugins/csp-trajectories/src/Plugin.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/csp-trajectories/src/Plugin.cpp b/plugins/csp-trajectories/src/Plugin.cpp index 64c92796e..7dd8ce396 100644 --- a/plugins/csp-trajectories/src/Plugin.cpp +++ b/plugins/csp-trajectories/src/Plugin.cpp @@ -193,8 +193,9 @@ void Plugin::update() { bool dotsEnabled = mPluginSettings->mEnablePlanetMarks.get(); for (auto const& dot : mTrajectoryDots) { if (updateVisibility(dot, dotsEnabled)) { - double dotScale = mPluginSettings->mPlanetMarkScale.get() * mPluginSettings->mPlanetMarkScale.get(); - dot->pSolidAngle = 0.0002F * fov2 * dotScale; + double dotScale = + mPluginSettings->mPlanetMarkScale.get() * mPluginSettings->mPlanetMarkScale.get(); + dot->pSolidAngle = 0.0002F * fov2 * static_cast(dotScale); } } @@ -242,9 +243,11 @@ void Plugin::update() { double bodySolidAngle = 4.0 * glm::pi() * std::pow(std::sin(bodyAngularSize * 0.5), 2.0); - double flareScale = mPluginSettings->mHDRFlareScale.get() * mPluginSettings->mHDRFlareScale.get(); - double maxSolidAngle = 0.005 * fov2 * flareScale; // The flare will not get larger than this. - double minSolidAngle = 0.00005 * fov2 * flareScale; // The flare will not get smaller than this. + double flareScale = + mPluginSettings->mHDRFlareScale.get() * mPluginSettings->mHDRFlareScale.get(); + double maxSolidAngle = 0.005 * fov2 * flareScale; // The flare will not get larger than this. + double minSolidAngle = + 0.00005 * fov2 * flareScale; // The flare will not get smaller than this. // We make the flare a bit larger than the body to ensure that it covers the body completely. double flareSolidAngle = glm::clamp(bodySolidAngle * 1.2, minSolidAngle, maxSolidAngle);