From: Alan M Webb <awebb@vnet.ibm.com>

This is a diagnostic patch in support of Mantis bug 1186.
It affects only SubModule and will not affect normal usage.
0.6.0-stable
Justin Clarke Casey 2008-05-12 13:44:25 +00:00
parent b4d128c811
commit d8a6c89a44
1 changed files with 53 additions and 22 deletions

View File

@ -52,15 +52,21 @@ namespace OpenSim.Region.Environment.Modules
private bool ready = false; private bool ready = false;
// Configurable values // Configurable values
private string m_mode = "SL";
private int m_frame_mod = 0; private int m_frame_mod = 0;
private double m_day_length = 0; private double m_day_length = 0;
private int m_year_length = 0; private int m_year_length = 0;
private double m_day_night = 0; private double m_day_night = 0;
private double m_longitude = 0;
private double m_latitude = 0;
// Configurable defaults Defaults close to SL // Configurable defaults Defaults close to SL
private string d_mode = "SL";
private int d_frame_mod = 100; // Every 10 seconds (actually less) 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 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 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_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 // Frame counter
private uint m_frame = 0; private uint m_frame = 0;
@ -114,6 +120,12 @@ namespace OpenSim.Region.Environment.Modules
// Just in case they don't have the stanzas // Just in case they don't have the stanzas
try 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 // Day length in decimal hours
m_year_length = config.Configs["Sun"].GetInt("year_length", d_year_length); m_year_length = config.Configs["Sun"].GetInt("year_length", d_year_length);
// Day length in decimal hours // Day length in decimal hours
@ -126,43 +138,58 @@ namespace OpenSim.Region.Environment.Modules
catch (Exception e) catch (Exception e)
{ {
m_log.Debug("[SUN] Configuration access failed, using defaults. Reason: "+e.Message); m_log.Debug("[SUN] Configuration access failed, using defaults. Reason: "+e.Message);
m_mode = d_mode;
m_year_length = d_year_length; m_year_length = d_year_length;
m_day_length = d_day_length; m_day_length = d_day_length;
m_day_night = d_day_night; m_day_night = d_day_night;
m_frame_mod = d_frame_mod; 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)
{
SecondsPerSunCycle = (uint) (m_day_length * 60 * 60); case "T1" :
SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length);
// Ration of real-to-virtual time default :
VWTimeRatio = 24/m_day_length; case "SL" :
// Time taken to complete a cycle (day and season)
// Speed of rotation needed to complete a cycle in the SecondsPerSunCycle = (uint) (m_day_length * 60 * 60);
// designated period (day and season) SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length);
SunSpeed = SunCycle/SecondsPerSunCycle; // Ration of real-to-virtual time
SeasonSpeed = SeasonalCycle/SecondsPerYear;
// Horizon translation VWTimeRatio = 24/m_day_length;
HorizonShift = m_day_night; // Z axis translation // Speed of rotation needed to complete a cycle in the
HoursToRadians = (SunCycle/24)*VWTimeRatio; // designated period (day and season)
// Insert our event handling hooks SunSpeed = SunCycle/SecondsPerSunCycle;
SeasonSpeed = SeasonalCycle/SecondsPerYear;
scene.EventManager.OnFrame += SunUpdate; // Horizon translation
scene.EventManager.OnNewClient += SunToClient;
ready = true; HorizonShift = m_day_night; // Z axis translation
HoursToRadians = (SunCycle/24)*VWTimeRatio;
m_log.Debug("[SUN] Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days"); // Insert our event handling hooks
m_log.Debug("[SUN] Axis offset is "+m_day_night);
m_log.Debug("[SUN] Positional data updated every "+m_frame_mod+" frames");
scene.EventManager.OnFrame += SunUpdate;
scene.EventManager.OnNewClient += SunToClient;
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() public void PostInitialise()
@ -189,10 +216,14 @@ namespace OpenSim.Region.Environment.Modules
public void SunToClient(IClientAPI client) public void SunToClient(IClientAPI client)
{ {
if(ready) if(m_mode != "T1")
{ {
GenSunPos(); // Generate shared values once if(ready)
client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); {
GenSunPos(); // Generate shared values once
client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition);
m_log.Debug("[SUN] Initial update for new client");
}
} }
} }