aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-01-30 00:06:09 +0000
committerJustin Clark-Casey (justincc)2014-01-30 00:06:09 +0000
commitb50e5704b8b5b49e9a845543dcc64182aabcb9e3 (patch)
tree7c03d7d85bdeef75a093c8a3d42a9050f07dbfb1 /OpenSim/Region
parentMerge branch 'justincc-master' (diff)
parentBulletSim: default physical terrain implementation to heightmap. (diff)
downloadopensim-SC_OLD-b50e5704b8b5b49e9a845543dcc64182aabcb9e3.zip
opensim-SC_OLD-b50e5704b8b5b49e9a845543dcc64182aabcb9e3.tar.gz
opensim-SC_OLD-b50e5704b8b5b49e9a845543dcc64182aabcb9e3.tar.bz2
opensim-SC_OLD-b50e5704b8b5b49e9a845543dcc64182aabcb9e3.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs100
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs32
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs8
4 files changed, 78 insertions, 64 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index c0b7312..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
261 261
262 private float GetCurrentTimeAsLindenSunHour() 262 private float GetCurrentTimeAsLindenSunHour()
263 { 263 {
264 if (m_SunFixed) 264 float curtime = m_SunFixed ? m_SunFixedHour : GetCurrentSunHour();
265 return m_SunFixedHour + 6; 265 return (curtime + 6.0f) % 24.0f;
266
267 return GetCurrentSunHour() + 6.0f;
268 } 266 }
269 267
270 #region INonSharedRegion Methods 268 #region INonSharedRegion Methods
@@ -517,7 +515,7 @@ namespace OpenSim.Region.CoreModules
517 return m_UpdateInterval; 515 return m_UpdateInterval;
518 516
519 case "current_time": 517 case "current_time":
520 return CurrentTime; 518 return GetCurrentTimeAsLindenSunHour();
521 519
522 default: 520 default:
523 throw new Exception("Unknown sun parameter."); 521 throw new Exception("Unknown sun parameter.");
@@ -526,7 +524,51 @@ namespace OpenSim.Region.CoreModules
526 524
527 public void SetSunParameter(string param, double value) 525 public void SetSunParameter(string param, double value)
528 { 526 {
529 HandleSunConsoleCommand("sun", new string[] {param, value.ToString() }); 527 switch (param)
528 {
529 case "year_length":
530 m_YearLengthDays = (int)value;
531 SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
532 SeasonSpeed = m_SeasonalCycle/SecondsPerYear;
533 break;
534
535 case "day_length":
536 m_DayLengthHours = value;
537 SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60);
538 SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
539 SunSpeed = m_SunCycle/SecondsPerSunCycle;
540 SeasonSpeed = m_SeasonalCycle/SecondsPerYear;
541 break;
542
543 case "day_night_offset":
544 m_HorizonShift = value;
545 HorizonShift = m_HorizonShift;
546 break;
547
548 case "day_time_sun_hour_scale":
549 m_DayTimeSunHourScale = value;
550 break;
551
552 case "update_interval":
553 m_UpdateInterval = (int)value;
554 break;
555
556 case "current_time":
557 value = (value + 18.0) % 24.0;
558 // set the current offset so that the effective sun time is the parameter
559 m_CurrentTimeOffset = 0; // clear this first so we use raw time
560 m_CurrentTimeOffset = (ulong)(SecondsPerSunCycle * value/ 24.0) - (CurrentTime % SecondsPerSunCycle);
561 break;
562
563 default:
564 throw new Exception("Unknown sun parameter.");
565
566 // Generate shared values
567 GenSunPos();
568
569 // When sun settings are updated, we should update all clients with new settings.
570 SunUpdateToAllClients();
571 }
530 } 572 }
531 573
532 public float GetCurrentSunHour() 574 public float GetCurrentSunHour()
@@ -606,53 +648,15 @@ namespace OpenSim.Region.CoreModules
606 } 648 }
607 else if (args.Length == 3) 649 else if (args.Length == 3)
608 { 650 {
609 float value = 0.0f; 651 double value = 0.0;
610 if (!float.TryParse(args[2], out value)) 652 if (! double.TryParse(args[2], out value))
611 { 653 {
612 Output.Add(String.Format("The parameter value {0} is not a valid number.", args[2])); 654 Output.Add(String.Format("The parameter value {0} is not a valid number.", args[2]));
655 return Output;
613 } 656 }
614 657
615 switch (args[1].ToLower()) 658 SetSunParameter(args[1].ToLower(), value);
616 {
617 case "year_length":
618 m_YearLengthDays = (int)value;
619 break;
620
621 case "day_length":
622 m_DayLengthHours = value;
623 break;
624
625 case "day_night_offset":
626 m_HorizonShift = value;
627 break;
628
629 case "day_time_sun_hour_scale":
630 m_DayTimeSunHourScale = value;
631 break;
632
633 case "update_interval":
634 m_UpdateInterval = (int)value;
635 break;
636
637 case "current_time":
638 // best to get the current time offset out of the currenttime equation then
639 // reset it
640 m_CurrentTimeOffset = 0;
641 m_CurrentTimeOffset = CurrentTime - (ulong)value;
642 break;
643
644 default:
645 Output.Add(String.Format("Unknown parameter {0}.", args[1]));
646 return Output;
647 }
648
649 Output.Add(String.Format("Parameter {0} set to {1}.", args[1], value.ToString())); 659 Output.Add(String.Format("Parameter {0} set to {1}.", args[1], value.ToString()));
650
651 // Generate shared values
652 GenSunPos();
653
654 // When sun settings are updated, we should update all clients with new settings.
655 SunUpdateToAllClients();
656 } 660 }
657 661
658 return Output; 662 return Output;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index d557168..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
40 [Test] 40 [Test]
41 public void BrushTest() 41 public void BrushTest()
42 { 42 {
43 int midRegion = (int)Constants.RegionSize / 2;
44
45 // Create a mask that covers only the left half of the region
43 bool[,] allowMask = new bool[(int)Constants.RegionSize, 256]; 46 bool[,] allowMask = new bool[(int)Constants.RegionSize, 256];
44 int x; 47 int x;
45 int y; 48 int y;
46 for (x = 0; x < (int)((int)Constants.RegionSize * 0.5f); x++) 49 for (x = 0; x < midRegion; x++)
47 { 50 {
48 for (y = 0; y < (int)Constants.RegionSize; y++) 51 for (y = 0; y < (int)Constants.RegionSize; y++)
49 { 52 {
@@ -57,13 +60,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
57 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); 60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
58 ITerrainPaintableEffect effect = new RaiseSphere(); 61 ITerrainPaintableEffect effect = new RaiseSphere();
59 62
60 effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 2, 0.1); 63 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
61 Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128)."); 64 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
62 Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128)."); 65 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
63 Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128)."); 66 Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
64 Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128)."); 67 Assert.That(map[128, midRegion] == 0.0, "Raise brush should not change value at this point (128,128).");
65 Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128)."); 68 Assert.That(map[0, midRegion] == 0.0, "Raise brush should not change value at this point (0,128).");
66
67 // 69 //
68 // Test LowerSphere 70 // Test LowerSphere
69 // 71 //
@@ -77,13 +79,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
77 } 79 }
78 effect = new LowerSphere(); 80 effect = new LowerSphere();
79 81
80 effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 2, 6.0); 82 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
81 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)."); 83 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
82 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)."); 84 Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
83 Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128)."); 85 Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
84 Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (123,128)."); 86 Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128).");
85 Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128)."); 87 Assert.That(map[128, midRegion] == 1.0, "Lower brush should not change value at this point (128,128).");
86 Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128)."); 88 Assert.That(map[0, midRegion] == 1.0, "Lower brush should not change value at this point (0,128).");
87 } 89 }
88 90
89 [Test] 91 [Test]
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
538 (s,o) => { s.PE.SetContactProcessingThreshold(o.PhysBody, ContactProcessingThreshold); } ), 538 (s,o) => { s.PE.SetContactProcessingThreshold(o.PhysBody, ContactProcessingThreshold); } ),
539 539
540 new ParameterDefn<float>("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)", 540 new ParameterDefn<float>("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
541 (float)BSTerrainPhys.TerrainImplementation.Mesh ), 541 (float)BSTerrainPhys.TerrainImplementation.Heightmap ),
542 new ParameterDefn<int>("TerrainMeshMagnification", "Number of times the 256x256 heightmap is multiplied to create the terrain mesh" , 542 new ParameterDefn<int>("TerrainMeshMagnification", "Number of times the 256x256 heightmap is multiplied to create the terrain mesh" ,
543 2 ), 543 2 ),
544 new ParameterDefn<float>("TerrainFriction", "Factor to reduce movement against terrain surface" , 544 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
235 // Set default values for physics parameters plus any overrides from the ini file 235 // Set default values for physics parameters plus any overrides from the ini file
236 GetInitialParameterValues(config); 236 GetInitialParameterValues(config);
237 237
238 // Force some parameters to values depending on other configurations
239 // Only use heightmap terrain implementation if terrain larger than legacy size
240 if ((uint)regionExtent.X > Constants.RegionSize || (uint)regionExtent.Y > Constants.RegionSize)
241 {
242 m_log.WarnFormat("{0} Forcing terrain implementation to heightmap for large region", LogHeader);
243 BSParam.TerrainImplementation = (float)BSTerrainPhys.TerrainImplementation.Heightmap;
244 }
245
238 // Get the connection to the physics engine (could be native or one of many DLLs) 246 // Get the connection to the physics engine (could be native or one of many DLLs)
239 PE = SelectUnderlyingBulletEngine(BulletEngineName); 247 PE = SelectUnderlyingBulletEngine(BulletEngineName);
240 248