From 9f2f5174d4c66d355c23f5395202949565558854 Mon Sep 17 00:00:00 2001 From: Thunderforge Date: Sat, 29 May 2021 16:17:30 -0500 Subject: [PATCH 1/2] Adding Object Paging Min Size combo box to Advanced -> Visuals Requested in Discord by CMAugust and hammered out with a few other users. --- apps/launcher/advancedpage.cpp | 4 ++++ files/ui/advancedpage.ui | 32 +++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index ed36634b62..9af1db504f 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -136,6 +136,7 @@ bool Launcher::AdvancedPage::loadSettings() loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain"); viewingDistanceComboBox->setValue(convertToCells(Settings::Manager::getInt("viewing distance", "Camera"))); + objectPagingMinSizeComboBox->setValue(Settings::Manager::getFloat("object paging min size", "Terrain")); } // Audio @@ -287,6 +288,9 @@ void Launcher::AdvancedPage::saveSettings() { Settings::Manager::setInt("viewing distance", "Camera", convertToUnits(viewingDistance)); } + double objectPagingMinSize = objectPagingMinSizeComboBox->value(); + if (objectPagingMinSize != Settings::Manager::getFloat("object paging min size", "Terrain")) + Settings::Manager::setFloat("object paging min size", "Terrain", objectPagingMinSize); } // Audio diff --git a/files/ui/advancedpage.ui b/files/ui/advancedpage.ui index 5859f1f382..4462ae356a 100644 --- a/files/ui/advancedpage.ui +++ b/files/ui/advancedpage.ui @@ -478,6 +478,36 @@ + + + + + <html><head/><body><p>Controls how large an object must be to be visible in the scene. The object’s size is divided by its distance to the camera and the result of the division is compared with this value. The smaller this value is, the more objects you will see in the scene.</p></body></html> + + + Object paging min size + + + + + + + 3 + + + 0.000000000000000 + + + 0.250000000000000 + + + 0.005000000000000 + + + + + + <html><head/><body><p>If true, use paging and LOD algorithms to display the entire terrain. If false, only display terrain of the loaded cells.</p></body></html> @@ -487,7 +517,7 @@ - + 20 From 89950e55288ac92e9ea5217da861ec61d8cdda26 Mon Sep 17 00:00:00 2001 From: Thunderforge Date: Sat, 29 May 2021 16:27:23 -0500 Subject: [PATCH 2/2] Preventing type conversion of double to float for objectPagingMinSize --- apps/launcher/advancedpage.cpp | 6 +++--- components/settings/settings.cpp | 16 ++++++++++++++++ components/settings/settings.hpp | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/apps/launcher/advancedpage.cpp b/apps/launcher/advancedpage.cpp index 9af1db504f..bddb70aa02 100644 --- a/apps/launcher/advancedpage.cpp +++ b/apps/launcher/advancedpage.cpp @@ -136,7 +136,7 @@ bool Launcher::AdvancedPage::loadSettings() loadSettingBool(activeGridObjectPagingCheckBox, "object paging active grid", "Terrain"); viewingDistanceComboBox->setValue(convertToCells(Settings::Manager::getInt("viewing distance", "Camera"))); - objectPagingMinSizeComboBox->setValue(Settings::Manager::getFloat("object paging min size", "Terrain")); + objectPagingMinSizeComboBox->setValue(Settings::Manager::getDouble("object paging min size", "Terrain")); } // Audio @@ -289,8 +289,8 @@ void Launcher::AdvancedPage::saveSettings() Settings::Manager::setInt("viewing distance", "Camera", convertToUnits(viewingDistance)); } double objectPagingMinSize = objectPagingMinSizeComboBox->value(); - if (objectPagingMinSize != Settings::Manager::getFloat("object paging min size", "Terrain")) - Settings::Manager::setFloat("object paging min size", "Terrain", objectPagingMinSize); + if (objectPagingMinSize != Settings::Manager::getDouble("object paging min size", "Terrain")) + Settings::Manager::setDouble("object paging min size", "Terrain", objectPagingMinSize); } // Audio diff --git a/components/settings/settings.cpp b/components/settings/settings.cpp index 13501ac8c9..09a3d1f516 100644 --- a/components/settings/settings.cpp +++ b/components/settings/settings.cpp @@ -61,6 +61,15 @@ float Manager::getFloat (const std::string& setting, const std::string& category return number; } +double Manager::getDouble (const std::string& setting, const std::string& category) +{ + const std::string& value = getString(setting, category); + std::stringstream stream(value); + double number = 0.0; + stream >> number; + return number; +} + int Manager::getInt (const std::string& setting, const std::string& category) { const std::string& value = getString(setting, category); @@ -128,6 +137,13 @@ void Manager::setFloat (const std::string &setting, const std::string &category, setString(setting, category, stream.str()); } +void Manager::setDouble (const std::string &setting, const std::string &category, const double value) +{ + std::ostringstream stream; + stream << value; + setString(setting, category, stream.str()); +} + void Manager::setBool(const std::string &setting, const std::string &category, const bool value) { setString(setting, category, value ? "true" : "false"); diff --git a/components/settings/settings.hpp b/components/settings/settings.hpp index ecc5aa5fd3..e3a29d4c34 100644 --- a/components/settings/settings.hpp +++ b/components/settings/settings.hpp @@ -44,6 +44,7 @@ namespace Settings static int getInt (const std::string& setting, const std::string& category); static float getFloat (const std::string& setting, const std::string& category); + static double getDouble (const std::string& setting, const std::string& category); static std::string getString (const std::string& setting, const std::string& category); static bool getBool (const std::string& setting, const std::string& category); static osg::Vec2f getVector2 (const std::string& setting, const std::string& category); @@ -51,6 +52,7 @@ namespace Settings static void setInt (const std::string& setting, const std::string& category, const int value); static void setFloat (const std::string& setting, const std::string& category, const float value); + static void setDouble (const std::string& setting, const std::string& category, const double value); static void setString (const std::string& setting, const std::string& category, const std::string& value); static void setBool (const std::string& setting, const std::string& category, const bool value); static void setVector2 (const std::string& setting, const std::string& category, const osg::Vec2f value);