From d8a6c89a4460c39d8c83aff68a8cb1fb2e8b9692 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 12 May 2008 13:44:25 +0000 Subject: From: Alan M Webb This is a diagnostic patch in support of Mantis bug 1186. It affects only SubModule and will not affect normal usage. --- .../Environment/Modules/World/Sun/SunModule.cs | 75 +++++++++++++++------- 1 file changed, 53 insertions(+), 22 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs index 75cf786..c6cb392 100644 --- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs @@ -52,15 +52,21 @@ namespace OpenSim.Region.Environment.Modules private bool ready = false; // Configurable values + private string m_mode = "SL"; private int m_frame_mod = 0; private double m_day_length = 0; private int m_year_length = 0; private double m_day_night = 0; + private double m_longitude = 0; + private double m_latitude = 0; // Configurable defaults Defaults close to SL + private string d_mode = "SL"; private int d_frame_mod = 100; // Every 10 seconds (actually less) private double d_day_length = 4; // A VW day is 4 RW hours long private int d_year_length = 60; // There are 60 VW days in a VW year private double d_day_night = 0.45; // axis offset: ratio of light-to-dark, approx 1:3 + private double d_longitude = -73.53; + private double d_latitude = 41.29; // Frame counter private uint m_frame = 0; @@ -114,6 +120,12 @@ namespace OpenSim.Region.Environment.Modules // Just in case they don't have the stanzas try { + // Mode: determines how the sun is handled + m_mode = config.Configs["Sun"].GetString("mode", d_mode); + // Mode: determines how the sun is handled + m_latitude = config.Configs["Sun"].GetDouble("latitude", d_latitude); + // Mode: determines how the sun is handled + m_longitude = config.Configs["Sun"].GetDouble("longitude", d_longitude); // Day length in decimal hours m_year_length = config.Configs["Sun"].GetInt("year_length", d_year_length); // Day length in decimal hours @@ -126,43 +138,58 @@ namespace OpenSim.Region.Environment.Modules catch (Exception e) { m_log.Debug("[SUN] Configuration access failed, using defaults. Reason: "+e.Message); + m_mode = d_mode; m_year_length = d_year_length; m_day_length = d_day_length; m_day_night = d_day_night; m_frame_mod = d_frame_mod; + m_latitude = d_latitude; + m_longitude = d_longitude; } - // Time taken to complete a cycle (day and season) + switch(m_mode) + { + + case "T1" : + + default : - SecondsPerSunCycle = (uint) (m_day_length * 60 * 60); - SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length); + case "SL" : + // Time taken to complete a cycle (day and season) - // Ration of real-to-virtual time + SecondsPerSunCycle = (uint) (m_day_length * 60 * 60); + SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length); - VWTimeRatio = 24/m_day_length; + // Ration of real-to-virtual time - // Speed of rotation needed to complete a cycle in the - // designated period (day and season) + VWTimeRatio = 24/m_day_length; - SunSpeed = SunCycle/SecondsPerSunCycle; - SeasonSpeed = SeasonalCycle/SecondsPerYear; + // Speed of rotation needed to complete a cycle in the + // designated period (day and season) - // Horizon translation + SunSpeed = SunCycle/SecondsPerSunCycle; + SeasonSpeed = SeasonalCycle/SecondsPerYear; - HorizonShift = m_day_night; // Z axis translation - HoursToRadians = (SunCycle/24)*VWTimeRatio; + // Horizon translation - // Insert our event handling hooks + HorizonShift = m_day_night; // Z axis translation + HoursToRadians = (SunCycle/24)*VWTimeRatio; - scene.EventManager.OnFrame += SunUpdate; - scene.EventManager.OnNewClient += SunToClient; + // Insert our event handling hooks - ready = true; + scene.EventManager.OnFrame += SunUpdate; + scene.EventManager.OnNewClient += SunToClient; - m_log.Debug("[SUN] Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days"); - m_log.Debug("[SUN] Axis offset is "+m_day_night); - m_log.Debug("[SUN] Positional data updated every "+m_frame_mod+" frames"); + ready = true; + m_log.Debug("[SUN] Mode is "+m_mode); + m_log.Debug("[SUN] Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days"); + m_log.Debug("[SUN] Axis offset is "+m_day_night); + m_log.Debug("[SUN] Positional data updated every "+m_frame_mod+" frames"); + + break; + + } } public void PostInitialise() @@ -189,10 +216,14 @@ namespace OpenSim.Region.Environment.Modules public void SunToClient(IClientAPI client) { - if(ready) + if(m_mode != "T1") { - GenSunPos(); // Generate shared values once - client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); + if(ready) + { + GenSunPos(); // Generate shared values once + client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); + m_log.Debug("[SUN] Initial update for new client"); + } } } -- cgit v1.1