diff options
author | Mic Bowman | 2014-01-28 15:43:47 -0800 |
---|---|---|
committer | Mic Bowman | 2014-01-28 15:43:47 -0800 |
commit | bfb0011cd3dd3235ea2adf97979e018d3cafec95 (patch) | |
tree | c95a417547993232fa61b981b1a39a32e3a8e0aa | |
parent | Merge branch 'master' into varregion (diff) | |
download | opensim-SC_OLD-bfb0011cd3dd3235ea2adf97979e018d3cafec95.zip opensim-SC_OLD-bfb0011cd3dd3235ea2adf97979e018d3cafec95.tar.gz opensim-SC_OLD-bfb0011cd3dd3235ea2adf97979e018d3cafec95.tar.bz2 opensim-SC_OLD-bfb0011cd3dd3235ea2adf97979e018d3cafec95.tar.xz |
Some major surgery on the sun module. Updates to the client were gated
by a "mode" check. That mode check has been removed (it didn't result
in any change of behavior anyway). Also added a command line variable
update to set the sun position time offset (offset from the system
clock). Default is no offset to preserve existing behavior.
-rw-r--r-- | OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 97 |
1 files changed, 46 insertions, 51 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 6f344c8..c0b7312 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -68,9 +68,6 @@ namespace OpenSim.Region.CoreModules | |||
68 | // updating those region settings in GenSunPos() | 68 | // updating those region settings in GenSunPos() |
69 | private bool receivedEstateToolsSunUpdate = false; | 69 | private bool receivedEstateToolsSunUpdate = false; |
70 | 70 | ||
71 | // Configurable values | ||
72 | private string m_RegionMode = "SL"; | ||
73 | |||
74 | // Sun's position information is updated and sent to clients every m_UpdateInterval frames | 71 | // Sun's position information is updated and sent to clients every m_UpdateInterval frames |
75 | private int m_UpdateInterval = 0; | 72 | private int m_UpdateInterval = 0; |
76 | 73 | ||
@@ -90,7 +87,6 @@ namespace OpenSim.Region.CoreModules | |||
90 | // private double m_longitude = 0; | 87 | // private double m_longitude = 0; |
91 | // private double m_latitude = 0; | 88 | // private double m_latitude = 0; |
92 | // Configurable defaults Defaults close to SL | 89 | // Configurable defaults Defaults close to SL |
93 | private string d_mode = "SL"; | ||
94 | private int d_frame_mod = 100; // Every 10 seconds (actually less) | 90 | private int d_frame_mod = 100; // Every 10 seconds (actually less) |
95 | private double d_day_length = 4; // A VW day is 4 RW hours long | 91 | private double d_day_length = 4; // A VW day is 4 RW hours long |
96 | private int d_year_length = 60; // There are 60 VW days in a VW year | 92 | private int d_year_length = 60; // There are 60 VW days in a VW year |
@@ -134,12 +130,15 @@ namespace OpenSim.Region.CoreModules | |||
134 | 130 | ||
135 | private const int TICKS_PER_SECOND = 10000000; | 131 | private const int TICKS_PER_SECOND = 10000000; |
136 | 132 | ||
133 | private ulong m_CurrentTimeOffset = 0; | ||
134 | |||
137 | // Current time in elapsed seconds since Jan 1st 1970 | 135 | // Current time in elapsed seconds since Jan 1st 1970 |
138 | private ulong CurrentTime | 136 | private ulong CurrentTime |
139 | { | 137 | { |
140 | get | 138 | get |
141 | { | 139 | { |
142 | return (ulong)(((DateTime.Now.Ticks) - TicksToEpoch + TicksUTCOffset) / TICKS_PER_SECOND); | 140 | ulong ctime = (ulong)(((DateTime.Now.Ticks) - TicksToEpoch + TicksUTCOffset) / TICKS_PER_SECOND); |
141 | return ctime + m_CurrentTimeOffset; | ||
143 | } | 142 | } |
144 | } | 143 | } |
145 | 144 | ||
@@ -291,8 +290,6 @@ namespace OpenSim.Region.CoreModules | |||
291 | try | 290 | try |
292 | { | 291 | { |
293 | // Mode: determines how the sun is handled | 292 | // Mode: determines how the sun is handled |
294 | m_RegionMode = config.Configs["Sun"].GetString("mode", d_mode); | ||
295 | // Mode: determines how the sun is handled | ||
296 | // m_latitude = config.Configs["Sun"].GetDouble("latitude", d_latitude); | 293 | // m_latitude = config.Configs["Sun"].GetDouble("latitude", d_latitude); |
297 | // Mode: determines how the sun is handled | 294 | // Mode: determines how the sun is handled |
298 | // m_longitude = config.Configs["Sun"].GetDouble("longitude", d_longitude); | 295 | // m_longitude = config.Configs["Sun"].GetDouble("longitude", d_longitude); |
@@ -314,7 +311,6 @@ namespace OpenSim.Region.CoreModules | |||
314 | catch (Exception e) | 311 | catch (Exception e) |
315 | { | 312 | { |
316 | m_log.Debug("[SUN]: Configuration access failed, using defaults. Reason: " + e.Message); | 313 | m_log.Debug("[SUN]: Configuration access failed, using defaults. Reason: " + e.Message); |
317 | m_RegionMode = d_mode; | ||
318 | m_YearLengthDays = d_year_length; | 314 | m_YearLengthDays = d_year_length; |
319 | m_DayLengthHours = d_day_length; | 315 | m_DayLengthHours = d_day_length; |
320 | m_HorizonShift = d_day_night; | 316 | m_HorizonShift = d_day_night; |
@@ -325,40 +321,28 @@ namespace OpenSim.Region.CoreModules | |||
325 | // m_longitude = d_longitude; | 321 | // m_longitude = d_longitude; |
326 | } | 322 | } |
327 | 323 | ||
328 | switch (m_RegionMode) | 324 | SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60); |
329 | { | 325 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays); |
330 | case "T1": | ||
331 | default: | ||
332 | case "SL": | ||
333 | // Time taken to complete a cycle (day and season) | ||
334 | |||
335 | SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60); | ||
336 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays); | ||
337 | 326 | ||
338 | // Ration of real-to-virtual time | 327 | // Ration of real-to-virtual time |
339 | 328 | ||
340 | // VWTimeRatio = 24/m_day_length; | 329 | // VWTimeRatio = 24/m_day_length; |
341 | 330 | ||
342 | // Speed of rotation needed to complete a cycle in the | 331 | // Speed of rotation needed to complete a cycle in the |
343 | // designated period (day and season) | 332 | // designated period (day and season) |
344 | 333 | ||
345 | SunSpeed = m_SunCycle/SecondsPerSunCycle; | 334 | SunSpeed = m_SunCycle/SecondsPerSunCycle; |
346 | SeasonSpeed = m_SeasonalCycle/SecondsPerYear; | 335 | SeasonSpeed = m_SeasonalCycle/SecondsPerYear; |
347 | 336 | ||
348 | // Horizon translation | 337 | // Horizon translation |
349 | 338 | ||
350 | HorizonShift = m_HorizonShift; // Z axis translation | 339 | HorizonShift = m_HorizonShift; // Z axis translation |
351 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; | 340 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; |
352 | |||
353 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); | ||
354 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); | ||
355 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); | ||
356 | m_log.Debug("[SUN]: Percentage of time for daylight " + m_DayTimeSunHourScale); | ||
357 | m_log.Debug("[SUN]: Positional data updated every " + m_UpdateInterval + " frames"); | ||
358 | |||
359 | break; | ||
360 | } | ||
361 | 341 | ||
342 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); | ||
343 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); | ||
344 | m_log.Debug("[SUN]: Percentage of time for daylight " + m_DayTimeSunHourScale); | ||
345 | m_log.Debug("[SUN]: Positional data updated every " + m_UpdateInterval + " frames"); | ||
362 | } | 346 | } |
363 | 347 | ||
364 | public Type ReplaceableInterface | 348 | public Type ReplaceableInterface |
@@ -385,7 +369,8 @@ namespace OpenSim.Region.CoreModules | |||
385 | string sunCommand = string.Format("sun {0}", kvp.Key); | 369 | string sunCommand = string.Format("sun {0}", kvp.Key); |
386 | m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand); | 370 | m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand); |
387 | } | 371 | } |
388 | 372 | m_scene.AddCommand("Regions", this, "sun help", "sun help", "list parameters that can be changed", "", HandleSunConsoleCommand); | |
373 | m_scene.AddCommand("Regions", this, "sun list", "sun list", "list parameters that can be changed", "", HandleSunConsoleCommand); | ||
389 | ready = true; | 374 | ready = true; |
390 | } | 375 | } |
391 | 376 | ||
@@ -419,23 +404,22 @@ namespace OpenSim.Region.CoreModules | |||
419 | 404 | ||
420 | public void SunToClient(IClientAPI client) | 405 | public void SunToClient(IClientAPI client) |
421 | { | 406 | { |
422 | if (m_RegionMode != "T1") | 407 | if (ready) |
423 | { | 408 | { |
424 | if (ready) | 409 | if (m_SunFixed) |
425 | { | 410 | { |
426 | if (m_SunFixed) | 411 | // m_log.DebugFormat("[SUN]: Fixed SunHour {0}, Position {1}, PosTime {2}, OrbitalPosition : {3} ", |
427 | { | 412 | // m_SunFixedHour, Position.ToString(), PosTime.ToString(), OrbitalPosition.ToString()); |
428 | // m_log.DebugFormat("[SUN]: SunHour {0}, Position {1}, PosTime {2}, OrbitalPosition : {3} ", m_SunFixedHour, Position.ToString(), PosTime.ToString(), OrbitalPosition.ToString()); | 413 | client.SendSunPos(Position, Velocity, PosTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); |
429 | client.SendSunPos(Position, Velocity, PosTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); | 414 | } |
430 | } | 415 | else |
431 | else | 416 | { |
432 | { | 417 | // m_log.DebugFormat("[SUN]: SunHour {0}, Position {1}, PosTime {2}, OrbitalPosition : {3} ", |
433 | // m_log.DebugFormat("[SUN]: SunHour {0}, Position {1}, PosTime {2}, OrbitalPosition : {3} ", m_SunFixedHour, Position.ToString(), PosTime.ToString(), OrbitalPosition.ToString()); | 418 | // m_SunFixedHour, Position.ToString(), PosTime.ToString(), OrbitalPosition.ToString()); |
434 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); | 419 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); |
435 | } | ||
436 | } | 420 | } |
437 | } | 421 | } |
438 | } | 422 | } |
439 | 423 | ||
440 | public void SunUpdate() | 424 | public void SunUpdate() |
441 | { | 425 | { |
@@ -532,6 +516,9 @@ namespace OpenSim.Region.CoreModules | |||
532 | case "update_interval": | 516 | case "update_interval": |
533 | return m_UpdateInterval; | 517 | return m_UpdateInterval; |
534 | 518 | ||
519 | case "current_time": | ||
520 | return CurrentTime; | ||
521 | |||
535 | default: | 522 | default: |
536 | throw new Exception("Unknown sun parameter."); | 523 | throw new Exception("Unknown sun parameter."); |
537 | } | 524 | } |
@@ -572,7 +559,7 @@ namespace OpenSim.Region.CoreModules | |||
572 | 559 | ||
573 | foreach (string output in ParseCmdParams(cmdparams)) | 560 | foreach (string output in ParseCmdParams(cmdparams)) |
574 | { | 561 | { |
575 | m_log.Info("[SUN] " + output); | 562 | MainConsole.Instance.Output(output); |
576 | } | 563 | } |
577 | } | 564 | } |
578 | 565 | ||
@@ -581,10 +568,11 @@ namespace OpenSim.Region.CoreModules | |||
581 | Dictionary<string, string> Params = new Dictionary<string, string>(); | 568 | Dictionary<string, string> Params = new Dictionary<string, string>(); |
582 | 569 | ||
583 | Params.Add("year_length", "number of days to a year"); | 570 | Params.Add("year_length", "number of days to a year"); |
584 | Params.Add("day_length", "number of seconds to a day"); | 571 | Params.Add("day_length", "number of hours to a day"); |
585 | Params.Add("day_night_offset", "induces a horizon shift"); | 572 | Params.Add("day_night_offset", "induces a horizon shift"); |
586 | Params.Add("update_interval", "how often to update the sun's position in frames"); | 573 | Params.Add("update_interval", "how often to update the sun's position in frames"); |
587 | Params.Add("day_time_sun_hour_scale", "scales day light vs nite hours to change day/night ratio"); | 574 | Params.Add("day_time_sun_hour_scale", "scales day light vs nite hours to change day/night ratio"); |
575 | Params.Add("current_time", "time in seconds of the simulator"); | ||
588 | 576 | ||
589 | return Params; | 577 | return Params; |
590 | } | 578 | } |
@@ -646,6 +634,13 @@ namespace OpenSim.Region.CoreModules | |||
646 | m_UpdateInterval = (int)value; | 634 | m_UpdateInterval = (int)value; |
647 | break; | 635 | break; |
648 | 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 | |||
649 | default: | 644 | default: |
650 | Output.Add(String.Format("Unknown parameter {0}.", args[1])); | 645 | Output.Add(String.Format("Unknown parameter {0}.", args[1])); |
651 | return Output; | 646 | return Output; |