From e947481d30b51e731947d85de45065d5b0c02e45 Mon Sep 17 00:00:00 2001
From: Rider Linden <rider@lindenlab.com>
Date: Mon, 27 Nov 2017 15:17:54 -0800
Subject: [PATCH] Start viewer/common split

---
 indra/newview/llsettingsdaycycle.cpp |  4 +-
 indra/newview/llsettingssky.cpp      | 70 ++++++++++++----------------
 indra/newview/llsettingssky.h        | 15 ++++--
 indra/newview/llsettingswater.cpp    | 28 ++++++++---
 indra/newview/llsettingswater.h      | 23 ++++++---
 5 files changed, 79 insertions(+), 61 deletions(-)

diff --git a/indra/newview/llsettingsdaycycle.cpp b/indra/newview/llsettingsdaycycle.cpp
index 391aeddf1cc..a579f991824 100644
--- a/indra/newview/llsettingsdaycycle.cpp
+++ b/indra/newview/llsettingsdaycycle.cpp
@@ -115,9 +115,9 @@ const std::string LLSettingsDay::SETTING_KEYNAME("key_name");
 const std::string LLSettingsDay::SETTING_KEYKFRAME("key_keyframe");
 const std::string LLSettingsDay::SETTING_TRACKS("tracks");
 
-//const S64 LLSettingsDayCycle::MINIMUM_DAYLENGTH(  300); // 5 mins
+const S64 LLSettingsDay::MINIMUM_DAYLENGTH(  300); // 5 mins
 
-const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 14400); // 4 hours
+//const S64 LLSettingsDay::MINIMUM_DAYLENGTH( 14400); // 4 hours
 const S64 LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days
 
 const S32 LLSettingsDay::TRACK_WATER(0);   // water track is 0
diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp
index 1109099ff57..f1825792d99 100644
--- a/indra/newview/llsettingssky.cpp
+++ b/indra/newview/llsettingssky.cpp
@@ -340,7 +340,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam
         newsettings[SETTING_MOON_ROTATION] = moonquat.getValue();
     }
 
-    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(newsettings);
+    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsVOSky>(newsettings);
  
     if (skyp->validate())
         return skyp;
@@ -352,7 +352,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildDefaultSky()
 {
     LLSD settings = LLSettingsSky::defaults();
 
-    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(settings);
+    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsVOSky>(settings);
     if (skyp->validate())
         return skyp;
 
@@ -363,7 +363,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildClone()
 {
     LLSD settings = cloneSettings();
 
-    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsSky>(settings);
+    LLSettingsSky::ptr_t skyp = boost::make_shared<LLSettingsVOSky>(settings);
 
     if (skyp->validate())
         return skyp;
@@ -551,27 +551,6 @@ void LLSettingsSky::calculateLightSettings()
 
     }
 
-#if 0
-    mSun.setColor(vary_SunlightColor);
-    mMoon.setColor(LLColor3(1.0f, 1.0f, 1.0f));
-
-    mSun.renewDirection();
-    mSun.renewColor();
-    mMoon.renewDirection();
-    mMoon.renewColor();
-
-    float dp = getToSunLast() * LLVector3(0,0,1.f);
-    if (dp < 0)
-    {
-        dp = 0;
-    }
-
-    // Since WL scales everything by 2, there should always be at least a 2:1 brightness ratio
-    // between sunlight and point lights in windlight to normalize point lights.
-    F32 sun_dynamic_range = llmax(gSavedSettings.getF32("RenderSunDynamicRange"), 0.0001f);
-    LLEnvironment::instance().setSceneLightStrength(2.0f * (1.0f + sun_dynamic_range * dp));
-#endif
-
     mSunDiffuse = vary_SunlightColor;
     mSunAmbient = vary_AmbientColor;
     mMoonDiffuse = vary_SunlightColor;
@@ -609,22 +588,6 @@ LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const
     return param_map;
 }
 
-void LLSettingsSky::applySpecial(void *ptarget)
-{
-    LLGLSLShader *shader = (LLGLSLShader *)ptarget;
-
-    shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDirection.mV);
-
-    shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0);
-
-    {
-        //LLEnvironment::instance().getCloudDelta();
-        LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]);
-        vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta());
-        shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV);
-    }
-}
-
 //=========================================================================
 namespace
 {
@@ -663,3 +626,30 @@ namespace
             altitude = 0.0f;
     }
 }
+
+//=========================================================================
+LLSettingsVOSky::LLSettingsVOSky(const LLSD &data):
+    LLSettingsSky(data)
+{
+}
+
+LLSettingsVOSky::LLSettingsVOSky():
+    LLSettingsSky()
+{
+}
+
+void LLSettingsVOSky::applySpecial(void *ptarget)
+{
+    LLGLSLShader *shader = (LLGLSLShader *)ptarget;
+
+    shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV);
+
+    shader->uniform4f(LLShaderMgr::GAMMA, getGamma(), 0.0, 0.0, 1.0);
+
+    {
+        LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]);
+        vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta());
+        shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV);
+    }
+}
+
diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h
index 8efadf44b04..3f564d2605e 100644
--- a/indra/newview/llsettingssky.h
+++ b/indra/newview/llsettingssky.h
@@ -413,19 +413,14 @@ class LLSettingsSky: public LLSettingsBase
 protected:
     LLSettingsSky();
 
-
     virtual stringset_t getSlerpKeys() const;
 
     virtual validation_list_t getValidationList() const;
 
-
     virtual void        updateSettings();
 
     virtual parammapping_t getParameterMap() const;
 
-    virtual void        applySpecial(void *);
-
-
 private:
     static const std::string SETTING_LEGACY_EAST_ANGLE;
     static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL;
@@ -455,4 +450,14 @@ class LLSettingsSky: public LLSettingsBase
     static mapNameToUniformId_t sNameToUniformMapping;
 };
 
+class LLSettingsVOSky : public LLSettingsSky
+{
+public:
+    LLSettingsVOSky(const LLSD &data);
+protected:
+    LLSettingsVOSky();
+
+    virtual void        applySpecial(void *);
+};
+
 #endif
diff --git a/indra/newview/llsettingswater.cpp b/indra/newview/llsettingswater.cpp
index dda92659039..caf7a4b7cca 100644
--- a/indra/newview/llsettingswater.cpp
+++ b/indra/newview/llsettingswater.cpp
@@ -76,8 +76,6 @@ const std::string LLSettingsWater::SETTING_LEGACY_SCALE_BELOW("scaleBelow");
 const std::string LLSettingsWater::SETTING_LEGACY_WAVE1_DIR("wave1Dir");
 const std::string LLSettingsWater::SETTING_LEGACY_WAVE2_DIR("wave2Dir");
 
-const F32 LLSettingsWater::WATER_FOG_LIGHT_CLAMP(0.3f);
-
 const LLUUID LLSettingsWater::DEFAULT_WATER_NORMAL_ID(DEFAULT_WATER_NORMAL);
 
 
@@ -272,7 +270,23 @@ LLSettingsWater::parammapping_t LLSettingsWater::getParameterMap() const
     return param_map;
 }
 
-void LLSettingsWater::applySpecial(void *ptarget)
+//=========================================================================
+const F32 LLSettingsVOWater::WATER_FOG_LIGHT_CLAMP(0.3f);
+
+//=========================================================================
+LLSettingsVOWater::LLSettingsVOWater(const LLSD &data):
+    LLSettingsWater(data)
+{
+
+}
+
+LLSettingsVOWater::LLSettingsVOWater() :
+    LLSettingsWater()
+{
+
+}
+
+void LLSettingsVOWater::applySpecial(void *ptarget)
 {
     LLGLSLShader *shader = (LLGLSLShader *)ptarget;
 
@@ -286,11 +300,10 @@ void LLSettingsWater::applySpecial(void *ptarget)
 
 }
 
-//=========================================================================
-void LLSettingsWater::updateSettings()
+void LLSettingsVOWater::updateSettings()
 {
-//    LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES);
-//    LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty.  Reticulating Splines..." << LL_ENDL;
+    //    LL_RECORD_BLOCK_TIME(FTM_UPDATE_WATERVALUES);
+    //    LL_INFOS("WINDLIGHT", "WATER", "EEP") << "Water Parameters are dirty.  Reticulating Splines..." << LL_ENDL;
 
     // base class clears dirty flag so as to not trigger recursive update
     LLSettingsBase::updateSettings();
@@ -324,3 +337,4 @@ void LLSettingsWater::updateSettings()
     }
 
 }
+
diff --git a/indra/newview/llsettingswater.h b/indra/newview/llsettingswater.h
index a62fa355dee..aa60861bd4c 100644
--- a/indra/newview/llsettingswater.h
+++ b/indra/newview/llsettingswater.h
@@ -203,14 +203,12 @@ class LLSettingsWater : public LLSettingsBase
 protected:
     LLSettingsWater();
 
-    virtual void        updateSettings();
-
     virtual parammapping_t getParameterMap() const;
 
-    virtual void        applySpecial(void *);
-
     virtual validation_list_t getValidationList() const;
 
+    LLVector4           mWaterPlane;
+    F32                 mWaterFogKS;
 private:
     static const std::string SETTING_LEGACY_BLUR_MULTIPILER;
     static const std::string SETTING_LEGACY_FOG_COLOR;
@@ -224,11 +222,22 @@ class LLSettingsWater : public LLSettingsBase
     static const std::string SETTING_LEGACY_SCALE_BELOW;
     static const std::string SETTING_LEGACY_WAVE1_DIR;
     static const std::string SETTING_LEGACY_WAVE2_DIR;
+};
+
+class LLSettingsVOWater : public LLSettingsWater
+{
+public:
+    LLSettingsVOWater(const LLSD &data);
 
-    static const F32    WATER_FOG_LIGHT_CLAMP;
+protected:
+    LLSettingsVOWater();
+
+    virtual void updateSettings();
+    virtual void applySpecial(void *);
+
+private:
+    static const F32 WATER_FOG_LIGHT_CLAMP;
 
-    LLVector4           mWaterPlane;
-    F32                 mWaterFogKS;
 };
 
 #endif
-- 
GitLab