diff options
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 48 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Wind/WindModule.cs | 47 |
2 files changed, 49 insertions, 46 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 15f1004..5f8d8f1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -1395,6 +1395,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1395 | Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData"); | 1395 | Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData"); |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | // wind caching | ||
1399 | private static int lastWindVersion = 0; | ||
1400 | private static List<LayerDataPacket> lastWindPackets = new List<LayerDataPacket>(); | ||
1401 | |||
1402 | |||
1398 | /// <summary> | 1403 | /// <summary> |
1399 | /// Send wind layer information to the client. | 1404 | /// Send wind layer information to the client. |
1400 | /// </summary> | 1405 | /// </summary> |
@@ -1403,22 +1408,41 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1403 | public virtual void SendWindData(int version, Vector2[] windSpeeds) | 1408 | public virtual void SendWindData(int version, Vector2[] windSpeeds) |
1404 | { | 1409 | { |
1405 | // Vector2[] windSpeeds = (Vector2[])o; | 1410 | // Vector2[] windSpeeds = (Vector2[])o; |
1406 | TerrainPatch[] patches = new TerrainPatch[2]; | 1411 | |
1407 | patches[0] = new TerrainPatch { Data = new float[16 * 16] }; | 1412 | bool isNewData; |
1408 | patches[1] = new TerrainPatch { Data = new float[16 * 16] }; | 1413 | lock(lastWindPackets) |
1414 | isNewData = lastWindVersion != version; | ||
1409 | 1415 | ||
1410 | for (int x = 0; x < 16 * 16; x++) | 1416 | if(isNewData) |
1411 | { | 1417 | { |
1412 | patches[0].Data[x] = windSpeeds[x].X; | 1418 | TerrainPatch[] patches = new TerrainPatch[2]; |
1413 | patches[1].Data[x] = windSpeeds[x].Y; | 1419 | patches[0] = new TerrainPatch { Data = new float[16 * 16] }; |
1414 | } | 1420 | patches[1] = new TerrainPatch { Data = new float[16 * 16] }; |
1415 | 1421 | ||
1416 | // neither we or viewers have extended wind | 1422 | for (int x = 0; x < 16 * 16; x++) |
1417 | byte layerType = (byte)TerrainPatch.LayerType.Wind; | 1423 | { |
1424 | patches[0].Data[x] = windSpeeds[x].X; | ||
1425 | patches[1].Data[x] = windSpeeds[x].Y; | ||
1426 | } | ||
1418 | 1427 | ||
1419 | LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(patches, layerType); | 1428 | // neither we or viewers have extended wind |
1420 | layerpack.Header.Zerocoded = true; | 1429 | byte layerType = (byte)TerrainPatch.LayerType.Wind; |
1421 | OutPacket(layerpack, ThrottleOutPacketType.Wind); | 1430 | |
1431 | LayerDataPacket layerpack = | ||
1432 | OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize( | ||
1433 | patches, layerType); | ||
1434 | layerpack.Header.Zerocoded = true; | ||
1435 | lock(lastWindPackets) | ||
1436 | { | ||
1437 | lastWindPackets.Clear(); | ||
1438 | lastWindPackets.Add(layerpack); | ||
1439 | lastWindVersion = version; | ||
1440 | } | ||
1441 | } | ||
1442 | |||
1443 | lock(lastWindPackets) | ||
1444 | foreach(LayerDataPacket pkt in lastWindPackets) | ||
1445 | OutPacket(pkt, ThrottleOutPacketType.Wind); | ||
1422 | } | 1446 | } |
1423 | 1447 | ||
1424 | /// <summary> | 1448 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index f1de0bc..bc92582 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |||
@@ -46,7 +46,8 @@ 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; |
@@ -97,7 +98,6 @@ namespace OpenSim.Region.CoreModules | |||
97 | 98 | ||
98 | m_scene = scene; | 99 | m_scene = scene; |
99 | m_frame = 0; | 100 | m_frame = 0; |
100 | |||
101 | // Register all the Wind Model Plug-ins | 101 | // Register all the Wind Model Plug-ins |
102 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) | 102 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) |
103 | { | 103 | { |
@@ -119,7 +119,6 @@ namespace OpenSim.Region.CoreModules | |||
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | |||
123 | // if the plug-in wasn't found, default to no wind. | 122 | // if the plug-in wasn't found, default to no wind. |
124 | if (m_activeWindPlugin == null) | 123 | if (m_activeWindPlugin == null) |
125 | { | 124 | { |
@@ -155,14 +154,14 @@ namespace OpenSim.Region.CoreModules | |||
155 | 154 | ||
156 | // 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 |
157 | m_scene.EventManager.OnFrame += WindUpdate; | 156 | m_scene.EventManager.OnFrame += WindUpdate; |
158 | // m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion; | ||
159 | 157 | ||
160 | // Register the wind module | 158 | // Register the wind module |
161 | m_scene.RegisterModuleInterface<IWindModule>(this); | 159 | m_scene.RegisterModuleInterface<IWindModule>(this); |
162 | 160 | ||
163 | // Generate initial wind values | 161 | // Generate initial wind values |
164 | GenWind(); | 162 | GenWind(); |
165 | 163 | // hopefully this will not be the same for all regions on same instance | |
164 | m_dataVersion = (int)m_scene.AllocateLocalId(); | ||
166 | // Mark Module Ready for duty | 165 | // Mark Module Ready for duty |
167 | m_ready = true; | 166 | m_ready = true; |
168 | } | 167 | } |
@@ -425,13 +424,11 @@ namespace OpenSim.Region.CoreModules | |||
425 | { | 424 | { |
426 | try | 425 | try |
427 | { | 426 | { |
428 | if(GenWind()) | 427 | GenWind(); |
429 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | 428 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
430 | 429 | { | |
431 | m_scene.ForEachRootClient(delegate(IClientAPI client) | 430 | client.SendWindData(m_dataVersion, windSpeeds); |
432 | { | 431 | }); |
433 | client.SendWindData(0, windSpeeds); | ||
434 | }); | ||
435 | 432 | ||
436 | } | 433 | } |
437 | finally | 434 | finally |
@@ -441,26 +438,7 @@ namespace OpenSim.Region.CoreModules | |||
441 | }, | 438 | }, |
442 | null, "WindModuleUpdate"); | 439 | null, "WindModuleUpdate"); |
443 | } | 440 | } |
444 | /* | ||
445 | private void SendWindAllClients() | ||
446 | { | ||
447 | if (!m_ready || m_scene.GetRootAgentCount() == 0) | ||
448 | return; | ||
449 | 441 | ||
450 | // Ask wind plugin to generate a LL wind array to be cached locally | ||
451 | // Try not to update this too often, as it may involve array copies | ||
452 | if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate)) | ||
453 | { | ||
454 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); | ||
455 | m_frameLastUpdateClientArray = m_frame; | ||
456 | } | ||
457 | |||
458 | m_scene.ForEachRootClient(delegate(IClientAPI client) | ||
459 | { | ||
460 | client.SendWindData(windSpeeds); | ||
461 | }); | ||
462 | } | ||
463 | */ | ||
464 | /// <summary> | 442 | /// <summary> |
465 | /// Calculate new wind | 443 | /// Calculate new wind |
466 | /// returns false if no change | 444 | /// returns false if no change |
@@ -468,10 +446,11 @@ namespace OpenSim.Region.CoreModules | |||
468 | 446 | ||
469 | private bool GenWind() | 447 | private bool GenWind() |
470 | { | 448 | { |
471 | if (m_activeWindPlugin != null) | 449 | if (m_activeWindPlugin != null && m_activeWindPlugin.WindUpdate(m_frame)) |
472 | { | 450 | { |
473 | // Tell Wind Plugin to update it's wind data | 451 | windSpeeds = m_activeWindPlugin.WindLLClientArray(); |
474 | return m_activeWindPlugin.WindUpdate(m_frame); | 452 | m_dataVersion++; |
453 | return true; | ||
475 | } | 454 | } |
476 | return false; | 455 | return false; |
477 | } | 456 | } |