aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs52
-rw-r--r--OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs57
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/WindModule.cs2
3 files changed, 84 insertions, 27 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 5f8d8f1..90f0336 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -1390,11 +1390,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1390 /// Send the cloud matrix to the client 1390 /// Send the cloud matrix to the client
1391 /// </summary> 1391 /// </summary>
1392 /// <param name="windSpeeds">16x16 array of cloud densities</param> 1392 /// <param name="windSpeeds">16x16 array of cloud densities</param>
1393/*
1393 public virtual void SendCloudData(int version, float[] cloudDensity) 1394 public virtual void SendCloudData(int version, float[] cloudDensity)
1394 { 1395 {
1395 Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData"); 1396 Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData");
1396 } 1397 }
1397 1398*/
1398 // wind caching 1399 // wind caching
1399 private static int lastWindVersion = 0; 1400 private static int lastWindVersion = 0;
1400 private static List<LayerDataPacket> lastWindPackets = new List<LayerDataPacket>(); 1401 private static List<LayerDataPacket> lastWindPackets = new List<LayerDataPacket>();
@@ -1445,30 +1446,53 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1445 OutPacket(pkt, ThrottleOutPacketType.Wind); 1446 OutPacket(pkt, ThrottleOutPacketType.Wind);
1446 } 1447 }
1447 1448
1449 // cloud caching
1450 private static int lastCloudVersion = 0;
1451 private static List<LayerDataPacket> lastCloudPackets = new List<LayerDataPacket>();
1452
1448 /// <summary> 1453 /// <summary>
1449 /// Send cloud layer information to the client. 1454 /// Send cloud layer information to the client.
1450 /// </summary> 1455 /// </summary>
1451 /// <param name="o"></param> 1456 /// <param name="o"></param>
1452 private void DoSendCloudData(object o) 1457// private void DoSendCloudData(object o)
1458 public virtual void SendCloudData(int version, float[] cloudDensity)
1453 { 1459 {
1454 float[] cloudCover = (float[])o; 1460// float[] cloudDensity = (float[])o;
1455 TerrainPatch[] patches = new TerrainPatch[1]; 1461 bool isNewData;
1456 patches[0] = new TerrainPatch(); 1462 lock(lastCloudPackets)
1457 patches[0].Data = new float[16 * 16]; 1463 isNewData = lastCloudVersion != version;
1458 1464
1459 for (int y = 0; y < 16; y++) 1465 if(isNewData)
1460 { 1466 {
1461 for (int x = 0; x < 16; x++) 1467 TerrainPatch[] patches = new TerrainPatch[1];
1468 patches[0] = new TerrainPatch();
1469 patches[0].Data = new float[16 * 16];
1470
1471 for (int y = 0; y < 16; y++)
1472 {
1473 for (int x = 0; x < 16; x++)
1474 {
1475 patches[0].Data[y * 16 + x] = cloudDensity[y * 16 + x];
1476 }
1477 }
1478 // neither we or viewers have extended clouds
1479 byte layerType = (byte)TerrainPatch.LayerType.Cloud;
1480
1481 LayerDataPacket layerpack =
1482 OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(
1483 patches, layerType);
1484 layerpack.Header.Zerocoded = true;
1485 lock(lastCloudPackets)
1462 { 1486 {
1463 patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x]; 1487 lastCloudPackets.Clear();
1488 lastCloudPackets.Add(layerpack);
1489 lastCloudVersion = version;
1464 } 1490 }
1465 } 1491 }
1466 // neither we or viewers have extended clouds
1467 byte layerType = (byte)TerrainPatch.LayerType.Cloud;
1468 1492
1469 LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(patches, layerType); 1493 lock(lastCloudPackets)
1470 layerpack.Header.Zerocoded = true; 1494 foreach(LayerDataPacket pkt in lastCloudPackets)
1471 OutPacket(layerpack, ThrottleOutPacketType.Cloud); 1495 OutPacket(pkt, ThrottleOutPacketType.Cloud);
1472 } 1496 }
1473 1497
1474 /// <summary> 1498 /// <summary>
diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
index f304307..3c2884b 100644
--- a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
+++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading;
30using Mono.Addins; 31using Mono.Addins;
31using Nini.Config; 32using Nini.Config;
32using OpenMetaverse; 33using OpenMetaverse;
@@ -49,6 +50,10 @@ namespace OpenSim.Region.CoreModules.World
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,13 @@ 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;
76 79
77 GenerateCloudCover(); 80 GenerateCloudCover();
81 m_dataVersion = (int)m_scene.AllocateLocalId();
82
83 scene.EventManager.OnNewClient += CloudsToClient;
84 scene.EventManager.OnFrame += CloudUpdate;
78 85
79 m_ready = true; 86 m_ready = true;
80 } 87 }
@@ -89,7 +96,6 @@ namespace OpenSim.Region.CoreModules.World
89 m_scene.EventManager.OnNewClient -= CloudsToClient; 96 m_scene.EventManager.OnNewClient -= CloudsToClient;
90 m_scene.EventManager.OnFrame -= CloudUpdate; 97 m_scene.EventManager.OnFrame -= CloudUpdate;
91 m_scene.UnregisterModuleInterface<ICloudModule>(this); 98 m_scene.UnregisterModuleInterface<ICloudModule>(this);
92
93 m_scene = null; 99 m_scene = null;
94 } 100 }
95 101
@@ -127,7 +133,8 @@ namespace OpenSim.Region.CoreModules.World
127 133
128 if (cloudCover != null) 134 if (cloudCover != null)
129 { 135 {
130 cover = cloudCover[y * 16 + x]; 136 lock(cloudlock)
137 cover = cloudCover[y * 16 + x];
131 } 138 }
132 139
133 return cover; 140 return cover;
@@ -188,22 +195,48 @@ namespace OpenSim.Region.CoreModules.World
188 } 195 }
189 } 196 }
190 Array.Copy(newCover, cloudCover, 16 * 16); 197 Array.Copy(newCover, cloudCover, 16 * 16);
198 m_dataVersion++;
191 } 199 }
192 200
193 private void CloudUpdate() 201 private void CloudUpdate()
194 { 202 {
195 if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready || (m_cloudDensity == 0)) 203 if ((!m_ready || m_cloudDensity == 0 || (m_frame++ % m_frameUpdateRate) != 0))
196 { 204 {
197 return; 205 return;
198 } 206 }
199 UpdateCloudCover(); 207
208 if(Monitor.TryEnter(cloudlock))
209 {
210 m_busy = true;
211 Util.FireAndForget(delegate
212 {
213 try
214 {
215 lock(cloudlock)
216 {
217 UpdateCloudCover();
218 m_scene.ForEachClient(delegate(IClientAPI client)
219 {
220 client.SendCloudData(m_dataVersion, cloudCover);
221 });
222 }
223 }
224 finally
225 {
226 m_busy = false;
227 }
228 },
229 null, "CloudModuleUpdate");
230 Monitor.Exit(cloudlock);
231 }
200 } 232 }
201 233
202 public void CloudsToClient(IClientAPI client) 234 public void CloudsToClient(IClientAPI client)
203 { 235 {
204 if (m_ready) 236 if (m_ready)
205 { 237 {
206 client.SendCloudData(0, cloudCover); 238 lock(cloudlock)
239 client.SendCloudData(m_dataVersion, cloudCover);
207 } 240 }
208 } 241 }
209 242
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
index bc92582..95cf57d 100644
--- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
+++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
@@ -425,7 +425,7 @@ namespace OpenSim.Region.CoreModules
425 try 425 try
426 { 426 {
427 GenWind(); 427 GenWind();
428 m_scene.ForEachRootClient(delegate(IClientAPI client) 428 m_scene.ForEachClient(delegate(IClientAPI client)
429 { 429 {
430 client.SendWindData(m_dataVersion, windSpeeds); 430 client.SendWindData(m_dataVersion, windSpeeds);
431 }); 431 });