diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs index 0314562..beb74ce 100644 --- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Region.Environment.Modules | |||
65 | private double d_day_length = 4; // A VW day is 4 RW hours long | 65 | private double d_day_length = 4; // A VW day is 4 RW hours long |
66 | private int d_year_length = 60; // There are 60 VW days in a VW year | 66 | private int d_year_length = 60; // There are 60 VW days in a VW year |
67 | private double d_day_night = 0.45; // axis offset: ratio of light-to-dark, approx 1:3 | 67 | private double d_day_night = 0.45; // axis offset: ratio of light-to-dark, approx 1:3 |
68 | private double d_longitude = -73.53; | 68 | private double d_longitude = -73.53; |
69 | private double d_latitude = 41.29; | 69 | private double d_latitude = 41.29; |
70 | 70 | ||
71 | // Frame counter | 71 | // Frame counter |
@@ -155,48 +155,44 @@ namespace OpenSim.Region.Environment.Modules | |||
155 | m_longitude = d_longitude; | 155 | m_longitude = d_longitude; |
156 | } | 156 | } |
157 | 157 | ||
158 | switch(m_mode) | 158 | switch (m_mode) |
159 | { | 159 | { |
160 | case "T1": | ||
161 | default: | ||
162 | case "SL": | ||
163 | // Time taken to complete a cycle (day and season) | ||
160 | 164 | ||
161 | case "T1" : | 165 | SecondsPerSunCycle = (uint) (m_day_length * 60 * 60); |
166 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length); | ||
162 | 167 | ||
163 | default : | 168 | // Ration of real-to-virtual time |
164 | 169 | ||
165 | case "SL" : | 170 | VWTimeRatio = 24/m_day_length; |
166 | // Time taken to complete a cycle (day and season) | ||
167 | 171 | ||
168 | SecondsPerSunCycle = (uint) (m_day_length * 60 * 60); | 172 | // Speed of rotation needed to complete a cycle in the |
169 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length); | 173 | // designated period (day and season) |
170 | 174 | ||
171 | // Ration of real-to-virtual time | 175 | SunSpeed = SunCycle/SecondsPerSunCycle; |
176 | SeasonSpeed = SeasonalCycle/SecondsPerYear; | ||
172 | 177 | ||
173 | VWTimeRatio = 24/m_day_length; | 178 | // Horizon translation |
174 | 179 | ||
175 | // Speed of rotation needed to complete a cycle in the | 180 | HorizonShift = m_day_night; // Z axis translation |
176 | // designated period (day and season) | 181 | HoursToRadians = (SunCycle/24)*VWTimeRatio; |
177 | 182 | ||
178 | SunSpeed = SunCycle/SecondsPerSunCycle; | 183 | // Insert our event handling hooks |
179 | SeasonSpeed = SeasonalCycle/SecondsPerYear; | ||
180 | 184 | ||
181 | // Horizon translation | 185 | scene.EventManager.OnFrame += SunUpdate; |
186 | scene.EventManager.OnNewClient += SunToClient; | ||
182 | 187 | ||
183 | HorizonShift = m_day_night; // Z axis translation | 188 | ready = true; |
184 | HoursToRadians = (SunCycle/24)*VWTimeRatio; | ||
185 | 189 | ||
186 | // Insert our event handling hooks | 190 | m_log.Debug("[SUN] Mode is "+m_mode); |
187 | 191 | m_log.Debug("[SUN] Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days"); | |
188 | scene.EventManager.OnFrame += SunUpdate; | 192 | m_log.Debug("[SUN] Axis offset is "+m_day_night); |
189 | scene.EventManager.OnNewClient += SunToClient; | 193 | m_log.Debug("[SUN] Positional data updated every "+m_frame_mod+" frames"); |
190 | |||
191 | ready = true; | ||
192 | |||
193 | m_log.Debug("[SUN] Mode is "+m_mode); | ||
194 | m_log.Debug("[SUN] Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days"); | ||
195 | m_log.Debug("[SUN] Axis offset is "+m_day_night); | ||
196 | m_log.Debug("[SUN] Positional data updated every "+m_frame_mod+" frames"); | ||
197 | 194 | ||
198 | break; | 195 | break; |
199 | |||
200 | } | 196 | } |
201 | } | 197 | } |
202 | 198 | ||
@@ -224,21 +220,20 @@ namespace OpenSim.Region.Environment.Modules | |||
224 | 220 | ||
225 | public void SunToClient(IClientAPI client) | 221 | public void SunToClient(IClientAPI client) |
226 | { | 222 | { |
227 | if(m_mode != "T1") | 223 | if (m_mode != "T1") |
228 | { | 224 | { |
229 | if(ready) | 225 | if (ready) |
230 | { | 226 | { |
231 | GenSunPos(); // Generate shared values once | 227 | GenSunPos(); // Generate shared values once |
232 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); | 228 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); |
233 | m_log.Debug("[SUN] Initial update for new client"); | 229 | m_log.Debug("[SUN] Initial update for new client"); |
234 | } | 230 | } |
235 | } | 231 | } |
236 | } | 232 | } |
237 | 233 | ||
238 | public void SunUpdate() | 234 | public void SunUpdate() |
239 | { | 235 | { |
240 | 236 | if (((m_frame++%m_frame_mod) != 0) || !ready) | |
241 | if(((m_frame++%m_frame_mod) != 0) || !ready) | ||
242 | { | 237 | { |
243 | return; | 238 | return; |
244 | } | 239 | } |
@@ -253,7 +248,6 @@ namespace OpenSim.Region.Environment.Modules | |||
253 | 248 | ||
254 | // set estate settings for region access to sun position | 249 | // set estate settings for region access to sun position |
255 | m_scene.RegionInfo.EstateSettings.sunPosition = Position; | 250 | m_scene.RegionInfo.EstateSettings.sunPosition = Position; |
256 | |||
257 | } | 251 | } |
258 | 252 | ||
259 | /// <summary> | 253 | /// <summary> |