do the same for legacy clouds (still visible on older viewer ie singu 1.8.7). Fix clouds update. Send clouds and wind also to child agents.
parent
8d7f10e36b
commit
f5189b2cdd
|
@ -1390,11 +1390,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
/// Send the cloud matrix to the client
|
/// Send the cloud matrix to the client
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="windSpeeds">16x16 array of cloud densities</param>
|
/// <param name="windSpeeds">16x16 array of cloud densities</param>
|
||||||
|
/*
|
||||||
public virtual void SendCloudData(int version, float[] cloudDensity)
|
public virtual void SendCloudData(int version, float[] cloudDensity)
|
||||||
{
|
{
|
||||||
Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData");
|
Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// wind caching
|
// wind caching
|
||||||
private static int lastWindVersion = 0;
|
private static int lastWindVersion = 0;
|
||||||
private static List<LayerDataPacket> lastWindPackets = new List<LayerDataPacket>();
|
private static List<LayerDataPacket> lastWindPackets = new List<LayerDataPacket>();
|
||||||
|
@ -1445,30 +1446,53 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
OutPacket(pkt, ThrottleOutPacketType.Wind);
|
OutPacket(pkt, ThrottleOutPacketType.Wind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cloud caching
|
||||||
|
private static int lastCloudVersion = 0;
|
||||||
|
private static List<LayerDataPacket> lastCloudPackets = new List<LayerDataPacket>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send cloud layer information to the client.
|
/// Send cloud layer information to the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="o"></param>
|
/// <param name="o"></param>
|
||||||
private void DoSendCloudData(object o)
|
// private void DoSendCloudData(object o)
|
||||||
|
public virtual void SendCloudData(int version, float[] cloudDensity)
|
||||||
{
|
{
|
||||||
float[] cloudCover = (float[])o;
|
// float[] cloudDensity = (float[])o;
|
||||||
TerrainPatch[] patches = new TerrainPatch[1];
|
bool isNewData;
|
||||||
patches[0] = new TerrainPatch();
|
lock(lastCloudPackets)
|
||||||
patches[0].Data = new float[16 * 16];
|
isNewData = lastCloudVersion != version;
|
||||||
|
|
||||||
for (int y = 0; y < 16; y++)
|
if(isNewData)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < 16; x++)
|
TerrainPatch[] patches = new TerrainPatch[1];
|
||||||
|
patches[0] = new TerrainPatch();
|
||||||
|
patches[0].Data = new float[16 * 16];
|
||||||
|
|
||||||
|
for (int y = 0; y < 16; y++)
|
||||||
{
|
{
|
||||||
patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
|
for (int x = 0; x < 16; x++)
|
||||||
|
{
|
||||||
|
patches[0].Data[y * 16 + x] = cloudDensity[y * 16 + x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// neither we or viewers have extended clouds
|
||||||
|
byte layerType = (byte)TerrainPatch.LayerType.Cloud;
|
||||||
|
|
||||||
|
LayerDataPacket layerpack =
|
||||||
|
OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(
|
||||||
|
patches, layerType);
|
||||||
|
layerpack.Header.Zerocoded = true;
|
||||||
|
lock(lastCloudPackets)
|
||||||
|
{
|
||||||
|
lastCloudPackets.Clear();
|
||||||
|
lastCloudPackets.Add(layerpack);
|
||||||
|
lastCloudVersion = version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// neither we or viewers have extended clouds
|
|
||||||
byte layerType = (byte)TerrainPatch.LayerType.Cloud;
|
|
||||||
|
|
||||||
LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(patches, layerType);
|
lock(lastCloudPackets)
|
||||||
layerpack.Header.Zerocoded = true;
|
foreach(LayerDataPacket pkt in lastCloudPackets)
|
||||||
OutPacket(layerpack, ThrottleOutPacketType.Cloud);
|
OutPacket(pkt, ThrottleOutPacketType.Cloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
using Mono.Addins;
|
using Mono.Addins;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
@ -49,6 +50,10 @@ namespace OpenSim.Region.CoreModules.World
|
||||||
private bool m_enabled = false;
|
private bool m_enabled = false;
|
||||||
private float m_cloudDensity = 1.0F;
|
private float m_cloudDensity = 1.0F;
|
||||||
private float[] cloudCover = new float[16 * 16];
|
private float[] cloudCover = new float[16 * 16];
|
||||||
|
private int m_dataVersion;
|
||||||
|
private bool m_busy;
|
||||||
|
private object cloudlock = new object();
|
||||||
|
|
||||||
|
|
||||||
public void Initialise(IConfigSource config)
|
public void Initialise(IConfigSource config)
|
||||||
{
|
{
|
||||||
|
@ -70,11 +75,13 @@ namespace OpenSim.Region.CoreModules.World
|
||||||
|
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
|
|
||||||
scene.EventManager.OnNewClient += CloudsToClient;
|
|
||||||
scene.RegisterModuleInterface<ICloudModule>(this);
|
scene.RegisterModuleInterface<ICloudModule>(this);
|
||||||
scene.EventManager.OnFrame += CloudUpdate;
|
|
||||||
|
|
||||||
GenerateCloudCover();
|
GenerateCloudCover();
|
||||||
|
m_dataVersion = (int)m_scene.AllocateLocalId();
|
||||||
|
|
||||||
|
scene.EventManager.OnNewClient += CloudsToClient;
|
||||||
|
scene.EventManager.OnFrame += CloudUpdate;
|
||||||
|
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +96,6 @@ namespace OpenSim.Region.CoreModules.World
|
||||||
m_scene.EventManager.OnNewClient -= CloudsToClient;
|
m_scene.EventManager.OnNewClient -= CloudsToClient;
|
||||||
m_scene.EventManager.OnFrame -= CloudUpdate;
|
m_scene.EventManager.OnFrame -= CloudUpdate;
|
||||||
m_scene.UnregisterModuleInterface<ICloudModule>(this);
|
m_scene.UnregisterModuleInterface<ICloudModule>(this);
|
||||||
|
|
||||||
m_scene = null;
|
m_scene = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +133,8 @@ namespace OpenSim.Region.CoreModules.World
|
||||||
|
|
||||||
if (cloudCover != null)
|
if (cloudCover != null)
|
||||||
{
|
{
|
||||||
cover = cloudCover[y * 16 + x];
|
lock(cloudlock)
|
||||||
|
cover = cloudCover[y * 16 + x];
|
||||||
}
|
}
|
||||||
|
|
||||||
return cover;
|
return cover;
|
||||||
|
@ -188,22 +195,48 @@ namespace OpenSim.Region.CoreModules.World
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Array.Copy(newCover, cloudCover, 16 * 16);
|
Array.Copy(newCover, cloudCover, 16 * 16);
|
||||||
|
m_dataVersion++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloudUpdate()
|
private void CloudUpdate()
|
||||||
{
|
{
|
||||||
if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready || (m_cloudDensity == 0))
|
if ((!m_ready || m_cloudDensity == 0 || (m_frame++ % m_frameUpdateRate) != 0))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UpdateCloudCover();
|
|
||||||
|
if(Monitor.TryEnter(cloudlock))
|
||||||
|
{
|
||||||
|
m_busy = true;
|
||||||
|
Util.FireAndForget(delegate
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lock(cloudlock)
|
||||||
|
{
|
||||||
|
UpdateCloudCover();
|
||||||
|
m_scene.ForEachClient(delegate(IClientAPI client)
|
||||||
|
{
|
||||||
|
client.SendCloudData(m_dataVersion, cloudCover);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
m_busy = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
null, "CloudModuleUpdate");
|
||||||
|
Monitor.Exit(cloudlock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CloudsToClient(IClientAPI client)
|
public void CloudsToClient(IClientAPI client)
|
||||||
{
|
{
|
||||||
if (m_ready)
|
if (m_ready)
|
||||||
{
|
{
|
||||||
client.SendCloudData(0, cloudCover);
|
lock(cloudlock)
|
||||||
|
client.SendCloudData(m_dataVersion, cloudCover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -425,7 +425,7 @@ namespace OpenSim.Region.CoreModules
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GenWind();
|
GenWind();
|
||||||
m_scene.ForEachRootClient(delegate(IClientAPI client)
|
m_scene.ForEachClient(delegate(IClientAPI client)
|
||||||
{
|
{
|
||||||
client.SendWindData(m_dataVersion, windSpeeds);
|
client.SendWindData(m_dataVersion, windSpeeds);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue