cache wind compressed data so cpu burning compression is only done after a change. Not happy with version scheme for several regions on same instance, but should be ok for now
parent
a6df626868
commit
8d7f10e36b
|
@ -1395,6 +1395,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData");
|
Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wind caching
|
||||||
|
private static int lastWindVersion = 0;
|
||||||
|
private static List<LayerDataPacket> lastWindPackets = new List<LayerDataPacket>();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Send wind layer information to the client.
|
/// Send wind layer information to the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1403,6 +1408,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
public virtual void SendWindData(int version, Vector2[] windSpeeds)
|
public virtual void SendWindData(int version, Vector2[] windSpeeds)
|
||||||
{
|
{
|
||||||
// Vector2[] windSpeeds = (Vector2[])o;
|
// Vector2[] windSpeeds = (Vector2[])o;
|
||||||
|
|
||||||
|
bool isNewData;
|
||||||
|
lock(lastWindPackets)
|
||||||
|
isNewData = lastWindVersion != version;
|
||||||
|
|
||||||
|
if(isNewData)
|
||||||
|
{
|
||||||
TerrainPatch[] patches = new TerrainPatch[2];
|
TerrainPatch[] patches = new TerrainPatch[2];
|
||||||
patches[0] = new TerrainPatch { Data = new float[16 * 16] };
|
patches[0] = new TerrainPatch { Data = new float[16 * 16] };
|
||||||
patches[1] = new TerrainPatch { Data = new float[16 * 16] };
|
patches[1] = new TerrainPatch { Data = new float[16 * 16] };
|
||||||
|
@ -1416,9 +1428,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// neither we or viewers have extended wind
|
// neither we or viewers have extended wind
|
||||||
byte layerType = (byte)TerrainPatch.LayerType.Wind;
|
byte layerType = (byte)TerrainPatch.LayerType.Wind;
|
||||||
|
|
||||||
LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(patches, layerType);
|
LayerDataPacket layerpack =
|
||||||
|
OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(
|
||||||
|
patches, layerType);
|
||||||
layerpack.Header.Zerocoded = true;
|
layerpack.Header.Zerocoded = true;
|
||||||
OutPacket(layerpack, ThrottleOutPacketType.Wind);
|
lock(lastWindPackets)
|
||||||
|
{
|
||||||
|
lastWindPackets.Clear();
|
||||||
|
lastWindPackets.Add(layerpack);
|
||||||
|
lastWindVersion = version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lock(lastWindPackets)
|
||||||
|
foreach(LayerDataPacket pkt in lastWindPackets)
|
||||||
|
OutPacket(pkt, ThrottleOutPacketType.Wind);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -46,7 +46,8 @@ namespace OpenSim.Region.CoreModules
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private uint m_frame = 0;
|
private uint m_frame = 0;
|
||||||
private uint m_frameLastUpdateClientArray = 0;
|
private int m_dataVersion = 0;
|
||||||
|
private int m_regionID = 0;
|
||||||
private int m_frameUpdateRate = 150;
|
private int m_frameUpdateRate = 150;
|
||||||
//private Random m_rndnums = new Random(Environment.TickCount);
|
//private Random m_rndnums = new Random(Environment.TickCount);
|
||||||
private Scene m_scene = null;
|
private Scene m_scene = null;
|
||||||
|
@ -97,7 +98,6 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
m_scene = scene;
|
m_scene = scene;
|
||||||
m_frame = 0;
|
m_frame = 0;
|
||||||
|
|
||||||
// Register all the Wind Model Plug-ins
|
// Register all the Wind Model Plug-ins
|
||||||
foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
|
foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
|
||||||
{
|
{
|
||||||
|
@ -119,7 +119,6 @@ namespace OpenSim.Region.CoreModules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if the plug-in wasn't found, default to no wind.
|
// if the plug-in wasn't found, default to no wind.
|
||||||
if (m_activeWindPlugin == null)
|
if (m_activeWindPlugin == null)
|
||||||
{
|
{
|
||||||
|
@ -155,14 +154,14 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
// Register event handlers for when Avatars enter the region, and frame ticks
|
// Register event handlers for when Avatars enter the region, and frame ticks
|
||||||
m_scene.EventManager.OnFrame += WindUpdate;
|
m_scene.EventManager.OnFrame += WindUpdate;
|
||||||
// m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;
|
|
||||||
|
|
||||||
// Register the wind module
|
// Register the wind module
|
||||||
m_scene.RegisterModuleInterface<IWindModule>(this);
|
m_scene.RegisterModuleInterface<IWindModule>(this);
|
||||||
|
|
||||||
// Generate initial wind values
|
// Generate initial wind values
|
||||||
GenWind();
|
GenWind();
|
||||||
|
// hopefully this will not be the same for all regions on same instance
|
||||||
|
m_dataVersion = (int)m_scene.AllocateLocalId();
|
||||||
// Mark Module Ready for duty
|
// Mark Module Ready for duty
|
||||||
m_ready = true;
|
m_ready = true;
|
||||||
}
|
}
|
||||||
|
@ -425,12 +424,10 @@ namespace OpenSim.Region.CoreModules
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(GenWind())
|
GenWind();
|
||||||
windSpeeds = m_activeWindPlugin.WindLLClientArray();
|
|
||||||
|
|
||||||
m_scene.ForEachRootClient(delegate(IClientAPI client)
|
m_scene.ForEachRootClient(delegate(IClientAPI client)
|
||||||
{
|
{
|
||||||
client.SendWindData(0, windSpeeds);
|
client.SendWindData(m_dataVersion, windSpeeds);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -441,26 +438,7 @@ namespace OpenSim.Region.CoreModules
|
||||||
},
|
},
|
||||||
null, "WindModuleUpdate");
|
null, "WindModuleUpdate");
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
private void SendWindAllClients()
|
|
||||||
{
|
|
||||||
if (!m_ready || m_scene.GetRootAgentCount() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Ask wind plugin to generate a LL wind array to be cached locally
|
|
||||||
// Try not to update this too often, as it may involve array copies
|
|
||||||
if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate))
|
|
||||||
{
|
|
||||||
windSpeeds = m_activeWindPlugin.WindLLClientArray();
|
|
||||||
m_frameLastUpdateClientArray = m_frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_scene.ForEachRootClient(delegate(IClientAPI client)
|
|
||||||
{
|
|
||||||
client.SendWindData(windSpeeds);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculate new wind
|
/// Calculate new wind
|
||||||
/// returns false if no change
|
/// returns false if no change
|
||||||
|
@ -468,10 +446,11 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
private bool GenWind()
|
private bool GenWind()
|
||||||
{
|
{
|
||||||
if (m_activeWindPlugin != null)
|
if (m_activeWindPlugin != null && m_activeWindPlugin.WindUpdate(m_frame))
|
||||||
{
|
{
|
||||||
// Tell Wind Plugin to update it's wind data
|
windSpeeds = m_activeWindPlugin.WindLLClientArray();
|
||||||
return m_activeWindPlugin.WindUpdate(m_frame);
|
m_dataVersion++;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue