From 2877c7d94df7711df27517df24fc326635dbc561 Mon Sep 17 00:00:00 2001
From: Mic Bowman
Date: Tue, 28 Jan 2014 16:34:22 -0800
Subject: Actually make the parameter updates change the behavior of sun
 movement.

---
 OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index c0b7312..e04cb29 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -616,14 +616,18 @@ namespace OpenSim.Region.CoreModules
                 {
                     case "year_length":
                         m_YearLengthDays = (int)value;
+                        SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
                         break;
 
                     case "day_length":
                         m_DayLengthHours = value;
+                        SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60);
+                        SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
                         break;
 
                     case "day_night_offset":
                         m_HorizonShift = value;
+                        HorizonShift = m_HorizonShift;
                         break;
 
                     case "day_time_sun_hour_scale":
-- 
cgit v1.1


From 226b5e4d758288b6c57dfbd25e011927a31f46e6 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 28 Jan 2014 16:36:56 -0800
Subject: Increase the strength of brushes in brush test in an attempt to
 overcome rounding introduced with new terrain height class.

---
 OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index d557168..81e87d7 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
             TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
             ITerrainPaintableEffect effect = new RaiseSphere();
 
-            effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 2, 0.1);
+            effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 4, 0.1);
             Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128).");
             Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128).");
             Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128).");
@@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
             }
             effect = new LowerSphere();
 
-            effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 2, 6.0);
+            effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 4, 6.0);
             Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
             Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
             Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128).");
-- 
cgit v1.1


From dde0e547a792f556f300eb791cf77dc7cbfe6a63 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 28 Jan 2014 16:48:34 -0800
Subject: Change area of brush test to account for rounding errors in terrain
 implementation

---
 OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index 81e87d7..13ac11e 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
             effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 4, 0.1);
             Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128).");
             Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128).");
-            Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128).");
+            Assert.That(map[120, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (120,128).");
             Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128).");
             Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128).");
 
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
             Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
             Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
             Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128).");
-            Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (123,128).");
+            Assert.That(map[120, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (120,128).");
             Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128).");
             Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128).");
         }
-- 
cgit v1.1


From 678c1079155673f3e411e065ccc19b95dcf5a18e Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 28 Jan 2014 16:58:27 -0800
Subject: Temporarily disable brush test. It will come back when tuning is
 complete.

---
 OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index 13ac11e..ff4cdfe 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -51,6 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
                 }
             }
 
+            /*
             //
             // Test RaiseSphere
             //
@@ -84,6 +85,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
             Assert.That(map[120, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (120,128).");
             Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128).");
             Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128).");
+             */
         }
 
         [Test]
-- 
cgit v1.1


From 1900254e77b61f643f569621ace017052b27f792 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Tue, 28 Jan 2014 21:43:18 -0800
Subject: Restore brush tests with correct values and adjustments for new
 terrain height rounding characteristics.

---
 .../CoreModules/World/Terrain/Tests/TerrainTest.cs | 34 +++++++++++-----------
 1 file changed, 17 insertions(+), 17 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index ff4cdfe..96c16a9 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -40,10 +40,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
         [Test]
         public void BrushTest()
         {
+            int midRegion = (int)Constants.RegionSize / 2;
+
+            // Create a mask that covers only the left half of the region
             bool[,] allowMask = new bool[(int)Constants.RegionSize, 256];
             int x;
             int y;
-            for (x = 0; x < (int)((int)Constants.RegionSize * 0.5f); x++)
+            for (x = 0; x < midRegion; x++)
             {
                 for (y = 0; y < (int)Constants.RegionSize; y++)
                 {
@@ -51,20 +54,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
                 }
             }
 
-            /*
             //
             // Test RaiseSphere
             //
             TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
             ITerrainPaintableEffect effect = new RaiseSphere();
 
-            effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 4, 0.1);
-            Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128).");
-            Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128).");
-            Assert.That(map[120, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (120,128).");
-            Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128).");
-            Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128).");
-
+            effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
+            Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
+            Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
+            Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
+            Assert.That(map[128, midRegion] == 0.0, "Raise brush should not change value at this point (128,128).");
+            Assert.That(map[0, midRegion] == 0.0, "Raise brush should not change value at this point (0,128).");
             //
             // Test LowerSphere
             //
@@ -78,14 +79,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
             }
             effect = new LowerSphere();
 
-            effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 4, 6.0);
-            Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
-            Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
-            Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128).");
-            Assert.That(map[120, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (120,128).");
-            Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128).");
-            Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128).");
-             */
+            effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
+            Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
+            Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
+            Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
+            Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128).");
+            Assert.That(map[128, midRegion] == 1.0, "Lower brush should not change value at this point (128,128).");
+            Assert.That(map[0, midRegion] == 1.0, "Lower brush should not change value at this point (0,128).");
         }
 
         [Test]
-- 
cgit v1.1


From 3f5c6c897f9ed6a8a78e8beddf4f5713995d5f34 Mon Sep 17 00:00:00 2001
From: Mic Bowman
Date: Tue, 28 Jan 2014 22:40:39 -0800
Subject: One more run at fixing the sun module. Parameter setting fixed to
 work through the OSSL interface. And setting the parameters now adjusts all
 the dependent variables correctly so the sun moves at the modified rate.

---
 OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 104 +++++++++++-----------
 1 file changed, 52 insertions(+), 52 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index e04cb29..561552a 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -261,10 +261,8 @@ namespace OpenSim.Region.CoreModules
 
         private float GetCurrentTimeAsLindenSunHour()
         {
-            if (m_SunFixed)
-                return m_SunFixedHour + 6;
-
-            return GetCurrentSunHour() + 6.0f;
+            float curtime = m_SunFixed ? m_SunFixedHour : GetCurrentSunHour();
+            return (curtime + 6.0f) % 24.0f;
         }
 
         #region INonSharedRegion Methods
@@ -517,7 +515,7 @@ namespace OpenSim.Region.CoreModules
                     return m_UpdateInterval;
 
                 case "current_time":
-                    return CurrentTime;
+                    return GetCurrentTimeAsLindenSunHour();
                 
                 default:
                     throw new Exception("Unknown sun parameter.");
@@ -526,7 +524,51 @@ namespace OpenSim.Region.CoreModules
 
         public void SetSunParameter(string param, double value)
         {
-            HandleSunConsoleCommand("sun", new string[] {param, value.ToString() });
+            switch (param)
+            {
+                case "year_length":
+                    m_YearLengthDays = (int)value;
+                    SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
+                    SeasonSpeed = m_SeasonalCycle/SecondsPerYear;
+                    break;
+
+                case "day_length":
+                    m_DayLengthHours = value;
+                    SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60);
+                    SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
+                    SunSpeed = m_SunCycle/SecondsPerSunCycle;
+                    SeasonSpeed = m_SeasonalCycle/SecondsPerYear;
+                    break;
+
+                case "day_night_offset":
+                    m_HorizonShift = value;
+                    HorizonShift = m_HorizonShift;
+                    break;
+
+                case "day_time_sun_hour_scale":
+                    m_DayTimeSunHourScale = value;
+                    break;
+
+                case "update_interval":
+                    m_UpdateInterval = (int)value;
+                    break;
+
+                case "current_time":
+                    value = (value + 18.0) % 24.0;
+                    // set the current offset so that the effective sun time is the parameter
+                    m_CurrentTimeOffset = 0; // clear this first so we use raw time
+                    m_CurrentTimeOffset = (ulong)(SecondsPerSunCycle * value/ 24.0) - (CurrentTime % SecondsPerSunCycle);
+                    break;
+
+                default:
+                    throw new Exception("Unknown sun parameter.");
+
+                // Generate shared values
+                GenSunPos();
+
+                // When sun settings are updated, we should update all clients with new settings.
+                SunUpdateToAllClients();
+            }
         }
 
         public float GetCurrentSunHour()
@@ -606,57 +648,15 @@ namespace OpenSim.Region.CoreModules
             }
             else if (args.Length == 3)
             {
-                float value = 0.0f;
-                if (!float.TryParse(args[2], out value))
+                double value = 0.0;
+                if (! double.TryParse(args[2], out value))
                 {
                     Output.Add(String.Format("The parameter value {0} is not a valid number.", args[2]));
+                    return Output;
                 }
 
-                switch (args[1].ToLower())
-                {
-                    case "year_length":
-                        m_YearLengthDays = (int)value;
-                        SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
-                        break;
-
-                    case "day_length":
-                        m_DayLengthHours = value;
-                        SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60);
-                        SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
-                        break;
-
-                    case "day_night_offset":
-                        m_HorizonShift = value;
-                        HorizonShift = m_HorizonShift;
-                        break;
-
-                    case "day_time_sun_hour_scale":
-                        m_DayTimeSunHourScale = value;
-                        break;
-
-                    case "update_interval":
-                        m_UpdateInterval = (int)value;
-                        break;
-
-                    case "current_time":
-                        // best to get the current time offset out of the currenttime equation then
-                        // reset it
-                        m_CurrentTimeOffset = 0;
-                        m_CurrentTimeOffset = CurrentTime - (ulong)value;
-                        break;
-
-                    default:
-                        Output.Add(String.Format("Unknown parameter {0}.", args[1]));
-                        return Output;
-                }
-
+                SetSunParameter(args[1].ToLower(), value);
                 Output.Add(String.Format("Parameter {0} set to {1}.", args[1], value.ToString()));
-
-                // Generate shared values
-                GenSunPos();
-
-                // When sun settings are updated, we should update all clients with new settings.
-                SunUpdateToAllClients();
             }
 
             return Output;
-- 
cgit v1.1


From 0842e2e15b6af6f940648b0b74488f2da88ce920 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 29 Jan 2014 06:44:14 -0800
Subject: BulletSim: default physical terrain implementation to heightmap. It
 originally looked like mesh terrain would perform better for vehicles but,
 after much use, heightmap is the clear winner. Force terrain implementation
 to heightmap if the physics region is larger than legacy region size. This
 solves running out of memory for very large regions.

---
 OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 2 +-
 OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 834228e..d993e6a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -538,7 +538,7 @@ public static class BSParam
             (s,o) => { s.PE.SetContactProcessingThreshold(o.PhysBody, ContactProcessingThreshold); } ),
 
 	    new ParameterDefn<float>("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
-            (float)BSTerrainPhys.TerrainImplementation.Mesh ),
+            (float)BSTerrainPhys.TerrainImplementation.Heightmap ),
         new ParameterDefn<int>("TerrainMeshMagnification", "Number of times the 256x256 heightmap is multiplied to create the terrain mesh" ,
             2 ),
         new ParameterDefn<float>("TerrainFriction", "Factor to reduce movement against terrain surface" ,
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index fe014fc..2d2e55f 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -235,6 +235,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
         // Set default values for physics parameters plus any overrides from the ini file
         GetInitialParameterValues(config);
 
+        // Force some parameters to values depending on other configurations
+        // Only use heightmap terrain implementation if terrain larger than legacy size
+        if ((uint)regionExtent.X > Constants.RegionSize || (uint)regionExtent.Y > Constants.RegionSize)
+        {
+            m_log.WarnFormat("{0} Forcing terrain implementation to heightmap for large region", LogHeader);
+            BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap;
+        }
+
         // Get the connection to the physics engine (could be native or one of many DLLs)
         PE = SelectUnderlyingBulletEngine(BulletEngineName);
 
-- 
cgit v1.1