diff options
Diffstat (limited to 'OpenSim/Region/CoreModules')
10 files changed, 134 insertions, 107 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 483c25f..e1c0cd7 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -374,9 +374,11 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
374 | if (channel == DEBUG_CHANNEL) | 374 | if (channel == DEBUG_CHANNEL) |
375 | return; | 375 | return; |
376 | 376 | ||
377 | // Is id an avatar? | 377 | if(target == UUID.Zero) |
378 | ScenePresence sp = m_scene.GetScenePresence(target); | 378 | return; |
379 | 379 | ||
380 | // Is target an avatar? | ||
381 | ScenePresence sp = m_scene.GetScenePresence(target); | ||
380 | if (sp != null) | 382 | if (sp != null) |
381 | { | 383 | { |
382 | // Send message to avatar | 384 | // Send message to avatar |
@@ -401,19 +403,22 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
401 | foreach (SceneObjectGroup sog in attachments) | 403 | foreach (SceneObjectGroup sog in attachments) |
402 | { | 404 | { |
403 | if (!sog.IsDeleted) | 405 | if (!sog.IsDeleted) |
404 | targets.Add(sog.UUID); | 406 | { |
407 | SceneObjectPart[] parts = sog.Parts; | ||
408 | foreach(SceneObjectPart p in parts) | ||
409 | targets.Add(p.UUID); | ||
410 | } | ||
405 | } | 411 | } |
406 | 412 | ||
407 | // Need to check each attachment | ||
408 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 413 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
409 | { | 414 | { |
410 | if (li.GetHostID().Equals(id)) | 415 | UUID liHostID = li.GetHostID(); |
416 | if (liHostID.Equals(id)) | ||
411 | continue; | 417 | continue; |
412 | 418 | if (m_scene.GetSceneObjectPart(liHostID) == null) | |
413 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | ||
414 | continue; | 419 | continue; |
415 | 420 | ||
416 | if (targets.Contains(li.GetHostID())) | 421 | if (targets.Contains(liHostID)) |
417 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 422 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
418 | } | 423 | } |
419 | 424 | ||
@@ -426,16 +431,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
426 | 431 | ||
427 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 432 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
428 | { | 433 | { |
434 | UUID liHostID = li.GetHostID(); | ||
429 | // Dont process if this message is from yourself! | 435 | // Dont process if this message is from yourself! |
430 | if (li.GetHostID().Equals(id)) | 436 | if (liHostID.Equals(id)) |
431 | continue; | 437 | continue; |
432 | 438 | ||
433 | SceneObjectPart sPart = m_scene.GetSceneObjectPart( | 439 | if (m_scene.GetSceneObjectPart(liHostID) == null) |
434 | li.GetHostID()); | ||
435 | if (sPart == null) | ||
436 | continue; | 440 | continue; |
437 | 441 | ||
438 | if (li.GetHostID().Equals(target)) | 442 | if (liHostID.Equals(target)) |
439 | { | 443 | { |
440 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 444 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
441 | break; | 445 | break; |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 2d590fc..f523af1 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -227,8 +227,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
227 | if (boOption != m_boundingOrigin) | 227 | if (boOption != m_boundingOrigin) |
228 | { | 228 | { |
229 | m_boundingOrigin = boOption; | 229 | m_boundingOrigin = boOption; |
230 | m_boundingBox = true; | ||
231 | } | 230 | } |
231 | m_boundingBox = true; | ||
232 | } | 232 | } |
233 | 233 | ||
234 | if (options.ContainsKey("bounding-size")) | 234 | if (options.ContainsKey("bounding-size")) |
@@ -936,14 +936,24 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
936 | 936 | ||
937 | if (m_assetService.GetMetadata(uuid) != null) | 937 | if (m_assetService.GetMetadata(uuid) != null) |
938 | { | 938 | { |
939 | sbyte asype = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; | ||
940 | if(asype == -2) | ||
941 | { | ||
942 | |||
943 | } | ||
944 | |||
939 | // m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid); | 945 | // m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid); |
940 | return true; | 946 | return true; |
941 | } | 947 | } |
942 | 948 | ||
943 | if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) | 949 | if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension)) |
944 | { | 950 | { |
945 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; | 951 | sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension]; |
946 | 952 | ||
953 | if(assetType == -2) | ||
954 | { | ||
955 | |||
956 | } | ||
947 | if (assetType == (sbyte)AssetType.Unknown) | 957 | if (assetType == (sbyte)AssetType.Unknown) |
948 | { | 958 | { |
949 | m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); | 959 | m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid); |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 895b55d..1526b1c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -285,10 +285,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
285 | if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count >= m_repliesRequired) | 285 | if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count >= m_repliesRequired) |
286 | { | 286 | { |
287 | m_requestState = RequestState.Completed; | 287 | m_requestState = RequestState.Completed; |
288 | 288 | if(m_notFoundAssetUuids.Count == 0) | |
289 | m_log.DebugFormat( | 289 | m_log.DebugFormat( |
290 | "[ARCHIVER]: Successfully added {0} assets ({1} assets not found but these may be expected invalid references)", | 290 | "[ARCHIVER]: Successfully added {0} assets", |
291 | m_foundAssetUuids.Count); | ||
292 | else | ||
293 | m_log.DebugFormat( | ||
294 | "[ARCHIVER]: Successfully added {0} assets ({1} assets not found but these may be expected invalid references)", | ||
291 | m_foundAssetUuids.Count, m_notFoundAssetUuids.Count); | 295 | m_foundAssetUuids.Count, m_notFoundAssetUuids.Count); |
296 | |||
292 | 297 | ||
293 | // We want to stop using the asset cache thread asap | 298 | // We want to stop using the asset cache thread asap |
294 | // as we now need to do the work of producing the rest of the archive | 299 | // as we now need to do the work of producing the rest of the archive |
diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs index d217f36..617c348 100644 --- a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs +++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Threading; | ||
30 | using Mono.Addins; | 31 | using Mono.Addins; |
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
@@ -43,12 +44,16 @@ namespace OpenSim.Region.CoreModules.World | |||
43 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 44 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
44 | private uint m_frame = 0; | 45 | private uint m_frame = 0; |
45 | private int m_frameUpdateRate = 1000; | 46 | private int m_frameUpdateRate = 1000; |
46 | private Random m_rndnums = new Random(Environment.TickCount); | 47 | private Random m_rndnums; |
47 | private Scene m_scene = null; | 48 | private Scene m_scene = null; |
48 | private bool m_ready = false; | 49 | private bool m_ready = false; |
49 | private bool m_enabled = false; | 50 | private bool m_enabled = false; |
50 | private float m_cloudDensity = 1.0F; | 51 | private float m_cloudDensity = 1.0F; |
51 | private float[] cloudCover = new float[16 * 16]; | 52 | private float[] cloudCover = new float[16 * 16]; |
53 | private int m_dataVersion; | ||
54 | private bool m_busy; | ||
55 | private object cloudlock = new object(); | ||
56 | |||
52 | 57 | ||
53 | public void Initialise(IConfigSource config) | 58 | public void Initialise(IConfigSource config) |
54 | { | 59 | { |
@@ -70,11 +75,17 @@ namespace OpenSim.Region.CoreModules.World | |||
70 | 75 | ||
71 | m_scene = scene; | 76 | m_scene = scene; |
72 | 77 | ||
73 | scene.EventManager.OnNewClient += CloudsToClient; | ||
74 | scene.RegisterModuleInterface<ICloudModule>(this); | 78 | scene.RegisterModuleInterface<ICloudModule>(this); |
75 | scene.EventManager.OnFrame += CloudUpdate; | 79 | int seed = Environment.TickCount; |
80 | seed += (int)(scene.RegionInfo.RegionLocX << 16); | ||
81 | seed += (int)(scene.RegionInfo.RegionLocY); | ||
82 | m_rndnums = new Random(seed); | ||
76 | 83 | ||
77 | GenerateCloudCover(); | 84 | GenerateCloudCover(); |
85 | m_dataVersion = (int)m_scene.AllocateLocalId(); | ||
86 | |||
87 | scene.EventManager.OnNewClient += CloudsToClient; | ||
88 | scene.EventManager.OnFrame += CloudUpdate; | ||
78 | 89 | ||
79 | m_ready = true; | 90 | m_ready = true; |
80 | } | 91 | } |
@@ -89,7 +100,6 @@ namespace OpenSim.Region.CoreModules.World | |||
89 | m_scene.EventManager.OnNewClient -= CloudsToClient; | 100 | m_scene.EventManager.OnNewClient -= CloudsToClient; |
90 | m_scene.EventManager.OnFrame -= CloudUpdate; | 101 | m_scene.EventManager.OnFrame -= CloudUpdate; |
91 | m_scene.UnregisterModuleInterface<ICloudModule>(this); | 102 | m_scene.UnregisterModuleInterface<ICloudModule>(this); |
92 | |||
93 | m_scene = null; | 103 | m_scene = null; |
94 | } | 104 | } |
95 | 105 | ||
@@ -127,7 +137,8 @@ namespace OpenSim.Region.CoreModules.World | |||
127 | 137 | ||
128 | if (cloudCover != null) | 138 | if (cloudCover != null) |
129 | { | 139 | { |
130 | cover = cloudCover[y * 16 + x]; | 140 | lock(cloudlock) |
141 | cover = cloudCover[y * 16 + x]; | ||
131 | } | 142 | } |
132 | 143 | ||
133 | return cover; | 144 | return cover; |
@@ -188,22 +199,47 @@ namespace OpenSim.Region.CoreModules.World | |||
188 | } | 199 | } |
189 | } | 200 | } |
190 | Array.Copy(newCover, cloudCover, 16 * 16); | 201 | Array.Copy(newCover, cloudCover, 16 * 16); |
202 | m_dataVersion++; | ||
191 | } | 203 | } |
192 | 204 | ||
193 | private void CloudUpdate() | 205 | private void CloudUpdate() |
194 | { | 206 | { |
195 | if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready || (m_cloudDensity == 0)) | 207 | if ((!m_ready || m_busy || m_cloudDensity == 0 || |
196 | { | 208 | (m_frame++ % m_frameUpdateRate) != 0)) |
197 | return; | 209 | return; |
198 | } | 210 | |
199 | UpdateCloudCover(); | 211 | if(Monitor.TryEnter(cloudlock)) |
212 | { | ||
213 | m_busy = true; | ||
214 | Util.FireAndForget(delegate | ||
215 | { | ||
216 | try | ||
217 | { | ||
218 | lock(cloudlock) | ||
219 | { | ||
220 | UpdateCloudCover(); | ||
221 | m_scene.ForEachClient(delegate(IClientAPI client) | ||
222 | { | ||
223 | client.SendCloudData(m_dataVersion, cloudCover); | ||
224 | }); | ||
225 | } | ||
226 | } | ||
227 | finally | ||
228 | { | ||
229 | m_busy = false; | ||
230 | } | ||
231 | }, | ||
232 | null, "CloudModuleUpdate"); | ||
233 | Monitor.Exit(cloudlock); | ||
234 | } | ||
200 | } | 235 | } |
201 | 236 | ||
202 | public void CloudsToClient(IClientAPI client) | 237 | public void CloudsToClient(IClientAPI client) |
203 | { | 238 | { |
204 | if (m_ready) | 239 | if (m_ready) |
205 | { | 240 | { |
206 | client.SendCloudData(cloudCover); | 241 | lock(cloudlock) |
242 | client.SendCloudData(m_dataVersion, cloudCover); | ||
207 | } | 243 | } |
208 | } | 244 | } |
209 | 245 | ||
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 425562f..87fb0db 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -1360,7 +1360,8 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1360 | 1360 | ||
1361 | public void sendRegionInfoPacketToAll() | 1361 | public void sendRegionInfoPacketToAll() |
1362 | { | 1362 | { |
1363 | Scene.ForEachRootClient(delegate(IClientAPI client) | 1363 | // Scene.ForEachRootClient(delegate(IClientAPI client) |
1364 | Scene.ForEachClient(delegate(IClientAPI client) | ||
1364 | { | 1365 | { |
1365 | HandleRegionInfoRequest(client); | 1366 | HandleRegionInfoRequest(client); |
1366 | }); | 1367 | }); |
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs index ec5af2b..1dcaed3 100644 --- a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs | |||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
63 | sr.Close(); | 63 | sr.Close(); |
64 | body = body.Trim(); | 64 | body = body.Trim(); |
65 | 65 | ||
66 | m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body); | 66 | // m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body); |
67 | 67 | ||
68 | try | 68 | try |
69 | { | 69 | { |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 68c9c97..11a6d9f 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -212,7 +212,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
212 | client.OnParcelReclaim += ClientOnParcelReclaim; | 212 | client.OnParcelReclaim += ClientOnParcelReclaim; |
213 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; | 213 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; |
214 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; | 214 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; |
215 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; | ||
216 | client.OnParcelEjectUser += ClientOnParcelEjectUser; | 215 | client.OnParcelEjectUser += ClientOnParcelEjectUser; |
217 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; | 216 | client.OnParcelFreezeUser += ClientOnParcelFreezeUser; |
218 | client.OnSetStartLocationRequest += ClientOnSetHome; | 217 | client.OnSetStartLocationRequest += ClientOnSetHome; |
@@ -223,10 +222,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
223 | avatar.currentParcelUUID = UUID.Zero; | 222 | avatar.currentParcelUUID = UUID.Zero; |
224 | } | 223 | } |
225 | 224 | ||
226 | void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | ||
227 | { | ||
228 | } | ||
229 | |||
230 | public void Close() | 225 | public void Close() |
231 | { | 226 | { |
232 | } | 227 | } |
diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs index 6af4050..65691fe 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs | |||
@@ -103,7 +103,7 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins | |||
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | public void WindUpdate(uint frame) | 106 | public bool WindUpdate(uint frame) |
107 | { | 107 | { |
108 | double avgAng = m_avgDirection * (Math.PI/180.0f); | 108 | double avgAng = m_avgDirection * (Math.PI/180.0f); |
109 | double varDir = m_varDirection * (Math.PI/180.0f); | 109 | double varDir = m_varDirection * (Math.PI/180.0f); |
@@ -125,10 +125,8 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins | |||
125 | offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3); | 125 | offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3); |
126 | double windSpeed = m_avgStrength + (m_varStrength * offset); | 126 | double windSpeed = m_avgStrength + (m_varStrength * offset); |
127 | 127 | ||
128 | if (windSpeed<0) | 128 | if (windSpeed < 0) |
129 | windSpeed=0; | 129 | windSpeed = -windSpeed; |
130 | |||
131 | |||
132 | 130 | ||
133 | m_curPredominateWind.X = (float)Math.Cos(windDir); | 131 | m_curPredominateWind.X = (float)Math.Cos(windDir); |
134 | m_curPredominateWind.Y = (float)Math.Sin(windDir); | 132 | m_curPredominateWind.Y = (float)Math.Sin(windDir); |
@@ -144,6 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins | |||
144 | m_windSpeeds[y * 16 + x] = m_curPredominateWind; | 142 | m_windSpeeds[y * 16 + x] = m_curPredominateWind; |
145 | } | 143 | } |
146 | } | 144 | } |
145 | return true; | ||
147 | } | 146 | } |
148 | 147 | ||
149 | public Vector3 WindSpeed(float fX, float fY, float fZ) | 148 | public Vector3 WindSpeed(float fX, float fY, float fZ) |
diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs index fcb0c10..d2ff7b3 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | |||
@@ -82,22 +82,23 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins | |||
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | public void WindUpdate(uint frame) | 85 | public bool WindUpdate(uint frame) |
86 | { | 86 | { |
87 | //Make sure our object is valid (we haven't been disposed of yet) | 87 | //Make sure our object is valid (we haven't been disposed of yet) |
88 | if (m_windSpeeds != null) | 88 | if (m_windSpeeds == null) |
89 | return false; | ||
90 | |||
91 | for (int y = 0; y < 16; y++) | ||
89 | { | 92 | { |
90 | for (int y = 0; y < 16; y++) | 93 | for (int x = 0; x < 16; x++) |
91 | { | 94 | { |
92 | for (int x = 0; x < 16; x++) | 95 | m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 |
93 | { | 96 | m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 |
94 | m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 | 97 | m_windSpeeds[y * 16 + x].X *= m_strength; |
95 | m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 | 98 | m_windSpeeds[y * 16 + x].Y *= m_strength; |
96 | m_windSpeeds[y * 16 + x].X *= m_strength; | ||
97 | m_windSpeeds[y * 16 + x].Y *= m_strength; | ||
98 | } | ||
99 | } | 99 | } |
100 | } | 100 | } |
101 | return true; | ||
101 | } | 102 | } |
102 | 103 | ||
103 | public Vector3 WindSpeed(float fX, float fY, float fZ) | 104 | public Vector3 WindSpeed(float fX, float fY, float fZ) |
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 35014f5..95cf57d 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |||
@@ -46,11 +46,13 @@ namespace OpenSim.Region.CoreModules | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 47 | ||
48 | private uint m_frame = 0; | 48 | private uint m_frame = 0; |
49 | private uint m_frameLastUpdateClientArray = 0; | 49 | private int m_dataVersion = 0; |
50 | private int m_regionID = 0; | ||
50 | private int m_frameUpdateRate = 150; | 51 | private int m_frameUpdateRate = 150; |
51 | //private Random m_rndnums = new Random(Environment.TickCount); | 52 | //private Random m_rndnums = new Random(Environment.TickCount); |
52 | private Scene m_scene = null; | 53 | private Scene m_scene = null; |
53 | private bool m_ready = false; | 54 | private bool m_ready = false; |
55 | private bool m_inUpdate = false; | ||
54 | 56 | ||
55 | private bool m_enabled = false; | 57 | private bool m_enabled = false; |
56 | private IConfig m_windConfig; | 58 | private IConfig m_windConfig; |
@@ -96,7 +98,6 @@ namespace OpenSim.Region.CoreModules | |||
96 | 98 | ||
97 | m_scene = scene; | 99 | m_scene = scene; |
98 | m_frame = 0; | 100 | m_frame = 0; |
99 | |||
100 | // Register all the Wind Model Plug-ins | 101 | // Register all the Wind Model Plug-ins |
101 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) | 102 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) |
102 | { | 103 | { |
@@ -118,7 +119,6 @@ namespace OpenSim.Region.CoreModules | |||
118 | } | 119 | } |
119 | } | 120 | } |
120 | 121 | ||
121 | |||
122 | // if the plug-in wasn't found, default to no wind. | 122 | // if the plug-in wasn't found, default to no wind. |
123 | if (m_activeWindPlugin == null) | 123 | if (m_activeWindPlugin == null) |
124 | { | 124 | { |
@@ -154,14 +154,14 @@ namespace OpenSim.Region.CoreModules | |||
154 | 154 | ||
155 | // Register event handlers for when Avatars enter the region, and frame ticks | 155 | // Register event handlers for when Avatars enter the region, and frame ticks |
156 | m_scene.EventManager.OnFrame += WindUpdate; | 156 | m_scene.EventManager.OnFrame += WindUpdate; |
157 | m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion; | ||
158 | 157 | ||
159 | // Register the wind module | 158 | // Register the wind module |
160 | m_scene.RegisterModuleInterface<IWindModule>(this); | 159 | m_scene.RegisterModuleInterface<IWindModule>(this); |
161 | 160 | ||
162 | // Generate initial wind values | 161 | // Generate initial wind values |
163 | GenWindPos(); | 162 | GenWind(); |
164 | 163 | // hopefully this will not be the same for all regions on same instance | |
164 | m_dataVersion = (int)m_scene.AllocateLocalId(); | ||
165 | // Mark Module Ready for duty | 165 | // Mark Module Ready for duty |
166 | m_ready = true; | 166 | m_ready = true; |
167 | } | 167 | } |
@@ -184,7 +184,7 @@ namespace OpenSim.Region.CoreModules | |||
184 | 184 | ||
185 | // Remove our hooks | 185 | // Remove our hooks |
186 | m_scene.EventManager.OnFrame -= WindUpdate; | 186 | m_scene.EventManager.OnFrame -= WindUpdate; |
187 | m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; | 187 | // m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; |
188 | 188 | ||
189 | } | 189 | } |
190 | 190 | ||
@@ -416,67 +416,43 @@ namespace OpenSim.Region.CoreModules | |||
416 | /// </summary> | 416 | /// </summary> |
417 | public void WindUpdate() | 417 | public void WindUpdate() |
418 | { | 418 | { |
419 | if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready) | 419 | if ((!m_ready || m_inUpdate || (m_frame++ % m_frameUpdateRate) != 0)) |
420 | { | ||
421 | return; | 420 | return; |
422 | } | ||
423 | |||
424 | GenWindPos(); | ||
425 | |||
426 | SendWindAllClients(); | ||
427 | } | ||
428 | 421 | ||
429 | public void OnAgentEnteredRegion(ScenePresence avatar) | 422 | m_inUpdate = true; |
430 | { | 423 | Util.FireAndForget(delegate |
431 | if (m_ready) | ||
432 | { | 424 | { |
433 | if (m_activeWindPlugin != null) | 425 | try |
434 | { | 426 | { |
435 | // Ask wind plugin to generate a LL wind array to be cached locally | 427 | GenWind(); |
436 | // Try not to update this too often, as it may involve array copies | 428 | m_scene.ForEachClient(delegate(IClientAPI client) |
437 | if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate)) | ||
438 | { | 429 | { |
439 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | 430 | client.SendWindData(m_dataVersion, windSpeeds); |
440 | m_frameLastUpdateClientArray = m_frame; | 431 | }); |
441 | } | 432 | |
442 | } | 433 | } |
443 | 434 | finally | |
444 | avatar.ControllingClient.SendWindData(windSpeeds); | ||
445 | } | ||
446 | } | ||
447 | |||
448 | private void SendWindAllClients() | ||
449 | { | ||
450 | if (m_ready) | ||
451 | { | ||
452 | if (m_scene.GetRootAgentCount() > 0) | ||
453 | { | 435 | { |
454 | // Ask wind plugin to generate a LL wind array to be cached locally | 436 | m_inUpdate = false; |
455 | // Try not to update this too often, as it may involve array copies | ||
456 | if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate)) | ||
457 | { | ||
458 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | ||
459 | m_frameLastUpdateClientArray = m_frame; | ||
460 | } | ||
461 | |||
462 | m_scene.ForEachRootClient(delegate(IClientAPI client) | ||
463 | { | ||
464 | client.SendWindData(windSpeeds); | ||
465 | }); | ||
466 | } | 437 | } |
467 | } | 438 | }, |
439 | null, "WindModuleUpdate"); | ||
468 | } | 440 | } |
441 | |||
469 | /// <summary> | 442 | /// <summary> |
470 | /// Calculate the sun's orbital position and its velocity. | 443 | /// Calculate new wind |
444 | /// returns false if no change | ||
471 | /// </summary> | 445 | /// </summary> |
472 | 446 | ||
473 | private void GenWindPos() | 447 | private bool GenWind() |
474 | { | 448 | { |
475 | if (m_activeWindPlugin != null) | 449 | if (m_activeWindPlugin != null && m_activeWindPlugin.WindUpdate(m_frame)) |
476 | { | 450 | { |
477 | // Tell Wind Plugin to update it's wind data | 451 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); |
478 | m_activeWindPlugin.WindUpdate(m_frame); | 452 | m_dataVersion++; |
453 | return true; | ||
479 | } | 454 | } |
455 | return false; | ||
480 | } | 456 | } |
481 | } | 457 | } |
482 | } | 458 | } |